From 15edbabbfc6869a188f026c38e4740697eef2683 Mon Sep 17 00:00:00 2001 From: Causeless Date: Sat, 4 Nov 2023 21:02:20 +0000 Subject: [PATCH 1/3] Attempted fix for buy menu order list awkwardness --- Lua/LuaAdapterDefinitions.h | 2 +- Lua/LuaAdapters.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Lua/LuaAdapterDefinitions.h b/Lua/LuaAdapterDefinitions.h index ee91c60db..f29a2c718 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..78ae53436 100644 --- a/Lua/LuaAdapters.cpp +++ b/Lua/LuaAdapters.cpp @@ -424,9 +424,15 @@ 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); + + auto* orderList = new std::list>(); + for (const SceneObject *constObjectInOrderList : constOrderList) { + orderList->push_back( std::unique_ptr(static_cast(constObjectInOrderList->Clone())) ); + } + return orderList; } From 7ae64798e64b72ce4423969c8648f9277c27fe4e Mon Sep 17 00:00:00 2001 From: Causeless Date: Sat, 4 Nov 2023 21:50:24 +0000 Subject: [PATCH 2/3] Hopefuly fix v2. --- Lua/LuaAdapterDefinitions.h | 2 +- Lua/LuaAdapters.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Lua/LuaAdapterDefinitions.h b/Lua/LuaAdapterDefinitions.h index f29a2c718..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 78ae53436..f2bddf81a 100644 --- a/Lua/LuaAdapters.cpp +++ b/Lua/LuaAdapters.cpp @@ -424,13 +424,16 @@ namespace RTE { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - std::list> * LuaAdaptersBuyMenuGUI::GetOrderList(const BuyMenuGUI *luaSelfObject) { + std::list * LuaAdaptersBuyMenuGUI::GetOrderList(const BuyMenuGUI *luaSelfObject) { std::list constOrderList; luaSelfObject->GetOrderList(constOrderList); - auto* orderList = new std::list>(); + // 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( std::unique_ptr(static_cast(constObjectInOrderList->Clone())) ); + orderList->push_back( const_cast(constObjectInOrderList) ); } return orderList; From 24c7cceecc510c62c25cc4ce98d3e850142ce15e Mon Sep 17 00:00:00 2001 From: Causeless Date: Sun, 5 Nov 2023 11:34:39 +0000 Subject: [PATCH 3/3] Expose orbitdirection to lua --- Lua/LuaBindingsManagers.cpp | 1 + Managers/SceneMan.cpp | 18 ++++++++++++++++-- Managers/SceneMan.h | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) 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 //////////////////////////////////////////////////////////////////////////////////////////