// //////////////////////////////////////////////////////////////////////////// // Video Options static bool startVideoOptionsMenu(void) { // Generate the resolution string snprintf(resolution, WIDG_MAXSTR, "%d x %d", war_GetWidth(), war_GetHeight()); // Generate texture size string snprintf(textureSize, WIDG_MAXSTR, "%d", getTextureSize()); addBackdrop(); addTopForm(); addBottomForm(); // Add a note about changes taking effect on restart for certain options addTextHint(FRONTEND_TAKESEFFECT, FRONTEND_POS1X + 48, FRONTEND_POS1Y + 24, _("* Takes effect on game restart")); // Fullscreen/windowed addTextButton(FRONTEND_WINDOWMODE, FRONTEND_POS2X-35, FRONTEND_POS2Y, _("Graphics Mode*"), 0); if (war_getFullscreen()) { addTextButton(FRONTEND_WINDOWMODE_R, FRONTEND_POS2M-55, FRONTEND_POS2Y, _("Fullscreen"), 0); } else { addTextButton(FRONTEND_WINDOWMODE_R, FRONTEND_POS2M-55, FRONTEND_POS2Y, _("Windowed"), 0); } // Resolution addTextButton(FRONTEND_RESOLUTION, FRONTEND_POS3X-35, FRONTEND_POS3Y, _("Resolution*"), WBUT_SECONDARY); addTextButton(FRONTEND_RESOLUTION_R, FRONTEND_POS3M-55, FRONTEND_POS3Y, resolution, WBUT_SECONDARY); widgSetString(psWScreen, FRONTEND_RESOLUTION_R, resolution); // Texture size addTextButton(FRONTEND_TEXTURESZ, FRONTEND_POS4X-35, FRONTEND_POS4Y, _("Texture size"), 0); addTextButton(FRONTEND_TEXTURESZ_R, FRONTEND_POS4M-55, FRONTEND_POS4Y, textureSize, 0); // Vsync addTextButton(FRONTEND_VSYNC, FRONTEND_POS5X-35, FRONTEND_POS5Y, _("Vertical sync*"), 0); if (war_GetVsync()) { addTextButton(FRONTEND_VSYNC_R, FRONTEND_POS5M-55, FRONTEND_POS5Y, _("On"), 0); } else { addTextButton(FRONTEND_VSYNC_R, FRONTEND_POS5M-55, FRONTEND_POS5Y, _("Off"), 0); } // Add some text down the side of the form addSideText(FRONTEND_SIDETEXT, FRONTEND_SIDEX, FRONTEND_SIDEY, _("VIDEO OPTIONS")); // Quit/return addMultiBut(psWScreen, FRONTEND_BOTFORM, FRONTEND_QUIT, 10, 10, 30, 29, P_("menu", "Return"), IMAGE_RETURN, IMAGE_RETURN_HI, IMAGE_RETURN_HI); return true; }
// //////////////////////////////////////////////////////////////////////////// bool saveConfig() { QSettings ini(PHYSFS_getWriteDir() + QString("/") + fileName, QSettings::IniFormat); if (ini.status() != QSettings::NoError) { debug(LOG_ERROR, "Could not open configuration file \"%s\"", fileName); return false; } debug(LOG_WZ, "Writing prefs to registry \"%s\"", ini.fileName().toUtf8().constData()); // ////////////////////////// // voicevol, fxvol and cdvol ini.setValue("voicevol", (int)(sound_GetUIVolume() * 100.0)); ini.setValue("fxvol", (int)(sound_GetEffectsVolume() * 100.0)); ini.setValue("cdvol", (int)(sound_GetMusicVolume() * 100.0)); ini.setValue("music_enabled", war_GetMusicEnabled()); ini.setValue("width", war_GetWidth()); ini.setValue("height", war_GetHeight()); ini.setValue("bpp", pie_GetVideoBufferDepth()); ini.setValue("fullscreen", war_getFullscreen()); ini.setValue("language", getLanguage()); // dont save out the cheat mode. if (getDifficultyLevel() != DL_KILLER && getDifficultyLevel() != DL_TOUGH) { ini.setValue("difficulty", getDifficultyLevel()); // level } ini.setValue("showFPS", (SDWORD)showFPS); ini.setValue("scroll",(SDWORD)scroll_speed_accel); // scroll ini.setValue("shake",(SDWORD)(getShakeStatus())); // screenshake ini.setValue("mouseflip",(SDWORD)(getInvertMouseStatus())); // flipmouse ini.setValue("nomousewarp", (SDWORD)getMouseWarp()); // mouse warp ini.setValue("RightClickOrders",(SDWORD)(getRightClickOrders())); ini.setValue("MiddleClickRotate",(SDWORD)(getMiddleClickRotate())); ini.setValue("showFPS", (SDWORD)showFPS); ini.setValue("shadows",(SDWORD)(getDrawShadows())); // shadows ini.setValue("sound", (SDWORD)war_getSoundEnabled()); ini.setValue("FMVmode",(SDWORD)(war_GetFMVmode())); // sequences ini.setValue("scanlines", (SDWORD)war_getScanlineMode()); ini.setValue("subtitles",(SDWORD)(seq_GetSubtitles())); // subtitles ini.setValue("radarObjectMode",(SDWORD)bEnemyAllyRadarColor); // enemy/allies radar view ini.setValue("radarTerrainMode",(SDWORD)radarDrawMode); ini.setValue("trapCursor", war_GetTrapCursor()); ini.setValue("vsync", war_GetVsync()); ini.setValue("textureSize", getTextureSize()); ini.setValue("FSAA", war_getFSAA()); ini.setValue("UPnP", (SDWORD)NetPlay.isUPNP); ini.setValue("rotateRadar", rotateRadar); ini.setValue("PauseOnFocusLoss", war_GetPauseOnFocusLoss()); ini.setValue("masterserver_name", NETgetMasterserverName()); ini.setValue("masterserver_port", NETgetMasterserverPort()); ini.setValue("gameserver_port", NETgetGameserverPort()); if (!bMultiPlayer) { ini.setValue("colour", getPlayerColour(0)); // favourite colour. } else { if (NetPlay.isHost && ingame.localJoiningInProgress) { if (bMultiPlayer && NetPlay.bComms) { ini.setValue("gameName", game.name); // last hosted game } ini.setValue("mapName", game.map); // map name ini.setValue("mapHash", game.hash.toString().c_str()); // map hash ini.setValue("maxPlayers", game.maxPlayers); // maxPlayers ini.setValue("power", game.power); // power ini.setValue("base", game.base); // size of base ini.setValue("alliance", game.alliance); // allow alliances ini.setValue("scavengers", game.scavengers); } ini.setValue("playerName", (char*)sPlayer); // player name } ini.setValue("colourMP", war_getMPcolour()); ini.sync(); return true; }
bool runVideoOptionsMenu(void) { //SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); HACK modes[] = {{1920, 1200}, {1920, 1080}, {1680, 1050}, {1600, 1200}, {1440, 900}, {1280, 1024}, {1280, 960}, {1280, 800}, {1280, 720}, {1024, 768}, {800, 600}, {720, 576}, {720, 480}, {640, 480}, {0, 0}}; UDWORD id = widgRunScreen(psWScreen); int level; switch (id) { case FRONTEND_WINDOWMODE: case FRONTEND_WINDOWMODE_R: if (war_getFullscreen()) { war_setFullscreen(false); widgSetString(psWScreen, FRONTEND_WINDOWMODE_R, _("Windowed")); } else { war_setFullscreen(true); widgSetString(psWScreen, FRONTEND_WINDOWMODE_R, _("Fullscreen")); } break; case FRONTEND_FSAA: case FRONTEND_FSAA_R: switch (level = war_getFSAA()) { case FSAA_OFF: war_setFSAA((FSAA_LEVEL)(level + 1)); widgSetString(psWScreen, FRONTEND_FSAA_R, "2X"); break; case FSAA_2X: war_setFSAA((FSAA_LEVEL)(level + 1)); widgSetString(psWScreen, FRONTEND_FSAA_R, "4X"); break; case FSAA_4X: war_setFSAA((FSAA_LEVEL)(level + 1)); widgSetString(psWScreen, FRONTEND_FSAA_R, "8X"); break; case FSAA_8X: war_setFSAA((FSAA_LEVEL)(level + 1)); widgSetString(psWScreen, FRONTEND_FSAA_R, _("Off")); break; default: // we can't check what the max level the card is capable of, without first creating that level, and testing. ASSERT(!"invalid FSAA level ?", "Invalid FSAA level: %u", (unsigned int)level); addTextButton(FRONTEND_FSAA_R, FRONTEND_POS5M-55, FRONTEND_POS6Y, _("Unsupported"), 0); break; } break; case FRONTEND_RESOLUTION: case FRONTEND_RESOLUTION_R: { int current, count, oldcurrent; // Get the current mode offset for (count = 0, current = 0; modes[count]; count++) { if (war_GetWidth() == modes[count]->w && war_GetHeight() == modes[count]->h) { current = count; } } // Increment and clip if required // Hide resolutions lower than Warzone can support oldcurrent = current; do { if (!mouseReleased(MOUSE_RMB)) { if (--current < 0) current = count - 1; } else { if (++current == count) current = 0; } } while ((modes[current]->w < 640 || modes[current]->h < 480) && current != oldcurrent); // Set the new width and height (takes effect on restart) war_SetWidth(modes[current]->w); war_SetHeight(modes[current]->h); // Generate the textual representation of the new width and height snprintf(resolution, WIDG_MAXSTR, "%d x %d", modes[current]->w, modes[current]->h); // Update the widget widgSetString(psWScreen, FRONTEND_RESOLUTION_R, resolution); break; } case FRONTEND_TRAP: case FRONTEND_TRAP_R: if (war_GetTrapCursor()) { war_SetTrapCursor(false); widgSetString(psWScreen, FRONTEND_TRAP_R, _("Off")); } else { war_SetTrapCursor(true); widgSetString(psWScreen, FRONTEND_TRAP_R, _("On")); } break; case FRONTEND_TEXTURESZ: case FRONTEND_TEXTURESZ_R: { int newTexSize = getTextureSize() * 2; // Clip such that 128 <= size <= 2048 if (newTexSize > 2048) { newTexSize = 128; } // Set the new size setTextureSize(newTexSize); // Generate the string representation of the new size snprintf(textureSize, WIDG_MAXSTR, "%d", newTexSize); // Update the widget widgSetString(psWScreen, FRONTEND_TEXTURESZ_R, textureSize); break; } case FRONTEND_VSYNC: case FRONTEND_VSYNC_R: { if (war_GetVsync()) { war_SetVsync(false); widgSetString(psWScreen, FRONTEND_VSYNC_R, _("Off")); } else { war_SetVsync(true); widgSetString(psWScreen, FRONTEND_VSYNC_R, _("On")); } break; } case FRONTEND_QUIT: changeTitleMode(OPTIONS); break; default: break; } if (CancelPressed()) { changeTitleMode(OPTIONS); } widgDisplayScreen(psWScreen); return true; }
// //////////////////////////////////////////////////////////////////////////// bool saveConfig(void) { debug( LOG_WZ, "Writing prefs to registry\n" ); if(!openWarzoneKey()) { return false; } // ////////////////////////// // voicevol, fxvol and cdvol setWarzoneKeyNumeric("voicevol", (int)(sound_GetUIVolume() * 100.0)); setWarzoneKeyNumeric("fxvol", (int)(sound_GetEffectsVolume() * 100.0)); setWarzoneKeyNumeric("cdvol", (int)(sound_GetMusicVolume() * 100.0)); setWarzoneKeyNumeric("music_enabled", war_GetMusicEnabled()); setWarzoneKeyNumeric("width", war_GetWidth()); setWarzoneKeyNumeric("height", war_GetHeight()); setWarzoneKeyNumeric("bpp", pie_GetVideoBufferDepth()); setWarzoneKeyNumeric("fullscreen", war_getFullscreen()); setWarzoneKeyString("language", getLanguage()); // dont save out the cheat mode. if(getDifficultyLevel()==DL_KILLER || getDifficultyLevel()== DL_TOUGH) { setDifficultyLevel(DL_NORMAL); } setWarzoneKeyNumeric("debugmode", bAllowDebugMode); setWarzoneKeyNumeric("framerate", (SDWORD)getFramerateLimit()); setWarzoneKeyNumeric("showFPS", (SDWORD)showFPS); setWarzoneKeyNumeric("scroll",(SDWORD)scroll_speed_accel); // scroll setWarzoneKeyNumeric("difficulty", getDifficultyLevel()); // level setWarzoneKeyNumeric("visfog",(SDWORD)(!war_GetFog())); // fogtype setWarzoneKeyNumeric("shake",(SDWORD)(getShakeStatus())); // screenshake setWarzoneKeyNumeric("mouseflip",(SDWORD)(getInvertMouseStatus())); // flipmouse setWarzoneKeyNumeric("RightClickOrders",(SDWORD)(getRightClickOrders())); setWarzoneKeyNumeric("MiddleClickRotate",(SDWORD)(getMiddleClickRotate())); setWarzoneKeyNumeric("shadows",(SDWORD)(getDrawShadows())); // shadows setWarzoneKeyNumeric("sound", (SDWORD)war_getSoundEnabled()); setWarzoneKeyNumeric("FMVmode",(SDWORD)(war_GetFMVmode())); // sequences setWarzoneKeyNumeric("subtitles",(SDWORD)(seq_GetSubtitles())); // subtitles setWarzoneKeyNumeric("radarObjectMode",(SDWORD)bEnemyAllyRadarColor); // enemy/allies radar view setWarzoneKeyNumeric("radarTerrainMode",(SDWORD)radarDrawMode); setWarzoneKeyNumeric("trapCursor", war_GetTrapCursor()); setWarzoneKeyNumeric("vsync", war_GetVsync()); setWarzoneKeyNumeric("textureSize", getTextureSize()); setWarzoneKeyNumeric("rotateRadar", rotateRadar); setWarzoneKeyNumeric("PauseOnFocusLoss", war_GetPauseOnFocusLoss()); setWarzoneKeyNumeric("ColouredCursor", war_GetColouredCursor()); setWarzoneKeyString("masterserver_name", NETgetMasterserverName()); setWarzoneKeyNumeric("masterserver_port", NETgetMasterserverPort()); setWarzoneKeyNumeric("gameserver_port", NETgetGameserverPort()); if(!bMultiPlayer) { setWarzoneKeyNumeric("colour",(SDWORD)getPlayerColour(0)); // favourite colour. } else { debug( LOG_NEVER, "Writing multiplay prefs to registry\n" ); if (NetPlay.isHost && ingame.localJoiningInProgress) { if (bMultiPlayer && NetPlay.bComms) { setWarzoneKeyString("gameName", game.name); // last hosted game } setWarzoneKeyString("mapName", game.map); // map name setWarzoneKeyNumeric("maxPlayers",game.maxPlayers); // maxPlayers setWarzoneKeyNumeric("power", game.power); // power setWarzoneKeyNumeric("base", game.base); // size of base setWarzoneKeyNumeric("fog", game.fog); // fog 'o war setWarzoneKeyNumeric("alliance", game.alliance); // allow alliances } setWarzoneKeyString("playerName",(char*)sPlayer); // player name setWarzoneKeyString("phrase0", ingame.phrases[0]); // phrases setWarzoneKeyString("phrase1", ingame.phrases[1]); setWarzoneKeyString("phrase2", ingame.phrases[2]); setWarzoneKeyString("phrase3", ingame.phrases[3]); setWarzoneKeyString("phrase4", ingame.phrases[4]); } return closeWarzoneKey(); }
bool runVideoOptionsMenu(void) { SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE); UDWORD id = widgRunScreen(psWScreen); switch (id) { case FRONTEND_WINDOWMODE: case FRONTEND_WINDOWMODE_R: if (war_getFullscreen()) { war_setFullscreen(false); widgSetString(psWScreen, FRONTEND_WINDOWMODE_R, _("Windowed")); } else { war_setFullscreen(true); widgSetString(psWScreen, FRONTEND_WINDOWMODE_R, _("Fullscreen")); } break; case FRONTEND_RESOLUTION: case FRONTEND_RESOLUTION_R: { int current, count, oldcurrent; // Get the current mode offset for (count = 0, current = 0; modes[count]; count++) { if (war_GetWidth() == modes[count]->w && war_GetHeight() == modes[count]->h) { current = count; } } // Increment and clip if required // Hide resolutions lower than Warzone can support oldcurrent = current; do { if (!mouseReleased(MOUSE_RMB)) { if (--current < 0) current = count - 1; } else { if (++current == count) current = 0; } } while ((modes[current]->w < 640 || modes[current]->h < 480) && current != oldcurrent); // Set the new width and height (takes effect on restart) war_SetWidth(modes[current]->w); war_SetHeight(modes[current]->h); // Generate the textual representation of the new width and height snprintf(resolution, WIDG_MAXSTR, "%d x %d", modes[current]->w, modes[current]->h); // Update the widget widgSetString(psWScreen, FRONTEND_RESOLUTION_R, resolution); break; } case FRONTEND_TRAP: case FRONTEND_TRAP_R: if (war_GetTrapCursor()) { war_SetTrapCursor(false); widgSetString(psWScreen, FRONTEND_TRAP_R, _("Off")); } else { war_SetTrapCursor(true); widgSetString(psWScreen, FRONTEND_TRAP_R, _("On")); } break; case FRONTEND_TEXTURESZ: case FRONTEND_TEXTURESZ_R: { int newTexSize = getTextureSize() * 2; // Clip such that 128 <= size <= 2048 if (newTexSize > 2048) { newTexSize = 128; } // Set the new size setTextureSize(newTexSize); // Generate the string representation of the new size snprintf(textureSize, WIDG_MAXSTR, "%d", newTexSize); // Update the widget widgSetString(psWScreen, FRONTEND_TEXTURESZ_R, textureSize); break; } case FRONTEND_VSYNC: case FRONTEND_VSYNC_R: { if (war_GetVsync()) { war_SetVsync(false); widgSetString(psWScreen, FRONTEND_VSYNC_R, _("Off")); } else { war_SetVsync(true); widgSetString(psWScreen, FRONTEND_VSYNC_R, _("On")); } break; } case FRONTEND_QUIT: changeTitleMode(OPTIONS); break; default: break; } if (CancelPressed()) { changeTitleMode(OPTIONS); } widgDisplayScreen(psWScreen); return true; }