Ticket #2087: 2087.3.diff
File 2087.3.diff, 10.2 KB (added by , 8 years ago) |
---|
-
binaries/data/config/default.cfg
220 220 ;9 = 221 221 ;10 = 222 222 223 [hotkey.loading] ; > LOADING SCREEN TOOLTIP HOTKEYS 224 previoustip = "LeftArrow" 225 nexttip = "RightArrow" 226 223 227 [hotkey.profile] 224 228 toggle = "F11" ; Enable/disable real-time profiler 225 229 save = "Shift+F11" ; Save current profiler data to logs/profile.txt … … 316 320 cursorblinkrate = 0.5 ; Cursor blink rate in seconds (0.0 to disable blinking) 317 321 scale = 1.0 ; GUI scaling factor, for improved compatibility with 4K displays 318 322 323 [gui.loadingtips] ; > LOADING SCREEN TIP CONTROLS 324 enabled = true 325 319 326 [gui.menu] 320 327 limitfps = true ; Limit FPS in the menus and loading screen 321 328 -
binaries/data/mods/public/gui/loading/loading.js
1 1 let g_Data; 2 let g_TipIndex; 3 let g_Tips; 2 4 const g_EndPieceWidth = 16; 3 5 4 6 function init(data) … … 5 7 { 6 8 g_Data = data; 7 9 8 // Set to "hourglass" cursor.9 Engine.SetCursor("cursor-wait");10 if (!g_Data) 11 return; 10 12 11 // Get tip image and corresponding tip text 12 let tipTextLoadingArray = Engine.BuildDirEntList("gui/text/tips/", "*.txt", false); 13 // Main loop now sets progress/description, but that won't 14 // happen until the first timeslice completes, so set initial values. 15 Engine.GetGUIObjectByName("loadingMapName").caption = sprintf( 16 data.attribs.mapType === "random" ? translate("Generating “%(map)s”") : translate("Loading “%(map)s”"), 17 { "map": translate(data.attribs.settings.Name) }); 13 18 14 if (tipTextLoadingArray.length > 0) 15 { 16 // Set tip text 17 let tipTextFilePath = tipTextLoadingArray[getRandom (0, tipTextLoadingArray.length-1)]; 18 let tipText = Engine.TranslateLines(Engine.ReadFile(tipTextFilePath)); 19 // Pick a random quote of the day (one quote per line). 20 let quoteArray = Engine.ReadFileLines("gui/text/quotes.txt"); 21 Engine.GetGUIObjectByName("quoteText").caption = translate(quoteArray[getRandom(0, quoteArray.length-1)]); 19 22 20 if (tipText) 21 { 22 let index = tipText.indexOf("\n"); 23 let tipTextTitle = tipText.substring(0, index); 24 let tipTextMessage = tipText.substring(index); 25 Engine.GetGUIObjectByName("tipTitle").caption = tipTextTitle? tipTextTitle : ""; 26 Engine.GetGUIObjectByName("tipText").caption = tipTextMessage? tipTextMessage : ""; 27 } 23 g_Tips = Engine.BuildDirEntList("gui/text/tips/", "*.txt", false); 24 let tipControlsEnabled = !data.isNetworked && 25 Engine.ConfigDB_GetValue("user", "gui.loadingtips.enabled") === "true" && 26 g_Tips && g_Tips.length > 0; 28 27 29 // Set tip image 30 let fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png"); 31 let tipImageFilePath = "loading/tips/" + fileName; 32 let 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."); 28 Engine.GetGUIObjectByName("prevTipButton").hidden = !tipControlsEnabled; 29 Engine.GetGUIObjectByName("nextTipButton").hidden = !tipControlsEnabled; 37 30 38 // janwas: main loop now sets progress / description, but that won't39 // happen until the first timeslice completes, so set initial values.40 let loadingMapName = Engine.GetGUIObjectByName("loadingMapName"); 31 if (g_Tips && g_Tips.length > 0) 32 updateTip(getRandom(0, g_Tips.length - 1)); 33 } 41 34 42 if (data) 43 { 44 let 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; 35 function nextTip() 36 { 37 updateTip((g_TipIndex + 1) % g_Tips.length); 38 } 51 39 52 case "random": 53 loadingMapName.caption = sprintf(translate("Generating “%(map)s”"), { "map": mapName }); 54 break; 40 function prevTip() 41 { 42 updateTip((g_Tips.length + g_TipIndex - 1) % g_Tips.length); 43 } 55 44 56 default: 57 error("Unknown map type: " + data.attribs.mapType); 58 } 45 function updateTip(nextTipIndex) 46 { 47 // Set tip text 48 g_TipIndex = nextTipIndex; 49 let tipTextFilePath = g_Tips[g_TipIndex]; 50 let tipText = Engine.TranslateLines(Engine.ReadFile(tipTextFilePath)); 51 if (!tipText) 52 { 53 error("Failed to read tip text for the loading screen."); 54 return; 59 55 } 60 56 61 Engine.GetGUIObjectByName("progressText").caption = "";62 Engine.GetGUIObjectByName("progressbar").caption = 0;57 let index = tipText.indexOf("\n"); 58 let fileName = tipTextFilePath.substring(tipTextFilePath.lastIndexOf("/")+1).replace(".txt", ".png"); 63 59 64 // Pick a random quote of the day (each line is a separate tip).65 let quoteArray = Engine.ReadFileLines("gui/text/quotes.txt");66 Engine.GetGUIObjectByName(" quoteText").caption = translate(quoteArray[getRandom(0, quoteArray.length-1)]);60 Engine.GetGUIObjectByName("tipTitle").caption = tipText.substring(0, index); 61 Engine.GetGUIObjectByName("tipText").caption = tipText.substring(index); 62 Engine.GetGUIObjectByName("tipImage").sprite = "stretched:" + "loading/tips/" + fileName; 67 63 } 68 64 69 65 function displayProgress() … … 78 74 Engine.GetGUIObjectByName("progressbar").caption = progress; // display current progress 79 75 Engine.GetGUIObjectByName("progressText").caption = progress + "%"; 80 76 81 // Displays detailed loading info rather than a percent82 // Engine.GetGUIObjectByName("progressText").caption = g_LoadDescription; // display current progess details83 84 77 // Keep curved right edge of progress bar in sync with the rest of the progress bar 85 78 let middle = Engine.GetGUIObjectByName("progressbar"); 86 79 let rightSide = Engine.GetGUIObjectByName("progressbar_right"); … … 100 93 */ 101 94 function reallyStartGame() 102 95 { 103 // Switch GUI from loading screen to game session. 96 if (Engine.GetGUIObjectByName("prevTipButton").hidden && Engine.GetGUIObjectByName("nextTipButton")) 97 { 98 startGame(); 99 return; 100 } 101 102 // Save the Camera Data 103 // TODO : Currently there is no function that returns the full camera position so if you zoom that will not be reset. 104 // We cannot prevent hotkeys from working because else the changing tooltip hotkeys wouldn't work. 105 g_Data.posZ = Engine.CameraGetZ(); 106 g_Data.posX = Engine.CameraGetX(); 107 // Pause the game so it doesn't run while we read tips 108 Engine.SetPaused(true); 109 Engine.GetGUIObjectByName("startGameButton").hidden = false; 110 } 111 112 function startGame() 113 { 114 Engine.SetPaused(false); 115 Engine.CameraMoveTo(g_Data.posX,g_Data.posZ); 116 // Switch GUI from loading screen to game session 104 117 Engine.SwitchGuiPage("page_session.xml", g_Data); 105 118 106 // Restore default cursor.107 Engine.SetCursor("arrow-default");108 109 119 // Notify the other clients that we have finished the loading screen 110 120 if (g_Data.isNetworked && g_Data.isRejoining) 111 121 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% 100 100%+30" 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% 100%-30 100%+30" z="99" hotkey="loading.nexttip" style="ModernButtonRed"> 52 <translatableAttribute id="caption">Next</translatableAttribute> 53 <action on="Press">nextTip();</action> 54 </object> 43 55 </object> 44 56 45 57 <!-- LOADING SCREEN QUOTE (needs increased z value to overcome the transparent area of the tip image above it --> … … 50 62 <object name="quoteText" size="0 30 100% 100%" type="text" style="LoadingText"></object> 51 63 </object> 52 64 </object> 65 66 <!-- LOADING SCREEN READY (needs increased z value to overcome the quote area --> 67 <object name="startGameButton" type="button" size="50%-200 80%+80 50%+200 80%+120" z="99" hidden="true" hotkey="confirm" style="ModernButtonRed"> 68 <translatableAttribute id="caption">I'm ready</translatableAttribute> 69 <action on="Press">startGame();</action> 70 </object> 71 53 72 </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 {