1
0
forked from 0ad/0ad

Display the updated batch size immediately when using the batch-train/barter hotkey, instead of waiting for the next turn. Patch by elexis. Fixes #3194

This was SVN commit r19028.
This commit is contained in:
wraitii 2016-12-07 19:18:57 +00:00
parent 977a5c7ca2
commit 78bc56f33e
3 changed files with 25 additions and 3 deletions

View File

@ -62,6 +62,16 @@
<action on="Press">backToWork();</action>
</object>
<object hotkey="session.batchtrain">
<action on="Press">updateSelectionDetails();</action>
<action on="Release">updateSelectionDetails();</action>
</object>
<object hotkey="session.massbarter">
<action on="Press">updateSelectionDetails();</action>
<action on="Release">updateSelectionDetails();</action>
</object>
<!-- Find idle warrior - TODO: Potentially move this to own UI button? -->
<object hotkey="selection.idlewarrior">
<action on="Press">findIdleUnit(g_MilitaryTypes);</action>

View File

@ -67,13 +67,24 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
{
InReaction ret = IN_PASS;
if (ev->ev.type == SDL_HOTKEYDOWN)
if (ev->ev.type == SDL_HOTKEYDOWN || ev->ev.type == SDL_HOTKEYUP)
{
const char* hotkey = static_cast<const char*>(ev->ev.user.data1);
std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey);
if (it != m_HotkeyObjects.end())
for (IGUIObject* const& obj : it->second)
obj->SendEvent(GUIM_PRESSED, "press");
{
// Update hotkey status before sending the event,
// else the status will be outdated when processing the GUI event.
HotkeyInputHandler(ev);
ret = IN_HANDLED;
if (ev->ev.type == SDL_HOTKEYDOWN)
obj->SendEvent(GUIM_PRESSED, "press");
else
obj->SendEvent(GUIM_RELEASED, "release");
}
}
else if (ev->ev.type == SDL_MOUSEMOTION)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2015 Wildfire Games.
/* Copyright (C) 2016 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -72,6 +72,7 @@ enum EGUIMessageType
GUIM_MOUSE_WHEEL_DOWN,
GUIM_SETTINGS_UPDATED, // SGUIMessage.m_Value = name of setting
GUIM_PRESSED,
GUIM_RELEASED,
GUIM_DOUBLE_PRESSED,
GUIM_MOUSE_MOTION,
GUIM_LOAD, // Called when an object is added to the GUI.