From 6bfa422bd53835a497496467b570d8d4284ae8ea Mon Sep 17 00:00:00 2001 From: devZoGok Date: Wed, 5 Aug 2026 19:07:54 +0300 Subject: [PATCH 01/15] adapted GUI to different resolutions --- Assets/Scripts/Gui/acsTechTree.lua | 2 +- Assets/Scripts/Gui/activeGameState.lua | 22 +++-- Assets/Scripts/Gui/aincTechTree.lua | 2 +- Assets/Scripts/Gui/audioTab.lua | 39 +++++++-- Assets/Scripts/Gui/console.lua | 36 ++++++-- Assets/Scripts/Gui/controlsTab.lua | 33 ++++++-- Assets/Scripts/Gui/defeat.lua | 6 +- Assets/Scripts/Gui/erTechTree.lua | 2 +- Assets/Scripts/Gui/gamePaused.lua | 9 +- Assets/Scripts/Gui/loadMap.lua | 26 ++++-- Assets/Scripts/Gui/loadingScreen.lua | 4 +- Assets/Scripts/Gui/mainMenu.lua | 27 ++++-- Assets/Scripts/Gui/mapEditor.lua | 93 ++++++++++++++++++--- Assets/Scripts/Gui/mapEditorMenu.lua | 18 +++- Assets/Scripts/Gui/mouseTab.lua | 44 ++++++++-- Assets/Scripts/Gui/newMap.lua | 67 +++++++++++---- Assets/Scripts/Gui/options.lua | 31 +++---- Assets/Scripts/Gui/playerSelection.lua | 2 +- Assets/Scripts/Gui/singlePlayerMenu.lua | 19 ++++- Assets/Scripts/Gui/statistics.lua | 53 +++++------- Assets/Scripts/Gui/tradingHub.lua | 46 +++++++++- Assets/Scripts/Gui/tradingPlayerGuiTray.lua | 14 ++-- Assets/Scripts/Gui/tradingScreen.lua | 4 +- Assets/Scripts/Gui/victory.lua | 6 +- Assets/Scripts/Gui/videoTab.lua | 53 ++++++------ mapEditorAppState.cpp | 23 +---- mapEditorAppState.h | 2 - statsButton.cpp | 2 +- 28 files changed, 480 insertions(+), 205 deletions(-) diff --git a/Assets/Scripts/Gui/acsTechTree.lua b/Assets/Scripts/Gui/acsTechTree.lua index 0b97011..70ddd46 100644 --- a/Assets/Scripts/Gui/acsTechTree.lua +++ b/Assets/Scripts/Gui/acsTechTree.lua @@ -84,7 +84,7 @@ gui = { trigger = 82, }, { - pos = {x = Pos.x + Size.x - (margin.right + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11}, + pos = {x = Pos.x + Size.x - (margin.right + 3.5 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11}, size = techButtonSize, name = "Carriers", imagePath = baseTechPath .. 'carriers.jpg', diff --git a/Assets/Scripts/Gui/activeGameState.lua b/Assets/Scripts/Gui/activeGameState.lua index e03ec2c..cda4cd6 100644 --- a/Assets/Scripts/Gui/activeGameState.lua +++ b/Assets/Scripts/Gui/activeGameState.lua @@ -29,7 +29,7 @@ end eyeIcon = 'eye.png' refIcon = 'refineds.png' minimapSize = {x = 200, y = 200} -minimapPos = {x = 0, y = res.y - minimapSize.y, z = .85} +minimapPos = {x = 0, y = res.y - minimapSize.y, z = -.05} resTextScale = {x = .5, y = .5} resIconBasePath = 'Icons/Resources/' @@ -45,7 +45,7 @@ noHackTex = 'noHack.png' gui = { { guiType = GuiType.GUI_RECTANGLE, - pos = {x = minimapPos.x, y = minimapPos.y, z = .8}, + pos = {x = minimapPos.x, y = minimapPos.y, z = -.1}, size = minimapSize, color = {x = .5, y = .5, z = .5, w = .6} }, @@ -61,7 +61,7 @@ gui = { guiType = GuiType.TEXT, name = 'refineds', text = '', - pos = {x = s, y = s, z = 0}, + pos = {x = s, y = s, z = -.2}, scale = resTextScale, font = 'batang.ttf', fontFirstChar = 0, @@ -72,7 +72,7 @@ gui = { guiType = GuiType.TEXT, name = 'wealth', text = '', - pos = {x = s, y = 2 * s, z = 0}, + pos = {x = s, y = 2 * s, z = -.2}, scale = resTextScale, font = 'batang.ttf', fontFirstChar = 0, @@ -83,7 +83,7 @@ gui = { guiType = GuiType.TEXT, name = 'research', text = '', - pos = {x = s, y = 3 * s, z = 0}, + pos = {x = s, y = 3 * s, z = -.2}, scale = resTextScale, font = 'batang.ttf', fontFirstChar = 0, @@ -93,21 +93,21 @@ gui = { { guiType = GuiType.GUI_RECTANGLE, name = 'refineds', - pos = {x = 0, y = 0, z = 0}, + pos = {x = 0, y = 0, z = -.2}, size = {x = s, y = s}, imagePath = resIconBasePath .. 'refineds.png', }, { guiType = GuiType.GUI_RECTANGLE, name = 'wealth', - pos = {x = 0, y = 1 * s, z = 0}, + pos = {x = 0, y = 1 * s, z = -.2}, size = {x = s, y = s}, imagePath = resIconBasePath .. 'wealth.png', }, { guiType = GuiType.GUI_RECTANGLE, name = 'research', - pos = {x = 0, y = 2 * s, z = 0}, + pos = {x = 0, y = 2 * s, z = -.2}, size = {x = s, y = s}, imagePath = resIconBasePath .. 'research.png', }, @@ -116,16 +116,14 @@ gui = { buttonType = ButtonType.PLAYER_TRADE, name = 'Trade', guiScreen = 'tradingHub.lua', - pos = {x = minimapSize.x, y = res.y - minimapSize.y, z = 0}, + pos = {x = minimapSize.x, y = res.y - minimapSize.y, z = -.2}, size = {x = Size.x, y = minimapSize.y - .75 * sz}, trigger = 10 }, { guiType = GuiType.GUI_RECTANGLE, - pos = {x = minimapSize.x, y = res.y - .75 * sz, z = 0}, + pos = {x = minimapSize.x, y = res.y - .75 * sz, z = -.2}, size = {x = res.x - minimapPos.x, y = sz * .75}, color = {x = .6, y = .6, z = .6, w = .4} }, - --[[ - ]]-- } diff --git a/Assets/Scripts/Gui/aincTechTree.lua b/Assets/Scripts/Gui/aincTechTree.lua index 7782408..69a66dd 100644 --- a/Assets/Scripts/Gui/aincTechTree.lua +++ b/Assets/Scripts/Gui/aincTechTree.lua @@ -84,7 +84,7 @@ gui = { trigger = 82, }, { - pos = {x = Pos.x + Size.x - (margin.right + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11}, + pos = {x = Pos.x + Size.x - (margin.right + 3.5 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11}, size = techButtonSize, name = "Carriers", imagePath = baseTechPath .. 'carriers.jpg', diff --git a/Assets/Scripts/Gui/audioTab.lua b/Assets/Scripts/Gui/audioTab.lua index 0419e1b..cc1f051 100644 --- a/Assets/Scripts/Gui/audioTab.lua +++ b/Assets/Scripts/Gui/audioTab.lua @@ -1,37 +1,58 @@ -numGui = 5 gui = { { - pos = {x = 110, y = 90, z = 0}, - size = {x = 100, y = 10}, + guiType = GuiType.TEXT, + name = '', + text = 'Audio', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Volume', + pos = {x = 20, y = 110, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 370, y = 100, z = 0}, + size = {x = 60, y = 30}, guiType = GuiType.TEXTBOX, }, { - pos = {x = 110, y = 40, z = 0}, - size = {x = 100, y = 10}, + pos = {x = 120, y = 100, z = 0}, + size = {x = 200, y = 10}, guiType = GuiType.SLIDER, minValue = 0, maxValue = 100, numDependencies = 1, dependencies = { - {id = 0} + {id = 1} } }, { - pos = {x = 100, y = 400, z = 0}, + pos = {x = 20, y = 400, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Ok', buttonType = ButtonType.OK }, { - pos = {x = 260, y = 400, z = 0}, + pos = {x = 180, y = 400, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Restore defaults', buttonType = ButtonType.DEFAULTS }, { - pos = {x = 420, y = 400, z = 0}, + pos = {x = 340, y = 400, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Back', diff --git a/Assets/Scripts/Gui/console.lua b/Assets/Scripts/Gui/console.lua index 61e3e64..8e00b57 100644 --- a/Assets/Scripts/Gui/console.lua +++ b/Assets/Scripts/Gui/console.lua @@ -1,28 +1,46 @@ -numGui = 3 gui = { { - pos = {x = 100, y = 100, z = 0}, - size = {x = 300, y = 20}, + guiType = GuiType.TEXT, + text = 'Console', + name = '', + pos = {x = 20, y = 40, z = 0}, + scale = 0.5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 40, z = 0}, + size = {x = 600, y = 20}, guiType = GuiType.LISTBOX, listboxType = ListboxType.CONSOLE, numMaxDisplay = 10, closable = false }, { - pos = {x = 100, y = 510, z = 0}, - size = {x = 270, y = 20}, + pos = {x = 20, y = 510, z = 0}, + size = {x = 550, y = 20}, guiType = GuiType.TEXTBOX }, { - pos = {x = 380, y = 510, z = 0}, - size = {x = 20, y = 20}, + pos = {x = 590, y = 510, z = 0}, + size = {x = 30, y = 20}, guiType = GuiType.BUTTON, buttonType = ButtonType.CONSOLE_COMMAND_OK, name = 'OK', numDependencies = 2, dependencies = { - {id = 0}, - {id = 1} + {id = 1}, + {id = 2} } + }, + { + pos = {x = 630, y = 510, z = 0}, + size = {x = 40, y = 20}, + guiType = GuiType.BUTTON, + buttonType = ButtonType.BACK, + screen = 'gamePaused.lua', + name = 'Back' } } diff --git a/Assets/Scripts/Gui/controlsTab.lua b/Assets/Scripts/Gui/controlsTab.lua index 8518863..e639ee9 100644 --- a/Assets/Scripts/Gui/controlsTab.lua +++ b/Assets/Scripts/Gui/controlsTab.lua @@ -1,28 +1,49 @@ -numGui = 4 gui = { { - pos = {x = 110, y = 190, z = 0}, - size = {x = 360, y = 20}, + guiType = GuiType.TEXT, + name = '', + text = 'Controls', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Key bindings', + pos = {x = 20, y = 190, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 200, z = 0}, + size = {x = 470, y = 20}, guiType = GuiType.LISTBOX, listboxType = ListboxType.CONTROLS, numMaxDisplay = 5 }, { - pos = {x = 100, y = 400, z = 0}, + pos = {x = 20, y = 410, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Ok', buttonType = ButtonType.OK }, { - pos = {x = 260, y = 400, z = 0}, + pos = {x = 180, y = 410, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Restore defaults', buttonType = ButtonType.DEFAULTS }, { - pos = {x = 420, y = 400, z = 0}, + pos = {x = 340, y = 410, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Back', diff --git a/Assets/Scripts/Gui/defeat.lua b/Assets/Scripts/Gui/defeat.lua index a73a62c..f0e545d 100644 --- a/Assets/Scripts/Gui/defeat.lua +++ b/Assets/Scripts/Gui/defeat.lua @@ -7,16 +7,16 @@ music = { res = graphics.resolution overlaySize = {x = 600, y = 450} -overlayPos = {x = .5 * (res.x - overlaySize.x), y = 200, z = 0} +overlayPos = {x = .5 * (res.x - overlaySize.x), y = 100, z = .2} buttonSize = {x = 150, y = 40} -buttonInitPos = {x = .5 * (res.x - buttonSize.x), y = 350, z = .1} +buttonInitPos = {x = .5 * (res.x - buttonSize.x), y = 250, z = .3} gui = { { guiType = GuiType.TEXT, text = 'Defeat', name = 'D', - pos = {x = overlayPos.x + 20, y = overlayPos.y + 75, z = .1}, + pos = {x = overlayPos.x + 150, y = overlayPos.y + 75, z = .3}, scale = 1, font = 'batang.ttf', fontFirstChar = 0, diff --git a/Assets/Scripts/Gui/erTechTree.lua b/Assets/Scripts/Gui/erTechTree.lua index 795769f..c9c5373 100644 --- a/Assets/Scripts/Gui/erTechTree.lua +++ b/Assets/Scripts/Gui/erTechTree.lua @@ -84,7 +84,7 @@ gui = { trigger = 82, }, { - pos = {x = Pos.x + Size.x - (margin.right + 3 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11}, + pos = {x = Pos.x + Size.x - (margin.right + 3.5 * techButtonSize.x), y = Pos.y + margin.top + 2 * heightOffset, z = .11}, size = techButtonSize, name = "Carriers", imagePath = baseTechPath .. 'carriers.jpg', diff --git a/Assets/Scripts/Gui/gamePaused.lua b/Assets/Scripts/Gui/gamePaused.lua index f9a4be1..92cedaf 100644 --- a/Assets/Scripts/Gui/gamePaused.lua +++ b/Assets/Scripts/Gui/gamePaused.lua @@ -1,8 +1,13 @@ Size = {x = 150, y = 50} -numGui = 5 gui = { { - pos = {x = 100, y = 100, z = 0}, + guiType = GuiType.GUI_RECTANGLE, + pos = {x = 0, y = 0, z = -.01}, + size = graphics.resolution, + color = {x = 0, y = 0, z = 0, w = .6} + }, + { + pos = {x = 100, y = 100, z = .3}, size = Size, guiType = GuiType.BUTTON, buttonType = ButtonType.RESUME, diff --git a/Assets/Scripts/Gui/loadMap.lua b/Assets/Scripts/Gui/loadMap.lua index 6538fda..1b65fc8 100644 --- a/Assets/Scripts/Gui/loadMap.lua +++ b/Assets/Scripts/Gui/loadMap.lua @@ -1,7 +1,17 @@ -numGui = 3 gui = { { - pos = {x = 110, y = 190, z = 0}, + guiType = GuiType.TEXT, + name = 't0', + text = 'Load map', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 100, z = 0}, size = {x = 360, y = 20}, guiType = GuiType.LISTBOX, addPlayerGui = false, @@ -9,19 +19,17 @@ gui = { numMaxDisplay = 5 }, { - pos = {x = 110, y = 250, z = 0}, - size = {x = 140, y = 40}, + pos = {x = 20, y = 210, z = 0}, + size = {x = 160, y = 40}, guiType = GuiType.BUTTON, name = 'Ok', buttonType = ButtonType.LOAD_MAP_OK, numDependencies = 1, - dependencies = { - {id = 0} - } + dependencies = {{id = 1}} }, { - pos = {x = 420, y = 400, z = 0}, - size = {x = 150, y = 50}, + pos = {x = 220, y = 210, z = 0}, + size = {x = 160, y = 40}, guiType = GuiType.BUTTON, name = 'Back', buttonType = ButtonType.BACK, diff --git a/Assets/Scripts/Gui/loadingScreen.lua b/Assets/Scripts/Gui/loadingScreen.lua index 159a0c6..41e4313 100644 --- a/Assets/Scripts/Gui/loadingScreen.lua +++ b/Assets/Scripts/Gui/loadingScreen.lua @@ -1,5 +1,7 @@ -initPos = {x = 850, y = 100, z = 0} +res = graphics.resolution + Size = {x = 200, y = 20} +initPos = {x = .5 * (res.x - Size.x), y = 100, z = 0} gui = { { diff --git a/Assets/Scripts/Gui/mainMenu.lua b/Assets/Scripts/Gui/mainMenu.lua index 8751fac..f3243f8 100644 --- a/Assets/Scripts/Gui/mainMenu.lua +++ b/Assets/Scripts/Gui/mainMenu.lua @@ -1,6 +1,12 @@ Size = {x = 150, y = 40} +res = graphics.resolution + +res = graphics.resolution +overlaySize = {x = 600, y = 450} +overlayPos = {x = .5 * (res.x - overlaySize.x), y = 100, z = 0} +buttonSize = {x = 150, y = 40} +buttonInitPos = {x = .5 * (res.x - buttonSize.x), y = 250, z = .1} -numGui = 4 music = { loop = true, shuffle = false, @@ -9,28 +15,39 @@ music = { } gui = { { - pos = {x = 110, y = 40, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Planet Fleet', + pos = {x = 20, y = 50, z = 0}, + scale = .75, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 0, y = 0, z = 1, w = 1} + }, + { + pos = {x = 20, y = 100, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Single player', buttonType = ButtonType.SINGLE_PLAYER }, { - pos = {x = 110, y = 90, z = 0}, + pos = {x = 20, y = 160, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Map editor', buttonType = ButtonType.MAP_EDITOR }, { - pos = {x = 110, y = 140, z = 0}, + pos = {x = 20, y = 220, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Options', buttonType = ButtonType.OPTIONS }, { - pos = {x = 110, y = 190, z = 0}, + pos = {x = 20, y = 280, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Exit', diff --git a/Assets/Scripts/Gui/mapEditor.lua b/Assets/Scripts/Gui/mapEditor.lua index 9fb8576..cb5f2dc 100644 --- a/Assets/Scripts/Gui/mapEditor.lua +++ b/Assets/Scripts/Gui/mapEditor.lua @@ -1,47 +1,120 @@ music = {tracks = {}} -numGui = 6 Size = {x = 140, y = 20} -startX = 100 +startX = 20 gui = { { - pos = {x = startX, y = 400, z = 0}, - size = Size, + guiType = GuiType.TEXT, + name = 'radius_', + text = '', + pos = {x = 0, y = 40, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = startX, y = 300, z = 0}, + size = {x = 80, y = 20}, guiType = GuiType.BUTTON, buttonType = ButtonType.EXPORT, name = 'Export' }, { - pos = {x = startX + Size.x + 10, y = 400, z = 0}, + pos = {x = startX + 110, y = 300, z = 0}, + size = {x = 170, y = 20}, + guiType = GuiType.BUTTON, + buttonType = ButtonType.BACK, + screen = 'mapEditorMenu.lua', + name = 'Back to map editor' + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Vehicles', + pos = {x = startX, y = 400, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = startX, y = 400, z = 0}, size = Size, guiType = GuiType.LISTBOX, listboxType = ListboxType.VEHICLES, numMaxDisplay = 5 }, { - pos = {x = startX + 2 * (Size.x + 10), y = 400, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Structures', + pos = {x = startX + 150, y = 400, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = startX + 150, y = 400, z = 0}, size = Size, guiType = GuiType.LISTBOX, listboxType = ListboxType.STRUCTURES, numMaxDisplay = 5 }, { - pos = {x = startX + 3 * (Size.x + 10), y = 400, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Resources', + pos = {x = startX + 2 * (Size.x + 10), y = 400, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = startX + 2 * (Size.x + 10), y = 400, z = 0}, size = Size, guiType = GuiType.LISTBOX, listboxType = ListboxType.RESOURCE_DEPOSITS, numMaxDisplay = 5 }, { - pos = {x = startX + 4 * (Size.x + 10), y = 400, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Skyboxes', + pos = {x = startX + 3 * (Size.x + 10), y = 400, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = startX + 3 * (Size.x + 10), y = 400, z = 0}, size = Size, guiType = GuiType.LISTBOX, listboxType = ListboxType.SKYBOX_TEXTURES, numMaxDisplay = 5 }, { - pos = {x = startX + 5 * (Size.x + 10), y = 400, z = 0}, - size = Size, + guiType = GuiType.TEXT, + name = '', + text = 'Land textures', + pos = {x = startX + 4 * (Size.x + 10), y = 400, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = startX + 4 * (Size.x + 10), y = 400, z = 0}, + size = {x = 170, y = 20}, guiType = GuiType.LISTBOX, listboxType = ListboxType.LAND_TEXTURES, numMaxDisplay = 5 diff --git a/Assets/Scripts/Gui/mapEditorMenu.lua b/Assets/Scripts/Gui/mapEditorMenu.lua index 5bae37a..aab0497 100644 --- a/Assets/Scripts/Gui/mapEditorMenu.lua +++ b/Assets/Scripts/Gui/mapEditorMenu.lua @@ -1,23 +1,33 @@ Size = {x = 150, y = 40} -numGui = 3 gui = { { - pos = {x = 110, y = 40, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Map editor', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 60, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'New map', buttonType = ButtonType.NEW_MAP }, { - pos = {x = 110, y = 90, z = 0}, + pos = {x = 20, y = 110, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Load map', buttonType = ButtonType.LOAD_MAP }, { - pos = {x = 110, y = 140, z = 0}, + pos = {x = 20, y = 160, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Back', diff --git a/Assets/Scripts/Gui/mouseTab.lua b/Assets/Scripts/Gui/mouseTab.lua index e9c34f4..d9c7595 100644 --- a/Assets/Scripts/Gui/mouseTab.lua +++ b/Assets/Scripts/Gui/mouseTab.lua @@ -1,23 +1,55 @@ -numGui = 6 gui = { { - pos = {x = 110, y = 80, z = 0}, - size = {x = 300, y = 10}, + guiType = GuiType.TEXT, + name = '', + text = 'Mouse', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Sensitivity', + pos = {x = 20, y = 110, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 470, y = 100, z = 0}, + size = {x = 60, y = 30}, guiType = GuiType.TEXTBOX }, { - pos = {x = 110, y = 40, z = 0}, + pos = {x = 120, y = 100, z = 0}, size = {x = 300, y = 10}, minValue = 0, maxValue = 2, guiType = GuiType.SLIDER, numDependencies = 1, dependencies = { - {id = 0} + {id = 1} } }, { - pos = {x = 110, y = 110, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Reverse', + pos = {x = 20, y = 150, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 110, y = 135, z = 0}, guiType = GuiType.CHECKBOX }, { diff --git a/Assets/Scripts/Gui/newMap.lua b/Assets/Scripts/Gui/newMap.lua index 2f0fc99..b416359 100644 --- a/Assets/Scripts/Gui/newMap.lua +++ b/Assets/Scripts/Gui/newMap.lua @@ -1,38 +1,77 @@ -Size = {x = 140, y = 40} +Size = {x = 200, y = 40} -numGui = 5 gui = { { - pos = {x = 110, y = 150, z = 0}, + guiType = GuiType.TEXT, + name = 't0', + text = 'New map', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = 't1', + text = 'Map name', + pos = {x = 20, y = 150, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 150, z = 0}, size = Size, guiType = GuiType.TEXTBOX }, { - pos = {x = 110, y = 190, z = 0}, + guiType = GuiType.TEXT, + name = 't2', + text = 'Width', + pos = {x = 20, y = 220, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 220, z = 0}, size = Size, guiType = GuiType.TEXTBOX }, { - pos = {x = 110, y = 220, z = 0}, + guiType = GuiType.TEXT, + name = 't3', + text = 'Height', + pos = {x = 20, y = 290, z = 0}, + scale = .25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 290, z = 0}, size = Size, guiType = GuiType.TEXTBOX }, { - pos = {x = 420, y = 400, z = 0}, - size = {x = 150, y = 50}, + pos = {x = 20, y = 400, z = 0}, + size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Ok', buttonType = ButtonType.NEW_MAP_OK, numDependencies = 3, - dependencies = { - {id = 0}, - {id = 1}, - {id = 2} - } + dependencies = {{id = 2}, {id = 4}, {id = 6}} }, { - pos = {x = 250, y = 400, z = 0}, - size = {x = 150, y = 50}, + pos = {x = 190, y = 400, z = 0}, + size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Back', buttonType = ButtonType.BACK, diff --git a/Assets/Scripts/Gui/options.lua b/Assets/Scripts/Gui/options.lua index d5be514..8276b2c 100644 --- a/Assets/Scripts/Gui/options.lua +++ b/Assets/Scripts/Gui/options.lua @@ -1,44 +1,47 @@ -Size = {x = 150, y = 40} +Size = {x = 120, y = 20} -numGui = 6 gui = { { - pos = {x = 110, y = 40, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Options', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 100, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Controls', buttonType = ButtonType.CONTROLS_TAB }, { - pos = {x = 270, y = 40, z = 0}, + pos = {x = 180, y = 100, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Mouse', buttonType = ButtonType.MOUSE_TAB }, { - pos = {x = 430, y = 40, z = 0}, + pos = {x = 340, y = 100, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Video', buttonType = ButtonType.VIDEO_TAB }, { - pos = {x = 590, y = 40, z = 0}, + pos = {x = 500, y = 100, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Audio', buttonType = ButtonType.AUDIO_TAB }, { - pos = {x = 750, y = 40, z = 0}, - size = Size, - guiType = GuiType.BUTTON, - name = 'Multiplayer', - buttonType = ButtonType.MULTIPLAYER_TAB - }, - { - pos = {x = 910, y = 100, z = 0}, + pos = {x = 20, y = 160, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Back', diff --git a/Assets/Scripts/Gui/playerSelection.lua b/Assets/Scripts/Gui/playerSelection.lua index 4b3ae1b..6230569 100644 --- a/Assets/Scripts/Gui/playerSelection.lua +++ b/Assets/Scripts/Gui/playerSelection.lua @@ -1,4 +1,4 @@ -playerListboxPos = {x = 110, y = 10, z = 0} +playerListboxPos = {x = 20, y = 10, z = 0} Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z} FactionListboxSize = {x = 270, y = 20} Size = {x = 150, y = 20} diff --git a/Assets/Scripts/Gui/singlePlayerMenu.lua b/Assets/Scripts/Gui/singlePlayerMenu.lua index 71fb002..689f489 100644 --- a/Assets/Scripts/Gui/singlePlayerMenu.lua +++ b/Assets/Scripts/Gui/singlePlayerMenu.lua @@ -10,7 +10,18 @@ MAIN_PLAYER_ID = 0 gui = { { - pos = {x = 110, y = 310, z = 0}, + guiType = GuiType.TEXT, + name = '', + text = 'Singleplayer', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 310, z = 0}, size = Size, guiType = GuiType.LISTBOX, addPlayerGui = true, @@ -18,16 +29,16 @@ gui = { numMaxDisplay = 5 }, { - pos = {x = 110, y = 460, z = 0}, + pos = {x = 20, y = 460, z = 0}, size = Size, guiType = GuiType.BUTTON, buttonType = ButtonType.PLAY, name = 'Play', numDependencies = 4, - dependencies = {{id = 0}} + dependencies = {{id = 1}} }, { - pos = {x = 110 + Size.x + 10, y = 460, z = 0}, + pos = {x = 20 + Size.x + 10, y = 460, z = 0}, size = Size, guiType = GuiType.BUTTON, buttonType = ButtonType.BACK, diff --git a/Assets/Scripts/Gui/statistics.lua b/Assets/Scripts/Gui/statistics.lua index 346e552..56913f8 100644 --- a/Assets/Scripts/Gui/statistics.lua +++ b/Assets/Scripts/Gui/statistics.lua @@ -1,6 +1,7 @@ -headerHeight = 150 -statsInitHeight = 120 -statsSpace = 100 +headerHeight = 100 +statsInitLeft = .5 * res.x - 400 +statsInitHeight = 40 +statsSpace = 20 fontName = 'batang.ttf' gui = { @@ -8,8 +9,7 @@ gui = { guiType = GuiType.TEXT, text = 'Statistics', name = 'stat', - pos = {x = 850, y = 100, z = 0}, - zIndex = 0, + pos = {x = .4 * res.x, y = 50, z = 0}, scale = 0.5, font = fontName, fontFirstChar = 0, @@ -20,9 +20,8 @@ gui = { guiType = GuiType.TEXT, text = 'Player', name = 'pl', - pos = {x = 50, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 10, y = headerHeight, z = 0}, + scale = 0.18, font = fontName, fontFirstChar = 0, fontLastChar = 256, @@ -32,9 +31,8 @@ gui = { guiType = GuiType.TEXT, text = 'Vehicles built', name = 'vb', - pos = {x = 150, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 110, y = headerHeight, z = 0}, + scale = 0.18, font = fontName, fontFirstChar = 0, fontLastChar = 256, @@ -44,9 +42,8 @@ gui = { guiType = GuiType.TEXT, text = 'Vehicles destroyed', name = 'vd', - pos = {x = 450, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 220, y = headerHeight, z = 0}, + scale = 0.18, font = fontName, fontFirstChar = 0, fontLastChar = 256, @@ -56,9 +53,8 @@ gui = { guiType = GuiType.TEXT, text = 'Vehicles lost', name = 'vl', - pos = {x = 850, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 370, y = headerHeight, z = 0}, + scale = 0.18, font = fontName, fontFirstChar = 0, fontLastChar = 256, @@ -66,11 +62,10 @@ gui = { }, { guiType = GuiType.TEXT, - text = 'Structures built', + text = 'Structs built', name = 'sb', - pos = {x = 1050, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 480, y = headerHeight, z = 0}, + scale = 0.18, font = fontName, fontFirstChar = 0, fontLastChar = 256, @@ -78,11 +73,10 @@ gui = { }, { guiType = GuiType.TEXT, - text = 'Structures destroyed', + text = 'Structs destroyed', name = 'sd', - pos = {x = 1350, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 580, y = headerHeight, z = 0}, + scale = 0.18, font = fontName, fontFirstChar = 0, fontLastChar = 256, @@ -90,18 +84,17 @@ gui = { }, { guiType = GuiType.TEXT, - text = 'Structures lost', + text = 'Structs lost', name = 'sl', - pos = {x = 1720, y = headerHeight, z = 0}, - zIndex = 0, - scale = 0.3, + pos = {x = statsInitLeft + 720, y = headerHeight, z = 0}, + scale = 0.18, font = 'batang.ttf', fontFirstChar = 0, fontLastChar = 256, color = {x = 1, y = 1, z = 1, w = 1} }, { - pos = {x = 1700, y = 1000, z = 0}, + pos = {x = res.x - Size.x - 10, y = res.y - Size.y - 10, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Back', diff --git a/Assets/Scripts/Gui/tradingHub.lua b/Assets/Scripts/Gui/tradingHub.lua index 552020e..62c0e9c 100644 --- a/Assets/Scripts/Gui/tradingHub.lua +++ b/Assets/Scripts/Gui/tradingHub.lua @@ -1,6 +1,6 @@ res = graphics.resolution -HubSize = {x = res.x * .3, y = res.y * .8} +HubSize = {x = 500, y = res.y * .8} HubPos = {x = .5 * (res.x - HubSize.x), y = 10, z = .1} HubMargin = {top = 10, left = 10, right = 10, bottom = 10} @@ -11,6 +11,50 @@ warIcon = 'Icons/PlayerStates/war.png' allianceIcon = 'Icons/PlayerStates/alliance.png' gui = { + { + guiType = GuiType.TEXT, + text = 'Trading hub', + name = '', + pos = {x = HubPos.x + .25 * HubSize.x, y = HubPos.y + HubMargin.top + 25, z = .11}, + scale = 0.5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + text = 'Name', + name = '', + pos = {x = HubPos.x + HubMargin.left, y = HubPos.y + HubMargin.top + 60, z = .11}, + scale = 0.25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + text = 'Status', + name = '', + pos = {x = HubPos.x + HubMargin.left + 130, y = HubPos.y + HubMargin.top + 60, z = .11}, + scale = 0.25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + text = 'Trade offers', + name = '', + pos = {x = HubPos.x + HubMargin.right + 200, y = HubPos.y + HubMargin.top + 60, z = .11}, + scale = 0.25, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, { guiType = GuiType.GUI_RECTANGLE, pos = HubPos, diff --git a/Assets/Scripts/Gui/tradingPlayerGuiTray.lua b/Assets/Scripts/Gui/tradingPlayerGuiTray.lua index 79098c5..2e126a4 100644 --- a/Assets/Scripts/Gui/tradingPlayerGuiTray.lua +++ b/Assets/Scripts/Gui/tradingPlayerGuiTray.lua @@ -1,17 +1,17 @@ res = graphics.resolution -buttonSize = {x = 100, y = 20} +buttonSize = {x = 60, y = 20} textboxSize = {x = 200, y = 20} -height = HubPos.y + HubMargin.top + lineId * 30 +height = HubPos.y + HubMargin.top + 90 + lineId * 70 gui = { { guiType = GuiType.TEXT, name = 'playerName', text = '', - pos = {x = HubPos.x + HubMargin.left, y = height + 35, z = .11}, - scale = {x = .2, y = .2}, + pos = {x = HubPos.x + HubMargin.left, y = height + 40, z = .11}, + scale = .2, font = 'batang.ttf', fontFirstChar = 0, fontLastChar = 256, @@ -19,8 +19,8 @@ gui = { }, { guiType = GuiType.GUI_RECTANGLE, - pos = {x = HubPos.x + HubMargin.left + 100, y = height, z = .11}, - size = {x = 50, y = 50}, + pos = {x = HubPos.x + HubMargin.left + 130, y = height, z = .11}, + size = {x = 40, y = 40}, imagePath = relationsIcon }, { @@ -35,7 +35,7 @@ gui = { buttonType = ButtonType.TRADING_SCREEN, name = 'Trade', guiScreen = 'tradingScreen.lua', - pos = {x = HubPos.x + HubSize.x - buttonSize.x - HubMargin.right, y = height + 25, z = .11}, + pos = {x = HubPos.x + HubSize.x - HubMargin.right - buttonSize.x, y = height + 25, z = .11}, size = buttonSize, trigger = 10, dependencies = {{id = 2}} diff --git a/Assets/Scripts/Gui/tradingScreen.lua b/Assets/Scripts/Gui/tradingScreen.lua index 2fab363..937e83b 100644 --- a/Assets/Scripts/Gui/tradingScreen.lua +++ b/Assets/Scripts/Gui/tradingScreen.lua @@ -3,7 +3,7 @@ HubMargin.top = 100 resTrayPos = {x = HubPos.x + HubMargin.left, y = HubPos.y + HubMargin.top} iconSize = {x = 25, y = 25} -textboxSize = {x = 200, y = 25} +textboxSize = {x = 150, y = 25} buttonSize = {x = 100, y = 20} @@ -117,7 +117,7 @@ gui = { buttonType = ButtonType.PLAYER_TRADE, name = 'Back', guiScreen = 'tradingHub.lua', - pos = {x = HubPos.x + HubSize.x - 3 * buttonSize.x - HubMargin.right, y = HubPos.y + HubSize.y - buttonSize.y - HubMargin.bottom, z = .2}, + pos = {x = HubPos.x + HubSize.x - 2 * buttonSize.x - 2 * HubMargin.right, y = HubPos.y + HubSize.y - buttonSize.y - HubMargin.bottom, z = .2}, size = buttonSize, trigger = 10 }, diff --git a/Assets/Scripts/Gui/victory.lua b/Assets/Scripts/Gui/victory.lua index 633459d..d969735 100644 --- a/Assets/Scripts/Gui/victory.lua +++ b/Assets/Scripts/Gui/victory.lua @@ -7,16 +7,16 @@ music = { res = graphics.resolution overlaySize = {x = 600, y = 450} -overlayPos = {x = .5 * (res.x - overlaySize.x), y = 200, z = 0} +overlayPos = {x = .5 * (res.x - overlaySize.x), y = 100, z = .2} buttonSize = {x = 150, y = 40} -buttonInitPos = {x = .5 * (res.x - buttonSize.x), y = 350, z = .1} +buttonInitPos = {x = .5 * (res.x - buttonSize.x), y = 250, z = .3} gui = { { guiType = GuiType.TEXT, text = 'VICTORY!!!', name = 'V', - pos = {x = overlayPos.x + 20, y = overlayPos.y + 75, z = .1}, + pos = {x = overlayPos.x + 20, y = overlayPos.y + 75, z = .3}, scale = 1, font = 'batang.ttf', fontFirstChar = 0, diff --git a/Assets/Scripts/Gui/videoTab.lua b/Assets/Scripts/Gui/videoTab.lua index 3ee280e..e0b0193 100644 --- a/Assets/Scripts/Gui/videoTab.lua +++ b/Assets/Scripts/Gui/videoTab.lua @@ -1,8 +1,29 @@ -numGui = 9 gui = { { - pos = {x = 210, y = 190, z = 0}, - size = {x = 360, y = 20}, + guiType = GuiType.TEXT, + name = '', + text = 'Video', + pos = {x = 20, y = 50, z = 0}, + scale = .5, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Resolution', + pos = {x = 20, y = 100, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + pos = {x = 20, y = 100, z = 0}, + size = {x = 120, y = 20}, guiType = GuiType.LISTBOX, listboxType = ListboxType.RESOLUTION, numMaxDisplay = 5, @@ -14,41 +35,21 @@ gui = { } }, { - pos = {x = 110, y = 40, z = 0}, - guiType = GuiType.CHECKBOX - }, - { - pos = {x = 110, y = 70, z = 0}, - guiType = GuiType.CHECKBOX - }, - { - pos = {x = 110, y = 100, z = 0}, - guiType = GuiType.CHECKBOX - }, - { - pos = {x = 110, y = 130, z = 0}, - guiType = GuiType.CHECKBOX - }, - { - pos = {x = 110, y = 160, z = 0}, - guiType = GuiType.CHECKBOX - }, - { - pos = {x = 100, y = 400, z = 0}, + pos = {x = 20, y = 310, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Ok', buttonType = ButtonType.OK }, { - pos = {x = 260, y = 400, z = 0}, + pos = {x = 180, y = 310, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Restore defaults', buttonType = ButtonType.DEFAULTS }, { - pos = {x = 420, y = 400, z = 0}, + pos = {x = 340, y = 310, z = 0}, size = {x = 150, y = 20}, guiType = GuiType.BUTTON, name = 'Back', diff --git a/mapEditorAppState.cpp b/mapEditorAppState.cpp index 8a2f50d..0491e5c 100644 --- a/mapEditorAppState.cpp +++ b/mapEditorAppState.cpp @@ -5,6 +5,7 @@ #include "resourceDeposit.h" #include "gameObjectFactory.h" #include "gameObjectFrameController.h" +#include "concreteGuiManager.h" #include "player.h" #include "game.h" #include "map.h" @@ -624,8 +625,7 @@ namespace battleship{ } void MapEditorAppState::update(){ - radiusText->setText(L"Radius: " + to_wstring(mapEditor->getCircleRadius())); - weightsText->setText(L"Weights generated: " + to_wstring(mapEditor->isWeightsGenerated())); + ConcreteGuiManager::getSingleton()->getText("radius_")->setText(L"Radius: " + to_wstring(mapEditor->getCircleRadius())); CameraController *camCtr = CameraController::getSingleton(); @@ -641,25 +641,6 @@ namespace battleship{ void MapEditorAppState::onAttached(){ AbstractAppState::onAttached(); mapEditor = new MapEditor(mapName, mapSize, newMap); - - Root *root = Root::getSingleton(); - Material *mat = new Material(root->getLibPath() + "text"); - mat->addBoolUniform("texturingEnabled", false); - mat->addVec4Uniform("diffuseColor", Vector4::VEC_IJKL); - - string fontPath = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; - radiusText = new Text(fontPath, L""); - radiusText->setMaterial(mat); - weightsText = new Text(fontPath, L""); - weightsText->setMaterial(mat); - - Node *radiusNode = new Node(Vector3(0, 100, 0)); - radiusNode->addText(radiusText); - root->getGuiNode()->attachChild(radiusNode); - - Node *weightsNode = new Node(Vector3(0, 200, 0)); - weightsNode->addText(weightsText); - root->getGuiNode()->attachChild(weightsNode); } void MapEditorAppState::onDettached(){} diff --git a/mapEditorAppState.h b/mapEditorAppState.h index 64281e0..7b4606a 100644 --- a/mapEditorAppState.h +++ b/mapEditorAppState.h @@ -16,7 +16,6 @@ namespace vb01{ class Texture; } - namespace battleship{ class MapEditor; @@ -90,7 +89,6 @@ namespace battleship{ std::string mapName; vb01::Vector2 mapSize; bool newMap; - vb01::Text *radiusText = nullptr, *weightsText = nullptr; }; } diff --git a/statsButton.cpp b/statsButton.cpp index d542bb9..3495f1f 100644 --- a/statsButton.cpp +++ b/statsButton.cpp @@ -43,11 +43,11 @@ namespace battleship{ categoryMat->addVec4Uniform("diffuseColor", Vector4(plCol.x, plCol.y, plCol.z, 1)); Text *categoryVal = new Text(GameManager::getSingleton()->getPath() + "Fonts/" + fontName, unitDataPairs[i].second); - categoryVal->setScale(category->getScale()); categoryVal->setMaterial(categoryMat); Node *categoryValNode = new Node(category->getNode()->getPosition() + Vector3(0, statsInitHeight + statsSpace * playerId, 0)); categoryValNode->addText(categoryVal); + categoryValNode->setScale(category->getNode()->getScale()); root->getGuiNode()->attachChild(categoryValNode); guiManager->addText(categoryVal); From ef15c0150aa53f33bd7166c7c0effcde4274553c Mon Sep 17 00:00:00 2001 From: jowen005 Date: Thu, 6 Aug 2026 01:40:33 -0400 Subject: [PATCH 02/15] Implement Unit minimaps --- .gitignore | 1 + Assets/Scripts/Core/options.lua | 6 +- CMakeLists.txt | 23 ++++++- activeGameState.cpp | 71 +++++++++++++++++---- activeGameState.h | 9 ++- binds.h | 107 ++++++++++++++++---------------- defConfigs.h | 21 ++++--- player.cpp | 2 + 8 files changed, 161 insertions(+), 79 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..13850f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +\build \ No newline at end of file diff --git a/Assets/Scripts/Core/options.lua b/Assets/Scripts/Core/options.lua index 9218efb..dab8dd6 100644 --- a/Assets/Scripts/Core/options.lua +++ b/Assets/Scripts/Core/options.lua @@ -16,8 +16,9 @@ mappings = { {bind = 12, trigger = 0, action = true, bindType = 1, inOptions = true}, {bind = 13, trigger = 1, action = true, bindType = 1, inOptions = true}, {bind = 14, trigger = 72, action = true, bindType = 0, inOptions = true}, - {bind = 15, trigger = 0, action = true, bindType = 0, inOptions = true}, - {bind = 16, trigger = 0, action = true, bindType = 0, inOptions = true}, + -- The triggers for 15 and 16, zoom in and out used to be 0 but I changed them to +/= and - + {bind = 15, trigger = 61, action = true, bindType = 0, inOptions = true}, + {bind = 16, trigger = 45, action = true, bindType = 0, inOptions = true}, {bind = 17, trigger = 341, action = true, bindType = 0, inOptions = true}, {bind = 18, trigger = 340, action = true, bindType = 0, inOptions = true}, {bind = 19, trigger = 80, action = true, bindType = 0, inOptions = true}, @@ -35,6 +36,7 @@ mappings = { {bind = 31, trigger = 57, action = true, bindType = 0, inOptions = true}, {bind = 32, trigger = 66, action = true, bindType = 0, inOptions = true}, {bind = 33, trigger = 256, action = true, bindType = 0, inOptions = true}, + {bind = 53, trigger = 81, action = true, bindType = 0, inOptions = true}, -- wasn't sure if it should be in options {bind = 47, trigger = 69, action = true, bindType = 0, inOptions = false}, {bind = 48, trigger = 84, action = true, bindType = 0, inOptions = false}, {bind = 49, trigger = 89, action = true, bindType = 0, inOptions = false}, diff --git a/CMakeLists.txt b/CMakeLists.txt index 554c9c1..99e97e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -pedantic") endif() -set(CMAKE_CXX_STANDART 17) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_POLICY_VERSION_MINIMUM 3.5) set(CMAKE_BUILD_TYPE Debug) set(BUILD_TESTS OFF) @@ -50,6 +50,16 @@ set(GAME_BASE_DIR external/gameBase) add_executable(${GAME_NAME} main.cpp ${GAME_SRC}) +# Do this for Windows +if(MSVC) + target_compile_options(${GAME_NAME} PRIVATE + /bigobj + # /utf-8 + # /UUNICODE + # /U_UNICODE + ) +endif() + include_directories(external/tinydir) include_directories(external/vb01/external/glm) include_directories(external/vb01/external/glm/glm) @@ -81,8 +91,17 @@ if(BUILD_TESTS) set(TEST_NAME battleshipTests) add_executable(${TEST_NAME} ${TEST_SRC}) + # Do this for Windows + if(MSVC) + target_compile_options(${TEST_NAME} PRIVATE + /bigobj + # /utf-8 + # /UUNICODE + # /U_UNICODE + ) + endif() target_include_directories(${TEST_NAME} PUBLIC ${VB01_DIR}) target_include_directories(${TEST_NAME} PUBLIC ${VB01_GUI_DIR}) target_include_directories(${TEST_NAME} PUBLIC ${GAME_BASE_DIR}) target_link_libraries(${TEST_NAME} ${DEPS} cppunit) -endif() +endif() \ No newline at end of file diff --git a/activeGameState.cpp b/activeGameState.cpp index db11820..f5375f6 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -583,7 +583,10 @@ namespace battleship{ unitButtons.push_back(guiManager->getButtons()[guiManager->getButtons().size() - (i + 1)]); } + // isPressed is whether the bind is pressed or just something like hovered void ActiveGameState::onAction(int bind, bool isPressed) { + int numEntered; // Used in entering number series to store the latest number entered + if(tradingScreen || !ConcreteGuiManager::getSingleton()->findClickedButtons().empty()) return; GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton(); @@ -803,21 +806,49 @@ namespace battleship{ case Bind::GROUP_7: case Bind::GROUP_8: case Bind::GROUP_9: - if(isPressed){ - int group = bind - Bind::GROUP_0; + // If none of the number keys are pressed then break + if(!isPressed) break; - if(controlPressed) - unitGroups[group] = mainPlayer->getSelectedUnits(); - else{ - if(!shiftPressed) - mainPlayer->selectUnits(unitGroups[group]); - else - for(Unit *u : unitGroups[group]) - mainPlayer->selectUnit(u); - } - } + // Otherwise save the number entered + numEntered = bind - Bind::GROUP_0; - break; + // If this is the first number enetered in this group then set the pendingGroup to 0 + if(pendingGroup == -1) + { + pendingGroup = 0; + } + + // Multiply the current pendingGroup num by 10 to give it another 0's place and add the new number enetered + pendingGroup = pendingGroup * 10 + numEntered; + break; + case Bind::Key_Q: + // qPressed = isPressed; + // If Q is not pressed or the pending group has not been set then break + if(!isPressed || pendingGroup == -1) break; + + if(controlPressed) + { + // Ctrl + group number + Q assigns the current selection of units + unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + } + else + { + // Pressing a number and Q without shifting replaces the unit selection with the unit group for the number pressed + if(!shiftPressed) + { + deselectUnits(); + mainPlayer->selectUnits(unitGroups[pendingGroup]); + } + // If shift is pressed then shift plus a number and Q adds the selection to the current selection + else + { + mainPlayer->selectUnits(unitGroups[pendingGroup]); + unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + } + } + // Reset the pending group + pendingGroup = -1; + break; case Bind::DESELECT_STRUCTURE: forceCursorState = false; buildableStructSelected = false; @@ -861,4 +892,18 @@ namespace battleship{ void ActiveGameState::onRawMouseWheelScroll(bool up){ CameraController::getSingleton()->zoomCamera(up); } + + std::vector& ActiveGameState::getUnitGroup(int i) + { + static std::vector empty; + auto it = unitGroups.find(i); + if(it != unitGroups.end()) + { + return it->second; + } + else + { + return empty; + } + } } diff --git a/activeGameState.h b/activeGameState.h index fef0dcb..a741ff4 100755 --- a/activeGameState.h +++ b/activeGameState.h @@ -7,6 +7,7 @@ #include "unit.h" #include +#include namespace vb01{ class Node; @@ -42,6 +43,7 @@ namespace battleship{ void onAction(int, bool); void onAnalog(int, float); void onRawMouseWheelScroll(bool); + std::vector& getUnitGroup(int i); inline CursorState getCursorState(){return cursorState;} inline void setCursorState(CursorState cs){this->cursorState = cs;} inline void addButton(vb01Gui::Button *b){guiButtons.push_back(b);} @@ -49,7 +51,7 @@ namespace battleship{ inline std::vector getGuiRects(){return guiRects;} inline std::vector getGuiTexts(){return guiTexts;} inline Player* getPlayer(){return mainPlayer;} - inline std::vector& getUnitGroup(int i){return unitGroups[i];} + // inline std::vector& getUnitGroup(int i){return unitGroups[i];} inline void setBuildableStructSelected(bool bss){this->buildableStructSelected = bss;} inline bool isBuildableStructSelected(){return buildableStructSelected;} inline float getDepth(){return depth;} @@ -82,7 +84,9 @@ namespace battleship{ GuiAppState *guiState; GameObject *gameObjHoveredOn = nullptr; vb01::Vector2 clickPoint; - std::vector unitGroups[9], prevSelectedUnits; + // std::vector unitGroups[10], prevSelectedUnits; + std::vector prevSelectedUnits; + std::unordered_map> unitGroups; std::vector targets; vb01::Node *dragboxNode = nullptr; std::vector guiRects; @@ -91,6 +95,7 @@ namespace battleship{ bool isSelectionBox = false; bool shiftPressed = false; bool controlPressed = false; + int pendingGroup = -1; // The group value entered to save and select a group of units. -1 means no units have been selected bool selectMouseClicked = false; bool orderMouseClicked = false; bool buildableStructSelected = false; diff --git a/binds.h b/binds.h index 97498d2..75610d4 100644 --- a/binds.h +++ b/binds.h @@ -3,59 +3,60 @@ namespace battleship{ enum Bind{ - LEFT_CLICK, - SCROLLING_UP, - SCROLLING_DOWN, - LEFT, - RIGHT, - DELETE_CHAR, - TOGGLE_MAIN_MENU, - LOOK_UP, - LOOK_DOWN, - LOOK_LEFT, - LOOK_RIGHT, - LOOK_AROUND, - DRAG_BOX, - ROTATE_OBJ_FRAME, - HALT, - ZOOM_IN, - ZOOM_OUT, - LEFT_CONTROL, - LEFT_SHIFT, - SELECT_PATROL_POINTS, - LAUNCH, - SHIFT_SUB_DEPTH, - GROUP_0, - GROUP_1, - GROUP_2, - GROUP_3, - GROUP_4, - GROUP_5, - GROUP_6, - GROUP_7, - GROUP_8, - GROUP_9, - SELECT_STRUCTURE, - DESELECT_STRUCTURE, - DECREASE_RADIUS, - INCREASE_RADIUS, - PUSH_VERTS_UP, - PUSH_VERTS_DOWN, - MOVE_TERR_OBJ, - SCALE_TERR_OBJ, - STOP_TERR_OBJ, - ENABLE_X_AXIS, - ENABLE_Y_AXIS, - ENABLE_Z_AXIS, - CREATE_WATERBODY, - GENERATE_WEIGHTS, - TOGGLE_CELL_MARKERS, - EJECT_GARRISON, - ENABLE_CHASE_STATE, - ENABLE_STAND_GROUND_STATE, - ENABLE_HOLD_FIRE_STATE, - HACK, - MOVE_CAMERA + LEFT_CLICK, // Bind 0 + SCROLLING_UP, // 1 + SCROLLING_DOWN, // 2 + LEFT, // 3 + RIGHT, // 4 + DELETE_CHAR, // 5 + TOGGLE_MAIN_MENU, // 6 + LOOK_UP, // 7 + LOOK_DOWN, // 8 + LOOK_LEFT, // 9 + LOOK_RIGHT, // 10 + LOOK_AROUND, // 11 + DRAG_BOX, // 12 + ROTATE_OBJ_FRAME, // 13 + HALT, // 14 + ZOOM_IN, // 15 + ZOOM_OUT, // 16 + LEFT_CONTROL, // 17 + LEFT_SHIFT, // 18 + SELECT_PATROL_POINTS, // 19 + LAUNCH, // 20 + SHIFT_SUB_DEPTH, // 21 + GROUP_0, // 22 + GROUP_1, // 23 + GROUP_2, // 24 + GROUP_3, // 25 + GROUP_4, // 26 + GROUP_5, // 27 + GROUP_6, // 28 + GROUP_7, // 29 + GROUP_8, // 30 + GROUP_9, // 31 + SELECT_STRUCTURE, // 32 + DESELECT_STRUCTURE, // 33 + DECREASE_RADIUS, // 34 + INCREASE_RADIUS, // 35 + PUSH_VERTS_UP, // 36 + PUSH_VERTS_DOWN, // 37 + MOVE_TERR_OBJ, // 38 + SCALE_TERR_OBJ, // 39 + STOP_TERR_OBJ, // 40 + ENABLE_X_AXIS, // 41 + ENABLE_Y_AXIS, // 42 + ENABLE_Z_AXIS, // 43 + CREATE_WATERBODY, // 44 + GENERATE_WEIGHTS, // 45 + TOGGLE_CELL_MARKERS, // 46 + EJECT_GARRISON, // 47 + ENABLE_CHASE_STATE, // 48 + ENABLE_STAND_GROUND_STATE, // 49 + ENABLE_HOLD_FIRE_STATE, // 50 + HACK, // 51 + MOVE_CAMERA, // 52 + Key_Q // 53 }; } diff --git a/defConfigs.h b/defConfigs.h index e11c178..fc34a6a 100755 --- a/defConfigs.h +++ b/defConfigs.h @@ -26,9 +26,9 @@ namespace battleship{ const static int numAppStates = 5; const static int numStaticBinds[numAppStates]{6, 0, 5, 19, 0}; - const static int numConfBinds[numAppStates]{0, 1, 27, 0, 0}; + const static int numConfBinds[numAppStates]{0, 1, 24, 0, 0}; const static int maxStaticBinds = 19; - const static int maxConfBinds = 23; + const static int maxConfBinds = 24; const static int numScripts = 5; const static std::string scriptPathBase = "Scripts/"; @@ -56,6 +56,7 @@ namespace battleship{ "Scripts/Trading/traderData.lua" }; + // Binds that remain the same throughout the lifecycle of a scene/GUI const static Bind staticBinds[numAppStates][maxStaticBinds]{ { Bind::LEFT_CLICK, @@ -82,6 +83,7 @@ namespace battleship{ }, {} }; + // Binds that change throughout the lifecycle of a scene/GUI const static Bind confBinds[numAppStates][maxConfBinds]{ {}, { @@ -110,7 +112,8 @@ namespace battleship{ Bind::GROUP_8, Bind::GROUP_9, Bind::SELECT_STRUCTURE, - Bind::DESELECT_STRUCTURE + Bind::DESELECT_STRUCTURE, + Bind::Key_Q }, {}, {} @@ -151,8 +154,10 @@ namespace battleship{ GLFW_KEY_LEFT, GLFW_KEY_RIGHT, GLFW_KEY_H, - 3, - 4, + GLFW_KEY_EQUAL, // Changed zoom in to the plus/equal key + GLFW_KEY_MINUS, // Changed zoom out to the minus key + // 3, + // 4, GLFW_KEY_LEFT_CONTROL, GLFW_KEY_LEFT_SHIFT, GLFW_KEY_P, @@ -169,7 +174,8 @@ namespace battleship{ GLFW_KEY_8, GLFW_KEY_9, GLFW_KEY_B, - GLFW_KEY_ESCAPE + GLFW_KEY_ESCAPE, + GLFW_KEY_Q }, {}, {} @@ -185,7 +191,8 @@ namespace battleship{ const static bool isConfKey[numAppStates][maxConfBinds]{ {}, {1}, - {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + // {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {}, {} }; diff --git a/player.cpp b/player.cpp index cb6c527..b098232 100755 --- a/player.cpp +++ b/player.cpp @@ -186,6 +186,8 @@ namespace battleship{ projectiles.erase(projectiles.begin() + id); } + /// @brief Takes the units in the passed vector and pushes them onto the selectedUnits vector for the player if they a garrisonable and not already selected + /// @param selUnits void Player::selectUnits(vector selUnits){ for(Unit *u : selUnits){ bool garrisonable = (!u->isVehicle() || (u->isVehicle() && !((Vehicle*)u)->getGarrisonable())); From d7b22f8131965b610d04140eb05752e68729f914 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Thu, 6 Aug 2026 10:32:40 +0300 Subject: [PATCH 03/15] Added explanatory texts to the singleplayer screen Difficulties can only be chosen for CPU players Added more colors --- Assets/Scripts/Core/options.lua | 3 + Assets/Scripts/Gui/playerSelection.lua | 133 +++++++++++++++--------- Assets/Scripts/Gui/singlePlayerMenu.lua | 46 +++++++- concreteGuiManager.cpp | 17 ++- gameManager.cpp | 2 + gameManager.h | 2 + playButton.cpp | 35 ++----- singlePlayerButton.cpp | 6 +- 8 files changed, 167 insertions(+), 77 deletions(-) diff --git a/Assets/Scripts/Core/options.lua b/Assets/Scripts/Core/options.lua index 9218efb..37ce21d 100644 --- a/Assets/Scripts/Core/options.lua +++ b/Assets/Scripts/Core/options.lua @@ -70,3 +70,6 @@ audio = { sfxVolume = 100, musicVolume = 100, } +multiplayer = { + name = "Player" +} diff --git a/Assets/Scripts/Gui/playerSelection.lua b/Assets/Scripts/Gui/playerSelection.lua index 6230569..a489448 100644 --- a/Assets/Scripts/Gui/playerSelection.lua +++ b/Assets/Scripts/Gui/playerSelection.lua @@ -1,58 +1,97 @@ -playerListboxPos = {x = 20, y = 10, z = 0} +playerListboxPos = {x = 20, y = 30, z = 0} Pos = {x = playerListboxPos.x, y = playerListboxPos.y, z = playerListboxPos.z} FactionListboxSize = {x = 270, y = 20} Size = {x = 150, y = 20} gap = 10 gapFactor = 3 -function generateFactions(humanPlayer) - factions = {'None', 'Asian Co-Prosperity Sphere', 'America inc.', 'European Republic'} +colors = { + {name = 'White', code = {r = 1, g = 1, b = 1}}, + {name = 'Red', code = {r = 1, g = 0, b = 0}}, + {name = 'Green', code = {r = 0, g = 1, b = 0}}, + {name = 'Blue', code = {r = 0, g = 0, b = 1}}, + {name = 'Yellow', code = {r = 1, g = 1, b = 0}}, + {name = 'Orange', code = {r = 1, g = .5, b = 0}}, + {name = 'Brown', code = {r = .5, g = .25, b = 0}}, + {name = 'Purple', code = {r = .7, g = 0, b = .7}}, + {name = 'Pink', code = {r = 1, g = .25, b = .5}}, +} - if humanPlayer then table.remove(factions, 1) end +function generateColorTable(colors, fieldName) + tbl = {} - return factions + for i = 1, #colors do + table.insert(tbl, colors[i][fieldName]) + end + + return tbl end -factions = generateFactions(lineId == MAIN_PLAYER_ID) -difficulties = {"Easy", "Medium", "Hard"} -colors = {'White', 'Black', 'Red'} -teams = {'0', '1', '2', '3', '4'} +function generateGui(humanPlayer) + factions = {'Random', 'Asian Co-Prosperity Sphere', 'America inc.', 'European Republic'} + difficulties = {'None', "Easy AI", "Medium AI", "Hard AI"} + teams = {'0', '1', '2', '3', '4'} -gui = { - { - pos = {x = Pos.x, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, - size = FactionListboxSize, - guiType = GuiType.LISTBOX, - name = 'factions', - numMaxDisplay = 3, - lines = factions, - listboxType = ListboxType.FACTIONS - }, - { - pos = {x = Pos.x + FactionListboxSize.x + gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, - size = Size, - guiType = GuiType.LISTBOX, - name = 'difficulties', - numMaxDisplay = 3, - lines = difficulties, - listboxType = ListboxType.CPU_DIFFICULTIES - }, - { - pos = {x = Pos.x + FactionListboxSize.x + Size.x + 2 * gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, - size = Size, - guiType = GuiType.LISTBOX, - name = 'colors', - numMaxDisplay = 3, - lines = colors, - listboxType = ListboxType.COLORS - }, - { - pos = {x = Pos.x + FactionListboxSize.x + 2 * Size.x + 3 * gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, - size = Size, - guiType = GuiType.LISTBOX, - name = 'teams', - numMaxDisplay = 3, - lines = teams, - listboxType = ListboxType.TEAMS - }, -} + firstGui = nil + + if humanPlayer then + table.remove(difficulties, 1) + + firstGui = { + guiType = GuiType.TEXT, + name = '_mainPlayer', + text = 'Player', + pos = {x = 20, y = 120, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + } + else + firstGui = { + pos = {x = Pos.x, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, + size = Size, + guiType = GuiType.LISTBOX, + name = 'difficulties', + numMaxDisplay = 3, + lines = difficulties, + listboxType = ListboxType.CPU_DIFFICULTIES + } + end + + local gui = { + firstGui, + { + pos = {x = Pos.x + Size.x + gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, + size = FactionListboxSize, + guiType = GuiType.LISTBOX, + name = 'factions', + numMaxDisplay = 3, + lines = factions, + listboxType = ListboxType.FACTIONS + }, + { + pos = {x = Pos.x + Size.x + FactionListboxSize.x + 2 * gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, + size = Size, + guiType = GuiType.LISTBOX, + name = 'colors', + numMaxDisplay = 3, + lines = generateColorTable(colors, 'name'), + listboxType = ListboxType.COLORS + }, + { + pos = {x = Pos.x + FactionListboxSize.x + 2 * Size.x + 3 * gap, y = Pos.y + (gapFactor * Size.y + gap) * (lineId + 1), z = Pos.z}, + size = {x = 50, y = 20}, + guiType = GuiType.LISTBOX, + name = 'teams', + numMaxDisplay = 3, + lines = teams, + listboxType = ListboxType.TEAMS + }, + } + + return gui +end + +gui = generateGui(lineId == MAIN_PLAYER_ID) diff --git a/Assets/Scripts/Gui/singlePlayerMenu.lua b/Assets/Scripts/Gui/singlePlayerMenu.lua index 689f489..abe579a 100644 --- a/Assets/Scripts/Gui/singlePlayerMenu.lua +++ b/Assets/Scripts/Gui/singlePlayerMenu.lua @@ -20,6 +20,50 @@ gui = { fontLastChar = 256, color = {x = 1, y = 1, z = 1, w = 1} }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Player', + pos = {x = 20, y = 100, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Faction', + pos = {x = 180, y = 100, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Color', + pos = {x = 460, y = 100, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, + { + guiType = GuiType.TEXT, + name = '', + text = 'Team', + pos = {x = 620, y = 100, z = 0}, + scale = .2, + font = 'batang.ttf', + fontFirstChar = 0, + fontLastChar = 256, + color = {x = 1, y = 1, z = 1, w = 1} + }, { pos = {x = 20, y = 310, z = 0}, size = Size, @@ -35,7 +79,7 @@ gui = { buttonType = ButtonType.PLAY, name = 'Play', numDependencies = 4, - dependencies = {{id = 1}} + dependencies = {{id = 5}} }, { pos = {x = 20 + Size.x + 10, y = 460, z = 0}, diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index 76c6939..31be54f 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -372,7 +372,6 @@ namespace battleship{ break; case CPU_DIFFICULTIES: case FACTIONS: - case COLORS: case TEAMS: numLines = lines.size(); closable = true; @@ -380,6 +379,22 @@ namespace battleship{ listbox = new Listbox(pos, size, lines, maxDisplay, fontPath); break; + case COLORS:{ + numLines = lines.size(); + closable = true; + maxDisplay = (numLines > numMaxDisplay ? numMaxDisplay : numLines); + SOL_LUA_STATE.script("colorCodes = generateColorTable(colors, 'code')"); + sol::table colorCodesTbl = SOL_LUA_STATE["colorCodes"]; + + listbox = new Listbox(pos, size, lines, maxDisplay, fontPath); + + for(int i = 0; i < numLines; i++){ + Vector4 col = Vector4(colorCodesTbl[i + 1]["r"], colorCodesTbl[i + 1]["g"], colorCodesTbl[i + 1]["b"], 1); + listbox->getLineText(i)->getMaterial()->setVec4Uniform("diffuseColor", col); + } + + break; + } case CONSOLE:{ for(int i = 0; i < numMaxDisplay; i++) lines.push_back(""); diff --git a/gameManager.cpp b/gameManager.cpp index 297385e..d278fe9 100755 --- a/gameManager.cpp +++ b/gameManager.cpp @@ -265,6 +265,8 @@ namespace battleship{ sol::table resTable = SOL_LUA_STATE["graphics"]["resolution"]; width = resTable["x"]; height = resTable["y"]; + + mainPlayerName = (wstring)SOL_LUA_STATE["multiplayer"]["name"]; } void GameManager::start(string gameDir) { diff --git a/gameManager.h b/gameManager.h index 99e93cb..4526a48 100755 --- a/gameManager.h +++ b/gameManager.h @@ -23,6 +23,7 @@ namespace battleship{ inline int getWidth(){return width;} inline int getHeight(){return height;} inline std::string getPath(){return path;} + inline std::wstring getMainPlayerName(){return mainPlayerName;} inline gameBase::InputManager* getInputManager(){return inputManager;} inline bool isServerSide(){return serverSide;} inline bool isRunning(){return running;} @@ -38,6 +39,7 @@ namespace battleship{ gameBase::InputManager *inputManager = nullptr; int width, height; std::string path = ""; + std::wstring mainPlayerName = L""; bool serverSide, running = false; }; diff --git a/playButton.cpp b/playButton.cpp index 903fc74..1374d72 100644 --- a/playButton.cpp +++ b/playButton.cpp @@ -39,38 +39,19 @@ namespace battleship{ const int MAIN_PLAYER_ID = (int)generateView()["MAIN_PLAYER_ID"]; for(int i = 0; i < numPlayers; i++){ - int faction = factionsListboxes[i]->getSelectedOption(); - bool cpuPlayer; + if(i != MAIN_PLAYER_ID && difficultiesListboxes[i - 1]->getContents()[difficultiesListboxes[i - 1]->getSelectedOption()] == L"None") continue; - if(factionsListboxes[i]->getContents()[faction] == L"None") continue; + wstring factionStr = factionsListboxes[i]->getContents()[factionsListboxes[i]->getSelectedOption()]; + int faction = (factionStr == L"Random" ? rand() % 3 : factionsListboxes[i]->getSelectedOption() - 1); - if(MAIN_PLAYER_ID == i) - cpuPlayer = false; - else{ - faction--; - cpuPlayer = true; - } - - string diffStr = (cpuPlayer ? wstringToString(difficultiesListboxes[i]->getContents()[colorsListboxes[i]->getSelectedOption()]) : ""); - int difficulty = -1; - - if(diffStr == "Easy") difficulty = 0; - else if(diffStr == "Medium") difficulty = 1; - else if(diffStr == "Hard") difficulty = 2; - - string colorStr = wstringToString(colorsListboxes[i]->getContents()[colorsListboxes[i]->getSelectedOption()]); - Vector3 color; - - if(colorStr == "Black") color = Vector3::VEC_ZERO; - else if(colorStr == "Red") color = Vector3::VEC_I; - else if(colorStr == "Green") color = Vector3::VEC_J; - else if(colorStr == "Blue") color = Vector3::VEC_K; - else if(colorStr == "White") color = Vector3::VEC_IJK; + bool cpuPlayer = (MAIN_PLAYER_ID != i); + int difficulty = (cpuPlayer ? difficultiesListboxes[i - 1]->getSelectedOption() : -1); + Vector4 color = ((Material::Vector4Uniform*)colorsListboxes[i]->getLineText(colorsListboxes[i]->getSelectedOption())->getMaterial()->getUniform("diffuseColor"))->value; int team = stoi(teamsListboxes[i]->getContents()[teamsListboxes[i]->getSelectedOption()]); - string name = (cpuPlayer ? "CPU player #" + to_string(i) : "Player"); - game->addPlayer(new Player(difficulty, faction, team, color, cpuPlayer, i, name)); + + game->addPlayer(new Player(difficulty, faction, team, Vector3(color.x, color.y, color.z), cpuPlayer, i, name)); } handleLoadingGui(new LoadingAppState(new InGameAppState(mapName), "inGame.lua")); diff --git a/singlePlayerButton.cpp b/singlePlayerButton.cpp index ef29559..72138f7 100644 --- a/singlePlayerButton.cpp +++ b/singlePlayerButton.cpp @@ -3,6 +3,7 @@ #include "concreteGuiManager.h" #include +#include #include @@ -22,10 +23,13 @@ namespace battleship{ } void SinglePlayerButton::onClick() { - ConcreteGuiManager::getSingleton()->readLuaScreenScript("singlePlayerMenu.lua"); + ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); + guiManager->readLuaScreenScript("singlePlayerMenu.lua"); Listbox *listbox = ConcreteGuiManager::getSingleton()->getListboxes()[0]; listbox->openUp(); listbox->close(); + + guiManager->getText("_mainPlayer")->setText(GameManager::getSingleton()->getMainPlayerName()); } } From 7f0c49ccdf20bb1afc5b7d65374446321f1eea69 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Thu, 6 Aug 2026 10:41:48 +0300 Subject: [PATCH 04/15] updated vb01 --- external/vb01 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/vb01 b/external/vb01 index eb53ad4..fe201de 160000 --- a/external/vb01 +++ b/external/vb01 @@ -1 +1 @@ -Subproject commit eb53ad485d43a872869fcef843782d0518d9d6a0 +Subproject commit fe201de0fa7c3156299aaf05a8abe7420e1bf6f5 From 406bbe613208cbc2be8ca2aa648bb6266911441f Mon Sep 17 00:00:00 2001 From: devZoGok Date: Fri, 7 Aug 2026 10:30:44 +0300 Subject: [PATCH 05/15] tooltips --- concreteGuiManager.cpp | 46 ++++++++++++++++++++++++++- concreteGuiManager.h | 3 ++ singlePlayerButton.cpp | 21 +++++++------ singlePlayerButton.h | 8 +++-- tooltip.cpp | 71 ++++++++++++++++++++++++++++++++++++++++-- tooltip.h | 26 ++++++++++++++-- 6 files changed, 158 insertions(+), 17 deletions(-) diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index 31be54f..f6affcf 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -60,6 +59,42 @@ namespace battleship{ return concreteGuiManager; } + Tooltip* ConcreteGuiManager::parseTooltip(sol::table &tooltipTbl, Vector3 guiPos){ + sol::table offsetTbl = tooltipTbl["offset"], sizeTbl = tooltipTbl["size"]; + Vector3 offset = Vector3(offsetTbl["x"], offsetTbl["y"], .1); + Vector2 size = Vector2(sizeTbl["x"], sizeTbl["y"]); + + sol::table lineDataTbl = tooltipTbl["lines"]; + int numLines = lineDataTbl.size(); + vector lines; + + for(int i = 0; i < numLines; i++){ + vector> iconsData; + sol::optional iconsTblOpt = lineDataTbl[i + 1]["icons"]; + + if(iconsTblOpt != sol::nullopt){ + sol::table iconsTbl = lineDataTbl[i + 1]["icons"]; + int numIcons = iconsTbl.size(); + + for(int j = 0; j < numIcons; j++) + iconsData.push_back(make_pair(iconsTbl[j + 1]["charId"], iconsTbl[j + 1]["path"])); + } + + sol::table entryTbl = lineDataTbl[i + 1]["entry"]; + wstring entry = (wstring)entryTbl["text"]; + Vector4 color = Vector4::VEC_IJKL; + sol::optional colorTblOpt = entryTbl["color"]; + + if(colorTblOpt != sol::nullopt) + color = Vector4(entryTbl["color"]["r"], entryTbl["color"]["g"], entryTbl["color"]["b"], entryTbl["color"]["a"]); + + lines.push_back(Tooltip::LineData(entry, color, iconsData)); + } + + string fontPath = GameManager::getSingleton()->getPath() + "Fonts/batang.ttf"; + return new Tooltip(guiPos + offset, size, lines, fontPath); + } + //TODO refactor player difficulty and faction listbox selection //TODO remove hardcoded font path values //TODO use configurable map path values @@ -91,12 +126,21 @@ namespace battleship{ bool texturingEnabled = true; } + Tooltip *tooltip = nullptr; + sol::optional tooltipTblOpt = guiTable["tooltip"]; + + if(tooltipTblOpt != sol::nullopt){ + sol::table tbl = guiTable["tooltip"]; + tooltip = parseTooltip(tbl, pos); + } + Button *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); diff --git a/concreteGuiManager.h b/concreteGuiManager.h index 06ae6a2..ac23877 100644 --- a/concreteGuiManager.h +++ b/concreteGuiManager.h @@ -2,6 +2,7 @@ #define CONCRETE_GUI_MANAGER_H #include +#include #include #include @@ -71,6 +72,7 @@ namespace battleship{ CONSOLE, TRADE_OFFERS }; + class Tooltip; class ConcreteGuiManager : public vb01Gui::AbstractGuiManager{ public: @@ -99,6 +101,7 @@ namespace battleship{ void parseLuaScript(std::string, std::string = ""); private: ConcreteGuiManager(); + Tooltip* parseTooltip(sol::table&, vb01::Vector3); vb01Gui::Button* parseButton(int); vb01Gui::Listbox* parseGameObjectListbox(); vb01Gui::Listbox* parseListbox(int); diff --git a/singlePlayerButton.cpp b/singlePlayerButton.cpp index 72138f7..11819be 100644 --- a/singlePlayerButton.cpp +++ b/singlePlayerButton.cpp @@ -1,8 +1,11 @@ #include "singlePlayerButton.h" -#include "gameManager.h" #include "concreteGuiManager.h" +#include "gameManager.h" +#include "tooltip.h" #include +#include +#include #include #include @@ -13,14 +16,8 @@ namespace battleship{ 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) {} - - void SinglePlayerButton::onMouseOver(){ - setColor(Vector4(.8, .8, .8, 1)); - } - - void SinglePlayerButton::onMouseOff(){ - setColor(Vector4(.6, .6, .6, 1)); - } + + SinglePlayerButton::~SinglePlayerButton(){delete tooltip;} void SinglePlayerButton::onClick() { ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton(); @@ -32,4 +29,10 @@ 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); + } } diff --git a/singlePlayerButton.h b/singlePlayerButton.h index 09e0224..4a5bf52 100644 --- a/singlePlayerButton.h +++ b/singlePlayerButton.h @@ -6,13 +6,17 @@ #include namespace battleship{ + class Tooltip; + class SinglePlayerButton : public vb01Gui::Button { public: SinglePlayerButton(vb01::Vector3, vb01::Vector2, std::string); + ~SinglePlayerButton(); void onClick(); - void onMouseOver(); - void onMouseOff(); + void update(); + inline void setTooltip(Tooltip *t){this->tooltip = t;} private: + Tooltip *tooltip = nullptr; }; } diff --git a/tooltip.cpp b/tooltip.cpp index a4d2681..838c3bf 100644 --- a/tooltip.cpp +++ b/tooltip.cpp @@ -1,14 +1,81 @@ #include "tooltip.h" +#include "gameManager.h" + +#include +#include +#include +#include +#include +#include using namespace std; using namespace vb01; namespace battleship{ - Tooltip::Tooltip(Vector2 pos, string entry){ - this->pos = pos; + Tooltip::Tooltip(Vector3 p, Vector2 s, vector lineData, string fontPath) : pos(p), size(s){ + Root *root = Root::getSingleton(); + Material *bgMat = new Material(root->getLibPath() + "gui"); + bgMat->addBoolUniform("texturingEnabled", false); + bgMat->addVec4Uniform("diffuseColor", Vector4(.5, .5, .5, .5)); + + background = new Quad(Vector3(s.x, s.y, 0), false); + background->setMaterial(bgMat); + + Node *bgNode = new Node(p); + bgNode->attachMesh(background); + root->getGuiNode()->attachChild(bgNode); + + string basePath = GameManager::getSingleton()->getPath(); + string iconBasePath = basePath + "Textures/Icons/"; + + for(int i = 0; i < lineData.size(); i++){ + LineData &ld = lineData[i]; + + Material *textMat = new Material(root->getLibPath() + "text"); + textMat->addBoolUniform("texturingEnabled", false); + textMat->addVec4Uniform("diffuseColor", ld.textColor); + + float scale = .2; + + Vector3 offset = Vector3(0, 20 * (i + 1), .01); + Text *text = new Text(fontPath, ld.entryText); + text->setMaterial(textMat); + Node *textNode = new Node(pos + offset - Vector3(0, 3, 0), Quaternion::QUAT_W, scale * Vector3::VEC_IJK); + textNode->addText(text); + bgNode->attachChild(textNode); + + for(pair &iconData: ld.iconsData){ + Vector3 iconOffset = offset; + wstring entry = text->getText(); + + for(int j = 0; j < iconData.first; j++){ + Text::Glyph *glyph = text->getGlyph(entry[j]); + iconOffset.x += scale * (glyph->advance >> 6); + } + + entry.insert(iconData.first, L" "); + text->setText(entry); + + Material *iconMat = new Material(root->getLibPath() + "gui"); + iconMat->addBoolUniform("texturingEnabled", true); + string ip[]{iconBasePath + iconData.second}; + Texture *t = new Texture(ip, 1, false); + iconMat->addTexUniform("textures[0]", t, false); + + Vector2 iconSize = 20 * Vector2::VEC_IJ; + Quad *rect = new Quad(Vector3(iconSize.x, iconSize.y, 0), false); + rect->setMaterial(iconMat); + Node *rectNode = new Node(iconOffset - Vector3(0, iconSize.y, 0)); + rectNode->attachMesh(rect); + bgNode->attachChild(rectNode); + } + } } Tooltip::~Tooltip(){ + Node *node = background->getNode(); + Root::getSingleton()->getGuiNode()->dettachChild(node); + delete node; } void Tooltip::update(){ diff --git a/tooltip.h b/tooltip.h index 68b8020..12316e4 100644 --- a/tooltip.h +++ b/tooltip.h @@ -1,16 +1,36 @@ #ifndef TOOLTIP_H #define TOOLTIP_H -#include +#include + +#include +#include +#include + +namespace vb01{ + class Quad; + class Text; +} namespace battleship{ class Tooltip{ public: - Tooltip(vb01::Vector2, std::string); + struct LineData{ + std::wstring entryText; + vb01::Vector4 textColor; + std::vector> iconsData; + + LineData(std::wstring et, vb01::Vector4 tc, std::vector> id) : entryText(et), textColor(tc), iconsData(id){}; + }; + + Tooltip(vb01::Vector3, vb01::Vector2, std::vector, std::string); ~Tooltip(); void update(); + inline vb01::Quad* getBackground(){return background;} private: - vb01::Vector2 pos; + vb01::Vector3 pos; + vb01::Vector2 size; + vb01::Quad *background = nullptr; }; } From 47b156b8d651581331494deeba14af08ee3ad242 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Fri, 7 Aug 2026 11:54:55 +0300 Subject: [PATCH 06/15] common PF button super class --- Assets/Scripts/Gui/mainMenu.lua | 11 ++++++++++- CMakeLists.txt | 2 +- activeStateButton.cpp | 2 +- activeStateButton.h | 4 ++-- backButton.cpp | 2 +- backButton.h | 4 ++-- concreteGuiManager.cpp | 21 +++++++++++++++++++-- defaultsButton.cpp | 2 +- defaultsButton.h | 4 ++-- exitButton.cpp | 2 +- exitButton.h | 5 +++-- exportButton.cpp | 2 +- exportButton.h | 4 ++-- inGameAppState.cpp | 15 ++++++++------- inGameAppState.h | 6 +++--- loadMapButton.cpp | 7 +++++-- loadMapButton.h | 6 +++--- mainMenuButton.cpp | 2 +- mainMenuButton.h | 4 ++-- mapEditorButton.h | 7 +++---- newMapButton.cpp | 13 +++++++------ newMapButton.h | 6 +++--- offerButton.cpp | 2 +- offerButton.h | 4 ++-- okButton.cpp | 2 +- okButton.h | 4 ++-- optionsButton.cpp | 2 +- optionsButton.h | 5 ++--- orderButton.cpp | 2 +- orderButton.h | 4 ++-- pfButtonBase.cpp | 23 +++++++++++++++++++++++ pfButtonBase.h | 25 +++++++++++++++++++++++++ playButton.cpp | 2 +- playButton.h | 4 ++-- resourceAmmountButton.cpp | 4 +++- resourceAmmountButton.h | 4 ++-- singlePlayerButton.cpp | 10 +--------- singlePlayerButton.h | 10 +++------- stateToggleButton.cpp | 2 +- stateToggleButton.h | 4 ++-- statsButton.cpp | 2 +- statsButton.h | 4 ++-- tabButton.cpp | 2 +- tabButton.h | 4 ++-- unitButton.cpp | 2 +- unitButton.h | 4 ++-- 46 files changed, 165 insertions(+), 97 deletions(-) create mode 100644 pfButtonBase.cpp create mode 100644 pfButtonBase.h diff --git a/Assets/Scripts/Gui/mainMenu.lua b/Assets/Scripts/Gui/mainMenu.lua index f3243f8..ba8edbe 100644 --- a/Assets/Scripts/Gui/mainMenu.lua +++ b/Assets/Scripts/Gui/mainMenu.lua @@ -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}, diff --git a/CMakeLists.txt b/CMakeLists.txt index 554c9c1..b12443e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/activeStateButton.cpp b/activeStateButton.cpp index 703b6f7..79c5a3a 100644 --- a/activeStateButton.cpp +++ b/activeStateButton.cpp @@ -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(); diff --git a/activeStateButton.h b/activeStateButton.h index 48a7c14..7433673 100644 --- a/activeStateButton.h +++ b/activeStateButton.h @@ -1,10 +1,10 @@ #ifndef ACTIVE_STATE_BUTTON_H #define ACTIVE_STATE_BUTTON_H -#include +#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(); diff --git a/backButton.cpp b/backButton.cpp index e221666..09cc4f6 100644 --- a/backButton.cpp +++ b/backButton.cpp @@ -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() { diff --git a/backButton.h b/backButton.h index 504eef7..86b3760 100644 --- a/backButton.h +++ b/backButton.h @@ -1,10 +1,10 @@ #ifndef BACK_BUTTON_H #define BACK_BUTTON_H -#include +#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(); diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index f6affcf..4a86acd 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -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 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)); diff --git a/defaultsButton.cpp b/defaultsButton.cpp index 8658e2c..21f91b9 100644 --- a/defaultsButton.cpp +++ b/defaultsButton.cpp @@ -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() {} } diff --git a/defaultsButton.h b/defaultsButton.h index f7ac6dd..4c722ed 100644 --- a/defaultsButton.h +++ b/defaultsButton.h @@ -1,10 +1,10 @@ #ifndef DEFAULTS_BUTTON_H #define DEFAULTS_BUTTON_H -#include +#include "pfButtonBase.h" namespace battleship{ - class DefaultsButton : public vb01Gui::Button{ + class DefaultsButton : public PfButtonBase{ public: DefaultsButton(vb01::Vector3, vb01::Vector2, std::string); void onClick(); diff --git a/exitButton.cpp b/exitButton.cpp index b1b895c..a1684d1 100755 --- a/exitButton.cpp +++ b/exitButton.cpp @@ -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); diff --git a/exitButton.h b/exitButton.h index c845342..54d17f2 100755 --- a/exitButton.h +++ b/exitButton.h @@ -1,11 +1,12 @@ #ifndef EXIT_BUTTON_H #define EXIT_BUTTON_H -#include +#include "pfButtonBase.h" + #include namespace battleship { - class ExitButton : public vb01Gui::Button { + class ExitButton : public PfButtonBase { public: ExitButton(vb01::Vector3, vb01::Vector2); void onClick(); diff --git a/exportButton.cpp b/exportButton.cpp index f38eea6..debb69a 100644 --- a/exportButton.cpp +++ b/exportButton.cpp @@ -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(); diff --git a/exportButton.h b/exportButton.h index 6066051..20db0e1 100644 --- a/exportButton.h +++ b/exportButton.h @@ -1,10 +1,10 @@ #ifndef EXPORT_BUTTON_H #define EXPORT_BUTTON_H -#include +#include "pfButtonBase.h" namespace battleship{ - class ExportButton : public vb01Gui::Button{ + class ExportButton : public PfButtonBase{ public: ExportButton(vb01::Vector3 pos, vb01::Vector2 size); void onClick(); diff --git a/inGameAppState.cpp b/inGameAppState.cpp index 3212658..76a610f 100755 --- a/inGameAppState.cpp +++ b/inGameAppState.cpp @@ -1,6 +1,5 @@ #include -#include #include #include @@ -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())); diff --git a/inGameAppState.h b/inGameAppState.h index 14172d5..04a15fb 100755 --- a/inGameAppState.h +++ b/inGameAppState.h @@ -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(); diff --git a/loadMapButton.cpp b/loadMapButton.cpp index 9d16784..6c5d6de 100644 --- a/loadMapButton.cpp +++ b/loadMapButton.cpp @@ -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"); diff --git a/loadMapButton.h b/loadMapButton.h index 997fea3..3a8f2fa 100644 --- a/loadMapButton.h +++ b/loadMapButton.h @@ -1,16 +1,16 @@ #ifndef LOAD_MAP_BUTTON_H #define LOAD_MAP_BUTTON_H -#include +#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(); diff --git a/mainMenuButton.cpp b/mainMenuButton.cpp index f7516c9..5ec3615 100644 --- a/mainMenuButton.cpp +++ b/mainMenuButton.cpp @@ -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(){ } diff --git a/mainMenuButton.h b/mainMenuButton.h index dff8db3..3ed0aa7 100644 --- a/mainMenuButton.h +++ b/mainMenuButton.h @@ -1,10 +1,10 @@ #ifndef MAIN_MENU_BUTTON_H #define MAIN_MENU_BUTTON_H -#include +#include "pfButtonBase.h" namespace battleship{ - class MainMenuButton : public vb01Gui::Button{ + class MainMenuButton : public PfButtonBase{ public: MainMenuButton(vb01::Vector3, vb01::Vector2, std::string); void onClick(); diff --git a/mapEditorButton.h b/mapEditorButton.h index 5c3be9d..1d63cdd 100644 --- a/mapEditorButton.h +++ b/mapEditorButton.h @@ -1,14 +1,13 @@ #ifndef MAP_EDITOR_BUTTON_H #define MAP_EDITOR_BUTTON_H -#include - +#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: }; diff --git a/newMapButton.cpp b/newMapButton.cpp index f85fee5..754aa0d 100644 --- a/newMapButton.cpp +++ b/newMapButton.cpp @@ -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"); diff --git a/newMapButton.h b/newMapButton.h index fd48fb0..300ff7d 100644 --- a/newMapButton.h +++ b/newMapButton.h @@ -1,16 +1,16 @@ #ifndef NEW_MAP_BUTTON_H #define NEW_MAP_BUTTON_H -#include +#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(); diff --git a/offerButton.cpp b/offerButton.cpp index c9bf9f7..b3f2c81 100644 --- a/offerButton.cpp +++ b/offerButton.cpp @@ -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(){ diff --git a/offerButton.h b/offerButton.h index 6de5592..07b3d08 100644 --- a/offerButton.h +++ b/offerButton.h @@ -1,10 +1,10 @@ #ifndef OFFER_BUTTON_H #define OFFER_BUTTON_H -#include +#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(); diff --git a/okButton.cpp b/okButton.cpp index 91aa580..12bf6af 100644 --- a/okButton.cpp +++ b/okButton.cpp @@ -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() {} } diff --git a/okButton.h b/okButton.h index 9aedbd7..4b130cb 100644 --- a/okButton.h +++ b/okButton.h @@ -1,10 +1,10 @@ #ifndef OK_BUTTON_H #define OK_BUTTON_H -#include +#include "pfButtonBase.h" namespace battleship{ - class OkButton : public vb01Gui::Button{ + class OkButton : public PfButtonBase{ public: OkButton(vb01::Vector3, vb01::Vector2, std::string); void onClick(); diff --git a/optionsButton.cpp b/optionsButton.cpp index d7297c7..151c49b 100755 --- a/optionsButton.cpp +++ b/optionsButton.cpp @@ -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"); diff --git a/optionsButton.h b/optionsButton.h index 98a5681..5415806 100755 --- a/optionsButton.h +++ b/optionsButton.h @@ -1,11 +1,10 @@ -#pragma once #ifndef OPTIONS_BUTTON_H #define OPTIONS_BUTTON_H -#include +#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(); diff --git a/orderButton.cpp b/orderButton.cpp index 0251c06..147e3ba 100644 --- a/orderButton.cpp +++ b/orderButton.cpp @@ -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) {} diff --git a/orderButton.h b/orderButton.h index fa05fc0..015bdcb 100644 --- a/orderButton.h +++ b/orderButton.h @@ -1,10 +1,10 @@ #ifndef ORDER_BUTTON_H #define ORDER_BUTTON_H -#include +#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(); diff --git a/pfButtonBase.cpp b/pfButtonBase.cpp new file mode 100644 index 0000000..d7504a4 --- /dev/null +++ b/pfButtonBase.cpp @@ -0,0 +1,23 @@ +#include "pfButtonBase.h" +#include "tooltip.h" + +#include +#include + +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); + } +} diff --git a/pfButtonBase.h b/pfButtonBase.h new file mode 100644 index 0000000..01a50e9 --- /dev/null +++ b/pfButtonBase.h @@ -0,0 +1,25 @@ +#ifndef PF_BUTTON_BASE_H +#define PF_BUTTON_BASE_H + +#include + +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 diff --git a/playButton.cpp b/playButton.cpp index 1374d72..9dc7070 100644 --- a/playButton.cpp +++ b/playButton.cpp @@ -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(); diff --git a/playButton.h b/playButton.h index d265cdc..5eecd69 100644 --- a/playButton.h +++ b/playButton.h @@ -1,14 +1,14 @@ #ifndef PLAY_BUTTON_H #define PLAY_BUTTON_H -#include +#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(); diff --git a/resourceAmmountButton.cpp b/resourceAmmountButton.cpp index 2d1448f..8af5cf9 100644 --- a/resourceAmmountButton.cpp +++ b/resourceAmmountButton.cpp @@ -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]; diff --git a/resourceAmmountButton.h b/resourceAmmountButton.h index 390dedd..502a88c 100644 --- a/resourceAmmountButton.h +++ b/resourceAmmountButton.h @@ -1,14 +1,14 @@ #ifndef RESOURCE_AMMOUNT_BUTTON_H #define RESOURCE_AMMOUNT_BUTTON_H -#include +#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(); diff --git a/singlePlayerButton.cpp b/singlePlayerButton.cpp index 11819be..0d0cc62 100644 --- a/singlePlayerButton.cpp +++ b/singlePlayerButton.cpp @@ -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); - } } diff --git a/singlePlayerButton.h b/singlePlayerButton.h index 4a5bf52..0fde367 100644 --- a/singlePlayerButton.h +++ b/singlePlayerButton.h @@ -3,20 +3,16 @@ #include -#include +#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; }; } diff --git a/stateToggleButton.cpp b/stateToggleButton.cpp index 52b09af..580c58f 100644 --- a/stateToggleButton.cpp +++ b/stateToggleButton.cpp @@ -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(); } diff --git a/stateToggleButton.h b/stateToggleButton.h index 774e087..a3cf846 100644 --- a/stateToggleButton.h +++ b/stateToggleButton.h @@ -1,10 +1,10 @@ #ifndef STATE_TOGGLE_BUTTON_H #define STATE_TOGGLE_BUTTON_H -#include +#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(); diff --git a/statsButton.cpp b/statsButton.cpp index 3495f1f..f1aa455 100644 --- a/statsButton.cpp +++ b/statsButton.cpp @@ -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; diff --git a/statsButton.h b/statsButton.h index 57e73cf..f593319 100644 --- a/statsButton.h +++ b/statsButton.h @@ -1,10 +1,10 @@ #ifndef STATS_BUTTON_H #define STATS_BUTTON_H -#include +#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(); diff --git a/tabButton.cpp b/tabButton.cpp index 64cf1cd..52f75a6 100644 --- a/tabButton.cpp +++ b/tabButton.cpp @@ -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; } diff --git a/tabButton.h b/tabButton.h index 5d91331..8a5f9e2 100644 --- a/tabButton.h +++ b/tabButton.h @@ -1,10 +1,10 @@ #ifndef TAB_BUTTON_H #define TAB_BUTTON_H -#include +#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(); diff --git a/unitButton.cpp b/unitButton.cpp index 8b0c3f3..ad87bee 100644 --- a/unitButton.cpp +++ b/unitButton.cpp @@ -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); diff --git a/unitButton.h b/unitButton.h index 86944ad..799026a 100644 --- a/unitButton.h +++ b/unitButton.h @@ -1,12 +1,12 @@ #ifndef UNIT_BUTTON_H #define UNIT_BUTTON_H -#include +#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: From 3dc145a21010f67fc59f6abd3a7bda5b2d0da8b3 Mon Sep 17 00:00:00 2001 From: jowen005 Date: Sat, 8 Aug 2026 00:15:06 -0400 Subject: [PATCH 07/15] Set max unit groups and fixed unit destruction bug --- activeGameState.cpp | 48 +++++++++++++++++++++++++++++++++++++++------ activeGameState.h | 2 ++ unit.cpp | 20 +++++++++++++++++++ unit.h | 1 + 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/activeGameState.cpp b/activeGameState.cpp index f5375f6..3e90132 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -829,21 +829,57 @@ namespace battleship{ if(controlPressed) { // Ctrl + group number + Q assigns the current selection of units - unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + + // If there are currently maximum allowed units in existence then do not allow creation of a new unique group, only allow overwritting an existing group + if(static_cast(unitGroups.size()) >= maxUnitGroups) + { + // See if pendingGroup is equal to any key and overwrite the key if so + auto it = unitGroups.find(pendingGroup); + if(it != unitGroups.end()) + { + unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + } + // Iterate through all the keys to see if pendingGroup is equal to any key and overwrite the key if so + // for(const auto& [key, value]: unitGroups) + // { + // if(key == pendingGroup) + // { + // unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + // } + // } + // If it can't overwrite then the pendingGroup will just be reset since this will bypass the rest of the if statements + } + else + { + unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + } + } else { // Pressing a number and Q without shifting replaces the unit selection with the unit group for the number pressed if(!shiftPressed) { - deselectUnits(); - mainPlayer->selectUnits(unitGroups[pendingGroup]); + auto it = unitGroups.find(pendingGroup); + if(it != unitGroups.end()) + { + deselectUnits(); + mainPlayer->selectUnits(it->second); + } + // deselectUnits(); + // mainPlayer->selectUnits(unitGroups[pendingGroup]); } - // If shift is pressed then shift plus a number and Q adds the selection to the current selection + // If shift is pressed then shift plus a number and Q adds the selection to the current group of the existing key else { - mainPlayer->selectUnits(unitGroups[pendingGroup]); - unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + auto it = unitGroups.find(pendingGroup); + if(it != unitGroups.end()) + { + mainPlayer->selectUnits(it->second); + unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + } + // mainPlayer->selectUnits(unitGroups[pendingGroup]); + // unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); } } // Reset the pending group diff --git a/activeGameState.h b/activeGameState.h index a741ff4..fa6923d 100755 --- a/activeGameState.h +++ b/activeGameState.h @@ -51,6 +51,7 @@ namespace battleship{ inline std::vector getGuiRects(){return guiRects;} inline std::vector getGuiTexts(){return guiTexts;} inline Player* getPlayer(){return mainPlayer;} + inline std::unordered_map>& getUnitGroups(){return unitGroups;} // Returns the unitGroups by reference // inline std::vector& getUnitGroup(int i){return unitGroups[i];} inline void setBuildableStructSelected(bool bss){this->buildableStructSelected = bss;} inline bool isBuildableStructSelected(){return buildableStructSelected;} @@ -96,6 +97,7 @@ namespace battleship{ bool shiftPressed = false; bool controlPressed = false; int pendingGroup = -1; // The group value entered to save and select a group of units. -1 means no units have been selected + int maxUnitGroups = 100; // There can be a max of 100 unit groups at a time bool selectMouseClicked = false; bool orderMouseClicked = false; bool buildableStructSelected = false; diff --git a/unit.cpp b/unit.cpp index 70e4537..ca4ea34 100755 --- a/unit.cpp +++ b/unit.cpp @@ -12,6 +12,8 @@ #include #include +#include + #include "unit.h" #include "weapon.h" #include "util.h" @@ -64,6 +66,7 @@ namespace battleship{ destroySound(); destroyHitbox(); destroyModel(); + removeFromUnitGroup(); } void Unit::initProperties(){ @@ -172,6 +175,23 @@ namespace battleship{ losLightNode = nullptr; } + /// @brief Check if unit is in a unit group and if so remove it + void Unit::removeFromUnitGroup(){ + ActiveGameState *activeState = (ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE); + std::unordered_map>& unitGroups = activeState->getUnitGroups(); + + // Iterate through all the individual unit groups and see if this unit is in any of them + for(auto& [key, value]: unitGroups) + { + if(std::find(value.begin(), value.end(), this) != value.end()) + { + //std::erase(value, this); + value.erase(std::remove(value.begin(), value.end(), this), value.end()); + } + } + + } + int Unit::getNumFreeGarrisonSlots(){ int numFreeSlots = 0; diff --git a/unit.h b/unit.h index 0bcf425..54bd923 100755 --- a/unit.h +++ b/unit.h @@ -112,6 +112,7 @@ namespace battleship{ bool canGarrison(Vehicle*); void initLosLight(); void destroyLosLight(); + void removeFromUnitGroup(); int getNumFreeGarrisonSlots(); inline void setState(State s){state = s;} inline State getState(){return state;} From 38d1bba585d6165a3cb7c000fe0701be23ff37a7 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sat, 8 Aug 2026 16:46:12 +0300 Subject: [PATCH 08/15] Added in-game tooltips More tooltip parameters --- Assets/Scripts/GameObjects/Units/unitData.lua | 419 ++++++++++++++++-- Assets/Scripts/Gui/activeGameState.lua | 9 +- Assets/Scripts/Gui/mainMenu.lua | 36 +- Assets/Scripts/Gui/tradingScreen.lua | 25 +- Assets/Scripts/Gui/unitGui.lua | 89 +++- Assets/Textures/Icons/Resources/time.png | Bin 2883 -> 2991 bytes Assets/Textures/Icons/Resources/time.svg | 23 +- concreteGuiManager.cpp | 28 +- pfButtonBase.h | 2 +- tooltip.cpp | 12 +- tooltip.h | 14 +- tradeButton.cpp | 37 +- tradeButton.h | 7 +- trader.cpp | 15 +- trader.h | 1 + 15 files changed, 626 insertions(+), 91 deletions(-) diff --git a/Assets/Scripts/GameObjects/Units/unitData.lua b/Assets/Scripts/GameObjects/Units/unitData.lua index d9a8972..c3058ea 100644 --- a/Assets/Scripts/GameObjects/Units/unitData.lua +++ b/Assets/Scripts/GameObjects/Units/unitData.lua @@ -186,6 +186,7 @@ units = { hitboxOffset = {x = 0, y = 4.5, z = 0}, lineOfSight = 25, name = 'Mech', + description = '', basePath = PATH .. vehiclePrefix .. 'Mechs/', meshPath = 'acsMech.xml', albedoPath = 'mech.jpg', @@ -261,6 +262,7 @@ units = { hitboxOffset = {x = 0, y = 3.02, z = .16}, lineOfSight = 25, name = 'Mech', + description = '', basePath = PATH .. vehiclePrefix .. 'Mechs/', meshPath = 'aincMech.xml', albedoPath = 'mech.jpg', @@ -336,6 +338,7 @@ units = { hitboxOffset = {x = 0, y = 4.27, z = .13}, lineOfSight = 25, name = 'Mech', + description = '', basePath = PATH .. vehiclePrefix .. 'Mechs/', meshPath = 'erMech.xml', albedoPath = 'mech.jpg', @@ -394,6 +397,7 @@ units = { hitboxOffset = {x = 0, y = 5.46, z = .86}, lineOfSight = 75, name = 'Tank', + description = '', basePath = PATH .. vehiclePrefix .. 'Tanks/', meshPath = 'acsTank.xml', albedoPath = 'tank.jpg', @@ -452,6 +456,7 @@ units = { hitboxOffset = {x = 0, y = 3.31, z = 0}, lineOfSight = 75, name = 'Tank', + description = '', basePath = PATH .. vehiclePrefix .. 'Tanks/', meshPath = 'aincTank.xml', albedoPath = 'tank.jpg', @@ -513,6 +518,7 @@ units = { hitboxOffset = {x = 0, y = 5.27, z = .26}, lineOfSight = 75, name = 'Tank', + description = '', basePath = PATH .. vehiclePrefix .. 'Tanks/', meshPath = 'erTank.xml', albedoPath = 'tank.jpg', @@ -572,6 +578,7 @@ units = { hitboxOffset = {x = 0, y = 7.69, z = .71}, lineOfSight = 90, name = 'Artillery', + description = '', basePath = PATH .. vehiclePrefix .. 'Artillery/', meshPath = 'acsArtillery.xml', albedoPath = 'artillery.jpg', @@ -630,6 +637,7 @@ units = { hitboxOffset = {x = 0, y = 7, z = 1.3}, lineOfSight = 90, name = 'Artillery', + description = '', basePath = PATH .. vehiclePrefix .. 'Artillery/', meshPath = 'aincArtillery.xml', albedoPath = 'artillery.jpg', @@ -689,6 +697,7 @@ units = { hitboxOffset = {x = 0, y = 1, z = 0}, lineOfSight = 30, name = 'Artillery', + description = '', basePath = PATH .. vehiclePrefix .. 'Artillery/', meshPath = 'artillery.xml', albedoPath = 'artillery.jpg', @@ -725,6 +734,7 @@ units = { hitboxOffset = {x = 0, y = 1.21, z = 0}, lineOfSight = 200, name = 'Engineer', + description = '', basePath = PATH .. vehiclePrefix .. 'Engineers/', albedoPath = 'engineer.jpg', colorNodes = {'Cube'}, @@ -755,7 +765,20 @@ units = { {id = UnitId.POINT_DEFENSE, iconPath = 'Icons/Buttons/GameObjects/pointDefense.png', buildable = true, trigger = 80}, {id = UnitId.EXTRACTOR, iconPath = 'Icons/Buttons/GameObjects/extractor.png', buildable = true, trigger = 69}, }, - abilityButtons = {{buttonType = ButtonType.ORDER, name = 'Hack', orderType = OrderType.HACK}}, + abilityButtons = { + { + buttonType = ButtonType.ORDER, + name = 'Hack', + orderType = OrderType.HACK, + tooltip = { + size = {x = 200, y = 40}, + lines = { + {entry = {text = 'Eject'}}, + {entry = {text = 'Eject all garrisoned units'}}, + } + } + } + }, unitClass = UnitClass.CYBORG_ENGINEER, unitType = UnitType.LAND, armor = {ArmorType.MECHANIC}, @@ -770,6 +793,7 @@ units = { hitboxOffset = {x = .178, y = 3.27, z = 0}, lineOfSight = 150, name = 'Engineer', + description = '', basePath = PATH .. vehiclePrefix .. 'Engineers/', albedoPath = 'engineer.jpg', colorNodes = {'Engineer_Asia.001'}, @@ -806,6 +830,7 @@ units = { hitboxOffset = {x = 0, y = 1.02, z = .19}, lineOfSight = 200, name = 'Engineer', + description = '', basePath = PATH .. vehiclePrefix .. 'Engineers/', albedoPath = 'engineer.jpg', colorNodes = {'EngineerAM.001'}, @@ -836,7 +861,20 @@ units = { {id = UnitId.POINT_DEFENSE, iconPath = 'Icons/Buttons/GameObjects/pointDefense.png', buildable = true, trigger = 80}, {id = UnitId.EXTRACTOR, iconPath = 'Icons/Buttons/GameObjects/extractor.png', buildable = true, trigger = 69}, }, - abilityButtons = {{buttonType = ButtonType.ORDER, name = 'Hack', orderType = OrderType.HACK}}, + abilityButtons = { + { + buttonType = ButtonType.ORDER, + name = 'Hack', + orderType = OrderType.HACK, + tooltip = { + size = {x = 200, y = 40}, + lines = { + {entry = {text = 'Eject'}}, + {entry = {text = 'Eject all garrisoned units'}}, + } + } + } + }, unitClass = UnitClass.CYBORG_ENGINEER, unitType = UnitType.LAND, armor = {ArmorType.MECHANIC}, @@ -851,6 +889,7 @@ units = { hitboxOffset = {x = 0, y = 2.83, z = .4}, lineOfSight = 150, name = 'Engineer', + description = '', basePath = PATH .. vehiclePrefix .. 'Engineers/', albedoPath = 'engineer.jpg', colorNodes = {'Cube.001'}, @@ -887,6 +926,7 @@ units = { hitboxOffset = {x = 0, y = 1.41, z = 1}, lineOfSight = 200, name = 'Engineer', + description = '', basePath = PATH .. vehiclePrefix .. 'Engineers/', albedoPath = 'engineer.jpg', colorNodes = {'Cube.001'}, @@ -917,7 +957,20 @@ units = { {id = UnitId.POINT_DEFENSE, iconPath = 'Icons/Buttons/GameObjects/pointDefense.png', buildable = true, trigger = 80}, {id = UnitId.EXTRACTOR, iconPath = 'Icons/Buttons/GameObjects/extractor.png', buildable = true, trigger = 69}, }, - abilityButtons = {{buttonType = ButtonType.ORDER, name = 'Hack', orderType = OrderType.HACK}}, + abilityButtons = { + { + buttonType = ButtonType.ORDER, + name = 'Hack', + orderType = OrderType.HACK, + tooltip = { + size = {x = 200, y = 40}, + lines = { + {entry = {text = 'Eject'}}, + {entry = {text = 'Eject all garrisoned units'}}, + } + } + } + }, unitClass = UnitClass.CYBORG_ENGINEER, unitType = UnitType.LAND, armor = {ArmorType.MECHANIC}, @@ -932,6 +985,7 @@ units = { hitboxOffset = {x = 0, y = 2.9, z = .55}, lineOfSight = 150, name = 'Engineer', + description = '', basePath = PATH .. vehiclePrefix .. 'Engineers/', albedoPath = 'engineer.jpg', colorNodes = {'Rig.001'}, @@ -1024,6 +1078,7 @@ units = { lineOfSight = 5, colorNodes = {'Cube.002'}, name = 'Transport', + description = '', basePath = PATH .. vehiclePrefix .. 'Transports/', meshPath = 'acsTransport.xml', albedoPath = 'transport.jpg', @@ -1103,6 +1158,7 @@ units = { lineOfSight = 5, colorNodes = {'turret'}, name = 'Transport', + description = '', basePath = PATH .. vehiclePrefix .. 'Transports/', meshPath = 'aincTransport.xml', albedoPath = 'transport.jpg', @@ -1196,9 +1252,51 @@ units = { { weapons = {}, abilityButtons = { - {buttonType = ButtonType.ORDER, name = 'Supply', orderType = OrderType.SUPPLY}, - {buttonType = ButtonType.ORDER, name = 'Load', orderType = OrderType.LOAD}, - {buttonType = ButtonType.ORDER, name = 'Unload', orderType = OrderType.UNLOAD}, + { + buttonType = ButtonType.ORDER, + name = 'Supply', + orderType = OrderType.SUPPLY, + tooltip = { + size = {x = 210, y = 60}, + lines = { + {entry = {text = 'Supply'}}, + {entry = {text = 'Begin collecting refineds'}}, + {entry = {text = 'from an extractor'}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + name = 'Load', + orderType = OrderType.LOAD, + tooltip = { + size = {x = 290, y = 120}, + lines = { + {entry = {text = 'Load'}}, + {entry = {text = 'Load the cargo ship with the'}}, + {entry = {text = 'corresponding resource. Can load:'}}, + {entry = {text = 'from refineries'}, icons = {{charId = 0, path = 'Resources/refineds.png'}}}, + {entry = {text = 'from trade centers'}, icons = {{charId = 0, path = 'Resources/wealth.png'}}}, + {entry = {text = 'from labs'}, icons = {{charId = 0, path = 'Resources/research.png'}}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + name = 'Unload', + orderType = OrderType.UNLOAD, + tooltip = { + size = {x = 320, y = 120}, + lines = { + {entry = {text = 'Unload'}}, + {entry = {text = 'Unload the cargo ship with the'}}, + {entry = {text = 'corresponding resource. Can unload:'}}, + {entry = {text = 'to refineries'}, icons = {{charId = 0, path = 'Resources/refineds.png'}}}, + {entry = {text = 'to trade centers'}, icons = {{charId = 0, path = 'Resources/wealth.png'}}}, + {entry = {text = 'to labs'}, icons = {{charId = 0, path = 'Resources/research.png'}}}, + } + } + } }, unitClass = UnitClass.RESOURCE_ROVER, unitType = UnitType.HOVER, @@ -1216,6 +1314,7 @@ units = { hitboxOffset = {x = 0, y = 2.65, z = 0}, lineOfSight = 5, name = 'Cargo ship', + description = '', colorNodes = {'Cargo'}, basePath = PATH .. vehiclePrefix .. 'Cargoships/', meshPath = 'acsCargoShip.xml', @@ -1231,9 +1330,51 @@ units = { { weapons = {}, abilityButtons = { - {buttonType = ButtonType.ORDER, name = 'Supply', orderType = OrderType.SUPPLY}, - {buttonType = ButtonType.ORDER, name = 'Load', orderType = OrderType.LOAD}, - {buttonType = ButtonType.ORDER, name = 'Unload', orderType = OrderType.UNLOAD}, + { + buttonType = ButtonType.ORDER, + name = 'Supply', + orderType = OrderType.SUPPLY, + tooltip = { + size = {x = 210, y = 60}, + lines = { + {entry = {text = 'Supply'}}, + {entry = {text = 'Begin collecting refineds'}}, + {entry = {text = 'from an extractor'}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + name = 'Load', + orderType = OrderType.LOAD, + tooltip = { + size = {x = 290, y = 120}, + lines = { + {entry = {text = 'Load'}}, + {entry = {text = 'Load the cargo ship with the'}}, + {entry = {text = 'corresponding resource. Can load:'}}, + {entry = {text = 'from refineries'}, icons = {{charId = 0, path = 'Resources/refineds.png'}}}, + {entry = {text = 'from trade centers'}, icons = {{charId = 0, path = 'Resources/wealth.png'}}}, + {entry = {text = 'from labs'}, icons = {{charId = 0, path = 'Resources/research.png'}}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + name = 'Unload', + orderType = OrderType.UNLOAD, + tooltip = { + size = {x = 320, y = 120}, + lines = { + {entry = {text = 'Unload'}}, + {entry = {text = 'Unload the cargo ship with the'}}, + {entry = {text = 'corresponding resource. Can unload:'}}, + {entry = {text = 'to refineries'}, icons = {{charId = 0, path = 'Resources/refineds.png'}}}, + {entry = {text = 'to trade centers'}, icons = {{charId = 0, path = 'Resources/wealth.png'}}}, + {entry = {text = 'to labs'}, icons = {{charId = 0, path = 'Resources/research.png'}}}, + } + } + } }, unitClass = UnitClass.RESOURCE_ROVER, unitType = UnitType.HOVER, @@ -1251,6 +1392,7 @@ units = { hitboxOffset = {x = 0, y = 2.65, z = 0}, lineOfSight = 5, name = 'Cargo ship', + description = '', colorNodes = {'Cargo'}, basePath = PATH .. vehiclePrefix .. 'Cargoships/', meshPath = 'aincCargoShip.xml', @@ -1266,9 +1408,51 @@ units = { { weapons = {}, abilityButtons = { - {buttonType = ButtonType.ORDER, name = 'Supply', orderType = OrderType.SUPPLY}, - {buttonType = ButtonType.ORDER, name = 'Load', orderType = OrderType.LOAD}, - {buttonType = ButtonType.ORDER, name = 'Unload', orderType = OrderType.UNLOAD}, + { + buttonType = ButtonType.ORDER, + name = 'Supply', + orderType = OrderType.SUPPLY, + tooltip = { + size = {x = 210, y = 60}, + lines = { + {entry = {text = 'Supply'}}, + {entry = {text = 'Begin collecting refineds'}}, + {entry = {text = 'from an extractor'}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + name = 'Load', + orderType = OrderType.LOAD, + tooltip = { + size = {x = 290, y = 120}, + lines = { + {entry = {text = 'Load'}}, + {entry = {text = 'Load the cargo ship with the'}}, + {entry = {text = 'corresponding resource. Can load:'}}, + {entry = {text = 'from refineries'}, icons = {{charId = 0, path = 'Resources/refineds.png'}}}, + {entry = {text = 'from trade centers'}, icons = {{charId = 0, path = 'Resources/wealth.png'}}}, + {entry = {text = 'from labs'}, icons = {{charId = 0, path = 'Resources/research.png'}}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + name = 'Unload', + orderType = OrderType.UNLOAD, + tooltip = { + size = {x = 320, y = 120}, + lines = { + {entry = {text = 'Unload'}}, + {entry = {text = 'Unload the cargo ship with the'}}, + {entry = {text = 'corresponding resource. Can unload:'}}, + {entry = {text = 'to refineries'}, icons = {{charId = 0, path = 'Resources/refineds.png'}}}, + {entry = {text = 'to trade centers'}, icons = {{charId = 0, path = 'Resources/wealth.png'}}}, + {entry = {text = 'to labs'}, icons = {{charId = 0, path = 'Resources/research.png'}}}, + } + } + } }, unitClass = UnitClass.RESOURCE_ROVER, unitType = UnitType.HOVER, @@ -1286,6 +1470,7 @@ units = { hitboxOffset = {x = 0, y = 2.65, z = 0}, lineOfSight = 5, name = 'Cargo ship', + description = '', colorNodes = {'Cargo'}, basePath = PATH .. vehiclePrefix .. 'Cargoships/', meshPath = 'erCargoShip.xml', @@ -1394,6 +1579,7 @@ units = { lineOfSight = 50, colorNodes = {'AATuret'}, name = 'Assault cruiser', + description = '', basePath = PATH .. vehiclePrefix .. 'Cruisers/', meshPath = 'heavyAssaultCruiser.xml', albedoPath = 'cruiser.jpg', @@ -1506,6 +1692,7 @@ units = { lineOfSight = 5, colorNodes = {'frontAATurret', 'rearAATurret'}, name = 'Assault cruiser', + description = '', basePath = PATH .. vehiclePrefix .. 'Cruisers/', meshPath = 'mediumAssaultCruiser.xml', albedoPath = 'cruiser.jpg', @@ -1616,6 +1803,7 @@ units = { lineOfSight = 5, colorNodes = {'aaTurret'}, name = 'Assault cruiser', + description = '', basePath = PATH .. vehiclePrefix .. 'Cruisers/', meshPath = 'lightAssaultCruiser.xml', albedoPath = 'cruiser.jpg', @@ -1706,6 +1894,7 @@ units = { lineOfSight = 100, colorNodes = {'FrontTurret', 'RearTurret'}, name = 'Anti sub cruiser', + description = '', basePath = PATH .. vehiclePrefix .. 'Cruisers/', meshPath = 'acsAntiSubCruiser.xml', albedoPath = 'cruiser.jpg', @@ -1832,6 +2021,7 @@ units = { lineOfSight = 100, colorNodes = {'sides'}, name = 'Anti sub cruiser', + description = '', basePath = PATH .. vehiclePrefix .. 'Cruisers/', meshPath = 'aincAntiSubCruiser.xml', albedoPath = 'cruiser.jpg', @@ -1987,6 +2177,7 @@ units = { lineOfSight = 100, colorNodes = {'Gunship.001'}, name = 'Anti sub cruiser', + description = '', basePath = PATH .. vehiclePrefix .. 'Cruisers/', meshPath = 'erAntiSubCruiser.xml', albedoPath = 'cruiser.jpg', @@ -2038,6 +2229,7 @@ units = { hitboxOffset = {x = 0, y = 1.8, z = -1.3}, lineOfSight = 50, name = 'Missile submarine', + description = '', basePath = PATH .. vehiclePrefix .. 'Submarines/', meshPath = 'acsMissileSubmarine.xml', albedoPath = 'submarine.jpg', @@ -2142,6 +2334,7 @@ units = { hitboxOffset = {x = 0, y = 2.29, z = -1.09}, lineOfSight = 500, name = 'Missile submarine', + description = '', basePath = PATH .. vehiclePrefix .. 'Submarines/', meshPath = 'erMissileSubmarine.xml', albedoPath = 'submarine.jpg', @@ -2181,6 +2374,7 @@ units = { hitboxOffset = {x = 0, y = 1.8, z = -1.3}, lineOfSight = 0, name = 'Stealth submarine', + description = '', colorNodes = {'Cube.001'}, basePath = PATH .. vehiclePrefix .. 'Submarines/', meshPath = 'acsSubmarine.xml', @@ -2220,6 +2414,7 @@ units = { size = {x = 8.32, y = 12.1, z = 57.4}, lineOfSight = 0, name = 'Stealth submarine', + description = '', colorNodes = {'Cube.001'}, basePath = PATH .. vehiclePrefix .. 'Submarines/', meshPath = 'aincSubmarine.xml', @@ -2259,6 +2454,7 @@ units = { size = {x = 5.37, y = 7.66, z = 43}, lineOfSight = 0, name = 'Stealth submarine', + description = '', colorNodes = {'Sphere.001'}, basePath = PATH .. vehiclePrefix .. 'Submarines/', meshPath = 'erSubmarine.xml', @@ -2282,6 +2478,7 @@ units = { hitboxOffset = {x = 0, y = 6.7, z = 0}, lineOfSight = 25, name = 'Icebreaker', + description = '', colorNodes = {'Cube.001'}, basePath = PATH .. vehiclePrefix .. 'Icebreakers/', meshPath = 'acsIcebreaker.xml', @@ -2305,6 +2502,7 @@ units = { hitboxOffset = {x = 0, y = 7.6, z = 5.88}, lineOfSight = 25, name = 'Icebreaker', + description = '', colorNodes = {'Cube.001'}, basePath = PATH .. vehiclePrefix .. 'Icebreakers/', meshPath = 'aincIcebreaker.xml', @@ -2328,6 +2526,7 @@ units = { hitboxOffset = {x = 0, y = 6.71, z = 5.95}, lineOfSight = 25, name = 'Icebreaker', + description = '', colorNodes = {'Cube.001'}, basePath = PATH .. vehiclePrefix .. 'Icebreakers/', meshPath = 'erIcebreaker.xml', @@ -2375,6 +2574,7 @@ units = { hitboxOffset = {x = 0, y = 4.7, z = 0}, lineOfSight = 25, name = 'Freezer', + description = '', colorNodes = {'CryoGun'}, basePath = PATH .. vehiclePrefix .. 'Freezers/', meshPath = 'freezer.xml', @@ -2416,6 +2616,7 @@ units = { hitboxOffset = {x = 0, y = 1.13, z = 1.83}, lineOfSight = 25, name = 'EMP boat', + description = '', colorNodes = {'turret'}, basePath = PATH .. vehiclePrefix .. 'EMPShips/', meshPath = 'empShip.xml', @@ -2449,6 +2650,7 @@ units = { lineOfSight = 5, colorNodes = {'ring'}, name = 'Land factory', + description = '', albedoPath = 'factory.jpg', basePath = PATH .. structurePrefix .. 'LandFactories/', meshPath = 'acsFactory.xml', @@ -2476,6 +2678,7 @@ units = { lineOfSight = 5, colorNodes = {'Cube.002'}, name = 'Land factory', + description = '', albedoPath = 'factory.jpg', basePath = PATH .. structurePrefix .. 'LandFactories/', meshPath = 'aincFactory.xml', @@ -2503,6 +2706,7 @@ units = { lineOfSight = 5, colorNodes = {'Sphere.001'}, name = 'Land factory', + description = '', albedoPath = 'factory.jpg', basePath = PATH .. structurePrefix .. 'LandFactories/', meshPath = 'erFactory.xml', @@ -2530,6 +2734,7 @@ units = { hitboxOffset = {x = 0, y = 28.4, z = -29}, lineOfSight = 5, name = 'Naval factory', + description = '', basePath = PATH .. structurePrefix .. 'NavalFactories/', meshPath = 'acsFactory.xml', colorNodes = {'stripes'}, @@ -2558,6 +2763,7 @@ units = { hitboxOffset = {x = 0, y = 18, z = 0}, lineOfSight = 5, name = 'Naval factory', + description = '', colorNodes = {'roof'}, basePath = PATH .. structurePrefix .. 'NavalFactories/', meshPath = 'aincFactory.xml', @@ -2588,6 +2794,7 @@ units = { hitboxOffset = {x = 0, y = 10, z = -14}, lineOfSight = 5, name = 'Naval factory', + description = '', colorNodes = {'building'}, basePath = PATH .. structurePrefix .. 'NavalFactories/', meshPath = 'erFactory.xml', @@ -2599,10 +2806,46 @@ units = { unitClass = UnitClass.TRADE_CENTER, unitType = UnitType.LAND, abilityButtons = { - {buttonType = ButtonType.BUY_REFINEDS, name = 'Buy ref', trigger = 73}, - {buttonType = ButtonType.SELL_REFINEDS, name = 'Sell ref', trigger = 79}, - {buttonType = ButtonType.BUY_RESEARCH, name = 'Buy rsch', trigger = 75}, - {buttonType = ButtonType.SELL_RESEARCH, name = 'Sell rsch', trigger = 76} + { + buttonType = ButtonType.BUY_REFINEDS, + name = 'Buy ref', + trigger = 73, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Buy _ refineds for _ wealth'}}} + } + }, + { + buttonType = ButtonType.SELL_REFINEDS, + name = 'Sell ref', + trigger = 79, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Sell _ refineds for _ wealth'}}} + } + }, + { + buttonType = ButtonType.BUY_RESEARCH, + name = 'Buy rsch', + trigger = 75, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Buy _ research for _ wealth'}}} + } + }, + { + buttonType = ButtonType.SELL_RESEARCH, + name = 'Sell rsch', + trigger = 76, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Sell _ research for _ wealth'}}} + } + } }, maxUnevenness = .5, isVehicle = false, @@ -2614,6 +2857,7 @@ units = { lineOfSight = 5, colorNodes = {'wall'}, name = 'Trade center', + description = '', basePath = PATH .. structurePrefix .. 'TradeCenters/', meshPath = 'acsTradeCenter.xml', albedoPath = 'tradeCenter.jpg', @@ -2624,10 +2868,46 @@ units = { unitClass = UnitClass.TRADE_CENTER, unitType = UnitType.LAND, abilityButtons = { - {buttonType = ButtonType.BUY_REFINEDS, name = 'Buy ref', trigger = 73}, - {buttonType = ButtonType.SELL_REFINEDS, name = 'Sell ref', trigger = 79}, - {buttonType = ButtonType.BUY_RESEARCH, name = 'Buy rsch', trigger = 75}, - {buttonType = ButtonType.SELL_RESEARCH, name = 'Sell rsch', trigger = 76} + { + buttonType = ButtonType.BUY_REFINEDS, + name = 'Buy ref', + trigger = 73, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Buy _ refineds for _ wealth'}}} + } + }, + { + buttonType = ButtonType.SELL_REFINEDS, + name = 'Sell ref', + trigger = 79, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Sell _ refineds for _ wealth'}}} + } + }, + { + buttonType = ButtonType.BUY_RESEARCH, + name = 'Buy rsch', + trigger = 75, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Buy _ research for _ wealth'}}} + } + }, + { + buttonType = ButtonType.SELL_RESEARCH, + name = 'Sell rsch', + trigger = 76, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Sell _ research for _ wealth'}}} + } + } }, maxUnevenness = .5, isVehicle = false, @@ -2639,6 +2919,7 @@ units = { lineOfSight = 5, colorNodes = {'Cube.001'}, name = 'Trade center', + description = '', basePath = PATH .. structurePrefix .. 'TradeCenters/', meshPath = 'aincTradeCenter.xml', albedoPath = 'tradeCenter.jpg', @@ -2649,10 +2930,46 @@ units = { unitClass = UnitClass.TRADE_CENTER, unitType = UnitType.LAND, abilityButtons = { - {buttonType = ButtonType.BUY_REFINEDS, name = 'Buy ref', trigger = 73}, - {buttonType = ButtonType.SELL_REFINEDS, name = 'Sell ref', trigger = 79}, - {buttonType = ButtonType.BUY_RESEARCH, name = 'Buy rsch', trigger = 75}, - {buttonType = ButtonType.SELL_RESEARCH, name = 'Sell rsch', trigger = 76} + { + buttonType = ButtonType.BUY_REFINEDS, + name = 'Buy ref', + trigger = 73, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Buy _ refineds for _ wealth'}}} + } + }, + { + buttonType = ButtonType.SELL_REFINEDS, + name = 'Sell ref', + trigger = 79, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Sell _ refineds for _ wealth'}}} + } + }, + { + buttonType = ButtonType.BUY_RESEARCH, + name = 'Buy rsch', + trigger = 75, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Buy _ research for _ wealth'}}} + } + }, + { + buttonType = ButtonType.SELL_RESEARCH, + name = 'Sell rsch', + trigger = 76, + amount = 10, + tooltip = { + size = {x = 200, y = 40}, + lines = {{entry = {text = 'Sell _ research for _ wealth'}}} + } + } }, maxUnevenness = .5, isVehicle = false, @@ -2664,6 +2981,7 @@ units = { lineOfSight = 5, colorNodes = {'sphere'}, name = 'Trade center', + description = '', basePath = PATH .. structurePrefix .. 'TradeCenters/', meshPath = 'erTradeCenter.xml', albedoPath = 'tradeCenter.jpg', @@ -2674,7 +2992,20 @@ units = { unitClass = UnitClass.LAB, unitType = UnitType.LAND, maxUnevenness = .5, - abilityButtons = {{buttonType = ButtonType.ACTIVE_STATE, name = 'Tech tree', guiScreen = 'acsTechTree.lua'}}, + abilityButtons = { + { + buttonType = ButtonType.ACTIVE_STATE, + name = 'Tech tree', + guiScreen = 'acsTechTree.lua', + tooltip = { + size = {x = 200, y = 40}, + lines = { + {entry = {text = 'Tech tree'}}, + {entry = {text = 'Access the Asian technology tree'}}, + } + } + } + }, isVehicle = false, health = 500, buildTime = 1000, @@ -2686,6 +3017,7 @@ units = { generationSpeed = 10, researchCost = 1, name = 'Lab', + description = '', colorNodes = {'stripes'}, basePath = PATH .. structurePrefix .. 'Labs/', meshPath = 'acsLab.xml', @@ -2697,7 +3029,20 @@ units = { unitClass = UnitClass.LAB, unitType = UnitType.LAND, maxUnevenness = .5, - abilityButtons = {{buttonType = ButtonType.ACTIVE_STATE, name = 'Tech tree', guiScreen = 'aincTechTree.lua'}}, + abilityButtons = { + { + buttonType = ButtonType.ACTIVE_STATE, + name = 'Tech tree', + guiScreen = 'aincTechTree.lua', + tooltip = { + size = {x = 200, y = 40}, + lines = { + {entry = {text = 'Tech tree'}}, + {entry = {text = 'Access the American technology tree'}}, + } + } + } + }, isVehicle = false, health = 500, buildTime = 1000, @@ -2709,6 +3054,7 @@ units = { generationSpeed = 10, researchCost = 1, name = 'Lab', + description = '', colorNodes = {'stripe'}, basePath = PATH .. structurePrefix .. 'Labs/', meshPath = 'aincLab.xml', @@ -2720,7 +3066,20 @@ units = { unitClass = UnitClass.LAB, unitType = UnitType.LAND, maxUnevenness = .5, - abilityButtons = {{buttonType = ButtonType.ACTIVE_STATE, name = 'Tech tree', guiScreen = 'erTechTree.lua'}}, + abilityButtons = { + { + buttonType = ButtonType.ACTIVE_STATE, + name = 'Tech tree', + guiScreen = 'erTechTree.lua', + tooltip = { + size = {x = 200, y = 40}, + lines = { + {entry = {text = 'Tech tree'}}, + {entry = {text = 'Access the European technology tree'}}, + } + } + } + }, isVehicle = false, health = 500, buildTime = 1000, @@ -2732,6 +3091,7 @@ units = { generationSpeed = 10, researchCost = 1, name = 'Lab', + description = '', colorNodes = {'stripes'}, basePath = PATH .. structurePrefix .. 'Labs/', meshPath = 'erLab.xml', @@ -2796,6 +3156,7 @@ units = { hitboxOffset = {x = 0, y = 4, z = 0}, lineOfSight = 55, name = 'Point defense', + description = '', colorNodes = {'Hoses', 'Hoses.001'}, turretNode = 'TurretBody', basePath = PATH .. structurePrefix .. 'PointDefenses/', @@ -2819,6 +3180,7 @@ units = { size = {x = 9.72, y = 10.14, z = 9.72}, lineOfSight = 5, name = 'Extractor', + description = 'Collects refineds from resource deposits', basePath = PATH .. structurePrefix .. 'Extractors/', meshPath = 'extractor.xml', albedoPath = 'extractor.jpg', @@ -2857,6 +3219,7 @@ units = { hitboxOffset = {x = 0, y = 15.2, z = 0}, lineOfSight = 5, name = 'Refinery', + description = '', basePath = PATH .. structurePrefix .. 'Refineries/', meshPath = 'aincRefinery.xml', albedoPath = 'refinery.jpg', @@ -2876,6 +3239,7 @@ units = { hitboxOffset = {x = 0, y = 13.95, z = 3.23}, lineOfSight = 5, name = 'Refinery', + description = '', basePath = PATH .. structurePrefix .. 'Refineries/', meshPath = 'erRefinery.xml', albedoPath = 'refinery.jpg', @@ -2891,6 +3255,7 @@ units = { hitboxOffset = {x = 0, y = 0, z = 0}, lineOfSight = 5, name = 'Ice sheet', + description = '', basePath = PATH .. structurePrefix .. 'IceSheets/', meshPath = 'iceSheet.xml', albedoPath = 'iceSheet.jpg', diff --git a/Assets/Scripts/Gui/activeGameState.lua b/Assets/Scripts/Gui/activeGameState.lua index cda4cd6..e7fa7da 100644 --- a/Assets/Scripts/Gui/activeGameState.lua +++ b/Assets/Scripts/Gui/activeGameState.lua @@ -118,7 +118,14 @@ gui = { guiScreen = 'tradingHub.lua', pos = {x = minimapSize.x, y = res.y - minimapSize.y, z = -.2}, size = {x = Size.x, y = minimapSize.y - .75 * sz}, - trigger = 10 + trigger = 10, + tooltip = { + offset = {x = Size.x, y = -(minimapSize.y - .75 * sz), z = .1}, + size = {x = 310, y = 20}, + lines = { + {entry = {text = 'Trade resources with other players'}}, + } + } }, { guiType = GuiType.GUI_RECTANGLE, diff --git a/Assets/Scripts/Gui/mainMenu.lua b/Assets/Scripts/Gui/mainMenu.lua index ba8edbe..78fef46 100644 --- a/Assets/Scripts/Gui/mainMenu.lua +++ b/Assets/Scripts/Gui/mainMenu.lua @@ -34,10 +34,13 @@ gui = { 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}, + offset = {x = 100, y = -25, z = .1}, + size = {x = 270, y = 20}, lines = { - {entry = {text = 'Play with computer opponents'}}, + { + entry = {text = 'Play with computer opponents'}, + }, + } } }, @@ -46,20 +49,41 @@ gui = { size = Size, guiType = GuiType.BUTTON, name = 'Map editor', - buttonType = ButtonType.MAP_EDITOR + buttonType = ButtonType.MAP_EDITOR, + tooltip = { + offset = {x = 100, y = -25, z = .1}, + size = {x = 340, y = 20}, + lines = { + {entry = {text = 'Create new maps or edit existing ones'}}, + } + } }, { pos = {x = 20, y = 220, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Options', - buttonType = ButtonType.OPTIONS + buttonType = ButtonType.OPTIONS, + tooltip = { + offset = {x = 100, y = -25, z = .1}, + size = {x = 200, y = 20}, + lines = { + {entry = {text = 'Configure Planet Fleet'}}, + } + } }, { pos = {x = 20, y = 280, z = 0}, size = Size, guiType = GuiType.BUTTON, name = 'Exit', - buttonType = ButtonType.EXIT + buttonType = ButtonType.EXIT, + tooltip = { + offset = {x = 100, y = -25, z = .1}, + size = {x = 150, y = 20}, + lines = { + {entry = {text = 'Exit Planet Fleet'}}, + } + } } } diff --git a/Assets/Scripts/Gui/tradingScreen.lua b/Assets/Scripts/Gui/tradingScreen.lua index 937e83b..d1da4ec 100644 --- a/Assets/Scripts/Gui/tradingScreen.lua +++ b/Assets/Scripts/Gui/tradingScreen.lua @@ -12,6 +12,9 @@ IconPath = {WEALTH = 'Icons/Resources/wealth.png', RESEARCH = 'Icons/Resources/r function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath) height = HubMargin.top + lineId * iconSize.y + tooltipOffset = {x = iconSize.x * (cpuPlayer and 1 or -1), y = -iconSize.y, z = .1} + tooltipSize = {x = 190, y = 20} + resourceAmountDelta = 10 if guiId == ResourceTrayGuiId.ICON then guiElPos = {x = HubPos.x + (cpuPlayer and HubMargin.left or HubSize.x -(HubMargin.right + 3 * iconSize.x + textboxSize.x)), y = height, z = .2} @@ -36,11 +39,18 @@ function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath) return { guiType = GuiType.BUTTON, buttonType = ButtonType.RESOURCE_AMMOUNT, - ammount = 10, + ammount = resourceAmountDelta, name = '+', pos = guiElPos, size = iconSize, - trigger = 10 + trigger = 10, + tooltip = { + offset = tooltipOffset, + size = tooltipSize, + lines = { + {entry = {text = 'Increase value by ' .. resourceAmountDelta}}, + } + } } elseif guiId == ResourceTrayGuiId.DECREMENT then guiElPos = {x = HubPos.x + (cpuPlayer and HubMargin.left + 2 * iconSize.x + textboxSize.x or HubSize.x -(HubMargin.right + iconSize.x)), y = height, z = .2} @@ -48,11 +58,18 @@ function createResourceTrayGui(cpuPlayer, lineId, guiId, imgPath) return { guiType = GuiType.BUTTON, buttonType = ButtonType.RESOURCE_AMMOUNT, - ammount = -10, + ammount = -resourceAmountDelta, name = '-', pos = guiElPos, size = iconSize, - trigger = 10 + trigger = 10, + tooltip = { + offset = tooltipOffset, + size = tooltipSize, + lines = { + {entry = {text = 'Decrease value by ' .. resourceAmountDelta}}, + } + } } end end diff --git a/Assets/Scripts/Gui/unitGui.lua b/Assets/Scripts/Gui/unitGui.lua index 8890486..e659db7 100644 --- a/Assets/Scripts/Gui/unitGui.lua +++ b/Assets/Scripts/Gui/unitGui.lua @@ -11,7 +11,7 @@ function generateButton(numGui, buttonData) yOffset = (numGui + 1) % 2 == 0 and (buttonSize.y + buttonSpace.y) or 0 button = { - pos = {x = buttonInitPos.x + xOffset, y = buttonInitPos.y + yOffset, z = .5}, + pos = {x = buttonInitPos.x + xOffset, y = buttonInitPos.y + yOffset, z = buttonInitPos.z}, size = buttonSize, guiType = GuiType.BUTTON, name = buttonData.name, @@ -22,6 +22,8 @@ function generateButton(numGui, buttonData) factoryId = buttonData.factoryId, engineerId = buttonData.engineerId, guiScreen = buttonData.guiScreen, + tooltip = buttonData.tooltip, + amount = buttonData.amount, slotId = buttonData.slotId } @@ -30,15 +32,50 @@ end function generateGui(unitId) local gui = {} + haltOrder = { + buttonType = ButtonType.ORDER, + orderType = OrderType.HALT, + name = 'Halt', + tooltip = { + offset = {x = buttonSize.x, y = -buttonSize.y, z = .1}, + size = {x = 210, y = 20}, + lines = {{entry = {text = "Cancel all unit\'s orders"}}} + } + } vehicleButtonData = { - {buttonType = ButtonType.UNIT_STATE, imagePath = 'Icons/Buttons/chase.png'}, - {buttonType = ButtonType.ORDER, orderType = OrderType.GARRISON, name = 'Garrison'}, - {buttonType = ButtonType.ORDER, orderType = OrderType.PATROL, name = 'Patrol'}, - {buttonType = ButtonType.ORDER, orderType = OrderType.HALT, name = 'Halt'}, - } - structureButtonData = { - {buttonType = ButtonType.ORDER, orderType = OrderType.HALT, name = 'Halt'} + { + buttonType = ButtonType.UNIT_STATE, + imagePath = 'Icons/Buttons/chase.png', + tooltip = { + offset = {x = buttonSize.x, y = -buttonSize.y, z = .1}, + size = {x = 340, y = 120}, + lines = { + {entry = {text = 'Toggle unit state'}}, + {entry = {text = '(C)hase: automatically attacks and'}}, + {entry = {text = 'pursues enemies'}}, + {entry = {text = '(S)tand ground: automatically fires on'}}, + {entry = {text = 'enemies but does not move'}}, + {entry = {text = '(H)old fire: does not react to enemies'}}, + } + } + }, + { + buttonType = ButtonType.ORDER, + orderType = OrderType.GARRISON, + name = 'Garrison', + tooltip = { + offset = {x = buttonSize.x, y = -buttonSize.y, z = .1}, + size = {x = 300, y = 60}, + lines = { + {entry = {text = 'Garrison'}}, + {entry = {text = 'Enter a garrisonable unit, such as a'}}, + {entry = {text = 'transport ship'}}, + } + } + }, + haltOrder } + structureButtonData = {haltOrder} mainUnit = units[unitId + 1] unitButtonData = mainUnit.isVehicle and vehicleButtonData or structureButtonData @@ -47,7 +84,15 @@ function generateGui(unitId) unitButtonData[#unitButtonData + 1] = { buttonType = ButtonType.ORDER, orderType = OrderType.EJECT, - name = 'Eject' + name = 'Eject', + tooltip = { + offset = {x = buttonSize.x, y = -buttonSize.y, z = .1}, + size = {x = 220, y = 40}, + lines = { + {entry = {text = 'Eject'}}, + {entry = {text = 'Eject all garrisoned units'}}, + } + } } end @@ -64,7 +109,13 @@ function generateGui(unitId) name = abilButton.name, buttonType = abilButton.buttonType, guiScreen = abilButton.guiScreen, - orderType = abilButton.orderType + orderType = abilButton.orderType, + amount = abilButton.amount, + tooltip = { + offset = {x = buttonSize.x, y = -buttonSize.y, z = .1}, + size = abilButton.tooltip.size, + lines = abilButton.tooltip.lines + } } gui[#gui + 1] = generateButton(#gui, buttonData) end @@ -86,6 +137,8 @@ function generateGui(unitId) mainUnit.unitClass == UnitClass.ENGINEER or mainUnit.unitClass == UnitClass.FREEZER ) + costStr = '' .. units[buildUnit.id + 1].cost + buildTimeStr = '' .. units[buildUnit.id + 1].buildTime buttonData = { trigger = buildUnit.trigger, @@ -94,7 +147,21 @@ function generateGui(unitId) factoryId = (isFactory and unitId or nil), engineerId = (isEng and unitId or nil), imagePath = buildUnit.iconPath, - slotId = (ButtonType.BUILD and i - 1 or nil) + slotId = (ButtonType.BUILD and i - 1 or nil), + tooltip = { + offset = {x = buttonSize.x, y = -buttonSize.y, z = .1}, + size = {x = 220, y = 60}, + lines = { + {entry = {text = units[buildUnit.id + 1].name}}, + { + entry = {text = 'Cost: ' .. costStr .. ' ' .. buildTimeStr}, + icons = { + {charId = 0, path = 'Resources/refineds.png'}, + {charId = 9 + #costStr, path = 'Resources/time.png'} + } + }, + } + } } gui[#gui + 1] = generateButton(#gui, buttonData) diff --git a/Assets/Textures/Icons/Resources/time.png b/Assets/Textures/Icons/Resources/time.png index ae1ba7c9c6232c602006cacc5b94ef50d4226ba1..a671a83db09f28725ec60db05601c0a98c7de420 100644 GIT binary patch delta 2941 zcmV-@3xf2+7OxkOED9O`00$ZYIPK+$kv1oP3p`0gK~#90?VWqDS5+0qKkI_`iV6w{ zTt#_Yc{bRT)mRpqh)t$wK{HB%X8$xj>@^cI)dbEoJ;boA9IY%vn@D>oKFWg7@kNk5 zsMLE&QxuR?9$vgW%DehwoeRJFT?IECl8Olj~f38}LhDg{nSP=duq&ZiI-)C}2KD z#9MPw;&5yLZUug(sxRlFfvVOu0poyw?*JWu7BqDL*8?Zly?yFPL<{h3U|#_m+?x&n zD}bqeh7jP`h=~6cpn;R7|3-Bf)~g8t<^azZph2@rTY<}nzP-JM5NxWtwg3%StF#&z zUyHWOe3m65bAg+I<1);)gJ@v~v_`2N`|!3@d1eD}AGWBRf-NkM%221Bz!j>0dRK;d zX4gZ2CTyI|;tkx7^{_7k?*fjfP~JR8KBtt(H)0FUCBOqw8EN(G1eODhg&MMeX6%hj zTfs+xj{(CSWq#6;-^?DK9|3$Ecq{|G*8yV+K?pDjcsfO8y5{_o1IxWK4IyQDO#!|O z>`hURO+ZVoga9*uEeR{ojty~tCnhXAGeS!890e=|b|tLSi@=+6Ap|%R*quP>PTWA_9@_;G(^;ckdiWH0vi*Oa$1ry8wiAm zOagvK*tAxGZvZn?bxmlQc|lbl0^R~#i`Bu4VZgm2Qf*4!W1%5$%xG+XEfDgyyac>2 zi(XOh9#U4`1;ERJb$=RYu1OCOktX0C!puW<5;hIb@ZU z-30tRpglT)_h&L>iO58MYzin&j_&~Gsp>wbe6NG5?gu`E9sPPBz|A5uK2ESlLPSIe z+bCQEEL7D_r+lx4s=f{^!1l#F7y0I|`pg;j5%P&&acfMD={e@%+UJbsK{nz{Ta?0gUXa zhs+0tIM}^GRbO(*6%NrR>96ov)t`~13{~9@+~g1)0$fsm`XA+lEOcbD4?BA8t+)xZ zWbq)4HT<>M8GRhOwfR9pL}WTXEA$_z>b5Z5iUAQ>gsm4m_!ID>q-Ck~+bVy5A#J&;+6t_9h#qYF1^^K`5wlH-!-{08{ir-h@VA71iy3%dtdNS7xlkO3a-h4)2CTgv@e0@TjWpOsG^| zSOmPoDSHRDp_(bwT;u-e5Iq|X5#l-XSesO-9Pu81r`+Sfhc#N&)c}8R$jkz0i2T4~ zj~1Po_C{<4E>hKw8kXT{yNMz)q5<=th(iZv-QL&GHKVGvWz0H!i^M4nm?KLZo>bKX z>2xX_6dR^${-Q9P%j~SQYupf>;W!}&MNXi zyFL$d0 zV=j3V=5IZKWH-ZJl^5N(Kl?4v*d28aQMI zfgT9RACx#whh9iN`gsImru?U|7ZMQZr?;*znn;jYL z0Vd^W!BJ?4$O%|r<)dRnJFrV*c69wmw;mGtGQ`Go!Vavi3DmPc;hV&h0r35QQZk^z z9aJK65*AG}ZZlD_7`(mFZ=_}rku$M1MO+k!{n)p-o8|psRwt3OqsNy}fa^uXv*_s; zh<3zp#1{_nmWpl=RYF5d!u;Yq0Unp-8DgVI3AoPLW(RZrHSUjT#hZmc?xF$fFuad|glhGa|t{ubB8G%{RA z_yu8GfC<6nB~PU^^%;#_EScnfM#YBmL_H%DLZV8v zU>~m}6;Lcn&i8<+ITA4qxB;^lNLr6p5_~fod^%5i*MOon-|ZvBhJO>q^Vh0nCSRDfVG)%0R!SD6gxdyuIf=J*7_UC_A&+V=XSY zzYq%`oTVM`K5YHdig|psVO~>vN)p&ve^+Y8+{j8Vxc9gOc<~BwxvJiqVV>Fbkg~UN zJa*S#+BdMM>9;t4HVShcvZ@d>2XpYxy8*LGTd>ehwQI9lW*(6;4EwfZF=pqL4q!K( z9#ix7s&xS+#7w}}9eWGVz}~bUv%r~Lw|1&mK_$eT6cOXOI3}<38n%B`_eE>wvn(&7 zc)^!o_h%Hvq4Y7}HejWeSrpa_xe?M$3G+Ew2+RYf*SYv;e`5X_w`l=xekcSXr4W(P z*aB{Ll)QoTz1Rjkj2UnIMpd8BIR8{A93kb198J3xc3q3SX3Us*D0ZaU6|HCwwgcTB n{e3&Om~6!smTg+_3kCiUiBnitCubkL00000NkvXXu0mjf!a7Sr delta 2832 zcmV+r3-9!=7sD2iEDDtX00)%;YY@i(kv1oP3eZVJK~#90?VW$HRaF(oKkLcEKtVwh zMGzn2dyxGg(|L|124YhgGNp!0L6)OdlhY3yYib&1nwn{{A|0F3oUx#WbYgS@f24_u zqmYPA{veCG%v;-j{G6|RqTn3yO^L7Pxx$yCT#JqnUuozgVs%vB3 zn>ds{P#V6Upa6-jp})`cC1wXROWE^iVru1a1{ z0}FvgP3ziJHPZvDq?@rmUdtTYfV+WffsPdNKLxk~xD9xzf(-At|Ho!tKN%9y;fQ#< zOa;8@D&QkcctFkqegbSSBiDXl0njyI2*J9JTY!U+!X5_x0$d8TXH7&IIoq9oEK8hh zzN`m;`M~ggO$aap*c>U`Ay?=RHJgMga=+KLi~|wbw_-0J(ys_{-P5u%E#mjUgcS1o z3h;AxT$NzDo!B5BZ7~l6+D*L7g^13I5^e+IOia7D`! z0vzoIZU1T74SW+AlolCT5aRNGXa{ZpdLpg<7r@|_A_RMtTorkORsrMFBqB>fyu2m= zt0QGy35-f2{Wcneh;#st1Lt_rw_~rc|7|q=R)ebk2RI*la}2(!yMYxV5?9O62MrM- zB4-0D2-O`uz-LtTI#u1*sBo~YZ@z;Y4!U?XYQO^AqpT!?iQqg>Q$ zz%*68rxAhr6IAujz(v3g7j-i5n21cNH_f^T5s~);_X5LR)FxnxsyC27s=BTo0R{q8bpvoArUV5T2HYniXT(h_79k>X z5^z6ZH?gpJB<_hlR=8Im`H$-G+E%zRg5D_^IxPx$N^p-rm+SUty_e%ULcPhZ0?jyP? zsuCh10{jjb>7t$iZmeI-+~Ee`Sr;CGX)vndNG)VGw)z81Q8-Ig_t!06&fv5avk1qN z=^`?#+C3Es5s~58KptS;K-5j84X6A1p%?W_5jn2X_0?L)kATrG`~qQrSRg*;WAiCs z-zW1bU09Y7r?vclsykKS%c^=HNeS}=RXqq?PpBQfzS38Gr55sC;3yYfsH#sUD`Nhj zs>^{z?sO3FopRUpAw)#R0-txMhp?`zKr)zz)hWPL?vtVfizL(M#2;*t?Q`}5;CpAMFrBuBVKqKK%4tI z4|FPjTi2W5|Z21hfRcE=UoLM&4<6X zt*Z^&M_2C80@=W~9?{iCxK0<~<&1?XP+I4s+OU;>+5vWFEKC7gmK$JLl#o3X$Ql(1 zIjE{{H$kAh<1NB@_F)3-!{*R;sp^QPiPZo^WHT_vo$kQak)@5Fs_FwtBqSocFcT#E z1|^YT3*cBUd?HR!moieBqG%%=H;%1#VS#ku7PJR--!ljsR7L`WL}W-m9Y>zWHuQs; z^~hp>>C#IHr8AUpQDQG40fu4rtojvHweD@mEdc*5x2KK1gcQgYeF)j^MO3p#SRftv zb-ulgQiWnC1+s>(++7BPsqeR73|5`=S&mX56Zq@l9)WOw8Bjq;bI@l!oTw@yG8zcH1Z-8+Q!^JW zXK*^Kt=O(yfKydCD#y6m3zy71mU!543$I_scH$~9+3gxFkPt*tcIrD_?6B>iNT_diQ`uL!7UeY#TD^U&sXXV)hY?5$0onOEj!hYaPRV`U9 z+Q+nps%{}1OO675kg}Y4!aTw{zcWgI22}9U=8Pr(3$t3Iz=f*%M2dnAc!m7D68xH>By8 zV;~=xZLFXkHv`93y!HqQUFjvXn-u&<4fF%s|G&qp$IGi-e?(88BJwaW-JL#viy7V@ zu)aZ(gowNg^RF`5Mg3J(t7<@Mv26V%Ot%GaHt@5$CCne@6OyqLxbBE|)Y$AUrPSG1 z)n->53TCg@cOLesn(m8{!F(@+y;#@P^n$nIftk7Ty}8{~>%BF5i*_pG<=Dgum`$w< zwD^iIfwO(}1fe!}1@;|Rlew#ZSnj(;tiy8ww-~`DvoOz{(3CVaBxHt|OP=^mHHGfMV!(5Moxxao&L~^_8 z(OIc}oN%GxZr~EF^fg`$4GdgUfd3H=T(1G=HhVyA!T{cl?Q8UX9p>|}=@nalXPKs8JAM5!?Vv_=NK*-M1sI3DlWXK@`Xe?|*7QoQu^f{y zpC5-KWqA-7n@XN37ib2y_rx#EAz%q`PO~e#irnvWFD3^gvcCe%O*QWf3OC%1EeFc9 zm?gkWU~mhNFxbhmv`mZG@5YLXGkyJr5U;>zV1E4eMG71A$F~B1-Ay3kJj~(Qjxut+ z1N;W)$V{FlRKO_AQOw>l6`_0=NxZrCCmfcijJDvaX+4+TJAL zJj=|+{9ScdxpXsTN_8D(pKv`kF7*I=RCRA8-D5CgF2k{xi%v{C-G%9z#!?w8v9-2; zQq?!(m#T3zjgS(1Axtqj2lLP{@d%ek5$KP=+?&S58f<^YAG8I$U$+DyKAb9lDrS0n z8lgHnDQpCmVSD + inkscape:export-xdpi="46.181816" + inkscape:export-ydpi="46.181816" /> + x="21.99954" + y="144.25369" + transform="rotate(-50.109638)" /> getPath() + "Fonts/batang.ttf"; - return new Tooltip(guiPos + offset, size, lines, fontPath); + Tooltip *tooltip = new Tooltip(guiPos + offset, size, lines, fontPath); + + sol::optional bgColorTblOpt = tooltipTbl["backgroundColor"]; + + if(bgColorTblOpt != sol::nullopt){ + sol::table bgColorTbl = tooltipTbl["backgroundColor"]; + Vector4 bgColor = Vector4(bgColorTbl["x"], bgColorTbl["y"], bgColorTbl["z"], bgColorTbl["w"]); + tooltip->getBackground()->getMaterial()->setVec4Uniform("diffuseColor", bgColor); + } + + return tooltip; } //TODO refactor player difficulty and faction listbox selection @@ -242,16 +256,16 @@ namespace battleship{ button = new ResearchButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["techId"]); break; case BUY_REFINEDS: - button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::BUY_REFINEDS); + button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::BUY_REFINEDS, (int)guiTable["amount"]); break; case SELL_REFINEDS: - button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::SELL_REFINEDS); + button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::SELL_REFINEDS, (int)guiTable["amount"]); break; case BUY_RESEARCH: - button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::BUY_RESEARCH); + button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::BUY_RESEARCH, (int)guiTable["amount"]); break; case SELL_RESEARCH: - button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::SELL_RESEARCH); + button = new TradeButton(pos, size, name, (int)guiTable["trigger"], imagePath, TradeButton::Type::SELL_RESEARCH, (int)guiTable["amount"]); break; case ACTIVE_STATE_BUTTON: button = new ActiveStateButton(pos, size, guiTable["guiScreen"], name, fontBasePath + "batang.ttf", (int)guiTable["trigger"], imagePath); diff --git a/pfButtonBase.h b/pfButtonBase.h index 01a50e9..d0a5353 100644 --- a/pfButtonBase.h +++ b/pfButtonBase.h @@ -15,7 +15,7 @@ namespace battleship{ 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: + protected: bool enabledHoveredOn = false; vb01::Vector4 baseColor, hoveredOnColor; Tooltip *tooltip = nullptr; diff --git a/tooltip.cpp b/tooltip.cpp index 838c3bf..b1df009 100644 --- a/tooltip.cpp +++ b/tooltip.cpp @@ -16,7 +16,7 @@ namespace battleship{ Root *root = Root::getSingleton(); Material *bgMat = new Material(root->getLibPath() + "gui"); bgMat->addBoolUniform("texturingEnabled", false); - bgMat->addVec4Uniform("diffuseColor", Vector4(.5, .5, .5, .5)); + bgMat->addVec4Uniform("diffuseColor", Vector4(.5, .5, .5, 1)); background = new Quad(Vector3(s.x, s.y, 0), false); background->setMaterial(bgMat); @@ -35,12 +35,10 @@ namespace battleship{ textMat->addBoolUniform("texturingEnabled", false); textMat->addVec4Uniform("diffuseColor", ld.textColor); - float scale = .2; - - Vector3 offset = Vector3(0, 20 * (i + 1), .01); + Vector3 offset = ld.getLineOffset(i); Text *text = new Text(fontPath, ld.entryText); text->setMaterial(textMat); - Node *textNode = new Node(pos + offset - Vector3(0, 3, 0), Quaternion::QUAT_W, scale * Vector3::VEC_IJK); + Node *textNode = new Node(pos + offset, Quaternion::QUAT_W, ld.scale * Vector3::VEC_IJK); textNode->addText(text); bgNode->attachChild(textNode); @@ -50,7 +48,7 @@ namespace battleship{ for(int j = 0; j < iconData.first; j++){ Text::Glyph *glyph = text->getGlyph(entry[j]); - iconOffset.x += scale * (glyph->advance >> 6); + iconOffset.x += ld.scale * (glyph->advance >> 6); } entry.insert(iconData.first, L" "); @@ -62,7 +60,7 @@ namespace battleship{ Texture *t = new Texture(ip, 1, false); iconMat->addTexUniform("textures[0]", t, false); - Vector2 iconSize = 20 * Vector2::VEC_IJ; + Vector2 iconSize = ld.height * Vector2::VEC_IJ; Quad *rect = new Quad(Vector3(iconSize.x, iconSize.y, 0), false); rect->setMaterial(iconMat); Node *rectNode = new Node(iconOffset - Vector3(0, iconSize.y, 0)); diff --git a/tooltip.h b/tooltip.h index 12316e4..724765c 100644 --- a/tooltip.h +++ b/tooltip.h @@ -16,11 +16,23 @@ namespace battleship{ class Tooltip{ public: struct LineData{ + int height; + float scale; + vb01::Vector3 textOffset; std::wstring entryText; vb01::Vector4 textColor; std::vector> iconsData; - LineData(std::wstring et, vb01::Vector4 tc, std::vector> id) : entryText(et), textColor(tc), iconsData(id){}; + inline vb01::Vector3 getLineOffset(int i){return vb01::Vector3(textOffset.x, height * (i + 1) + textOffset.y, textOffset.z);} + + LineData(std::wstring et, vb01::Vector4 tc, std::vector> id, int h, vb01::Vector3 to, float s) : + entryText(et), + textColor(tc), + iconsData(id), + height(h), + textOffset(to), + scale(s) + {} }; Tooltip(vb01::Vector3, vb01::Vector2, std::vector, std::string); diff --git a/tradeButton.cpp b/tradeButton.cpp index 51b98a5..8a0c28b 100644 --- a/tradeButton.cpp +++ b/tradeButton.cpp @@ -2,6 +2,10 @@ #include "activeGameState.h" #include "player.h" +#include +#include +#include + #include namespace battleship{ @@ -9,15 +13,42 @@ namespace battleship{ using namespace vb01; using namespace gameBase; - 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){} + TradeButton::TradeButton(Vector3 pos, Vector2 size, string name, int trigger, string imagePath, Type t, int am) : + UnitButton(pos, size, name, GameManager::getSingleton()->getPath() + "Fonts/batang.ttf", trigger, imagePath), + type(t), + amount(am) + {} void TradeButton::onClick(){ ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE)); Player *player = activeState->getPlayer(); - int resType, ammount = 10; + int resType; bool buy; + editResourceTradeData(resType, buy); + player->getTrader()->trade(player, resType, amount, buy); + } + void TradeButton::update(){ + PfButtonBase::update(); + + Text *descText = tooltip->getBackground()->getNode()->getChild(0)->getText(0); + + if(tooltipInitDesc == L"") tooltipInitDesc = descText->getText(); + + wstring entry = tooltipInitDesc; + entry.replace(entry.find_first_of(L"_"), 1, to_wstring(amount)); + + int rt; + bool b; + editResourceTradeData(rt, b); + ActiveGameState *activeState = (ActiveGameState*)(GameManager::getSingleton()->getStateManager()->getAppStateByType((int)AppStateType::ACTIVE_STATE)); + entry.replace(entry.find_last_of(L"_"), 1, to_wstring(activeState->getPlayer()->getTrader()->getResourceRate(rt))); + + descText->setText(entry); + } + + void TradeButton::editResourceTradeData(int &resType, bool &buy){ switch(type){ case Type::BUY_REFINEDS: resType = (int)ResourceType::REFINEDS; @@ -36,7 +67,5 @@ namespace battleship{ buy = false; break; } - - player->getTrader()->trade(player, resType, ammount, buy); } } diff --git a/tradeButton.h b/tradeButton.h index 604858b..fd504fc 100644 --- a/tradeButton.h +++ b/tradeButton.h @@ -8,10 +8,15 @@ namespace battleship{ public: enum class Type{BUY_REFINEDS, SELL_REFINEDS, BUY_RESEARCH, SELL_RESEARCH}; - TradeButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, Type); + TradeButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, Type, int); void onClick(); + void update(); private: Type type; + int amount; + std::wstring tooltipInitDesc = L""; + + void editResourceTradeData(int&, bool&); }; } diff --git a/trader.cpp b/trader.cpp index 5e5af2e..49d2baa 100644 --- a/trader.cpp +++ b/trader.cpp @@ -45,17 +45,12 @@ namespace battleship{ } } - void Trader::trade(Player *tradingPlayer, int rt, int ammount, bool buying){ - int tradeResRate; + int Trader::getResourceRate(int rt){ + return (ResourceType)rt == ResourceType::REFINEDS ? refinedsRate : researchRate; + } - switch((ResourceType)rt){ - case ResourceType::REFINEDS: - tradeResRate = refinedsRate; - break; - case ResourceType::RESEARCH: - tradeResRate = researchRate; - break; - } + void Trader::trade(Player *tradingPlayer, int rt, int ammount, bool buying){ + int tradeResRate = getResourceRate(rt); if(buying && ammount * tradeResRate <= tradingPlayer->getResource(ResourceType::WEALTH)){ tradingPlayer->updateResource((ResourceType)rt, ammount, true); diff --git a/trader.h b/trader.h index 1121cf4..acfbfbf 100644 --- a/trader.h +++ b/trader.h @@ -11,6 +11,7 @@ namespace battleship{ Trader(); void update(); void trade(Player*, int, int, bool); + int getResourceRate(int); private: void initProperties(); From b78c27da58e73e9420084deddc3cfce6e8efa8ef Mon Sep 17 00:00:00 2001 From: devZoGok Date: Thu, 13 Aug 2026 19:21:24 +0300 Subject: [PATCH 09/15] removed raycasting for vehicle alignment removed Lua garbage collection --- game.cpp | 1 - unit.cpp | 16 +--------------- unit.h | 3 ++- vehicle.cpp | 18 ++++++++++++++---- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/game.cpp b/game.cpp index 25183bc..b4d8703 100644 --- a/game.cpp +++ b/game.cpp @@ -49,7 +49,6 @@ namespace battleship{ for(int i = 0; i < getCpuPlayers().size(); i++) { string plStr = "game.cpuPlayers[" + to_string(i + 1) + "]"; SOL_LUA_VIEW.script("executeBtNode(" + plStr + ", " + plStr + ".behaviour)"); - SOL_LUA_VIEW.collect_garbage(); } int numPlayersWithUnits = 0; diff --git a/unit.cpp b/unit.cpp index 70e4537..16452c9 100755 --- a/unit.cpp +++ b/unit.cpp @@ -515,22 +515,8 @@ namespace battleship{ //TODO select only the closest cells based on unit size void Unit::placeAt(Vector3 p){ - Map *map = Map::getSingleton(); - - if(alignToSurface){ - vector res = map->raycastTerrain(Vector3(p.x, 100, p.z), -Vector3::VEC_J, true); - - if(res.empty() || res[0].mesh->getNode() != map->getNodeParent()->getChild(0)) - model->lookAt(Vector3(dirVec.x, 0, dirVec.z).norm(), Vector3::VEC_J); - else if(res[0].mesh->getNode() == map->getNodeParent()->getChild(0)){ - float angle = upVec.getAngleBetween(res[0].norm); - - //if(angle > 0) - model->lookAt(leftVec.cross(res[0].norm), res[0].norm); - } - } - ActiveGameState *activeState = (ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE); + Map *map = Map::getSingleton(); //check twice in case the unit is warped over a long distance if(activeState) map->blockCells(this); diff --git a/unit.h b/unit.h index 0bcf425..d1a58ac 100755 --- a/unit.h +++ b/unit.h @@ -148,9 +148,10 @@ namespace battleship{ sf::SoundBuffer *selectionSfxBuffer; sf::Sound *selectionSfx = nullptr; vb01::Node *losLightNode = nullptr; - bool vehicle, currOrderStarted = false, alignToSurface = false; + bool vehicle, currOrderStarted = false; Condition condition = Condition::ABLE; protected: + bool alignToSurface = false; UnitType type; UnitClass unitClass; std::vector orders; diff --git a/vehicle.cpp b/vehicle.cpp index 4956e6d..7be0c21 100644 --- a/vehicle.cpp +++ b/vehicle.cpp @@ -148,12 +148,16 @@ namespace battleship{ // y = ax + b float a = hypVec.z / hypVec.x; float b = pos.z - a * pos.x; + Vector3 c1 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, true, false); //top left + Vector3 c2 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, true, true); //top right + Vector3 c3 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, false, false); //bottom left + Vector3 c4 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, false, true); //bottom right while(!(sqIds[0] == (int)sqIdsEndVec.x && sqIds[1] == (int)sqIdsEndVec.y)){ - Vector3 c1 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, true, false); //top left - Vector3 c2 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, true, true); //top right - Vector3 c3 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, false, false); //bottom left - Vector3 c4 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, false, true); //bottom right + c1 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, true, false); //top left + c2 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, true, true); //top right + c3 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, false, false); //bottom left + c4 = terrQuad->getSubquadCorner(sqIds[0], sqIds[1], numVertDiv, numHorDiv, false, true); //bottom right float minX = c1.x, maxX = c2.x, minY = c1.z, maxY = c3.z; bool bottom = (hypVec.z > 0), left = (hypVec.x < 0); @@ -208,6 +212,12 @@ namespace battleship{ placeAt(endPos); + if(alignToSurface){ + Vector3 normal = (c3 - c1).norm().cross((c2 - c1).norm()); + float angle = upVec.getAngleBetween(normal); + model->lookAt(leftVec.cross(normal), normal); + } + if(fabs(pathPoints[0].x - pos.x) <= destOffset && fabs(pathPoints[0].z - pos.z) <= destOffset) arrivedAtPathpoint(false); } From 89567b63e3a92ecde40d8ccfc12c30ae74dcfa10 Mon Sep 17 00:00:00 2001 From: devZoGok Date: Sun, 16 Aug 2026 14:16:48 +0300 Subject: [PATCH 10/15] minor changes to accomodate MSVC compilers fixed hack tooltip --- Assets/Scripts/GameObjects/Units/unitData.lua | 21 +++++++++++-------- concreteGuiManager.cpp | 9 +++++--- gameManager.cpp | 3 ++- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/GameObjects/Units/unitData.lua b/Assets/Scripts/GameObjects/Units/unitData.lua index c3058ea..48d8e14 100644 --- a/Assets/Scripts/GameObjects/Units/unitData.lua +++ b/Assets/Scripts/GameObjects/Units/unitData.lua @@ -771,10 +771,11 @@ units = { name = 'Hack', orderType = OrderType.HACK, tooltip = { - size = {x = 200, y = 40}, + size = {x = 220, y = 60}, lines = { - {entry = {text = 'Eject'}}, - {entry = {text = 'Eject all garrisoned units'}}, + {entry = {text = 'Hack'}}, + {entry = {text = 'Hack into a hostile unit'}}, + {entry = {text = 'to turn it over to your side'}}, } } } @@ -867,10 +868,11 @@ units = { name = 'Hack', orderType = OrderType.HACK, tooltip = { - size = {x = 200, y = 40}, + size = {x = 220, y = 60}, lines = { - {entry = {text = 'Eject'}}, - {entry = {text = 'Eject all garrisoned units'}}, + {entry = {text = 'Hack'}}, + {entry = {text = 'Hack into a hostile unit'}}, + {entry = {text = 'to turn it over to your side'}}, } } } @@ -963,10 +965,11 @@ units = { name = 'Hack', orderType = OrderType.HACK, tooltip = { - size = {x = 200, y = 40}, + size = {x = 220, y = 60}, lines = { - {entry = {text = 'Eject'}}, - {entry = {text = 'Eject all garrisoned units'}}, + {entry = {text = 'Hack'}}, + {entry = {text = 'Hack into a hostile unit'}}, + {entry = {text = 'to turn it over to your side'}}, } } } diff --git a/concreteGuiManager.cpp b/concreteGuiManager.cpp index 5df9ca3..12b8d7f 100644 --- a/concreteGuiManager.cpp +++ b/concreteGuiManager.cpp @@ -77,12 +77,15 @@ namespace battleship{ sol::table iconsTbl = lineDataTbl[i + 1]["icons"]; int numIcons = iconsTbl.size(); - for(int j = 0; j < numIcons; j++) - iconsData.push_back(make_pair(iconsTbl[j + 1]["charId"], iconsTbl[j + 1]["path"])); + for(int j = 0; j < numIcons; j++){ + string path = iconsTbl[j + 1]["path"]; + iconsData.push_back(make_pair(iconsTbl[j + 1]["charId"], path)); + } } sol::table entryTbl = lineDataTbl[i + 1]["entry"]; - wstring entry = (wstring)entryTbl["text"]; + string e = entryTbl["text"]; + wstring entry = vb01::stringToWstring(e); Vector4 color = Vector4::VEC_IJKL; sol::optional colorTblOpt = entryTbl["color"]; diff --git a/gameManager.cpp b/gameManager.cpp index d278fe9..b6bfaac 100755 --- a/gameManager.cpp +++ b/gameManager.cpp @@ -266,7 +266,8 @@ namespace battleship{ width = resTable["x"]; height = resTable["y"]; - mainPlayerName = (wstring)SOL_LUA_STATE["multiplayer"]["name"]; + string n = SOL_LUA_STATE["multiplayer"]["name"]; + mainPlayerName = vb01::stringToWstring(n); } void GameManager::start(string gameDir) { From 6f85c9f7dcdfd874c2fb1ffc8bb267a912cfcf60 Mon Sep 17 00:00:00 2001 From: jowen005 Date: Sun, 16 Aug 2026 13:45:59 -0400 Subject: [PATCH 11/15] Removed commented out lines --- activeGameState.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/activeGameState.h b/activeGameState.h index fa6923d..c4659cb 100755 --- a/activeGameState.h +++ b/activeGameState.h @@ -52,7 +52,6 @@ namespace battleship{ inline std::vector getGuiTexts(){return guiTexts;} inline Player* getPlayer(){return mainPlayer;} inline std::unordered_map>& getUnitGroups(){return unitGroups;} // Returns the unitGroups by reference - // inline std::vector& getUnitGroup(int i){return unitGroups[i];} inline void setBuildableStructSelected(bool bss){this->buildableStructSelected = bss;} inline bool isBuildableStructSelected(){return buildableStructSelected;} inline float getDepth(){return depth;} @@ -85,7 +84,6 @@ namespace battleship{ GuiAppState *guiState; GameObject *gameObjHoveredOn = nullptr; vb01::Vector2 clickPoint; - // std::vector unitGroups[10], prevSelectedUnits; std::vector prevSelectedUnits; std::unordered_map> unitGroups; std::vector targets; From d82bef02ba995f4bb5d7ece4c5f33d3debf5a2ff Mon Sep 17 00:00:00 2001 From: jowen005 Date: Mon, 17 Aug 2026 01:38:14 -0400 Subject: [PATCH 12/15] Append Group Correction --- activeGameState.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/activeGameState.cpp b/activeGameState.cpp index 3e90132..7ed345b 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "activeGameState.h" #include "inGameAppState.h" @@ -833,24 +834,18 @@ namespace battleship{ // If there are currently maximum allowed units in existence then do not allow creation of a new unique group, only allow overwritting an existing group if(static_cast(unitGroups.size()) >= maxUnitGroups) { - // See if pendingGroup is equal to any key and overwrite the key if so + // See if pendingGroup is equal to any key and overwrite the key if so. auto it = unitGroups.find(pendingGroup); if(it != unitGroups.end()) { unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); } - // Iterate through all the keys to see if pendingGroup is equal to any key and overwrite the key if so - // for(const auto& [key, value]: unitGroups) - // { - // if(key == pendingGroup) - // { - // unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); - // } - // } // If it can't overwrite then the pendingGroup will just be reset since this will bypass the rest of the if statements } + // Runs if there are not max allowed units in existence else { + // This will create a key if it doesn't already exist unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); } @@ -866,8 +861,6 @@ namespace battleship{ deselectUnits(); mainPlayer->selectUnits(it->second); } - // deselectUnits(); - // mainPlayer->selectUnits(unitGroups[pendingGroup]); } // If shift is pressed then shift plus a number and Q adds the selection to the current group of the existing key else @@ -876,10 +869,21 @@ namespace battleship{ if(it != unitGroups.end()) { mainPlayer->selectUnits(it->second); - unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); + + // Create unordered_set containing unit group to check for duplicates while adding the currently selected units to the groups + std::unordered_set duplicateCheck(unitGroups[pendingGroup].begin(), unitGroups[pendingGroup].end()); + + for(Unit* unit: mainPlayer->getSelectedUnits()) + { + if(duplicateCheck.insert(unit).second) + { + unitGroups[pendingGroup].push_back(unit); + } + } + + // I believe this produces same result but rewrites entire group + // unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); } - // mainPlayer->selectUnits(unitGroups[pendingGroup]); - // unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); } } // Reset the pending group From 124e63b2bc75c1056c640d0d43290ddd16d848f8 Mon Sep 17 00:00:00 2001 From: jowen005 Date: Mon, 17 Aug 2026 01:39:01 -0400 Subject: [PATCH 13/15] update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 13850f8..4295206 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -\build \ No newline at end of file +\build +.vscode/c_cpp_properties.json From 80e14c33aaccd8e153f5ab66a46fd8e6ffcd24e4 Mon Sep 17 00:00:00 2001 From: jowen005 Date: Mon, 17 Aug 2026 01:45:45 -0400 Subject: [PATCH 14/15] Removed comment --- activeGameState.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/activeGameState.cpp b/activeGameState.cpp index 7ed345b..3bb240f 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -880,9 +880,6 @@ namespace battleship{ unitGroups[pendingGroup].push_back(unit); } } - - // I believe this produces same result but rewrites entire group - // unitGroups[pendingGroup] = mainPlayer->getSelectedUnits(); } } } From 139429fc6b5ff99b0529d0a5bb0a65985b3ebb76 Mon Sep 17 00:00:00 2001 From: jowen005 Date: Thu, 20 Aug 2026 00:18:50 -0400 Subject: [PATCH 15/15] Shift Selects Multiple unit groups --- activeGameState.cpp | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/activeGameState.cpp b/activeGameState.cpp index 3bb240f..4f93a41 100755 --- a/activeGameState.cpp +++ b/activeGameState.cpp @@ -852,35 +852,16 @@ namespace battleship{ } else { - // Pressing a number and Q without shifting replaces the unit selection with the unit group for the number pressed - if(!shiftPressed) + auto it = unitGroups.find(pendingGroup); + if(it != unitGroups.end()) { - auto it = unitGroups.find(pendingGroup); - if(it != unitGroups.end()) + // Pressing a number and Q without shifting replaces the unit selection with the unit group for the number pressed + // Pressing shift allows multiple unit groups to be selected + if(!shiftPressed) { deselectUnits(); - mainPlayer->selectUnits(it->second); - } - } - // If shift is pressed then shift plus a number and Q adds the selection to the current group of the existing key - else - { - auto it = unitGroups.find(pendingGroup); - if(it != unitGroups.end()) - { - mainPlayer->selectUnits(it->second); - - // Create unordered_set containing unit group to check for duplicates while adding the currently selected units to the groups - std::unordered_set duplicateCheck(unitGroups[pendingGroup].begin(), unitGroups[pendingGroup].end()); - - for(Unit* unit: mainPlayer->getSelectedUnits()) - { - if(duplicateCheck.insert(unit).second) - { - unitGroups[pendingGroup].push_back(unit); - } - } } + mainPlayer->selectUnits(it->second); } } // Reset the pending group