diff --git a/Lua/LuaAdapterDefinitions.h b/Lua/LuaAdapterDefinitions.h index ee91c60db..8af53d57e 100644 --- a/Lua/LuaAdapterDefinitions.h +++ b/Lua/LuaAdapterDefinitions.h @@ -362,7 +362,7 @@ namespace RTE { #pragma region BuyMenuGUI Lua Adapters struct LuaAdaptersBuyMenuGUI { - static std::list * GetOrderList(const BuyMenuGUI *luaSelfObject); + static std::list * GetOrderList(const BuyMenuGUI *luaSelfObject); }; #pragma endregion diff --git a/Lua/LuaAdapters.cpp b/Lua/LuaAdapters.cpp index f4f446857..f2bddf81a 100644 --- a/Lua/LuaAdapters.cpp +++ b/Lua/LuaAdapters.cpp @@ -424,9 +424,18 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::list * LuaAdaptersBuyMenuGUI::GetOrderList(const BuyMenuGUI *luaSelfObject) { - auto* orderList = new std::list(); - luaSelfObject->GetOrderList(*orderList); + std::list * LuaAdaptersBuyMenuGUI::GetOrderList(const BuyMenuGUI *luaSelfObject) { + std::list constOrderList; + luaSelfObject->GetOrderList(constOrderList); + + // Previously I tried to push back a cloned object for const-correctness (and giving unique ptr so luabind would clean it up after) + // This is needed cause lua doesn't really enjoy being given a const SceneObject* + // But it didn't like that. So eh + auto* orderList = new std::list(); + for (const SceneObject *constObjectInOrderList : constOrderList) { + orderList->push_back( const_cast(constObjectInOrderList) ); + } + return orderList; } diff --git a/Lua/LuaBindingsManagers.cpp b/Lua/LuaBindingsManagers.cpp index 5d6c39341..47b844f11 100644 --- a/Lua/LuaBindingsManagers.cpp +++ b/Lua/LuaBindingsManagers.cpp @@ -277,6 +277,7 @@ namespace RTE { .property("SceneHeight", &SceneMan::GetSceneHeight) .property("SceneWrapsX", &SceneMan::SceneWrapsX) .property("SceneWrapsY", &SceneMan::SceneWrapsY) + .property("SceneOrbitDirection", &SceneMan::GetSceneOrbitDirection) .property("LayerDrawMode", &SceneMan::GetLayerDrawMode, &SceneMan::SetLayerDrawMode) .property("GlobalAcc", &SceneMan::GetGlobalAcc) .property("OzPerKg", &SceneMan::GetOzPerKg) diff --git a/Managers/SceneMan.cpp b/Managers/SceneMan.cpp index c3ea9ea16..d19671d16 100644 --- a/Managers/SceneMan.cpp +++ b/Managers/SceneMan.cpp @@ -421,13 +421,27 @@ bool SceneMan::SceneWrapsY() const ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Directions SceneMan::GetSceneOrbitDirection() const { + if (m_pCurrentScene) { + SLTerrain *terrain = m_pCurrentScene->GetTerrain(); + if (terrain) { + return terrain->GetOrbitDirection(); + } + } + + return Directions::Up; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + SLTerrain * SceneMan::GetTerrain() { // RTEAssert(m_pCurrentScene, "Trying to get terrain matter before there is a scene or terrain!"); - if (m_pCurrentScene) + if (m_pCurrentScene) { return m_pCurrentScene->GetTerrain(); + } - return 0; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Managers/SceneMan.h b/Managers/SceneMan.h index 3f190631b..7ce6479fc 100644 --- a/Managers/SceneMan.h +++ b/Managers/SceneMan.h @@ -344,6 +344,12 @@ class SceneMan : public Singleton, public Serializable { bool SceneWrapsY() const; + /// + /// Gets the orbit direction for the current scene. + /// + /// The orbit direction for the current scene. + Directions GetSceneOrbitDirection() const; + ////////////////////////////////////////////////////////////////////////////////////////// // Method: GetTerrain //////////////////////////////////////////////////////////////////////////////////////////