Ticket #1028 (closed enhancement: fixed)
[PATCH] UI Enhancement: Right Click selection removal
| Reported by: | michael | Owned by: | kingadami |
|---|---|---|---|
| Priority: | Should Have | Milestone: | Alpha 13 |
| Component: | UI & Simulation | Keywords: | patch |
| Cc: |
Description (last modified by michael) (diff)
Currently, when multiple units are selected, the player can remove a unit (or group of like units) from the selection by ctrl+left clicking the icon portrait of that unit in the selection UI (center panel).
An enhancement here would be to also allow removal of units from the selection via simply right-clicking their icons in the center panel (no Ctrl key necessary). This does not replace the ctrl-left click, but adds a redundant method. Currently right-clicking icons in the center panel does nothing.
This is a GUI enhancement only/does not effect ctrl-clicking behavior in the game world.
Attachments
Change History
comment:6 Changed 17 months ago by gerbilOFdoom
- Owner set to gerbilOFdoom
- Status changed from new to assigned
Working on it... just give me some time.
Changed 17 months ago by gerbilOFdoom
- Attachment #1028.patch added
Patch to add right-click functionality
comment:7 follow-up: ↓ 12 Changed 17 months ago by gerbilOFdoom
- Keywords simple, review added; simple removed
- Status changed from assigned to closed
- Resolution set to fixed
- Summary changed from UI Enhancement: Right Click selection removal to [PATCH]UI Enhancement: Right Click selection removal
First time coding C++, although I reused the code from left-clicks... pretty exciting to have gotten something done!
comment:8 follow-up: ↓ 10 Changed 17 months ago by gerbilOFdoom
- Status changed from closed to reopened
- Resolution fixed deleted
comment:10 in reply to: ↑ 8 Changed 16 months ago by Ganon
Replying to gerbilOFdoom:
Why you discharge your solution? Are not good?
comment:11 Changed 16 months ago by gerbilOFdoom
Oh, I accidentally closed it before it was reviewed and applied. In order for it to show up in the review query, it has to be new, so I reset it to new. When it's applied, it should be closed by whoever applies it.
comment:12 in reply to: ↑ 7 Changed 16 months ago by historic_bruno
- Keywords simple added; simple, review removed
- Summary changed from [PATCH]UI Enhancement: Right Click selection removal to [PATCH] UI Enhancement: Right Click selection removal
Replying to gerbilOFdoom:
First time coding C++, although I reused the code from left-clicks... pretty exciting to have gotten something done!
Thanks, sorry it's taken a while to review :) Your patch seems to work well, I do have a few suggestions:
- changePrimarySelectionGroup in input.js: it probably shouldn't have a parameter called rightPressed, because generally the function doesn't care about the mouse state, we only want to indicate what type of action should be performed. I think it would be more appropriate to call it something like deselectGroup. Then in unit_commands.js when the button callbacks are set up, you can still pass true for right button presses (because no matter whether the hotkey was used or not, it's a deselect action) and then pass the Engine.HotkeyIsPressed(...) for the other press event callback.
- Right-click-press now toggles checkboxes and radio buttons, which is unusual behavior for GUIs, and it could lead to undesired behavior in future GUI objects if they handle the GUIM_PRESSED event expecting only left clicks. So I think you should add e.g. GUIM_PRESSED_MOUSE_RIGHT enums to EGUIMessageType in GUIbase.h, because they should be handled separately than the current press and double press events. (At first I was thinking we would need to likewise refactor the left-click-press events, but it may be possible in the future for buttons to be pressed in response to keystrokes, which would have no logical difference from a standard left-click-press, so it seems best to leave them for now.)
- It's nothing introduced by your script, but the switch blocks in IGUIButtonBehavior.cpp are unconventional in that the break statements for each case are on the same line as the closing "}" bracket. This is a good chance to correct that by moving each of them onto a new line.
- I think the added comment in IGUIButtonBehavior.h should either go before the end of the line (inside the period) or just be removed, it looks strange hanging at the end.
- Usually we update the copyright date at the top of C++ source files when modifying them, though inconsistently.
comment:13 Changed 15 months ago by k776
- Priority changed from If Time Permits to Nice to Have
- Milestone changed from Alpha 9 to Alpha 10
comment:14 Changed 14 months ago by k776
- Cc gerbilOFdoom added
- Keywords patch, added
Hey gerbilOFdoom. Any progress with implementing historic_bruno's suggestions? Keep to have this in Alpha 10 if we can.
comment:15 Changed 14 months ago by k776
- Keywords ui, patch added; UI, patch, simple removed
- Priority changed from Nice to Have to Should Have
comment:16 Changed 14 months ago by gerbilOFdoom
Sorry, forgot to do anything about his suggestions. I'll hop on it soon, once I wrap up my current web development ticket!
comment:19 Changed 12 months ago by gerbilOFdoom
Installing Visual Studio on my new OS.
comment:21 Changed 6 months ago by gerbilOFdoom
- Cc gerbilOFdoom removed
- Owner gerbilOFdoom deleted
I haven't fixed up the patch yet, not sure if I ever will. Removing myself from this so someone else can pick up where I left off.
comment:22 Changed 5 months ago by kingadami
- Owner set to kingadami
- Status changed from new to assigned
comment:25 Changed 5 months ago by quantumstate
Thanks for picking up this patch. Generally it looks ok, a few comments.
guiName == "Selection" should be guiName == SELECTION
Engine.HotkeyIsPressed?("selection.remove") should not be used, the hotkey is session.deselectgroup and this is already checked for in changePrimarySelectionGroup.
Also it would be better if you copy what has been done for research, so leave line 535 untouched and then add an if (guiName == SELECTION) {} block afterwards which sets onpress and onrightpress correctly for the selection case. This is so that you are not passing an unexpected boolean to all of the other callbacks.
Changed 5 months ago by kingadami
- Attachment 0adTicket_1028.patch added
Implemented quantumstate's suggestions. Thanks for the input. Picking up this patch is introducing me to the code without being overwelmed (along with making me learn javascript).
comment:26 Changed 5 months ago by kingadami
Updated patch file with quantumstate's suggestions. Thanks for the input.
comment:27 Changed 5 months ago by quantumstate
- Status changed from assigned to closed
- Resolution set to fixed
In 13040:
comment:28 Changed 5 months ago by quantumstate
- Keywords review removed
This is pretty nice to use, thanks for the joint effort on the patch. And of course it also makes things easier for other right click actions we might want to add.
