diff --git a/binaries/data/mods/public/gui/loading/loading.js
index 685ab89..e33cb66 100644
a
|
b
|
|
1 | | var g_Data; |
2 | | const END_PIECE_WIDTH = 16; |
| 1 | let g_Data; |
| 2 | const g_EndPieceWidth = 16; |
3 | 3 | |
4 | 4 | function init(data) |
5 | 5 | { |
6 | 6 | g_Data = data; |
7 | 7 | |
| 8 | if(!g_Data) |
| 9 | return; |
| 10 | |
8 | 11 | // Set to "hourglass" cursor. |
9 | 12 | Engine.SetCursor("cursor-wait"); |
10 | 13 | |
11 | 14 | // Get tip image and corresponding tip text |
12 | | var tipTextLoadingArray = Engine.BuildDirEntList("gui/text/tips/", "*.txt", false); |
| 15 | let tipTextLoadingArray = Engine.BuildDirEntList("gui/text/tips/", "*.txt", false); |
13 | 16 | |
14 | 17 | if (tipTextLoadingArray.length > 0) |
15 | 18 | { |
16 | 19 | // Set tip text |
17 | | var tipTextFilePath = tipTextLoadingArray[getRandom (0, tipTextLoadingArray.length-1)]; |
18 | | var tipText = Engine.TranslateLines(Engine.ReadFile(tipTextFilePath)); |
| 20 | let tipTextFilePath = tipTextLoadingArray[getRandom (0, tipTextLoadingArray.length-1)]; |
| 21 | let tipText = Engine.TranslateLines(Engine.ReadFile(tipTextFilePath)); |
19 | 22 | |
20 | 23 | if (tipText) |
21 | 24 | { |
22 | | var index = tipText.indexOf("\n"); |
23 | | var tipTextTitle = tipText.substring(0, index); |
24 | | var tipTextMessage = tipText.substring(index); |
| 25 | let index = tipText.indexOf("\n"); |
| 26 | let tipTextTitle = tipText.substring(0, index); |
| 27 | let tipTextMessage = tipText.substring(index); |
25 | 28 | Engine.GetGUIObjectByName("tipTitle").caption = tipTextTitle? tipTextTitle : ""; |
26 | 29 | Engine.GetGUIObjectByName("tipText").caption = tipTextMessage? tipTextMessage : ""; |
27 | 30 | } |
28 | 31 | |
29 | 32 | // Set tip image |
30 | | var fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png"); |
31 | | var tipImageFilePath = "loading/tips/" + fileName; |
32 | | var sprite = "stretched:" + tipImageFilePath; |
| 33 | let fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png"); |
| 34 | let tipImageFilePath = "loading/tips/" + fileName; |
| 35 | let sprite = "stretched:" + tipImageFilePath; |
33 | 36 | Engine.GetGUIObjectByName("tipImage").sprite = sprite? sprite : ""; |
34 | 37 | } |
35 | 38 | else |
… |
… |
function init(data)
|
37 | 40 | |
38 | 41 | // janwas: main loop now sets progress / description, but that won't |
39 | 42 | // happen until the first timeslice completes, so set initial values. |
40 | | var loadingMapName = Engine.GetGUIObjectByName("loadingMapName"); |
| 43 | let loadingMapName = Engine.GetGUIObjectByName("loadingMapName"); |
41 | 44 | |
42 | 45 | if (data) |
43 | 46 | { |
44 | | var mapName = translate(data.attribs.settings.Name); |
| 47 | let mapName = translate(data.attribs.settings.Name); |
45 | 48 | switch (data.attribs.mapType) |
46 | 49 | { |
47 | 50 | case "skirmish": |
… |
… |
function init(data)
|
62 | 65 | Engine.GetGUIObjectByName("progressbar").caption = 0; |
63 | 66 | |
64 | 67 | // Pick a random quote of the day (each line is a separate tip). |
65 | | var quoteArray = Engine.ReadFileLines("gui/text/quotes.txt"); |
| 68 | let quoteArray = Engine.ReadFileLines("gui/text/quotes.txt"); |
66 | 69 | Engine.GetGUIObjectByName("quoteText").caption = translate(quoteArray[getRandom(0, quoteArray.length-1)]); |
67 | 70 | } |
68 | 71 | |
… |
… |
function displayProgress()
|
73 | 76 | return; |
74 | 77 | |
75 | 78 | // Show 100 when it is really 99 |
76 | | var progress = g_Progress + 1; |
| 79 | let progress = g_Progress + 1; |
77 | 80 | |
78 | 81 | Engine.GetGUIObjectByName("progressbar").caption = progress; // display current progress |
79 | 82 | Engine.GetGUIObjectByName("progressText").caption = progress + "%"; |
… |
… |
function displayProgress()
|
82 | 85 | // Engine.GetGUIObjectByName("progressText").caption = g_LoadDescription; // display current progess details |
83 | 86 | |
84 | 87 | // Keep curved right edge of progress bar in sync with the rest of the progress bar |
85 | | var middle = Engine.GetGUIObjectByName("progressbar"); |
86 | | var rightSide = Engine.GetGUIObjectByName("progressbar_right"); |
| 88 | let middle = Engine.GetGUIObjectByName("progressbar"); |
| 89 | let rightSide = Engine.GetGUIObjectByName("progressbar_right"); |
87 | 90 | |
88 | | var middleLength = (middle.size.right - middle.size.left) - (END_PIECE_WIDTH / 2); |
89 | | var increment = Math.round(progress * middleLength / 100); |
| 91 | let middleLength = (middle.size.right - middle.size.left) - (g_EndPieceWidth / 2); |
| 92 | let increment = Math.round(progress * middleLength / 100); |
90 | 93 | |
91 | | var size = rightSide.size; |
| 94 | let size = rightSide.size; |
92 | 95 | size.left = increment; |
93 | | size.right = increment + END_PIECE_WIDTH; |
| 96 | size.right = increment + g_EndPieceWidth; |
94 | 97 | rightSide.size = size; |
95 | 98 | } |
96 | 99 | |
… |
… |
function reallyStartGame()
|
105 | 108 | |
106 | 109 | // Restore default cursor. |
107 | 110 | Engine.SetCursor("arrow-default"); |
108 | | |
| 111 | |
109 | 112 | // Notify the other clients that we have finished the loading screen |
110 | 113 | if (g_Data.isNetworked && g_Data.isRejoining) |
111 | 114 | Engine.SendNetworkRejoined(); |