Loading...
  OR  Zero-K Name:    Password:   

EZSelector (Widget)

7 posts, 699 views
Post comment
Filter:    Player:  
sort
New Widget here

What it is:
- Holding down a key (user defined) will create a circular selector for specific unit types (again user defined!) with visual feedback. These are: Riots, Assaults, Arty, Raiders, and Skirms by default.
- Upon the release of the key, your selection will be changed to the circled units.
- Setting debug to true can help you with finding keys you want.

Very primitive. Would like to hear some feedback.

I'll be releasing a new version soon which is just a circular selector. Thought I'd at least release it since it was originally made for FRrankHelwor. Was teaching some lua to FRrankHelwor as well so don't mind the comments ^^

May develop this further.
+6 / -0
7 years ago
This sounds pretty good, anything better than current autogroup would be great.
Maybe you could provide some screenshoots or a vid?
+0 / -0
The selection preview is a little primitive but here's some screen shots.



Probably needs a deeper blue but w/e


Don't you just hate it when you just want a role of units in a clusterfuck like this?




Btw: You can change the radius of the selector too! It even gives a helpful preview (it only renders for 3 frames too!)



With some time I'll make it better. I don't know how to 'highlight' units yet in openGL (my knowledge is very limited :( ). But hey, it's my first widget incorporating visuals :D

I'm wondering if there was a way to provide selection tools somehow. Finding a good key for it is hard. Circular selection might be a cool thing if I can figure out how to bind it to the mouse or something.
+4 / -0
Nice, a bit like the 'old' selection-hotkeys of engine but with visuals.
Maybe have outline on the text, especially the blue text is hard to read I think.

For keycode constants you can include this file
https://github.com/spring/spring/blob/5f08624585852b8c8dfd1a16d020ae530269dc09/cont/LuaUI/Headers/keysym.h.lua
via
include("keysym.h.lua")
and then be like
function widget:KeyPress(key)
if (key == KEYSYMS.S) then


For TraceScreenRay and its random numbers see
https://springrts.com/wiki/Lua_UnsyncedRead#Screen_Trace
This is a bit 'guessing' and can be UB:
quote:

if Spring.ValidUnitID(pos) then
x,_,y = Spring.GetUnitPosition(pos)
elseif Spring.ValidFeatureID(pos) then
Say the ray hits the feature with ID=25. But elsewhere there is also a unit with ID=25.
Then ValidUnitID(pos) will be true but will not be what you want.
(Super unlikely but since the returned values tell if it hit a unit/feature/ground, use that.)

Instead of GameFrame() maybe try Update() because GameFrame stops ticking during pause.
(So the widget keeps working during pausewars like other GUI)
+2 / -0


7 years ago
Ah yes, update would be better. The reason why I put the actual work in gameframe is because during testing I originally had it in KeyPressed, but this killed my performance (went from ~135fps to 5!).

quote:
and then be like
function widget:KeyPress(key)
if (key == KEYSYMS.S) then


Oh wow! That's really useful to know. I saw the other day about in-game settings, I wonder if I could read settings from there and use this to translate.

quote:
(Super unlikely but since the returned values tell if it hit a unit/feature/ground, use that.)

Huh. I think since it's now onlyCoords = true it shouldn't have that issue? Probably safe to remove the extra code, but I keep it there just in case. It does seem to prevent annoying snapping.

quote:
Maybe have outline on the text, especially the blue text is hard to read I think.

I'd have to add 'o' or 'O' to 'v' right?

I'll make changes today to reflect on this. Thanks for the helpful pointers.
+0 / -0

7 years ago
thanks, it's awesome
+0 / -0

7 years ago
Here is hacked version, that does not crash:
http://pastebin.com/PGjf4Y2n

Knorke-s suggestions are on the spot.
+0 / -0