Ticket #1090: loadsave.patch

File loadsave.patch, 3.1 KB (added by mimo, 2 years ago)

with fixes following IRC comments

  • binaries/data/mods/public/gui/savedgames/load.js

     
    88    if (!savedGames.length)
    99    {
    1010        gameSelection.list = [translate("No saved games found")];
    11         gameSelection.selected = 0;
     11        gameSelection.selected = -1;
    1212        Engine.GetGUIObjectByName("loadGameButton").enabled = false;
    1313        Engine.GetGUIObjectByName("deleteGameButton").enabled = false;
     14        Engine.GetGUIObjectByName("gameInfo").hidden = true;
    1415        return;
    1516    }
    1617
     
    2829        gameSelection.selected = savedGames.length - 1;
    2930}
    3031
     32function selectionChanged()
     33{
     34    let gameSelection = Engine.GetGUIObjectByName("gameSelection");
     35    if (gameSelection.selected == -1)
     36        return;
     37
     38    let metadata = g_SavedGamesMetadata[gameSelection.selected];
     39    let gameInfo = Engine.GetGUIObjectByName("gameInfo");
     40    gameInfo.hidden = false;
     41    gameInfo.caption = sprintf(translate("%(players)s | %(playedTime)s | %(mapType)s | %(gameType)s | %(mods)s"), {
     42        "players": translate("Players: ") + (metadata.initAttributes.settings.PlayerData.length - 1),
     43        "playedTime": translate("Played time: ") + (metadata.gui.timeElapsed ? Math.round(metadata.gui.timeElapsed/1000) : 0) + "s",
     44        "mapType": translate("Map type: ") + metadata.initAttributes.mapType,
     45        "gameType": translate("Game type: ") + metadata.initAttributes.settings.GameType,
     46        "mods": sprintf(translate("Mods: %(mods)s"), { "mods": metadata.mods.join(translate(", ")) })
     47    });
     48    gameInfo.tooltip = translate("Info on selected game");
     49}
     50
    3151function loadGame()
    3252{
    3353    var gameSelection = Engine.GetGUIObjectByName("gameSelection");
  • binaries/data/mods/public/gui/savedgames/load.xml

     
    2020            style="ModernList"
    2121            type="list"
    2222            size="24 24 100%-24 100%-100">
     23            <action on="SelectionChange">selectionChanged();</action>
    2324        </object>
    2425
     26        <object name="gameInfo" type="text" style="SmallLeftLabelText" size="24 100%-90 100%-24 100%-70" />
     27
    2528        <object type="button" size="0%+25 100%-60 33%+10 100%-32" style="StoneButton" hotkey="cancel">
    2629            <translatableAttribute id="caption">Cancel</translatableAttribute>
    2730            <action on="Press">Engine.PopGuiPage();</action>
  • binaries/data/mods/public/gui/savedgames/save.js

     
    1414
    1515function init(data)
    1616{
    17     g_SavedGameData = data && data.savedGameData || undefined;
     17    g_SavedGameData = data && data.savedGameData || {};
     18    g_SavedGameData.timeElapsed = Engine.GuiInterfaceCall("GetSimulationState").timeElapsed;
    1819
    1920    var gameSelection = Engine.GetGUIObjectByName("gameSelection");
    2021    Engine.GetGUIObjectByName("deleteGameButton").enabled = false;