1414---- ----------------------------------------------------------------------------
1515-- Local Variables
1616
17+ local loadRate = 1
1718local mapListWindow
1819local lobby
19- local loadRate = 1
2020local oldOnlyFeaturedMaps = nil
2121local IMG_READY = LUA_DIRNAME .. " images/ready.png"
2222local IMG_UNREADY = LUA_DIRNAME .. " images/unready.png"
@@ -25,31 +25,7 @@ local IMG_UNREADY = LUA_DIRNAME .. "images/unready.png"
2525---- ----------------------------------------------------------------------------
2626-- Utilities
2727
28- local function GetTerrainType (hillLevel , waterLevel )
29- if waterLevel == 3 then
30- return " Sea"
31- end
32- local first
33- if hillLevel == 1 then
34- first = " Flat "
35- elseif hillLevel == 2 then
36- first = " Hilly "
37- else
38- first = " Mountainous "
39- end
40- local second
41- if waterLevel == 1 then
42- second = " land"
43- else
44- second = " mixed"
45- end
46-
47- return first .. second
48- end
49-
50- local function CreateMapEntry (mapName , mapData , CloseFunc )-- {"ResourceID":7098,"Name":"2_Mountains_Battlefield","SupportLevel":2,"Width":16,"Height":16,"IsAssymetrical":false,"Hills":2,"WaterLevel":1,"Is1v1":false,"IsTeams":true,"IsFFA":false,"IsChickens":false,"FFAMaxTeams":null,"RatingCount":3,"RatingSum":10,"IsSpecial":false},
51- local Configuration = WG .Chobby .Configuration
52-
28+ local function CreateMapEntry (mapName , mapData , CloseFunc , Configuration , listFont )-- {"ResourceID":7098,"Name":"2_Mountains_Battlefield","SupportLevel":2,"Width":16,"Height":16,"IsAssymetrical":false,"Hills":2,"WaterLevel":1,"Is1v1":false,"IsTeams":true,"IsFFA":false,"IsChickens":false,"FFAMaxTeams":null,"RatingCount":3,"RatingSum":10,"IsSpecial":false},
5329 local mapButton = Button :New {
5430 classname = " button_rounded" ,
5531 x = 0 ,
@@ -70,7 +46,7 @@ local function CreateMapEntry(mapName, mapData, CloseFunc)--{"ResourceID":7098,"
7046 }
7147
7248 local mapImageFile , needDownload = Configuration :GetMinimapSmallImage (mapName )
73- local minimapImage = Image :New {
49+ Image :New {
7450 name = " minimapImage" ,
7551 x = 3 ,
7652 y = 3 ,
@@ -79,7 +55,7 @@ local function CreateMapEntry(mapName, mapData, CloseFunc)--{"ResourceID":7098,"
7955 padding = {1 ,1 ,1 ,1 },
8056 keepAspect = true ,
8157 file = mapImageFile ,
82- fallbackFile = Configuration :GetLoadingImage (2 ),
58+ fallbackFile = ( needDownload and Configuration :GetLoadingImage (2 )) or nil ,
8359 checkFileExists = needDownload ,
8460 parent = mapButton ,
8561 }
@@ -90,7 +66,7 @@ local function CreateMapEntry(mapName, mapData, CloseFunc)--{"ResourceID":7098,"
9066 width = 200 ,
9167 height = 16 ,
9268 valign = ' center' ,
93- objectOverrideFont = Configuration : GetFont ( 2 ) ,
69+ objectOverrideFont = listFont ,
9470 caption = mapName :gsub (" _" , " " ),
9571 parent = mapButton ,
9672 }
@@ -108,15 +84,16 @@ local function CreateMapEntry(mapName, mapData, CloseFunc)--{"ResourceID":7098,"
10884 local sortData
10985 if mapData then
11086 local mapSizeText = (mapData .Width or " ?" ) .. " x" .. (mapData .Height or " ?" )
111- local terrainType = GetTerrainType (mapData .Hills , mapData .WaterLevel )
87+ local mapType = mapData .MapType
88+ local terrainType = mapData .TerrainType
11289
11390 Label :New {
11491 x = 274 ,
11592 y = 15 ,
11693 width = 68 ,
11794 height = 16 ,
11895 valign = ' center' ,
119- objectOverrideFont = Configuration : GetFont ( 2 ) ,
96+ objectOverrideFont = listFont ,
12097 caption = mapSizeText ,
12198 parent = mapButton ,
12299 }
@@ -126,8 +103,8 @@ local function CreateMapEntry(mapName, mapData, CloseFunc)--{"ResourceID":7098,"
126103 width = 68 ,
127104 height = 16 ,
128105 valign = ' center' ,
129- objectOverrideFont = Configuration : GetFont ( 2 ) ,
130- caption = mapData . MapType ,
106+ objectOverrideFont = listFont ,
107+ caption = mapType ,
131108 parent = mapButton ,
132109 }
133110 Label :New {
@@ -136,12 +113,12 @@ local function CreateMapEntry(mapName, mapData, CloseFunc)--{"ResourceID":7098,"
136113 width = 160 ,
137114 height = 16 ,
138115 valign = ' center' ,
139- objectOverrideFont = Configuration : GetFont ( 2 ) ,
116+ objectOverrideFont = listFont ,
140117 caption = terrainType ,
141118 parent = mapButton ,
142119 }
143120
144- sortData = {string.lower (mapName ), (mapData .Width or 0 )* 100 + (mapData .Height or 0 ), string.lower (mapData . MapType ), string.lower (terrainType ), (haveMap and 1 ) or 0 }
121+ sortData = {string.lower (mapName ), (mapData .Width or 0 )* 100 + (mapData .Height or 0 ), string.lower (mapType ), string.lower (terrainType ), (haveMap and 1 ) or 0 }
145122 sortData [6 ] = sortData [1 ] .. " " .. mapSizeText .. " " .. sortData [3 ] .. " " .. sortData [4 ] -- Used for text filter by name, type, terrain or size.
146123 else
147124 sortData = {string.lower (mapName ), 0 , " " , " " , (haveMap and 1 ) or 0 }
@@ -170,6 +147,7 @@ local function InitializeControls()
170147 -- Spring.Echo("LuaMenu KB", lmkb, "allocs", lmalloc, "Lua global KB", lgkb, "allocs", lgalloc)
171148
172149 local Configuration = WG .Chobby .Configuration
150+ local listFont = Configuration :GetFont (2 )
173151
174152 local mapListWindow = Window :New {
175153 classname = " main_window" ,
@@ -265,7 +243,7 @@ local function InitializeControls()
265243 for i = 1 , loadRate do
266244 if featuredMapList [featuredMapIndex ] then
267245 local mapName = featuredMapList [featuredMapIndex ].Name
268- control , sortData , mapFuncs [mapName ] = CreateMapEntry (mapName , featuredMapList [featuredMapIndex ], CloseFunc )
246+ control , sortData , mapFuncs [mapName ] = CreateMapEntry (mapName , featuredMapList [featuredMapIndex ], CloseFunc , Configuration , listFont )
269247 mapItems [# mapItems + 1 ] = {mapName , control , sortData }
270248 featuredMapIndex = featuredMapIndex + 1
271249 end
@@ -278,7 +256,7 @@ local function InitializeControls()
278256 for i , archive in pairs (VFS .GetAllArchives ()) do
279257 local info = VFS .GetArchiveInfo (archive )
280258 if info and info .modtype == 3 and not mapFuncs [info .name ] then
281- control , sortData , mapFuncs [info .name ] = CreateMapEntry (info .name , nil , CloseFunc )
259+ control , sortData , mapFuncs [info .name ] = CreateMapEntry (info .name , nil , CloseFunc , Configuration , listFont )
282260 mapItems [# mapItems + 1 ] = {info .name , control , sortData }
283261 end
284262 end
@@ -298,7 +276,7 @@ local function InitializeControls()
298276 width = 80 ,
299277 height = WG .BUTTON_HEIGHT ,
300278 caption = i18n (" close" ),
301- objectOverrideFont = Configuration :GetButtonFont (3 ),
279+ objectOverrideFont = Configuration :GetFont (3 ),
302280 classname = " negative_button" ,
303281 parent = mapListWindow ,
304282 OnClick = {
@@ -309,13 +287,13 @@ local function InitializeControls()
309287 }
310288
311289 if Configuration .gameConfig .link_maps ~= nil then
312- local btnOnlineMaps = Button :New {
290+ Button :New {
313291 right = 98 ,
314292 y = WG .TOP_BUTTON_Y ,
315293 width = 180 ,
316294 height = WG .BUTTON_HEIGHT ,
317295 caption = i18n (" download_maps" ),
318- objectOverrideFont = Configuration :GetButtonFont (3 ),
296+ objectOverrideFont = Configuration :GetFont (3 ),
319297 classname = " option_button" ,
320298 parent = mapListWindow ,
321299 OnClick = {
@@ -387,7 +365,7 @@ local function InitializeControls()
387365 local info = VFS .GetArchiveInfo (thingName )
388366 if info and info .modtype == 3 and not mapFuncs [info .name ] then
389367 local control , sortData
390- control , sortData , mapFuncs [info .name ] = CreateMapEntry (info .name , nil , CloseFunc )
368+ control , sortData , mapFuncs [info .name ] = CreateMapEntry (info .name , nil , CloseFunc , Configuration , listFont )
391369 mapList :AddItem (info .name , control , sortData )
392370 end
393371 end
0 commit comments