-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create gui/tooltips.lua: show info (f.e. job name) at units and/or mouse cursor #1365
base: master
Are you sure you want to change the base?
Conversation
I am intrigued and delighted : ) |
Let me finish reviewing DFHack/dfhack#4959 so getUnitsInBox no longer returns inactive units |
@@ -0,0 +1,281 @@ | |||
-- Show tooltips on units and/or mouse | |||
|
|||
local RELOAD = false -- set to true when actively working on this script |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, devel/clear-script-env
has the same effect:
multicmd devel/clear-script-env gui/tooltips; gui/tooltips
:tags: fort inspection | ||
|
||
This script shows "tooltips" following units and/or mouse with job names. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an **IMPORTANT NOTE**
at the beginning of the description text
docs/gui/tooltips.rst
Outdated
:summary: Show tooltips with useful info. | ||
:tags: fort inspection | ||
|
||
This script shows "tooltips" following units and/or mouse with job names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs more description of the two options and their effects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a bit of clarification...
It's kind of hard to describe though
Co-authored-by: Myk <[email protected]>
Co-authored-by: Myk <[email protected]>
Btw this PR has started some discussion on the Discord server where your input would be valuable: https://discord.com/channels/793331351645323264/807444515194798090/1325754489659195502 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My feedback:
- this would be better as a fullscreen overlay that could be toggled via a keybinding bound to
dwarfmode/Default
anddungeonmode/Default
(file). It could also be toggleable fromgui/tooltips
(which becomes just the configuration interface instead of the rendering mechanism). I don't want to promote leaving a windowed DFHack tool on the screen indefinitely because of Prevent crash if DFHack GUI window is open when exiting fort dfhack#4183 - the enabled state should be managed by the overlay framework. this means that whether the tooltips are displayed is a per-player global setting. The tooltip behavior/contents configuration would likewise be global, stored in
dfhack-config/tooltips.json
There were some reservations about the name gui/tooltips
-- I'll get more feedback from people about that on Discord.
not required for this PR but maybe consider as a future enhancement:
- the configuration for which elements to display could be a matrix of checkboxes so players could choose any combination of information for the tooltip and the mouseover.
is there a CheckBox control, or what should I use for this? |
There isn't a super convenient widget for that yet, largely because every place I've needed toggle checkboxes so far, they've been in a list (which doesn't take widgets). See |
@@ -267,7 +269,7 @@ function MouseTooltip:render(dc) | |||
|
|||
local pos = dfhack.gui.getMousePos() | |||
local text = GetTooltipText(pos) | |||
if #text == 0 then return end | |||
if not text or #text == 0 then return end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not just an ascii mode exception -- dfhack.gui.getMousePos() would return nil in graphics mode too if the mouse cursor is not over the DF window
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't reproduce it in graphics though, probably because of the check just above for the dfhack.screen.getMousePos()
return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as discussed on Discord, could you rename gui/tooltips
to gui/spectate
and move the overlay code to plugins/lua/spectate.lua
? spectate
itself will need a bit of an overhaul. I can do that or you can if you'd like to.
local gui = require('gui') | ||
local widgets = require('gui.widgets') | ||
local overlay = require('plugins.overlay') | ||
local ResizingPanel = require('gui.widgets.containers.resizing_panel') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't need to be individually imported -- it can already be addressed as widgets.ResizingPanel
|
||
-- pens are the same as gui/control-panel.lua | ||
local textures = require('gui.textures') | ||
local function get_icon_pens() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ugly duplication, but we don't have a good widget API for it yet, so I don't think there's a better option. We can change this later once we have a better way to address this fairly common use case. I see orders.lua
does some similar duplication for the workshop labor restrictions overlay.
yeah, that might be a good idea :) But how? |
order of rendering in |
I'll try to do that, just can't promise when. |
I can overhaul |
The script shows some info (currently: name of the job) in tooltips (sort of...) following units and or mouse (see screenshot).