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

adapt to canonicalized structures #1165

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions gui/advfort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1420,20 +1420,20 @@ function track_stop_configure(bld) --TODO: dedicated widget with nice interface
local choices={"Friction","Dumping"}
local function chosen(index,choice)
if choice.text=="Friction" then
dialog.showInputPrompt("Choose friction","Friction",nil,tostring(bld.friction),function ( txt )
dialog.showInputPrompt("Choose friction","Friction",nil,tostring(bld.track_stop_info.friction),function ( txt )
local num=tonumber(txt) --TODO allow only vanilla friction settings
if num then
bld.friction=num
bld.track_stop_info.friction=num
end
end)
else
dialog.showListPrompt("Dumping direction", "Choose dumping:",COLOR_WHITE,dump_choices,function ( index,choice)
if choice.x then
bld.track_flags.use_dump=true
bld.dump_x_shift=choice.x
bld.dump_y_shift=choice.y
bld.track_stop_info.track_flags.use_dump=true
bld.track_stop_info.dump_x_shift=choice.x
bld.track_stop_info.dump_y_shift=choice.y
else
bld.track_flags.use_dump=false
bld.track_stop_info.track_flags.use_dump=false
end
end)
end
Expand Down
8 changes: 4 additions & 4 deletions internal/quickfort/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ local function do_trackstop_props(db_entry, props)
(props.friction == '50000' or props.friction == '10000' or props.friction == '500' or
props.friction == '50' or props.friction == '10')
then
db_entry.props.friction = tonumber(props.friction)
ensure_key(db_entry.props, 'track_stop_info').friction = tonumber(props.friction)
props.friction = nil
end
if props.take_from then
Expand Down Expand Up @@ -632,13 +632,13 @@ local function make_transform_trackstop_fn(vector, friction)
return make_transform_building_fn(vector, trackstop_revmap, post_fn)
end
local function make_trackstop_entry(direction, friction)
local label, fields, transform = 'No Dump', {friction=friction}, nil
local label, fields, transform = 'No Dump', {track_stop_info={friction=friction}}, nil
if direction then
ensure_key(fields, 'track_flags').use_dump = true
ensure_key(fields.track_stop_info, 'track_flags').use_dump = true
for k,v in pairs(direction) do
local trackstop_data_entry = trackstop_data[k][v]
label = trackstop_data_entry.label
fields[k] = v
fields.track_stop_info[k] = v
transform = make_transform_trackstop_fn(
trackstop_data_entry.vector, friction)
end
Expand Down
11 changes: 2 additions & 9 deletions trackstop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,8 @@ TrackStopOverlay.ATTRS{
frame_background=gui.CLEAR_PEN,
}

function TrackStopOverlay:getFriction()
return dfhack.gui.getSelectedBuilding().friction
end

function TrackStopOverlay:setFriction(friction)
local building = dfhack.gui.getSelectedBuilding()

building.friction = FRICTION_MAP[friction]
dfhack.gui.getSelectedBuilding().track_stop_info.friction = FRICTION_MAP[friction]
end

function TrackStopOverlay:getDumpDirection()
Expand Down Expand Up @@ -121,9 +115,8 @@ function TrackStopOverlay:setDumpDirection(direction)
end

function TrackStopOverlay:render(dc)
local building = dfhack.gui.getSelectedBuilding()
local friction = building.friction
local friction_cycle = self.subviews.friction
local friction = dfhack.gui.getSelectedBuilding().track_stop_info.friction

friction_cycle:setOption(FRICTION_MAP_REVERSE[friction])

Expand Down
Loading