Changeset 134
- Timestamp:
- 08/26/10 21:49:12 (18 months ago)
- Location:
- cafu/branches/cafu_to_wx
- Files:
-
- 4 modified
-
Ca3DE/AppCafu.cpp (modified) (5 diffs)
-
Ca3DE/ConDefs.cpp (modified) (2 diffs)
-
Games/DeathMatch/GUIs/MainMenu/MainMenu_main.cgui (modified) (1 diff)
-
Libs/GuiSys/GuiImpl.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
cafu/branches/cafu_to_wx/Ca3DE/AppCafu.cpp
r132 r134 81 81 82 82 83 static bool CompareModes(const wxVideoMode& Mode1, const wxVideoMode& Mode2) 84 { 85 // Compare the widths. 86 if (Mode1.w < Mode2.w) return true; 87 if (Mode1.w > Mode2.w) return false; 88 89 // The widths are equal, now compare the heights. 90 if (Mode1.h < Mode2.h) return true; 91 if (Mode1.h > Mode2.h) return false; 92 93 // The widths and heights are equal, now compare the BPP. 94 if (Mode1.bpp < Mode2.bpp) return true; 95 if (Mode1.bpp > Mode2.bpp) return false; 96 97 // The widths, heights and BPPs are equal, now compare the refresh rate. 98 if (Mode1.refresh < Mode2.refresh) return true; 99 if (Mode1.refresh > Mode2.refresh) return false; 100 101 // The modes are equal. 102 return false; 103 } 104 105 106 static std::string GetVideoModes() 107 { 108 ArrayT<wxVideoMode> Modes; 109 110 { 111 wxDisplay Display; 112 wxArrayVideoModes wxModes=Display.GetModes(); 113 114 for (size_t ModeNr=0; ModeNr<wxModes.GetCount(); ModeNr++) 115 Modes.PushBack(wxModes[ModeNr]); 116 } 117 118 // Remove modes according to certain filter criteria, cutting excessively long mode lists. 119 for (unsigned long ModeNr=0; ModeNr<Modes.Size(); ModeNr++) 120 { 121 const wxVideoMode& Mode=Modes[ModeNr]; 122 123 if (Mode.w==0 || Mode.h==0 || Mode.bpp<15) 124 { 125 Modes.RemoveAt(ModeNr); 126 ModeNr--; 127 continue; 128 } 129 130 for (unsigned long OtherNr=0; OtherNr<Modes.Size(); OtherNr++) 131 { 132 if (OtherNr==ModeNr) continue; 133 134 const wxVideoMode& Other=Modes[OtherNr]; 135 136 if (Mode==Other || (Mode.w==Other.w && Mode.h==Other.h && Mode.bpp<32 && Mode.bpp<Other.bpp)) 137 { 138 Modes.RemoveAt(ModeNr); 139 ModeNr--; 140 break; 141 } 142 } 143 144 // Note that the above loop is written in a way that allows no additional statements here. 145 } 146 147 // Sort the modes by increasing width, height, BPP and refresh rate. 148 Modes.QuickSort(CompareModes); 149 150 // Build the result string. 151 wxString List; 152 153 for (unsigned long ModeNr=0; ModeNr<Modes.Size(); ModeNr++) 154 { 155 const wxVideoMode& Mode=Modes[ModeNr]; 156 157 List+=wxString::Format("%i x %i, %i bpp, %i Hz\n", Mode.w, Mode.h, Mode.bpp, Mode.refresh); 158 } 159 160 return List.ToStdString(); 161 } 162 163 83 164 IMPLEMENT_APP(AppCafuT) 84 165 … … 121 202 122 203 // Parse the command line. 123 if (!wxApp::OnInit()) return false;204 if (!wxApp::OnInit()) { OnExit(); return false; } 124 205 125 206 // Insert legacy dialog here... … … 142 223 MaterialManager->RegisterMaterialScriptsInDir("Games/"+GameName+"/Materials", "Games/"+GameName+"/"); 143 224 SoundShaderManager->RegisterSoundShaderScriptsInDir("Games/"+GameName+"/SoundShader", "Games/"+GameName+"/"); 225 226 227 // The console variable VideoModes is initialized here, because under wxGTK, using wxDisplay requires 228 // that the wxWidgets library (and thus GTK) is initialized first. 229 // Note that the format of the VideoModes string is fixed - it is parsed by the Main Menu GUI in order to populate the choice box. 230 static ConVarT VideoModes("VideoModes", GetVideoModes(), ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_READ_ONLY, "The list of video modes that are available on your system."); 144 231 145 232 … … 204 291 "but it didn't work out (zero values mean system defaults).\n"+ 205 292 "We will continue with the currently active video mode instead, where you can press F11 to toggle full-screen mode.\n\n"+ 206 "Alternatively, you can set a different video mode at the Options menu,\n"+ 207 "or tweak the video mode details via the console variables.\n", 293 "Alternatively, you can set a different video mode at the Options menu, or tweak the video mode details via the console variables.\n", 208 294 "Could not change the video mode", wxOK | wxICON_EXCLAMATION); 209 295 … … 301 387 302 388 if (Parser.Found("con", &s)) ConsoleInterpreter->RunCommand(s.ToStdString()); 303 if (Parser.Found("svGame", &s)) Options_ServerGameName=s ;304 if (Parser.Found("svWorld", &s)) Options_ServerWorldName=s ;305 if (Parser.Found("svPort", &i)) Options_ServerPortNr=i ;389 if (Parser.Found("svGame", &s)) Options_ServerGameName=s.ToStdString(); 390 if (Parser.Found("svWorld", &s)) Options_ServerWorldName=s.ToStdString(); 391 if (Parser.Found("svPort", &i)) Options_ServerPortNr=int(i); 306 392 if (Parser.Found("noFS") ) Options_ClientFullScreen=false; 307 if (Parser.Found("clPort", &i)) Options_ClientPortNr=i ;308 if (Parser.Found("clRemoteName", &s)) Options_ClientRemoteName=s ;309 if (Parser.Found("clRemotePort", &i)) Options_ClientRemotePortNr=i ;310 if (Parser.Found("clTexDetail", &i)) Options_ClientTextureDetail=i % 3;311 if (Parser.Found("clWinSizeX", &i)) Options_ClientWindowSizeX=i ;312 if (Parser.Found("clWinSizeY", &i)) Options_ClientWindowSizeY=i ;313 if (Parser.Found("clRenderer", &s)) Options_ClientDesiredRenderer=s ;314 if (Parser.Found("clSoundSystem", &s)) Options_ClientDesiredSoundSystem=s ;315 if (Parser.Found("clPlayerName", &s)) Options_DeathMatchPlayerName=s ;316 if (Parser.Found("clModelName", &s)) Options_DeathMatchModelName=s ;393 if (Parser.Found("clPort", &i)) Options_ClientPortNr=int(i); 394 if (Parser.Found("clRemoteName", &s)) Options_ClientRemoteName=s.ToStdString(); 395 if (Parser.Found("clRemotePort", &i)) Options_ClientRemotePortNr=int(i); 396 if (Parser.Found("clTexDetail", &i)) Options_ClientTextureDetail=int(i % 3); 397 if (Parser.Found("clWinSizeX", &i)) Options_ClientWindowSizeX=int(i); 398 if (Parser.Found("clWinSizeY", &i)) Options_ClientWindowSizeY=int(i); 399 if (Parser.Found("clRenderer", &s)) Options_ClientDesiredRenderer=s.ToStdString(); 400 if (Parser.Found("clSoundSystem", &s)) Options_ClientDesiredSoundSystem=s.ToStdString(); 401 if (Parser.Found("clPlayerName", &s)) Options_DeathMatchPlayerName=s.ToStdString(); 402 if (Parser.Found("clModelName", &s)) Options_DeathMatchModelName=s.ToStdString(); 317 403 318 404 if (!Parser.Found("svWorld") && Parser.GetParamCount()==1) 319 Options_ServerWorldName=Parser.GetParam(0) ;405 Options_ServerWorldName=Parser.GetParam(0).ToStdString(); 320 406 321 407 return wxApp::OnCmdLineParsed(Parser); -
cafu/branches/cafu_to_wx/Ca3DE/ConDefs.cpp
r133 r134 77 77 78 78 79 static bool CompareModes(const wxVideoMode& Mode1, const wxVideoMode& Mode2)80 {81 // Compare the widths.82 if (Mode1.w < Mode2.w) return true;83 if (Mode1.w > Mode2.w) return false;84 85 // The widths are equal, now compare the heights.86 if (Mode1.h < Mode2.h) return true;87 if (Mode1.h > Mode2.h) return false;88 89 // The widths and heights are equal, now compare the BPP.90 if (Mode1.bpp < Mode2.bpp) return true;91 if (Mode1.bpp > Mode2.bpp) return false;92 93 // The widths, heights and BPPs are equal, now compare the refresh rate.94 if (Mode1.refresh < Mode2.refresh) return true;95 if (Mode1.refresh > Mode2.refresh) return false;96 97 // The modes are equal.98 return false;99 }100 101 static std::string GetVideoModes()102 {103 ArrayT<wxVideoMode> Modes;104 105 {106 wxDisplay Display;107 wxArrayVideoModes wxModes=Display.GetModes();108 109 for (size_t ModeNr=0; ModeNr<wxModes.GetCount(); ModeNr++)110 Modes.PushBack(wxModes[ModeNr]);111 }112 113 // Remove modes according to certain filter criteria, cutting excessively long mode lists.114 for (unsigned long ModeNr=0; ModeNr<Modes.Size(); ModeNr++)115 {116 const wxVideoMode& Mode=Modes[ModeNr];117 118 if (Mode.w==0 || Mode.h==0 || Mode.bpp<15)119 {120 Modes.RemoveAt(ModeNr);121 ModeNr--;122 continue;123 }124 125 for (unsigned long OtherNr=0; OtherNr<Modes.Size(); OtherNr++)126 {127 if (OtherNr==ModeNr) continue;128 129 const wxVideoMode& Other=Modes[OtherNr];130 131 if (Mode==Other || (Mode.w==Other.w && Mode.h==Other.h && Mode.bpp<32 && Mode.bpp<Other.bpp))132 {133 Modes.RemoveAt(ModeNr);134 ModeNr--;135 break;136 }137 }138 139 // Note that the above loop is written in a way that allows no additional statements here.140 }141 142 // Sort the modes by increasing width, height, BPP and refresh rate.143 Modes.QuickSort(CompareModes);144 145 // Build the result string.146 wxString List;147 148 for (unsigned long ModeNr=0; ModeNr<Modes.Size(); ModeNr++)149 {150 const wxVideoMode& Mode=Modes[ModeNr];151 152 List+=wxString::Format("%i x %i, %i bpp, %i Hz\n", Mode.w, Mode.h, Mode.bpp, Mode.refresh);153 }154 155 return List.ToStdString();156 }157 158 // Note that the format of the VideoModes string is fixed - it is parsed by the Main Menu GUI in order to populate the choice box.159 static ConVarT VideoModes("VideoModes", GetVideoModes(), ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_READ_ONLY, "The list of video modes that are available on your system.");160 161 162 79 static int ConFunc_CleanupPersistentConfig_Callback(lua_State* LuaState) 163 80 { … … 214 131 static int ConFunc_VideoInfo_Callback(lua_State* LuaState) 215 132 { 216 Console->Print(GetVideoModes());133 // Console->Print(GetVideoModes()); 217 134 Console->Print(cf::va("Renderer Info: %s\n", MatSys::Renderer ? MatSys::Renderer->GetDescription() : "[No renderer active.]")); 218 135 return 0; -
cafu/branches/cafu_to_wx/Games/DeathMatch/GUIs/MainMenu/MainMenu_main.cgui
r132 r134 1200 1200 -- but still just handle the case here to be totally sure. 1201 1201 if (VideoOptionsDialog.Frame.ScreenResChoice:GetNumChoices()==0) then 1202 Console.Warning("Console variable VideoModes is empty! ");1202 Console.Warning("Console variable VideoModes is empty!\n"); 1203 1203 1204 1204 VideoOptionsDialog.Frame.ScreenResChoice:Append(" 640 x 480"); -
cafu/branches/cafu_to_wx/Libs/GuiSys/GuiImpl.hpp
r125 r134 29 29 30 30 #include <cstdarg> 31 #include <stdexcept> 31 32 32 33
