From 370dd6b4fd931541afc8e6ff0f6d861b61278c8b Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sun, 25 Jun 2023 16:21:46 +0300 Subject: [PATCH] listbox differentiation --- concreteGuiManager.cpp | 33 +++++++++++++++++++++++++++++---- concreteGuiManager.h | 4 ++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index 5c98dbd..78a5d38 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -101,11 +101,36 @@ namespace battleship{ Vector2 size = Vector2(sizeX, sizeY); int numMaxDisplay = lm->getIntFromTable(guiTable, vector{Index(guiId + 1), Index("numMaxDisplay")}); - string fontFile = lm->getStringFromTable(guiTable, vector{Index(guiId + 1), Index("font")}); - bool closable = lm->getBoolFromTable(guiTable, vector{Index(guiId + 1), Index("closable")}); + ListboxType listboxType = (ListboxType)lm->getIntFromTable(guiTable, vector{Index(guiId + 1), Index("listboxType")}); + + vector lines; + int maxDisplay, numLines; + bool closable; + + switch(listboxType){ + case CONTROLS:{ + numLines = 6; + closable = false; + + for(int i = 0; i < numLines; i++) + lines.push_back(to_string(i)); + } + break; + case RESOLUTION:{ + numLines = lm->getIntFromTable(guiTable, vector{Index(guiId + 1), Index("numLines")}); + + for(int i = 0; i < numLines; i++) + lines.push_back(lm->getStringFromTable(guiTable, vector{Index(guiId + 1), Index("lines"), Index(i + 1)})); + + closable = true; + } + break; + } + + maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines); + string fontPath = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; + Listbox *listbox = new Listbox(pos, size, lines, maxDisplay, fontPath, closable); - string fontPath = GameManager::getSingleton()->getPath() + "Fonts/" + fontFile; - Listbox *listbox = new Listbox(pos, size, vector{"a", "b"}, 2, fontPath, closable); return listbox; } diff --git a/concreteGuiManager.h b/concreteGuiManager.h index 993eb73..0556e2d 100644 --- a/concreteGuiManager.h +++ b/concreteGuiManager.h @@ -21,6 +21,10 @@ namespace battleship{ AUDIO_TAB, MULTIPLAYER_TAB }; + enum ListboxType { + CONTROLS, + RESOLUTION + }; class ConcreteGuiManager : public vb01Gui::AbstractGuiManager{ public: