From: <sv...@ww...> - 2007-07-09 21:12:19
|
Author: nsmoooose Date: 2007-07-09 14:11:26 -0700 (Mon, 09 Jul 2007) New Revision: 2136 Modified: trunk/csp/bin/sim.py trunk/csp/cspsim/CSPSim.cpp trunk/csp/cspsim/CSPSim.h trunk/csp/data/ui/scripts/startup.py trunk/csp/data/ui/scripts/windows/quitresume.py trunk/csp/data/ui/themes/default/quit_resume.xml Log: It is now possible to return to the main menu from the simulation. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2136 Modified: trunk/csp/bin/sim.py =================================================================== --- trunk/csp/bin/sim.py 2007-07-08 17:35:22 UTC (rev 2135) +++ trunk/csp/bin/sim.py 2007-07-09 21:11:26 UTC (rev 2136) @@ -342,6 +342,7 @@ from csp.data.ui.scripts.startup import UserInterfaceStartup userInterface = UserInterfaceStartup(sim) userInterface.run(); + sim.run() finally: sim.cleanup() Modified: trunk/csp/cspsim/CSPSim.cpp =================================================================== --- trunk/csp/cspsim/CSPSim.cpp 2007-07-08 17:35:22 UTC (rev 2135) +++ trunk/csp/cspsim/CSPSim.cpp 2007-07-09 21:11:26 UTC (rev 2136) @@ -127,7 +127,7 @@ CSPLOG(DEBUG, APP) << "Constructing CSPSim object"; m_Clean = true; - + m_UnloadSimulationRequested = false; m_Paused = true; m_Finished = false; @@ -535,8 +535,26 @@ } void CSPSim::unloadSimulation() { + m_UnloadSimulationRequested = true; } +void CSPSim::unloadSimulationNow() { + m_ActiveObject = NULL; + + // The virtual battlefield + m_Battlefield = NULL; + m_Scene = NULL; + m_NetworkClient = NULL; + + // TODO the terrain will eventually be encapsulated in a Theater class + m_Theater = NULL; + + if(m_Terrain.valid()) { + m_Terrain->deactivate(); + m_Terrain = NULL; + } +} + void CSPSim::displayLogoScreen() { Ref<LogoScreen> logoScreen = new LogoScreen(screenSettings.width, screenSettings.height); logoScreen->onInit(); @@ -648,6 +666,14 @@ if (time_render.elapsed() + time_object_update.elapsed() > 0.05) { //std::cout << "long frame: update=" << time_object_update.elapsed() << " render=" << time_render.elapsed() << " lo=" << lopri << "\n"; } + + // Check if someone has requested that the simulation should be + // unloaded. This usually means that the user wants to go back to + // the main menu. + if(m_UnloadSimulationRequested) { + unloadSimulationNow(); + m_UnloadSimulationRequested = false; + } } //m_Battlefield->dumpObjectHistory(); } Modified: trunk/csp/cspsim/CSPSim.h =================================================================== --- trunk/csp/cspsim/CSPSim.h 2007-07-08 17:35:22 UTC (rev 2135) +++ trunk/csp/cspsim/CSPSim.h 2007-07-09 21:11:26 UTC (rev 2136) @@ -99,12 +99,13 @@ virtual void loadSimulation(); // Unloads all objects used during a simulation. virtual void unloadSimulation(); + virtual void unloadSimulationNow(); virtual void displayLogoScreen(); virtual void displayMenuScreen(); virtual void run(); virtual void quit(); virtual void cleanup(); - + virtual wf::Signal* getConfigurationChangedSignal(); virtual config::Configuration* getConfiguration(); virtual void setConfiguration(config::Configuration* config); @@ -158,6 +159,7 @@ bool m_Paused; bool m_Finished; bool m_Clean; + bool m_UnloadSimulationRequested; // The current simulation time/date SimDate m_CurrentTime; Modified: trunk/csp/data/ui/scripts/startup.py =================================================================== --- trunk/csp/data/ui/scripts/startup.py 2007-07-08 17:35:22 UTC (rev 2135) +++ trunk/csp/data/ui/scripts/startup.py 2007-07-09 21:11:26 UTC (rev 2136) @@ -68,7 +68,6 @@ self.displayDesktop() self.displayTopMenu() self.displayMainMenu() - self.cspsim.run() def configuration_Changed(self): self.configuration = self.cspsim.getConfiguration() Modified: trunk/csp/data/ui/scripts/windows/quitresume.py =================================================================== --- trunk/csp/data/ui/scripts/windows/quitresume.py 2007-07-08 17:35:22 UTC (rev 2135) +++ trunk/csp/data/ui/scripts/windows/quitresume.py 2007-07-09 21:11:26 UTC (rev 2136) @@ -57,5 +57,14 @@ self.close() def end_simulation_Click(self): - # self.cspsim.displayMenuScreen() - print 'End requested' + # Start by changing the screen. This makes it possible for us to + # display the main menu and the desktop. + self.cspsim.displayMenuScreen() + # End the simulation by unloading everything. + self.cspsim.unloadSimulation() + + # Use the UserInterfaceStartup class to return to the main menu + # and the desktop. + from csp.data.ui.scripts.startup import UserInterfaceStartup + startup = UserInterfaceStartup(self.cspsim) + startup.run() Modified: trunk/csp/data/ui/themes/default/quit_resume.xml =================================================================== --- trunk/csp/data/ui/themes/default/quit_resume.xml 2007-07-08 17:35:22 UTC (rev 2135) +++ trunk/csp/data/ui/themes/default/quit_resume.xml 2007-07-09 21:11:26 UTC (rev 2136) @@ -13,7 +13,7 @@ <Label CssClass="stripe" LocationX="0" LocationY="30" SizeWidth="428" SizeHeight="10" /> <Button LocationX="47" LocationY="60" SizeWidth="150" SizeHeight="40" Id="resume" Text="${resume}" /> - <Button LocationX="229" LocationY="60" SizeWidth="150" SizeHeight="40" Id="end_simulation" Text="${main_menu}" Enabled="false" /> + <Button LocationX="229" LocationY="60" SizeWidth="150" SizeHeight="40" Id="end_simulation" Text="${main_menu}" /> </Controls> </MultiControlContainer> </Control> |