-
Notifications
You must be signed in to change notification settings - Fork 197
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
gui/probe
candidate
#967
Open
MagistrumT-T
wants to merge
9
commits into
DFHack:master
Choose a base branch
from
MagistrumT-T:gui-probe-proposal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
gui/probe
candidate
#967
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dc56d6c
Create gui\probe
MagistrumT-T 5788e71
Remove sneaky tabs and stop checking the tiles under the window.
MagistrumT-T 3f1f13f
Give user ability to unpause and move map around.
MagistrumT-T 2266109
Bring in suggested changes.
MagistrumT-T 38fa629
Add changelog and docs entry.
MagistrumT-T 4e6a0ef
Add mouse over tile marker.
MagistrumT-T 8ca9bb2
Make the cursor blink when in ascii mode
MagistrumT-T 3518bf4
Keep cursor at last probed position when locked or havering the panel.
MagistrumT-T bc9347f
Add cprobe and bprobe functionality.
MagistrumT-T File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
-- Shows the info given by `probe` in a friendly display | ||
|
||
local gui = require('gui') | ||
local guidm = require('gui.dwarfmode') | ||
local widgets = require('gui.widgets') | ||
local overlay = require('plugins.overlay') | ||
|
||
Probe = defclass(Probe, widgets.Window) | ||
Probe.ATTRS{ | ||
frame = { | ||
w = 40, | ||
h = 45, | ||
r = 2, | ||
t = 18, | ||
}, | ||
resizable=true, | ||
frame_title='Probe', | ||
} | ||
|
||
function Probe:init() | ||
self:addviews{ | ||
widgets.ToggleHotkeyLabel{ | ||
view_id='lock', | ||
frame={t=0, l=0}, | ||
key='CUSTOM_CTRL_F', | ||
label='Lock on tile:', | ||
initial_option=false, | ||
}, | ||
widgets.Label{ | ||
view_id='report', | ||
frame={t=2, l=0}, | ||
}, | ||
} | ||
end | ||
|
||
function Probe:onRenderBody() | ||
if self.subviews.lock:getOptionValue() or self:getMouseFramePos() then return end | ||
guidm.setCursorPos(dfhack.gui.getMousePos()) | ||
MagistrumT-T marked this conversation as resolved.
Show resolved
Hide resolved
|
||
local report = dfhack.run_command_silent('probe') | ||
self.subviews.report:setText(report) | ||
self:updateLayout() | ||
end | ||
|
||
function Probe:onInput(keys) | ||
if Probe.super.onInput(self, keys) then | ||
return true | ||
end | ||
if keys._MOUSE_L and not self:getMouseFramePos() then | ||
self.subviews.lock:cycle() | ||
return true | ||
end | ||
end | ||
|
||
ProbeScreen = defclass(ProbeScreen, gui.ZScreenModal) | ||
ProbeScreen.ATTRS{ | ||
focus_string='probe-screen', | ||
MagistrumT-T marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
function ProbeScreen:init() | ||
self:addviews{Probe{}} | ||
end | ||
|
||
function ProbeScreen:onDismiss() | ||
view = nil | ||
end | ||
|
||
if not dfhack.isMapLoaded() then | ||
qerror("This script requires a fortress map to be loaded") | ||
end | ||
|
||
view = view and view:raise() or ProbeScreen {}:show() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
since you're allowing the window to be resized, a
widgets.WrappedLabel
might be more appropriate here.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.
Now that I have done it I find it a bit harder to understand this way. The wrapping is perfect for the tiletypes section, but on the materials section it becomes difficult to parse and to someone who is not already used to probe it is impossible to discern what it is describing because there are a lot of colons on the material names/description.
Wondering if having text clearly going off screen wouldn't be better to hint to the player that he should extend the screen if he needs that bit of info, but I don't know if it is even common knowledge that you can move and resize DFHack screens, considering vanilla screens don't let you I don't think anyone even tries.
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.
if the text needs better formatting, you have a few options:
probe
itselfprobe
return the raw data in a structure via a Lua API call and you can format it yourselfThere 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.
Thinking a bit about it, I believe it would be very clear where and how wrapping is happening if we just color the words before the first colon on each line(if present). I don't suppose we have any markup or anything like that for the current label text pen situation? If not I think we are going with 2.