unit orders aren't invoked if pressing a button

This commit is contained in:
devZoGok
2024-03-17 15:07:16 +02:00
parent ae93ada2c4
commit ce62c429c5
9 changed files with 72 additions and 5 deletions
+22
View File
@@ -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
}
}
+1
View File
@@ -33,6 +33,7 @@ ButtonType = {
SELL_REFINEDS = 29,
BUY_RESEARCH = 30,
SELL_RESEARCH = 31,
ACTIVE_GAME_STATE = 32
}
ListboxType = {
+1 -1
View File
@@ -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})
+4 -2
View File
@@ -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<Unit*> 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;
+22
View File
@@ -0,0 +1,22 @@
#include "activeStateButton.h"
#include "gameManager.h"
#include "activeGameState.h"
#include <stateManager.h>
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(){
}
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef ACTIVE_STATE_BUTTON_H
#define ACTIVE_STATE_BUTTON_H
#include <button.h>
namespace battleship{
class ActiveStateButton : public vb01Gui::Button{
public:
ActiveStateButton(vb01::Vector2, vb01::Vector2, std::string, int = -1, std::string = "");
void onClick();
private:
};
}
#endif
+4
View File
@@ -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};
+2 -1
View File
@@ -46,7 +46,8 @@ namespace battleship{
BUY_REFINEDS,
SELL_REFINEDS,
BUY_RESEARCH,
SELL_RESEARCH
SELL_RESEARCH,
ACTIVE_GAME_STATE
};
enum ListboxType {
CONTROLS,
+1 -1
View File
@@ -47,7 +47,7 @@ namespace battleship{
leftMousePressed = isPressed;
if(isPressed)
guiManager->findClickedButton();
guiManager->updateGui();
break;
case Bind::SCROLLING_UP:{