Ticket #3194: gui_hotkey_release_event_v1_debug.patch
File gui_hotkey_release_event_v1_debug.patch, 6.2 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/gui/session/hotkeys/misc.xml
48 48 49 49 <object hotkey="session.stop"> 50 50 <action on="Press">stopUnits(g_Selection.toList());</action> 51 51 </object> 52 52 53 <object hotkey="session.batchtrain"> 54 <action on="Press">warn("Processing batchtrain PRESS");updateSelectionDetails();</action> 55 <action on="Release">warn("Processing batchtrain RELEASE");updateSelectionDetails();</action> 56 </object> 57 58 <object hotkey="session.massbarter"> 59 <action on="Press">warn("Processing massbarter PRESS");updateSelectionDetails();</action> 60 <action on="Release">warn("Processing massbarter RELEASE");updateSelectionDetails();</action> 61 </object> 62 53 63 <!-- Find idle warrior - TODO: Potentially move this to own UI button? --> 54 64 <object hotkey="selection.idlewarrior"> 55 65 <action on="Press">findIdleUnit(["Hero", "Champion", "CitizenSoldier", "Siege", "Warship", "Dog"]);</action> 56 66 </object> 57 67 -
binaries/data/mods/public/gui/session/selection_panels.js
g_SelectionPanels.Barter = { 112 112 let selectionIcon = Engine.GetGUIObjectByName("unitBarterSellSelection[" + data.i + "]"); 113 113 114 114 let amountToSell = BARTER_RESOURCE_AMOUNT_TO_SELL; 115 115 if (Engine.HotkeyIsPressed("session.massbarter")) 116 116 amountToSell *= BARTER_BUNCH_MULTIPLIER; 117 117 warn("CHECKING massbarter pressed: " + String(Engine.HotkeyIsPressed("session.massbarter"))); 118 118 amount.Sell.caption = "-" + amountToSell; 119 119 let prices = data.unitEntState.barterMarket.prices; 120 120 amount.Buy.caption = "+" + Math.round(prices.sell[g_BarterSell] / prices.buy[data.item] * amountToSell); 121 121 122 122 let resource = getLocalizedResourceName(data.item, "withinSentence"); … … g_SelectionPanels.Training = { 974 974 getTrainingBatchStatus(data.playerState, data.unitEntState.id, data.item, data.selection); 975 975 976 976 let trainNum = buildingsCountToTrainFullBatch || 1; 977 977 if (Engine.HotkeyIsPressed("session.batchtrain")) 978 978 trainNum = buildingsCountToTrainFullBatch * fullBatchSize + remainderBatch; 979 979 warn("CHECKING batchtrain pressed: " + String(Engine.HotkeyIsPressed("session.batchtrain"))); 980 980 let neededResources; 981 981 if (template.cost) 982 982 neededResources = Engine.GuiInterfaceCall("GetNeededResources", { 983 983 "cost": multiplyEntityCosts(template, trainNum), 984 984 "player": data.unitEntState.player -
source/gui/CGUI.cpp
const u32 MAX_OBJECT_DEPTH = 100; // Max 63 63 64 64 InReaction CGUI::HandleEvent(const SDL_Event_* ev) 65 65 { 66 66 InReaction ret = IN_PASS; 67 67 68 if (ev->ev.type == SDL_HOTKEYDOWN )68 if (ev->ev.type == SDL_HOTKEYDOWN || ev->ev.type == SDL_HOTKEYUP) 69 69 { 70 70 const char* hotkey = static_cast<const char*>(ev->ev.user.data1); 71 if (CStr(hotkey) == "session.batchtrain" || CStr(hotkey) == "session.massbarter") 72 LOGERROR("HandleEvent %s", hotkey); 73 71 74 std::map<CStr, std::vector<IGUIObject*> >::iterator it = m_HotkeyObjects.find(hotkey); 72 75 if (it != m_HotkeyObjects.end()) 73 76 for (IGUIObject* const& obj : it->second) 74 obj->SendEvent(GUIM_PRESSED, "press"); 77 { 78 // Update hotkey status before sending the event, 79 // else the status will be outdated when processing the GUI event. 80 HotkeyInputHandler(ev); 81 ret = IN_HANDLED; 82 83 if (ev->ev.type == SDL_HOTKEYDOWN) 84 obj->SendEvent(GUIM_PRESSED, "press"); 85 else 86 obj->SendEvent(GUIM_RELEASED, "release"); 87 } 75 88 } 76 89 77 90 else if (ev->ev.type == SDL_MOUSEMOTION) 78 91 { 79 92 // Yes the mouse position is stored as float to avoid -
source/gui/GUIbase.h
1 /* Copyright (C) 201 5Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … enum EGUIMessageType 70 70 GUIM_MOUSE_RELEASE_RIGHT, 71 71 GUIM_MOUSE_WHEEL_UP, 72 72 GUIM_MOUSE_WHEEL_DOWN, 73 73 GUIM_SETTINGS_UPDATED, // SGUIMessage.m_Value = name of setting 74 74 GUIM_PRESSED, 75 GUIM_RELEASED, 75 76 GUIM_DOUBLE_PRESSED, 76 77 GUIM_MOUSE_MOTION, 77 78 GUIM_LOAD, // Called when an object is added to the GUI. 78 79 GUIM_GOT_FOCUS, 79 80 GUIM_LOST_FOCUS, -
source/ps/Hotkey.cpp
1 /* Copyright (C) 201 5Wildfire Games.1 /* Copyright (C) 2016 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify 5 5 * it under the terms of the GNU General Public License as published by 6 6 * the Free Software Foundation, either version 2 of the License, or … … InReaction HotkeyInputHandler(const SDL_ 191 191 break; 192 192 } 193 193 return IN_PASS; 194 194 195 195 case SDL_HOTKEYDOWN: 196 { 197 const char* hotkey = static_cast<const char*>(ev->ev.user.data1); 198 if (CStr(hotkey) == "session.batchtrain" || CStr(hotkey) == "session.massbarter") 199 LOGERROR("HotkeyInputHandler DOWN %s", static_cast<const char*>(ev->ev.user.data1)); 196 200 g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = true; 197 201 return IN_PASS; 198 202 } 199 203 case SDL_HOTKEYUP: 204 { 205 const char* hotkey = static_cast<const char*>(ev->ev.user.data1); 206 if (CStr(hotkey) == "session.batchtrain" || CStr(hotkey) == "session.massbarter") 207 LOGERROR("HotkeyInputHandler UP %s", static_cast<const char*>(ev->ev.user.data1)); 200 208 g_HotkeyStatus[static_cast<const char*>(ev->ev.user.data1)] = false; 201 209 return IN_PASS; 202 210 } 203 211 default: 204 212 return IN_PASS; 205 213 } 206 214 207 215 // Somewhat hackish: