CString VariableConfigBlock::GetStringParameter(LPCTSTR name, LPCTSTR defaultValue) { if (_tcscmp(configPath_, TEXT("")) == 0) { return defaultValue; } // 首先读取当前配置 CString strCurMode = GetCurrentMode(); if (_tcscmp(strCurMode, TEXT("")) == 0) { return defaultValue; } // 再在当前配置下读取数据 TCHAR szValue[MAX_PATH] = { 0 }; GetPrivateProfileString(strCurMode, name, defaultValue, szValue, _countof(szValue), configPath_); if (_tcscmp(szValue, TEXT("")) == 0) { return defaultValue; } else { return CString(szValue); } }
HRESULT hsGDirect3DTnLEnumerate::D3DEnum_SelectDefaultMode(int width, int height, int depth) { hsAssert(GetCurrentDriver() && GetCurrentDevice(), "Must have selected device already"); BOOL windowed = false; if (depth == 0) { // Legacy code writes out 0 bit depth to mean windowed windowed = true; depth = 32; } D3DEnum_DeviceInfo* device = GetCurrentDevice(); int i; for( i = 0; i < device->fModes.GetCount(); i++ ) { D3DEnum_ModeInfo* mode = &device->fModes[i]; if (mode->fWindowed != windowed) continue; if( depth ) { if( width < mode->fDDmode.Width ) continue; if( height < mode->fDDmode.Height ) continue; } if( depth < mode->fBitDepth ) continue; if( GetCurrentMode() ) { D3DEnum_ModeInfo* curMode = GetCurrentDriver()->fCurrentMode; if( depth ) { if( curMode->fDDmode.Width > mode->fDDmode.Width ) continue; if( curMode->fDDmode.Height > mode->fDDmode.Height ) continue; } if( curMode->fBitDepth > mode->fBitDepth ) continue; } SetCurrentMode(mode); } return S_OK; }
void VariableConfigBlock::SetIntParemeter(LPCTSTR name,int choiceValue) { if (_tcscmp(configPath_, TEXT("")) == 0) { return; } CString strCurMode = GetCurrentMode(); if (_tcscmp(strCurMode,TEXT(""))==0) { return; } //只需将整型的值变为字符型 CString strTemp; strTemp.Format(L"%d", choiceValue); ::WritePrivateProfileString(strCurMode, name, strTemp, configPath_); }
bool CXRandR::TurnOnOutput(const std::string& name) { XOutput *output = GetOutput(name); if (!output) return false; XMode mode = GetCurrentMode(output->name); if (mode.isCurrent) return true; // get preferred mode for (unsigned int j = 0; j < m_outputs.size(); j++) { if (m_outputs[j].name == output->name) { for (unsigned int i = 0; i < m_outputs[j].modes.size(); i++) { if (m_outputs[j].modes[i].isPreferred) { mode = m_outputs[j].modes[i]; break; } } } } if (!mode.isPreferred) return false; if (!SetMode(*output, mode)) return false; XbmcThreads::EndTime timeout(5000); while (!timeout.IsTimePast()) { if (!Query(true)) return false; output = GetOutput(name); if (output && output->h > 0) return true; Sleep(200); } return false; }
bool VariableConfigBlock::SetStringParameter(LPCTSTR name, LPCTSTR _value) { if (_tcscmp(configPath_, TEXT("")) == 0) { return false; } // 首先读取当前配置 CString strCurMode = GetCurrentMode(); if (_tcscmp(strCurMode, TEXT("")) == 0) { return false; } // 再在当前配置下读取数据 return WritePrivateProfileString(strCurMode, name, _value, configPath_); }
int VariableConfigBlock::GetIntParameter(LPCTSTR name, int defaultValue) { if (_tcscmp(configPath_, TEXT("")) == 0) { return defaultValue; } // 首先读取当前配置 CString strCurMode = GetCurrentMode(); if (_tcscmp(strCurMode, TEXT("")) == 0) { return defaultValue; } // 再在当前配置下读取数据 return GetPrivateProfileInt(strCurMode, name, defaultValue, configPath_); }
void InfoBoxManager::SetupFocused() { int i = GetFocused(); if (i < 0) return; const enum mode mode = GetCurrentMode(); int old_type = GetType(i, mode); /* create a fake WndProperty for dlgComboPicker() */ /* XXX reimplement properly */ DataFieldEnum *dfe = new DataFieldEnum(old_type, NULL); for (unsigned i = 0; i < InfoBoxFactory::NUM_TYPES; i++) dfe->addEnumText(gettext(GetTypeDescription(i))); dfe->Sort(0); dfe->Set(old_type); ComboList *list = dfe->CreateComboList(); delete dfe; /* let the user select */ info_box_combo_list = list; int result = ComboPicker(XCSoarInterface::main_window, _("InfoBox"), *list, OnInfoBoxHelp); if (result < 0) { delete list; return; } /* was there a modification? */ int new_type = (*list)[result].DataFieldIndex; delete list; if (new_type == old_type) return; /* yes: apply and save it */ SetType(i, new_type, mode); DisplayInfoBox(); Profile::SetInfoBoxes(i, GetTypes(i)); }
bool VariableConfigBlock::SetIntParameter(LPCTSTR name, int _value) { if (_tcscmp(configPath_, TEXT("")) == 0) { return false; } // 首先读取当前配置 CString strCurMode = GetCurrentMode(); if (_tcscmp(strCurMode, TEXT("")) == 0) { return false; } // 再在当前配置下读取数据 TCHAR valBuf[16]; _itot(_value, valBuf, 10); // wsprintf(valBuf, TEXT("%i"), _value); return WritePrivateProfileString(strCurMode, name, valBuf, configPath_); }
bool wxDisplayImplMultimon::ChangeMode(const wxVideoMode& mode) { // prepare ChangeDisplaySettingsEx() parameters DEVMODE dm; DEVMODE *pDevMode; int flags; if ( mode == wxDefaultVideoMode ) { // reset the video mode to default pDevMode = NULL; flags = 0; } else // change to the given mode { wxCHECK_MSG( mode.GetWidth() && mode.GetHeight(), false, wxT("at least the width and height must be specified") ); wxZeroMemory(dm); dm.dmSize = sizeof(dm); dm.dmDriverExtra = 0; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; dm.dmPelsWidth = mode.GetWidth(); dm.dmPelsHeight = mode.GetHeight(); if ( mode.GetDepth() ) { dm.dmFields |= DM_BITSPERPEL; dm.dmBitsPerPel = mode.GetDepth(); } if ( mode.GetRefresh() ) { dm.dmFields |= DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = mode.GetRefresh(); } pDevMode = &dm; #ifdef __WXWINCE__ flags = 0; #else // !__WXWINCE__ flags = CDS_FULLSCREEN; #endif // __WXWINCE__/!__WXWINCE__ } // get pointer to the function dynamically // // we're only called from the main thread, so it's ok to use static // variable static ChangeDisplaySettingsEx_t pfnChangeDisplaySettingsEx = NULL; if ( !pfnChangeDisplaySettingsEx ) { wxDynamicLibrary dllDisplay(displayDllName, wxDL_VERBATIM | wxDL_QUIET); if ( dllDisplay.IsLoaded() ) { wxDL_INIT_FUNC_AW(pfn, ChangeDisplaySettingsEx, dllDisplay); } //else: huh, no this DLL must always be present, what's going on?? #ifndef __WXWINCE__ if ( !pfnChangeDisplaySettingsEx ) { // we must be under Win95 and so there is no multiple monitors // support anyhow pfnChangeDisplaySettingsEx = ChangeDisplaySettingsExForWin95; } #endif // !__WXWINCE__ } // do change the mode switch ( pfnChangeDisplaySettingsEx ( GetName().wx_str(), // display name pDevMode, // dev mode or NULL to reset NULL, // reserved flags, NULL // pointer to video parameters (not used) ) ) { case DISP_CHANGE_SUCCESSFUL: // ok { // If we have a top-level, full-screen frame, emulate // the DirectX behavior and resize it. This makes this // API quite a bit easier to use. wxWindow *winTop = wxTheApp->GetTopWindow(); wxFrame *frameTop = wxDynamicCast(winTop, wxFrame); if (frameTop && frameTop->IsFullScreen()) { wxVideoMode current = GetCurrentMode(); frameTop->SetClientSize(current.GetWidth(), current.GetHeight()); } } return true; case DISP_CHANGE_BADMODE: // don't complain about this, this is the only "expected" error break; default: wxFAIL_MSG( wxT("unexpected ChangeDisplaySettingsEx() return value") ); } return false; }
HRESULT hsGDirect3DTnLEnumerate::SelectFromDevMode(const hsG3DDeviceRecord* devRec, const hsG3DDeviceMode* devMode) { int i; for( i = 0; i < GetNumDrivers(); i++ ) { if( !stricmp(GetDriver(i)->fAdapterInfo.Description, devRec->GetDriverDesc()) ) { int j; for( j = 0; j < GetDriver(i)->fDevices.GetCount(); j++ ) { if( !stricmp(GetDriver(i)->fDevices[j].fStrName, devRec->GetDeviceDesc()) ) { SetCurrentDriver(GetDriver(i)); SetCurrentDevice(&GetDriver(i)->fDevices[j]); D3DEnum_SelectDefaultMode( devMode->GetWidth(), devMode->GetHeight(), devMode->GetColorDepth()); return false; } } } } char errStr[256]; sprintf(errStr, "Can't find requested device - %s:%s:%s:%s:%s", devRec->GetG3DDeviceTypeName(), devRec->GetDriverDesc(), devRec->GetDriverName(), devRec->GetDriverVersion(), devRec->GetDeviceDesc()); DWORD enumFlags = 0; int width = devMode->GetWidth(); int height = devMode->GetHeight(); int colorDepth = devMode->GetColorDepth(); // for a window, take whatever colordepth we can get. if( !colorDepth ) enumFlags |= D3DENUM_CANWINDOW; enumFlags |= D3DENUM_TNLHAL; #ifdef HS_ALLOW_D3D_REF_DRIVER enumFlags |= D3DENUM_REFERENCERAST; #endif D3DEnum_SelectDefaultDriver(enumFlags); // If we didn't get what we want, try for anything. if( !GetCurrentDriver() || !GetCurrentDevice() ) { enumFlags = colorDepth ? 0 : D3DENUM_CANWINDOW; D3DEnum_SelectDefaultDriver(enumFlags); } if( !GetCurrentDriver() || !GetCurrentDevice() ) D3DEnum_SelectDefaultDriver(0); if( !GetCurrentDriver() || !GetCurrentDevice() ) { if( !*GetEnumeErrorStr() ) SetEnumeErrorStr("Error finding device"); return true; } D3DEnum_SelectDefaultMode(width, height, colorDepth); if( !GetCurrentMode() ) { if( !*GetEnumeErrorStr() ) SetEnumeErrorStr("Error finding mode"); return true; } return false; }
bool wxDisplayMSW::ChangeMode(const wxVideoMode& mode) { // prepare ChangeDisplaySettingsEx() parameters DEVMODE dm; DEVMODE *pDevMode; int flags; if ( mode == wxDefaultVideoMode ) { // reset the video mode to default pDevMode = NULL; flags = 0; } else // change to the given mode { wxCHECK_MSG( mode.GetWidth() && mode.GetHeight(), false, wxT("at least the width and height must be specified") ); wxZeroMemory(dm); dm.dmSize = sizeof(dm); dm.dmDriverExtra = 0; dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; dm.dmPelsWidth = mode.GetWidth(); dm.dmPelsHeight = mode.GetHeight(); if ( mode.GetDepth() ) { dm.dmFields |= DM_BITSPERPEL; dm.dmBitsPerPel = mode.GetDepth(); } if ( mode.GetRefresh() ) { dm.dmFields |= DM_DISPLAYFREQUENCY; dm.dmDisplayFrequency = mode.GetRefresh(); } pDevMode = &dm; flags = CDS_FULLSCREEN; } // do change the mode switch ( ::ChangeDisplaySettingsEx ( GetName().t_str(), // display name pDevMode, // dev mode or NULL to reset NULL, // reserved flags, NULL // pointer to video parameters (not used) ) ) { case DISP_CHANGE_SUCCESSFUL: // ok { // If we have a top-level, full-screen frame, emulate // the DirectX behaviour and resize it. This makes this // API quite a bit easier to use. wxWindow *winTop = wxTheApp->GetTopWindow(); wxFrame *frameTop = wxDynamicCast(winTop, wxFrame); if (frameTop && frameTop->IsFullScreen()) { wxVideoMode current = GetCurrentMode(); frameTop->SetClientSize(current.GetWidth(), current.GetHeight()); } } return true; case DISP_CHANGE_BADMODE: // don't complain about this, this is the only "expected" error break; default: wxFAIL_MSG( wxT("unexpected ChangeDisplaySettingsEx() return value") ); } return false; }
void InfoBoxManager::SetCurrentType(unsigned box, char type) { SetType(box, type, GetCurrentMode()); }
unsigned InfoBoxManager::GetCurrentType(unsigned box) { unsigned retval = GetType(box, GetCurrentMode()); return std::min(InfoBoxFactory::NUM_TYPES - 1, retval); }
void DigitalBrain::FrameExec(SimObjectType* curTargetList, SimObjectType* curTarget) { maxGs = af->MaxGs(); maxGs = max (maxGs, 2.5F); // 2002-03-15 MN if we've flamed out // and our speed is below minvcas, put the wheels out so that there is a chance to land if (self->af->Fuel() <= 0.0F && self->af->vcas < self->af->MinVcas()){ // Set Landed flag now, so that RegroupAircraft can be called in Eom.cpp - // have the maintenance crew tow us back to the airbase ;-) //TJL 02/19/04 Flame out = Eject for Digital pilots //SetATCFlag(Landed); //af->gearHandle = 1.0F; self->Eject(); rStick = -0.3f;//Roll while the plane dies } else { // make sure the wheels are up after takeoff if (self->curWaypoint && self->curWaypoint->GetWPAction() != WP_TAKEOFF){ af->gearHandle = -1.0F; } else if (!self->OnGround()){ //Cobra stop Naval aircraft flying around with gear down af->gearHandle = -1.0F; } } // assume we're not going to be firing in this frame ClearFlag (MslFireFlag | GunFireFlag); // check to see if our leader is dead and if not set leader to next in // flight (and/or ourself) CheckLead(); // FRB - Keep radar sweeping while in CombatAP if ((self->IsPlayer())&&(g_bwoeir)) self->targetUpdateRate = (VU_TIME)(.01 * SEC_TO_MSEC); else self->targetUpdateRate = (VU_TIME)(5 * SEC_TO_MSEC); // Find a threat/target DoTargeting(); // Make Decisions SetCurrentTactic(); // Set the controls Actions(); // RV - Biker - Enable shooting missiles if flight lead is AI if (flightLead && !flightLead->IsPlayer() && missileShotTimer >= SimLibElapsedTime + 4.9 * 60 * 60 * SEC_TO_MSEC) { missileShotTimer = SimLibElapsedTime; } // has the target changed? if (targetPtr != lastTarget){ lastTarget = targetPtr; ataddot = 10.0F; rangeddot = 10.0F; } // edg: check stick settings for bad values if ( rStick < -1.0f ) rStick = -1.0f; else if ( rStick > 1.0f ) rStick = 1.0f; if ( pStick < -1.0f ) pStick = -1.0f; else if ( pStick > 1.0f ) pStick = 1.0f; //me123 unload if roll input is 1 (to rool faster and eleveate the f4 bug) if (fabs(rStick) >0.9f && groundAvoidNeeded == FALSE) pStick = 0.0f; if ( throtl < 0.0f ) throtl = 0.0f; else if ( throtl > 1.5f ) throtl = 1.5f; // RV - Biker - Don't allow AB when low on fuel or on ground if (IsSetATC(SaidFumes) || IsSetATC(SaidFlameout) || (self->OnGround() && GetCurrentMode() != TakeoffMode)) { throtl = min(1.0f, throtl); } }