common PF button super class

This commit is contained in:
devZoGok
2026-08-07 11:54:55 +03:00
parent 406bbe6132
commit 47b156b8d6
46 changed files with 165 additions and 97 deletions
+10 -1
View File
@@ -30,7 +30,16 @@ gui = {
size = Size,
guiType = GuiType.BUTTON,
name = 'Single player',
buttonType = ButtonType.SINGLE_PLAYER
buttonType = ButtonType.SINGLE_PLAYER,
baseColor = {x = .6, y = .6, z = .6, w = 1},
hoveredOnColor = {x = .8, y = .8, z = .8, w = 1},
tooltip = {
offset = {x = 100, y = 100},
size = {x = 300, y = 200},
lines = {
{entry = {text = 'Play with computer opponents'}},
}
}
},
{
pos = {x = 20, y = 160, z = 0},
+1 -1
View File
@@ -23,7 +23,7 @@ set(OPTIONS_BUTTONS optionsButton.cpp tabButton.cpp okButton.cpp defaultsButton.
set(TRADING_BUTTONS activeStateBackButton.cpp playerTradeButton.cpp tradingScreenButton.cpp offerButton.cpp resourceAmmountButton.cpp)
set(MENU_BUTTONS mainMenuButton.cpp singlePlayerButton.cpp exitButton.cpp backButton.cpp playButton.cpp)
set(MAP_EDITOR_BUTTONS mapEditorButton.cpp newMapButton.cpp loadMapButton.cpp exportButton.cpp)
set(BUTTONS statsButton.cpp activeStateButton.cpp minimapButton.cpp ${TRADING_BUTTONS} ${OPTIONS_BUTTONS} ${MENU_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS})
set(BUTTONS pfButtonBase.cpp statsButton.cpp activeStateButton.cpp minimapButton.cpp ${TRADING_BUTTONS} ${OPTIONS_BUTTONS} ${MENU_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS})
set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp mapListbox.cpp)
set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
+1 -1
View File
@@ -19,7 +19,7 @@ namespace battleship{
using namespace gameBase;
ActiveStateButton::ActiveStateButton(Vector3 pos, Vector2 size, string gs, string name, string fontPath, int trigger, string imagePath) :
Button(pos, size, name, fontPath, trigger, true, imagePath), guiScreen(gs){}
PfButtonBase(pos, size, name, fontPath, trigger, true, imagePath), guiScreen(gs){}
void ActiveStateButton::onClick(){
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef ACTIVE_STATE_BUTTON_H
#define ACTIVE_STATE_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class ActiveStateButton : public vb01Gui::Button{
class ActiveStateButton : public PfButtonBase{
public:
ActiveStateButton(vb01::Vector3, vb01::Vector2, std::string, std::string, std::string, int = -1, std::string = "");
void onClick();
+1 -1
View File
@@ -8,7 +8,7 @@ namespace battleship{
using namespace vb01Gui;
BackButton::BackButton(Vector3 pos, Vector2 size, string name, string scr) :
Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true),
PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true),
screen(scr){}
void BackButton::onClick() {
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef BACK_BUTTON_H
#define BACK_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class BackButton : public vb01Gui::Button{
class BackButton : public PfButtonBase{
public:
BackButton(vb01::Vector3, vb01::Vector2, std::string, std::string);
void onClick();
+19 -2
View File
@@ -5,6 +5,7 @@
#include "concreteGuiManager.h"
#include "unit.h"
#include "gameManager.h"
#include "pfButtonBase.h"
#include "singlePlayerButton.h"
#include "mapEditorButton.h"
#include "optionsButton.h"
@@ -134,13 +135,12 @@ namespace battleship{
tooltip = parseTooltip(tbl, pos);
}
Button *button = nullptr;
PfButtonBase *button = nullptr;
string guiScreen = "";
switch(type){
case SINGLE_PLAYER:
button = new SinglePlayerButton(pos, size, name);
((SinglePlayerButton*)button)->setTooltip(tooltip);
break;
case EDITOR:
button = new MapEditorButton(pos, size);
@@ -290,6 +290,23 @@ namespace battleship{
}
}
sol::optional<sol::table> baseColorTblOpt = guiTable["baseColor"], hoveredColorTblOpt = guiTable["hoveredOnColor"];
if(baseColorTblOpt != sol::nullopt){
sol::table baseColorTbl = guiTable["baseColor"];
Vector4 color = Vector4(baseColorTbl["x"], baseColorTbl["y"], baseColorTbl["z"], baseColorTbl["w"]);
button->setBaseColor(color);
button->setColor(color);
}
if(hoveredColorTblOpt != sol::nullopt){
sol::table hoveredColorTbl = guiTable["hoveredOnColor"];
button->setHoveredOnColor(Vector4(hoveredColorTbl["x"], hoveredColorTbl["y"], hoveredColorTbl["z"], hoveredColorTbl["w"]));
button->setEnabledHoverdOn(true);
}
button->setTooltip(tooltip);
int typeArr[2]{(int)GuiElementType::BUTTON, (int)type};
guiElements.push_back(make_pair(typeArr, (void*)button));
+1 -1
View File
@@ -6,7 +6,7 @@ namespace battleship{
using namespace vb01;
using namespace vb01Gui;
DefaultsButton::DefaultsButton(Vector3 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
DefaultsButton::DefaultsButton(Vector3 pos, Vector2 size, string name) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
void DefaultsButton::onClick() {}
}
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef DEFAULTS_BUTTON_H
#define DEFAULTS_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class DefaultsButton : public vb01Gui::Button{
class DefaultsButton : public PfButtonBase{
public:
DefaultsButton(vb01::Vector3, vb01::Vector2, std::string);
void onClick();
+1 -1
View File
@@ -5,7 +5,7 @@ using namespace std;
using namespace vb01;
namespace battleship{
ExitButton::ExitButton(Vector3 pos, Vector2 size) : Button(pos, size, "Exit", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
ExitButton::ExitButton(Vector3 pos, Vector2 size) : PfButtonBase(pos, size, "Exit", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
void ExitButton::onClick() {
GameManager::getSingleton()->setRunning(false);
+3 -2
View File
@@ -1,11 +1,12 @@
#ifndef EXIT_BUTTON_H
#define EXIT_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
#include <vector.h>
namespace battleship {
class ExitButton : public vb01Gui::Button {
class ExitButton : public PfButtonBase {
public:
ExitButton(vb01::Vector3, vb01::Vector2);
void onClick();
+1 -1
View File
@@ -10,7 +10,7 @@ namespace battleship{
using namespace vb01Gui;
using namespace gameBase;
ExportButton::ExportButton(Vector3 pos, Vector2 size) : Button(pos, size, "Export", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){}
ExportButton::ExportButton(Vector3 pos, Vector2 size) : PfButtonBase(pos, size, "Export", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){}
void ExportButton::onClick(){
StateManager *sm = GameManager::getSingleton()->getStateManager();
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef EXPORT_BUTTON_H
#define EXPORT_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class ExportButton : public vb01Gui::Button{
class ExportButton : public PfButtonBase{
public:
ExportButton(vb01::Vector3 pos, vb01::Vector2 size);
void onClick();
+8 -7
View File
@@ -1,6 +1,5 @@
#include <algorithm>
#include <button.h>
#include <util.h>
#include <root.h>
@@ -11,6 +10,7 @@
#include "defConfigs.h"
#include "inGameAppState.h"
#include "pfButtonBase.h"
#include "game.h"
#include "console.h"
#include "gameObjectFrameController.h"
@@ -27,22 +27,23 @@ namespace battleship{
using namespace configData;
using namespace gameBase;
InGameAppState::ResumeButton::ResumeButton(Vector3 pos, Vector2 size) : Button(pos, size, "Resume", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
InGameAppState::ResumeButton::ResumeButton(Vector3 pos, Vector2 size) : PfButtonBase(pos, size, "Resume", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
void InGameAppState::ResumeButton::onClick() {
Game::getSingleton()->togglePause();
}
InGameAppState::ConsoleButton::ConsoleButton(Vector3 pos, Vector2 size) : Button(pos, size, "Console", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) { }
InGameAppState::ConsoleButton::ConsoleButton(Vector3 pos, Vector2 size) : PfButtonBase(pos, size, "Console", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
void InGameAppState::ConsoleButton::onClick() {
ConcreteGuiManager::getSingleton()->readLuaScreenScript("console.lua");
}
InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::ConsoleCommandEntryButton(Textbox *t, Listbox *l, Vector3 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", 257, true) {
textbox = t;
listbox = l;
}
InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::ConsoleCommandEntryButton(Textbox *t, Listbox *l, Vector3 pos, Vector2 size, string name) :
PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", 257, true),
textbox(t),
listbox(l)
{}
void InGameAppState::ConsoleButton::ConsoleButton::ConsoleCommandEntryButton::onClick() {
Console::execute(wstringToString(textbox->getText()));
+3 -3
View File
@@ -16,16 +16,16 @@
namespace battleship{
class InGameAppState : public gameBase::AbstractAppState {
public:
class ResumeButton : public vb01Gui::Button {
class ResumeButton : public PfButtonBase {
public:
ResumeButton(vb01::Vector3, vb01::Vector2);
void onClick();
private:
};
class ConsoleButton : public vb01Gui::Button {
class ConsoleButton : public PfButtonBase {
public:
class ConsoleCommandEntryButton : public Button {
class ConsoleCommandEntryButton : public PfButtonBase {
public:
ConsoleCommandEntryButton(vb01Gui::Textbox*, vb01Gui::Listbox*, vb01::Vector3, vb01::Vector2, std::string);
void onClick();
+5 -2
View File
@@ -12,7 +12,10 @@ namespace battleship{
using namespace vb01Gui;
using namespace gameBase;
LoadMapButton::OkButton::OkButton(vb01::Vector3 pos, vb01::Vector2 size, vb01Gui::Listbox *listbox) : Button(pos, size, "Ok", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){ this->listbox = listbox; }
LoadMapButton::OkButton::OkButton(Vector3 pos, Vector2 size, Listbox *lb) :
PfButtonBase(pos, size, "Ok", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true),
listbox(lb)
{}
void LoadMapButton::OkButton::onClick(){
StateManager *sm = GameManager::getSingleton()->getStateManager();
@@ -20,7 +23,7 @@ namespace battleship{
handleLoadingGui(new LoadingAppState(new MapEditorAppState(name, Vector2::VEC_ZERO, false), "mapEditor.lua"));
}
LoadMapButton::LoadMapButton(Vector3 pos, Vector2 size) : Button(pos, size, "Load map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){}
LoadMapButton::LoadMapButton(Vector3 pos, Vector2 size) : PfButtonBase(pos, size, "Load map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){}
void LoadMapButton::onClick(){
ConcreteGuiManager::getSingleton()->readLuaScreenScript("loadMap.lua");
+3 -3
View File
@@ -1,16 +1,16 @@
#ifndef LOAD_MAP_BUTTON_H
#define LOAD_MAP_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace vb01Gui{
class Listbox;
}
namespace battleship{
class LoadMapButton : public vb01Gui::Button{
class LoadMapButton : public PfButtonBase{
public:
class OkButton : public vb01Gui::Button{
class OkButton : public PfButtonBase{
public:
OkButton(vb01::Vector3, vb01::Vector2, vb01Gui::Listbox*);
void onClick();
+1 -1
View File
@@ -7,7 +7,7 @@ namespace battleship{
using namespace vb01;
using namespace vb01Gui;
MainMenuButton::MainMenuButton(Vector3 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){}
MainMenuButton::MainMenuButton(Vector3 pos, Vector2 size, string name) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){}
void MainMenuButton::onClick(){
}
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef MAIN_MENU_BUTTON_H
#define MAIN_MENU_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class MainMenuButton : public vb01Gui::Button{
class MainMenuButton : public PfButtonBase{
public:
MainMenuButton(vb01::Vector3, vb01::Vector2, std::string);
void onClick();
+3 -4
View File
@@ -1,14 +1,13 @@
#ifndef MAP_EDITOR_BUTTON_H
#define MAP_EDITOR_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
#include "gameManager.h"
namespace battleship{
class MapEditorButton : public vb01Gui::Button{
class MapEditorButton : public PfButtonBase{
public:
MapEditorButton(vb01::Vector3 pos, vb01::Vector2 size) : vb01Gui::Button(pos, size, "Map editor", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){}
MapEditorButton(vb01::Vector3 pos, vb01::Vector2 size) : PfButtonBase(pos, size, "Map editor", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){}
void onClick();
private:
};
+7 -6
View File
@@ -15,11 +15,12 @@ namespace battleship{
using namespace vb01Gui;
using namespace gameBase;
NewMapButton::OkButton::OkButton(vb01::Vector3 pos, vb01::Vector2 size, vb01Gui::Textbox *name, vb01Gui::Textbox *sx, vb01Gui::Textbox *sy) : Button(pos, size, "Ok", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){
this->name = name;
this->sizeX = sx;
this->sizeY = sy;
}
NewMapButton::OkButton::OkButton(Vector3 pos, Vector2 size, Textbox *nm, Textbox *sx, Textbox *sy) :
PfButtonBase(pos, size, "Ok", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true),
name(nm),
sizeX(sx),
sizeY(sy)
{}
void NewMapButton::OkButton::onClick(){
Vector2 size = Vector2(
@@ -29,7 +30,7 @@ namespace battleship{
handleLoadingGui(new LoadingAppState(new MapEditorAppState(wstringToString(name->getText()), size, true), "mapEditor.lua"));
}
NewMapButton::NewMapButton(Vector3 pos, Vector2 size) : Button(pos, size, "New map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"){}
NewMapButton::NewMapButton(Vector3 pos, Vector2 size) : PfButtonBase(pos, size, "New map", GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true){}
void NewMapButton::onClick(){
ConcreteGuiManager::getSingleton()->readLuaScreenScript("newMap.lua");
+3 -3
View File
@@ -1,16 +1,16 @@
#ifndef NEW_MAP_BUTTON_H
#define NEW_MAP_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace vb01Gui{
class Textbox;
}
namespace battleship{
class NewMapButton : public vb01Gui::Button{
class NewMapButton : public PfButtonBase{
public:
class OkButton : public vb01Gui::Button{
class OkButton : public PfButtonBase{
public:
OkButton(vb01::Vector3, vb01::Vector2, vb01Gui::Textbox*, vb01Gui::Textbox*, vb01Gui::Textbox*);
void onClick();
+1 -1
View File
@@ -17,7 +17,7 @@ namespace battleship{
using namespace gameBase;
OfferButton::OfferButton(Vector3 pos, Vector2 size, int plId, string name, int trigger, string imagePath) :
Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath),
PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath),
playerId(plId){}
void OfferButton::onClick(){
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef OFFER_BUTTON_H
#define OFFER_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class OfferButton : public vb01Gui::Button{
class OfferButton : public PfButtonBase{
public:
OfferButton(vb01::Vector3, vb01::Vector2, int, std::string, int, std::string);
void onClick();
+1 -1
View File
@@ -6,7 +6,7 @@ namespace battleship{
using namespace vb01;
using namespace vb01Gui;
OkButton::OkButton(Vector3 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
OkButton::OkButton(Vector3 pos, Vector2 size, string name) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {}
void OkButton::onClick() {}
}
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef OK_BUTTON_H
#define OK_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class OkButton : public vb01Gui::Button{
class OkButton : public PfButtonBase{
public:
OkButton(vb01::Vector3, vb01::Vector2, std::string);
void onClick();
+1 -1
View File
@@ -7,7 +7,7 @@ using namespace vb01;
using namespace std;
namespace battleship{
OptionsButton::OptionsButton(Vector3 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {}
OptionsButton::OptionsButton(Vector3 pos, Vector2 size, string name, bool separate) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, separate) {}
void OptionsButton::onClick() {
ConcreteGuiManager::getSingleton()->readLuaScreenScript("options.lua");
+2 -3
View File
@@ -1,11 +1,10 @@
#pragma once
#ifndef OPTIONS_BUTTON_H
#define OPTIONS_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship {
class OptionsButton : public vb01Gui::Button {
class OptionsButton : public PfButtonBase {
public:
OptionsButton(vb01::Vector3, vb01::Vector2, std::string, bool);
virtual void onClick();
+1 -1
View File
@@ -13,7 +13,7 @@ namespace battleship{
using namespace gameBase;
OrderButton::OrderButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int oid) :
Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath),
PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath),
orderId(oid)
{}
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef ORDER_BUTTON_H
#define ORDER_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class OrderButton : public vb01Gui::Button{
class OrderButton : public PfButtonBase{
public:
OrderButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int);
void onClick();
+23
View File
@@ -0,0 +1,23 @@
#include "pfButtonBase.h"
#include "tooltip.h"
#include <quad.h>
#include <node.h>
namespace battleship{
using namespace std;
using namespace vb01;
PfButtonBase::PfButtonBase(Vector3 pos, Vector2 size, string name, string fontPath, int trigger, bool separate, string imagePath) : Button(pos, size, name, fontPath, trigger, separate, imagePath){}
PfButtonBase::~PfButtonBase(){
if(tooltip) delete tooltip;
}
void PfButtonBase::update() {
if(enabledHoveredOn)
setColor(mouseOver ? hoveredOnColor : baseColor);
if(tooltip) tooltip->getBackground()->getNode()->setVisible(mouseOver);
}
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef PF_BUTTON_BASE_H
#define PF_BUTTON_BASE_H
#include <button.h>
namespace battleship{
class Tooltip;
class PfButtonBase : public vb01Gui::Button{
public:
PfButtonBase(vb01::Vector3, vb01::Vector2, std::string, std::string, int, bool, std::string = "");
~PfButtonBase();
virtual void update();
inline void setTooltip(Tooltip *t){this->tooltip = t;}
inline void setEnabledHoverdOn(bool e){this->enabledHoveredOn = e;}
inline void setHoveredOnColor(vb01::Vector4 hc){this->hoveredOnColor = hc;}
inline void setBaseColor(vb01::Vector4 bc){this->baseColor = bc;}
private:
bool enabledHoveredOn = false;
vb01::Vector4 baseColor, hoveredOnColor;
Tooltip *tooltip = nullptr;
};
}
#endif
+1 -1
View File
@@ -15,7 +15,7 @@ namespace battleship{
using namespace vb01Gui;
using namespace gameBase;
PlayButton::PlayButton(Listbox *ml, Vector3 pos, Vector2 size, string name, bool separate) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_P, separate), mapListbox(ml) {}
PlayButton::PlayButton(Listbox *ml, Vector3 pos, Vector2 size, string name, bool separate) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_P, separate), mapListbox(ml) {}
void PlayButton::onClick() {
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
+2 -2
View File
@@ -1,14 +1,14 @@
#ifndef PLAY_BUTTON_H
#define PLAY_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace vb01Gui{
class Listbox;
}
namespace battleship{
class PlayButton : public vb01Gui::Button {
class PlayButton : public PfButtonBase {
public:
PlayButton(vb01Gui::Listbox*, vb01::Vector3, vb01::Vector2, std::string, bool);
void onClick();
+3 -1
View File
@@ -9,7 +9,9 @@ namespace battleship{
using namespace vb01;
using namespace vb01Gui;
ResourceAmmountButton::ResourceAmmountButton(Vector3 pos, Vector2 size, string name, int amm, int trigger, string imagePath) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath), ammount(amm) {
ResourceAmmountButton::ResourceAmmountButton(Vector3 pos, Vector2 size, string name, int amm, int trigger, string imagePath) :
PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath), ammount(amm)
{
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
int numTextboxes = guiManager->getTextboxes().size();
textbox = guiManager->getTextboxes()[numTextboxes - 1];
+2 -2
View File
@@ -1,14 +1,14 @@
#ifndef RESOURCE_AMMOUNT_BUTTON_H
#define RESOURCE_AMMOUNT_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace vb01Gui{
class Textbox;
}
namespace battleship{
class ResourceAmmountButton : public vb01Gui::Button{
class ResourceAmmountButton : public PfButtonBase{
public:
ResourceAmmountButton(vb01::Vector3, vb01::Vector2, std::string, int, int, std::string);
void onClick();
+1 -9
View File
@@ -15,9 +15,7 @@ namespace battleship{
using namespace vb01;
using namespace vb01Gui;
SinglePlayerButton::SinglePlayerButton(Vector3 pos, Vector2 size, string name) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_S, true) {}
SinglePlayerButton::~SinglePlayerButton(){delete tooltip;}
SinglePlayerButton::SinglePlayerButton(Vector3 pos, Vector2 size, string name) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", GLFW_KEY_S, true) {}
void SinglePlayerButton::onClick() {
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
@@ -29,10 +27,4 @@ namespace battleship{
guiManager->getText("_mainPlayer")->setText(GameManager::getSingleton()->getMainPlayerName());
}
void SinglePlayerButton::update() {
setColor(mouseOver ? Vector4(.8, .8, .8, 1) : Vector4(.6, .6, .6, 1));
if(tooltip) tooltip->getBackground()->getNode()->setVisible(mouseOver);
}
}
+3 -7
View File
@@ -3,20 +3,16 @@
#include <vector>
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class Tooltip;
class SinglePlayerButton : public vb01Gui::Button {
class SinglePlayerButton : public PfButtonBase {
public:
SinglePlayerButton(vb01::Vector3, vb01::Vector2, std::string);
~SinglePlayerButton();
~SinglePlayerButton(){}
void onClick();
void update();
inline void setTooltip(Tooltip *t){this->tooltip = t;}
private:
Tooltip *tooltip = nullptr;
};
}
+1 -1
View File
@@ -12,7 +12,7 @@ namespace battleship{
using namespace vb01Gui;
using namespace gameBase;
StateToggleButton::StateToggleButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath) {
StateToggleButton::StateToggleButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath) {
updateStateId();
toggleImage();
}
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef STATE_TOGGLE_BUTTON_H
#define STATE_TOGGLE_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class StateToggleButton : public vb01Gui::Button{
class StateToggleButton : public PfButtonBase{
public:
StateToggleButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string);
void onClick();
+1 -1
View File
@@ -13,7 +13,7 @@ namespace battleship{
using namespace vb01;
using namespace gameBase;
StatsButton::StatsButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath){}
StatsButton::StatsButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, true, imagePath){}
void StatsButton::addPlayerDataGuiElements(int playerId){
const int numPairs = 7;
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef STATS_BUTTON_H
#define STATS_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship {
class StatsButton : public vb01Gui::Button{
class StatsButton : public PfButtonBase{
public:
StatsButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string);
void onClick();
+1 -1
View File
@@ -7,7 +7,7 @@ namespace battleship{
using namespace vb01;
using namespace vb01Gui;
TabButton::TabButton(Vector3 pos, Vector2 size, string name, string screenScript) : Button(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
TabButton::TabButton(Vector3 pos, Vector2 size, string name, string screenScript) : PfButtonBase(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", -1, true) {
this->screenScript = screenScript;
}
+2 -2
View File
@@ -1,10 +1,10 @@
#ifndef TAB_BUTTON_H
#define TAB_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class TabButton : public vb01Gui::Button{
class TabButton : public PfButtonBase{
public:
TabButton(vb01::Vector3, vb01::Vector2, std::string, std::string);
void onClick();
+1 -1
View File
@@ -12,7 +12,7 @@ namespace battleship{
using namespace vb01Gui;
using namespace gameBase;
UnitButton::UnitButton(Vector3 pos, Vector2 size, string name, string fontPath, int trigger, string imagePath) : Button(pos, size, name, fontPath, trigger, true, imagePath){
UnitButton::UnitButton(Vector3 pos, Vector2 size, string name, string fontPath, int trigger, string imagePath) : PfButtonBase(pos, size, name, fontPath, trigger, true, imagePath){
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
ActiveGameState *activeState = (ActiveGameState*)stateManager->getAppStateByType((int)AppStateType::ACTIVE_STATE);
+2 -2
View File
@@ -1,12 +1,12 @@
#ifndef UNIT_BUTTON_H
#define UNIT_BUTTON_H
#include <button.h>
#include "pfButtonBase.h"
namespace battleship{
class Unit;
class UnitButton : public vb01Gui::Button{
class UnitButton : public PfButtonBase{
public:
UnitButton(vb01::Vector3, vb01::Vector2, std::string, std::string, int, std::string);
protected: