Changeset 126
- Timestamp:
- 08/23/10 22:34:43 (18 months ago)
- Location:
- cafu/branches/cafu_to_wx/Ca3DE
- Files:
-
- 5 modified
-
AppCafu.cpp (modified) (6 diffs)
-
AppCafu.hpp (modified) (3 diffs)
-
ConDefs.cpp (modified) (2 diffs)
-
MainCanvas.cpp (modified) (3 diffs)
-
MainFrame.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cafu/branches/cafu_to_wx/Ca3DE/AppCafu.cpp
r116 r126 40 40 #include "../Games/Game.hpp" 41 41 42 #include "wx/cmdline.h" 42 43 #include "wx/filename.h" 43 44 #include "wx/msgdlg.h" … … 85 86 AppCafu::AppCafu() 86 87 : wxApp(), 88 m_IsFullScreen(false), 87 89 m_MainFrame(NULL) 88 90 { … … 117 119 118 120 ConsoleInterpreter->RunCommand("dofile('config.lua');"); 121 122 // Parse the command line. 123 if (!wxApp::OnInit()) return false; 119 124 120 125 // Insert legacy dialog here... … … 138 143 SoundShaderManager->RegisterSoundShaderScriptsInDir("Games/"+GameName+"/SoundShader", "Games/"+GameName+"/"); 139 144 145 // Change display mode. 146 wxDisplay Display; 147 148 m_DesktopMode=Display.GetCurrentMode(); 149 150 if (m_DesktopMode.w==0) m_DesktopMode.w=wxGetDisplaySize().x; 151 if (m_DesktopMode.h==0) m_DesktopMode.h=wxGetDisplaySize().y; 152 153 m_CurrentMode=m_DesktopMode; 154 155 extern ConVarT Options_ClientWindowSizeX; 156 extern ConVarT Options_ClientWindowSizeY; 157 extern ConVarT Options_ClientDisplayBPP; 158 extern ConVarT Options_ClientDisplayRefresh; 159 extern ConVarT Options_ClientFullScreen; 160 161 if (Options_ClientFullScreen.GetValueBool()) 162 { 163 const wxVideoMode VideoMode(Options_ClientWindowSizeX.GetValueInt(), 164 Options_ClientWindowSizeY.GetValueInt(), 165 Options_ClientDisplayBPP.GetValueInt(), 166 Options_ClientDisplayRefresh.GetValueInt()); 167 168 if (Display.ChangeMode(VideoMode)) 169 { 170 m_CurrentMode=Display.GetCurrentMode(); 171 m_IsFullScreen=true; 172 } 173 else 174 { 175 wxMessageBox("Cafu tried to change the video mode to\n"+ 176 wxString::Format(" %i x %i, %i BPP at %i Hz,\n", VideoMode.w, VideoMode.h, VideoMode.bpp, VideoMode.refresh)+ 177 "but it didn't work out (zero values mean system defaults).\n"+ 178 "We will use the currently active video mode instead and continue.\n\n"+ 179 "Alternatively, you can set a different video mode at the Options menu,\n"+ 180 "or tweak the video mode details via the console variables.\n", 181 "Could not change the video mode", wxOK | wxICON_EXCLAMATION); 182 } 183 } 184 140 185 // Create the main frame. 141 186 m_MainFrame=new MainFrameT(); 142 187 SetTopWindow(m_MainFrame); 143 188 144 return wxApp::OnInit();189 return true; 145 190 } 146 191 … … 148 193 int AppCafu::OnExit() 149 194 { 195 if (m_CurrentMode!=m_DesktopMode) 196 { 197 wxDisplay Display; 198 199 Display.ChangeMode(m_DesktopMode); 200 } 201 150 202 delete g_WinSock; 151 203 g_WinSock=NULL; … … 157 209 return wxApp::OnExit(); 158 210 } 211 212 213 extern ConVarT Options_ServerGameName; 214 extern ConVarT Options_ServerWorldName; 215 extern ConVarT Options_ServerPortNr; 216 extern ConVarT Options_ClientPortNr; 217 extern ConVarT Options_ClientRemoteName; 218 extern ConVarT Options_ClientRemotePortNr; 219 220 extern ConVarT Options_ClientWindowSizeX; 221 extern ConVarT Options_ClientWindowSizeY; 222 extern ConVarT Options_ClientDisplayBPP; // TODO 223 extern ConVarT Options_ClientDisplayRefresh; // TODO 224 extern ConVarT Options_ClientFullScreen; 225 226 extern ConVarT Options_ClientDesiredRenderer; 227 extern ConVarT Options_ClientDesiredSoundSystem; 228 extern ConVarT Options_ClientTextureDetail; 229 extern ConVarT Options_DeathMatchPlayerName; 230 extern ConVarT Options_DeathMatchModelName; 231 232 233 void AppCafu::OnInitCmdLine(wxCmdLineParser& Parser) 234 { 235 Parser.AddOption("con", "", "Runs the given commands in the console. -con \"x=3;\" is equivalent to appending x=3; to the end of the config.lua file.", wxCMD_LINE_VAL_STRING); 236 Parser.AddOption("svGame", "", "Name of the MOD / game the server should run ["+Options_ServerGameName.GetValueString()+"]. Case sensitive!", wxCMD_LINE_VAL_STRING); 237 Parser.AddOption("svWorld", "", "Name of the world the server should run ["+Options_ServerWorldName.GetValueString()+"]. Case sensitive!", wxCMD_LINE_VAL_STRING); 238 Parser.AddOption("svPort", "", wxString::Format("Server port number [%i].", Options_ServerPortNr.GetValueInt()), wxCMD_LINE_VAL_NUMBER); 239 Parser.AddSwitch("noFS", "clNoFullscreen", "Don't run full-screen, but rather in a window."); 240 Parser.AddOption("clPort", "", wxString::Format("Client port number [%i].", Options_ClientPortNr.GetValueInt()), wxCMD_LINE_VAL_NUMBER); 241 Parser.AddOption("clRemoteName", "", "Name or IP of the server we connect to ["+Options_ClientRemoteName.GetValueString()+"].", wxCMD_LINE_VAL_STRING); 242 Parser.AddOption("clRemotePort", "", wxString::Format("Port number of the remote server [%i].", Options_ClientRemotePortNr.GetValueInt()), wxCMD_LINE_VAL_NUMBER); 243 Parser.AddOption("clTexDetail", "", wxString::Format("0 high detail, 1 medium detail, 2 low detail [%i].", Options_ClientTextureDetail.GetValueInt()), wxCMD_LINE_VAL_NUMBER); 244 Parser.AddOption("clWinSizeX", "", wxString::Format("If not full-screen, this is the width of the window [%i].", Options_ClientWindowSizeX.GetValueInt()), wxCMD_LINE_VAL_NUMBER); 245 Parser.AddOption("clWinSizeY", "", wxString::Format("If not full-screen, this is the height of the window [%i].", Options_ClientWindowSizeY.GetValueInt()), wxCMD_LINE_VAL_NUMBER); 246 Parser.AddOption("clRenderer", "", "Override the auto-selection of the best available renderer [auto].", wxCMD_LINE_VAL_STRING); 247 Parser.AddOption("clSoundSystem", "", "Override the auto-selection of the best available sound system [auto].", wxCMD_LINE_VAL_STRING); 248 Parser.AddOption("clPlayerName", "", "Player name ["+Options_DeathMatchPlayerName.GetValueString()+"].", wxCMD_LINE_VAL_STRING); 249 Parser.AddOption("clModelName", "", "Name of the players model ["+Options_DeathMatchModelName.GetValueString()+"].", wxCMD_LINE_VAL_STRING); 250 251 wxApp::OnInitCmdLine(Parser); 252 Parser.AddUsageText("\nDefault values are enclosed in [brackets]."); 253 Parser.AddUsageText("It is also ok to omit the \"-svWorld\" option for specifying a world name: \"Cafu MyWorld\" is the same as \"Cafu -svWorld MyWorld\".\n"); 254 Parser.SetSwitchChars("-"); 255 } 256 257 258 bool AppCafu::OnCmdLineParsed(wxCmdLineParser& Parser) 259 { 260 long int i=0; 261 wxString s=""; 262 263 if (Parser.Found("con", &s)) ConsoleInterpreter->RunCommand(s.ToStdString()); 264 if (Parser.Found("svGame", &s)) Options_ServerGameName=s; 265 if (Parser.Found("svWorld", &s)) Options_ServerWorldName=s; 266 if (Parser.Found("svPort", &i)) Options_ServerPortNr=i; 267 if (Parser.Found("noFS") ) Options_ClientFullScreen=false; 268 if (Parser.Found("clPort", &i)) Options_ClientPortNr=i; 269 if (Parser.Found("clRemoteName", &s)) Options_ClientRemoteName=s; 270 if (Parser.Found("clRemotePort", &i)) Options_ClientRemotePortNr=i; 271 if (Parser.Found("clTexDetail", &i)) Options_ClientTextureDetail=i % 3; 272 if (Parser.Found("clWinSizeX", &i)) Options_ClientWindowSizeX=i; 273 if (Parser.Found("clWinSizeY", &i)) Options_ClientWindowSizeY=i; 274 if (Parser.Found("clRenderer", &s)) Options_ClientDesiredRenderer=s; 275 if (Parser.Found("clSoundSystem", &s)) Options_ClientDesiredSoundSystem=s; 276 if (Parser.Found("clPlayerName", &s)) Options_DeathMatchPlayerName=s; 277 if (Parser.Found("clModelName", &s)) Options_DeathMatchModelName=s; 278 279 if (!Parser.Found("svWorld") && Parser.GetParamCount()==1) 280 Options_ServerWorldName=Parser.GetParam(0); 281 282 return wxApp::OnCmdLineParsed(Parser); 283 } -
cafu/branches/cafu_to_wx/Ca3DE/AppCafu.hpp
r116 r126 36 36 37 37 #include "wx/app.h" 38 #include "wx/display.h" 38 39 39 40 … … 48 49 AppCafu(); 49 50 51 /// This method returns the desktops video mode (that was active before the Cafu application was started). 52 const wxVideoMode& GetDesktopMode() const { return m_DesktopMode; } 53 54 /// This method returns the current video mode, which may be identical to the desktops video mode 55 /// (in which case the mode as not switched at all at app init), or any custom mode. 56 const wxVideoMode& GetCurrentMode() const { return m_CurrentMode; } 57 58 /// Returns whether we're running in full-screen mode (with video mode changed, no frame border, etc.) 59 /// or in a regular window (on the desktop, with frame border, etc.). 60 bool IsFullScreen() const { return m_IsFullScreen; } 61 62 /// Returns the main frame of the Cafu application. 50 63 MainFrameT* GetMainFrame() const { return m_MainFrame; } 51 64 … … 56 69 private: 57 70 71 void OnInitCmdLine(wxCmdLineParser& Parser); 72 bool OnCmdLineParsed(wxCmdLineParser& Parser); 73 74 wxVideoMode m_DesktopMode; ///< The desktops video mode. 75 wxVideoMode m_CurrentMode; ///< The video mode we're currently using. 76 bool m_IsFullScreen; ///< Whether we are running in full-screen mode (with video mode changed, no frame border, etc.) or in a regular window (on the desktop, with frame border, etc.). 58 77 MainFrameT* m_MainFrame; 59 78 }; -
cafu/branches/cafu_to_wx/Ca3DE/ConDefs.cpp
r116 r126 54 54 /*static*/ ConVarT Options_DeathMatchPlayerName ("dlg_dmPlayerName", "Player", ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "Player name for the DeathMatch game."); 55 55 /*static*/ ConVarT Options_DeathMatchModelName ("dlg_dmModelName", "James", ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "Name of the model to use for the DeathMatch game."); 56 /*static*/ ConVarT Options_ClientFullScreen ("dlg_clFullScreen", true, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, " If the clients runs in full-screen or windowed mode.");56 /*static*/ ConVarT Options_ClientFullScreen ("dlg_clFullScreen", true, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "When true, the video mode is changed on startup and fullscreen display is used. Otherwise, Cafu runs in an application window on the desktop."); 57 57 /*static*/ ConVarT Options_ClientWindowSizeX ("dlg_clWindowSizeX", 1024, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "The size of the client window in X direction."); 58 58 /*static*/ ConVarT Options_ClientWindowSizeY ("dlg_clWindowSizeY", 768, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "The size of the client window in Y direction."); … … 62 62 /*static*/ ConVarT Options_ClientRemoteName ("dlg_clRemoteName", "192.168.1.1", ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "Name or IP of the server the client connects to."); 63 63 /*static*/ ConVarT Options_ClientRemotePortNr ("dlg_clRemotePort", 30000, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "Port number of the remote server.", 0, 0xFFFF); 64 /*static*/ ConVarT Options_ClientDisplayBPP ("dlg_clDisplayBPP", 1, ConVarT::FLAG_MAIN_EXE, "Use 0 for 16 BPP, 1 for 32 BPP.", 0, 1); 64 /*static*/ ConVarT Options_ClientDisplayBPP ("dlg_clDisplayBPP", 32, ConVarT::FLAG_MAIN_EXE, "The display depth in bits-per-pixel. Normally use 32, or 0 for system default.", 0, 64); 65 /*static*/ ConVarT Options_ClientDisplayRefresh ("dlg_clDisplayRefresh", 0, ConVarT::FLAG_MAIN_EXE, "The display refresh rate. Use 0 for system default, check with your monitor specs for any other value."); 65 66 /*static*/ ConVarT Options_ClientTextureDetail ("dlg_clTextureDetail", 0, ConVarT::FLAG_MAIN_EXE | ConVarT::FLAG_PERSISTENT, "0 high detail, 1 medium detail, 2 low detail", 0, 2); 66 67 /*static*/ ConVarT Options_ServerGameName ("dlg_svGameName", "DeathMatch", ConVarT::FLAG_MAIN_EXE, "Name of the game (MOD) to load."); -
cafu/branches/cafu_to_wx/Ca3DE/MainCanvas.cpp
r125 r126 125 125 m_GLContext=new wxGLContext(this); 126 126 127 SetCursor(wxCURSOR_BLANK); 127 128 SetBackgroundStyle(wxBG_STYLE_PAINT); 128 129 } … … 504 505 if (m_InitState==INIT_REQUIRED) 505 506 { 507 dc.SetBackground(*wxBLACK_BRUSH); 508 dc.Clear(); 509 dc.SetBackgroundMode(wxTRANSPARENT); 510 dc.SetTextForeground(wxColour(255, 200, 0)); 511 dc.DrawText("Initializing Cafu...", 10, 40); 512 506 513 // This code is in this place due to a few peculiarities of OpenGL under GTK that do not exist under MSW: 507 514 // - An OpenGL context can only be made current with a canvas that is shown on the screen. … … 892 899 return; 893 900 } 901 902 case WXK_F11: 903 { 904 m_Parent->ShowFullScreen(!m_Parent->IsFullScreen()); 905 return; 906 } 894 907 } 895 908 -
cafu/branches/cafu_to_wx/Ca3DE/MainFrame.cpp
r116 r126 23 23 24 24 #include "MainFrame.hpp" 25 #include "AppCafu.hpp" 25 26 #include "MainCanvas.hpp" 26 27 … … 31 32 32 33 34 static long int GetStyle() 35 { 36 // This seems to be a limitation of Windows: 37 // Creating a frame with a border that is shown full-screen in a video mode 38 // other than the default (desktop) mode does not properly fill the screen... 39 return wxGetApp().IsFullScreen() ? 0 : wxDEFAULT_FRAME_STYLE; 40 } 41 42 33 43 MainFrameT::MainFrameT() 34 : wxFrame(NULL /*parent*/, wxID_ANY, wxString("Cafu Engine - ") + __DATE__ ),44 : wxFrame(NULL /*parent*/, wxID_ANY, wxString("Cafu Engine - ") + __DATE__, wxDefaultPosition, wxDefaultSize, GetStyle()), 35 45 m_MainCanvas(NULL) 36 46 { … … 49 59 50 60 // Show the frame - it is not shown by default... 51 Show();61 if (wxGetApp().IsFullScreen()) ShowFullScreen(true); else Show(); 52 62 } 53 63
