imagePath is now an optional Lua GUI config field

added new Textures folder structure
This commit is contained in:
devZoGok
2024-03-24 17:11:13 +02:00
parent 1bb23231cb
commit e6d6e675ec
40 changed files with 37 additions and 38 deletions
+4 -4
View File
@@ -2,6 +2,7 @@ res = graphics.resolution
Size = {x = 70, y = 70}
sz = 210
s = 90
resIconBasePath = 'Icons/Resources/'
gui = {
{
@@ -45,21 +46,21 @@ gui = {
pos = {x = 0, y = 0},
zIndex = .9,
size = {x = s, y = s},
imagePath = 'Icons/refineds.png',
imagePath = resIconBasePath .. 'refineds.png',
},
{
guiType = GuiType.GUI_RECTANGLE,
pos = {x = 0, y = 100},
zIndex = .9,
size = {x = s, y = s},
imagePath = 'Icons/wealth.png',
imagePath = resIconBasePath .. 'wealth.png',
},
{
guiType = GuiType.GUI_RECTANGLE,
pos = {x = 0, y = 200},
zIndex = .9,
size = {x = s, y = s},
imagePath = 'Icons/research.png',
imagePath = resIconBasePath .. 'research.png',
},
{
guiType = GuiType.TEXT,
@@ -77,7 +78,6 @@ gui = {
guiType = GuiType.BUTTON,
buttonType = ButtonType.PLAYER_TRADE,
name = 'Trade',
imagePath = '',
guiScreen = 'tradingHub.lua',
pos = {x = res.x - Size.x, y = 200},
size = Size,
-6
View File
@@ -7,7 +7,6 @@ gui = {
{
pos = {x = res.x - 3 * Size.x, y = res.y - 3 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUILD,
trigger = 76,
@@ -15,7 +14,6 @@ gui = {
{
pos = {x = res.x - 2 * Size.x, y = res.y - 3 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUILD,
trigger = 78,
@@ -23,7 +21,6 @@ gui = {
{
pos = {x = res.x - 1 * Size.x, y = res.y - 3 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUILD,
trigger = 77,
@@ -31,7 +28,6 @@ gui = {
{
pos = {x = res.x - 3 * Size.x, y = res.y - 2 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUILD,
trigger = 84,
@@ -39,7 +35,6 @@ gui = {
{
pos = {x = res.x - 2 * Size.x, y = res.y - 2 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUILD,
trigger = 68,
@@ -47,7 +42,6 @@ gui = {
{
pos = {x = res.x - 1 * Size.x, y = res.y - 2 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUILD,
trigger = 70,
-1
View File
@@ -7,7 +7,6 @@ gui = {
{
pos = {x = res.x - Size.x + .5 * margin, y = res.y - Size.y + .5 * margin},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.FORT_TRAIN,
trigger = 82
@@ -7,7 +7,6 @@ gui = {
{
pos = {x = res.x + .5 * margin - Size.x, y = res.y - 3 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.LAND_FACTORY_TRAIN,
trigger = 87
@@ -15,7 +14,6 @@ gui = {
{
pos = {x = res.x + .5 * margin - 2 * Size.x, y = res.y - 3 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.LAND_FACTORY_TRAIN,
trigger = 84
@@ -23,7 +21,6 @@ gui = {
{
pos = {x = res.x + .5 * margin - 3 * Size.x, y = res.y - 3 * Size.y},
size = sz,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.LAND_FACTORY_TRAIN,
trigger = 65
@@ -5,7 +5,6 @@ gui = {
{
pos = {x = res.x - Size.x, y = res.y - Size.y},
size = Size,
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.NAVAL_FACTORY_TRAIN,
trigger = 66
@@ -4,21 +4,22 @@ 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",
imagePath = '',
guiType = GuiType.BUTTON,
buttonType = ButtonType.RESEARCH,
techId = TechId.APT,
trigger = 82,
},
]]--
{
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = 'Tech',
imagePath = '',
guiScreen = 'techTree.lua',
pos = {x = res.x - 2 * Size.x, y = res.y - Size.y},
size = sz,
trigger = 85
+9 -1
View File
@@ -17,7 +17,15 @@ gui = {
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = 'Back',
imagePath = '',
guiScreen = 'activeGameState.lua',
pos = {x = Pos.x + Size.x - buttonSize.x - margin.right, y = Pos.y + Size.y - buttonSize.y - margin.bottom},
size = buttonSize,
trigger = 10
},
{
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = 'Back',
guiScreen = 'activeGameState.lua',
pos = {x = Pos.x + Size.x - buttonSize.x - margin.right, y = Pos.y + Size.y - buttonSize.y - margin.bottom},
size = buttonSize,
+2 -3
View File
@@ -6,8 +6,8 @@ textboxSize = {x = 200, y = 25}
margin = {top = 10, left = 10, right = 10, bottom = 10}
height = Pos.y + margin.top + lineId * 30
warIcon = 'Icons/war.png'
allianceIcon = 'Icons/alliance.png'
warIcon = 'Icons/PlayerStates/war.png'
allianceIcon = 'Icons/PlayerStates/alliance.png'
gui = {
{
@@ -43,7 +43,6 @@ gui = {
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = 'Trade',
imagePath = '',
guiScreen = 'tradingScreen.lua',
pos = {x = Pos.x + Size.x - buttonSize.x - margin.right, y = height},
size = buttonSize,
+1 -5
View File
@@ -10,7 +10,7 @@ textboxSize = {x = 200, y = 25}
buttonSize = {x = 100, y = 20}
ResourceTrayGuiId = {ICON = 0, TEXTBOX = 1, INCREMENT = 2, DECREMENT = 3}
IconPath = {WEALTH = 'Icons/wealth.png', RESEARCH = 'Icons/research.png', REFINEDS = 'Icons/refineds.png', TIME = 'Icons/time.png'}
IconPath = {WEALTH = 'Icons/Resources/wealth.png', RESEARCH = 'Icons/Resources/research.png', REFINEDS = 'Icons/Resources/refineds.png', TIME = 'Icons/Resources/time.png'}
function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath)
height = margin.top + lineId * iconSize.y
@@ -39,7 +39,6 @@ function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath)
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = '+',
imagePath = '',
guiScreen = 'tradingScreen.lua',
pos = guiElPos,
size = iconSize,
@@ -52,7 +51,6 @@ function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath)
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = '-',
imagePath = '',
guiScreen = 'tradingScreen.lua',
pos = guiElPos,
size = iconSize,
@@ -122,7 +120,6 @@ gui = {
guiType = GuiType.BUTTON,
buttonType = ButtonType.PLAYER_TRADE,
name = 'Back',
imagePath = '',
guiScreen = 'tradingHub.lua',
pos = {x = Pos.x + Size.x - 2 * buttonSize.x - margin.right, y = Pos.y + Size.y - buttonSize.y - margin.bottom},
size = buttonSize,
@@ -132,7 +129,6 @@ gui = {
guiType = GuiType.BUTTON,
buttonType = ButtonType.ACTIVE_GAME_STATE,
name = 'Offer',
imagePath = '',
guiScreen = 'tradingHub.lua',
pos = {x = Pos.x + Size.x - buttonSize.x - margin.right, y = Pos.y + Size.y - buttonSize.y - margin.bottom},
size = buttonSize,

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

+18 -12
View File
@@ -61,11 +61,17 @@ namespace battleship{
sol::table sizeTable = guiTable["size"];
Vector2 size = Vector2(sizeTable["x"], sizeTable["y"]);
//TODO factor out repetetive optional lua key checks
string nk = "name";
sol::optional<string> nameOpt = guiTable[nk];
string name = (nameOpt != sol::nullopt ? (string)guiTable[nk] : "");
ButtonType type = (ButtonType)guiTable["buttonType"];
string ipk = "imagePath";
sol::optional<string> pathOpt = guiTable[ipk];
string imagePath = (pathOpt != sol::nullopt ? texBasePath + (string)guiTable[ipk] : "");
bool texturingEnabled = (imagePath != "");
Button *button = nullptr;
switch(type){
@@ -176,7 +182,7 @@ namespace battleship{
int unitId = SOL_LUA_STATE["UnitId"]["ENGINEER"];
int strId = SOL_LUA_STATE["units"][unitId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][strId + 1]["name"];
button = new BuildButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], unitId, guiId);
button = new BuildButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, unitId, guiId);
break;
}
case LAND_FACTORY_TRAIN:
@@ -184,7 +190,7 @@ namespace battleship{
int facId = SOL_LUA_STATE["UnitId"]["LAND_FACTORY"];
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], facId, guiId);
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, facId, guiId);
break;
}
case NAVAL_FACTORY_TRAIN:
@@ -192,7 +198,7 @@ namespace battleship{
int facId = SOL_LUA_STATE["UnitId"]["NAVAL_FACTORY"];
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], facId, guiId);
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, facId, guiId);
break;
}
case FORT_TRAIN:
@@ -200,32 +206,32 @@ namespace battleship{
int facId = SOL_LUA_STATE["UnitId"]["FORT"];
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], (string)guiTable["imagePath"], facId, guiId);
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, facId, guiId);
break;
}
case STATISTICS:
button = new StatsButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
button = new StatsButton(pos, size, name, (int)guiTable["trigger"], imagePath);
break;
case RESEARCH:
button = new ResearchButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["LAB"], (int)guiTable["techId"]);
button = new ResearchButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["LAB"], (int)guiTable["techId"]);
break;
case BUY_REFINEDS:
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::BUY_REFINEDS);
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::BUY_REFINEDS);
break;
case SELL_REFINEDS:
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::SELL_REFINEDS);
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::SELL_REFINEDS);
break;
case BUY_RESEARCH:
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], (string)guiTable["imagePath"], (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::BUY_RESEARCH);
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::BUY_RESEARCH);
break;
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);
button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)SOL_LUA_STATE["UnitId"]["TRADE_CENTER"], TradeButton::Type::SELL_RESEARCH);
break;
case ACTIVE_GAME_STATE:
button = new ActiveStateButton(pos, size, (string)guiTable["guiScreen"], name, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
button = new ActiveStateButton(pos, size, (string)guiTable["guiScreen"], name, (int)guiTable["trigger"], imagePath);
break;
case PLAYER_TRADE:
button = new PlayerTradeButton(pos, size, (string)guiTable["guiScreen"], name, (int)guiTable["trigger"], (string)guiTable["imagePath"]);
button = new PlayerTradeButton(pos, size, (string)guiTable["guiScreen"], name, (int)guiTable["trigger"], imagePath);
break;
}