2015-01-08 13:29:27 -08:00
/* Copyright (C) 2015 Wildfire Games.
2009-06-20 09:13:29 -07:00
* This file is part of 0 A . D .
*
* 0 A . D . is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 2 of the License , or
* ( at your option ) any later version .
*
* 0 A . D . is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with 0 A . D . If not , see < http : //www.gnu.org/licenses/>.
*/
2007-06-05 11:35:05 -07:00
# include "precompiled.h"
2006-04-23 16:14:18 -07:00
# include "ScenarioEditor.h"
2007-06-05 11:16:55 -07:00
# include "wx/busyinfo.h"
2014-11-20 12:52:32 -08:00
# include "wx/clipbrd.h"
2007-02-25 13:11:57 -08:00
# include "wx/config.h"
2011-09-01 19:27:55 -07:00
# include "wx/dir.h"
2006-04-23 16:14:18 -07:00
# include "wx/evtloop.h"
2007-06-05 11:16:55 -07:00
# include "wx/ffile.h"
2006-11-11 20:02:36 -08:00
# include "wx/filename.h"
2007-06-05 11:16:55 -07:00
# include "wx/image.h"
2014-11-20 12:52:32 -08:00
# include "wx/sstream.h"
2011-09-01 19:27:55 -07:00
# include "wx/sysopt.h"
2007-06-05 11:16:55 -07:00
# include "wx/tooltip.h"
2014-11-20 12:52:32 -08:00
# include "wx/xml/xml.h"
2006-04-23 16:14:18 -07:00
2006-05-30 22:27:02 -07:00
# include "General/AtlasEventLoop.h"
2006-07-12 07:49:10 -07:00
# include "General/Datafile.h"
2006-05-30 22:27:02 -07:00
2009-06-26 15:43:49 -07:00
# include "CustomControls/Buttons/ToolButton.h"
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
# include "CustomControls/Canvas/Canvas.h"
2011-08-28 14:10:45 -07:00
# include "CustomControls/HighResTimer/HighResTimer.h"
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
# include "CustomControls/MapDialog/MapDialog.h"
2006-04-23 16:14:18 -07:00
# include "GameInterface/MessagePasser.h"
# include "GameInterface/Messages.h"
2010-06-01 17:36:21 -07:00
# include "Misc/KeyMap.h"
2006-11-11 20:02:36 -08:00
# include "Tools/Common/Tools.h"
2007-06-12 15:01:25 -07:00
# include "Tools/Common/Brushes.h"
2007-06-14 05:11:22 -07:00
# include "Tools/Common/MiscState.h"
2006-04-23 16:14:18 -07:00
static HighResTimer g_Timer ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
using namespace AtlasMessage ;
2006-04-23 16:14:18 -07:00
//////////////////////////////////////////////////////////////////////////
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
// GL functions exported from DLL, and called by game (in a separate
// thread to the standard wx one)
2007-01-02 10:11:00 -08:00
ATLASDLLIMPEXP void Atlas_GLSetCurrent ( void * canvas )
2006-04-23 16:14:18 -07:00
{
2011-08-18 16:38:11 -07:00
static_cast < Canvas * > ( canvas ) - > SetCurrent ( ) ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
}
2007-01-02 10:11:00 -08:00
ATLASDLLIMPEXP void Atlas_GLSwapBuffers ( void * canvas )
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
{
2011-08-18 16:38:11 -07:00
static_cast < Canvas * > ( canvas ) - > SwapBuffers ( ) ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
}
2006-04-23 16:14:18 -07:00
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
//////////////////////////////////////////////////////////////////////////
class GameCanvas : public Canvas
{
public :
2007-09-03 16:50:25 -07:00
GameCanvas ( ScenarioEditor & scenarioEditor , wxWindow * parent , int * attribList )
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
: Canvas ( parent , attribList , wxWANTS_CHARS ) ,
2007-09-03 16:50:25 -07:00
m_ScenarioEditor ( scenarioEditor ) , m_MouseState ( NONE ) , m_LastMouseState ( NONE )
2006-04-23 16:14:18 -07:00
{
}
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
private :
2006-04-23 16:14:18 -07:00
bool KeyScroll ( wxKeyEvent & evt , bool enable )
{
int dir ;
switch ( evt . GetKeyCode ( ) )
{
2010-06-02 03:13:26 -07:00
case ' A ' : case WXK_LEFT : dir = eScrollConstantDir : : LEFT ; break ;
case ' D ' : case WXK_RIGHT : dir = eScrollConstantDir : : RIGHT ; break ;
case ' W ' : case WXK_UP : dir = eScrollConstantDir : : FORWARDS ; break ;
case ' S ' : case WXK_DOWN : dir = eScrollConstantDir : : BACKWARDS ; break ;
2014-06-29 14:30:51 -07:00
case ' Q ' : case ' [ ' : dir = eScrollConstantDir : : CLOCKWISE ; break ;
case ' E ' : case ' ] ' : dir = eScrollConstantDir : : ANTICLOCKWISE ; break ;
2006-04-23 16:14:18 -07:00
case WXK_SHIFT : case WXK_CONTROL : dir = - 1 ; break ;
default : return false ;
}
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
float speed = 120.f * ScenarioEditor : : GetSpeedModifier ( ) ;
2006-04-23 16:14:18 -07:00
if ( dir = = - 1 ) // changed modifier keys - update all currently-scrolling directions
{
2010-04-17 04:28:54 -07:00
if ( wxGetKeyState ( WXK_LEFT ) ) POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : LEFT , speed ) ) ;
if ( wxGetKeyState ( WXK_RIGHT ) ) POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : RIGHT , speed ) ) ;
if ( wxGetKeyState ( WXK_UP ) ) POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : FORWARDS , speed ) ) ;
if ( wxGetKeyState ( WXK_DOWN ) ) POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : BACKWARDS , speed ) ) ;
2014-06-29 14:30:51 -07:00
if ( wxGetKeyState ( ( wxKeyCode ) ' [ ' ) ) POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : CLOCKWISE , speed ) ) ;
if ( wxGetKeyState ( ( wxKeyCode ) ' ] ' ) ) POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : ANTICLOCKWISE , speed ) ) ;
2010-06-01 17:36:21 -07:00
return false ;
2006-04-23 16:14:18 -07:00
}
else
{
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , dir , enable ? speed : 0.0f ) ) ;
2010-06-01 17:36:21 -07:00
return true ;
2006-04-23 16:14:18 -07:00
}
}
void OnKeyDown ( wxKeyEvent & evt )
{
2011-05-27 14:56:43 -07:00
if ( m_ScenarioEditor . GetToolManager ( ) . GetCurrentTool ( ) - > OnKey ( evt , ITool : : KEY_DOWN ) )
2006-04-23 16:14:18 -07:00
{
// Key event has been handled by the tool, so don't try
// to use it for camera motion too
return ;
}
if ( KeyScroll ( evt , true ) )
return ;
2010-06-01 17:36:21 -07:00
// Slight hack: Only pass 'special' keys; normal keys will generate a translated Char event instead
if ( evt . GetKeyCode ( ) > = 256 )
POST_MESSAGE ( GuiKeyEvent , ( GetSDLKeyFromWxKeyCode ( evt . GetKeyCode ( ) ) , evt . GetUnicodeKey ( ) , true ) ) ;
2006-04-23 16:14:18 -07:00
evt . Skip ( ) ;
}
void OnKeyUp ( wxKeyEvent & evt )
{
2011-05-27 14:56:43 -07:00
if ( m_ScenarioEditor . GetToolManager ( ) . GetCurrentTool ( ) - > OnKey ( evt , ITool : : KEY_UP ) )
2006-04-23 16:14:18 -07:00
return ;
if ( KeyScroll ( evt , false ) )
return ;
2010-06-01 17:36:21 -07:00
// Slight hack: Only pass 'special' keys; normal keys will generate a translated Char event instead
if ( evt . GetKeyCode ( ) > = 256 )
POST_MESSAGE ( GuiKeyEvent , ( GetSDLKeyFromWxKeyCode ( evt . GetKeyCode ( ) ) , evt . GetUnicodeKey ( ) , false ) ) ;
2006-04-23 16:14:18 -07:00
evt . Skip ( ) ;
}
void OnChar ( wxKeyEvent & evt )
{
2011-05-27 14:56:43 -07:00
if ( m_ScenarioEditor . GetToolManager ( ) . GetCurrentTool ( ) - > OnKey ( evt , ITool : : KEY_CHAR ) )
2006-04-23 16:14:18 -07:00
return ;
2007-09-03 16:50:25 -07:00
// Alt+enter toggles fullscreen
if ( evt . GetKeyCode ( ) = = WXK_RETURN & & wxGetKeyState ( WXK_ALT ) )
{
if ( m_ScenarioEditor . IsFullScreen ( ) )
m_ScenarioEditor . ShowFullScreen ( false ) ;
else
m_ScenarioEditor . ShowFullScreen ( true , wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION ) ;
return ;
}
2011-02-11 15:56:55 -08:00
if ( evt . GetKeyCode ( ) = = ' c ' )
{
POST_MESSAGE ( CameraReset , ( ) ) ;
return ;
}
2006-04-23 16:14:18 -07:00
int dir = 0 ;
if ( evt . GetKeyCode ( ) = = ' - ' | | evt . GetKeyCode ( ) = = ' _ ' )
dir = - 1 ;
else if ( evt . GetKeyCode ( ) = = ' + ' | | evt . GetKeyCode ( ) = = ' = ' )
dir = + 1 ;
// TODO: internationalisation (-/_ and +/= don't always share a key)
if ( dir )
{
2010-06-01 17:36:21 -07:00
float speed = 16.f * ScenarioEditor : : GetSpeedModifier ( ) ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
POST_MESSAGE ( SmoothZoom , ( eRenderView : : GAME , speed * dir ) ) ;
2006-04-23 16:14:18 -07:00
}
else
2010-06-01 17:36:21 -07:00
{
2011-02-25 15:53:09 -08:00
// Slight hack: Only pass 'normal' keys; special keys will generate a KeyDown/KeyUp event instead
if ( evt . GetKeyCode ( ) < 256 )
POST_MESSAGE ( GuiCharEvent , ( GetSDLKeyFromWxKeyCode ( evt . GetKeyCode ( ) ) , evt . GetUnicodeKey ( ) ) ) ;
2010-06-01 17:36:21 -07:00
2006-04-23 16:14:18 -07:00
evt . Skip ( ) ;
2010-06-01 17:36:21 -07:00
}
2006-04-23 16:14:18 -07:00
}
2010-06-02 03:13:26 -07:00
void OnKillFocus ( wxFocusEvent & evt )
{
// Stop any scrolling, since otherwise we'll carry on forever if
// we lose focus and the KeyUp events go to a different window
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : LEFT , 0.0f ) ) ;
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : RIGHT , 0.0f ) ) ;
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : FORWARDS , 0.0f ) ) ;
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : BACKWARDS , 0.0f ) ) ;
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : CLOCKWISE , 0.0f ) ) ;
POST_MESSAGE ( ScrollConstant , ( eRenderView : : GAME , eScrollConstantDir : : ANTICLOCKWISE , 0.0f ) ) ;
evt . Skip ( ) ;
}
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
virtual void HandleMouseEvent ( wxMouseEvent & evt )
2006-04-23 16:14:18 -07:00
{
// TODO or at least to think about: When using other controls in the
// editor, it's annoying that keyboard/scrollwheel no longer navigate
// around the world until you click on it.
// Setting focus back whenever the mouse moves over the GL window
// feels like a fairly natural solution to me, since I can use
// e.g. brush-editing controls normally, and then move the mouse to
// see the brush outline and magically get given back full control
2012-04-28 20:20:00 -07:00
// of the camera.
if ( evt . Moving ( ) )
2006-04-23 16:14:18 -07:00
SetFocus ( ) ;
2011-05-27 14:56:43 -07:00
if ( m_ScenarioEditor . GetToolManager ( ) . GetCurrentTool ( ) - > OnMouse ( evt ) )
2006-04-23 16:14:18 -07:00
{
// Mouse event has been handled by the tool, so don't try
// to use it for camera motion too
return ;
}
2006-06-11 00:03:59 -07:00
// Global mouse event handlers (for camera motion)
2006-04-23 16:14:18 -07:00
if ( evt . GetWheelRotation ( ) )
{
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
float speed = 16.f * ScenarioEditor : : GetSpeedModifier ( ) ;
POST_MESSAGE ( SmoothZoom , ( eRenderView : : GAME , evt . GetWheelRotation ( ) * speed / evt . GetWheelDelta ( ) ) ) ;
2006-04-23 16:14:18 -07:00
}
else
{
if ( evt . MiddleIsDown ( ) )
{
2006-06-11 00:03:59 -07:00
if ( wxGetKeyState ( WXK_CONTROL ) | | evt . RightIsDown ( ) )
2006-04-23 16:14:18 -07:00
m_MouseState = ROTATEAROUND ;
else
m_MouseState = SCROLL ;
}
else
m_MouseState = NONE ;
if ( m_MouseState ! = m_LastMouseState )
{
switch ( m_MouseState )
{
case NONE : break ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
case SCROLL : POST_MESSAGE ( Scroll , ( eRenderView : : GAME , eScrollType : : FROM , evt . GetPosition ( ) ) ) ; break ;
case ROTATEAROUND : POST_MESSAGE ( RotateAround , ( eRenderView : : GAME , eRotateAroundType : : FROM , evt . GetPosition ( ) ) ) ; break ;
2006-04-23 16:14:18 -07:00
default : wxFAIL ;
}
m_LastMouseState = m_MouseState ;
}
else if ( evt . Dragging ( ) )
{
switch ( m_MouseState )
{
case NONE : break ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
case SCROLL : POST_MESSAGE ( Scroll , ( eRenderView : : GAME , eScrollType : : TO , evt . GetPosition ( ) ) ) ; break ;
case ROTATEAROUND : POST_MESSAGE ( RotateAround , ( eRenderView : : GAME , eRotateAroundType : : TO , evt . GetPosition ( ) ) ) ; break ;
2006-04-23 16:14:18 -07:00
default : wxFAIL ;
}
}
}
2010-06-01 17:36:21 -07:00
2012-02-06 16:40:55 -08:00
// Button down and double click appear to be mutually exclusive events,
// meaning a second button down event is not sent before a double click
if ( evt . ButtonDown ( ) | | evt . ButtonDClick ( ) )
2010-06-01 17:36:21 -07:00
POST_MESSAGE ( GuiMouseButtonEvent , ( evt . GetButton ( ) , true , evt . GetPosition ( ) ) ) ;
else if ( evt . ButtonUp ( ) )
POST_MESSAGE ( GuiMouseButtonEvent , ( evt . GetButton ( ) , false , evt . GetPosition ( ) ) ) ;
else if ( evt . GetEventType ( ) = = wxEVT_MOTION )
POST_MESSAGE ( GuiMouseMotionEvent , ( evt . GetPosition ( ) ) ) ;
2006-04-23 16:14:18 -07:00
}
enum { NONE , SCROLL , ROTATEAROUND } ;
int m_MouseState , m_LastMouseState ;
2007-09-03 16:50:25 -07:00
ScenarioEditor & m_ScenarioEditor ;
2007-09-02 16:38:58 -07:00
2006-04-23 16:14:18 -07:00
DECLARE_EVENT_TABLE ( ) ;
} ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
BEGIN_EVENT_TABLE ( GameCanvas , Canvas )
EVT_KEY_DOWN ( GameCanvas : : OnKeyDown )
EVT_KEY_UP ( GameCanvas : : OnKeyUp )
EVT_CHAR ( GameCanvas : : OnChar )
2010-06-02 03:13:26 -07:00
EVT_KILL_FOCUS ( GameCanvas : : OnKillFocus )
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
END_EVENT_TABLE ( )
2006-04-23 16:14:18 -07:00
//////////////////////////////////////////////////////////////////////////
volatile bool g_FrameHasEnded ;
// Called from game thread
ATLASDLLIMPEXP void Atlas_NotifyEndOfFrame ( )
{
g_FrameHasEnded = true ;
}
enum
{
ID_Quit = 1 ,
2006-07-12 07:49:10 -07:00
2011-04-13 21:01:59 -07:00
ID_New ,
2006-07-12 07:49:10 -07:00
ID_Open ,
ID_Save ,
ID_SaveAs ,
2012-08-07 11:49:46 -07:00
ID_ImportHeightmap ,
2006-04-23 16:14:18 -07:00
2014-11-20 12:52:32 -08:00
ID_Copy ,
ID_Paste ,
2006-04-23 16:14:18 -07:00
ID_Wireframe ,
ID_MessageTrace ,
ID_Screenshot ,
2012-03-05 16:15:48 -08:00
ID_BigScreenshot ,
2007-02-01 18:17:15 -08:00
ID_JavaScript ,
2011-02-11 15:56:55 -08:00
ID_CameraReset ,
2011-03-26 13:17:21 -07:00
ID_RenderPathFixed ,
ID_RenderPathShader ,
2011-04-13 21:01:59 -07:00
ID_DumpState ,
ID_DumpBinaryState ,
2006-04-23 16:14:18 -07:00
ID_Toolbar // must be last in the list
} ;
BEGIN_EVENT_TABLE ( ScenarioEditor , wxFrame )
EVT_CLOSE ( ScenarioEditor : : OnClose )
EVT_TIMER ( wxID_ANY , ScenarioEditor : : OnTimer )
2011-04-13 21:01:59 -07:00
EVT_MENU ( ID_New , ScenarioEditor : : OnNew )
2006-07-12 07:49:10 -07:00
EVT_MENU ( ID_Open , ScenarioEditor : : OnOpen )
EVT_MENU ( ID_Save , ScenarioEditor : : OnSave )
EVT_MENU ( ID_SaveAs , ScenarioEditor : : OnSaveAs )
2012-08-07 11:49:46 -07:00
EVT_MENU ( ID_ImportHeightmap , ScenarioEditor : : OnImportHeightmap )
2007-02-09 09:04:55 -08:00
EVT_MENU_RANGE ( wxID_FILE1 , wxID_FILE9 , ScenarioEditor : : OnMRUFile )
2006-07-12 07:49:10 -07:00
2006-04-23 16:14:18 -07:00
EVT_MENU ( ID_Quit , ScenarioEditor : : OnQuit )
EVT_MENU ( wxID_UNDO , ScenarioEditor : : OnUndo )
EVT_MENU ( wxID_REDO , ScenarioEditor : : OnRedo )
2014-11-20 12:52:32 -08:00
EVT_MENU ( ID_Copy , ScenarioEditor : : OnCopy )
EVT_MENU ( ID_Paste , ScenarioEditor : : OnPaste )
2006-04-23 16:14:18 -07:00
EVT_MENU ( ID_Wireframe , ScenarioEditor : : OnWireframe )
EVT_MENU ( ID_MessageTrace , ScenarioEditor : : OnMessageTrace )
EVT_MENU ( ID_Screenshot , ScenarioEditor : : OnScreenshot )
2012-03-05 16:15:48 -08:00
EVT_MENU ( ID_BigScreenshot , ScenarioEditor : : OnScreenshot )
2007-02-01 18:17:15 -08:00
EVT_MENU ( ID_JavaScript , ScenarioEditor : : OnJavaScript )
2011-02-11 15:56:55 -08:00
EVT_MENU ( ID_CameraReset , ScenarioEditor : : OnCameraReset )
2011-04-13 21:01:59 -07:00
EVT_MENU ( ID_DumpState , ScenarioEditor : : OnDumpState )
EVT_MENU ( ID_DumpBinaryState , ScenarioEditor : : OnDumpState )
2011-03-26 13:17:21 -07:00
EVT_MENU ( ID_RenderPathFixed , ScenarioEditor : : OnRenderPath )
EVT_MENU ( ID_RenderPathShader , ScenarioEditor : : OnRenderPath )
2006-04-23 16:14:18 -07:00
2014-11-20 12:52:32 -08:00
EVT_MENU_OPEN ( ScenarioEditor : : OnMenuOpen )
2006-04-23 16:14:18 -07:00
EVT_IDLE ( ScenarioEditor : : OnIdle )
END_EVENT_TABLE ( )
static AtlasWindowCommandProc g_CommandProc ;
AtlasWindowCommandProc & ScenarioEditor : : GetCommandProc ( ) { return g_CommandProc ; }
2014-02-24 12:22:02 -08:00
ScenarioEditor : : ScenarioEditor ( wxWindow * parent )
2006-07-12 07:49:10 -07:00
: wxFrame ( parent , wxID_ANY , _T ( " " ) , wxDefaultPosition , wxSize ( 1024 , 768 ) )
2014-02-24 12:22:02 -08:00
, m_FileHistory ( _T ( " Scenario Editor " ) )
2011-05-27 14:56:43 -07:00
, m_ObjectSettings ( g_SelectedObjects , AtlasMessage : : eRenderView : : GAME )
2007-09-02 16:38:58 -07:00
, m_ToolManager ( this )
2006-04-23 16:14:18 -07:00
{
// Global application initialisation:
2006-07-12 07:49:10 -07:00
2011-08-18 16:38:11 -07:00
wxImage : : AddHandler ( new wxICOHandler ) ;
2011-09-01 19:27:55 -07:00
/* "osx.openfiledialog.always-show-types: Per default a wxFileDialog with wxFD_OPEN
does not show a types - popup on OSX but allows the selection of files from any of
the supported types . Setting this to 1 shows a wxChoice for selection ( if there
is more than one supported filetype ) . " */
wxSystemOptions : : SetOption ( _T ( " osx.openfiledialog.always-show-types " ) , 1 ) ; // has global effect
2006-07-12 07:49:10 -07:00
// wxLog::SetTraceMask(wxTraceMessages);
2012-04-16 19:43:52 -07:00
g_SelectedTexture = _T ( " grass1_spring " ) ;
g_SelectedTexture . NotifyObservers ( ) ;
2006-07-12 07:49:10 -07:00
SetOpenFilename ( _T ( " " ) ) ;
2010-06-01 17:36:21 -07:00
# if defined(__WXMSW__)
2014-10-17 18:53:06 -07:00
m_Icon = wxIcon ( _T ( " ICON_ScenarioEditor " ) ) ; // load from atlas.rc
2010-06-01 17:36:21 -07:00
# else
{
const wxString relativePath ( _T ( " tools/atlas/icons/ScenarioEditor.ico " ) ) ;
wxFileName filename ( relativePath , wxPATH_UNIX ) ;
filename . MakeAbsolute ( Datafile : : GetDataDirectory ( ) ) ;
2014-10-17 18:53:06 -07:00
m_Icon = wxIcon ( filename . GetFullPath ( ) , wxBITMAP_TYPE_ICO ) ;
2010-06-01 17:36:21 -07:00
}
# endif
2014-10-17 18:53:06 -07:00
SetIcon ( m_Icon ) ;
2006-07-12 07:49:10 -07:00
2006-04-23 16:14:18 -07:00
wxToolTip : : Enable ( true ) ;
2006-07-12 07:49:10 -07:00
2006-04-23 16:14:18 -07:00
wxImage : : AddHandler ( new wxPNGHandler ) ;
2010-10-21 16:44:54 -07:00
//////////////////////////////////////////////////////////////////////////
// Do some early game initialisation:
// (This must happen before constructing the GL canvas.)
POST_MESSAGE ( Init , ( ) ) ;
2010-10-23 12:58:45 -07:00
// Wait for it to finish running Init
qPing qry ;
qry . Post ( ) ;
2006-04-23 16:14:18 -07:00
//////////////////////////////////////////////////////////////////////////
// Menu
wxMenuBar * menuBar = new wxMenuBar ;
SetMenuBar ( menuBar ) ;
wxMenu * menuFile = new wxMenu ;
menuBar - > Append ( menuFile , _ ( " &File " ) ) ;
{
2011-04-13 21:01:59 -07:00
menuFile - > Append ( ID_New , _ ( " &New... " ) ) ;
2006-07-12 07:49:10 -07:00
menuFile - > Append ( ID_Open , _ ( " &Open... " ) ) ;
menuFile - > Append ( ID_Save , _ ( " &Save " ) ) ;
menuFile - > Append ( ID_SaveAs , _ ( " Save &As... " ) ) ;
menuFile - > AppendSeparator ( ) ; //-----------
2012-08-07 11:49:46 -07:00
menuFile - > Append ( ID_ImportHeightmap , _ ( " &Import Heightmap... " ) ) ;
menuFile - > AppendSeparator ( ) ; //-----------
2006-04-23 16:14:18 -07:00
menuFile - > Append ( ID_Quit , _ ( " E&xit " ) ) ;
2007-02-09 09:04:55 -08:00
m_FileHistory . UseMenu ( menuFile ) ; //-------
m_FileHistory . AddFilesToMenu ( ) ;
2006-04-23 16:14:18 -07:00
}
2006-07-12 07:49:10 -07:00
// m_menuItem_Save = menuFile->FindItem(ID_Save); // remember this item, to let it be greyed out
// wxASSERT(m_menuItem_Save);
2006-04-23 16:14:18 -07:00
wxMenu * menuEdit = new wxMenu ;
menuBar - > Append ( menuEdit , _ ( " &Edit " ) ) ;
{
menuEdit - > Append ( wxID_UNDO , _ ( " &Undo " ) ) ;
menuEdit - > Append ( wxID_REDO , _ ( " &Redo " ) ) ;
2014-11-20 12:52:32 -08:00
menuEdit - > AppendSeparator ( ) ;
menuEdit - > Append ( ID_Copy , _ ( " &Copy " ) ) ;
menuEdit - > Enable ( ID_Copy , false ) ;
menuEdit - > Append ( ID_Paste , _ ( " &Paste " ) ) ;
menuEdit - > Enable ( ID_Paste , false ) ;
2006-04-23 16:14:18 -07:00
}
2014-11-20 12:52:32 -08:00
g_SelectedObjects . RegisterObserver ( 0 , & ScenarioEditor : : OnSelectedObjectsChange , this ) ;
2006-04-23 16:14:18 -07:00
GetCommandProc ( ) . SetEditMenu ( menuEdit ) ;
GetCommandProc ( ) . Initialize ( ) ;
wxMenu * menuMisc = new wxMenu ;
menuBar - > Append ( menuMisc , _ ( " &Misc hacks " ) ) ;
{
menuMisc - > AppendCheckItem ( ID_Wireframe , _ ( " &Wireframe " ) ) ;
menuMisc - > AppendCheckItem ( ID_MessageTrace , _ ( " Message debug trace " ) ) ;
menuMisc - > Append ( ID_Screenshot , _ ( " &Screenshot " ) ) ;
2012-03-05 16:15:48 -08:00
menuMisc - > Append ( ID_BigScreenshot , _ ( " Big screenshot " ) ) ;
2007-02-01 18:17:15 -08:00
menuMisc - > Append ( ID_JavaScript , _ ( " &JS console " ) ) ;
2011-02-11 15:56:55 -08:00
menuMisc - > Append ( ID_CameraReset , _ ( " &Reset camera " ) ) ;
2011-03-26 13:17:21 -07:00
2011-04-13 21:01:59 -07:00
wxMenu * menuSS = new wxMenu ;
menuMisc - > AppendSubMenu ( menuSS , _ ( " Si&mulation state " ) ) ;
menuSS - > Append ( ID_DumpState , _ ( " &Dump to disk " ) ) ;
menuSS - > Append ( ID_DumpBinaryState , _ ( " Dump &binary to disk " ) ) ;
2011-03-26 13:17:21 -07:00
wxMenu * menuRP = new wxMenu ;
menuMisc - > AppendSubMenu ( menuRP , _ ( " Render &path " ) ) ;
menuRP - > Append ( ID_RenderPathFixed , _ ( " &Fixed function " ) ) ;
2011-04-13 11:28:27 -07:00
menuRP - > Append ( ID_RenderPathShader , _ ( " &Shader (default) " ) ) ;
2006-04-23 16:14:18 -07:00
}
2012-12-19 19:57:17 -08:00
m_FileHistory . LoadFromSubDir ( * wxConfigBase : : Get ( ) ) ;
2007-02-09 09:04:55 -08:00
2006-07-12 07:49:10 -07:00
m_SectionLayout . SetWindow ( this ) ;
2006-04-23 16:14:18 -07:00
// Toolbar:
2011-08-28 14:10:45 -07:00
// wxOSX/Cocoa 2.9 doesn't seem to like SetToolBar, so we use CreateToolBar which implicitly associates
// the toolbar with the frame, and use OnCreateToolBar to construct our custom toolbar
// (this should be equivalent behavior on all platforms)
2011-08-28 20:50:29 -07:00
CreateToolBar ( wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL , ID_Toolbar ) - > Realize ( ) ;
2006-04-23 16:14:18 -07:00
// Set the default tool to be selected
2007-09-02 16:38:58 -07:00
m_ToolManager . SetCurrentTool ( _T ( " " ) ) ;
2006-04-23 16:14:18 -07:00
// Set up GL canvas:
int glAttribList [ ] = {
WX_GL_RGBA ,
WX_GL_DOUBLEBUFFER ,
WX_GL_DEPTH_SIZE , 24 , // TODO: wx documentation doesn't say 24 is valid
2011-03-18 11:07:18 -07:00
WX_GL_STENCIL_SIZE , 8 ,
2015-03-15 16:59:48 -07:00
WX_GL_BUFFER_SIZE , 24 , // color bits
2006-04-23 16:14:18 -07:00
WX_GL_MIN_ALPHA , 8 , // alpha bits
0
} ;
2007-09-03 16:50:25 -07:00
Canvas * canvas = new GameCanvas ( * this , m_SectionLayout . GetCanvasParent ( ) , glAttribList ) ;
2006-04-23 16:14:18 -07:00
m_SectionLayout . SetCanvas ( canvas ) ;
2006-11-11 20:02:36 -08:00
2007-01-03 07:45:13 -08:00
// Set up sidebars:
2007-06-05 11:16:55 -07:00
m_SectionLayout . Build ( * this ) ;
2007-01-03 07:45:13 -08:00
# if defined(__WXMSW__)
2006-04-23 16:14:18 -07:00
// The canvas' context gets made current on creation; but it can only be
// current for one thread at a time, and it needs to be current for the
// thread that is doing the draw calls, so disable it for this one.
wglMakeCurrent ( NULL , NULL ) ;
2011-08-27 17:28:06 -07:00
# elif defined(__WXGTK__) || defined(__WXOSX__) || defined(__WXMAC__)
// Need to make sure the canvas is realised, so that its context is valid
// this solves the "invalid drawable" error
2007-01-03 07:45:13 -08:00
Show ( true ) ;
2015-02-19 21:46:24 -08:00
Raise ( ) ;
2011-08-27 17:28:06 -07:00
# endif
# ifdef __WXGTK__
// TODO: wxSafeYield causes issues on wxOSX 2.9, is it necessary?
2007-01-03 07:45:13 -08:00
wxSafeYield ( ) ;
# endif
2006-04-23 16:14:18 -07:00
// Send setup messages to game engine:
2015-02-19 21:46:24 -08:00
POST_MESSAGE ( InitSDL , ( ) ) ;
2011-11-13 04:57:34 -08:00
POST_MESSAGE ( SetCanvas , ( static_cast < wxGLCanvas * > ( canvas ) ,
canvas - > GetClientSize ( ) . GetWidth ( ) , canvas - > GetClientSize ( ) . GetHeight ( ) ) ) ;
2006-04-23 16:14:18 -07:00
2010-10-21 16:44:54 -07:00
POST_MESSAGE ( InitGraphics , ( ) ) ;
2006-04-23 16:14:18 -07:00
canvas - > InitSize ( ) ;
// Start with a blank map (so that the editor can assume there's always
// a valid map loaded)
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
POST_MESSAGE ( LoadMap , ( _T ( " maps/scenarios/_default.xml " ) ) ) ;
2013-02-22 15:20:59 -08:00
POST_MESSAGE ( SimPlay , ( 0.f , false ) ) ;
2011-04-13 21:01:59 -07:00
2011-05-29 08:02:02 -07:00
// Select the initial sidebar (after the map has loaded)
m_SectionLayout . SelectPage ( _T ( " MapSidebar " ) ) ;
2011-04-13 21:01:59 -07:00
// Wait for blank map
qry . Post ( ) ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
POST_MESSAGE ( RenderEnable , ( eRenderView : : GAME ) ) ;
2006-04-23 16:14:18 -07:00
// Set up a timer to make sure tool-updates happen frequently (in addition
// to the idle handler (which makes them happen more frequently if there's nothing
// else to do))
m_Timer . SetOwner ( this ) ;
m_Timer . Start ( 20 ) ;
}
2011-08-28 14:10:45 -07:00
wxToolBar * ScenarioEditor : : OnCreateToolBar ( long style , wxWindowID id , const wxString & WXUNUSED ( name ) )
{
ToolButtonBar * toolbar = new ToolButtonBar ( m_ToolManager , this , & m_SectionLayout , id , style ) ;
// TODO: configurable small vs large icon images
// (button label; tooltip text; image; internal tool name; section to switch to)
toolbar - > AddToolButton ( _ ( " Default " ) , _ ( " Default " ) , _T ( " default.png " ) , _T ( " " ) , _T ( " " ) ) ;
toolbar - > AddToolButton ( _ ( " Move " ) , _ ( " Move/rotate object " ) , _T ( " moveobject.png " ) , _T ( " TransformObject " ) , _T ( " " ) /*_T("ObjectSidebar")*/ ) ;
toolbar - > AddToolButton ( _ ( " Elevation " ) , _ ( " Alter terrain elevation " ) , _T ( " alterelevation.png " ) , _T ( " AlterElevation " ) , _T ( " " ) /*_T("TerrainSidebar")*/ ) ;
toolbar - > AddToolButton ( _ ( " Smooth " ) , _ ( " Smooth terrain elevation " ) , _T ( " smoothelevation.png " ) , _T ( " SmoothElevation " ) , _T ( " " ) /*_T("TerrainSidebar")*/ ) ;
toolbar - > AddToolButton ( _ ( " Flatten " ) , _ ( " Flatten terrain elevation " ) , _T ( " flattenelevation.png " ) , _T ( " FlattenElevation " ) , _T ( " " ) /*_T("TerrainSidebar")*/ ) ;
toolbar - > AddToolButton ( _ ( " Paint Terrain " ) , _ ( " Paint terrain texture " ) , _T ( " paintterrain.png " ) , _T ( " PaintTerrain " ) , _T ( " " ) /*_T("TerrainSidebar")*/ ) ;
return toolbar ;
}
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
float ScenarioEditor : : GetSpeedModifier ( )
{
if ( wxGetKeyState ( WXK_SHIFT ) & & wxGetKeyState ( WXK_CONTROL ) )
return 1.f / 64.f ;
else if ( wxGetKeyState ( WXK_CONTROL ) )
return 1.f / 4.f ;
else if ( wxGetKeyState ( WXK_SHIFT ) )
return 4.f ;
else
return 1.f ;
}
2015-01-08 13:29:27 -08:00
void ScenarioEditor : : OnClose ( wxCloseEvent & event )
2006-04-23 16:14:18 -07:00
{
2015-01-08 13:29:27 -08:00
if ( event . CanVeto ( ) & & GetCommandProc ( ) . IsDirty ( ) )
{
if ( wxMessageBox ( _T ( " You have unsaved changes. Are you sure you want to quit? " ) , _T ( " Discard unsaved changes? " ) , wxICON_QUESTION | wxYES_NO ) ! = wxYES )
{
event . Veto ( ) ;
return ;
}
}
2007-09-02 16:38:58 -07:00
m_ToolManager . SetCurrentTool ( _T ( " " ) ) ;
2006-04-23 16:14:18 -07:00
2012-12-19 19:57:17 -08:00
m_FileHistory . SaveToSubDir ( * wxConfigBase : : Get ( ) ) ;
2007-02-09 09:04:55 -08:00
2006-06-02 22:08:32 -07:00
POST_MESSAGE ( Shutdown , ( ) ) ;
2006-04-23 16:14:18 -07:00
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
qExit ( ) . Post ( ) ;
2006-04-23 16:14:18 -07:00
// blocks until engine has noticed the message, so we won't be
// destroying the GLCanvas while it's still rendering
Destroy ( ) ;
}
2007-09-02 16:38:58 -07:00
static void UpdateTool ( ToolManager & toolManager )
2006-04-23 16:14:18 -07:00
{
// Don't keep posting events if the game can't keep up
if ( g_FrameHasEnded )
{
g_FrameHasEnded = false ; // (thread safety doesn't matter here)
// TODO: Smoother timing stuff?
static double last = g_Timer . GetTime ( ) ;
double time = g_Timer . GetTime ( ) ;
2011-05-27 14:56:43 -07:00
toolManager . GetCurrentTool ( ) - > OnTick ( time - last ) ;
2006-04-23 16:14:18 -07:00
last = time ;
}
}
void ScenarioEditor : : OnTimer ( wxTimerEvent & )
{
2007-09-02 16:38:58 -07:00
UpdateTool ( m_ToolManager ) ;
2006-04-23 16:14:18 -07:00
}
void ScenarioEditor : : OnIdle ( wxIdleEvent & )
{
2007-09-02 16:38:58 -07:00
UpdateTool ( m_ToolManager ) ;
2006-04-23 16:14:18 -07:00
}
void ScenarioEditor : : OnQuit ( wxCommandEvent & )
{
Close ( ) ;
}
void ScenarioEditor : : OnUndo ( wxCommandEvent & )
{
GetCommandProc ( ) . Undo ( ) ;
}
void ScenarioEditor : : OnRedo ( wxCommandEvent & )
{
GetCommandProc ( ) . Redo ( ) ;
}
2014-11-20 12:52:32 -08:00
void ScenarioEditor : : OnCopy ( wxCommandEvent & WXUNUSED ( event ) )
{
if ( GetToolManager ( ) . GetCurrentToolName ( ) = = _T ( " TransformObject " ) )
GetToolManager ( ) . GetCurrentTool ( ) - > OnCommand ( _T ( " copy " ) , NULL ) ;
}
void ScenarioEditor : : OnPaste ( wxCommandEvent & WXUNUSED ( event ) )
{
if ( GetToolManager ( ) . GetCurrentToolName ( ) ! = _T ( " TransformObject " ) )
GetToolManager ( ) . SetCurrentTool ( _T ( " TransformObject " ) , NULL ) ;
GetToolManager ( ) . GetCurrentTool ( ) - > OnCommand ( _T ( " paste " ) , NULL ) ;
}
2006-04-23 16:14:18 -07:00
//////////////////////////////////////////////////////////////////////////
2011-04-13 21:01:59 -07:00
void ScenarioEditor : : OnNew ( wxCommandEvent & WXUNUSED ( event ) )
{
2011-05-29 08:02:02 -07:00
if ( wxMessageBox ( _ ( " Discard current map and start blank new map? " ) , _ ( " New map " ) , wxOK | wxCANCEL | wxICON_QUESTION , this ) = = wxOK )
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
OpenFile ( _T ( " " ) , _T ( " maps/scenarios/_default.xml " ) ) ;
2011-04-13 21:01:59 -07:00
}
2011-10-20 16:45:27 -07:00
bool ScenarioEditor : : OpenFile ( const wxString & name , const wxString & filename )
2007-02-09 09:04:55 -08:00
{
2011-10-20 16:45:27 -07:00
wxBusyInfo busy ( _ ( " Loading " ) + name ) ;
2007-02-09 09:04:55 -08:00
wxBusyCursor busyc ;
2011-10-20 16:45:27 -07:00
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
AtlasMessage : : qVFSFileExists qry ( filename . wc_str ( ) ) ;
2011-10-20 16:45:27 -07:00
qry . Post ( ) ;
if ( ! qry . exists )
return false ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2007-02-09 09:04:55 -08:00
// Deactivate tools, so they don't carry forwards into the new CWorld
// and crash.
2007-09-02 16:38:58 -07:00
m_ToolManager . SetCurrentTool ( _T ( " " ) ) ;
2007-02-09 09:04:55 -08:00
// TODO: clear the undo buffer, etc
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
std : : wstring map ( filename . wc_str ( ) ) ;
2007-02-09 09:04:55 -08:00
POST_MESSAGE ( LoadMap , ( map ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
SetOpenFilename ( name ) ;
2007-02-09 09:04:55 -08:00
2011-10-20 16:45:27 -07:00
{ // Wait for it to load, while the wxBusyInfo is telling the user that we're doing that
qPing qry ;
qry . Post ( ) ;
}
2007-02-09 09:04:55 -08:00
2011-05-29 08:02:02 -07:00
NotifyOnMapReload ( ) ;
2011-04-13 21:01:59 -07:00
2015-01-08 13:29:27 -08:00
GetCommandProc ( ) . ClearCommands ( ) ;
2011-10-20 16:45:27 -07:00
return true ;
2007-02-09 09:04:55 -08:00
// TODO: Make this a non-undoable command
}
2006-07-12 07:49:10 -07:00
// TODO (eventually): replace all this file-handling stuff with the Workspace Editor
void ScenarioEditor : : OnOpen ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-01-08 13:29:27 -08:00
if ( DiscardChangesDialog ( ) )
return ;
2014-10-17 18:53:06 -07:00
MapDialog dlg ( NULL , MAPDIALOG_OPEN , m_Icon ) ;
2006-07-12 07:49:10 -07:00
if ( dlg . ShowModal ( ) = = wxID_OK )
2011-10-20 16:45:27 -07:00
{
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxString filename = dlg . GetFilename ( ) ;
if ( ! OpenFile ( filename , filename ) )
wxLogError ( _ ( " Map '%ls' does not exist " ) , filename . c_str ( ) ) ;
2011-10-20 16:45:27 -07:00
}
2006-07-12 07:49:10 -07:00
// TODO: Make this a non-undoable command
}
2012-08-07 11:49:46 -07:00
void ScenarioEditor : : OnImportHeightmap ( wxCommandEvent & WXUNUSED ( event ) )
{
2015-01-08 13:29:27 -08:00
if ( DiscardChangesDialog ( ) )
return ;
2012-08-07 11:49:46 -07:00
wxFileDialog dlg ( NULL , wxFileSelectorPromptStr ,
_T ( " " ) , _T ( " " ) ,
_T ( " Valid Image files|*.png;*.jpg;*.bmp|All files (*.*)|*.* " ) ,
wxFD_OPEN ) ;
// Set default filter
dlg . SetFilterIndex ( 0 ) ;
if ( dlg . ShowModal ( ) ! = wxID_OK )
return ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
OpenFile ( _T ( " " ) , _T ( " maps/scenarios/_default.xml " ) ) ;
2012-08-07 11:49:46 -07:00
std : : wstring image ( dlg . GetPath ( ) . wc_str ( ) ) ;
POST_MESSAGE ( ImportHeightmap , ( image ) ) ;
// TODO: Make this a non-undoable command
}
2007-02-09 09:04:55 -08:00
void ScenarioEditor : : OnMRUFile ( wxCommandEvent & event )
{
2011-04-13 21:01:59 -07:00
wxString filename ( m_FileHistory . GetHistoryFile ( event . GetId ( ) - wxID_FILE1 ) ) ;
2011-10-20 16:45:27 -07:00
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
// Handle old MRU filenames
if ( filename . Mid ( 0 , 5 ) ! = _T ( " maps/ " ) )
{
filename = L " maps/scenarios/ " + filename ;
m_FileHistory . RemoveFileFromHistory ( event . GetId ( ) - wxID_FILE1 ) ;
}
2015-01-08 13:29:27 -08:00
if ( DiscardChangesDialog ( ) )
return ;
2011-10-20 16:45:27 -07:00
if ( ! OpenFile ( filename , filename ) )
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
{
// Missing or invalid - warn and remove from MRU
2011-10-20 16:45:27 -07:00
wxLogError ( _ ( " Map '%ls' does not exist " ) , filename . c_str ( ) ) ;
2011-04-13 21:01:59 -07:00
m_FileHistory . RemoveFileFromHistory ( event . GetId ( ) - wxID_FILE1 ) ;
}
2007-02-09 09:04:55 -08:00
}
2006-07-12 07:49:10 -07:00
void ScenarioEditor : : OnSave ( wxCommandEvent & event )
{
if ( m_OpenFilename . IsEmpty ( ) )
2011-04-13 21:01:59 -07:00
{
2006-07-12 07:49:10 -07:00
OnSaveAs ( event ) ;
2011-04-13 21:01:59 -07:00
}
2006-07-12 07:49:10 -07:00
else
{
2011-10-20 16:45:27 -07:00
wxBusyInfo busy ( _ ( " Saving " ) + m_OpenFilename ) ;
wxBusyCursor busyc ;
2006-07-12 07:49:10 -07:00
2007-02-04 06:56:38 -08:00
// Deactivate tools, so things like unit previews don't get saved.
// (TODO: Would be nicer to leave the tools active, and just not save
// the preview units.)
2007-09-02 16:38:58 -07:00
m_ToolManager . SetCurrentTool ( _T ( " " ) ) ;
2007-02-04 06:56:38 -08:00
2011-08-18 16:38:11 -07:00
std : : wstring map ( m_OpenFilename . wc_str ( ) ) ;
2006-07-12 07:49:10 -07:00
POST_MESSAGE ( SaveMap , ( map ) ) ;
// Wait for it to finish saving
2011-05-29 08:02:02 -07:00
qPing qry ;
2006-07-12 07:49:10 -07:00
qry . Post ( ) ;
2015-01-08 13:29:27 -08:00
GetCommandProc ( ) . MarkAsSaved ( ) ;
2006-07-12 07:49:10 -07:00
}
}
void ScenarioEditor : : OnSaveAs ( wxCommandEvent & WXUNUSED ( event ) )
{
2014-10-17 18:53:06 -07:00
MapDialog dlg ( NULL , MAPDIALOG_SAVE , m_Icon ) ;
2006-07-12 07:49:10 -07:00
if ( dlg . ShowModal ( ) = = wxID_OK )
{
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxString filename ( dlg . GetFilename ( ) ) ;
wxBusyInfo busy ( _ ( " Saving " ) + filename ) ;
2011-10-20 16:45:27 -07:00
wxBusyCursor busyc ;
2006-07-12 07:49:10 -07:00
2007-09-02 16:38:58 -07:00
m_ToolManager . SetCurrentTool ( _T ( " " ) ) ;
2007-02-04 06:56:38 -08:00
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
std : : wstring map ( filename . wc_str ( ) ) ;
2006-07-12 07:49:10 -07:00
POST_MESSAGE ( SaveMap , ( map ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
SetOpenFilename ( filename ) ;
2006-07-12 07:49:10 -07:00
// Wait for it to finish saving
2011-05-29 08:02:02 -07:00
qPing qry ;
2006-07-12 07:49:10 -07:00
qry . Post ( ) ;
2015-01-08 13:29:27 -08:00
GetCommandProc ( ) . MarkAsSaved ( ) ;
2006-07-12 07:49:10 -07:00
}
}
void ScenarioEditor : : SetOpenFilename ( const wxString & filename )
{
SetTitle ( wxString : : Format ( _ ( " Atlas - Scenario Editor - %s " ) ,
2006-11-11 20:02:36 -08:00
( filename . IsEmpty ( ) ? wxString ( _ ( " (untitled) " ) ) : filename ) . c_str ( ) ) ) ;
2006-07-12 07:49:10 -07:00
m_OpenFilename = filename ;
2007-02-09 09:04:55 -08:00
if ( ! filename . IsEmpty ( ) )
m_FileHistory . AddFileToHistory ( filename ) ;
2006-07-12 07:49:10 -07:00
}
2011-05-29 08:02:02 -07:00
void ScenarioEditor : : NotifyOnMapReload ( )
{
m_SectionLayout . OnMapReload ( ) ;
2011-08-22 14:45:39 -07:00
// Notify observers, here so it's independent of individual panels
m_MapSettings . NotifyObservers ( ) ;
2011-05-29 08:02:02 -07:00
}
2015-01-08 13:29:27 -08:00
bool ScenarioEditor : : DiscardChangesDialog ( )
{
return GetCommandProc ( ) . IsDirty ( ) & &
wxMessageBox ( _T ( " You have unsaved changes. Are you sure you want to open another map? " ) , _T ( " Discard unsaved changes? " ) , wxICON_QUESTION | wxYES_NO ) ! = wxYES ;
}
2006-07-12 07:49:10 -07:00
//////////////////////////////////////////////////////////////////////////
2006-04-23 16:14:18 -07:00
void ScenarioEditor : : OnWireframe ( wxCommandEvent & event )
{
POST_MESSAGE ( RenderStyle , ( event . IsChecked ( ) ) ) ;
}
void ScenarioEditor : : OnMessageTrace ( wxCommandEvent & event )
{
POST_MESSAGE ( MessageTrace , ( event . IsChecked ( ) ) ) ;
}
2012-03-05 16:15:48 -08:00
void ScenarioEditor : : OnScreenshot ( wxCommandEvent & event )
2006-04-23 16:14:18 -07:00
{
2012-03-05 16:15:48 -08:00
switch ( event . GetId ( ) )
{
case ID_BigScreenshot :
POST_MESSAGE ( Screenshot , ( true , 10 ) ) ;
break ;
case ID_Screenshot :
POST_MESSAGE ( Screenshot , ( false , 0 ) ) ;
break ;
}
2006-04-23 16:14:18 -07:00
}
2007-02-01 18:17:15 -08:00
void ScenarioEditor : : OnJavaScript ( wxCommandEvent & WXUNUSED ( event ) )
{
wxString cmd = : : wxGetTextFromUser ( _T ( " " ) , _ ( " JS command " ) , _T ( " " ) , this ) ;
if ( cmd . IsEmpty ( ) )
return ;
2011-08-18 16:38:11 -07:00
POST_MESSAGE ( JavaScript , ( ( std : : wstring ) cmd . wc_str ( ) ) ) ;
2007-02-01 18:17:15 -08:00
}
2011-02-11 15:56:55 -08:00
void ScenarioEditor : : OnCameraReset ( wxCommandEvent & WXUNUSED ( event ) )
{
POST_MESSAGE ( CameraReset , ( ) ) ;
}
2011-03-26 13:17:21 -07:00
void ScenarioEditor : : OnRenderPath ( wxCommandEvent & event )
{
switch ( event . GetId ( ) )
{
case ID_RenderPathFixed :
POST_MESSAGE ( SetViewParamS , ( eRenderView : : GAME , L " renderpath " , L " fixed " ) ) ;
break ;
case ID_RenderPathShader :
POST_MESSAGE ( SetViewParamS , ( eRenderView : : GAME , L " renderpath " , L " shader " ) ) ;
break ;
}
}
2011-04-13 21:01:59 -07:00
void ScenarioEditor : : OnDumpState ( wxCommandEvent & event )
{
wxDateTime time = wxDateTime : : Now ( ) ;
wxString filename ;
bool doBinary = false ;
switch ( event . GetId ( ) )
{
case ID_DumpState :
filename = wxString : : Format ( _T ( " sim-dump-%d.txt " ) , time . GetTicks ( ) ) ;
break ;
case ID_DumpBinaryState :
doBinary = true ;
filename = wxString : : Format ( _T ( " sim-dump-%d.dat " ) , time . GetTicks ( ) ) ;
break ;
}
qSimStateDebugDump q ( doBinary ) ;
q . Post ( ) ;
2011-07-10 14:00:21 -07:00
std : : wstring dump = * q . dump ;
wxString state ( dump . c_str ( ) ) ;
2011-04-13 21:01:59 -07:00
wxFFile file ( filename . c_str ( ) , _T ( " w " ) ) ;
if ( file . IsOpened ( ) & & ! file . Error ( ) )
{
file . Write ( state ) ;
file . Close ( ) ;
}
else
{
2011-10-20 16:45:27 -07:00
wxLogError ( _ ( " Error writing to file '%ls' " ) , filename . c_str ( ) ) ;
2011-04-13 21:01:59 -07:00
}
}
2014-11-20 12:52:32 -08:00
void ScenarioEditor : : OnSelectedObjectsChange ( const std : : vector < ObjectID > & selectedObjects )
{
GetMenuBar ( ) - > Enable ( ID_Copy , ! selectedObjects . empty ( ) ) ;
}
void ScenarioEditor : : OnMenuOpen ( wxMenuEvent & event )
{
// This could be done far more elegantly if wxMenuItem had changeable id.
wxMenu * pasteMenuItem = NULL ;
event . GetMenu ( ) - > FindItem ( ID_Paste , & pasteMenuItem ) ;
GetMenuBar ( ) - > Enable ( ID_Paste , false ) ;
if ( ! pasteMenuItem )
return ;
wxString content ;
if ( wxTheClipboard - > Open ( ) )
{
if ( wxTheClipboard - > IsSupported ( wxDF_TEXT ) )
{
wxTextDataObject data ;
wxTheClipboard - > GetData ( data ) ;
content = data . GetText ( ) ;
}
wxTheClipboard - > Close ( ) ;
}
if ( content . empty ( ) )
return ;
wxInputStream * is = new wxStringInputStream ( content ) ;
wxXmlDocument doc ;
{
wxLogNull stopComplaining ;
static_cast < void > ( stopComplaining ) ;
if ( ! doc . Load ( * is ) )
return ;
}
wxXmlNode * root = doc . GetRoot ( ) ;
if ( ! root | | root - > GetName ( ) ! = wxT ( " Entities " ) )
return ;
GetMenuBar ( ) - > Enable ( ID_Paste , true ) ;
}
2011-04-13 21:01:59 -07:00
2006-04-23 16:14:18 -07:00
//////////////////////////////////////////////////////////////////////////
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
Position : : Position ( const wxPoint & pt )
2006-04-23 16:14:18 -07:00
: type ( 1 )
{
type1 . x = pt . x ;
type1 . y = pt . y ;
}
2006-05-30 22:27:02 -07:00
//////////////////////////////////////////////////////////////////////////
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
/* Disabled (and should be removed if it turns out to be unnecessary)
- see MessagePasserImpl . cpp for information
2006-05-30 22:27:02 -07:00
2006-04-23 16:14:18 -07:00
static void QueryCallback ( )
{
// If this thread completely blocked on the semaphore inside Query, it would
// never respond to window messages, and the system deadlocks if the
// game tries to display an assertion failure dialog. (See
// WaitForSingleObject on MSDN.)
// So, this callback is called occasionally, and gives wx a change to
// handle messages.
// This is kind of like wxYield, but without the ProcessPendingEvents -
// it's enough to make Windows happy and stop deadlocking, without actually
// calling the event handlers (which could lead to nasty recursion)
2006-05-30 22:27:02 -07:00
// while (wxEventLoop::GetActive()->Pending())
// wxEventLoop::GetActive()->Dispatch();
// Oh dear, we can't use that either - it (at least in wx 2.6.3) still
// processes messages, which causes reentry into various things that we
// don't want to be reentrant. So do it all manually, accepting Windows
// messages and sticking them on a list for later processing (in a custom
// event loop class):
// (TODO: Rethink this entire process on Linux)
// (Alt TODO: Could we make the game never pop up windows (or use the Win32
// GUI in any other way) when it's running under Atlas, so we wouldn't need
// to do any message processing here at all?)
2006-11-11 20:02:36 -08:00
# ifdef _WIN32
2006-05-30 22:27:02 -07:00
AtlasEventLoop * evtLoop = ( AtlasEventLoop * ) wxEventLoop : : GetActive ( ) ;
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
// evtLoop might be NULL, particularly if we're still initialising windows
// and haven't got into the normal event loop yet. But we'd have to process
// messages anyway, to avoid the deadlocks that this is for. So, don't bother
// with that and just crash instead.
// (Maybe it could be solved better by constructing/finding an event loop
// object here and setting it as the global one, assuming it's not overwritten
// later by wx.)
2006-05-30 22:27:02 -07:00
while ( evtLoop - > Pending ( ) )
{
// Based on src/msw/evtloop.cpp's wxEventLoop::Dispatch()
MSG msg ;
BOOL rc = : : GetMessage ( & msg , ( HWND ) NULL , 0 , 0 ) ;
if ( rc = = 0 )
{
// got WM_QUIT
return ;
}
if ( rc = = - 1 )
{
wxLogLastError ( wxT ( " GetMessage " ) ) ;
return ;
}
// Our special bits:
if ( msg . message = = WM_PAINT )
{
// "GetMessage does not remove WM_PAINT messages from the queue.
// The messages remain in the queue until processed."
// So let's process them, to avoid infinite loops...
PAINTSTRUCT paint ;
: : BeginPaint ( msg . hwnd , & paint ) ;
: : EndPaint ( msg . hwnd , & paint ) ;
// Remember that some painting was needed - we'll just repaint
// the whole screen when this is finished.
evtLoop - > NeedsPaint ( ) ;
}
else
{
// Add this message to a queue for later processing. (That's
// probably kind of valid, at least in most cases.)
MSG * pMsg = new MSG ( msg ) ;
evtLoop - > AddMessage ( pMsg ) ;
}
}
2006-11-11 20:02:36 -08:00
# endif
2006-04-23 16:14:18 -07:00
}
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
*/
void QueryMessage : : Post ( )
2006-04-23 16:14:18 -07:00
{
# Added tool for viewing models and animations outside the game.
Atlas: Added ActorViewer. Moved GL canvas into separate class for shared
use. Disabled message-handling callback while blocked on the game, and
stopped creating dialog boxes inside the game thread in order to avoid
deadlocks (hopefully). Support multiple Views (for independent sets of
camera/update/render code). Recalculate territory boundaries when
necessary. Changed default list of animations to match those currently
used by actors.
# Tidied up more code.
Moved some more #includes out of .h files, to minimise unnecessary
compilation.
MathUtil: Deleted unused/unuseful macros (M_PI (use PI instead), M_PI_2
(use PI/2), MAX3, ABS (use abs)).
ObjectManager: Removed some ScEd-specific things.
Unit: Moved creation out of UnitManager, so units can be created without
adding to the manager. Changed CStr8 to the more conventional CStr.
app_hooks: Removed warning for setting multiple times.
win: Restored SEH catcher.
GameSetup, GameView: Removed RenderNoCull, because it doesn't seem to do
what it says it does ("force renderer to load everything") since we're
loading-on-demand most stuff and it doesn't seem especially useful since
we'd prefer to minimise loading times (but feel free to correct me if
I'm wrong). (And because it crashes when things need to be initialised
in a different order, so it's easier to remove than to understand and
fix it.)
PatchRData, Renderer: Work sensibly when there's no game (hence no LOS
manager, water, etc).
LOSManager: Use entity position instead of actor position when possible.
TerritoryManager: Allow delayed recalculations (so Atlas can issue lots
of move+recalculate commands per frame).
Cinematic: Non-pointer wxTimer, so it doesn't leak and doesn't have to
be deleted manually.
This was SVN commit r4261.
2006-08-28 10:36:42 -07:00
// g_MessagePasser->Query(this, &QueryCallback);
g_MessagePasser - > Query ( this , NULL ) ;
2006-04-23 16:14:18 -07:00
}