Skip to content
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

Make workorder-recheck work again #797

Merged
merged 7 commits into from
Aug 13, 2023

Conversation

TymurGubayev
Copy link
Contributor

@TymurGubayev TymurGubayev commented Aug 12, 2023

This repairs the workorder-recheck.lua script and adds an overlay to the work order conditions screen.

image

make `workorder-recheck` work again, add a widget
Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome back! I've honestly missed your work!

workorder-recheck.lua Outdated Show resolved Hide resolved

local function set_current_inactive()
local scrConditions = df.global.game.main_interface.info.work_orders.conditions
if scrConditions.open then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the condition that would allow the overlay to be shown or the focus string to match below. I suppose it doesn't hurt terribly to check it again, but I don't think it's necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it in case something went terribly wrong. I guess the only possible scenario is if the overlay would somehow be active when it shouldn't...

workorder-recheck.lua Outdated Show resolved Hide resolved
self:addviews{
widgets.HotkeyLabel{
frame={t=0, l=0},
label='recheck',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I understand the need for making this label short, "recheck" might be too short for players to grok. I'd want some input from people on the Discord server about what would be best here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about "re-check conditions" for this label? or maybe "request manager review"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"request conditions re-check"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just "request re-check"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I definitely want to keep the check there because it's everywhere on that screen

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

another option is the new widgets.TextButton that is designed to appear in more cramped spaces. It could fit in the single line directly above the active/inactive status icon.

screenshots of how that might look here: DFHack/dfhack#3655

example code: https://github.com/DFHack/dfhack/blob/9cb764b847f0dd0129e47d80b28e3c2c750b8738/plugins/lua/zone.lua#L1000

@TymurGubayev
Copy link
Contributor Author

another option is the new widgets.TextButton that is designed to appear in more cramped spaces. It could fit in the single line directly above the active/inactive status icon.

is there a way to find where elements are on a screen? I discovered the tabs can be 1 or 2 lines, which makes positioning tricky

@TymurGubayev
Copy link
Contributor Author

with default_pos={x=6,y=10}, and TextButton, it looks like this with two rows of tabs

image

but maximizing the DF window results in this:

image

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

You can try this:

  • make the overlay 2 tiles tall (and don't specify a frame_background)
  • on render, check the position of the status icon. If different from the last time you checked, adjust the TextButton frame and call updateLayout()

You can use dfhack.screen.readTile() to get what's on the screen at that position. The position you check should be relative to your overlay self.frame_rect (iirc)

@TymurGubayev
Copy link
Contributor Author

that would work if readTile worked... Here is what I get for every coordinate:

[lua]# ~ dfhack.screen.readTile(10, 10, false)
userdata: 00000208D89089B8
bold = true
bg = 0
tile_color = false
ch = 0
fg = 7

And passing true returns the map tile.

Am I missing something?

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

Hmm, I'm not sure. What does devel/inspect-screen say for those tiles?

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

ha, oh I see:
image
the image is completely rendered in the lower layer, which readTile doesn't pick up. Let me see if I can extend readTile to work in that case

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

for now, you can test in ASCII mode, which works:
image

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

you know what, maybe test for text (the ch property) at coordinates (7,7). That will be a character from a tab label if there are two rows of tabs and will be blank otherwise.

edit: changed coordinates from (7, 8) to (7, 7) so the check will be the same in ascii mode

@myk002
Copy link
Member

myk002 commented Aug 12, 2023

DFHack/dfhack#3670 will improve the readTile situation, but as I wrote above, I don't think you'll actually need it for this PR.

@TymurGubayev
Copy link
Contributor Author

the textbox is now correctly positioned in all 4 cases ( { graphics, ASCII } x { one row, two rows} )

workorder-recheck.lua Outdated Show resolved Hide resolved
workorder-recheck.lua Outdated Show resolved Hide resolved
workorder-recheck.lua Show resolved Hide resolved
self:addviews{
widgets.HotkeyLabel{
frame={t=0, l=0},
label='recheck',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about "re-check conditions" for this label? or maybe "request manager review"?

TymurGubayev and others added 3 commits August 13, 2023 12:17
Co-authored-by: Myk <myk.taylor@gmail.com>
Co-authored-by: Myk <myk.taylor@gmail.com>
Copy link
Member

@myk002 myk002 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome. Thanks!

@myk002 myk002 merged commit 01a8d46 into DFHack:master Aug 13, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants