Skip to content

Commit a0d500e

Browse files
committed
Configure new PW factions.
1 parent 8f2d2ab commit a0d500e

3 files changed

Lines changed: 61 additions & 13 deletions

File tree

LuaMenu/configs/planetwars/factionText.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
local data = {
22
Machines = {
33
motto = "Freedom from the ashes",
4-
desc = "Revolutionary Communists",
4+
desc = "Revolutionary Communists, fighting to unshackle themselves from human tyranny.",
55
image = LUA_DIRNAME .. "images/factions/Machines.png",
6+
--imageLarge = LUA_DIRNAME .. "images/factions/Machines.png",
7+
},
8+
Hegemony = {
9+
motto = "Peace Without Flaw",
10+
desc = "A technocratic oligarchy, intent on restoring peace and prosperity to the galaxy through careful control.",
11+
image = LUA_DIRNAME .. "images/factions/SynPact.png",
12+
--imageLarge = LUA_DIRNAME .. "images/factions/SynPact.png",
13+
},
14+
Rising = {
15+
motto = "Hope of True Humanity",
16+
desc = "Political movement based on the moral superiority of humans over 'enhanced' and artificial intelligences.",
17+
image = LUA_DIRNAME .. "images/factions/Rising.png",
18+
--imageLarge = LUA_DIRNAME .. "images/factions/Rising.png",
619
},
720
Empire = {
821
motto = "Order, loyalty, dignity",

LuaMenu/widgets/gui_planetwars_list_window.lua

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ local IMG_LINK = LUA_DIRNAME .. "images/link.png"
2525

2626
local panelInterface
2727
local PLANET_NAME_LENGTH = 210
28-
local FACTION_SPACING = 156
28+
local FACTION_SPACING = 134
2929

3030
local phaseTimer
3131
local requiredGame = false
@@ -94,7 +94,7 @@ local function TryToJoinPlanet(planetData)
9494
WG.Analytics.SendOnetimeEvent("lobby:multiplayer:planetwars:join_site")
9595
end
9696

97-
local function GetAttackingOrDefending(lobby, attackerFaction, defenderFactions)
97+
local function GetAttackingOrDefending(lobby, attackerFaction, defenderFactions, currentMode)
9898
local myFaction = lobby:GetMyFaction()
9999
local attacking = (myFaction == attackerFaction)
100100
local defending = false
@@ -669,7 +669,7 @@ local function MakePlanetControl(planetData, DeselectOtherFunc)
669669
else
670670
btnJoin:SetCaption("???")
671671
end
672-
else then
672+
else
673673
if downloading then
674674
btnJoin:SetCaption(i18n("downloading"))
675675
else
@@ -853,7 +853,7 @@ local function MakeFactionSelector(parent, x, y, SelectionFunc, CancelFunc, righ
853853

854854
local HolderType = (right and bottom and ScrollPanel) or Control
855855

856-
local offset = 0
856+
local offset = 15
857857
local holder = HolderType:New {
858858
x = x,
859859
y = y,
@@ -876,6 +876,7 @@ local function MakeFactionSelector(parent, x, y, SelectionFunc, CancelFunc, righ
876876
local name = factionList[i].Name
877877
local factionData = factionText[shortname] or {}
878878

879+
local buttonPos = 140
879880
if factionData.imageLarge then
880881
Image:New {
881882
x = 2,
@@ -886,10 +887,21 @@ local function MakeFactionSelector(parent, x, y, SelectionFunc, CancelFunc, righ
886887
file = factionData.imageLarge,
887888
parent = holder,
888889
}
890+
elseif factionData.image then
891+
buttonPos = 86
892+
Image:New {
893+
x = 8,
894+
y = offset,
895+
width = 64,
896+
height = 64,
897+
keepAspect = true,
898+
file = factionData.image,
899+
parent = holder,
900+
}
889901
end
890902

891903
Button:New {
892-
x = 140,
904+
x = buttonPos,
893905
y = offset,
894906
width = 260,
895907
height = WG.BUTTON_HEIGHT,
@@ -907,14 +919,26 @@ local function MakeFactionSelector(parent, x, y, SelectionFunc, CancelFunc, righ
907919
parent = holder,
908920
}
909921

910-
if factionData.motto and factionData.desc then
922+
if factionData.motto then
923+
TextBox:New {
924+
x = buttonPos,
925+
y = offset + 56,
926+
width = 360,
927+
height = 45,
928+
objectOverrideFont = Configuration:GetFont(2),
929+
text = [["]] .. factionData.motto .. [["]],
930+
parent = holder,
931+
}
932+
offset = offset + 30
933+
end
934+
if factionData.motto then
911935
TextBox:New {
912-
x = 140,
936+
x = buttonPos,
913937
y = offset + 56,
914-
width = 240,
938+
width = 360,
915939
height = 45,
916940
objectOverrideFont = Configuration:GetFont(2),
917-
text = [["]] .. factionData.motto .. [["]] .. "\n" .. factionData.desc,
941+
text = factionData.desc,
918942
parent = holder,
919943
}
920944
end
@@ -1248,7 +1272,7 @@ local function InitializeControls(window)
12481272
end
12491273
end
12501274

1251-
local attacking, defending = GetAttackingOrDefending(lobby, attackerFaction, defenderFactions)
1275+
local attacking, defending = GetAttackingOrDefending(lobby, attackerFaction, defenderFactions, currentMode)
12521276
UpdateStatusText(attacking, defending, currentMode)
12531277

12541278
planetList.SetPlanetList(planets, modeSwitched)
@@ -1257,14 +1281,14 @@ local function InitializeControls(window)
12571281
lobby:AddListener("OnPwMatchCommand", OnPwMatchCommand)
12581282

12591283
local function OnPwAttackingPlanet()
1260-
local attacking, defending = GetAttackingOrDefending(lobby, oldAttackerFaction, oldDefenderFactions)
1284+
local attacking, defending = GetAttackingOrDefending(lobby, oldAttackerFaction, oldDefenderFactions, oldMode)
12611285
UpdateStatusText(attacking, defending, oldMode)
12621286
end
12631287
lobby:AddListener("OnPwAttackingPlanet", OnPwAttackingPlanet)
12641288

12651289
local function OnUpdateUserStatus(listener, userName, status)
12661290
if lobby:GetMyUserName() == userName then
1267-
local attacking, defending = GetAttackingOrDefending(lobby, oldAttackerFaction, oldDefenderFactions)
1291+
local attacking, defending = GetAttackingOrDefending(lobby, oldAttackerFaction, oldDefenderFactions, oldMode)
12681292
UpdateStatusText(attacking, defending, oldMode)
12691293
end
12701294
end
@@ -1395,6 +1419,7 @@ function DelayedInitialize()
13951419
end
13961420

13971421
local function OnPwStatus(_, enabledStatus, requiredLevel)
1422+
Spring.Echo("OnPwStatus", enabledStatus, requiredLevel, lobby.PW_PREGAME, lobby.PW_ENABLED)
13981423
local myInfo = lobby:GetMyInfo()
13991424
myLevel = myInfo.level
14001425
planetwarsLevelRequired = requiredLevel

libs/liblobby/lobby/interface_zerok.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,15 @@ function Interface:_PwMatchCommand(data)
19771977
end
19781978
Interface.jsonCommands["PwMatchCommand"] = Interface._PwMatchCommand
19791979

1980+
function Interface:_PwAttackCharges(data)
1981+
self:_OnPwMatchCommand(data.AttackerFaction, data.DefenderFactions, data.Mode, data.Options, data.DeadlineSeconds)
1982+
--{
1983+
-- public int Current { get; set; }
1984+
-- public int? NextRechargeTurn { get; set; }
1985+
--}
1986+
end
1987+
Interface.jsonCommands["PwAttackCharges"] = Interface._PwAttackCharges
1988+
19801989
function Interface:_PwRequestJoinPlanet(data)
19811990
self:_OnPwRequestJoinPlanet(data.PlanetID)
19821991
end
@@ -2153,5 +2162,6 @@ Interface.jsonCommands["SiteToLobbyCommand"] = Interface._OnSiteToLobbyCommand
21532162
--ForceJoinBattle
21542163
--LinkSteam
21552164
--PwMatchCommand
2165+
--PwAttackCharges
21562166

21572167
return Interface

0 commit comments

Comments
 (0)