-
Notifications
You must be signed in to change notification settings - Fork 198
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
WIP Add reorderstops overlay #889
base: master
Are you sure you want to change the base?
Conversation
13e0e1c
to
a7f269b
Compare
trackstop.lua
Outdated
end | ||
|
||
local function reset_guide_paths(conditions) | ||
for _i, condition in ipairs(conditions) do |
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.
for unused variables, the Lua convention is just to use an underscore with no other characters.
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.
Ah yeah that's it. Was wondering why it still showed greyed out in the editor but hadn't looked into it yet. ty!
trackstop.lua
Outdated
df.global.game.main_interface.recenter_indicator_m.x = item_pos.x | ||
df.global.game.main_interface.recenter_indicator_m.y = item_pos.y | ||
df.global.game.main_interface.recenter_indicator_m.z = item_pos.z |
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.
pass another , true
to revealInDwarfmodeMap
to get this for free
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.
Siick
trackstop.lua
Outdated
@@ -236,7 +260,170 @@ function RollerOverlay:init() | |||
} | |||
end | |||
|
|||
selected_stop = selected_stop or nil |
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.
why does this need to be a global instead of an instance variable in ReorderStopsWindow?
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.
Can fix!
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 guess with the way modals work I don't need the other global variable either. Nice. Removed that too.
trackstop.lua
Outdated
ReorderStopsWindow.ATTRS { | ||
frame={t=4,l=60,w=45, h=28}, | ||
frame_title='Reorder Stops', | ||
view_id='main', |
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 this is never referenced, you don't need to give it an explicit view_id
trackstop.lua
Outdated
|
||
ReorderStopsWindow = defclass(ReorderStopsWindow, widgets.Window) | ||
ReorderStopsWindow.ATTRS { | ||
frame={t=4,l=60,w=45, h=28}, |
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 this window contains a list with a variable number of elements, it would be useful to set resizable=true
trackstop.lua
Outdated
if item.type == 'stop' then | ||
local stop_index = item.stop_index | ||
|
||
-- don't allow moving stops to a different route |
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.
why not?
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.
Yeah this might be fine, I'll revisit it for sure.
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 possible
d642880
to
882f8e2
Compare
46811aa
to
068b6a3
Compare
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 have to admit this scares me a little bit, but if @ab9rf gives the ok that we've handled all the potential places where the id is stored, then I'll allow it.
- `trackstop`: provides 3 new overlays: | ||
- trackstop: allow changing track stop dump direction and friction | ||
- rollers: allow changing roller direction and speed | ||
- reorderstops: reorder stops in hauling routes |
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 kind of formatting doesn't translate well to the final rendered changelog. each line should be independent. If you start each of them with `trackstop`:
then they will get combined into a list similar to your intention here
ReorderStopsOverlay.ATTRS{ | ||
default_pos={x=6, y=6}, | ||
default_enabled=true, | ||
viewscreens='dwarfmode/Hauling', |
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.
is this specific enough, or should it disappear on hauling subscreens? We might need to extend Gui.cpp if this is the case
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.
It looks like it's okay on all of them except them item selection one. Will fix.
} | ||
|
||
local SELECT_STOP_HINT = 'Select a stop to move' | ||
local SELECT_ANOTHER_STOP_HINT = 'Select another stop to swap or same to cancel' |
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.
right click should also cancel out of a partially completed reorder operation. you can do this by handling keys._MOUSE_R
in ReorderStopsWindow:onInput(keys)
and returning true
if you have handled the right click and don't want the window to close.
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.
Fixed
the function where this all takes place in the game is one of the monsters that ghidra cannot decompile (i left it running for six hours and it was unable to do so). clearing the guide path after reordering the stop resolved the odd behavior we were seeing previously. there aren't any other fields involved and since we're just reordering the elements in the vector, pointers to the individual stops are unaffected. stockpile links to hauling stops are by pointer, not by id, so changing the hauling stop id doesn't affect those the one thing i'm not sure this covers is the |
also, make sure you test to see what happens if a minecart is en route to a reordered stop, both in the pushing case and the guided case |
Thanks to both of you! Will update and ensure to test these scenarios. |
I was wondering why I got a reply for my own notification, replied on my other account 😅 haha |
I think the code now handles updating If I have this setup: And I swap Stop 1 and Stop 4 (different physical locations): From the same initial setup, if I swap Stop 1 and Stop 5 (same physical locations): Again from that setup, if I swap Stop 2 and Stop 4 (different physical locations): Again from that setup, if I swap Stop 1 and Stop 2 (same route, same result regardless of which stop is selected first): So, if after swapping stops, the cart for that route is not physically at the stop index it was at before the swap, it will be moved there. If the swapped stop is at the same physical location, the cart will be considered in the right spot. If the stops are swapped within the same route, the vehicle index is updated appropriately. Still working on more playtesting. |
I have notes on the UX, but they can wait until you have the basic functionality tested |
Need to do some testing with this and figure out if changing the ids breaks stuff, or if anything else needs to be cleared out like the guide paths. Putting up what I have for now.