Open Moth-Tolias opened 2 years ago
Thoughts on a gui:
Overview
Info and hotkey hints on the sidebar, map visible. Managed farm plots visible on the map flash green. Unmanaged farm plots flash in red.
User can select a box on the screen to include/exclude farm plots.
On the sidebar, metadata is displayed about the current configuration:
Toggle hotkeys for enabling / disabling aboveground and underground plot management.
Hitting a hotkey ('t' for "thresholds"?) brings up a dialog (or maybe a full screen window, depending on how much space we need) where the user can manage thresholds.
The dialog shows plant types in the left column. Only plant types in stock are shown by default, but all types can be shown by toggling a setting.
The remaining columns are:
Use cursor keys to highlight a line. 'c' to copy threshold, 'p' to paste, 'del' to clear, enter to get an edit field where the user can enter a specific number (or empty to clear the current threshold), 'd' to set the default threshold.
Esc to close the dialog, and another esc to exit out of the menu overlay.
Implementation
Implemented as a guidm.MenuOverlay
subclass.
On GUI start, get id exclusion list, aboveground and below ground toggle settings, default threshold, and plant-specific thresholds from the plugin (via Lua).
Scan all buildings to get plot and tile counts, as well as positions of managed and unmanaged plot tiles.
Scan items for plants and seeds. Do we need to get the mapping of plant to seed from the plugin?
Use guidm.renderMapOverlay()
to highlight any onscreen farms (using the position map calculated in init()
)
Show dialog data in a List widget for the free scrolling and "cur line" logic? Maybe turn off the line highlight and just highlight the threshold column to indicate what is editable? On enter, maybe render an edit field over the threshold for the character input.
Need Lua API in the plugin for getting/setting config. Will also need "dry run" output to get which plants autofarm will plant next.
current state of UI:
I'm working on the details screen, but this is the information I'm thinking of putting on it: -- plant name -- plant id string -- target threshold -- plants on hand -- seeds on hand -- percent of map where this plant is plantable -- farm plots currently allocated to this plant -- plot tiles currently allocated to this plant -- farm plots allocated to this plant on next update -- plot tiles allocated to this plant on next update
Details screen is functional:
The proposed autofarm
Lua API is defined here: https://github.com/myk002/scripts/blob/myk_autofarm/gui/autofarm.lua#L21-L74
Keep in mind, these functions don't need to be implemented in C++ directly. There can be a different C++->Lua API with pure Lua wrappers in plugins/lua/autofarm.lua
that massage the data into the required formats. For example, it is relatively complex to send a set structure from C++ to Lua. It would be easier to send a vector across the language boundary, then have a Lua wrapper function (in plugins/lua/autofarm.lua
) turn the list into a set.
@myk002 Is this waiting on something? Or does it require changes due to 0.50.*? Seems like a very cool feature!
The GUI is finished, though it probably needs a refresh with more recent widgets. I wrote the code in this PR before I really knew what I was doing. It was never merged because autofarm
needs supporting changes first (which I could write, but I need to coordinate with @ab9rf)
as mentioned in the discord.
also, a gui