Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -404,6 +404,10 @@ move.left = "Ctrl+LeftArrow" ; Move cursor to start of word to the left of cursor move.right = "Ctrl+RightArrow" ; Move cursor to start of word to the right of cursor +[hotkey.loading] +previoustip = "LeftArrow" ; Switch to the previous tip in the loading screen. +nexttip = "RightArrow" ; Switch to the next tip in the loading screen. + [gui] cursorblinkrate = 0.5 ; Cursor blink rate in seconds (0.0 to disable blinking) scale = 1.0 ; GUI scaling factor, for improved compatibility with 4K displays Index: binaries/data/mods/public/gui/loading/TipDisplay.js =================================================================== --- binaries/data/mods/public/gui/loading/TipDisplay.js +++ binaries/data/mods/public/gui/loading/TipDisplay.js @@ -9,22 +9,92 @@ this.tipImage = Engine.GetGUIObjectByName("tipImage"); this.tipTitle = Engine.GetGUIObjectByName("tipTitle"); this.tipText = Engine.GetGUIObjectByName("tipText"); + this.previousTipButton = Engine.GetGUIObjectByName("previousTip"); + this.nextTipButton = Engine.GetGUIObjectByName("nextTip"); + this.previousTipButton.caption = this.CaptionPreviousTip; + this.nextTipButton.caption = this.CaptionNextTip; + + this.tipsDisplayedIndex = -1; + this.tipsDisplayed = []; + this.tipFiles = listFiles(this.TextPath, ".txt", false); - this.displayRandomTip(); + + this.setupButtons(); } - displayRandomTip() + setupButtons() { - let tipFile = pickRandom(this.tipFiles); - if (tipFile) - this.displayTip(tipFile); - else + if (this.tipFiles.length === 0) + { error("Failed to find any matching tips for the loading screen."); + return; + } + + //we are going yo build tips random + while (this.tipsDisplayed.length < this.tipFiles.length) + this.pickRandomTip(); + + this.tipsDisplayedIndex = 0; + this.displayTip(this.tipsDisplayed[this.tipsDisplayedIndex]); + + this.nextTipButton.onPress = this.onNextTip.bind(this); + this.previousTipButton.onPress = this.onPreviousTip.bind(this); + + this.refreshButtonVisibility(); } + refreshButtonVisibility() + { + this.previousTipButton.hidden = this.tipsDisplayedIndex === 0; + this.nextTipButton.hidden = this.tipsDisplayedIndex >= this.tipsDisplayed.length - 1; + } + + onPreviousTip() + { + this.tipsDisplayedIndex--; + if (this.tipsDisplayedIndex < 0) + this.tipsDisplayedIndex = 0; + + this.displayTip(this.tipsDisplayed[this.tipsDisplayedIndex]); + this.refreshButtonVisibility(); + } + + onNextTip() + { + this.tipsDisplayedIndex++; + if (this.tipsDisplayedIndex > this.tipsDisplayed.length) + this.tipsDisplayedIndex = this.tipsDisplayed.length - 1; + + this.displayTip(this.tipsDisplayed[this.tipsDisplayedIndex]); + this.refreshButtonVisibility(); + } + + pickRandomTip() + { + let tipFile = undefined; + + while (true) + { + tipFile = pickRandom(this.tipFiles); + + if (!tipFile || !this.tipsDisplayed.includes(tipFile)) + break; + } + + if (tipFile) + { + this.tipsDisplayed.push(tipFile); + return true; + } + + return false + } + displayTip(tipFile) { + if (!tipFile) + return; this.tipImage.sprite = "stretched:" + this.ImagePath + tipFile + ".png"; @@ -60,3 +130,7 @@ // Translation: A bullet point used before every item of list of tips displayed on loading screen TipDisplay.prototype.BulletFormat = translate("ÔÇó %(tiptext)s"); + +TipDisplay.prototype.CaptionPreviousTip = translate("Previous"); + +TipDisplay.prototype.CaptionNextTip = translate("Next"); Index: binaries/data/mods/public/gui/loading/TipDisplay.xml =================================================================== --- binaries/data/mods/public/gui/loading/TipDisplay.xml +++ binaries/data/mods/public/gui/loading/TipDisplay.xml @@ -11,5 +11,7 @@ +