correctly deleting GUI rects when changing trading screens

This commit is contained in:
devZoGok
2024-05-25 20:19:09 +03:00
parent 83b9184812
commit 1274ba20f6
4 changed files with 20 additions and 2 deletions
+3
View File
@@ -44,18 +44,21 @@ gui = {
},
{
guiType = GuiType.GUI_RECTANGLE,
name = 'refineds',
pos = {x = 0, y = 0, z = 0},
size = {x = s, y = s},
imagePath = resIconBasePath .. 'refineds.png',
},
{
guiType = GuiType.GUI_RECTANGLE,
name = 'wealth',
pos = {x = 200, y = 0, z = 0},
size = {x = s, y = s},
imagePath = resIconBasePath .. 'wealth.png',
},
{
guiType = GuiType.GUI_RECTANGLE,
name = 'research',
pos = {x = 400, y = 0, z = 0},
size = {x = s, y = s},
imagePath = resIconBasePath .. 'research.png',
+6
View File
@@ -58,6 +58,12 @@ function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath)
end
gui = {
{
guiType = GuiType.GUI_RECTANGLE,
pos = HubPos,
size = HubSize,
color = {x = 0, y = 0, z = 0, w = .6}
},
{
guiType = GuiType.TEXT,
name = 'P0',
+5 -1
View File
@@ -33,7 +33,11 @@ namespace battleship{
vector<Checkbox*> checkboxes{};
vector<Slider*> sliders{};
vector<Textbox*> textboxes{};
vector<Node*> guiRects = guiManager->getGuiRectangles();
vector<Node*> guiRects{
guiManager->getGuiRectangle("refineds"),
guiManager->getGuiRectangle("wealth"),
guiManager->getGuiRectangle("research"),
};
vector<Text*> texts{
guiManager->getText("depth"),
guiManager->getText("refineds"),
+6 -1
View File
@@ -441,6 +441,7 @@ namespace battleship{
return textbox;
}
//TODO factor out checking for optional lua values
Node* ConcreteGuiManager::parseGuiRectangle(int guiId){
sol::state_view SOL_LUA_STATE = generateView();
sol::table guiTable = SOL_LUA_STATE["gui"][guiId + 1];
@@ -454,6 +455,10 @@ namespace battleship{
string imagePath = (pathOpt != sol::nullopt ? (string)guiTable[ipk] : "");
bool texturingEnabled = (imagePath != "");
string nk = "name";
sol::optional<string> nameOpt = guiTable[nk];
string name = (nameOpt != sol::nullopt ? (string)guiTable[nk] : "");
mat->addBoolUniform("texturingEnabled", texturingEnabled);
if(texturingEnabled){
@@ -471,7 +476,7 @@ namespace battleship{
quad->setMaterial(mat);
sol::table posTable = guiTable["pos"];
Node *guiRectangle = new Node(Vector3(posTable["x"], posTable["y"], posTable["z"]));
Node *guiRectangle = new Node(Vector3(posTable["x"], posTable["y"], posTable["z"]), Quaternion::QUAT_W, Vector3::VEC_IJK, name);
guiRectangle->attachMesh(quad);
root->getGuiNode()->attachChild(guiRectangle);