Hi, I had an idea for a widget and I was wondering if it already exists, and if not I was looking for some help on a few specific points in writing it.
This is essentially a port of the Rome: Total War formation system.
Basically, the widget would come with units pre-sorted into "roles", the standard raider, skirm, riot, assault, as well as some others like artillery, support, heavy, anti-heavy, and aa. Then, it would come with some pre-defined formations that arrange units into lines/boxes based on their role. Users select a formation from a small gui panel. When a group of selected units are issued a move or fight order with the widget (I'd like to bind it to LMB+RMB, but that's a detail) their target positions would be divided over their assigned box/line within the selected position similar to a standard line-move.
I know this sounds pedantic, but I manually set my units into formations in team games right now. Anecdotally, I find large armies in ZK do much better when arranged in a formation. Riots and assaults will tank the alpha during an approach and deliver massive DPS when they come in range of the defenses. The raiders just behind the front line emerge and provide more DPS while taking minimal damage since the riots/assault are still targeted. Arty and skirmishers stay safely behind a secure line, allowing them to deliver support without fear of a pack of raiders catching them out of position. (I'm interested to hear whether other players also use or would use formations in large games).
I'm pretty competent with Lua, but I'm not too familiar with the Spring API and how that all fits together. I know how to build the data structures for encoding formations, and the simple geometry needed to scale and quantize them into unit positions.
My specific questions follow:
1. How do I register a handler to be invoked via a key/mouse binding? (I'm guessing there's a "call-in" involved here)
2. How do I iterate over the currently selected units when the widget is invoked?
3. How do I register a new panel with buttons (as well as their handlers) on the GUI?
4. How do I assign orders to a selected unit?
5. How do I render boxes/lines on to the terrain to represent a preview of the formation while the user is issuing the order.
Any answers or pointers to widgets that do these things are very much appreciated.