diff --git a/Assets/Scripts/Gui/activeGameState.lua b/Assets/Scripts/Gui/activeGameState.lua index f863dd5..c323562 100644 --- a/Assets/Scripts/Gui/activeGameState.lua +++ b/Assets/Scripts/Gui/activeGameState.lua @@ -1,3 +1,5 @@ +Size = {x = 100, y = 100} + gui = { { guiType = GuiType.TEXT, @@ -46,5 +48,25 @@ gui = { fontFirstChar = 0, fontLastChar = 256, color = {x = 1, y = 1, z = 1, w = 1} + }, + --[[ + ]]-- + { + guiType = GuiType.BUTTON, + buttonType = ButtonType.ACTIVE_GAME_STATE, + name = 'Tech', + imagePath = '', + pos = {x = 600, y = 800}, + size = Size, + trigger = 10 + }, + { + guiType = GuiType.BUTTON, + buttonType = ButtonType.ACTIVE_GAME_STATE, + name = 'Trade', + imagePath = '', + pos = {x = 300, y = 800}, + size = Size, + trigger = 10 } } diff --git a/Assets/Scripts/Gui/main.lua b/Assets/Scripts/Gui/main.lua index ee35787..71238fa 100644 --- a/Assets/Scripts/Gui/main.lua +++ b/Assets/Scripts/Gui/main.lua @@ -33,6 +33,7 @@ ButtonType = { SELL_REFINEDS = 29, BUY_RESEARCH = 30, SELL_RESEARCH = 31, + ACTIVE_GAME_STATE = 32 } ListboxType = { diff --git a/CMakeLists.txt b/CMakeLists.txt index 0836f53..f2f54ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(UNIT_BUTTONS unitButton.cpp tradeButton.cpp buildButton.cpp trainButton.cpp set(OPTIONS_BUTTONS optionsButton.cpp tabButton.cpp okButton.cpp defaultsButton.cpp) set(IN_GAME_APP_STATE_BUTTONS mainMenuButton.cpp) set(MAP_EDITOR_BUTTONS mapEditorButton.cpp newMapButton.cpp loadMapButton.cpp exportButton.cpp) -set(BUTTONS singlePlayerButton.cpp exitButton.cpp backButton.cpp playButton.cpp statsButton.cpp ${OPTIONS_BUTTONS} ${IN_GAME_APP_STATE_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS}) +set(BUTTONS singlePlayerButton.cpp exitButton.cpp backButton.cpp playButton.cpp statsButton.cpp activeStateButton.cpp ${OPTIONS_BUTTONS} ${IN_GAME_APP_STATE_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS}) set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp) set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES}) diff --git a/activeGameState.cpp b/activeGameState.cpp index 097707c..d6c3323 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -159,9 +159,8 @@ namespace battleship{ ufCtr->removeGameObjectFrames(); ufCtr->setPlacingFrames(false); - ConcreteGuiManager::getSingleton()->removeAllButtons(); - buttons.clear(); unitGuiScreen = ""; + ConcreteGuiManager::getSingleton()->readLuaScreenScript("activeGameState.lua"); } bool ActiveGameState::selectedUnitsAmongst(vector units){ @@ -331,6 +330,9 @@ namespace battleship{ void ActiveGameState::onAction(int bind, bool isPressed) { GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton(); + if(!ConcreteGuiManager::getSingleton()->findClickedButtons().empty()) + return; + switch((Bind)bind){ case Bind::DRAG_BOX: leftMouseClicked = isPressed; diff --git a/activeStateButton.cpp b/activeStateButton.cpp new file mode 100644 index 0000000..7feb027 --- /dev/null +++ b/activeStateButton.cpp @@ -0,0 +1,22 @@ +#include "activeStateButton.h" +#include "gameManager.h" +#include "activeGameState.h" + +#include + +namespace battleship{ + using namespace std; + using namespace vb01; + using namespace gameBase; + + ActiveStateButton::ActiveStateButton(Vector2 pos, Vector2 size, string name, int trigger, string imagePath) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath){ + StateManager *stateManager = GameManager::getSingleton()->getStateManager(); + ActiveGameState *activeState = (ActiveGameState*)stateManager->getAppStateByType((int)AppStateType::ACTIVE_STATE); + + if(activeState) + activeState->addButton(this); + } + + void ActiveStateButton::onClick(){ + } +} diff --git a/activeStateButton.h b/activeStateButton.h new file mode 100644 index 0000000..67ece5a --- /dev/null +++ b/activeStateButton.h @@ -0,0 +1,15 @@ +#ifndef ACTIVE_STATE_BUTTON_H +#define ACTIVE_STATE_BUTTON_H + +#include + +namespace battleship{ + class ActiveStateButton : public vb01Gui::Button{ + public: + ActiveStateButton(vb01::Vector2, vb01::Vector2, std::string, int = -1, std::string = ""); + void onClick(); + private: + }; +} + +#endif diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index 51f0f35..3369ee7 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -26,6 +26,7 @@ #include "statsButton.h" #include "researchButton.h" #include "tradeButton.h" +#include "activeStateButton.h" namespace battleship{ using namespace std; @@ -213,6 +214,9 @@ namespace battleship{ case SELL_RESEARCH: button = new TradeButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::SELL_RESEARCH); break; + case ACTIVE_GAME_STATE: + button = new ActiveStateButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"]); + break; } int typeArr[2]{(int)GuiElementType::BUTTON, (int)type}; diff --git a/concreteGuiManager.h b/concreteGuiManager.h index 3a9a57c..7c4b122 100644 --- a/concreteGuiManager.h +++ b/concreteGuiManager.h @@ -46,7 +46,8 @@ namespace battleship{ BUY_REFINEDS, SELL_REFINEDS, BUY_RESEARCH, - SELL_RESEARCH + SELL_RESEARCH, + ACTIVE_GAME_STATE }; enum ListboxType { CONTROLS, diff --git a/guiAppState.cpp b/guiAppState.cpp index 375d546..feaccf6 100755 --- a/guiAppState.cpp +++ b/guiAppState.cpp @@ -47,7 +47,7 @@ namespace battleship{ leftMousePressed = isPressed; if(isPressed) - guiManager->findClickedButton(); + guiManager->updateGui(); break; case Bind::SCROLLING_UP:{