Ticket #3512: t3512_phaseNotif_WIP_v0.2.patch

File t3512_phaseNotif_WIP_v0.2.patch, 7.9 KB (added by Bichtiades, 8 years ago)
  • binaries/data/config/default.cfg

     
    5454display = 0
    5555
    5656; Emulate right-click with Ctrl+Click on Mac mice
    5757macmouse = false
    5858
     59; > GAMEPLAY SETTINGS
     60teamNotification = true
     61
    5962; System settings:
    6063
    6164; if false, actors won't be rendered but anything entity will be.
    6265renderactors = true
    6366
  • 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": "Automatically send notifications to your allies when 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       
     60        <object name="gameplaySetting" type="image" sprite="ModernDarkBoxGold" size="620 40%+4 916 70%-4">
     61            <object style="ModernLabelText" type="text" size="0 5 100% 25">
     62                <translatableAttribute id="caption">Gameplay Settings</translatableAttribute>
     63            </object>
     64            <repeat count="1">
     65                <object name="gameplaySetting[n]" size="0 25 100% 50" hidden="true">
     66                    <object name="gameplaySettingLabel[n]" size="0 0 65% 100%" type="text" style="ModernLabelText" text_align="left"/>
     67                    <object name="gameplaySettingTickbox[n]" size="90% 5 100% 100%+5" type="checkbox" style="ModernTickBox" hidden="true"/>
     68                    <object name="gameplaySettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/>
     69                    <object name="gameplaySettingDropdown[n]" size="70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>
     70                </object>
     71            </repeat>
     72        </object>
     73       
     74        <object name="LobbySettings" type="image" sprite="ModernDarkBoxGold" size="620 70%+4 916 100%-52">
    6075            <object style="ModernLabelText" type="text" size="0 5 100% 25">
    6176                <translatableAttribute id="caption">Lobby Settings</translatableAttribute>
    6277            </object>
    6378            <repeat count="10">
    6479                <object name="lobbySetting[n]" size="0 25 100% 50" hidden="true">
     
    6782                    <object name="lobbySettingInput[n]" size="70% 0 100%-8 100%" type="input" style="ModernInput" hidden="true"/>
    6883                    <object name="lobbySettingDropdown[n]" size="70% 0 100%-8 100%" type="dropdown" style="ModernDropDown" hidden="true"/>
    6984                </object>
    7085            </repeat>
    7186        </object>
     87       
    7288        <object type="button" style="ModernButtonRed" size="50%-236 100%-44 50%-136 100%-16">
    7389            <translatableAttribute id="caption">Reset</translatableAttribute>
    7490            <translatableAttribute id="tooltip">Resets user settings to their game default</translatableAttribute>
    7591            <action on="Press">setDefaults();</action>
    7692        </object>
  • binaries/data/mods/public/gui/session/messages.js

     
    3434    "rejoined": msg => addChatMessage({ "type": "rejoined", "guid": msg.guid }),
    3535    "kicked": msg => addChatMessage({ "type": "system", "text": sprintf(translate("%(username)s has been kicked"), { "username": msg.username }) }),
    3636    "banned": msg => addChatMessage({ "type": "system", "text": sprintf(translate("%(username)s has been banned"), { "username": msg.username }) }),
    3737    "chat": msg => addChatMessage({ "type": "message", "guid": msg.guid, "text": msg.text }),
    3838    "aichat": msg => addChatMessage({ "type": "message", "guid": msg.guid, "text": msg.text, "translate": true }),
     39    //"AutoTeamMsg": msg => addChatMessage({ "type": "message", "guid": msg.guid, "text": msg.text, "translate": true }),
    3940    "gamesetup": msg => "", // Needed for autostart
    4041    "start": msg => ""
    4142};
    4243
    4344var g_FormatChatMessage = {
     
    178179                    continue;
    179180
    180181                message.parameters[param] = colorizePlayernameByID(message.parameters[param]);
    181182            }
    182183        }
    183 
     184   
     185        addChatMessage(message);
     186    },
     187    "AutoTeamMsg": function(notification, player)
     188    {
     189        // if the option is not enabled OR player has no allies, return
     190        if (Engine.ConfigDB_GetValue("user", "teamNotification") != "true")
     191            return;
     192           
     193        let message = {
     194            "guid": findGuidForPlayerID(player) || -1,
     195            "type": "message",
     196            "text": notification.message,
     197            "translate": true
     198        };
     199       
     200        if (message.guid == -1)
     201            message.player = player;
     202           
     203        if (notification.translateParameters)
     204        {
     205            message.translateParameters = notification.translateParameters;
     206            message.parameters = notification.parameters;
     207        }   
     208           
    184209        addChatMessage(message);
    185210    },
    186211    "defeat": function(notification, player)
    187212    {
    188213        addChatMessage({
  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    302302                else
    303303                    queue.AddBatch(cmd.template, "unit", +cmd.count);
    304304        }
    305305    },
    306306
     307/*
     308 *
     309 * name: g_Commands.research
     310 * @param
     311 * @return
     312 *
     313 */
    307314    "research": function(player, cmd, data)
    308315    {
    309316        if (!CanControlUnit(cmd.entity, player, data.controlAllUnits))
    310317        {
    311318            if (g_DebugCommands)
     
    322329        }
    323330
    324331        var queue = Engine.QueryInterface(cmd.entity, IID_ProductionQueue);
    325332        if (queue)
    326333            queue.AddBatch(cmd.template, "technology");
    327     },
     334       
     335        // if the researched technology is phasing, send a notification to GUI
     336        if (cmd.template == "phase_town" || cmd.template == "phase_city")
     337        {
     338            if (cmd.template == "phase_town")
     339                var _phase_ = "Town Phase";
     340            else
     341                var _phase_ = "City Phase";
    328342
     343            var cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     344           
     345            cmpGuiInterface.PushNotification({
     346                "type": "AutoTeamMsg",
     347                "players": [player],
     348                "message": "/allies " + markForTranslation("I am advancing to the %(phase)s."),
     349                "translateParameters": ["phase"],
     350                "parameters": { "phase": _phase_ },
     351                "translateMessage": true
     352            });
     353        }
     354    },
    329355    "stop-production": function(player, cmd, data)
    330356    {
    331357        if (!CanControlUnit(cmd.entity, player, data.controlAllUnits))
    332358        {
    333359            if (g_DebugCommands)