Skip to content

Commit d2956f4

Browse files
committed
WIP
1 parent bb8b1b4 commit d2956f4

7 files changed

Lines changed: 146 additions & 52 deletions

File tree

LuaRules/Configs/RogueK/reward_defs.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ local categories = {
9393
light_turret = {
9494
humanName = "Turret",
9595
options = ProcessUnitList({
96-
"turretlaser",
9796
"turretmissile",
9897
"turretimpulse",
9998
"turretgauss",
@@ -108,6 +107,8 @@ local categories = {
108107
"staticmex",
109108
"energywind",
110109
"energysolar",
110+
"turretlaser",
111+
"staticrearm",
111112
"staticradar",
112113
}),
113114
},

LuaRules/Utilities/unitDefReplacements.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ local planetwarsStructure = {}
99
local buildPlate = {}
1010
local buildPowerCache = {}
1111
local rangeCache = {}
12+
local baseDefCache = {}
1213
local dynComm = {}
1314
local variableCostUnit = {
1415
[UnitDefNames["terraunit"].id] = true
@@ -130,6 +131,19 @@ function Spring.Utilities.GetUnitRange(unitID, unitDefID)
130131
return Spring.GetUnitRulesParam(unitID, "comm_max_range") or GetCachedBaseRange(unitDefID), Spring.GetUnitRulesParam(unitID, "primary_weapon_range")
131132
end
132133

134+
function Spring.Utilities.GetBaseDefID(unitDefID)
135+
if not unitDefID then
136+
return unitDefID
137+
end
138+
if baseDefCache then
139+
return baseDefCache[unitDefID]
140+
end
141+
local ud = UnitDefs[unitDefID]
142+
local bud = ud.customParams.baseDef and UnitDefNames[ud.customParams.baseDef]
143+
baseDefCache[unitDefID] = bud and bud.id or unitDefID
144+
return baseDefCache[unitDefID]
145+
end
146+
133147
-------------------------------------------------------------------------------------
134148
-------------------------------------------------------------------------------------
135149

LuaUI/Widgets/chili/Skins/Evolved/skin.lua

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -659,30 +659,7 @@ skin.main_window_tall = {
659659
}
660660

661661
skin.main_window = {
662-
TileImage = ":c:tech_mainwindow_opaque.png",
663-
tiles = {176, 64, 176, 64}, --// tile widths: left, top, right, bottom
664-
padding = {10, 6, 10, 6},
665-
hitpadding = {4, 4, 4, 4},
666-
667-
captionColor = {1, 1, 1, 0.45},
668-
backgroundColor = {0.1, 0.1, 0.1, 0.7},
669-
670-
boxes = {
671-
resize = {-23, -19, -12, -8},
672-
drag = {0, 0, "100%", 10},
673-
},
674-
675-
NCHitTest = NCHitTestWithPadding,
676-
NCMouseDown = WindowNCMouseDown,
677-
NCMouseDownPostChildren = WindowNCMouseDownPostChildren,
678-
679-
DrawControl = DrawWindow,
680-
DrawDragGrip = function() end,
681-
DrawResizeGrip = DrawResizeGrip,
682-
}
683-
684-
skin.main_window_opaque = {
685-
TileImage = ":c:tech_mainwindow_opaque.png",
662+
TileImage = ":c:tech_mainwindow.png",
686663
tiles = {176, 64, 176, 64}, --// tile widths: left, top, right, bottom
687664
padding = {10, 6, 10, 6},
688665
hitpadding = {4, 4, 4, 4},

LuaUI/Widgets/chili_old/Skins/Evolved/skin.lua

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -681,29 +681,6 @@ skin.main_window = {
681681
DrawResizeGrip = DrawResizeGrip,
682682
}
683683

684-
skin.main_window_opaque = {
685-
TileImage = ":c:tech_mainwindow_opaque.png",
686-
tiles = {176, 64, 176, 64}, --// tile widths: left, top, right, bottom
687-
padding = {10, 6, 10, 6},
688-
hitpadding = {4, 4, 4, 4},
689-
690-
captionColor = {1, 1, 1, 0.45},
691-
backgroundColor = {0.1, 0.1, 0.1, 0.7},
692-
693-
boxes = {
694-
resize = {-23, -19, -12, -8},
695-
drag = {0, 0, "100%", 10},
696-
},
697-
698-
NCHitTest = NCHitTestWithPadding,
699-
NCMouseDown = WindowNCMouseDown,
700-
NCMouseDownPostChildren = WindowNCMouseDownPostChildren,
701-
702-
DrawControl = DrawWindow,
703-
DrawDragGrip = function() end,
704-
DrawResizeGrip = DrawResizeGrip,
705-
}
706-
707684
skin.window_black = {
708685
TileImage = ":c:tech_black.png",
709686
tiles = {0, 0, 0, 0}, --// tile widths: left,top,right,bottom

LuaUI/Widgets/gui_chili_rogue_rewards.lua

Lines changed: 97 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ local screen0
4949
local rewardButtons = {}
5050
local currentLoadout = {}
5151

52+
local planetButtons = {}
53+
5254
local blackBackground
5355
local loadoutDisplay
5456

@@ -93,6 +95,11 @@ end
9395
--------------------------------------------------------------------------------
9496
-- Utils
9597

98+
local function ClickPlanet(planetID)
99+
for i = 1, #planetButtons do
100+
planetButtons[i].SetSelection(planetID == i)
101+
end
102+
end
96103

97104
local function ClickRewardCategoryButton(buttonID)
98105
for i = 1, #rewardButtons do
@@ -127,16 +134,103 @@ end
127134
--------------------------------------------------------------------------------
128135
-- Galaxy Map
129136

130-
local function SetupGalaxyMap(parent)
137+
local function StartBattle()
138+
139+
end
140+
141+
local function GetPlanet(parent, planetID, planetDef)
142+
local isSelected = false
143+
local isDisabled = false
144+
local oldFont = WG.GetSpecialFont(14, "internal_white", {outlineColor = {0, 0, 0, 1}, color = {1, 1, 1, 1}})
145+
146+
local button = Chili.Button:New{
147+
parent = parent,
148+
caption = planetDef.humanName,
149+
OnClick = {function () ClickPlanet(planetID) end},
150+
x = 200 + planetDef.pos[1] * 100,
151+
y = planetDef.pos[2] * 100,
152+
width = 70,
153+
height = 70,
154+
}
131155

132156
local externalFuncs = {}
133-
function externalFuncs.Show()
157+
function externalFuncs.SetDisabled(newDisabled)
158+
if newDisabled == isDisabled then
159+
return
160+
end
161+
isDisabled = newDisabled
162+
if isDisabled then
163+
button.backgroundColor = BUTTON_DISABLE_COLOR
164+
button.focusColor = BUTTON_DISABLE_FOCUS_COLOR
165+
button.borderColor = BUTTON_DISABLE_FOCUS_COLOR
166+
function button:HitTest(x,y) return false end
167+
button.font = WG.GetSpecialFont(14, "integral_grey", {outlineColor = {0, 0, 0, 1}, color = {0.6, 0.6, 0.6, 1}})
168+
else
169+
button.backgroundColor = BUTTON_COLOR
170+
button.focusColor = BUTTON_FOCUS_COLOR
171+
button.borderColor = BUTTON_BORDER_COLOR
172+
button.font = oldFont
173+
function button:HitTest(x,y) return self end
174+
end
175+
button:Invalidate()
176+
end
134177

178+
function externalFuncs.SetSelection(newIsSelected)
179+
if isSelected == newIsSelected then
180+
return
181+
end
182+
isSelected = newIsSelected
183+
if isSelected then
184+
button.backgroundColor = SELECT_BUTTON_COLOR
185+
button.focusColor = SELECT_BUTTON_FOCUS_COLOR
186+
else
187+
button.backgroundColor = BUTTON_COLOR
188+
button.focusColor = BUTTON_FOCUS_COLOR
189+
end
190+
button:Invalidate()
135191
end
136-
function externalFuncs.Hide()
137192

193+
return externalFuncs
194+
end
195+
196+
local function SetupGalaxyMap(parent)
197+
local galaxy = CustomKeyToUsefulTable(modOptions.rk_galaxy)
198+
199+
local holder = Chili.Control:New{
200+
parent = parent,
201+
x = 0,
202+
y = 0,
203+
right = 0,
204+
bottom = 0,
205+
padding = {10, 10, 10, 10},
206+
}
207+
208+
local startButton = Chili.Button:New{
209+
parent = holder,
210+
caption = "Start Battle",
211+
OnClick = {function () StartBattle() end},
212+
x = 20,
213+
y = 20,
214+
width = 140,
215+
height = 70,
216+
}
217+
218+
for i = 1, #galaxy.planets do
219+
local planetDef = galaxy.planets[i]
220+
planetButtons[i] = GetPlanet(holder, i, planetDef)
221+
if planetDef.state then
222+
planetButtons[i].SetDisabled(true)
223+
end
138224
end
139225

226+
local externalFuncs = {}
227+
function externalFuncs.Show()
228+
holder:SetVisibility(true)
229+
end
230+
function externalFuncs.Hide()
231+
holder:SetVisibility(false)
232+
end
233+
externalFuncs.Hide()
140234
return externalFuncs
141235
end
142236

@@ -426,7 +520,6 @@ local function MakeRewardList(holder, name, leftBound, rightBound, itemList)
426520
return externalFunctions
427521
end
428522

429-
430523
local function SetupLoadoutPanel(bottomPanel)
431524
local teamID = Spring.GetMyTeamID()
432525
if not currentLoadout then

ModOptions.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,14 @@ local options = {
554554
type = "string",
555555
def = "",
556556
},
557+
{
558+
key = "extraunits",
559+
name = "Extra Units",
560+
desc = "A base64 encoded definition of extra units. Use customparams.base_def to use an existing unit as a base.",
561+
section = 'experimental',
562+
type = "string",
563+
def = "",
564+
},
557565
{
558566
key = "option_notes",
559567
name = "Notes",

gamedata/unitdefs_post.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,30 @@ do
112112
end
113113
end
114114

115+
-- New units
116+
117+
118+
do
119+
local append = false
120+
local modoptName = "extraunits"
121+
while modOptions[modoptName] and modOptions[modoptName] ~= "" do
122+
local units = Spring.Utilities.CustomKeyToUsefulTable(modOptions[modoptName])
123+
if type(tweaks) == "table" then
124+
Spring.Echo("Loading extraunits modoption", append or 0)
125+
for name, ud in pairs(units) do
126+
Spring.Echo("Loading extraunit " .. name)
127+
local ud = lowerkeys(ud)
128+
if ud.customparams.base_def then
129+
Spring.Utilities.OverwriteTableInplace(ud, lowerkeys(UnitDefs[ud.customparams.base_def]), true)
130+
end
131+
UnitDefs[name] = ud
132+
end
133+
end
134+
append = (append or 0) + 1
135+
modoptName = "extraunits" .. append
136+
end
137+
end
138+
115139
--------------------------------------------------------------------------------
116140
--------------------------------------------------------------------------------
117141
--

0 commit comments

Comments
 (0)