diff --git a/binaries/data/tools/atlas/scripts/section/terrain.js b/binaries/data/tools/atlas/scripts/section/terrain.js index 63edf11725..5d2dbc6bb2 100644 --- a/binaries/data/tools/atlas/scripts/section/terrain.js +++ b/binaries/data/tools/atlas/scripts/section/terrain.js @@ -87,9 +87,11 @@ TerrainPreviewPage.prototype = { var hit = list.hitTest(evt.position); var tip = undefined; if (hit.item != -1 && (hit.flags & wxListHitTest.ONITEMICON)) + { tip = names[hit.item] - if (list.toolTip !== tip) - list.toolTip = tip; + if (list.toolTip !== tip) + list.toolTip = tip; + } }; list.onItemSelected = function(evt) { Atlas.SetSelectedTexture(names[evt.index]); @@ -97,6 +99,8 @@ TerrainPreviewPage.prototype = { list.setImageList(imglist, wxListCtrl.NORMAL); + this.panel.layout(); + this.loaded = true; } }; @@ -159,7 +163,7 @@ function init(window, bottomWindow) ]; var shapeNames = []; for each (var s in shapes) shapeNames.push(s[0]); - var shapeBox = new wxRadioBox(window, -1, 'Shape', wxDefaultPosition, wxDefaultSize, shapeNames); + var shapeBox = new wxRadioBox(window, -1, 'Shape', wxDefaultPosition, wxDefaultSize, shapeNames, 0, wxRadioBox.SPECIFY_ROWS); brushSizer.add(shapeBox); shapeBox.onRadioBox = function(evt) { @@ -194,9 +198,11 @@ function init(window, bottomWindow) var nb = new wxNotebook(bottomWindow, -1); bottomWindow.sizer = new wxBoxSizer(wxOrientation.VERTICAL); bottomWindow.sizer.add(nb, 1, wxStretch.EXPAND); + var pages = []; nb.onPageChanged = function (evt) { pages[evt.selection].display() + evt.skip = true; } for each (var groupname in terrainGroups.groupnames) { diff --git a/source/tools/atlas/AtlasScript/NativeWrapper.inl b/source/tools/atlas/AtlasScript/NativeWrapper.inl index ca9bc1d45c..c4b3b7cdef 100644 --- a/source/tools/atlas/AtlasScript/NativeWrapper.inl +++ b/source/tools/atlas/AtlasScript/NativeWrapper.inl @@ -85,8 +85,8 @@ struct ScriptInterface_NativeWrapper { // JSNative-compatible function that wraps the function identified in the template argument list #define OVERLOADS(z, i, data) \ template \ - JSBool ScriptInterface::call(JSContext* cx, JSObject* /*obj*/, uintN argc, jsval* argv, jsval* rval) { \ - (void)argc; (void)argv; /* avoid 'unused parameter' warnings */ \ + 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, ~) \ ScriptInterface_NativeWrapper::call(cx, *rval, fptr A0_TAIL(z,i)); \ return JS_TRUE; \ diff --git a/source/tools/atlas/AtlasScript/ScriptInterface.cpp b/source/tools/atlas/AtlasScript/ScriptInterface.cpp index c2a0b585b0..d60e1daaae 100644 --- a/source/tools/atlas/AtlasScript/ScriptInterface.cpp +++ b/source/tools/atlas/AtlasScript/ScriptInterface.cpp @@ -131,7 +131,7 @@ namespace if (! JS_GetArrayLength(cx, obj, &length)) FAIL("Failed to get array length"); out.reserve(length); - for (jsint i = 0; i < length; ++i) + for (jsuint i = 0; i < length; ++i) { jsval el; if (! JS_GetElement(cx, obj, i, &el)) @@ -149,7 +149,7 @@ namespace template struct ToJSVal { - static jsval Convert(JSContext* cx, const T& val) + static jsval Convert(JSContext* cx, const T& WXUNUSED(val)) { JS_ReportError(cx, "Unrecognised query return type"); return JSVAL_VOID; @@ -214,7 +214,7 @@ namespace for (size_t i = 0; i < val.size(); ++i) { jsval el = ToJSVal::Convert(cx, val[i]); - JS_SetElement(cx, obj, i, &el); + JS_SetElement(cx, obj, (jsint)i, &el); } JS_RemoveRoot(cx, &obj); return OBJECT_TO_JSVAL(obj); @@ -499,16 +499,18 @@ std::pair ScriptInterface::LoadScriptAsSidebar(const wxStrin #define ARG_LIST(r, data, i, elem) BOOST_PP_COMMA_IF(i) a##i #define MESSAGE(name, vals) \ - JSBool call_##name(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* WXUNUSED(rval)) \ + JSBool call_##name(JSContext* cx, JSObject* WXUNUSED(obj), uintN WXUNUSED(argc), jsval* argv, jsval* WXUNUSED(rval)) \ { \ + (void)cx; (void)argv; /* avoid 'unused parameter' warnings */ \ BOOST_PP_SEQ_FOR_EACH_I(CONVERT_ARGS, ~, vals) \ g_MessagePasser->Add(SHAREABLE_NEW(m##name, ( BOOST_PP_SEQ_FOR_EACH_I(ARG_LIST, ~, vals) ))); \ return JS_TRUE; \ } #define QUERY(name, in_vals, out_vals) \ - JSBool call_##name(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) \ + JSBool call_##name(JSContext* cx, JSObject* WXUNUSED(obj), uintN WXUNUSED(argc), jsval* argv, jsval* rval) \ { \ + (void)argv; /* avoid 'unused parameter' warnings */ \ BOOST_PP_SEQ_FOR_EACH_I(CONVERT_ARGS, ~, in_vals) \ q##name q = q##name( BOOST_PP_SEQ_FOR_EACH_I(ARG_LIST, ~, in_vals) ); \ q.Post(); \ diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp index 95a8997fc9..1f2d9bd09b 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/SectionLayout.cpp @@ -238,9 +238,12 @@ public: virtual void OnFirstDisplay() { + Freeze(); std::pair panels = m_ScenarioEditor.GetScriptInterface().LoadScriptAsSidebar(_T("section/") + m_Name, this, m_BottomBarContainer); m_MainSizer->Add(panels.first, wxSizerFlags(1).Expand()); m_BottomBar = panels.second; + Layout(); + Thaw(); } private: wxString m_Name; diff --git a/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp index 3a2c4b7b72..02a7bda9d1 100644 --- a/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp @@ -142,7 +142,6 @@ MESSAGEHANDLER(SetActorViewer) MESSAGEHANDLER(SetCanvas) { g_GameLoop->glCanvas = msg->canvas; - printf("Setting gl canvas to %p\n", g_GameLoop->glCanvas); Atlas_GLSetCurrent(const_cast(g_GameLoop->glCanvas)); } diff --git a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp index cd34ff5e4a..e5044113f4 100644 --- a/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/ObjectHandlers.cpp @@ -727,8 +727,13 @@ BEGIN_COMMAND(DeleteObject) if (unit->GetEntity()) { + bool wasTerritoryCentre = unit->GetEntity()->m_base->m_isTerritoryCentre; + m_FrozenEntity.reset(new SimState::Entity( SimState::Entity::Freeze(unit) )); unit->GetEntity()->Kill(); + + if (wasTerritoryCentre) + g_Game->GetWorld()->GetTerritoryManager()->DelayedRecalculate(); } else { @@ -741,10 +746,10 @@ BEGIN_COMMAND(DeleteObject) { if (m_FrozenEntity.get()) { - m_FrozenEntity->Thaw(); + CEntity* entity = m_FrozenEntity->Thaw(); - // XXXif (m_UnitInLimbo->GetEntity()->m_base->m_isTerritoryCentre) - //g_Game->GetWorld()->GetTerritoryManager()->DelayedRecalculate(); + if (entity && entity->m_base->m_isTerritoryCentre) + g_Game->GetWorld()->GetTerritoryManager()->DelayedRecalculate(); m_FrozenEntity.reset(); } diff --git a/source/tools/atlas/GameInterface/SimState.cpp b/source/tools/atlas/GameInterface/SimState.cpp index 48c921a250..ef3a46050a 100644 --- a/source/tools/atlas/GameInterface/SimState.cpp +++ b/source/tools/atlas/GameInterface/SimState.cpp @@ -32,19 +32,20 @@ SimState::Entity SimState::Entity::Freeze(CUnit* unit) return e; } -void SimState::Entity::Thaw() +CEntity* SimState::Entity::Thaw() { CEntityTemplate* base = g_EntityTemplateCollection.GetTemplate(templateName, g_Game->GetPlayer(playerID)); if (! base) - return; + return NULL; HEntity ent = g_EntityManager.Create(base, position, angle, selections); if (! ent) - return; + return NULL; ent->m_actor->SetPlayerID(playerID); ent->m_actor->SetID(unitID); ent->Initialize(); + return ent; } SimState::Nonentity SimState::Nonentity::Freeze(CUnit* unit) @@ -59,18 +60,19 @@ SimState::Nonentity SimState::Nonentity::Freeze(CUnit* unit) return n; } -void SimState::Nonentity::Thaw() +CUnit* SimState::Nonentity::Thaw() { CUnitManager& unitMan = g_Game->GetWorld()->GetUnitManager(); CUnit* unit = unitMan.CreateUnit(actorName, NULL, selections); if (! unit) - return; + return NULL; CMatrix3D m; m.SetYRotation(angle + PI); m.Translate(position); unit->GetModel()->SetTransform(m); unit->SetID(unitID); + return unit; } SimState* SimState::Freeze(bool onlyEntities) @@ -112,9 +114,6 @@ void SimState::Thaw() CUnitManager& unitMan = g_Game->GetWorld()->GetUnitManager(); // delete all existing entities - g_Game; - g_Game->GetWorld(); - g_Game->GetWorld()->GetProjectileManager(); g_Game->GetWorld()->GetProjectileManager().DeleteAll(); g_EntityManager.DeleteAll(); diff --git a/source/tools/atlas/GameInterface/SimState.h b/source/tools/atlas/GameInterface/SimState.h index 1649b90b7f..fb6270c022 100644 --- a/source/tools/atlas/GameInterface/SimState.h +++ b/source/tools/atlas/GameInterface/SimState.h @@ -2,6 +2,7 @@ #define SIMSTATE_INCLUDED class CUnit; +class CEntity; #include "maths/Vector3D.h" class SimState @@ -11,7 +12,7 @@ public: { public: static Entity Freeze(CUnit* unit); - void Thaw(); + CEntity* Thaw(); private: CStrW templateName; int unitID; @@ -25,7 +26,7 @@ public: { public: static Nonentity Freeze(CUnit* unit); - void Thaw(); + CUnit* Thaw(); private: CStrW actorName; int unitID; diff --git a/source/tools/atlas/wxJS/gui/control/notebook.cpp b/source/tools/atlas/wxJS/gui/control/notebook.cpp index fdfe03a155..1f53c463d1 100644 --- a/source/tools/atlas/wxJS/gui/control/notebook.cpp +++ b/source/tools/atlas/wxJS/gui/control/notebook.cpp @@ -63,9 +63,6 @@ bool Notebook::GetProperty(wxNotebook *p, JSContext *cx, JSObject *obj, int id, bool Notebook::SetProperty(wxNotebook *p, JSContext *cx, JSObject *obj, int id, jsval *vp) { - switch (id) - { - } return true; } @@ -101,13 +98,16 @@ struct Wrapper_wxNotebook : public wxNotebook ~Wrapper_wxNotebook() { wxList* d = GetDynamicEventTable(); - for (wxList::iterator it = d->begin(), end = d->end(); it != end; ++it) + if (d) { - wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)*it; - delete entry->m_callbackUserData; - delete entry; + for (wxList::iterator it = d->begin(), end = d->end(); it != end; ++it) + { + wxDynamicEventTableEntry *entry = (wxDynamicEventTableEntry*)*it; + delete entry->m_callbackUserData; + delete entry; + } + d->Clear(); } - d->Clear(); } }; diff --git a/source/tools/atlas/wxJS/gui/control/radiobox.cpp b/source/tools/atlas/wxJS/gui/control/radiobox.cpp index 92f0690b58..cb2d8b7c4d 100644 --- a/source/tools/atlas/wxJS/gui/control/radiobox.cpp +++ b/source/tools/atlas/wxJS/gui/control/radiobox.cpp @@ -275,7 +275,7 @@ JSBool RadioBox::create(JSContext *cx, if ( argc > 9 ) argc = 9; - int style = 0; + int style = wxRA_SPECIFY_COLS; int max = 0; StringsPtr items; const wxSize *size = &wxDefaultSize; diff --git a/source/tools/atlas/wxJS/gui/event/notebookevt.cpp b/source/tools/atlas/wxJS/gui/event/notebookevt.cpp index 5512087bca..f56f0dec0c 100644 --- a/source/tools/atlas/wxJS/gui/event/notebookevt.cpp +++ b/source/tools/atlas/wxJS/gui/event/notebookevt.cpp @@ -7,8 +7,6 @@ #include "../../common/main.h" #include "../../common/apiwrap.h" -#include - #include "jsevent.h" #include "../misc/size.h" #include "notebookevt.h" diff --git a/source/tools/atlas/wxJS/gui/event/notebookevt.h b/source/tools/atlas/wxJS/gui/event/notebookevt.h index 83c71f5a34..df2380b3cc 100644 --- a/source/tools/atlas/wxJS/gui/event/notebookevt.h +++ b/source/tools/atlas/wxJS/gui/event/notebookevt.h @@ -1,7 +1,7 @@ #ifndef _WXJSNotebookEvent_H #define _WXJSNotebookEvent_H -class wxNotebookEvent; +#include namespace wxjs { diff --git a/source/tools/atlas/wxJS/gui/event/spinevt.cpp b/source/tools/atlas/wxJS/gui/event/spinevt.cpp index 8cc39fb2c9..23a073ecb0 100644 --- a/source/tools/atlas/wxJS/gui/event/spinevt.cpp +++ b/source/tools/atlas/wxJS/gui/event/spinevt.cpp @@ -7,8 +7,6 @@ #include "../../common/main.h" #include "../../common/apiwrap.h" -#include - #include "jsevent.h" #include "../misc/size.h" #include "spinevt.h" diff --git a/source/tools/atlas/wxJS/gui/event/spinevt.h b/source/tools/atlas/wxJS/gui/event/spinevt.h index bb74893b95..7fce65ca82 100644 --- a/source/tools/atlas/wxJS/gui/event/spinevt.h +++ b/source/tools/atlas/wxJS/gui/event/spinevt.h @@ -1,7 +1,7 @@ #ifndef _WXJSSpinEvent_H #define _WXJSSpinEvent_H -class wxSpinEvent; +#include namespace wxjs { diff --git a/source/tools/atlas/wxJS/precompiled.h b/source/tools/atlas/wxJS/precompiled.h index 8ce0969ffe..be9cd39ff5 100644 --- a/source/tools/atlas/wxJS/precompiled.h +++ b/source/tools/atlas/wxJS/precompiled.h @@ -20,11 +20,23 @@ // Precompiled headers: #ifdef USING_PCH - -#define WX_PRECOMP -#include "common/main.h" -#include "wx/wxprec.h" - +# define WX_PRECOMP +# include "common/main.h" +# include "wx/wxprec.h" #endif +/* +// DISABLED: because normally this DLL gets unloaded before the leak reports, which means the +// __FILE__ strings are no longer in valid memory, which breaks everything. + +#if defined(_MSC_VER) && !defined(NDEBUG) +// Include some STL headers that don't like 'new' being redefined +# include +// then redefine 'new' +# define _CRTDBG_MAP_ALLOC +# include +# define new new(_NORMAL_BLOCK, __FILE__, __LINE__) +#endif +*/ + #endif // INCLUDED_STDAFX