Skip to content

Commit 2c90e19

Browse files
committed
Fix: quickfort UI freeze on large blueprints and strip undocumented ghost-features
1 parent 3455f68 commit 2c90e19

2 files changed

Lines changed: 14 additions & 35 deletions

File tree

gui/quickfort.lua

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function BlueprintDialog:init()
129129
},
130130
widgets.HotkeyLabel{
131131
frame={b=0, l=15},
132-
key='SELECT_ALL', -- TODO: change to SEC_SELECT once 51.01 is stable
132+
key='SEC_SELECT',
133133
label='Delete selected blueprint',
134134
on_activate=self:callback('delete_blueprint'),
135135
enabled=function()
@@ -545,35 +545,8 @@ function Quickfort:on_transform_change(val)
545545
self.dirty = true
546546
end
547547

548-
local origin, test_point = {x=0, y=0}, {x=1, y=-2}
549-
local minimal_sequence = {
550-
['x=1, y=-2'] = {},
551-
['x=2, y=-1'] = {'cw', 'flipv'},
552-
['x=2, y=1'] = {'cw'},
553-
['x=1, y=2'] = {'flipv'},
554-
['x=-1, y=2'] = {'cw', 'cw'},
555-
['x=-2, y=1'] = {'ccw', 'flipv'},
556-
['x=-2, y=-1'] = {'ccw'},
557-
['x=-1, y=-2'] = {'fliph'}
558-
}
559-
560-
-- reduces the list of transformations to a minimal sequence
561-
local function reduce_transform(elements)
562-
local pos = test_point
563-
for _,elem in ipairs(elements) do
564-
pos = quickfort_transform.make_transform_fn_from_name(elem)(pos, origin)
565-
end
566-
local ret = quickfort_transform.resolve_vector(pos, minimal_sequence)
567-
if #ret == #elements then
568-
-- if we're not making the sequence any shorter, prefer the existing set
569-
return elements
570-
end
571-
return copyall(ret)
572-
end
573-
574548
function Quickfort:on_transform(val)
575549
table.insert(transformations, val)
576-
transformations = reduce_transform(transformations)
577550
self:updateLayout()
578551
self.dirty = true
579552
end
@@ -684,12 +657,18 @@ function Quickfort:onRenderFrame(dc, rect)
684657
-- if the (non-locked) cursor has moved since last preview processing or any
685658
-- settings have changed, regenerate the preview
686659
local cursor = dfhack.gui.getMousePos() or self.saved_cursor
687-
if self.dirty or not same_xyz(self.saved_cursor, cursor) then
688-
if not self.cursor_locked then
689-
self.saved_cursor = cursor
660+
if not self.cursor_locked and not same_xyz(self.saved_cursor, cursor) then
661+
self.saved_cursor = cursor
662+
self.last_cursor_move_time = os.clock()
663+
self.dirty = true
664+
end
665+
666+
if self.dirty then
667+
local now = os.clock()
668+
if not self.last_cursor_move_time or (now - self.last_cursor_move_time > 0.1) then
669+
self:refresh_preview()
670+
self.dirty = false
690671
end
691-
self:refresh_preview()
692-
self.dirty = false
693672
end
694673

695674
local tiles = self.saved_preview.tiles

quickfort.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ setmetatable(action_switch, {__index=function() return do_help end})
9393

9494
local args = {...}
9595
local action = table.remove(args, 1) or 'help'
96-
args.commands = argparse.stringList(action)
96+
args.commands = {action}
9797

98-
local action_fn = action_switch[args.commands[1]]
98+
local action_fn = action_switch[action]
9999

100100
if (action == 'run' or action == 'orders' or action == 'undo') and
101101
not dfhack.isMapLoaded() then

0 commit comments

Comments
 (0)