1 | diff --git a/binaries/data/mods/public/gui/loading/loading.js b/binaries/data/mods/public/gui/loading/loading.js
|
---|
2 | index 8ca3191..55f3331 100644
|
---|
3 | --- a/binaries/data/mods/public/gui/loading/loading.js
|
---|
4 | +++ b/binaries/data/mods/public/gui/loading/loading.js
|
---|
5 | @@ -1,4 +1,6 @@
|
---|
6 | var g_Data;
|
---|
7 | +var current_tip_num;
|
---|
8 | +
|
---|
9 | const END_PIECE_WIDTH = 16;
|
---|
10 |
|
---|
11 | function init(data)
|
---|
12 | @@ -6,36 +8,11 @@ function init(data)
|
---|
13 | g_Data = data;
|
---|
14 |
|
---|
15 | // Set to "hourglass" cursor.
|
---|
16 | - setCursor("cursor-wait");
|
---|
17 | -
|
---|
18 | - // Get tip image and corresponding tip text
|
---|
19 | - var tipTextLoadingArray = buildDirEntList("gui/text/tips/", "*.txt", false);
|
---|
20 | -
|
---|
21 | - if (tipTextLoadingArray.length > 0)
|
---|
22 | - {
|
---|
23 | - // Set tip text
|
---|
24 | - var tipTextFilePath = tipTextLoadingArray[getRandom (0, tipTextLoadingArray.length-1)];
|
---|
25 | - var tipText = readFile(tipTextFilePath);
|
---|
26 | + // TODO: Disabled for now as this disabled clicking next/prev buttons
|
---|
27 | + // setCursor("cursor-wait");
|
---|
28 |
|
---|
29 | - if (tipText)
|
---|
30 | - {
|
---|
31 | - var index = tipText.indexOf("\n");
|
---|
32 | - tipTextTitle = tipText.substring(0, index);
|
---|
33 | - tipTextMessage = tipText.substring(index);
|
---|
34 | - getGUIObjectByName("tipTitle").caption = tipTextTitle? tipTextTitle : "";
|
---|
35 | - getGUIObjectByName("tipText").caption = tipTextMessage? tipTextMessage : "";
|
---|
36 | - }
|
---|
37 | -
|
---|
38 | - // Set tip image
|
---|
39 | - var fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png");
|
---|
40 | - var tipImageFilePath = "loading/tips/" + fileName;
|
---|
41 | - var sprite = "stretched:" + tipImageFilePath;
|
---|
42 | - getGUIObjectByName("tipImage").sprite = sprite? sprite : "";
|
---|
43 | - }
|
---|
44 | - else
|
---|
45 | - {
|
---|
46 | - error("Failed to find any matching tips for the loading screen.")
|
---|
47 | - }
|
---|
48 | + // Setting the tip is now handled by getTip, setTip, nextTip and prevTip
|
---|
49 | + nextTip();
|
---|
50 |
|
---|
51 | // janwas: main loop now sets progress / description, but that won't
|
---|
52 | // happen until the first timeslice completes, so set initial values.
|
---|
53 | @@ -68,6 +45,116 @@ function init(data)
|
---|
54 | }
|
---|
55 |
|
---|
56 | // ====================================================================
|
---|
57 | +function nextTip()
|
---|
58 | +{
|
---|
59 | + var tips = getTipArray();
|
---|
60 | +
|
---|
61 | + if (tips.length > 0)
|
---|
62 | + {
|
---|
63 | + // Either generate a random tip number or take the next number
|
---|
64 | + // depending on the value of current_tip_num
|
---|
65 | + var num = current_tip_num
|
---|
66 | + ? current_tip_num + 1
|
---|
67 | + : getRandom(0, tips.length - 1);
|
---|
68 | +
|
---|
69 | + // Num should not be larger than the tiptextloadingarray length
|
---|
70 | + // Set to 0 if it is longer
|
---|
71 | + num = (num > tips.length - 1)
|
---|
72 | + ? 0
|
---|
73 | + : num;
|
---|
74 | +
|
---|
75 | + // Set global
|
---|
76 | + current_tip_num = num;
|
---|
77 | + }
|
---|
78 | +
|
---|
79 | + setTip();
|
---|
80 | +}
|
---|
81 | +
|
---|
82 | +// ====================================================================
|
---|
83 | +function prevTip()
|
---|
84 | +{
|
---|
85 | + var tips = getTipArray();
|
---|
86 | +
|
---|
87 | + if(tips.length > 0)
|
---|
88 | + {
|
---|
89 | + // Either generate a random tip number or take the previous number
|
---|
90 | + // depending on the value of current_tip_num
|
---|
91 | + var num = current_tip_num
|
---|
92 | + ? current_tip_num - 1
|
---|
93 | + : getRandom(0, tips.length - 1);
|
---|
94 | +
|
---|
95 | + // Num should not be smaller than 0
|
---|
96 | + // Set to max if it is smaller
|
---|
97 | + num = (num < 0)
|
---|
98 | + ? tips.length - 1
|
---|
99 | + : num;
|
---|
100 | +
|
---|
101 | + // Set global
|
---|
102 | + current_tip_num = num;
|
---|
103 | + }
|
---|
104 | +
|
---|
105 | + setTip();
|
---|
106 | +}
|
---|
107 | +
|
---|
108 | +// ====================================================================
|
---|
109 | +function getTipArray()
|
---|
110 | +{
|
---|
111 | + return buildDirEntList("gui/text/tips/", "*.txt", false);
|
---|
112 | +}
|
---|
113 | +
|
---|
114 | +// ====================================================================
|
---|
115 | +function getTip()
|
---|
116 | +{
|
---|
117 | + var tip;
|
---|
118 | +
|
---|
119 | + // Get tip image and corresponding tip text
|
---|
120 | + var tipTextLoadingArray = getTipArray();
|
---|
121 | +
|
---|
122 | + if (tipTextLoadingArray.length > 0)
|
---|
123 | + {
|
---|
124 | + // Set tip text
|
---|
125 | + var tipTextFilePath = tipTextLoadingArray[current_tip_num];
|
---|
126 | + var tipText = readFile(tipTextFilePath);
|
---|
127 | +
|
---|
128 | + if (tipText)
|
---|
129 | + {
|
---|
130 | + var index = tipText.indexOf("\n");
|
---|
131 | +
|
---|
132 | + // Set tip image
|
---|
133 | + var fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png");
|
---|
134 | + var tipImageFilePath = "loading/tips/" + fileName;
|
---|
135 | + var sprite = "stretched:" + tipImageFilePath;
|
---|
136 | +
|
---|
137 | + tip = {
|
---|
138 | + title : tipText.substring(0, index),
|
---|
139 | + text : tipText.substring(index),
|
---|
140 | + sprite : sprite
|
---|
141 | + };
|
---|
142 | +
|
---|
143 | + return tip;
|
---|
144 | + }
|
---|
145 | + }
|
---|
146 | +
|
---|
147 | + // Failed to find tip
|
---|
148 | + error("Failed to find any matching tips for the loading screen.")
|
---|
149 | +
|
---|
150 | + return false;
|
---|
151 | +}
|
---|
152 | +
|
---|
153 | +// ====================================================================
|
---|
154 | +function setTip()
|
---|
155 | +{
|
---|
156 | + var tip = getTip();
|
---|
157 | +
|
---|
158 | + if(tip)
|
---|
159 | + {
|
---|
160 | + getGUIObjectByName("tipTitle").caption = tip.title ? tip.title : "";
|
---|
161 | + getGUIObjectByName("tipText").caption = tip.text ? tip.text : "";
|
---|
162 | + getGUIObjectByName("tipImage").sprite = tip.sprite ? tip.sprite : "";
|
---|
163 | + }
|
---|
164 | +}
|
---|
165 | +
|
---|
166 | +// ====================================================================
|
---|
167 | function displayProgress()
|
---|
168 | {
|
---|
169 | // Make the progessbar finish a little early so that the user can actually see it finish
|
---|
170 | @@ -108,8 +195,19 @@ function reallyStartGame()
|
---|
171 | // to start the game (i.e. loading progress has reached 100%).
|
---|
172 |
|
---|
173 | // Switch GUI from loading screen to game session.
|
---|
174 | - Engine.SwitchGuiPage("page_session.xml", g_Data);
|
---|
175 | + //Engine.SwitchGuiPage("page_session.xml", g_Data);
|
---|
176 | +
|
---|
177 | + // Show the start game button
|
---|
178 | + getGUIObjectByName("startGameButton").size = "50%-200 75%+80 50%+200 75%+120";
|
---|
179 |
|
---|
180 | // Restore default cursor.
|
---|
181 | setCursor("arrow-default");
|
---|
182 | }
|
---|
183 | +
|
---|
184 | +// ====================================================================
|
---|
185 | +function startGameButtonClick()
|
---|
186 | +{
|
---|
187 | + // Switch GUI from loading screen to game session.
|
---|
188 | + Engine.SwitchGuiPage("page_session.xml", g_Data);
|
---|
189 | +}
|
---|
190 | +
|
---|
191 | diff --git a/binaries/data/mods/public/gui/loading/loading.xml b/binaries/data/mods/public/gui/loading/loading.xml
|
---|
192 | index 7ad8c38..82bb810 100644
|
---|
193 | --- a/binaries/data/mods/public/gui/loading/loading.xml
|
---|
194 | +++ b/binaries/data/mods/public/gui/loading/loading.xml
|
---|
195 | @@ -37,15 +37,31 @@
|
---|
196 | </object>
|
---|
197 |
|
---|
198 | <!-- LOADING SCREEN TIP TEXT-->
|
---|
199 | + <object name="prevTipButton" type="button" size="25%-80 50% 25% 50%+40" style="StoneButton">
|
---|
200 | + Previous
|
---|
201 | + <action on="Press">prevTip();</action>
|
---|
202 | + </object>
|
---|
203 | +
|
---|
204 | <object size="50%+128 50%-193 50%+448 50%+193" type="image" sprite="LoadingTipText">
|
---|
205 | <object name="tipTitle" size="30 30 100% 50" type="text" style="LoadingTipTitleText"/>
|
---|
206 | <object name="tipText" size="30 50 100%-30 100%" type="text" style="LoadingTipText"/>
|
---|
207 | </object>
|
---|
208 |
|
---|
209 | + <object name="nextTipButton" type="button" size="75% 50% 75%+80 50%+40" style="StoneButton">
|
---|
210 | + Next
|
---|
211 | + <action on="Press">nextTip();</action>
|
---|
212 | + </object>
|
---|
213 | +
|
---|
214 | <!-- LOADING SCREEN QUOTE (needs increased z value to overcome the transparent area of the tip image above it -->
|
---|
215 | <object size="50%-448 50%+230 50%+448 100%-16" z="20">
|
---|
216 | <object name="quoteTitleText" size="0 0 100% 30" type="text" style="LoadingTitleText">Quote of the Day:</object>
|
---|
217 | <object name="quoteText" size="0 30 100% 100%" type="text" style="LoadingText"></object>
|
---|
218 | </object>
|
---|
219 | +
|
---|
220 | + <!-- Initially hidden (needs increased z value to overcome the quote area) -->
|
---|
221 | + <object name="startGameButton" type="button" size="0 0 0 0" z="99" style="StoneButton">
|
---|
222 | + Start game
|
---|
223 | + <action on="Press">startGameButtonClick();</action>
|
---|
224 | + </object>
|
---|
225 | </object>
|
---|
226 | </objects>
|
---|