Merge pull request #189 from devZoGok/ft-187-ability-buttons

Ft 187 ability buttons
This commit is contained in:
devZoGok
2025-04-14 15:51:54 +00:00
committed by GitHub
31 changed files with 883 additions and 205 deletions
+5 -6
View File
@@ -11,7 +11,6 @@ Player.taskForceData = {
Player.taskForces = {}
--TODO use enum-like values instead of literals for order types
--TODO simplify building construction
function Player:buildFort(arguments)
forts = self:getUnitsByClass(UnitClass.FORT, 1)
@@ -47,7 +46,7 @@ function Player:buildFort(arguments)
angle = self.baseDir:getAngleBetween(Vector3:new(0, 0, 1)) * (right and -1 or 1)
fort = GameObjectFactory.createUnit(self, UnitId.FORT, sp, Quaternion:new(angle, Vector3:new(0, 1, 0)), 0)
self:addUnit(fort)
self:issueOrder(1, Vector3:new(0, 0, 0), {Target:new(fort, Vector3:new(0, 0, 0))}, false)
self:issueOrder(OrderType.BUILD, Vector3:new(0, 0, 0), {Target:new(fort, Vector3:new(0, 0, 0))}, false)
return BTNodeResult.RUNNING
end
@@ -85,7 +84,7 @@ function Player:buildStructure(engineer, buildingId, buildPos, buildAngle)
building = GameObjectFactory.createUnit(self, buildingId, buildPos, Quaternion:new(1, 0, 0, 0), 0)
self:addUnit(building)
self:issueOrder(1, Vector3:new(0, 0, 0), {Target:new(building, Vector3:new(0, 0, 0))}, false)
self:issueOrder(OrderType.BUILD, Vector3:new(0, 0, 0), {Target:new(building, Vector3:new(0, 0, 0))}, false)
end
building = self:getUnitsByClass(unitClass, 1)[1]
@@ -156,7 +155,7 @@ function Player:startHarvesting()
self:deselectUnits()
self:selectUnits({harvesters[1]})
self:issueOrder(7, Vector3:new(0, 0, 0), {Target:new(extractor, Vector3:new(0, 0, 0))}, false)
self:issueOrder(OrderType.SUPPLY, Vector3:new(0, 0, 0), {Target:new(extractor, Vector3:new(0, 0, 0))}, false)
return BTNodeResult.SUCCESS
end
@@ -259,7 +258,7 @@ function Player:clearNearEnemies(arguments)
if not taskForce.clearing and targUnit then
self:deselectUnits()
self:selectUnits(taskForce.units)
self:issueOrder(2, Vector3:new(0, 0, 0), {Target:new(targUnit, Vector3:new(0, 0, 0))}, false)
self:issueOrder(OrderType.MOVE, Vector3:new(0, 0, 0), {Target:new(targUnit, Vector3:new(0, 0, 0))}, false)
self.taskForces[arguments.tfId].clearing = true
elseif taskForce.clearing and not targUnit then
@@ -281,7 +280,7 @@ function Player:attackSpawnPoint(arguments)
for i = 1, #taskForce.units do taskForce.units[i]:setState(0) end
enemySpawnPoint = Map.getSingleton():getSpawnPoint(taskForce.spawnPointId)
self:issueOrder(2, Vector3:new(0, 0, 0), {Target:new(nil, enemySpawnPoint)}, false)
self:issueOrder(OrderType.MOVE, Vector3:new(0, 0, 0), {Target:new(nil, enemySpawnPoint)}, false)
self.taskForces[arguments.tfId].attacking = true
return BTNodeResult.RUNNING
+34 -20
View File
@@ -1,4 +1,15 @@
--TYPE = {ATTACK = 0, BUILD = 1, MOVE = 2, GARRISON = 3, EJECT = 4, PATROL = 5, LAUNCH = 6};
OrderType = {
HALT = -1,
ATTACK = 0,
BUILD = 1,
MOVE = 2,
GARRISON = 3,
EJECT = 4,
PATROL = 5,
LAUNCH = 6,
SUPPLY = 7,
HACK = 8
}
UnitId = {
WAR_MECH = 0,
TANK = 1,
@@ -254,15 +265,16 @@ units = {
{type = WeaponClass.HITSCAN, rateOfFire = 2000, fireSfx = PATH .. 'Sounds/Units/WarMechs/fire.ogg', damage = 20, maxRange = 8},
},
buildableUnits = {
{id = UnitId.LAND_FACTORY, buildable = true},
{id = UnitId.NAVAL_FACTORY, buildable = true},
{id = UnitId.TRADE_CENTER, buildable = true},
{id = UnitId.LAB, buildable = true},
{id = UnitId.POINT_DEFENSE, buildable = true},
{id = UnitId.FORT, buildable = true},
{id = UnitId.EXTRACTOR, buildable = true},
{id = UnitId.REFINERY, buildable = true},
{id = UnitId.LAND_FACTORY, buildable = true, trigger = 76},
{id = UnitId.NAVAL_FACTORY, buildable = true, trigger = 78},
{id = UnitId.TRADE_CENTER, buildable = true, trigger = 77},
{id = UnitId.LAB, buildable = true, trigger = 84},
{id = UnitId.POINT_DEFENSE, buildable = true, trigger = 80},
{id = UnitId.FORT, buildable = true, trigger = 70},
{id = UnitId.EXTRACTOR, buildable = true, trigger = 69},
{id = UnitId.REFINERY, buildable = true, trigger = 82},
},
abilityButtons = {{buttonType = ButtonType.ORDER, name = 'Hack', orderType = OrderType.HACK}},
unitClass = UnitClass.ENGINEER,
unitType = UnitType.HOVER,
armor = {ArmorType.MECHANIC},
@@ -280,7 +292,6 @@ units = {
albedoPath = 'engineer.jpg',
colorNodes = {'Cube.008'},
meshPath = 'engineer2.xml',
guiScreen = 'engineerCommands.lua',
selectionSfx = PATH .. 'Sounds/Units/Engineers/selection.ogg',
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
speed = .1,
@@ -342,6 +353,7 @@ units = {
},
{
weapons = {},
abilityButtons = {{buttonType = ButtonType.ORDER, name = 'Supply', orderType = OrderType.SUPPLY}},
unitClass = UnitClass.RESOURCE_ROVER,
unitType = UnitType.HOVER,
armor = {ArmorType.CAST},
@@ -777,10 +789,10 @@ units = {
},
{
buildableUnits = {
{id = UnitId.WAR_MECH, buildable = true},
{id = UnitId.TANK, buildable = true},
{id = UnitId.ARTILLERY, buildable = true},
{id = UnitId.RESOURCE_ROVER, buildable = true}
{id = UnitId.WAR_MECH, buildable = true, trigger = 87},
{id = UnitId.TANK, buildable = true, trigger = 84},
{id = UnitId.ARTILLERY, buildable = true, trigger = 65},
{id = UnitId.RESOURCE_ROVER, buildable = true, trigger = 82}
},
unitClass = UnitClass.LAND_FACTORY,
unitType = UnitType.LAND,
@@ -796,7 +808,6 @@ units = {
albedoPath = 'factory.jpg',
basePath = PATH .. structurePrefix .. 'LandFactories/',
meshPath = 'landFactory.xml',
guiScreen = 'landFactoryCommands.lua',
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
},
@@ -814,13 +825,18 @@ units = {
basePath = PATH .. structurePrefix .. 'NavalFactories/',
meshPath = 'navalFactory.xml',
albedoPath = 'factory.jpg',
guiScreen = 'navalFactoryCommands.lua',
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
},
{
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}
},
isVehicle = false,
health = 500,
buildTime = 1000,
@@ -833,13 +849,13 @@ units = {
basePath = PATH .. structurePrefix .. 'TradeCenters/',
meshPath = 'tradeCenter.xml',
albedoPath = 'tradeCenter.jpg',
guiScreen = 'tradingCenterCommands.lua',
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
},
{
unitClass = UnitClass.LAB,
unitType = UnitType.LAND,
abilityButtons = {{buttonType = ButtonType.ACTIVE_GAME_STATE, name = 'Tech tree', guiScreen = 'techTree.lua'}},
isVehicle = false,
health = 500,
buildTime = 1000,
@@ -855,7 +871,6 @@ units = {
basePath = PATH .. structurePrefix .. 'Labs/',
meshPath = 'lab2.xml',
albedoPath = 'lab.jpg',
guiScreen = 'researchStructCommands.lua',
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
},
@@ -957,7 +972,7 @@ units = {
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
},
{
buildableUnits = {{id = UnitId.ENGINEER, buildable = true}},
buildableUnits = {{id = UnitId.ENGINEER, buildable = true, trigger = 69}},
unitClass = UnitClass.FORT,
unitType = UnitType.LAND,
isVehicle = false,
@@ -972,7 +987,6 @@ units = {
meshPath = 'fort2.xml',
colorNodes = {'Cube.004'},
albedoPath = 'fort.jpg',
guiScreen = 'fortCommands.lua',
selectionSfx = PATH .. 'Sounds/Units/Sample/selection.ogg',
deathSfx = PATH .. 'Sounds/SFX/Explosions/explosion01.ogg',
},
+14 -21
View File
@@ -6,13 +6,18 @@ s = 40
eyeIcon = 'eye.png'
refIcon = 'refineds.png'
minimapSize = {x = 200, y = 200}
minimapPos = {x = res.x - minimapSize.x, y = 0, z = .9}
minimapPos = {x = 0, y = res.y - minimapSize.y, z = .9}
resTextScale = {x = .5, y = .5}
resIconBasePath = 'Icons/Resources/'
pointerTex = 'pointer.png'
attackTex = 'attack.png'
garrisonTex = 'garrison.png'
supplyTex = 'supply.png'
hackTex = 'hack.png'
noGarrisonTex = 'noGarrison.png'
noSupplyTex = 'noSupply.png'
noHackTex = 'noHack.png'
gui = {
{
@@ -38,7 +43,7 @@ gui = {
guiType = GuiType.TEXT,
name = 'wealth',
text = '',
pos = {x = 200 + s, y = s, z = 0},
pos = {x = s, y = 2 * s, z = 0},
scale = resTextScale,
font = 'batang.ttf',
fontFirstChar = 0,
@@ -49,7 +54,7 @@ gui = {
guiType = GuiType.TEXT,
name = 'research',
text = '',
pos = {x = 400 + s, y = s, z = 0},
pos = {x = s, y = 3 * s, z = 0},
scale = resTextScale,
font = 'batang.ttf',
fontFirstChar = 0,
@@ -66,14 +71,14 @@ gui = {
{
guiType = GuiType.GUI_RECTANGLE,
name = 'wealth',
pos = {x = 200, y = 0, z = 0},
pos = {x = 0, y = 1 * s, z = 0},
size = {x = s, y = s},
imagePath = resIconBasePath .. 'wealth.png',
},
{
guiType = GuiType.GUI_RECTANGLE,
name = 'research',
pos = {x = 400, y = 0, z = 0},
pos = {x = 0, y = 2 * s, z = 0},
size = {x = s, y = s},
imagePath = resIconBasePath .. 'research.png',
},
@@ -93,26 +98,14 @@ gui = {
buttonType = ButtonType.PLAYER_TRADE,
name = 'Trade',
guiScreen = 'tradingHub.lua',
pos = {x = res.x - Size.x, y = 200, z = 0},
size = Size,
pos = {x = minimapSize.x, y = res.y - minimapSize.y, z = 0},
size = {x = Size.x, y = minimapSize.y - .75 * sz},
trigger = 10
},
{
guiType = GuiType.GUI_RECTANGLE,
pos = {x = res.x - sz, y = res.y - sz, z = 0},
size = {x = sz, y = sz},
color = {x = .6, y = .6, z = .6, w = .4}
},
{
guiType = GuiType.GUI_RECTANGLE,
pos = {x = 0, y = res.y - sz, z = 0},
size = {x = sz, y = sz},
color = {x = .6, y = .6, z = .6, w = .4}
},
{
guiType = GuiType.GUI_RECTANGLE,
pos = {x = sz, y = res.y - .75 * sz, z = 0},
size = {x = res.x - 2 * sz, y = sz * .75},
pos = {x = minimapPos.x, y = res.y - .75 * sz, z = 0},
size = {x = res.x - minimapPos.x, y = sz * .75},
color = {x = .6, y = .6, z = .6, w = .4}
},
}
+15 -15
View File
@@ -24,21 +24,21 @@ ButtonType = {
MAIN_MENU = 20,
CONSOLE_COMMAND_OK = 21,
BUILD = 22,
LAND_FACTORY_TRAIN = 23,
NAVAL_FACTORY_TRAIN = 24,
FORT_TRAIN = 25,
STATISTICS = 26,
RESEARCH = 27,
BUY_REFINEDS = 28,
SELL_REFINEDS = 29,
BUY_RESEARCH = 30,
SELL_RESEARCH = 31,
ACTIVE_GAME_STATE = 32,
PLAYER_TRADE = 33,
TRADING_SCREEN = 34,
TRADE_OFFER = 35,
RESOURCE_AMMOUNT = 36,
MINIMAP = 37
TRAIN = 23,
STATISTICS = 24,
RESEARCH = 25,
BUY_REFINEDS = 26,
SELL_REFINEDS = 27,
BUY_RESEARCH = 28,
SELL_RESEARCH = 29,
ACTIVE_GAME_STATE = 30,
PLAYER_TRADE = 31,
TRADING_SCREEN = 32,
TRADE_OFFER = 33,
RESOURCE_AMMOUNT = 34,
UNIT_STATE = 35,
ORDER = 36,
MINIMAP = 37,
}
ListboxType = {
@@ -1,39 +0,0 @@
res = graphics.resolution
Size = {x = 70, y = 70}
margin = 10
sz = {x = Size.x - margin, y = Size.y - margin}
gui = {
{
pos = {x = res.x - Size.x, y = res.y - Size.y, z = 0},
size = sz,
name = 'Buy ref',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUY_REFINEDS,
trigger = 73,
},
{
pos = {x = res.x - 2 * Size.x, y = res.y - Size.y, z = 0},
size = sz,
name = 'Sell ref',
guiType = GuiType.BUTTON,
buttonType = ButtonType.SELL_REFINEDS,
trigger = 79,
},
{
pos = {x = res.x - Size.x, y = res.y - 2 * Size.y, z = 0},
size = sz,
name = 'Buy rsch',
guiType = GuiType.BUTTON,
buttonType = ButtonType.BUY_RESEARCH,
trigger = 75,
},
{
pos = {x = res.x - 2 * Size.x, y = res.y - 2 * Size.y, z = 0},
size = sz,
name = 'Sell rsch',
guiType = GuiType.BUTTON,
buttonType = ButtonType.SELL_RESEARCH,
trigger = 76,
}
}
+102
View File
@@ -0,0 +1,102 @@
res = graphics.resolution
sz = 210
resTextScale = {x = .5, y = .5}
buttonInitPos = {x = sz, y = res.y - .65 * sz, z = 0}
buttonSize = {x = 50, y = 50}
buttonSpace = {x = 10, y = 10}
function generateButton(numGui, buttonData)
xOffset = math.floor(.5 * numGui) * (buttonSize.x + buttonSpace.x)
yOffset = (numGui + 1) % 2 == 0 and (buttonSize.y + buttonSpace.y) or 0
button = {
pos = {x = buttonInitPos.x + xOffset, y = buttonInitPos.y + yOffset, z = .5},
size = buttonSize,
guiType = GuiType.BUTTON,
name = buttonData.name,
imagePath = buttonData.imagePath,
buttonType = buttonData.buttonType,
trigger = (buttonData.trigger or -1),
orderType = buttonData.orderType,
factoryId = buttonData.factoryId,
engineerId = buttonData.engineerId,
guiScreen = buttonData.guiScreen,
slotId = buttonData.slotId
}
return button
end
function generateGui(unitId)
local gui = {}
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'}
}
mainUnit = units[unitId + 1]
unitButtonData = mainUnit.isVehicle and vehicleButtonData or structureButtonData
if mainUnit.garrisonCapacity then
unitButtonData[#unitButtonData + 1] = {
buttonType = ButtonType.ORDER,
orderType = OrderType.EJECT,
name = 'Eject'
}
end
for i = 1, #unitButtonData do
gui[#gui + 1] = generateButton(#gui, unitButtonData[i])
end
if mainUnit.abilityButtons then
for i = 1, #mainUnit.abilityButtons do
abilButton = mainUnit.abilityButtons[i]
buttonData = {
trigger = abilButton.trigger,
name = abilButton.name,
buttonType = abilButton.buttonType,
guiScreen = abilButton.guiScreen,
orderType = abilButton.orderType
}
gui[#gui + 1] = generateButton(#gui, buttonData)
end
end
if mainUnit.buildableUnits then
for i = 1, #mainUnit.buildableUnits do
buildUnit = mainUnit.buildableUnits[i]
if not buildUnit.buildable then goto continue end
isFactory = (
mainUnit.unitClass == UnitClass.LAND_FACTORY or
mainUnit.unitClass == UnitClass.NAVAL_FACTORY or
mainUnit.unitClass == UnitClass.FORT
)
buttonData = {
trigger = buildUnit.trigger,
name = units[buildUnit.id + 1].name,
buttonType = (mainUnit.isVehicle and ButtonType.BUILD or ButtonType.TRAIN),
factoryId = (isFactory and unitId or nil),
engineerId = (mainUnit.unitClass == UnitClass.ENGINEER and unitId or nil),
slotId = (ButtonType.BUILD and i - 1 or nil)
}
gui[#gui + 1] = generateButton(#gui, buttonData)
::continue::
end
end
return gui
end
gui = generateGui(_mainUnitId)
Binary file not shown.

After

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 549 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 979 B

+98
View File
@@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg1"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
sodipodi:docname="state.svg"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="0.75900674"
inkscape:cx="229.90573"
inkscape:cy="538.20339"
inkscape:window-width="1918"
inkscape:window-height="1058"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" /><defs
id="defs1"><pattern
inkscape:collect="always"
xlink:href="#invert grid"
preserveAspectRatio="xMidYMid"
id="pattern15"
patternTransform="scale(0.5)"
x="0"
y="0" /><pattern
patternUnits="userSpaceOnUse"
width="12"
height="12"
preserveAspectRatio="xMidYMid"
id="invert grid"
x="0"
y="0"
style="fill:#11a529"
inkscape:label="Inverted grid"
inkscape:collect="always"
inkscape:isstock="true"><rect
style="stroke:none;paint-order:markers fill stroke"
id="rect2-0"
width="10"
height="10"
x="0"
y="0" /></pattern><linearGradient
id="swatch7"
inkscape:swatch="solid"><stop
style="stop-color:#3f3f3f;stop-opacity:1;"
offset="0"
id="stop8" /></linearGradient><inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-2.2804804 : 132.16513 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="210 : 135.28811 : 1"
inkscape:persp3d-origin="102.71952 : 82.665123 : 1"
id="perspective1" /></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"><path
id="rect4"
style="fill:#3f3f3f;fill-rule:evenodd;stroke:#121212;stroke-width:3;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers;fill-opacity:1;stroke-opacity:1;stroke-dasharray:none"
d="M 51.291495,136.05279 H 152.77511 l 32.78747,68.1354 H 18.504013 Z"
sodipodi:nodetypes="ccccc"
inkscape:export-filename="noHack.png"
inkscape:export-xdpi="5.6718144"
inkscape:export-ydpi="5.6718144" /><path
id="rect4-7"
style="fill:url(#pattern15);fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers;fill-opacity:1;stroke-dasharray:none"
d="M 152.77511,136.05279 H 51.291488 L 40.93474,67.91739 h 122.19713 z"
sodipodi:nodetypes="ccccc"
inkscape:export-filename="hack.png"
inkscape:export-xdpi="7.4680233"
inkscape:export-ydpi="7.4680233" /><path
id="path2"
style="display:inline;fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.1;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 102.03357,27.226245 A 111.90711,111.90711 0 0 0 -9.8738159,139.13311 111.90711,111.90711 0 0 0 102.03357,251.04049 111.90711,111.90711 0 0 0 213.94043,139.13311 111.90711,111.90711 0 0 0 102.03357,27.226245 Z m 0,13.79554 A 98.111313,98.111313 0 0 1 200.14489,139.13311 98.111313,98.111313 0 0 1 102.03357,237.24443 98.111313,98.111313 0 0 1 3.9222412,139.13311 98.111313,98.111313 0 0 1 102.03357,41.021785 Z" /><rect
style="display:inline;fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.113265;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect3"
width="222.7867"
height="17.734119"
x="-147.01964"
y="159.95135"
transform="rotate(-48.17088)" /></g></svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg1"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
sodipodi:docname="noGarrison.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="0.53669881"
inkscape:cx="251.53773"
inkscape:cy="472.33196"
inkscape:window-width="1918"
inkscape:window-height="1058"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
<defs
id="defs1" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
id="path1"
style="fill:#0c1fd5;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.56342;stroke-linecap:square;stroke-linejoin:round;stroke-opacity:1;paint-order:stroke fill markers"
inkscape:transform-center-x="1.1131741e-06"
inkscape:transform-center-y="-1.2077841e-06"
d="M 63.749468,51.966222 96.532477,108.74778 H 63.749985 L 95.127397,163.0964 H 63.749985 l 38.283455,66.30965 38.28396,-66.30965 h -31.37792 l 31.37792,-54.34862 h -32.783 l 32.783,-56.781558 z"
inkscape:export-filename="garrison.png"
inkscape:export-xdpi="7.0948467"
inkscape:export-ydpi="7.0948467" />
<path
id="path2"
style="fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.1;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 102.03357 27.226245 A 111.90711 111.90711 0 0 0 -9.8738159 139.13311 A 111.90711 111.90711 0 0 0 102.03357 251.04049 A 111.90711 111.90711 0 0 0 213.94043 139.13311 A 111.90711 111.90711 0 0 0 102.03357 27.226245 z M 102.03357 41.021785 A 98.111313 98.111313 0 0 1 200.14489 139.13311 A 98.111313 98.111313 0 0 1 102.03357 237.24443 A 98.111313 98.111313 0 0 1 3.9222412 139.13311 A 98.111313 98.111313 0 0 1 102.03357 41.021785 z " />
<rect
style="fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.113265;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect3"
width="222.7867"
height="17.734119"
x="-147.01964"
y="159.95135"
transform="rotate(-48.17088)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

+92
View File
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg1"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
sodipodi:docname="noHack.svg"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="0.75900674"
inkscape:cx="324.76655"
inkscape:cy="560.60109"
inkscape:window-width="1918"
inkscape:window-height="1058"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" /><defs
id="defs1"><pattern
inkscape:collect="always"
xlink:href="#invert grid"
preserveAspectRatio="xMidYMid"
id="pattern15"
patternTransform="scale(0.5)"
x="0"
y="0" /><pattern
patternUnits="userSpaceOnUse"
width="12"
height="12"
preserveAspectRatio="xMidYMid"
id="invert grid"
x="0"
y="0"
style="fill:#11a529"
inkscape:label="Inverted grid"
inkscape:collect="always"
inkscape:isstock="true"><rect
style="stroke:none;paint-order:markers fill stroke"
id="rect2-0"
width="10"
height="10"
x="0"
y="0" /></pattern><linearGradient
id="swatch7"
inkscape:swatch="solid"><stop
style="stop-color:#3f3f3f;stop-opacity:1;"
offset="0"
id="stop8" /></linearGradient><inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-2.2804804 : 132.16513 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="210 : 135.28811 : 1"
inkscape:persp3d-origin="102.71952 : 82.665123 : 1"
id="perspective1" /></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"><path
id="rect4"
style="fill:#3f3f3f;fill-rule:evenodd;stroke:#121212;stroke-width:3;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers;fill-opacity:1;stroke-opacity:1;stroke-dasharray:none"
d="M 51.291495,136.05279 H 152.77511 l 32.78747,68.1354 H 18.504013 Z"
sodipodi:nodetypes="ccccc" /><path
id="rect4-7"
style="fill:url(#pattern15);fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers;fill-opacity:1;stroke-dasharray:none"
d="M 152.77511,136.05279 H 51.291488 L 40.93474,67.91739 h 122.19713 z"
sodipodi:nodetypes="ccccc" /><path
id="path2"
style="display:inline;fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.1;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 102.03357,27.226245 A 111.90711,111.90711 0 0 0 -9.8738159,139.13311 111.90711,111.90711 0 0 0 102.03357,251.04049 111.90711,111.90711 0 0 0 213.94043,139.13311 111.90711,111.90711 0 0 0 102.03357,27.226245 Z m 0,13.79554 A 98.111313,98.111313 0 0 1 200.14489,139.13311 98.111313,98.111313 0 0 1 102.03357,237.24443 98.111313,98.111313 0 0 1 3.9222412,139.13311 98.111313,98.111313 0 0 1 102.03357,41.021785 Z" /><rect
style="display:inline;fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.113265;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect3"
width="222.7867"
height="17.734119"
x="-147.01964"
y="159.95135"
transform="rotate(-48.17088)" /></g></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg1"
inkscape:version="1.4 (e7c3feb100, 2024-10-09)"
sodipodi:docname="noSupply.svg"
xml:space="preserve"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
id="namedview1"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
inkscape:zoom="0.53669881"
inkscape:cx="251.53773"
inkscape:cy="472.33196"
inkscape:window-width="1918"
inkscape:window-height="1058"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" /><defs
id="defs1"><inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="-2.2804804 : 132.16513 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="210 : 135.28811 : 1"
inkscape:persp3d-origin="102.71952 : 82.665123 : 1"
id="perspective1" /></defs><g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"><g
inkscape:label="Layer 1"
id="layer1-2"
transform="matrix(2.8225892,0,0,2.8225892,-241.26587,-131.88818)"><path
id="rect61"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 95.470299,96.005376 h 4.572571 l 7.72779,9.348274 H 87.742509 Z"
sodipodi:nodetypes="ccccc"
inkscape:export-filename="refineds.png"
inkscape:export-xdpi="100.52969"
inkscape:export-ydpi="100.52969" /><path
id="rect61-0"
style="fill:#ababab;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 100.33197,96.005374 26.97968,-5.992591 7.75676,9.844057 -27.31132,5.49681 z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-0-5"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 95.470299,96.005376 25.987121,-6.137336 6.00556,0.144743 -27.28234,5.992591 z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-5"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 115.96685,96.005377 h 4.57257 l 7.72779,9.348273 h -20.02815 z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-0-6"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 120.82852,96.005375 26.97968,-5.992591 7.75676,9.844057 -27.31132,5.496809 z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-0-5-9"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 115.96685,96.005377 25.98712,-6.137336 6.00556,0.144743 -27.28234,5.992591 z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-5-5"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 105.19985,86.624821 h 4.57257 l 7.72779,9.348273 H 97.472059 Z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-0-6-2"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 110.06152,86.624819 26.97968,-5.992591 7.75676,9.844057 -27.31132,5.496809 z"
sodipodi:nodetypes="ccccc" /><path
id="rect61-0-5-9-5"
style="fill:#dddddd;fill-rule:evenodd;stroke:#000000;stroke-width:0.4;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="m 105.19985,86.624821 25.98712,-6.137336 6.00556,0.144743 -27.28234,5.992591 z"
sodipodi:nodetypes="ccccc" /></g><path
id="path2"
style="fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.1;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
d="M 102.03357 27.226245 A 111.90711 111.90711 0 0 0 -9.8738159 139.13311 A 111.90711 111.90711 0 0 0 102.03357 251.04049 A 111.90711 111.90711 0 0 0 213.94043 139.13311 A 111.90711 111.90711 0 0 0 102.03357 27.226245 z M 102.03357 41.021785 A 98.111313 98.111313 0 0 1 200.14489 139.13311 A 98.111313 98.111313 0 0 1 102.03357 237.24443 A 98.111313 98.111313 0 0 1 3.9222412 139.13311 A 98.111313 98.111313 0 0 1 102.03357 41.021785 z " /><rect
style="fill:#f21104;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:0.113265;stroke-linecap:square;stroke-linejoin:round;paint-order:stroke fill markers"
id="rect3"
width="222.7867"
height="17.734119"
x="-147.01964"
y="159.95135"
transform="rotate(-48.17088)" /></g></svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

+1 -1
View File
@@ -15,7 +15,7 @@ set(BUILD_TESTS ON)
set(BUILD_SHARED_LIBS OFF CACHE BOOL FORCED)
cmake_policy(SET CMP0015 NEW)
set(UNIT_BUTTONS unitButton.cpp tradeButton.cpp buildButton.cpp trainButton.cpp researchButton.cpp)
set(UNIT_BUTTONS unitButton.cpp tradeButton.cpp buildButton.cpp trainButton.cpp researchButton.cpp orderButton.cpp stateToggleButton.cpp)
set(OPTIONS_BUTTONS optionsButton.cpp tabButton.cpp okButton.cpp defaultsButton.cpp)
set(TRADING_BUTTONS playerTradeButton.cpp tradingScreenButton.cpp offerButton.cpp resourceAmmountButton.cpp)
set(MENU_BUTTONS mainMenuButton.cpp singlePlayerButton.cpp exitButton.cpp backButton.cpp playButton.cpp)
+120 -37
View File
@@ -27,6 +27,9 @@
#include "gameObjectFrameController.h"
#include "gameObjectFactory.h"
#include "cameraController.h"
#include "unitButton.h"
#include "extractor.h"
#include "resourceDeposit.h"
#include "concreteGuiManager.h"
using namespace vb01;
@@ -74,12 +77,27 @@ namespace battleship{
string pt = SOL_LUA_VIEW["pointerTex"],
at = SOL_LUA_VIEW["attackTex"],
gt = SOL_LUA_VIEW["garrisonTex"],
st = SOL_LUA_VIEW["supplyTex"],
ht = SOL_LUA_VIEW["hackTex"],
ngt = SOL_LUA_VIEW["noGarrisonTex"],
nst = SOL_LUA_VIEW["noSupplyTex"],
nht = SOL_LUA_VIEW["noHackTex"],
p1[]{basePath + pt},
p2[]{basePath + at},
p3[]{basePath + gt};
p3[]{basePath + gt},
p4[]{basePath + st},
p5[]{basePath + ht},
p6[]{basePath + ngt},
p7[]{basePath + nst},
p8[]{basePath + nht};
pointerTex = new Texture(p1, 1, false);
attackTex = new Texture(p2, 1, false);
garrisonTex = new Texture(p3, 1, false);
supplyTex = new Texture(p4, 1, false);
hackTex = new Texture(p5, 1, false);
noGarrisonTex = new Texture(p6, 1, false);
noSupplyTex = new Texture(p7, 1, false);
noHackTex = new Texture(p8, 1, false);
Root *root = Root::getSingleton();
Material *mat = new Material(root->getLibPath() + "gui");
@@ -114,13 +132,52 @@ namespace battleship{
Vector2 cursorPos = getCursorPos();
cursorNode->setPosition(Vector3(cursorPos.x, cursorPos.y, .8));
bool canSelect = canSelectHoveredOnGameObj();
bool ownGameObj = (gameObjHoveredOn && gameObjHoveredOn->getPlayer()->getTeam() == mainPlayer->getTeam());
if(mainPlayer->getNumSelectedUnits() > 0){
bool ownGameObj = (gameObjHoveredOn && gameObjHoveredOn->getPlayer()->getTeam() == mainPlayer->getTeam());
bool gameObjUnit = (gameObjHoveredOn && gameObjHoveredOn->getType() == GameObject::Type::UNIT);
bool gameObjTransport = (gameObjUnit && ((Unit*)gameObjHoveredOn)->getNumGarrisonSlots() > 0);
bool canGarrison = true;
if(controlPressed || (gameObjHoveredOn && !ownGameObj && gameObjHoveredOn->getType() == GameObject::Type::UNIT))
cursorState = CursorState::ATTACK;
else
cursorState = CursorState::NORMAL;
if(gameObjUnit && gameObjTransport)
for(int i = 0; i < mainPlayer->getNumSelectedUnits(); i++)
if(!((Unit*)gameObjHoveredOn)->canGarrison((Vehicle*)mainPlayer->getSelectedUnit(i))){
canGarrison = false;
break;
}
bool supply = (
gameObjUnit &&
((Unit*)gameObjHoveredOn)->getUnitClass() == UnitClass::EXTRACTOR &&
mainPlayer->getSelectedUnit(0)->getUnitClass() == UnitClass::RESOURCE_ROVER
);
if(!forceCursorState){
if(gameObjUnit && gameObjTransport){
orderPossible = (ownGameObj && canGarrison);
cursorState = CursorState::GARRISON;
}
else if(supply){
orderPossible = (ownGameObj && ((Extractor*)gameObjHoveredOn)->getDeposit()->getAmmount());
cursorState = CursorState::SUPPLY;
}
else if(gameObjUnit && !ownGameObj)
cursorState = CursorState::ATTACK;
else
cursorState = CursorState::NORMAL;
}
else{
if(cursorState == CursorState::GARRISON)
orderPossible = (ownGameObj && gameObjTransport && canGarrison);
else if(cursorState == CursorState::SUPPLY)
orderPossible = (ownGameObj && supply && ((Extractor*)gameObjHoveredOn)->getDeposit()->getAmmount());
else if(cursorState == CursorState::HACK)
orderPossible = (!ownGameObj && gameObjUnit && mainPlayer->getSelectedUnit(0)->getUnitClass() == UnitClass::ENGINEER);
else if(gameObjUnit)
cursorState = CursorState::ATTACK;
else
cursorState = CursorState::NORMAL;
}
}
cursorNode->setVisible(cursorState != CursorState::NORMAL);
Texture *tex = nullptr;
@@ -130,7 +187,13 @@ namespace battleship{
tex = attackTex;
break;
case CursorState::GARRISON:
tex = garrisonTex;
tex = (orderPossible ? garrisonTex : noGarrisonTex);
break;
case CursorState::SUPPLY:
tex = (orderPossible ? supplyTex : noSupplyTex);
break;
case CursorState::HACK:
tex = (orderPossible ? hackTex : noHackTex);
break;
}
@@ -182,6 +245,13 @@ namespace battleship{
renderUnits();
vector<Unit*> currSelectedUnits = mainPlayer->getSelectedUnits();
if(prevSelectedUnits != currSelectedUnits){
addUnitGui();
prevSelectedUnits = currSelectedUnits;
}
if(fc->isRotating() || fc->isPlacingOnSurface() || fc->isPlacingVertically())
fc->update();
@@ -351,14 +421,6 @@ namespace battleship{
if(!u->getLosLightNode()) u->initLosLight();
model->setVisible(true);
Vector2 pos = u->getScreenPos();
string guiScreen = u->getGuiScreen();
if(!selUnits.empty() && u == selUnits[0] && guiScreen != "" && guiScreen != unitGuiScreen){
guiManager->readLuaScreenScript(u->getGuiScreen(), buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
unitGuiScreen = guiScreen;
}
}
else{
if(u->getLosLightNode()) u->destroyLosLight();
@@ -435,6 +497,7 @@ namespace battleship{
}
mainPlayer->issueOrder(type, destDir, targets, addOrder);
forceCursorState = false;
this->targets.clear();
}
@@ -457,6 +520,24 @@ namespace battleship{
for(Unit *unit : selectedUnits)
unit->setState(state);
}
void ActiveGameState::addUnitGui(){
vector<Unit*> currSelectedUnits = mainPlayer->getSelectedUnits();
if(currSelectedUnits.empty()) return;
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
sol::state_view SOL_LUA_VIEW = generateView();
SOL_LUA_VIEW.script("_mainUnitId = " + to_string(currSelectedUnits[0]->getId()));
guiManager->readLuaScreenScriptDel("unitGui.lua", unitButtons);
SOL_LUA_VIEW.script("numGui = #gui");
int numButtons = SOL_LUA_VIEW["numGui"];
for(int i = 0; i < numButtons; i++)
unitButtons.push_back(guiManager->getButtons()[guiManager->getButtons().size() - (i + 1)]);
}
void ActiveGameState::onAction(int bind, bool isPressed) {
GameObjectFrameController *ufCtr = GameObjectFrameController::getSingleton();
@@ -523,29 +604,25 @@ namespace battleship{
}
}
else if(!isSelectionBox){
bool canSelect = canSelectHoveredOnGameObj();
bool ownGameObj = (gameObjHoveredOn && gameObjHoveredOn->getPlayer()->getTeam() == mainPlayer->getTeam());
if(gameObjHoveredOn && gameObjHoveredOn->getType() == GameObject::Type::UNIT && ownGameObj && ((Unit*)gameObjHoveredOn)->getNumGarrisonSlots() > 0){
bool canGarrison = true;
for(int i = 0; i < mainPlayer->getNumSelectedUnits(); i++)
if(!((Unit*)gameObjHoveredOn)->canGarrison((Vehicle*)mainPlayer->getSelectedUnit(i))){
canGarrison = false;
break;
}
if(canGarrison)
issueOrder(Order::TYPE::GARRISON, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn, gameObjHoveredOn->getPos())}, shiftPressed);
if(cursorState == CursorState::GARRISON){
if(orderPossible) issueOrder(Order::TYPE::GARRISON, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn, gameObjHoveredOn->getPos())}, shiftPressed);
}
else if(gameObjHoveredOn && ownGameObj && ((Unit*)gameObjHoveredOn)->getUnitClass() == UnitClass::EXTRACTOR && !controlPressed){
issueOrder(Order::TYPE::SUPPLY, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn)}, shiftPressed);
else if(cursorState == CursorState::SUPPLY){
if(orderPossible) issueOrder(Order::TYPE::SUPPLY, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn)}, shiftPressed);
}
else if(gameObjHoveredOn && (controlPressed || (!ownGameObj && gameObjHoveredOn->getType() == GameObject::Type::UNIT)))
issueOrder(Order::TYPE::ATTACK, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn, gameObjHoveredOn->getPos())}, shiftPressed);
else if(controlPressed && !gameObjHoveredOn){
castRayToTerrain();
issueOrder(Order::TYPE::ATTACK, targets, shiftPressed);
else if(cursorState == CursorState::ATTACK){
if(controlPressed && !gameObjHoveredOn){
castRayToTerrain();
issueOrder(Order::TYPE::ATTACK, targets, shiftPressed);
}
else{
if(orderPossible) issueOrder(Order::TYPE::ATTACK, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn, gameObjHoveredOn->getPos())}, shiftPressed);
}
}
else if(cursorState == CursorState::HACK){
if(orderPossible) issueOrder(Order::TYPE::HACK, vector<Order::Target>{Order::Target((Unit*)gameObjHoveredOn)}, shiftPressed);
}
else if(selectedUnits[0]->getUnitClass() == UnitClass::ENGINEER && ufCtr->isPlacingOnSurface()){
castRayToTerrain();
@@ -561,7 +638,7 @@ namespace battleship{
buildableStructSelected = false;
}
else if(!canSelect){
else if(!canSelectHoveredOnGameObj()){
if(targets.empty()) castRayToTerrain();
issueOrder(Order::TYPE::MOVE, targets, shiftPressed);
@@ -591,6 +668,7 @@ namespace battleship{
}
break;
/*
case Bind::HACK:
if(isPressed){
if(gameObjHoveredOn && gameObjHoveredOn->getType() == GameObject::Type::UNIT && gameObjHoveredOn->getPlayer()->getTeam() != mainPlayer->getTeam())
@@ -598,6 +676,7 @@ namespace battleship{
break;
}
*/
case Bind::SHIFT_SUB_DEPTH:
ufCtr->toggleFrameTransformations(false, false, isPressed);
break;
@@ -626,7 +705,10 @@ namespace battleship{
break;
//TODO reimplement submarine diving mechanic
case Bind::LEFT_CONTROL:
controlPressed = isPressed;
if(isPressed) cursorState = CursorState::ATTACK;
forceCursorState = isPressed;
controlPressed = isPressed;
break;
case Bind::LEFT_SHIFT:
{
@@ -676,6 +758,7 @@ namespace battleship{
break;
case Bind::DESELECT_STRUCTURE:
forceCursorState = false;
buildableStructSelected = false;
ufCtr->toggleFrameTransformations(false, false, false);
ufCtr->removeGameObjectFrames();
+20 -10
View File
@@ -19,9 +19,19 @@ namespace vb01Gui{
namespace battleship{
class GameObject;
class Unit;
class UnitButton;
class ActiveGameState : public gameBase::AbstractAppState {
public:
enum CursorState{
NORMAL,
ATTACK,
GARRISON,
SUPPLY,
HACK
};
ActiveGameState(GuiAppState*, int);
~ActiveGameState();
void onAttached();
@@ -30,6 +40,8 @@ namespace battleship{
void onAction(int, bool);
void onAnalog(int, float);
void onRawMouseWheelScroll(bool);
inline CursorState getCursorState(){return cursorState;}
inline void setCursorState(CursorState cs){this->cursorState = cs;}
inline void addButton(vb01Gui::Button *b){buttons.push_back(b);}
inline std::vector<vb01Gui::Button*> getButtons(){return buttons;}
inline Player* getPlayer(){return mainPlayer;}
@@ -37,14 +49,9 @@ namespace battleship{
inline void setBuildableStructSelected(bool bss){this->buildableStructSelected = bss;}
inline bool isBuildableStructSelected(){return buildableStructSelected;}
inline float getDepth(){return depth;}
inline void setForceCursorState(bool force){this->forceCursorState = force;}
inline bool isForceCursorState(){return forceCursorState;}
private:
enum CursorState{
NORMAL,
ATTACK,
GARRISON,
SUPPLY
};
bool selectedUnitsAmongst(std::vector<Unit*>);
void updateGameObjHoveredOn();
void initCursor();
@@ -60,6 +67,7 @@ namespace battleship{
void issueOrder(Order::TYPE, std::vector<Order::Target>, bool);
bool isInLineOfSight(vb01::Vector3, float, Unit*);
void enableUnitState(Unit::State);
void addUnitGui();
inline bool canSelectHoveredOnGameObj(){return gameObjHoveredOn && gameObjHoveredOn->isSelectable() && gameObjHoveredOn->getPlayer() == mainPlayer;}
CursorState cursorState = CursorState::NORMAL;
@@ -69,9 +77,9 @@ namespace battleship{
GameObject *gameObjHoveredOn = nullptr;
vb01::Node *dragboxNode = nullptr;
vb01::Vector2 clickPoint;
std::vector<Unit*> unitGroups[9];
std::vector<Unit*> unitGroups[9], prevSelectedUnits;
std::vector<Order::Target> targets;
std::vector<vb01Gui::Button*> buttons;
std::vector<vb01Gui::Button*> buttons, unitButtons;
bool isSelectionBox = false;
bool shiftPressed = false;
bool controlPressed = false;
@@ -80,12 +88,14 @@ namespace battleship{
bool buildableStructSelected = false;
bool selectingPatrolPoints = false;
bool selectingDestOrient = false;
bool forceCursorState = false;
bool orderPossible = false;
int playerId, zooms = 0;
const int NUM_MAX_ZOOMS = 10;
float depth = 1;
vb01::s64 lastSelectMouseClicked = 0, lastOrderMouseClicked = 0;
vb01::Node *cursorNode = nullptr;
vb01::Texture *pointerTex = nullptr, *attackTex = nullptr, *garrisonTex = nullptr;
vb01::Texture *pointerTex = nullptr, *attackTex = nullptr, *garrisonTex = nullptr, *noGarrisonTex = nullptr, *supplyTex = nullptr, *noSupplyTex = nullptr, *hackTex = nullptr, *noHackTex = nullptr;
};
}
+1 -19
View File
@@ -27,24 +27,6 @@ namespace battleship{
}
void ActiveStateButton::onClick(){
ConcreteGuiManager *guiManager = ConcreteGuiManager::getSingleton();
vector<Listbox*> listboxes{};
vector<Checkbox*> checkboxes{};
vector<Slider*> sliders{};
vector<Textbox*> textboxes{};
vector<Node*> guiRects{
guiManager->getGuiRectangle("refineds"),
guiManager->getGuiRectangle("wealth"),
guiManager->getGuiRectangle("research"),
};
vector<Text*> texts{
guiManager->getText("depth"),
guiManager->getText("refineds"),
guiManager->getText("wealth"),
guiManager->getText("research")
};
guiManager->readLuaScreenScript(guiScreen, buttons, listboxes, checkboxes, sliders, textboxes, guiRects, texts);
ConcreteGuiManager::getSingleton()->parseLuaScript(guiScreen);
}
}
+36 -31
View File
@@ -3,6 +3,7 @@
#include <quad.h>
#include "concreteGuiManager.h"
#include "unit.h"
#include "gameManager.h"
#include "singlePlayerButton.h"
#include "mapEditorButton.h"
@@ -32,6 +33,8 @@
#include "tradingScreenButton.h"
#include "offerButton.h"
#include "resourceAmmountButton.h"
#include "orderButton.h"
#include "stateToggleButton.h"
#include "minimapButton.h"
namespace battleship{
@@ -181,37 +184,11 @@ namespace battleship{
break;
}
case BUILD:
{
int unitId = SOL_LUA_STATE["UnitId"]["ENGINEER"];
int strId = SOL_LUA_STATE["units"][unitId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][strId + 1]["name"];
button = new BuildButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, unitId, guiId);
button = new BuildButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["engineerId"], (int)guiTable["slotId"]);
break;
}
case LAND_FACTORY_TRAIN:
{
int facId = SOL_LUA_STATE["UnitId"]["LAND_FACTORY"];
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, facId, guiId);
case TRAIN:
button = new TrainButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["factoryId"], (int)guiTable["slotId"]);
break;
}
case NAVAL_FACTORY_TRAIN:
{
int facId = SOL_LUA_STATE["UnitId"]["NAVAL_FACTORY"];
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, facId, guiId);
break;
}
case FORT_TRAIN:
{
int facId = SOL_LUA_STATE["UnitId"]["FORT"];
int unitId = SOL_LUA_STATE["units"][facId + 1]["buildableUnits"][guiId + 1]["id"];
string buttonName = SOL_LUA_STATE["units"][unitId + 1]["name"];
button = new TrainButton(pos, size, buttonName, (int)guiTable["trigger"], imagePath, facId, guiId);
break;
}
case STATISTICS:
button = new StatsButton(pos, size, name, (int)guiTable["trigger"], imagePath);
break;
@@ -252,6 +229,12 @@ namespace battleship{
case RESOURCE_AMMOUNT:
button = new ResourceAmmountButton(pos, size, name, (int)guiTable["ammount"], (int)guiTable["trigger"], imagePath);
break;
case ORDER:
button = new OrderButton(pos, size, name, (int)guiTable["trigger"], imagePath, (int)guiTable["orderType"]);
break;
case UNIT_STATE:
button = new StateToggleButton(pos, size, name, (int)guiTable["trigger"], imagePath);
break;
case MINIMAP:{
string minimapPath = GameManager::getSingleton()->getPath() + "Models/Maps/" + Map::getSingleton()->getMapName() + "/minimap.jpg";
button = new MinimapButton(pos, size, minimapPath);
@@ -547,10 +530,32 @@ namespace battleship{
vector<Checkbox*> checkboxExceptions,
vector<Slider*> sliderExceptions,
vector<Textbox*> textboxExceptions,
vector<Node*> guiRecttboxExceptions,
vector<Node*> guiRectboxExceptions,
vector<Text*> textExceptions
){
removeAllGuiElements(buttonExceptions, listboxExceptions, checkboxExceptions, sliderExceptions, textboxExceptions, guiRecttboxExceptions, textExceptions);
removeAllGuiElements(buttonExceptions, listboxExceptions, checkboxExceptions, sliderExceptions, textboxExceptions, guiRectboxExceptions, textExceptions);
guiElements.clear();
parseLuaScript(script);
}
void ConcreteGuiManager::readLuaScreenScriptDel(
string script,
vector<Button*> buttons,
vector<Listbox*> listboxs,
vector<Checkbox*> checkboxs,
vector<Slider*> sliders,
vector<Textbox*> textboxs,
vector<Node*> guiRectboxs,
vector<Text*> texts
){
for(Button *b : buttons) removeButton(b);
for(Listbox *l : listboxs) removeListbox(l);
for(Checkbox *c : checkboxs) removeCheckbox(c);
for(Slider *s : sliders) removeSlider(s);
for(Textbox *t : textboxs) removeTextbox(t);
for(Node *r : guiRectboxs) removeGuiRectangle(r);
for(Text *t : texts) removeText(t);
guiElements.clear();
parseLuaScript(script);
}
+13 -3
View File
@@ -38,9 +38,7 @@ namespace battleship{
MAIN_MENU,
CONSOLE_COMMAND_OK,
BUILD,
LAND_FACTORY_TRAIN,
NAVAL_FACTORY_TRAIN,
FORT_TRAIN,
TRAIN,
STATISTICS,
RESEARCH,
BUY_REFINEDS,
@@ -52,6 +50,8 @@ namespace battleship{
TRADING_SCREEN,
TRADE_OFFER,
RESOURCE_AMMOUNT,
UNIT_STATE,
ORDER,
MINIMAP
};
enum ListboxType {
@@ -84,6 +84,16 @@ namespace battleship{
std::vector<vb01::Node*> = std::vector<vb01::Node*>{},
std::vector<vb01::Text*> = std::vector<vb01::Text*>{}
);
void readLuaScreenScriptDel(
std::string,
std::vector<vb01Gui::Button*> = std::vector<vb01Gui::Button*>{},
std::vector<vb01Gui::Listbox*> = std::vector<vb01Gui::Listbox*>{},
std::vector<vb01Gui::Checkbox*> = std::vector<vb01Gui::Checkbox*>{},
std::vector<vb01Gui::Slider*> = std::vector<vb01Gui::Slider*>{},
std::vector<vb01Gui::Textbox*> = std::vector<vb01Gui::Textbox*>{},
std::vector<vb01::Node*> = std::vector<vb01::Node*>{},
std::vector<vb01::Text*> = std::vector<vb01::Text*>{}
);
void parseLuaScript(std::string);
private:
ConcreteGuiManager();
+1 -1
+1 -1
View File
@@ -100,7 +100,7 @@ namespace battleship{
void InGameAppState::onAction(int bind, bool isPressed) {
switch((Bind)bind){
case Bind::TOGGLE_MAIN_MENU:
if(isPressed && !GameObjectFrameController::getSingleton()->isPlacingOnSurface())
if(isPressed && !(GameObjectFrameController::getSingleton()->isPlacingOnSurface() || activeState->isForceCursorState()))
Game::getSingleton()->togglePause();
break;
}
+63
View File
@@ -0,0 +1,63 @@
#include "orderButton.h"
#include "gameManager.h"
#include "activeGameState.h"
#include "player.h"
#include "unit.h"
#include <stateManager.h>
namespace battleship{
using namespace std;
using namespace vb01;
using namespace vb01Gui;
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),
orderId(oid)
{}
void OrderButton::onClick(){
ActiveGameState *activeState = ((ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE));
Player *player = activeState->getPlayer();
vector<Unit*> units = player->getSelectedUnits();
if(orderId > -1){
switch(Order::TYPE(orderId)){
case Order::TYPE::EJECT:
{
for(Unit *unit : units)
unit->receiveOrder(Order(Order::TYPE::EJECT, vector<Order::Target>{}), false);
break;
}
default:
{
ActiveGameState::CursorState cs;
switch((Order::TYPE)orderId){
case Order::TYPE::ATTACK:
cs = ActiveGameState::CursorState::ATTACK;
break;
case Order::TYPE::GARRISON:
cs = ActiveGameState::CursorState::GARRISON;
break;
case Order::TYPE::SUPPLY:
cs = ActiveGameState::CursorState::SUPPLY;
break;
case Order::TYPE::HACK:
cs = ActiveGameState::CursorState::HACK;
break;
}
activeState->setCursorState(cs);
activeState->setForceCursorState(true);
break;
}
}
}
else
for(Unit *unit : units)
unit->halt();
}
}
+16
View File
@@ -0,0 +1,16 @@
#ifndef ORDER_BUTTON_H
#define ORDER_BUTTON_H
#include <button.h>
namespace battleship{
class OrderButton : public vb01Gui::Button{
public:
OrderButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string, int);
void onClick();
private:
int orderId;
};
}
#endif
+71
View File
@@ -0,0 +1,71 @@
#include "stateToggleButton.h"
#include "gameManager.h"
#include "activeGameState.h"
#include "player.h"
#include "unit.h"
#include <stateManager.h>
namespace battleship{
using namespace std;
using namespace vb01;
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) {
updateStateId();
toggleImage();
}
void StateToggleButton::updateStateId(){
const int NUM_STATES = 3;
int numUnitsByState[NUM_STATES]{0, 0, 0};
Player *player = ((ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE))->getPlayer();
vector<Unit*> units = player->getSelectedUnits();
for(Unit *unit : units)
numUnitsByState[(int)unit->getState()]++;
int maxId = 0, maxNum = numUnitsByState[maxId];
for(int i = 0; i < NUM_STATES; i++)
if(maxNum < numUnitsByState[i]){
maxId = i;
maxNum = numUnitsByState[maxId];
}
currStateId = maxId;
}
void StateToggleButton::toggleImage(){
string imgPath = "";
switch(Unit::State(currStateId)){
case Unit::State::HOLD_FIRE:
imgPath = "holdFire.png";
break;
case Unit::State::CHASE:
imgPath = "chase.png";
break;
case Unit::State::STAND_GROUND:
imgPath = "standGround.png";
break;
}
setImage(GameManager::getSingleton()->getPath() + "Textures/Icons/Buttons/" + imgPath);
}
void StateToggleButton::onClick(){
const int NUM_STATES = 3;
Unit::State nextState = (currStateId + 1 == NUM_STATES ? Unit::State(0) : Unit::State(currStateId + 1));
Player *player = ((ActiveGameState*)GameManager::getSingleton()->getStateManager()->getAppStateByType(AppStateType::ACTIVE_STATE))->getPlayer();
vector<Unit*> units = player->getSelectedUnits();
for(Unit *unit : units) unit->setState(nextState);
updateStateId();
toggleImage();
}
}
+19
View File
@@ -0,0 +1,19 @@
#ifndef STATE_TOGGLE_BUTTON_H
#define STATE_TOGGLE_BUTTON_H
#include <button.h>
namespace battleship{
class StateToggleButton : public vb01Gui::Button{
public:
StateToggleButton(vb01::Vector3, vb01::Vector2, std::string, int, std::string);
void onClick();
private:
void updateStateId();
void toggleImage();
int currStateId, x;
};
}
#endif
+2 -1
View File
@@ -53,7 +53,7 @@ namespace battleship{
std::vector<Target> targets;
Order(){}
Order(TYPE t, std::vector<Target> targ, vb01::Vector3 dir, int lid = -1, bool pa = true) : type(t), playerAssigned(pa), lineId(lid), targets(targ), direction(dir){}
Order(TYPE t, std::vector<Target> targ, vb01::Vector3 dir = vb01::Vector3::VEC_ZERO, int lid = -1, bool pa = true) : type(t), playerAssigned(pa), lineId(lid), targets(targ), direction(dir){}
};
enum class MoveDir {LEFT, UP, FORW};
@@ -138,6 +138,7 @@ namespace battleship{
void initLosLight();
void destroyLosLight();
inline void setState(State s){state = s;}
inline State getState(){return state;}
inline Engineer* toEngineer(){return (Engineer*)this;}
inline Structure* toStructure(){return (Structure*)this;}
inline Factory* toFactory(){return (Factory*)this;}