diff --git a/source/graphics/MapWriter.h b/source/graphics/MapWriter.h index 00eb32a22a..faff1d0166 100644 --- a/source/graphics/MapWriter.h +++ b/source/graphics/MapWriter.h @@ -2,6 +2,7 @@ #define INCLUDED_MAPWRITER #include +#include #include "MapIO.h" #include "ps/CStr.h" #include "ps/FilePacker.h" diff --git a/source/graphics/ObjectManager.h b/source/graphics/ObjectManager.h index 2bd8280533..3d805aa1e4 100644 --- a/source/graphics/ObjectManager.h +++ b/source/graphics/ObjectManager.h @@ -3,6 +3,7 @@ #include #include +#include #include "ps/CStr.h" class CEntityTemplate; diff --git a/source/lib/secure_crt.cpp b/source/lib/secure_crt.cpp index 4e3366811c..8f7e3e3c57 100644 --- a/source/lib/secure_crt.cpp +++ b/source/lib/secure_crt.cpp @@ -12,6 +12,7 @@ #include #include +#include #include "secure_crt.h" diff --git a/source/lib/sysdep/ia32/ia32.cpp b/source/lib/sysdep/ia32/ia32.cpp index b339c67381..ab2a195768 100644 --- a/source/lib/sysdep/ia32/ia32.cpp +++ b/source/lib/sysdep/ia32/ia32.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "lib/posix/posix.h" // pthread diff --git a/source/lib/sysdep/unix/ucpu.cpp b/source/lib/sysdep/unix/ucpu.cpp index fff9123f13..0da183b6a4 100644 --- a/source/lib/sysdep/unix/ucpu.cpp +++ b/source/lib/sysdep/unix/ucpu.cpp @@ -6,6 +6,10 @@ #include #endif +#if OS_LINUX +#include "valgrind.h" +#endif + int ucpu_IsThrottlingPossible() { return -1; // don't know @@ -41,6 +45,12 @@ LibError ucpu_CallByEachCPU(CpuCallback cb, void* param) { long ncpus = sysconf(_SC_NPROCESSORS_CONF); + // Valgrind reports the number of real CPUs, but only emulates a single CPU. + // That causes problems when we expect all those CPUs to be distinct, so + // just pretend there's only one CPU + if (RUNNING_ON_VALGRIND) + ncpus = 1; + cpu_set_t set; for (long i = 0; i < ncpus && i < CPU_SETSIZE; ++i) { diff --git a/source/lib/timer.cpp b/source/lib/timer.cpp index 60a0250110..c1cf093fc7 100644 --- a/source/lib/timer.cpp +++ b/source/lib/timer.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include "lib/posix/posix_time.h" diff --git a/source/maths/Vector3D.cpp b/source/maths/Vector3D.cpp index ff7f876c01..d9e1bacbc5 100644 --- a/source/maths/Vector3D.cpp +++ b/source/maths/Vector3D.cpp @@ -12,6 +12,7 @@ #include "Vector3D.h" #include +#include #include "MathUtil.h" int CVector3D::operator ! () const diff --git a/source/ps/CLogger.h b/source/ps/CLogger.h index e0aa25c010..6188eb609a 100644 --- a/source/ps/CLogger.h +++ b/source/ps/CLogger.h @@ -4,6 +4,7 @@ #include #include #include +#include class CLogger; extern CLogger* g_Logger; diff --git a/source/ps/FileUnpacker.cpp b/source/ps/FileUnpacker.cpp index b3d81f35a9..6532d348b3 100644 --- a/source/ps/FileUnpacker.cpp +++ b/source/ps/FileUnpacker.cpp @@ -11,6 +11,7 @@ #include "FileUnpacker.h" #include "lib/path_util.h" #include "lib/res/res.h" +#include "ps/CStr.h" //////////////////////////////////////////////////////////////////////////////////////// // CFileUnpacker constructor diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 3cc7f97a3d..b0ad0582c2 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -898,6 +898,9 @@ void EarlyInit() timer_Init(); cpu_Init(); // must come after timer_Init + + // Initialise the low-quality rand function + srand(time(NULL)); } void Init(const CmdLineArgs& args, uint flags) diff --git a/source/simulation/EntityManager.h b/source/simulation/EntityManager.h index 15ba5d4d14..c6ffca2342 100644 --- a/source/simulation/EntityManager.h +++ b/source/simulation/EntityManager.h @@ -17,6 +17,8 @@ #define INCLUDED_ENTITYMANAGER #include +#include +#include #include "EntityHandles.h" #include "ps/Game.h" @@ -25,6 +27,7 @@ class CEntityTemplate; class CPlayer; class CStrW; +class CStr8; class CVector3D; #define MAX_HANDLES 4096 @@ -67,7 +70,7 @@ public: ~CEntityManager(); HEntity Create( CEntityTemplate* base, CVector3D position, float orientation, - const std::set& actorSelections, const CStrW* building = 0 ); + const std::set& actorSelections, const CStrW* building = 0 ); HEntity Create( const CStrW& templateName, CPlayer* player, CVector3D position, float orientation, const CStrW* building = 0 ); diff --git a/source/tools/atlas/AtlasScript/NativeWrapper.inl b/source/tools/atlas/AtlasScript/NativeWrapper.inl index c4b3b7cdef..b8cc118122 100644 --- a/source/tools/atlas/AtlasScript/NativeWrapper.inl +++ b/source/tools/atlas/AtlasScript/NativeWrapper.inl @@ -26,7 +26,7 @@ public: // Define RegisterFunction #define OVERLOADS(z, i, data) \ - template \ + template \ void RegisterFunction(const char* name) { \ Register(name, call, nargs<0 T0_TAIL(z,i)>()); \ } @@ -38,7 +38,7 @@ private: // JSNative-compatible function that wraps the function identified in the template argument list // (Definition comes later, since it depends on some things we haven't defined yet) #define OVERLOADS(z, i, data) \ - template \ + template \ static JSBool call(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval); BOOST_PP_REPEAT(MAX_ARGS, OVERLOADS, ~) #undef OVERLOADS @@ -54,7 +54,7 @@ private: // are not permitted inside non-namespace scopes -// ScriptInterface_NativeWrapper::call(cx, rval, fptr, args...) will call fptr(args), +// ScriptInterface_NativeWrapper::call(cx, rval, fptr, args...) will call fptr(cbdata, args), // and if T != void then it will store the result in rval: // Templated on the return type so void can be handled separately @@ -63,7 +63,7 @@ struct ScriptInterface_NativeWrapper { #define OVERLOADS(z, i, data) \ template \ static void call(JSContext* cx, jsval& rval, f fptr T0_A0(z,i)) { \ - rval = ScriptInterface::ToJSVal(cx, fptr(A0(z,i))); \ + rval = ScriptInterface::ToJSVal(cx, fptr(ScriptInterface::GetCallbackData(cx) A0_TAIL(z,i))); \ } BOOST_PP_REPEAT(MAX_ARGS, OVERLOADS, ~) @@ -75,8 +75,8 @@ template <> struct ScriptInterface_NativeWrapper { #define OVERLOADS(z, i, data) \ template \ - static void call(JSContext* /*cx*/, jsval& /*rval*/, f fptr T0_A0(z,i)) { \ - fptr(A0(z,i)); \ + static void call(JSContext* cx, jsval& /*rval*/, f fptr T0_A0(z,i)) { \ + fptr(ScriptInterface::GetCallbackData(cx) A0_TAIL(z,i)); \ } BOOST_PP_REPEAT(MAX_ARGS, OVERLOADS, ~) #undef OVERLOADS @@ -84,7 +84,7 @@ struct ScriptInterface_NativeWrapper { // JSNative-compatible function that wraps the function identified in the template argument list #define OVERLOADS(z, i, data) \ - template \ + template \ JSBool ScriptInterface::call(JSContext* cx, JSObject* /*obj*/, uintN /*argc*/, jsval* argv, jsval* rval) { \ (void)argv; /* avoid 'unused parameter' warnings */ \ BOOST_PP_REPEAT_##z (i, CONVERT_ARG, ~) \ diff --git a/source/tools/atlas/AtlasScript/ScriptInterface.cpp b/source/tools/atlas/AtlasScript/ScriptInterface.cpp index 9356cfa6e9..16d84d1c4f 100644 --- a/source/tools/atlas/AtlasScript/ScriptInterface.cpp +++ b/source/tools/atlas/AtlasScript/ScriptInterface.cpp @@ -11,7 +11,7 @@ #include "wx/wx.h" #include "wxJS/common/main.h" -#include "wxJS/ext/jsmembuf.h" +#include "wxJS/ext/wxjs_ext.h" #include "wxJS/io/init.h" #include "wxJS/gui/init.h" #include "wxJS/gui/control/panel.h" @@ -361,6 +361,8 @@ ScriptInterface_impl::ScriptInterface_impl() JS_BeginRequest(m_cx); // if you get linker errors, see the comment in the .h about JS_THREADSAFE + JS_SetContextPrivate(m_cx, NULL); + JS_SetErrorReporter(m_cx, ErrorReporter); JS_SetOptions(m_cx, @@ -375,7 +377,8 @@ ScriptInterface_impl::ScriptInterface_impl() wxjs::gui::InitClass(m_cx, m_glob); wxjs::io::InitClass(m_cx, m_glob); - wxjs::ext::MemoryBuffer::JSInit(m_cx, m_glob); + wxjs::ext::InitClass(m_cx, m_glob); + wxjs::ext::InitObject(m_cx, m_glob); JS_DefineFunction(m_cx, m_glob, "print", ::print, 0, JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT); @@ -423,6 +426,16 @@ ScriptInterface::~ScriptInterface() { } +void ScriptInterface::SetCallbackData(void* cbdata) +{ + JS_SetContextPrivate(m->m_cx, cbdata); +} + +void* ScriptInterface::GetCallbackData(JSContext* cx) +{ + return JS_GetContextPrivate(cx); +} + void ScriptInterface::Register(const char* name, JSNative fptr, size_t nargs) { m->Register(name, fptr, (uintN)nargs); diff --git a/source/tools/atlas/AtlasScript/ScriptInterface.h b/source/tools/atlas/AtlasScript/ScriptInterface.h index 8214233969..665fed74cb 100644 --- a/source/tools/atlas/AtlasScript/ScriptInterface.h +++ b/source/tools/atlas/AtlasScript/ScriptInterface.h @@ -26,9 +26,11 @@ class ScriptInterface public: ScriptInterface(); ~ScriptInterface(); + void SetCallbackData(void* cbdata); + static void* GetCallbackData(JSContext* cx); // Defined elsewhere: - // template + // template // void RegisterFunction(const char* functionName); // (NOTE: The return type must be defined as a ToJSVal specialisation // in ScriptInterface.cpp, else you'll end up with linker errors.) diff --git a/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp b/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp index bfc8223d47..676979bf71 100644 --- a/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp +++ b/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.cpp @@ -7,6 +7,7 @@ #include "ToolButton.h" #include "ScenarioEditor/Tools/Common/Tools.h" +#include "ScenarioEditor/SectionLayout.h" #include "General/Datafile.h" BEGIN_EVENT_TABLE(ToolButton, wxButton) @@ -14,13 +15,10 @@ BEGIN_EVENT_TABLE(ToolButton, wxButton) END_EVENT_TABLE() ToolButton::ToolButton - (wxWindow *parent, - const wxString& label, - const wxString& toolName, - const wxSize& size, - long style) - : wxButton(parent, wxID_ANY, label, wxDefaultPosition, size, style), - m_Tool(toolName) + (ToolManager& toolManager, wxWindow *parent, const wxString& label, const wxString& toolName, const wxSize& size, long style) + : wxButton(parent, wxID_ANY, label, wxDefaultPosition, size, style) + , m_ToolManager(toolManager) + , m_Tool(toolName) { // Explicitly set appearance, so that the button is always owner-drawn // (by the wxButton code), rather than initially using the native @@ -34,9 +32,9 @@ void ToolButton::OnClick(wxCommandEvent& WXUNUSED(evt)) { // Toggle on/off if (m_Selected) - SetCurrentTool(_T("")); + m_ToolManager.SetCurrentTool(_T("")); else - SetCurrentTool(m_Tool); + m_ToolManager.SetCurrentTool(m_Tool); } void ToolButton::SetSelectedAppearance(bool selected) @@ -54,9 +52,9 @@ BEGIN_EVENT_TABLE(ToolButtonBar, wxToolBar) EVT_TOOL(wxID_ANY, ToolButtonBar::OnTool) END_EVENT_TABLE() -ToolButtonBar::ToolButtonBar(wxWindow* parent, SectionLayout* sectionLayout, int baseID) +ToolButtonBar::ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID) : wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTB_FLAT|wxTB_HORIZONTAL) -, m_SectionLayout(sectionLayout), m_Id(baseID), m_Size(-1) +, m_ToolManager(toolManager), m_SectionLayout(sectionLayout), m_Id(baseID), m_Size(-1) { /* "msw.remap: If 1 (the default), wxToolBar bitmap colours will be remapped to the current theme's values. Set this to 0 to disable this functionality, @@ -105,7 +103,7 @@ void ToolButtonBar::OnTool(wxCommandEvent& evt) { std::map::iterator it = m_Buttons.find(evt.GetId()); wxCHECK_RET(it != m_Buttons.end(), _T("Invalid toolbar button")); - SetCurrentTool(it->second.name); + m_ToolManager.SetCurrentTool(it->second.name); if (! it->second.sectionPage.IsEmpty()) m_SectionLayout->SelectPage(it->second.sectionPage); } diff --git a/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h b/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h index 340fb9048b..e1f3f926ef 100644 --- a/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h +++ b/source/tools/atlas/AtlasUI/CustomControls/Buttons/ToolButton.h @@ -4,11 +4,12 @@ class ITool; class SectionLayout; +class ToolManager; class ToolButton : public wxButton { public: - ToolButton(wxWindow *parent, const wxString& label, const wxString& toolName, const wxSize& size = wxDefaultSize, long style = 0); + ToolButton(ToolManager& toolManager, wxWindow *parent, const wxString& label, const wxString& toolName, const wxSize& size = wxDefaultSize, long style = 0); void SetSelectedAppearance(bool selected); @@ -16,6 +17,7 @@ protected: void OnClick(wxCommandEvent& evt); private: + ToolManager& m_ToolManager; wxString m_Tool; bool m_Selected; @@ -25,7 +27,7 @@ private: class ToolButtonBar : public wxToolBar { public: - ToolButtonBar(wxWindow* parent, SectionLayout* sectionLayout, int baseID); + ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID); void AddToolButton(const wxString& shortLabel, const wxString& longLabel, const wxString& iconPNGFilename, const wxString& toolName, const wxString& sectionPage); @@ -33,6 +35,7 @@ protected: void OnTool(wxCommandEvent& evt); private: + ToolManager& m_ToolManager; int m_Id; int m_Size; struct Button diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp index 789c33d6a8..3d564dbc7f 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp @@ -50,9 +50,9 @@ ATLASDLLIMPEXP void Atlas_GLSwapBuffers(void* canvas) class GameCanvas : public Canvas { public: - GameCanvas(wxWindow* parent, int* attribList) + GameCanvas(ToolManager& toolManager, wxWindow* parent, int* attribList) : Canvas(parent, attribList, wxWANTS_CHARS), - m_MouseState(NONE), m_LastMouseState(NONE) + m_ToolManager(toolManager), m_MouseState(NONE), m_LastMouseState(NONE) { } @@ -90,7 +90,7 @@ private: void OnKeyDown(wxKeyEvent& evt) { - if (GetCurrentTool().OnKey(evt, ITool::KEY_DOWN)) + if (m_ToolManager.GetCurrentTool().OnKey(evt, ITool::KEY_DOWN)) { // Key event has been handled by the tool, so don't try // to use it for camera motion too @@ -105,7 +105,7 @@ private: void OnKeyUp(wxKeyEvent& evt) { - if (GetCurrentTool().OnKey(evt, ITool::KEY_UP)) + if (m_ToolManager.GetCurrentTool().OnKey(evt, ITool::KEY_UP)) return; if (KeyScroll(evt, false)) @@ -116,7 +116,7 @@ private: void OnChar(wxKeyEvent& evt) { - if (GetCurrentTool().OnKey(evt, ITool::KEY_CHAR)) + if (m_ToolManager.GetCurrentTool().OnKey(evt, ITool::KEY_CHAR)) return; int dir = 0; @@ -151,7 +151,7 @@ private: if (evt.Moving()) SetFocus(); - if (GetCurrentTool().OnMouse(evt)) + if (m_ToolManager.GetCurrentTool().OnMouse(evt)) { // Mouse event has been handled by the tool, so don't try // to use it for camera motion too @@ -204,6 +204,8 @@ private: enum { NONE, SCROLL, ROTATEAROUND }; int m_MouseState, m_LastMouseState; + ToolManager& m_ToolManager; + DECLARE_EVENT_TABLE(); }; @@ -267,17 +269,21 @@ AtlasWindowCommandProc& ScenarioEditor::GetCommandProc() { return g_CommandProc; namespace { // Wrapper function because SetCurrentTool takes an optional argument, which JS doesn't like - void SetCurrentTool_script(wxString name) + void SetCurrentTool_script(void* cbdata, wxString name) { - SetCurrentTool(name); + static_cast(cbdata)->GetToolManager().SetCurrentTool(name); + } + wxString GetDataDirectory(void*) + { + return Datafile::GetDataDirectory(); } // TODO: see comment in terrain.js, and remove this when/if it's no longer necessary - void SetBrushStrength(float strength) + void SetBrushStrength(void*, float strength) { g_Brush_Elevation.SetStrength(strength); } - void SetSelectedTexture(wxString name) + void SetSelectedTexture(void*, wxString name) { g_SelectedTexture = name; } @@ -286,6 +292,8 @@ namespace ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterface) : wxFrame(parent, wxID_ANY, _T(""), wxDefaultPosition, wxSize(1024, 768)) , m_FileHistory(_T("Scenario Editor")), m_ScriptInterface(scriptInterface) +, m_ObjectSettings(g_SelectedObjects, AtlasMessage::eRenderView::GAME) +, m_ToolManager(this) { // Global application initialisation: @@ -301,7 +309,8 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac ////////////////////////////////////////////////////////////////////////// // Script interface functions - GetScriptInterface().RegisterFunction("GetDataDirectory"); + GetScriptInterface().SetCallbackData(static_cast(this)); + GetScriptInterface().RegisterFunction("GetDataDirectory"); GetScriptInterface().RegisterFunction("SetCurrentTool"); GetScriptInterface().RegisterFunction("SetBrushStrength"); GetScriptInterface().RegisterFunction("SetSelectedTexture"); @@ -366,7 +375,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac // Toolbar: - ToolButtonBar* toolbar = new ToolButtonBar(this, &m_SectionLayout, ID_Toolbar); + ToolButtonBar* toolbar = new ToolButtonBar(m_ToolManager, this, &m_SectionLayout, ID_Toolbar); // TODO: configurable small vs large icon images // (button label; tooltip text; image; internal tool name; section to switch to) @@ -379,7 +388,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac toolbar->Realize(); SetToolBar(toolbar); // Set the default tool to be selected - SetCurrentTool(_T("")); + m_ToolManager.SetCurrentTool(_T("")); // Set up GL canvas: @@ -392,7 +401,7 @@ ScenarioEditor::ScenarioEditor(wxWindow* parent, ScriptInterface& scriptInterfac WX_GL_MIN_ALPHA, 8, // alpha bits 0 }; - Canvas* canvas = new GameCanvas(m_SectionLayout.GetCanvasParent(), glAttribList); + Canvas* canvas = new GameCanvas(m_ToolManager, m_SectionLayout.GetCanvasParent(), glAttribList); m_SectionLayout.SetCanvas(canvas); // Set up sidebars: @@ -453,7 +462,7 @@ float ScenarioEditor::GetSpeedModifier() void ScenarioEditor::OnClose(wxCloseEvent&) { - SetCurrentTool(_T("")); + m_ToolManager.SetCurrentTool(_T("")); m_FileHistory.Save(*wxConfigBase::Get()); @@ -467,7 +476,7 @@ void ScenarioEditor::OnClose(wxCloseEvent&) } -static void UpdateTool() +static void UpdateTool(ToolManager& toolManager) { // Don't keep posting events if the game can't keep up if (g_FrameHasEnded) @@ -476,17 +485,17 @@ static void UpdateTool() // TODO: Smoother timing stuff? static double last = g_Timer.GetTime(); double time = g_Timer.GetTime(); - GetCurrentTool().OnTick(time-last); + toolManager.GetCurrentTool().OnTick(time-last); last = time; } } void ScenarioEditor::OnTimer(wxTimerEvent&) { - UpdateTool(); + UpdateTool(m_ToolManager); } void ScenarioEditor::OnIdle(wxIdleEvent&) { - UpdateTool(); + UpdateTool(m_ToolManager); } void ScenarioEditor::OnQuit(wxCommandEvent&) @@ -516,7 +525,7 @@ void ScenarioEditor::OpenFile(const wxString& name) // Deactivate tools, so they don't carry forwards into the new CWorld // and crash. - SetCurrentTool(_T("")); + m_ToolManager.SetCurrentTool(_T("")); // TODO: clear the undo buffer, etc POST_MESSAGE(LoadMap, (map)); @@ -569,7 +578,7 @@ void ScenarioEditor::OnSave(wxCommandEvent& event) // 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.) - SetCurrentTool(_T("")); + m_ToolManager.SetCurrentTool(_T("")); std::wstring map = m_OpenFilename.c_str(); POST_MESSAGE(SaveMap, (map)); @@ -591,7 +600,7 @@ void ScenarioEditor::OnSaveAs(wxCommandEvent& WXUNUSED(event)) { wxBusyInfo busy(_("Saving map")); - SetCurrentTool(_T("")); + m_ToolManager.SetCurrentTool(_T("")); // TODO: Work when the map is not in .../maps/scenarios/ std::wstring map = dlg.GetFilename().c_str(); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h index 1ebd41d864..faf6881f11 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h @@ -2,6 +2,9 @@ #define INCLUDED_SCENARIOEDITOR #include "General/AtlasWindowCommandProc.h" +#include "General/Observable.h" +#include "Tools/Common/ObjectSettings.h" +#include "Tools/Common/Tools.h" #include "CustomControls/FileHistory/FileHistory.h" #include "SectionLayout.h" @@ -38,14 +41,21 @@ public: static float GetSpeedModifier(); ScriptInterface& GetScriptInterface() const { return m_ScriptInterface; } + Observable& GetObjectSettings() { return m_ObjectSettings; } + + ToolManager& GetToolManager() { return m_ToolManager; } private: ScriptInterface& m_ScriptInterface; + ToolManager m_ToolManager; + wxTimer m_Timer; SectionLayout m_SectionLayout; + Observable m_ObjectSettings; + void SetOpenFilename(const wxString& filename); wxString m_OpenFilename; FileHistory m_FileHistory; diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp index 3fa4517b02..50ca4457dc 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Cinematic/Cinematic.cpp @@ -6,7 +6,7 @@ #include "CustomControls/Buttons/ActionButton.h" //#include "CustomControls/Buttons/FloatingSpinCtrl.h" #include "General/Datafile.h" -#include "ScenarioEditor/Tools/Common/Tools.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "HighResTimer/HighResTimer.h" #include "General/VideoRecorder/VideoRecorder.h" diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp index 53bc70875b..218759cb36 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Environment/Environment.cpp @@ -4,7 +4,7 @@ #include "LightControl.h" #include "GameInterface/Messages.h" -#include "ScenarioEditor/Tools/Common/Tools.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "General/Observable.h" #include "CustomControls/ColourDialog/ColourDialog.h" diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp index a4da5d781c..ce02a20ee3 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp @@ -3,7 +3,7 @@ #include "Object.h" #include "Buttons/ToolButton.h" -#include "ScenarioEditor/Tools/Common/Tools.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "ScenarioEditor/Tools/Common/ObjectSettings.h" #include "ScenarioEditor/Tools/Common/MiscState.h" #include "VariationControl.h" @@ -15,8 +15,9 @@ class ObjectSelectListBox : public wxListBox { public: - ObjectSelectListBox(wxWindow* parent) + ObjectSelectListBox(wxWindow* parent, ToolManager& toolManager) : wxListBox(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_HSCROLL) + , m_ToolManager(toolManager) { } @@ -24,10 +25,11 @@ public: { // On selecting an object, enable the PlaceObject tool with this object wxString id = static_cast(evt.GetClientObject())->GetData(); - SetCurrentTool(_T("PlaceObject"), &id); + m_ToolManager.SetCurrentTool(_T("PlaceObject"), &id); } private: + ToolManager& m_ToolManager; DECLARE_EVENT_TABLE(); }; BEGIN_EVENT_TABLE(ObjectSelectListBox, wxListBox) @@ -66,7 +68,7 @@ END_EVENT_TABLE(); class ObjectBottomBar : public wxPanel { public: - ObjectBottomBar(wxWindow* parent); + ObjectBottomBar(wxWindow* parent, Observable& objectSettings); }; struct ObjectSidebarImpl @@ -85,10 +87,10 @@ ObjectSidebar::ObjectSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarCo strings.Add(_("Actors (all)")); m_MainSizer->Add(new ObjectChoiceCtrl(this, strings, *this), wxSizerFlags().Expand()); - p->m_ObjectListBox = new ObjectSelectListBox(this); + p->m_ObjectListBox = new ObjectSelectListBox(this, scenarioEditor.GetToolManager()); m_MainSizer->Add(p->m_ObjectListBox, wxSizerFlags().Proportion(1).Expand()); - m_BottomBar = new ObjectBottomBar(bottomBarContainer); + m_BottomBar = new ObjectBottomBar(bottomBarContainer, scenarioEditor.GetObjectSettings()); } ObjectSidebar::~ObjectSidebar() @@ -129,20 +131,17 @@ void ObjectSidebar::SetObjectFilter(int type) class PlayerComboBox : public wxComboBox { public: - PlayerComboBox(wxWindow* parent, wxArrayString& choices) - : wxComboBox(parent, -1, choices[g_ObjectSettings.GetPlayerID()], wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY) + PlayerComboBox(wxWindow* parent, wxArrayString& choices, Observable& objectSettings) + : wxComboBox(parent, -1, choices[objectSettings.GetPlayerID()], wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY) + , m_ObjectSettings(objectSettings) { - m_Conn = g_ObjectSettings.RegisterObserver(1, &PlayerComboBox::OnObjectSettingsChange, this); - } - - ~PlayerComboBox() - { - g_ObjectSettings.RemoveObserver(m_Conn); + m_Conn = m_ObjectSettings.RegisterObserver(1, &PlayerComboBox::OnObjectSettingsChange, this); } private: - ObservableConnection m_Conn; + ObservableScopedConnection m_Conn; + Observable& m_ObjectSettings; void OnObjectSettingsChange(const ObjectSettings& settings) { @@ -151,8 +150,8 @@ private: void OnSelect(wxCommandEvent& evt) { - g_ObjectSettings.SetPlayerID(evt.GetInt()); - g_ObjectSettings.NotifyObserversExcept(m_Conn); + m_ObjectSettings.SetPlayerID(evt.GetInt()); + m_ObjectSettings.NotifyObserversExcept(m_Conn); } DECLARE_EVENT_TABLE(); @@ -163,7 +162,7 @@ END_EVENT_TABLE(); ////////////////////////////////////////////////////////////////////////// -ObjectBottomBar::ObjectBottomBar(wxWindow* parent) +ObjectBottomBar::ObjectBottomBar(wxWindow* parent, Observable& objectSettings) : wxPanel(parent, wxID_ANY) { wxSizer* sizer = new wxBoxSizer(wxVERTICAL); @@ -179,10 +178,10 @@ ObjectBottomBar::ObjectBottomBar(wxWindow* parent) players.Add(_("Player 6")); players.Add(_("Player 7")); players.Add(_("Player 8")); - wxComboBox* playerSelect = new PlayerComboBox(this, players); + wxComboBox* playerSelect = new PlayerComboBox(this, players, objectSettings); sizer->Add(playerSelect); - wxWindow* variationSelect = new VariationControl(this, g_ObjectSettings); + wxWindow* variationSelect = new VariationControl(this, objectSettings); variationSelect->SetMinSize(wxSize(160, -1)); wxSizer* variationSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Variation")); variationSizer->Add(variationSelect, wxSizerFlags().Proportion(1).Expand()); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp index d29212201a..50f4e6cbb2 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp @@ -4,8 +4,8 @@ #include "Buttons/ToolButton.h" #include "General/Datafile.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "ScenarioEditor/Tools/Common/Brushes.h" -#include "ScenarioEditor/Tools/Common/Tools.h" #include "ScenarioEditor/Tools/Common/MiscState.h" #include "GameInterface/Messages.h" @@ -38,11 +38,11 @@ TerrainSidebar::TerrainSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebar { wxSizer* sizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Elevation tools")); - sizer->Add(new ToolButton(this, _("Modify"), _T("AlterElevation"), wxSize(50,20))); - sizer->Add(new ToolButton(this, _("Flatten"), _T("FlattenElevation"), wxSize(50,20))); -// sizer->Add(new ToolButton(this, _("Smooth"), _T(""), wxSize(50,20))); -// sizer->Add(new ToolButton(this, _("Sample"), _T(""), wxSize(50,20))); - sizer->Add(new ToolButton(this, _("Paint"), _T("PaintTerrain"), wxSize(50,20))); + sizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Modify"), _T("AlterElevation"), wxSize(50,20))); + sizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Flatten"), _T("FlattenElevation"), wxSize(50,20))); +// sizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Smooth"), _T(""), wxSize(50,20))); +// sizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Sample"), _T(""), wxSize(50,20))); + sizer->Add(new ToolButton(scenarioEditor.GetToolManager(), this, _("Paint"), _T("PaintTerrain"), wxSize(50,20))); m_MainSizer->Add(sizer); } diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp index fc7e1ef9d5..9be1ceaed6 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Trigger/Trigger.cpp @@ -3,7 +3,7 @@ #include "Trigger.h" #include "GameInterface/Messages.h" #include "CustomControls/Buttons/ActionButton.h" -#include "ScenarioEditor/Tools/Common/Tools.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "ScenarioEditor/Tools/Common/MiscState.h" #include "wx/treectrl.h" diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp index 4ea62b3987..2d3c01a097 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/AlterElevation.cpp @@ -1,5 +1,6 @@ #include "precompiled.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "Common/Tools.h" #include "Common/Brushes.h" #include "GameInterface/Messages.h" diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp index 9e19d194aa..4841dec4f3 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.cpp @@ -3,9 +3,7 @@ #include "ObjectSettings.h" #include "GameInterface/Messages.h" -#include "ScenarioEditor/Tools/Common/Tools.h" - -Observable g_ObjectSettings(g_SelectedObjects, AtlasMessage::eRenderView::GAME); +#include "ScenarioEditor/ScenarioEditor.h" ObjectSettings::ObjectSettings(Observable >& selectedObjects, int view) : m_PlayerID(0), m_SelectedObjects(selectedObjects), m_View(view) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.h index c24968592b..85dfae7384 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.h +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.h @@ -60,6 +60,4 @@ private: void PostToGame(); }; -extern Observable g_ObjectSettings; - #endif // INCLUDED_OBJECTSETTINGS diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.cpp index b6c177e8d7..2a4eaa65ec 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.cpp @@ -6,33 +6,49 @@ class DummyTool : public ITool { - void Init(void*) {} + void Init(void*, ScenarioEditor*) {} void Shutdown() {} bool OnMouse(wxMouseEvent& WXUNUSED(evt)) { return false; } bool OnKey(wxKeyEvent& WXUNUSED(evt), KeyEventType) { return false; } void OnTick(float) {} } dummy; -static ITool* g_CurrentTool = &dummy; -static wxString g_CurrentToolName; +struct ToolManagerImpl +{ + ToolManagerImpl() : CurrentTool(&dummy) {} + + ITool* CurrentTool; + wxString CurrentToolName; + +}; + +ToolManager::ToolManager(ScenarioEditor* scenarioEditor) + : m(new ToolManagerImpl), m_ScenarioEditor(scenarioEditor) +{ +} + +ToolManager::~ToolManager() +{ + delete m; +} + +ITool& ToolManager::GetCurrentTool() +{ + return *m->CurrentTool; +} void SetActive(bool active, const wxString& name); -ITool& GetCurrentTool() +void ToolManager::SetCurrentTool(const wxString& name, void* initData) { - return *g_CurrentTool; -} - -void SetCurrentTool(const wxString& name, void* initData) -{ - if (g_CurrentTool != &dummy) + if (m->CurrentTool != &dummy) { - g_CurrentTool->Shutdown(); - delete g_CurrentTool; - g_CurrentTool = &dummy; + m->CurrentTool->Shutdown(); + delete m->CurrentTool; + m->CurrentTool = &dummy; } - SetActive(false, g_CurrentToolName); + SetActive(false, m->CurrentToolName); ITool* tool = NULL; if (name.Len()) @@ -43,12 +59,12 @@ void SetCurrentTool(const wxString& name, void* initData) if (tool) { - g_CurrentTool = tool; - tool->Init(initData); + m->CurrentTool = tool; + tool->Init(initData, m_ScenarioEditor); } - g_CurrentToolName = name; - SetActive(true, g_CurrentToolName); + m->CurrentToolName = name; + SetActive(true, m->CurrentToolName); } ////////////////////////////////////////////////////////////////////////// diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h index 9a4c0f95c6..73c7bde84c 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h @@ -1,18 +1,18 @@ #ifndef INCLUDED_TOOLS #define INCLUDED_TOOLS -#include "ScenarioEditor/ScenarioEditor.h" #include "General/AtlasWindowCommand.h" class wxMouseEvent; class wxKeyEvent; +class ScenarioEditor; class ITool : public wxObject { public: enum KeyEventType { KEY_DOWN, KEY_UP, KEY_CHAR }; - virtual void Init(void* initData) = 0; + virtual void Init(void* initData, ScenarioEditor* scenarioEditor) = 0; virtual void Shutdown() = 0; virtual bool OnMouse(wxMouseEvent& evt) = 0; // return true if handled virtual bool OnKey(wxKeyEvent& evt, KeyEventType dir) = 0; // return true if handled @@ -21,8 +21,18 @@ public: virtual ~ITool() {}; }; -extern ITool& GetCurrentTool(); -extern void SetCurrentTool(const wxString& name, void* initData = NULL); +struct ToolManagerImpl; +class ToolManager +{ +public: + ToolManager(ScenarioEditor* scenarioEditor); + ~ToolManager(); + ITool& GetCurrentTool(); + void SetCurrentTool(const wxString& name, void* initData = NULL); +private: + ToolManagerImpl* m; + ScenarioEditor* m_ScenarioEditor; +}; class ToolButton; extern void RegisterToolButton(ToolButton* button, const wxString& toolName); @@ -59,12 +69,13 @@ class StateDrivenTool : public ITool { public: StateDrivenTool() - : m_CurrentState(&Disabled) + : m_CurrentState(&Disabled), m_ScenarioEditor(NULL) { } - virtual void Init(void* WXUNUSED(initData)) + virtual void Init(void* WXUNUSED(initData), ScenarioEditor* scenarioEditor) { + m_ScenarioEditor = scenarioEditor; } virtual void Shutdown() @@ -110,9 +121,13 @@ protected: m_CurrentState->OnEnter(static_cast(this)); } + ScenarioEditor& GetScenarioEditor() { wxASSERT(m_ScenarioEditor); return *m_ScenarioEditor; } + private: State* m_CurrentState; + ScenarioEditor* m_ScenarioEditor; // not NULL, except before Init has been called + virtual bool OnMouse(wxMouseEvent& evt) { return m_CurrentState->OnMouse(static_cast(this), evt); diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp index bb27d79212..8be361f27b 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/FlattenElevation.cpp @@ -1,5 +1,6 @@ #include "precompiled.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "Common/Tools.h" #include "Common/Brushes.h" #include "GameInterface/Messages.h" diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp index 6abbc3de1e..b4bf56aef8 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PaintTerrain.cpp @@ -1,5 +1,6 @@ #include "precompiled.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "Common/Tools.h" #include "Common/Brushes.h" #include "Common/MiscState.h" diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp index 20e7f18467..f8a06265f4 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/PlaceObject.cpp @@ -1,5 +1,6 @@ #include "precompiled.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "Common/Tools.h" #include "Common/Brushes.h" #include "Common/MiscState.h" @@ -30,13 +31,15 @@ public: + (m_ScreenPos.type1.y-m_Target.type1.y)*(m_ScreenPos.type1.y-m_Target.type1.y); bool useTarget = (dragDistSq >= 16*16); if (preview) - POST_MESSAGE(ObjectPreview, (m_ObjectID.c_str(), g_ObjectSettings.GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle)); + POST_MESSAGE(ObjectPreview, (m_ObjectID.c_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle)); else - POST_COMMAND(CreateObject, (m_ObjectID.c_str(), g_ObjectSettings.GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle)); + POST_COMMAND(CreateObject, (m_ObjectID.c_str(), GetScenarioEditor().GetObjectSettings().GetSettings(), m_ObjPos, useTarget, m_Target, g_DefaultAngle)); } - virtual void Init(void* initData) + virtual void Init(void* initData, ScenarioEditor* scenarioEditor) { + StateDrivenTool::Init(initData, scenarioEditor); + wxASSERT(initData); wxString& id = *static_cast(initData); m_ObjectID = id; @@ -134,8 +137,8 @@ public: if (type == KEY_CHAR && (evt.GetKeyCode() >= '0' && evt.GetKeyCode() <= '9')) { int playerID = evt.GetKeyCode() - '0'; - g_ObjectSettings.SetPlayerID(playerID); - g_ObjectSettings.NotifyObservers(); + obj->GetScenarioEditor().GetObjectSettings().SetPlayerID(playerID); + obj->GetScenarioEditor().GetObjectSettings().NotifyObservers(); obj->SendObjectMsg(true); return true; } diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp index d2776f4aad..233e8bea7b 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/Tools/TransformObject.cpp @@ -1,5 +1,6 @@ #include "precompiled.h" +#include "ScenarioEditor/ScenarioEditor.h" #include "Common/Tools.h" #include "Common/Brushes.h" #include "Common/MiscState.h" @@ -77,7 +78,7 @@ public: return false; } - bool OnKey(TransformObject* WXUNUSED(obj), wxKeyEvent& evt, KeyEventType type) + bool OnKey(TransformObject* obj, wxKeyEvent& evt, KeyEventType type) { if (type == KEY_CHAR && evt.GetKeyCode() == WXK_DELETE) { @@ -93,8 +94,8 @@ public: else if (type == KEY_CHAR && (evt.GetKeyCode() >= '0' && evt.GetKeyCode() <= '9')) { int playerID = evt.GetKeyCode() - '0'; - g_ObjectSettings.SetPlayerID(playerID); - g_ObjectSettings.NotifyObservers(); + obj->GetScenarioEditor().GetObjectSettings().SetPlayerID(playerID); + obj->GetScenarioEditor().GetObjectSettings().NotifyObservers(); return true; } else diff --git a/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp index f9c92d74ff..24fbf67dd9 100644 --- a/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/ElevationHandlers.cpp @@ -5,6 +5,7 @@ #include "../CommandProc.h" #include "graphics/Terrain.h" +#include "ps/CStr.h" #include "ps/Game.h" #include "ps/World.h" #include "maths/MathUtil.h" diff --git a/source/tools/atlas/GameInterface/SimState.h b/source/tools/atlas/GameInterface/SimState.h index fb6270c022..c31970f77f 100644 --- a/source/tools/atlas/GameInterface/SimState.h +++ b/source/tools/atlas/GameInterface/SimState.h @@ -1,9 +1,14 @@ #ifndef SIMSTATE_INCLUDED #define SIMSTATE_INCLUDED +#include +#include + +#include "ps/CStr.h" +#include "maths/Vector3D.h" + class CUnit; class CEntity; -#include "maths/Vector3D.h" class SimState { diff --git a/source/tools/atlas/GameInterface/View.h b/source/tools/atlas/GameInterface/View.h index 5192db2516..f154118acc 100644 --- a/source/tools/atlas/GameInterface/View.h +++ b/source/tools/atlas/GameInterface/View.h @@ -1,6 +1,8 @@ #ifndef INCLUDED_VIEW #define INCLUDED_VIEW +#include + #include "graphics/Camera.h" #include "Messages.h" diff --git a/source/tools/atlas/wxJS/README.txt b/source/tools/atlas/wxJS/README.txt index f1d043a7e2..46bf8fe8d6 100644 --- a/source/tools/atlas/wxJS/README.txt +++ b/source/tools/atlas/wxJS/README.txt @@ -56,4 +56,12 @@ gui/gui_init.cpp: add obj = Timer::JSInit(cx, global); wxASSERT_MSG(obj != NULL, wxT("wxTimer prototype creation failed")); if (! obj ) - return false; \ No newline at end of file + return false; + +gui/event/jsevent.cpp: add + obj = NotebookEvent::JSInit(cx, global, NotifyEvent::GetClassPrototype()); + wxASSERT_MSG(obj != NULL, wxT("wxNotebookEvent prototype creation failed")); + if (! obj ) + return false; + +TODO: add back tooltips into window.cpp \ No newline at end of file diff --git a/source/tools/atlas/wxJS/gui/event/jsevent.cpp b/source/tools/atlas/wxJS/gui/event/jsevent.cpp index 2286ac70fa..233956ecc8 100644 --- a/source/tools/atlas/wxJS/gui/event/jsevent.cpp +++ b/source/tools/atlas/wxJS/gui/event/jsevent.cpp @@ -48,6 +48,7 @@ #include "htmllink.h" #include "split.h" #include "spinevt.h" +#include "notebookevt.h" #include "notify.h" #include "listevt.h" @@ -178,5 +179,10 @@ bool wxjs::gui::InitEventClasses(JSContext *cx, JSObject *global) if (! obj ) return false; + obj = NotebookEvent::JSInit(cx, global, NotifyEvent::GetClassPrototype()); + wxASSERT_MSG(obj != NULL, wxT("wxNotebookEvent prototype creation failed")); + if (! obj ) + return false; + return true; }