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 gui/workorder-details and gui/workshop-job work again #799

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
84fc36d
Update workorder-details.lua
TymurGubayev Aug 13, 2023
1f9c249
Update workorder-details.rst
TymurGubayev Aug 13, 2023
9eca80b
remove trailing whitespaces
TymurGubayev Aug 13, 2023
8b559fd
merge workorder-details into workshop-job, update to not use `gui.dia…
TymurGubayev Sep 3, 2023
c94a5be
Update job-details.lua: fix whitespaces
TymurGubayev Sep 3, 2023
1f2c9f5
`require 'gui.dialogs'` for the `showMessage()`
TymurGubayev Sep 3, 2023
3846f1f
add instructions how to open the tool
TymurGubayev Sep 3, 2023
d80af4f
explain magic numbers
TymurGubayev Oct 2, 2023
d06b5a8
make use of more specific focus strings
TymurGubayev Oct 2, 2023
937e6d2
avoid redefining a variable
TymurGubayev Oct 2, 2023
e2bd30f
use more descriptive label text
TymurGubayev Oct 8, 2023
07a9ccd
separate ZScreenModal and Window
TymurGubayev Oct 10, 2023
bfa2892
separate ZScreenModal and Window, part 2
TymurGubayev Oct 10, 2023
590dd4a
add the widget to workorder conditions as well
TymurGubayev Nov 5, 2023
7603249
use HotkeyLabel to make actions clickable
TymurGubayev Nov 5, 2023
9ada99a
place the overlay text over task name in BuildingTask view regardless…
TymurGubayev Nov 5, 2023
ef0ebcc
do not show unnamed flags even if set
TymurGubayev Nov 5, 2023
bf055ab
job-details.rst: mention where can we find the tool
TymurGubayev Nov 5, 2023
85b92c0
enable in the workshops' work order details screen
TymurGubayev Nov 5, 2023
36985ed
improve positioning logic for building overlay
TymurGubayev Nov 6, 2023
069fd09
set auto_width=true on hotkey labels
TymurGubayev Nov 6, 2023
bd88a1a
remove the 'LEAVESCREEN' label
TymurGubayev Nov 7, 2023
77ab5b9
only hide numeric flag names if `dfhack.getHideArmokTools() == true`
TymurGubayev Nov 7, 2023
597c48a
Use user-friendly quantity instead of internal counter
TymurGubayev Nov 7, 2023
cd7ca2f
use window size do determine if tabs are in two rows
TymurGubayev Nov 7, 2023
bb95a28
disable the key if job has no items
TymurGubayev Nov 7, 2023
17ca139
add an ability to reset changes
TymurGubayev Nov 7, 2023
e861565
disable "change type" if Armok mode is off
TymurGubayev Nov 7, 2023
5ac5b9c
use special setItemType and setMaterial methods when resetting changes
TymurGubayev Nov 7, 2023
11393bc
fix a bug introduced in recent commit
TymurGubayev Nov 7, 2023
492417b
fix another bug
TymurGubayev Nov 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make use of more specific focus strings
  • Loading branch information
TymurGubayev authored Oct 2, 2023
commit d06b5a8a06687db11fa35379ece0878f73d464a7
29 changes: 3 additions & 26 deletions gui/job-details.lua
Original file line number Diff line number Diff line change
Expand Up @@ -395,40 +395,17 @@ function DetailsHotkeyOverlay:init()
}
end

local function isManagerOrderScreen()
local scr = ScrJobDetails()
return scr.context == df.job_details_context_type.MANAGER_WORK_ORDER
end

DetailsHotkeyOverlay_ManagerWorkOrder = defclass(DetailsHotkeyOverlay_ManagerWorkOrder, DetailsHotkeyOverlay)
DetailsHotkeyOverlay_ManagerWorkOrder.ATTRS{
default_pos={x=5, y=5}, -- {x=5, y=5} is right above the job title
viewscreens='dwarfmode/JobDetails/MANAGER_WORK_ORDER',
}
function DetailsHotkeyOverlay_ManagerWorkOrder:onRenderBody(dc)
if isManagerOrderScreen() then
self.subviews.button.visible = true
else
self.subviews.button.visible = false
return
end

DetailsHotkeyOverlay.super.onRenderBody(self, dc)
end

DetailsHotkeyOverlay_BuildingTask = defclass(DetailsHotkeyOverlay_BuildingTask, DetailsHotkeyOverlay)
DetailsHotkeyOverlay_BuildingTask.ATTRS{
default_pos={x=-123, y=6}, -- {x=-123, y=6} is right above the job title on all but smallest widths
default_pos={x=-120, y=6}, -- {x=-120, y=6} is right above the job title on all but smallest widths
Copy link
Member

Choose a reason for hiding this comment

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

I'd move this to the right by 5 so it still looks good at the smallest width

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 "reserved" the whole line using frame={w=1000, h= 1}, so that now with dfhack.screen.getWindowSize() I can move the hotkey around and it always fits.

It would've been nice to be able to move the widget itself. IIRC that wasn't possible last time I checked (half a year ago? because of label placement in the workorder-recheck.lua).

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 improved upon this. The logic is as follows now.

  1. Fix the distance from the right edge; make the widget slightly wider than necessary to allow moving the text around
  2. determine the calculated x1 coordinate of the frame, which is the screen width minus the distance from the right minus the widget width
  3. if the x1 < 0, set it to 0 --- making it the real position of the widget (I think this works better than built-in methods for some reason, although it's a few experiments back)
  4. is the real left edge position of the widget too far to the left (x1 < 6), move the text to the right (offset = 6 - x1).

This works well enough until you try to narrow the game window to the minimum and then widen it again. Then the self.frame.r is changed from 102 to 77 and stays that way. That's why the 4th step is needed

  1. restore original self.frame.r

Even with this after widening the window it doesn't immediately get the right position, but another small resizing in any direction sets it right.

viewscreens='dwarfmode/JobDetails/BUILDING_TASK_LIST',
}
function DetailsHotkeyOverlay_BuildingTask:onRenderBody(dc)
if not isManagerOrderScreen() then
self.subviews.button.visible = true
else
self.subviews.button.visible = false
return
end

DetailsHotkeyOverlay.super.onRenderBody(self, dc)
end

-- -------------------

Expand Down
Loading