mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
bugfix for crashes when clicking on trade centers or labs
This commit is contained in:
@@ -2676,7 +2676,7 @@ units = {
|
|||||||
unitClass = UnitClass.LAB,
|
unitClass = UnitClass.LAB,
|
||||||
unitType = UnitType.LAND,
|
unitType = UnitType.LAND,
|
||||||
maxUnevenness = .5,
|
maxUnevenness = .5,
|
||||||
abilityButtons = {{buttonType = ButtonType.RESEARCH, name = 'Tech tree', guiScreen = 'researchStructCommands.lua'}},
|
abilityButtons = {{buttonType = ButtonType.ACTIVE_STATE, name = 'Tech tree', guiScreen = 'acsTechTree.lua'}},
|
||||||
isVehicle = false,
|
isVehicle = false,
|
||||||
health = 500,
|
health = 500,
|
||||||
buildTime = 1000,
|
buildTime = 1000,
|
||||||
@@ -2699,7 +2699,7 @@ units = {
|
|||||||
unitClass = UnitClass.LAB,
|
unitClass = UnitClass.LAB,
|
||||||
unitType = UnitType.LAND,
|
unitType = UnitType.LAND,
|
||||||
maxUnevenness = .5,
|
maxUnevenness = .5,
|
||||||
abilityButtons = {{buttonType = ButtonType.RESEARCH, name = 'Tech tree', guiScreen = 'researchStructCommands.lua'}},
|
abilityButtons = {{buttonType = ButtonType.ACTIVE_STATE, name = 'Tech tree', guiScreen = 'aincTechTree.lua'}},
|
||||||
isVehicle = false,
|
isVehicle = false,
|
||||||
health = 500,
|
health = 500,
|
||||||
buildTime = 1000,
|
buildTime = 1000,
|
||||||
@@ -2722,7 +2722,7 @@ units = {
|
|||||||
unitClass = UnitClass.LAB,
|
unitClass = UnitClass.LAB,
|
||||||
unitType = UnitType.LAND,
|
unitType = UnitType.LAND,
|
||||||
maxUnevenness = .5,
|
maxUnevenness = .5,
|
||||||
abilityButtons = {{buttonType = ButtonType.RESEARCH, name = 'Tech tree', guiScreen = 'researchStructCommands.lua'}},
|
abilityButtons = {{buttonType = ButtonType.ACTIVE_STATE, name = 'Tech tree', guiScreen = 'erTechTree.lua'}},
|
||||||
isVehicle = false,
|
isVehicle = false,
|
||||||
health = 500,
|
health = 500,
|
||||||
buildTime = 1000,
|
buildTime = 1000,
|
||||||
|
|||||||
@@ -0,0 +1,106 @@
|
|||||||
|
res = graphics.resolution
|
||||||
|
Size = {x = res.x * .5, y = res.y * .5}
|
||||||
|
techButtonSize = {x = 50, y = 50}
|
||||||
|
Pos = {x = res.x * .3, y = res.y * .1, z = .1}
|
||||||
|
margin = {top = 10, left = 10, right = 10, bottom = 10}
|
||||||
|
baseTechPath = 'Icons/Technologies/'
|
||||||
|
heightOffset = techButtonSize.y + 10
|
||||||
|
|
||||||
|
gui = {
|
||||||
|
{
|
||||||
|
guiType = GuiType.GUI_RECTANGLE,
|
||||||
|
pos = Pos,
|
||||||
|
size = Size,
|
||||||
|
color = {x = 0, y = 0, z = 0, w = .6}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x - techButtonSize.x), y = Pos.y + margin.top, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "ACS APT",
|
||||||
|
imagePath = baseTechPath .. 'apt.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.APT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + margin.left, y = Pos.y + margin.top + heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "FPT",
|
||||||
|
imagePath = baseTechPath .. 'fpt.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.FPT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + margin.left, y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Cruisers",
|
||||||
|
imagePath = baseTechPath .. 'cruisers.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.CRUISERS,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x - techButtonSize.x), y = Pos.y + margin.top + heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "EFT",
|
||||||
|
imagePath = baseTechPath .. 'ept.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.EFT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x - 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Stealth",
|
||||||
|
imagePath = baseTechPath .. 'stealth.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.ST_SUB,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Robotics",
|
||||||
|
imagePath = baseTechPath .. 'robo.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.ROBO,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x - (margin.right + techButtonSize.x), y = Pos.y + margin.top + heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "PCT",
|
||||||
|
imagePath = baseTechPath .. 'pct.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.PCT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x - (margin.right + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Carriers",
|
||||||
|
imagePath = baseTechPath .. 'carriers.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.CARRIERS,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x - (margin.right + techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Tanks",
|
||||||
|
imagePath = baseTechPath .. 'tanks.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.TANKS,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
res = graphics.resolution
|
||||||
|
Size = {x = res.x * .5, y = res.y * .5}
|
||||||
|
techButtonSize = {x = 50, y = 50}
|
||||||
|
Pos = {x = res.x * .3, y = res.y * .1, z = .1}
|
||||||
|
margin = {top = 10, left = 10, right = 10, bottom = 10}
|
||||||
|
baseTechPath = 'Icons/Technologies/'
|
||||||
|
heightOffset = techButtonSize.y + 10
|
||||||
|
|
||||||
|
gui = {
|
||||||
|
{
|
||||||
|
guiType = GuiType.GUI_RECTANGLE,
|
||||||
|
pos = Pos,
|
||||||
|
size = Size,
|
||||||
|
color = {x = 0, y = 0, z = 0, w = .6}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x - techButtonSize.x), y = Pos.y + margin.top, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "AInc APT",
|
||||||
|
imagePath = baseTechPath .. 'apt.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.APT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + margin.left, y = Pos.y + margin.top + heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "FPT",
|
||||||
|
imagePath = baseTechPath .. 'fpt.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.FPT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + margin.left, y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Cruisers",
|
||||||
|
imagePath = baseTechPath .. 'cruisers.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.CRUISERS,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x - techButtonSize.x), y = Pos.y + margin.top + heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "EFT",
|
||||||
|
imagePath = baseTechPath .. 'ept.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.EFT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x - 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Stealth",
|
||||||
|
imagePath = baseTechPath .. 'stealth.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.ST_SUB,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + .5 * (Size.x + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Robotics",
|
||||||
|
imagePath = baseTechPath .. 'robo.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.ROBO,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x - (margin.right + techButtonSize.x), y = Pos.y + margin.top + heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "PCT",
|
||||||
|
imagePath = baseTechPath .. 'pct.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.PCT,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x - (margin.right + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Carriers",
|
||||||
|
imagePath = baseTechPath .. 'carriers.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.CARRIERS,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pos = {x = Pos.x + Size.x - (margin.right + techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11},
|
||||||
|
size = techButtonSize,
|
||||||
|
name = "Tanks",
|
||||||
|
imagePath = baseTechPath .. 'tanks.jpg',
|
||||||
|
guiType = GuiType.BUTTON,
|
||||||
|
buttonType = ButtonType.RESEARCH,
|
||||||
|
techId = TechId.TANKS,
|
||||||
|
trigger = 82,
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ gui = {
|
|||||||
{
|
{
|
||||||
pos = {x = Pos.x + .5 * (Size.x - techButtonSize.x), y = Pos.y + margin.top, z = .11},
|
pos = {x = Pos.x + .5 * (Size.x - techButtonSize.x), y = Pos.y + margin.top, z = .11},
|
||||||
size = techButtonSize,
|
size = techButtonSize,
|
||||||
name = "APT",
|
name = "ER APT",
|
||||||
imagePath = baseTechPath .. 'apt.jpg',
|
imagePath = baseTechPath .. 'apt.jpg',
|
||||||
guiType = GuiType.BUTTON,
|
guiType = GuiType.BUTTON,
|
||||||
buttonType = ButtonType.RESEARCH,
|
buttonType = ButtonType.RESEARCH,
|
||||||
@@ -31,14 +31,15 @@ ButtonType = {
|
|||||||
SELL_REFINEDS = 27,
|
SELL_REFINEDS = 27,
|
||||||
BUY_RESEARCH = 28,
|
BUY_RESEARCH = 28,
|
||||||
SELL_RESEARCH = 29,
|
SELL_RESEARCH = 29,
|
||||||
ACTIVE_STATE_BACK = 30,
|
ACTIVE_STATE = 30,
|
||||||
PLAYER_TRADE = 31,
|
ACTIVE_STATE_BACK = 31,
|
||||||
TRADING_SCREEN = 32,
|
PLAYER_TRADE = 32,
|
||||||
TRADE_OFFER = 33,
|
TRADING_SCREEN = 33,
|
||||||
RESOURCE_AMMOUNT = 34,
|
TRADE_OFFER = 34,
|
||||||
UNIT_STATE = 35,
|
RESOURCE_AMMOUNT = 35,
|
||||||
ORDER = 36,
|
UNIT_STATE = 36,
|
||||||
MINIMAP = 37,
|
ORDER = 37,
|
||||||
|
MINIMAP = 38,
|
||||||
}
|
}
|
||||||
|
|
||||||
ListboxType = {
|
ListboxType = {
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
res = graphics.resolution
|
|
||||||
Size = {x = 70, y = 70}
|
|
||||||
margin = 10
|
|
||||||
sz = {x = Size.x - margin, y = Size.y - margin}
|
|
||||||
|
|
||||||
gui = {
|
|
||||||
--[[
|
|
||||||
{
|
|
||||||
pos = {x = res.x - Size.x, y = res.y - Size.y},
|
|
||||||
size = sz,
|
|
||||||
name = "Research",
|
|
||||||
guiType = GuiType.BUTTON,
|
|
||||||
buttonType = ButtonType.RESEARCH,
|
|
||||||
techId = TechId.APT,
|
|
||||||
trigger = 82,
|
|
||||||
},
|
|
||||||
]]--
|
|
||||||
{
|
|
||||||
guiType = GuiType.BUTTON,
|
|
||||||
buttonType = ButtonType.ACTIVE_GAME_STATE,
|
|
||||||
name = 'Tech',
|
|
||||||
guiScreen = 'techTree.lua',
|
|
||||||
pos = {x = res.x - 2 * Size.x, y = res.y - Size.y, z = 0},
|
|
||||||
size = sz,
|
|
||||||
trigger = 85
|
|
||||||
},
|
|
||||||
}
|
|
||||||
+5
-2
@@ -16,12 +16,15 @@ namespace battleship{
|
|||||||
using namespace vb01Gui;
|
using namespace vb01Gui;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
BuildButton::BuildButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int uid, int slId) :
|
BuildButton::BuildButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int slId) :
|
||||||
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid), slotId(slId){}
|
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath), slotId(slId){}
|
||||||
|
|
||||||
void BuildButton::onClick(){
|
void BuildButton::onClick(){
|
||||||
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||||
Player *player = activeState->getPlayer();
|
Player *player = activeState->getPlayer();
|
||||||
|
|
||||||
|
sol::state_view SOL_LUA_VIEW = generateView();
|
||||||
|
int unitId = SOL_LUA_VIEW["_mainUnitId"];
|
||||||
Unit* builder = player->getUnitsById(unitId)[0];
|
Unit* builder = player->getUnitsById(unitId)[0];
|
||||||
|
|
||||||
if(builder->getBuildableUnit(slotId).buildable){
|
if(builder->getBuildableUnit(slotId).buildable){
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
namespace battleship{
|
namespace battleship{
|
||||||
class BuildButton : public UnitButton{
|
class BuildButton : public UnitButton{
|
||||||
public:
|
public:
|
||||||
BuildButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int, int);
|
BuildButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int);
|
||||||
void onClick();
|
void onClick();
|
||||||
private:
|
private:
|
||||||
int slotId;
|
int slotId;
|
||||||
|
|||||||
+10
-7
@@ -186,28 +186,31 @@ namespace battleship{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BUILD:
|
case BUILD:
|
||||||
button = new BuildButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["engineerId"], (int)guiTable["slotId"]);
|
button = new BuildButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["slotId"]);
|
||||||
break;
|
break;
|
||||||
case TRAIN:
|
case TRAIN:
|
||||||
button = new TrainButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["factoryId"], (int)guiTable["slotId"]);
|
button = new TrainButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["slotId"]);
|
||||||
break;
|
break;
|
||||||
case STATISTICS:
|
case STATISTICS:
|
||||||
button = new StatsButton(pos, size, name, (int)guiTable["trigger"], imagePath);
|
button = new StatsButton(pos, size, name, (int)guiTable["trigger"], imagePath);
|
||||||
break;
|
break;
|
||||||
case RESEARCH:
|
case RESEARCH:
|
||||||
button = new ResearchButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["LAB"], (int)guiTable["techId"]);
|
button = new ResearchButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["techId"]);
|
||||||
break;
|
break;
|
||||||
case BUY_REFINEDS:
|
case BUY_REFINEDS:
|
||||||
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::BUY_REFINEDS);
|
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::BUY_REFINEDS);
|
||||||
break;
|
break;
|
||||||
case SELL_REFINEDS:
|
case SELL_REFINEDS:
|
||||||
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::SELL_REFINEDS);
|
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::SELL_REFINEDS);
|
||||||
break;
|
break;
|
||||||
case BUY_RESEARCH:
|
case BUY_RESEARCH:
|
||||||
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::BUY_RESEARCH);
|
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::BUY_RESEARCH);
|
||||||
break;
|
break;
|
||||||
case SELL_RESEARCH:
|
case SELL_RESEARCH:
|
||||||
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::SELL_RESEARCH);
|
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::SELL_RESEARCH);
|
||||||
|
break;
|
||||||
|
case ACTIVE_STATE_BUTTON:
|
||||||
|
button = new ActiveStateButton(pos, size, guiTable["guiScreen"], name, fontBasePath + "batang.ttf", (int)guiTable["trigger"], imagePath);
|
||||||
break;
|
break;
|
||||||
case ACTIVE_STATE_BACK:
|
case ACTIVE_STATE_BACK:
|
||||||
button = new ActiveStateBackButton(pos, size, name);
|
button = new ActiveStateBackButton(pos, size, name);
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace battleship{
|
|||||||
SELL_REFINEDS,
|
SELL_REFINEDS,
|
||||||
BUY_RESEARCH,
|
BUY_RESEARCH,
|
||||||
SELL_RESEARCH,
|
SELL_RESEARCH,
|
||||||
|
ACTIVE_STATE_BUTTON,
|
||||||
ACTIVE_STATE_BACK,
|
ACTIVE_STATE_BACK,
|
||||||
PLAYER_TRADE,
|
PLAYER_TRADE,
|
||||||
TRADING_SCREEN,
|
TRADING_SCREEN,
|
||||||
|
|||||||
+4
-4
@@ -19,8 +19,8 @@ namespace battleship{
|
|||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
ResearchButton::ResearchButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int uid, int tid) :
|
ResearchButton::ResearchButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int tid) :
|
||||||
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid), techId(tid){
|
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath), techId(tid){
|
||||||
Root *root = Root::getSingleton();
|
Root *root = Root::getSingleton();
|
||||||
Material *mat = new Material(root->getLibPath() + "gui");
|
Material *mat = new Material(root->getLibPath() + "gui");
|
||||||
mat->addVec4Uniform("diffuseColor", Vector4::VEC_IJKL);
|
mat->addVec4Uniform("diffuseColor", Vector4::VEC_IJKL);
|
||||||
@@ -41,7 +41,7 @@ namespace battleship{
|
|||||||
void ResearchButton::onClick(){
|
void ResearchButton::onClick(){
|
||||||
if(!active) return;
|
if(!active) return;
|
||||||
|
|
||||||
vector<Unit*> labs = getUnits(unitId);
|
vector<Unit*> labs = getUnits();
|
||||||
|
|
||||||
for(Unit *lab : labs)
|
for(Unit *lab : labs)
|
||||||
((ResearchStruct*)lab)->appendToQueue(techId);
|
((ResearchStruct*)lab)->appendToQueue(techId);
|
||||||
@@ -72,7 +72,7 @@ namespace battleship{
|
|||||||
active = true;
|
active = true;
|
||||||
overlay->setVisible(false);
|
overlay->setVisible(false);
|
||||||
|
|
||||||
vector<Unit*> labs = getUnits(unitId);
|
vector<Unit*> labs = getUnits();
|
||||||
|
|
||||||
for(Unit *lab : labs){
|
for(Unit *lab : labs){
|
||||||
vector<int> researchQueue = ((ResearchStruct*)lab)->getQueue();
|
vector<int> researchQueue = ((ResearchStruct*)lab)->getQueue();
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
namespace battleship{
|
namespace battleship{
|
||||||
class ResearchButton : public UnitButton{
|
class ResearchButton : public UnitButton{
|
||||||
public:
|
public:
|
||||||
ResearchButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int, int);
|
ResearchButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int);
|
||||||
~ResearchButton();
|
~ResearchButton();
|
||||||
void onClick();
|
void onClick();
|
||||||
void update();
|
void update();
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@ namespace battleship{
|
|||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
TradeButton::TradeButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int uid, Type t) : UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid), type(t){}
|
TradeButton::TradeButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, Type t) : UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath), type(t){}
|
||||||
|
|
||||||
void TradeButton::onClick(){
|
void TradeButton::onClick(){
|
||||||
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ namespace battleship{
|
|||||||
public:
|
public:
|
||||||
enum class Type{BUY_REFINEDS, SELL_REFINEDS, BUY_RESEARCH, SELL_RESEARCH};
|
enum class Type{BUY_REFINEDS, SELL_REFINEDS, BUY_RESEARCH, SELL_RESEARCH};
|
||||||
|
|
||||||
TradeButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int, Type);
|
TradeButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, Type);
|
||||||
void onClick();
|
void onClick();
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
|
|||||||
+5
-5
@@ -11,14 +11,14 @@ namespace battleship{
|
|||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
TrainButton::TrainButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int uid, int slId) :
|
TrainButton::TrainButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, int slId) :
|
||||||
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath, uid),
|
UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath),
|
||||||
slotId(slId) {}
|
slotId(slId) {}
|
||||||
|
|
||||||
void TrainButton::onClick(){
|
void TrainButton::onClick(){
|
||||||
vector<Unit*> labs = getUnits(unitId);
|
vector<Unit*> factories = getUnits();
|
||||||
|
|
||||||
for(Unit *lab : labs)
|
for(Unit *fac : factories)
|
||||||
((Factory*)lab)->appendToQueue(slotId);
|
((Factory*)fac)->appendToQueue(slotId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
namespace battleship{
|
namespace battleship{
|
||||||
class TrainButton : public UnitButton{
|
class TrainButton : public UnitButton{
|
||||||
public:
|
public:
|
||||||
TrainButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int, int);
|
TrainButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int);
|
||||||
void onClick();
|
void onClick();
|
||||||
private:
|
private:
|
||||||
int slotId;
|
int slotId;
|
||||||
|
|||||||
+8
-4
@@ -4,26 +4,30 @@
|
|||||||
|
|
||||||
#include <stateManager.h>
|
#include <stateManager.h>
|
||||||
|
|
||||||
|
#include <solUtil.h>
|
||||||
|
|
||||||
namespace battleship{
|
namespace battleship{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace vb01;
|
using namespace vb01;
|
||||||
using namespace vb01Gui;
|
using namespace vb01Gui;
|
||||||
using namespace gameBase;
|
using namespace gameBase;
|
||||||
|
|
||||||
UnitButton::UnitButton(Vector3 pos, Vector2 size, string name, string fontPath, int trigger, string imagePath, int uid) : Button(pos, size, name, fontPath, trigger, true, imagePath), unitId(uid){
|
UnitButton::UnitButton(Vector3 pos, Vector2 size, string name, string fontPath, int trigger, string imagePath) : Button(pos, size, name, fontPath, trigger, true, imagePath){
|
||||||
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
StateManager *stateManager = GameManager::getSingleton()->getStateManager();
|
||||||
ActiveGameState *activeState = (ActiveGameState*)stateManager->getAppStateByType((int)AppStateType::ACTIVE_STATE);
|
ActiveGameState *activeState = (ActiveGameState*)stateManager->getAppStateByType((int)AppStateType::ACTIVE_STATE);
|
||||||
|
|
||||||
if(activeState)
|
if(activeState) activeState->addButton(this);
|
||||||
activeState->addButton(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO optimize this code
|
//TODO optimize this code
|
||||||
vector<Unit*> UnitButton::getUnits(int unitId){
|
vector<Unit*> UnitButton::getUnits(){
|
||||||
vector<Unit*> units;
|
vector<Unit*> units;
|
||||||
|
|
||||||
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE));
|
||||||
Player *player = activeState->getPlayer();
|
Player *player = activeState->getPlayer();
|
||||||
|
|
||||||
|
sol::state_view SOL_LUA_VIEW = generateView();
|
||||||
|
int unitId = SOL_LUA_VIEW["_mainUnitId"];
|
||||||
vector<Unit*> selUnits = player->getSelectedUnits(), researchStructs = player->getUnitsById(unitId);
|
vector<Unit*> selUnits = player->getSelectedUnits(), researchStructs = player->getUnitsById(unitId);
|
||||||
|
|
||||||
for(Unit *rs : researchStructs)
|
for(Unit *rs : researchStructs)
|
||||||
|
|||||||
+2
-4
@@ -8,11 +8,9 @@ namespace battleship{
|
|||||||
|
|
||||||
class UnitButton : public vb01Gui::Button{
|
class UnitButton : public vb01Gui::Button{
|
||||||
public:
|
public:
|
||||||
UnitButton(vb01::Vector3, vb01::Vector2, std::string, std::string, int, std::string, int);
|
UnitButton(vb01::Vector3, vb01::Vector2, std::string, std::string, int, std::string);
|
||||||
protected:
|
protected:
|
||||||
int unitId;
|
std::vector<Unit*> getUnits();
|
||||||
|
|
||||||
std::vector<Unit*> getUnits(int);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user