From 78bc56f33eb70d2fb153f9f65c633bc9f7e77186 Mon Sep 17 00:00:00 2001 From: wraitii Date: Wed, 7 Dec 2016 19:18:57 +0000 Subject: [PATCH] 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. --- .../data/mods/public/gui/session/hotkeys/misc.xml | 10 ++++++++++ source/gui/CGUI.cpp | 15 +++++++++++++-- source/gui/GUIbase.h | 3 ++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/binaries/data/mods/public/gui/session/hotkeys/misc.xml b/binaries/data/mods/public/gui/session/hotkeys/misc.xml index b258530a3f..87844d24c3 100644 --- a/binaries/data/mods/public/gui/session/hotkeys/misc.xml +++ b/binaries/data/mods/public/gui/session/hotkeys/misc.xml @@ -62,6 +62,16 @@ backToWork(); + + updateSelectionDetails(); + updateSelectionDetails(); + + + + updateSelectionDetails(); + updateSelectionDetails(); + + findIdleUnit(g_MilitaryTypes); diff --git a/source/gui/CGUI.cpp b/source/gui/CGUI.cpp index a78d7b1b35..c5efeed48c 100644 --- a/source/gui/CGUI.cpp +++ b/source/gui/CGUI.cpp @@ -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(ev->ev.user.data1); + std::map >::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) diff --git a/source/gui/GUIbase.h b/source/gui/GUIbase.h index f71c7331d4..553e94b9e1 100644 --- a/source/gui/GUIbase.h +++ b/source/gui/GUIbase.h @@ -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.