Ticket #2087: 2087_Rebased.diff
File 2087_Rebased.diff, 11.1 KB (added by , 8 years ago) |
---|
-
binaries/data/config/default.cfg
309 309 fastforward = Space ; If timewarp mode enabled, speed up the game 310 310 rewind = Backspace ; If timewarp mode enabled, go back to earlier point in the game 311 311 312 ; > LOADING SCREEN TOOLTIP HOTKEYS 313 hotkey.loading.previoustip = "LeftArrow" 314 hotkey.loading.nexttip = "RightArrow" 315 312 316 [hotkey.text] ; > GUI TEXTBOX HOTKEYS 313 317 delete.left = "Ctrl+Backspace" ; Delete word to the left of cursor 314 318 delete.right = "Ctrl+Del" ; Delete word to the right of cursor … … 346 350 ; The Debugger is currently broken and can't be enabled until the SpiderMonkey upgrade is done and the debugger is updated for the new API. 347 351 enable = false ; Enable Javascript debugging. 348 352 353 ; LOADING SCREEN TIP CONTROLS 354 gui.loadingtips.enabled = true 355 349 356 [lobby] 350 357 chattimestamp = false ; Show time chat message was posted 351 358 history = 0 ; Number of past messages to display on join -
binaries/data/mods/public/gui/gamesetup/gamesetup.js
1204 1204 Engine.SwitchGuiPage("page_loading.xml", { 1205 1205 "attribs": g_GameAttributes, 1206 1206 "isNetworked" : g_IsNetworked, 1207 "playerAssignments": g_PlayerAssignments 1207 "playerAssignments": g_PlayerAssignments, 1208 "isController": g_IsController 1208 1209 }); 1209 1210 } 1210 1211 } -
binaries/data/mods/public/gui/loading/loading.js
1 var g_Data; 1 let g_Data; 2 let tipControlsEnabled; 3 let tips; 4 let tipIndex; 5 2 6 const END_PIECE_WIDTH = 16; 3 7 4 8 function init(data) 5 9 { 6 10 g_Data = data; 11 if (!data) 12 return; 7 13 8 // Set to "hourglass" cursor. 9 Engine.SetCursor("cursor-wait"); 14 // janwas: main loop now sets progress / description, but that won't 15 // happen until the first timeslice completes, so set initial values. 16 Engine.GetGUIObjectByName("loadingMapName").caption = sprintf( 17 data.attribs.mapType === "random" ? translate("Generating “%(map)s”") : translate("Loading “%(map)s”"), 18 { "map": translate(data.attribs.settings.Name) }); 10 19 11 // Get tip image and corresponding tip text 12 var tipTextLoadingArray = Engine.BuildDirEntList("gui/text/tips/", "*.txt", false); 20 // Pick a random quote of the day (one quote per line). 21 let quoteArray = Engine.ReadFileLines("gui/text/quotes.txt"); 22 Engine.GetGUIObjectByName("quoteText").caption = translate(quoteArray[getRandom(0, quoteArray.length-1)]); 13 23 14 if (tipTextLoadingArray.length > 0) 15 { 16 // Set tip text 17 var tipTextFilePath = tipTextLoadingArray[getRandom (0, tipTextLoadingArray.length-1)]; 18 var tipText = Engine.TranslateLines(Engine.ReadFile(tipTextFilePath)); 24 tips = Engine.BuildDirEntList("gui/text/tips/", "*.txt", false); 25 tipControlsEnabled = !data.isNetworked 26 && Engine.ConfigDB_GetValue("user", "gui.loadingtips.enabled") === "true" 27 && tips && tips.length > 0; 19 28 20 if (tipText) 21 { 22 var index = tipText.indexOf("\n"); 23 var tipTextTitle = tipText.substring(0, index); 24 var tipTextMessage = tipText.substring(index); 25 Engine.GetGUIObjectByName("tipTitle").caption = tipTextTitle? tipTextTitle : ""; 26 Engine.GetGUIObjectByName("tipText").caption = tipTextMessage? tipTextMessage : ""; 27 } 29 Engine.GetGUIObjectByName("prevTipButton").hidden = !tipControlsEnabled; 30 Engine.GetGUIObjectByName("nextTipButton").hidden = !tipControlsEnabled; 28 31 29 // 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 Engine.GetGUIObjectByName("tipImage").sprite = sprite? sprite : ""; 34 } 35 else 36 error("Failed to find any matching tips for the loading screen."); 32 if (tips && tips.length > 0) 33 updateTip(getRandom(0, tips.length - 1)); 34 } 37 35 38 // janwas: main loop now sets progress / description, but that won't 39 // happen until the first timeslice completes, so set initial values. 40 var loadingMapName = Engine.GetGUIObjectByName("loadingMapName"); 36 function nextTip() 37 { 38 updateTip((tipIndex + 1) % tips.length); 39 } 41 40 42 if (data) 41 function prevTip() 42 { 43 updateTip((tips.length + tipIndex - 1) % tips.length); 44 } 45 46 function updateTip(nextTipIndex) 47 { 48 // Set tip text 49 tipIndex = nextTipIndex; 50 let tipTextFilePath = tips[tipIndex]; 51 let tipText = Engine.TranslateLines(Engine.ReadFile(tipTextFilePath)); 52 if (!tipText) 43 53 { 44 var mapName = translate(data.attribs.settings.Name); 45 switch (data.attribs.mapType) 46 { 47 case "skirmish": 48 case "scenario": 49 loadingMapName.caption = sprintf(translate("Loading “%(map)s”"), { "map": mapName }); 50 break; 51 52 case "random": 53 loadingMapName.caption = sprintf(translate("Generating “%(map)s”"), { "map": mapName }); 54 break; 55 56 default: 57 error("Unknown map type: " + data.attribs.mapType); 58 } 54 error("Failed to read tip text for the loading screen."); 55 return; 59 56 } 60 57 61 Engine.GetGUIObjectByName("progressText").caption = "";62 Engine.GetGUIObjectByName("progressbar").caption = 0;58 let index = tipText.indexOf("\n"); 59 let fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png"); 63 60 64 // Pick a random quote of the day (each line is a separate tip).65 var quoteArray = Engine.ReadFileLines("gui/text/quotes.txt");66 Engine.GetGUIObjectByName(" quoteText").caption = translate(quoteArray[getRandom(0, quoteArray.length-1)]);61 Engine.GetGUIObjectByName("tipTitle").caption = tipText.substring(0, index); 62 Engine.GetGUIObjectByName("tipText").caption = tipText.substring(index); 63 Engine.GetGUIObjectByName("tipImage").sprite = "stretched:" + "loading/tips/" + fileName; 67 64 } 68 65 69 66 function displayProgress() … … 78 75 Engine.GetGUIObjectByName("progressbar").caption = progress; // display current progress 79 76 Engine.GetGUIObjectByName("progressText").caption = progress + "%"; 80 77 81 // Displays detailed loading info rather than a percent82 // Engine.GetGUIObjectByName("progressText").caption = g_LoadDescription; // display current progess details83 84 78 // Keep curved right edge of progress bar in sync with the rest of the progress bar 85 varmiddle = Engine.GetGUIObjectByName("progressbar");86 varrightSide = Engine.GetGUIObjectByName("progressbar_right");79 let middle = Engine.GetGUIObjectByName("progressbar"); 80 let rightSide = Engine.GetGUIObjectByName("progressbar_right"); 87 81 88 varmiddleLength = (middle.size.right - middle.size.left) - (END_PIECE_WIDTH / 2);89 varincrement = Math.round(progress * middleLength / 100);82 let middleLength = (middle.size.right - middle.size.left) - (END_PIECE_WIDTH / 2); 83 let increment = Math.round(progress * middleLength / 100); 90 84 91 varsize = rightSide.size;85 let size = rightSide.size; 92 86 size.left = increment; 93 87 size.right = increment + END_PIECE_WIDTH; 94 88 rightSide.size = size; … … 100 94 */ 101 95 function reallyStartGame() 102 96 { 103 // Switch GUI from loading screen to game session. 97 if (!tipControlsEnabled) 98 { 99 startGame(); 100 return; 101 } 102 103 // Pause the game so it doesn't run while we read tips 104 Engine.SetPaused(true); 105 Engine.GetGUIObjectByName("startGameButton").hidden = false; 106 } 107 108 function startGame() 109 { 110 Engine.SetPaused(false); 111 112 // Switch GUI from loading screen to game session 104 113 Engine.SwitchGuiPage("page_session.xml", g_Data); 105 114 106 // Restore default cursor.107 Engine.SetCursor("arrow-default");108 109 115 // Notify the other clients that we have finished the loading screen 110 116 if (g_Data.isNetworked && g_Data.isRejoining) 111 117 Engine.SendNetworkRejoined(); -
binaries/data/mods/public/gui/loading/loading.xml
40 40 <object size="50%+128 50%-193 50%+448 50%+193" type="image" sprite="LoadingTipText"> 41 41 <object name="tipTitle" size="30 30 100% 50" type="text" style="LoadingTipTitleText"/> 42 42 <object name="tipText" size="30 50 100%-30 100%" type="text" style="LoadingTipText"/> 43 44 <!-- LOADING SCREEN TIP SHOW PREVIOUS --> 45 <object name="prevTipButton" type="button" size="20 100%-80 100 100%-40" z="99" hotkey="loading.previoustip" style="ModernButtonRed"> 46 <translatableAttribute id="caption">Previous</translatableAttribute> 47 <action on="Press">prevTip();</action> 48 </object> 49 50 <!-- LOADING SCREEN TIP SHOW NEXT --> 51 <object name="nextTipButton" type="button" size="100%-90 100%-80 100%-30 100%-40" z="99" hotkey="loading.nexttip" style="ModernButtonRed"> 52 <translatableAttribute id="caption">Next</translatableAttribute> 53 <action on="Press">nextTip();</action> 54 </object> 55 43 56 </object> 44 57 45 58 <!-- LOADING SCREEN QUOTE (needs increased z value to overcome the transparent area of the tip image above it --> … … 49 62 </object> 50 63 <object name="quoteText" size="0 30 100% 100%" type="text" style="LoadingText"></object> 51 64 </object> 65 52 66 </object> 67 68 <!-- LOADING SCREEN READY (needs increased z value to overcome the quote area --> 69 <object name="startGameButton" type="button" size="50%-200 80%+80 50%+200 80%+120" z="99" hidden="true" hotkey="confirm" style="ModernButtonRed"> 70 <translatableAttribute id="caption">I'm ready</translatableAttribute> 71 <action on="Press">startGame();</action> 72 </object> 73 53 74 </objects> -
binaries/data/mods/public/gui/options/options.js
15 15 [translate("Gametime Overlay"), translate("Show current simulation time in top right corner."), {"config":"gui.session.timeelapsedcounter"}, "boolean"], 16 16 [translate("Ceasefire Time Overlay"), translate("Always show the remaining ceasefire time."), {"config":"gui.session.ceasefirecounter"}, "boolean"], 17 17 [translate("Persist Match Settings"), translate("Save and restore match settings for quick reuse when hosting another game"), {"config":"persistmatchsettings"}, "boolean"], 18 [translate("Tip Controls"), translate("Allow navigating through loading screen tips and wait for the user before entering game."), {"config":"gui.loadingtips.enabled"}, "boolean"], 18 19 ], 19 20 "graphicsSetting": 20 21 [ … … 116 117 case "config": 117 118 // Load initial value if not yet loaded. 118 119 if (!checked || typeof checked != "boolean") 119 checked = Engine.ConfigDB_GetValue("user", option[2][action]) === "true" ? true : false;120 checked = Engine.ConfigDB_GetValue("user", option[2][action]) === "true"; 120 121 // Hacky macro to create the callback. 121 122 var callback = function(key) 122 123 {