@@ -49,6 +49,8 @@ local screen0
4949local rewardButtons = {}
5050local currentLoadout = {}
5151
52+ local planetButtons = {}
53+
5254local blackBackground
5355local loadoutDisplay
5456
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
97104local 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
141235end
142236
@@ -426,7 +520,6 @@ local function MakeRewardList(holder, name, leftBound, rightBound, itemList)
426520 return externalFunctions
427521end
428522
429-
430523local function SetupLoadoutPanel (bottomPanel )
431524 local teamID = Spring .GetMyTeamID ()
432525 if not currentLoadout then
0 commit comments