コード例 #1
0
ファイル: timer.cpp プロジェクト: paulftw/vpinball
void Timer::SetDefaults(bool fromMouseClick)
{
	HRESULT hr;
	int iTmp;

	hr = GetRegInt("DefaultProps\\Timer","TimerEnabled", &iTmp);
	if ((hr == S_OK) && fromMouseClick)
		m_d.m_tdr.m_fTimerEnabled = iTmp == 0 ? false : true;
	else
		m_d.m_tdr.m_fTimerEnabled = true;
	
	hr = GetRegInt("DefaultProps\\Timer","TimerInterval", &iTmp);
	if ((hr == S_OK) && fromMouseClick)
		m_d.m_tdr.m_TimerInterval = iTmp;
	else
		m_d.m_tdr.m_TimerInterval = 100;
}
コード例 #2
0
ファイル: xaudplayer.cpp プロジェクト: djrobx/vpinballx
XAudPlayer::XAudPlayer()
{
   m_stream = NULL;

#ifdef DEBUG_NO_SOUND
   return;
#endif

   if (!bass_init)
   {
      int DSidx;
      const HRESULT hr = GetRegInt("Player", "SoundDeviceBG", &DSidx);
      if (hr != S_OK)
          DSidx = -1;

      // now match the Direct Sound device with the BASS device (by name)
      int BASSidx = -1;
      if (DSidx != -1)
      {
          DSAudioDevices DSads;
          if (!FAILED(DirectSoundEnumerate(DSEnumCallBack, &DSads)))
          {
              if ((unsigned int)DSidx >= DSads.size() || DSads[DSidx]->guid != NULL) // primary device has guid NULL, so use BASSidx = -1 in that case
              {
                  BASS_DEVICEINFO info;
                  for (int i = 1; BASS_GetDeviceInfo(i, &info); i++) // 0 = no sound/no device
                      if (info.flags & BASS_DEVICE_ENABLED) // device must be enabled
                      if (strcmp(info.name, DSads[DSidx]->description.c_str()) == 0)
                      {
                          BASSidx = i;
                          break;
                      }
              }

              for (size_t i = 0; i < DSads.size(); i++)
                  delete DSads[i];
          }
      }

      if (!BASS_Init(BASSidx, 44100, 0, g_pvp->m_hwnd, NULL)) // note that sample rate is usually ignored and set depending on the input/file automatically
      {
         char bla[128];
         sprintf_s(bla, "BASS music/sound library initialization error %d", BASS_ErrorGetCode());
         MessageBox(g_pvp->m_hwnd, bla, "Error", MB_ICONERROR);
      }
      bass_init = true;
   }
}
コード例 #3
0
ファイル: log.c プロジェクト: twonds/chesspark
void Log_Write(int level, const char *v, ...)
{
	va_list ap;
	FILE *plogfile;
	char initialbuf[8192], *buf;
	int buflen;
	int needed;

	if (nolog)
	{
		return;
	}

	if (!GetRegInt("ExtendedLogging"))
	{
		return;
	}

	/* set no log so we don't cause a loop */
	nolog = 1;

	buf = initialbuf;
	buflen = 8192;

	va_start(ap, v);
	needed = xmpp_vsnprintf(buf, buflen, v, ap);
	va_end(ap);

	if (needed > buflen)
	{
		buflen = needed + 1;
		buf = malloc(buflen);
		va_start(ap, v);
		xmpp_vsnprintf(buf, buflen, v, ap);
		va_end(ap);
	}

	Log_WriteString(level, buf);

	if (buf != initialbuf)
	{
		free(buf);
	}

	nolog = 0;
}
コード例 #4
0
ファイル: fileicon.c プロジェクト: mingpen/OpenNT
//
// get g_MaxIcons from the registry, returning TRUE if it has changed
//
BOOL QueryNewMaxIcons(void)
{
    HKEY hkey;
    int MaxIcons = DEF_MAX_ICONS;

    if (RegOpenKey(HKEY_LOCAL_MACHINE, REGSTR_PATH_EXPLORER, &hkey) == 0)
    {
        MaxIcons = GetRegInt(hkey, g_szMaxCachedIcons, MaxIcons);
        RegCloseKey(hkey);

        if (MaxIcons < 0)
            MaxIcons = DEF_MAX_ICONS;
    }

    if (g_MaxIcons != MaxIcons)
    {
        g_MaxIcons = MaxIcons;
        return TRUE;
    }

    return FALSE;
}
コード例 #5
0
ファイル: flasher.cpp プロジェクト: djrobx/vpinballx
void Flasher::SetDefaults(bool fromMouseClick)
{
   HRESULT hr;
   float fTmp;
   int iTmp;

   hr = GetRegStringAsFloat("DefaultProps\\Flasher", "Height", &fTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_height = fTmp;
   else
      m_d.m_height = 50.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Flasher", "RotX", &fTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_rotX = fTmp;
   else
      m_d.m_rotX = 0.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Flasher", "RotY", &fTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_rotY = fTmp;
   else
      m_d.m_rotY = 0.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Flasher", "RotZ", &fTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_rotZ = fTmp;
   else
      m_d.m_rotZ = 0.0f;

   hr = GetRegInt("DefaultProps\\Flasher", "Color", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_color = iTmp;
   else
      m_d.m_color = RGB(50, 200, 50);

   hr = GetRegInt("DefaultProps\\Flasher", "TimerEnabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_tdr.m_fTimerEnabled = iTmp == 0 ? false : true;
   else
      m_d.m_tdr.m_fTimerEnabled = false;

   hr = GetRegInt("DefaultProps\\Flasher", "TimerInterval", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_tdr.m_TimerInterval = iTmp;
   else
      m_d.m_tdr.m_TimerInterval = 100;

   hr = GetRegString("DefaultProps\\Flasher", "ImageA", m_d.m_szImageA, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      m_d.m_szImageA[0] = 0;

   hr = GetRegString("DefaultProps\\Flasher", "ImageB", m_d.m_szImageB, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      m_d.m_szImageB[0] = 0;

   hr = GetRegInt("DefaultProps\\Flasher", "Opacity", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fAlpha = iTmp;
   else
      m_d.m_fAlpha = 100;

   m_d.m_intensity_scale = 1.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Flasher", "ModulateVsAdd", &fTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_modulate_vs_add = fTmp;
   else
      m_d.m_modulate_vs_add = 0.9f;

   hr = GetRegInt("DefaultProps\\Flasher", "FilterAmount", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fFilterAmount = iTmp;
   else
      m_d.m_fFilterAmount = 100;

   hr = GetRegInt("DefaultProps\\Flasher", "Visible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_IsVisible = iTmp == 0 ? false : true;
   else
      m_d.m_IsVisible = true;

   hr = GetRegInt("DefaultProps\\Flasher", "AddBlend", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fAddBlend = iTmp == 0 ? false : true;
   else
      m_d.m_fAddBlend = false;

   hr = GetRegInt("DefaultProps\\Flasher", "DMD", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
	   m_d.m_IsDMD = iTmp == 0 ? false : true;
   else
	   m_d.m_IsDMD = false;

   hr = GetRegInt("DefaultProps\\Flasher", "DisplayTexture", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fDisplayTexture = (iTmp == 0) ? false : true;
   else
      m_d.m_fDisplayTexture = false;

   m_d.m_imagealignment = fromMouseClick ? (RampImageAlignment)GetRegIntWithDefault("DefaultProps\\Flasher", "ImageMode", ImageModeWrap) : ImageModeWrap;
   m_d.m_filter = fromMouseClick ? (Filters)GetRegIntWithDefault("DefaultProps\\Flasher", "Filter", Filter_Overlay) : Filter_Overlay;
}
コード例 #6
0
ファイル: fileicon.c プロジェクト: mingpen/OpenNT
//
// Initializes shared resources for Shell_GetIconIndex and others
//
BOOL WINAPI FileIconInit( BOOL fRestoreCache )
{
    BOOL fNotify = FALSE;
    BOOL fInit = FALSE;
    HKEY hkey;
    int cxIcon, cyIcon, ccIcon, cxSmIcon, cySmIcon, res;

    QueryNewMaxIcons(); // in case the size of the icon cache has changed

    ccIcon   = 0;
    cxIcon   = GetSystemMetrics(SM_CXICON);
    cyIcon   = GetSystemMetrics(SM_CYICON);
////cxSmIcon = GetSystemMetrics(SM_CXSMICON);
////cySmIcon = GetSystemMetrics(SM_CYSMICON);
    cxSmIcon = GetSystemMetrics(SM_CXICON) / 2;
    cySmIcon = GetSystemMetrics(SM_CYICON) / 2;

    //
    //  get the user prefered icon size (and color depth) from the
    //  registry.
    //
    if (RegOpenKey(HKEY_CURRENT_USER, REGSTR_PATH_METRICS, &hkey) == 0)
    {
        cxIcon   = GetRegInt(hkey, g_szShellIconSize, cxIcon);
        cxSmIcon = GetRegInt(hkey, g_szShellSmallIconSize, cxSmIcon);
        ccIcon   = GetRegInt(hkey, g_szShellIconDepth, ccIcon);

        cyIcon   = cxIcon;      // icons are always square
        cySmIcon = cxSmIcon;

        RegCloseKey(hkey);
    }

    res = (int)GetCurColorRes();

    if (ccIcon > res)
        ccIcon = 0;

    if (res <= 8)
        ccIcon = 0; // wouldn't have worked anyway

#if 0
    //
    // use a 8bpp imagelist on a HiColor device iff we will
    // be stretching icons.
    //
    if (res > 8 && ccIcon == 0 && (cxIcon != GetSystemMetrics(SM_CXICON) ||
         cxSmIcon != GetSystemMetrics(SM_CXICON)/2))
    {
        ccIcon = 8;
    }
#endif

    ENTERCRITICAL

    //
    // if we already have a icon cache make sure it is the right size etc.
    //
    if (himlIcons)
    {
        // cant change this while running sorry.
        ccIcon = g_ccIcon;

        if (g_cxIcon   == cxIcon &&
            g_cyIcon   == cyIcon &&
            g_cxSmIcon == cxSmIcon &&
            g_cySmIcon == cySmIcon &&
            g_ccIcon   == ccIcon)
        {
            fInit = TRUE;
            goto Exit;
        }

        FlushIconCache();
        FlushFileClass();

        // make sure every one updates.
        fNotify = TRUE;
    }

    g_cxIcon   = cxIcon;
    g_cyIcon   = cyIcon;
    g_ccIcon   = ccIcon;
    g_cxSmIcon = cxSmIcon;
    g_cySmIcon = cySmIcon;

    if (res > 4 && g_ccIcon <= 4)
        g_lrFlags = LR_VGACOLOR;
    else
        g_lrFlags = 0;

    DebugMsg(DM_TRACE, TEXT("IconCache: Size=%dx%d SmSize=%dx%d Bpp=%d"), cxIcon, cyIcon, cxSmIcon, cySmIcon, (ccIcon&ILC_COLOR));

    if (g_iLastSysIcon == 0)        // Keep track of which icons are perm.
    {
        if (fRestoreCache)
            g_iLastSysIcon = II_LASTSYSICON;
        else
            g_iLastSysIcon = (II_OVERLAYLAST - II_OVERLAYFIRST) + 1;
    }

    // try to restore the icon cache (if we have not loaded it yet)
    if (himlIcons != NULL || !fRestoreCache || !_IconCacheRestore(g_cxIcon, g_cyIcon, g_cxSmIcon, g_cySmIcon, g_ccIcon))
    {
        if (!_ShellImageListInit(g_cxIcon, g_cyIcon, g_cxSmIcon, g_cySmIcon, g_ccIcon, fRestoreCache))
            goto Exit;
    }

    fInit = TRUE;

Exit:
    LEAVECRITICAL

    if (fInit && fNotify)
    {
        DebugMsg(DM_TRACE, TEXT("IconCache: icon size has changed sending SHCNE_UPDATEIMAGE(-1)..."));
        SHChangeNotify(SHCNE_UPDATEIMAGE, SHCNF_DWORD, (LPCVOID)-1, NULL);
    }

    return fInit;
}
コード例 #7
0
// set the defaults for the objects persistent data (m_d.*) in case this
// is a new instance of this object or there is a backwards compatability
// issue (old version of object doesn't contain all the needed fields)
//
void DispReel::SetDefaults(bool fromMouseClick)
{
   // object is only available on the backglass
   m_fBackglass = true;

   // set all the Data defaults
   HRESULT hr;
   float fTmp;
   int iTmp;

   hr = GetRegString("DefaultProps\\Ramp", "Image", m_d.m_szImage, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      m_d.m_szImage[0] = 0;

   hr = GetRegString("DefaultProps\\Ramp", "Sound", m_d.m_szSound, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      m_d.m_szSound[0] = 0;

   hr = GetRegInt("DefaultProps\\EMReel", "UseImageGrid", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fUseImageGrid = iTmp == 0 ? false : true;
   else
      m_d.m_fUseImageGrid = false;

   hr = GetRegInt("DefaultProps\\EMReel", "Visible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fVisible = true;

   hr = GetRegInt("DefaultProps\\EMReel", "ImagesPerRow", &iTmp);
   m_d.m_imagesPerGridRow = (hr == S_OK) && fromMouseClick ? iTmp : 1;

   hr = GetRegInt("DefaultProps\\EMReel", "Transparent", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fTransparent = iTmp == 0 ? false : true;
   else
      m_d.m_fTransparent = false;

   hr = GetRegInt("DefaultProps\\EMReel", "ReelCount", &iTmp);
   m_d.m_reelcount = (hr == S_OK) && fromMouseClick ? iTmp : 5;

   hr = GetRegStringAsFloat("DefaultProps\\EMReel", "Width", &fTmp);
   m_d.m_width = (hr == S_OK) && fromMouseClick ? fTmp : 30.0f;

   hr = GetRegStringAsFloat("DefaultProps\\EMReel", "Height", &fTmp);
   m_d.m_height = (hr == S_OK) && fromMouseClick ? fTmp : 40.0f;

   hr = GetRegStringAsFloat("DefaultProps\\EMReel", "ReelSpacing", &fTmp);
   m_d.m_reelspacing = (hr == S_OK) && fromMouseClick ? fTmp : 4.0f;

   hr = GetRegStringAsFloat("DefaultProps\\EMReel", "MotorSteps", &fTmp);
   m_d.m_motorsteps = (hr == S_OK) && fromMouseClick ? fTmp : 2.0f;

   hr = GetRegInt("DefaultProps\\EMReel", "DigitRange", &iTmp);
   m_d.m_digitrange = (hr == S_OK) && fromMouseClick ? iTmp : 9;

   hr = GetRegInt("DefaultProps\\EMReel", "UpdateInterval", &iTmp);
   m_d.m_updateinterval = (hr == S_OK) && fromMouseClick ? iTmp : 50;

   hr = GetRegInt("DefaultProps\\EMReel", "BackColor", &iTmp);
   m_d.m_backcolor = (hr == S_OK) && fromMouseClick ? iTmp : RGB(64, 64, 64);

   hr = GetRegInt("DefaultProps\\EMReel", "TimerEnabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_tdr.m_fTimerEnabled = iTmp == 0 ? false : true;
   else
      m_d.m_tdr.m_fTimerEnabled = 0;

   hr = GetRegInt("DefaultProps\\EMReel", "TimerInterval", &iTmp);
   m_d.m_tdr.m_TimerInterval = (hr == S_OK) && fromMouseClick ? iTmp : 100;
}
コード例 #8
0
BOOL CApp::InitInstance()
{
	if(!CDCGFApp::InitInstance()) return FALSE;
	
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

/*
#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif
*/
	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("DEAD:CODE"));

	LoadStdProfileSettings(8);  // Load standard INI file options (including MRU)

	CDCGFStringTable::Init();

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CMultiDocTemplate* pDocTemplate;
	pDocTemplate = new CMultiDocTemplate(
		IDR_PROJECTYPE,
		RUNTIME_CLASS(CProjectDoc),
		RUNTIME_CLASS(CChildFrame), // custom MDI child frame
		RUNTIME_CLASS(CProjectView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Enable drag/drop open
	//m_pMainWnd->DragAcceptFiles();

	// This code replaces the MFC created menus with 
	// the Ownerdrawn versions 
	static UINT toolbars[]={
		IDR_MAINFRAME, IDR_TOOLBAR_2
	};	
	pDocTemplate->m_hMenuShared=pMainFrame->NewMenu(IDR_PROJECTYPE, toolbars, 2);
	pMainFrame->m_hMenuDefault=pMainFrame->NewDefaultMenu(IDR_MAINFRAME, toolbars, 2);
/*
	CDCGFStringTable::LocMenu(CMenu::FromHandle(pMainFrame->m_hMenuDefault));
	CDCGFStringTable::LocMenu(CMenu::FromHandle(pDocTemplate->m_hMenuShared));
*/
	// This simulates a window being opened if you don't have
	// a default window displayed at startup
	pMainFrame->OnUpdateFrameMenu(pMainFrame->m_hMenuDefault);


	// Enable DDE Execute open
	EnableShellOpen();
	RegisterShellFileTypes(FALSE);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	if(cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew)
		cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;


	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The main window has been initialized, so show and update it.
	pMainFrame->ShowWindow(SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();

	if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileNothing)
	{
		DoSomeNagging();

		if(GetRegInt(HKEY_CURRENT_USER, DCGF_TOOLS_REG_PATH, "AutoCheckUpdates", 1))
		{
			pMainFrame->CheckForUpdates(true);
		}
	}

	pMainFrame->UpdateMenuURL(pMainFrame->GetMenu());


	return TRUE;
}
コード例 #9
0
ファイル: main.cpp プロジェクト: djrobx/vpinballx
   virtual BOOL InitInstance() 
   { 
#ifdef CRASH_HANDLER
      rde::CrashHandler::Init();
#endif

      // disable auto-rotate on tablets
#if (WINVER <= 0x0601)
      SetDisplayAutoRotationPreferences = (pSDARP)GetProcAddress(GetModuleHandle(TEXT("user32.dll")),
         "SetDisplayAutoRotationPreferences");
      if (SetDisplayAutoRotationPreferences)
         SetDisplayAutoRotationPreferences(ORIENTATION_PREFERENCE_LANDSCAPE);
#else
      SetDisplayAutoRotationPreferences(ORIENTATION_PREFERENCE_LANDSCAPE);
#endif

      g_hinst = theInstance;
#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED)
      hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
#else
      hRes = CoInitialize(NULL);
#endif
      _ASSERTE(SUCCEEDED(hRes));
      _Module.Init(ObjectMap, theInstance, &LIBID_VPinballLib);

      fFile = false;
      fPlay = false;
      fPov = false;
      bRun = true;
      int nRet = 0;
      memset(szTableFileName, 0, _MAX_PATH);
      // Start VP with file dialog open and then also playing that one?
      int stos;
      HRESULT hr = GetRegInt("Editor", "SelectTableOnStart", &stos);
      if (hr != S_OK)
         stos = 1; // The default = on
      if (stos)
      {
         fFile = true;
         fPlay = true;
         fPov = false;
      }

      int nArgs;
      LPSTR *szArglist = CommandLineToArgvA(GetCommandLine(), &nArgs);

      for (int i = 0; i < nArgs; ++i)
      {
         if (lstrcmpi(szArglist[i], _T("-h")) == 0 || lstrcmpi(szArglist[i], _T("/h")) == 0
            || lstrcmpi(szArglist[i], _T("-Help")) == 0 || lstrcmpi(szArglist[i], _T("/Help")) == 0
            || lstrcmpi(szArglist[i], _T("-?")) == 0 || lstrcmpi(szArglist[i], _T("/?")) == 0)
         {
            ShowError("-UnregServer  Unregister VP functions\n-RegServer  Register VP functions\n\n-DisableTrueFullscreen  Force-disable True Fullscreen setting\n\n-Edit [filename]  load file into VP\n-Play [filename]  load and play file\n-Pov [filename]  load, export pov and close");
            bRun = false;
            break;
         }

         if (lstrcmpi(szArglist[i], _T("-UnregServer")) == 0 || lstrcmpi(szArglist[i], _T("/UnregServer")) == 0)
         {
            _Module.UpdateRegistryFromResource(IDR_VPINBALL, FALSE);
            nRet = _Module.UnregisterServer(TRUE);
            bRun = false;
            break;
         }
         if (lstrcmpi(szArglist[i], _T("-RegServer")) == 0 || lstrcmpi(szArglist[i], _T("/RegServer")) == 0)
         {
            _Module.UpdateRegistryFromResource(IDR_VPINBALL, TRUE);
            nRet = _Module.RegisterServer(TRUE);
            bRun = false;
            break;
         }

         disableTrueFullscreen |= (lstrcmpi(szArglist[i], _T("-DisableTrueFullscreen")) == 0 || lstrcmpi(szArglist[i], _T("/DisableTrueFullscreen")) == 0);

         const bool editfile = (lstrcmpi(szArglist[i], _T("-Edit")) == 0 || lstrcmpi(szArglist[i], _T("/Edit")) == 0);
         const bool playfile = (lstrcmpi(szArglist[i], _T("-Play")) == 0 || lstrcmpi(szArglist[i], _T("/Play")) == 0);
		 const bool povfile = (lstrcmpi(szArglist[i], _T("-Pov")) == 0 || lstrcmpi(szArglist[i], _T("/Pov")) == 0);
		 if ((editfile || playfile || povfile) && (i + 1 < nArgs))
         {
            fFile = true;
            fPlay = playfile;
			fPov = povfile;

            // Remove leading - or /
            char* filename;
            if ((szArglist[i + 1][0] == '-') || (szArglist[i + 1][0] == '/'))
               filename = szArglist[i + 1] + 1;
            else
               filename = szArglist[i + 1];

            // Remove " "
            if (filename[0] == '"') {
               strcpy_s(szTableFileName, filename + 1);
               szTableFileName[lstrlen(szTableFileName) - 1] = '\0';
            }
            else
               strcpy_s(szTableFileName, filename);

            // Add current path
            char szLoadDir[MAX_PATH];
            if (szTableFileName[1] != ':') {
               GetCurrentDirectory(MAX_PATH, szLoadDir);
               strcat_s(szLoadDir, "\\");
               strcat_s(szLoadDir, szTableFileName);
               strcpy_s(szTableFileName, szLoadDir);
            }
            else
               // Or set from table path
               if (playfile) {
                  PathFromFilename(szTableFileName, szLoadDir);
                  SetCurrentDirectory(szLoadDir);
               }

            if (playfile || povfile)
               VPinball::SetOpenMinimized();

            break;
         }
      }

      free(szArglist);

      // load and register VP type library for COM integration
      char szFileName[_MAX_PATH];
      if (GetModuleFileName(theInstance, szFileName, _MAX_PATH))
      {
         ITypeLib *ptl = NULL;
         MAKE_WIDEPTR_FROMANSI(wszFileName, szFileName);
         if (SUCCEEDED(LoadTypeLib(wszFileName, &ptl)))
         {
            // first try to register system-wide (if running as admin)
            hr = RegisterTypeLib(ptl, wszFileName, NULL);
            if (!SUCCEEDED(hr))
            {
               // if failed, register only for current user
               hr = RegisterTypeLibForUser(ptl, wszFileName, NULL);
               if (!SUCCEEDED(hr))
                  MessageBox(0, "Could not register type library. Try running Visual Pinball as administrator.", "Error", MB_ICONWARNING);
            }
            ptl->Release();
         }
         else
            MessageBox(0, "Could not load type library.", "Error", MB_ICONSTOP);
      }

      //SET_CRT_DEBUG_FIELD( _CRTDBG_LEAK_CHECK_DF );
      return TRUE;
   }
コード例 #10
0
void Bumper::SetDefaults(bool fromMouseClick)
{
   HRESULT hr;
   float fTmp;
   int iTmp;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper", "Radius", &fTmp);
   m_d.m_radius = (hr == S_OK) && fromMouseClick ? fTmp : 45.f;

   SetDefaultPhysics(fromMouseClick);

   hr = GetRegStringAsFloat("DefaultProps\\Bumper", "HeightScale", &fTmp);
   m_d.m_heightScale = (hr == S_OK) && fromMouseClick ? fTmp : 90.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper", "RingSpeed", &fTmp);
   m_d.m_ringSpeed = (hr == S_OK) && fromMouseClick ? fTmp : 0.5f;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper", "Orientation", &fTmp);
   m_d.m_orientation = (hr == S_OK) && fromMouseClick ? fTmp : 0.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper", "Threshold", &fTmp);
   m_d.m_threshold = (hr == S_OK) && fromMouseClick ? fTmp : 1.f;

   hr = GetRegString("DefaultProps\\Bumper", "Surface", m_d.m_szSurface, MAXTOKEN);
   if (hr != S_OK || !fromMouseClick)
      m_d.m_szSurface[0] = 0;

   hr = GetRegInt("DefaultProps\\Bumper", "TimerEnabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_tdr.m_fTimerEnabled = iTmp == 0 ? false : true;
   else
      m_d.m_tdr.m_fTimerEnabled = false;

   hr = GetRegInt("DefaultProps\\Bumper", "TimerInterval", &iTmp);
   m_d.m_tdr.m_TimerInterval = (hr == S_OK) && fromMouseClick ? iTmp : 100;

   hr = GetRegInt("DefaultProps\\Bumper", "CapVisible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fCapVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fCapVisible = true;

   hr = GetRegInt("DefaultProps\\Bumper", "BaseVisible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fBaseVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fBaseVisible = true;

   hr = GetRegInt("DefaultProps\\Bumper", "RingVisible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fRingVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fRingVisible = true;

   hr = GetRegInt("DefaultProps\\Bumper", "SkirtVisible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fSkirtVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fSkirtVisible = true;

   hr = GetRegInt("DefaultProps\\Bumper", "ReflectionEnabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fReflectionEnabled = iTmp == 0 ? false : true;
   else
      m_d.m_fReflectionEnabled = true;

   hr = GetRegInt("DefaultProps\\Bumper", "HasHitEvent", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
       m_d.m_fHitEvent= iTmp == 0 ? false : true;
   else
       m_d.m_fHitEvent = true;

   hr = GetRegInt("DefaultProps\\Bumper", "Collidable", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
       m_d.m_fCollidable = iTmp == 0 ? false : true;
   else
       m_d.m_fCollidable = true;
}
コード例 #11
0
ファイル: pinsound.cpp プロジェクト: paulftw/vpinball
void PinDirectSound::InitDirectSound(HWND hwnd, bool IsBackglass)
{
#ifdef DEBUG_NO_SOUND
    return;
#endif

    HRESULT hr;
    LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;

    // Initialize COM
    //if( hr = CoInitialize( NULL ) )
    //return hr;

    DSAudioDevices DSads;
    int DSidx = 0;
    if (!FAILED(DirectSoundEnumerate(DSEnumCallBack, &DSads)))
    {
        hr = GetRegInt("Player", IsBackglass ? "SoundDeviceBG" : "SoundDevice", &DSidx);
        if ((hr != S_OK) || ((unsigned int)DSidx >= DSads.size()))
            DSidx = 0; // The default primary sound device
    }

    // Create IDirectSound using the selected sound device
    if (FAILED(hr = DirectSoundCreate((DSidx != 0) ? DSads[DSidx]->guid : NULL, &m_pDS, NULL)))
    {
        ShowError("Could not create Direct Sound.");
        return;// hr;
    }

    // free audio devices list
    for (size_t i = 0; i < DSads.size(); i++)
        delete DSads[i];

    // Set coop level to DSSCL_PRIORITY
    if (FAILED(hr = m_pDS->SetCooperativeLevel(hwnd, DSSCL_PRIORITY)))
    {
        ShowError("Could not set Direct Sound Priority.");
        return;// hr;
    }

    // Get the primary buffer 
    DSBUFFERDESC dsbd;
    ZeroMemory(&dsbd, sizeof(DSBUFFERDESC));
    dsbd.dwSize = sizeof(DSBUFFERDESC);
    dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
    dsbd.dwBufferBytes = 0;
    dsbd.lpwfxFormat = NULL;

    if (FAILED(hr = m_pDS->CreateSoundBuffer(&dsbd, &pDSBPrimary, NULL)))
    {
        ShowError("Could not create primary sound buffer.");
        return;// hr;
    }

    // Set primary buffer format to 44kHz and 16-bit output.
    WAVEFORMATEX wfx;
    ZeroMemory(&wfx, sizeof(WAVEFORMATEX));
    wfx.wFormatTag = WAVE_FORMAT_PCM;
    wfx.nChannels = 2;
    wfx.nSamplesPerSec = 44100;
    wfx.wBitsPerSample = 16;
    wfx.nBlockAlign = wfx.wBitsPerSample / (WORD)8 * wfx.nChannels;
    wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;

    if (FAILED(hr = pDSBPrimary->SetFormat(&wfx)))
    {
        ShowError("Could not set sound format.");
        return;// hr;
    }

    SAFE_RELEASE(pDSBPrimary);

    //return S_OK;
}
コード例 #12
0
ファイル: flipper.cpp プロジェクト: paulftw/vpinball
void Flipper::SetDefaults(bool fromMouseClick)
{
   HRESULT hr;
   float fTmp;
   int iTmp;

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","StartAngle", &fTmp);
   m_d.m_StartAngle = (hr == S_OK) && fromMouseClick ? fTmp : 121;

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","EndAngle", &fTmp);
   m_d.m_EndAngle = (hr == S_OK) && fromMouseClick ? fTmp : 70;

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","BaseRadius", &fTmp);
   m_d.m_BaseRadius = (hr == S_OK) && fromMouseClick ? fTmp : 21.5f;		// 15

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","EndRadius", &fTmp);
   m_d.m_EndRadius = (hr == S_OK) && fromMouseClick ? fTmp : 13.f;		// 6

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","Length", &fTmp);
   m_d.m_FlipperRadiusMax = (hr == S_OK) && fromMouseClick ? fTmp : 130.f;	// 80

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","MaxDifLength", &fTmp);
   m_d.m_FlipperRadiusMin = (hr == S_OK) && fromMouseClick ? fTmp : 0;

   m_d.m_FlipperRadius = m_d.m_FlipperRadiusMax;

   //m_d.m_angleEOS = 0; //!! reenable?

   SetDefaultPhysics(fromMouseClick);

   hr = GetRegInt("DefaultProps\\Flipper","TimerEnabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_tdr.m_fTimerEnabled = iTmp == 0 ? false : true;
   else
      m_d.m_tdr.m_fTimerEnabled = false;

   hr = GetRegInt("DefaultProps\\Flipper","TimerInterval", &iTmp);
   m_d.m_tdr.m_TimerInterval = (hr == S_OK) && fromMouseClick ? iTmp : 100;

   hr = GetRegInt("DefaultProps\\Flipper","Color", &iTmp);
   m_d.m_color = (hr == S_OK) && fromMouseClick ? iTmp : RGB(255,255,255);

   hr = GetRegInt("DefaultProps\\Flipper","RubberColor", &iTmp);
   m_d.m_rubbercolor = (hr == S_OK) && fromMouseClick ? iTmp : RGB(128,50,50);

   hr = GetRegString("DefaultProps\\Flipper", "Surface", &m_d.m_szSurface, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      m_d.m_szSurface[0] = 0;

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","Strength", &fTmp);
   m_d.m_strength = (hr == S_OK) && fromMouseClick ? fTmp : 2200.0f;

   hr = GetRegStringAsFloat("DefaultProps\\Flipper","Height", &fTmp);
   m_d.m_height = (hr == S_OK) && fromMouseClick ? fTmp : 50;

   hr = GetRegInt("DefaultProps\\Flipper","RubberThickness", &iTmp);
   m_d.m_rubberthickness = (hr == S_OK) && fromMouseClick ? iTmp : 7;

   hr = GetRegInt("DefaultProps\\Flipper","RubberHeight", &iTmp);
   m_d.m_rubberheight = (hr == S_OK) && fromMouseClick ? iTmp : 19;

   hr = GetRegInt("DefaultProps\\Flipper","RubberWidth", &iTmp);
   m_d.m_rubberwidth = (hr == S_OK) && fromMouseClick ? iTmp : 24;

   hr = GetRegInt("DefaultProps\\Flipper","Visible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fVisible = true;

   hr = GetRegInt("DefaultProps\\Flipper","Enabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fEnabled = iTmp == 0 ? false : true;
   else
      m_d.m_fEnabled = true;
}
コード例 #13
0
ファイル: bumper.cpp プロジェクト: c-f-h/vpinball
void Bumper::SetDefaults(bool fromMouseClick)
{
   HRESULT hr;
   float fTmp;
   int iTmp;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper","Radius", &fTmp);
   m_d.m_radius = (hr == S_OK) && fromMouseClick ? fTmp : 45;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper","Force", &fTmp);
   m_d.m_force = (hr == S_OK) && fromMouseClick ? fTmp : 15;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper","HeightOffset", &fTmp);
   m_d.m_heightoffset = (hr == S_OK) && fromMouseClick ? fTmp : 0;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper","Threshold", &fTmp);
   m_d.m_threshold = (hr == S_OK) && fromMouseClick ? fTmp : 1;

   hr = GetRegStringAsFloat("DefaultProps\\Bumper","Overhang", &fTmp);
   m_d.m_overhang = (hr == S_OK) && fromMouseClick ? fTmp : 25;

   hr = GetRegInt("DefaultProps\\Bumper","Color", &iTmp);
   m_d.m_color = (hr == S_OK) && fromMouseClick ? iTmp : RGB(255,0,0);

   hr = GetRegInt("DefaultProps\\Bumper","SideColor", &iTmp);
   m_d.m_sidecolor = (hr == S_OK) && fromMouseClick ? iTmp : RGB(255,255,255);

   hr = GetRegString("DefaultProps\\Bumper","Image", m_d.m_szImage, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      m_d.m_szImage[0] = 0;

   hr = GetRegString("DefaultProps\\Bumper","Surface", m_d.m_szSurface, MAXTOKEN);
   if (hr != S_OK || !fromMouseClick )	
      m_d.m_szSurface[0] = 0;

   hr = GetRegInt("DefaultProps\\Bumper","TimerEnabled", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_tdr.m_fTimerEnabled = iTmp == 0 ? fFalse : fTrue;
   else
      m_d.m_tdr.m_fTimerEnabled = fFalse;

   hr = GetRegInt("DefaultProps\\Bumper","TimerInterval", &iTmp);
   m_d.m_tdr.m_TimerInterval = (hr == S_OK) && fromMouseClick ? iTmp : 100;

   hr = GetRegInt("DefaultProps\\Bumper","LightState", &iTmp);
   m_d.m_state = (hr == S_OK) && fromMouseClick ? (enum LightState)iTmp : LightStateOff;

   hr = GetRegString("DefaultProps\\Bumper","BlinkPattern", m_rgblinkpattern, MAXTOKEN);
   if ((hr != S_OK) || !fromMouseClick)
      strcpy_s(m_rgblinkpattern, sizeof(m_rgblinkpattern), "10");

   hr = GetRegInt("DefaultProps\\Bumper","BlinkInterval", &iTmp);
   m_blinkinterval = (hr == S_OK) && fromMouseClick ? iTmp : 125;

   hr = GetRegInt("DefaultProps\\Bumper","FlashWhenHit", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fFlashWhenHit = iTmp == 0 ? false : true;
   else
      m_d.m_fFlashWhenHit = fTrue;

   hr = GetRegInt("DefaultProps\\Bumper","CastsShadow", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fCastsShadow = iTmp == 0 ? false : true;
   else
      m_d.m_fCastsShadow = fTrue;

   hr = GetRegInt("DefaultProps\\Bumper","Visible", &iTmp);
   if ((hr == S_OK)&& fromMouseClick)
      m_d.m_fVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fVisible = fTrue;

   hr = GetRegInt("DefaultProps\\Bumper","SideVisible", &iTmp);
   if ((hr == S_OK) && fromMouseClick)
      m_d.m_fSideVisible = iTmp == 0 ? false : true;
   else
      m_d.m_fSideVisible = fTrue;
}