Ticket #3512: t3512_phaseNotif_WIP_v0.3.patch

File t3512_phaseNotif_WIP_v0.3.patch, 6.3 KB (added by Bichtiades, 8 years ago)

now the simulation sends a notification with just "player - type - event" fields, and the gui creates the message. I d like to hear suggestions on how to translate the message's string though.

  • binaries/data/config/default.cfg

     
    5454display = 0
    5555
    5656; Emulate right-click with Ctrl+Click on Mac mice
    5757macmouse = false
    5858
     59; Gameplay Settings
     60
     61; if true, receive automatic notifications from allies about their progress (currently only phasing notifications)
     62teamNotification = true
     63
    5964; System settings:
    6065
    6166; if false, actors won't be rendered but anything entity will be.
    6267renderactors = true
    6368
  • binaries/data/mods/public/gui/options/options.json

     
    200200            "label": "UI Gain",
    201201            "tooltip": "UI sound gain",
    202202            "parameters": { "config": "sound.uigain", "function": "SetUIGain", "min": "0" }
    203203        }
    204204    ],
     205    "gameplaySetting":
     206    [
     207        {
     208            "type": "boolean",
     209            "label": "Team Notifications",
     210            "tooltip": "Receive automatically created messages from your allies about their progress (currently: only when they are phasing up)",
     211            "parameters": { "config": "teamNotification" }
     212        }
     213    ],
    205214    "lobbySetting":
    206215    [
    207216        {
    208217            "type": "number",
    209218            "label": "Chat Backlog",
  • binaries/data/mods/public/gui/options/options.xml

     
    4141                    <object name="graphicsSettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/>
    4242                    <object name="graphicsSettingDropdown[n]" size="70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>
    4343                </object>
    4444            </repeat>
    4545        </object>
    46         <object name="SoundSettings" type="image" sprite="ModernDarkBoxGold" size="620 16 916 50%-4">
     46        <object name="SoundSettings" type="image" sprite="ModernDarkBoxGold" size="620 16 916 40%-4">
    4747            <object style="ModernLabelText" type="text" size="0 5 100% 25">
    4848                <translatableAttribute id="caption">Sound Settings</translatableAttribute>
    4949            </object>
    5050            <repeat count="10">
    5151                <object name="soundSetting[n]" size="0 25 100% 50" hidden="true">
     
    5454                    <object name="soundSettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/>
    5555                    <object name="soundSettingDropdown[n]" size="70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>
    5656                </object>
    5757            </repeat>
    5858        </object>
    59         <object name="LobbySettings" type="image" sprite="ModernDarkBoxGold" size="620 50%+4 916 100%-52">
     59        <object name="gameplaySetting" type="image" sprite="ModernDarkBoxGold" size="620 40%+4 916 70%-4">
     60            <object style="ModernLabelText" type="text" size="0 5 100% 25">
     61                <translatableAttribute id="caption">Gameplay Settings</translatableAttribute>
     62            </object>
     63            <repeat count="1">
     64                <object name="gameplaySetting[n]" size="0 25 100% 50" hidden="true">
     65                    <object name="gameplaySettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLabelText" text_align="left"/>
     66                    <object name="gameplaySettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/>
     67                    <object name="gameplaySettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/>
     68                    <object name="gameplaySettingDropdown[n]" size="70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>
     69                </object>
     70            </repeat>
     71        </object>
     72        <object name="LobbySettings" type="image" sprite="ModernDarkBoxGold" size="620 70%+4 916 100%-52">
    6073            <object style="ModernLabelText" type="text" size="0 5 100% 25">
    6174                <translatableAttribute id="caption">Lobby Settings</translatableAttribute>
    6275            </object>
    6376            <repeat count="10">
    6477                <object name="lobbySetting[n]" size="0 25 100% 50" hidden="true">
  • binaries/data/mods/public/gui/session/messages.js

     
    181181            }
    182182        }
    183183
    184184        addChatMessage(message);
    185185    },
     186    "AutoTeamMsg": function(notification, player)
     187    {
     188        // do not inform user of his own progress or if the option is not enabled
     189        if (Engine.ConfigDB_GetValue("user", "teamNotification") != "true" )//|| notification.players == Engine.GetPlayerID())
     190            return;
     191       
     192        let notification_message = "";
     193        if (notification.event == "advancing_phase_town")
     194            notification_message = translate("I am advancing to the Town Phase.");
     195        else if (notification.event == "advancing_phase_city")
     196            mnotification_message = translate("I am advancing to the City Phase.");
     197        // TODO: create messages for the events of phase reached, new civil center started, new market built, wonder
     198       
     199        let message = {
     200            "guid": findGuidForPlayerID(player) || -1,
     201            "type": "message",
     202            "text": "/allies " + notification_message,
     203            "translate": true
     204        };
     205       
     206        if (message.guid == -1)
     207            message.player = player;
     208           
     209        addChatMessage(message);
     210    },
    186211    "defeat": function(notification, player)
    187212    {
    188213        addChatMessage({
    189214            "type": "defeat",
    190215            "guid": findGuidForPlayerID(player),
  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    322322        }
    323323
    324324        var queue = Engine.QueryInterface(cmd.entity, IID_ProductionQueue);
    325325        if (queue)
    326326            queue.AddBatch(cmd.template, "technology");
     327           
     328        // if the researched technology is phasing, send a notification to GUI
     329        if (cmd.template == "phase_town" || cmd.template == "phase_city")
     330        {
     331            var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     332            cmpGuiInterface.PushNotification({
     333                "type": "AutoTeamMsg",
     334                "players": [player],
     335                "event": "advancing_" + cmd.template
     336            });
     337        }
    327338    },
    328339
    329340    "stop-production": function(player, cmd, data)
    330341    {
    331342        if (!CanControlUnit(cmd.entity, player, data.controlAllUnits))