Skip to content

Commit 6c24dc1

Browse files
committed
support single-line mod list export
1 parent ed4a014 commit 6c24dc1

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

gui/mod-manager.lua

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -452,9 +452,29 @@ function ModlistWindow:init()
452452
initial_option=false,
453453
on_change=function() self:refresh_list() end,
454454
},
455+
widgets.Divider{
456+
frame={t=2, h=1},
457+
frame_style=gui.FRAME_THIN,
458+
frame_style_l=false,
459+
frame_style_r=false,
460+
},
461+
widgets.HotkeyLabel{
462+
frame={t=4, r=0},
463+
label='Export to clipboard (single line)',
464+
text_pen=COLOR_YELLOW,
465+
auto_width=true,
466+
on_activate=function()
467+
local text = {}
468+
for _,choice in ipairs(self.subviews.list:getChoices()) do
469+
table.insert(text, ('%s %s'):format(choice.data.name, choice.data.version))
470+
end
471+
dfhack.internal.setClipboardTextCp437Multiline(table.concat(text, ', '))
472+
end,
473+
enabled=function() return #self.subviews.list:getChoices() > 0 end,
474+
},
455475
widgets.HotkeyLabel{
456-
frame={t=0, r=0},
457-
label='Copy list to clipboard',
476+
frame={t=5, r=0},
477+
label='Export to clipboard (with links)',
458478
text_pen=COLOR_YELLOW,
459479
auto_width=true,
460480
on_activate=function()
@@ -466,27 +486,21 @@ function ModlistWindow:init()
466486
end,
467487
enabled=function() return #self.subviews.list:getChoices() > 0 end,
468488
},
469-
widgets.Divider{
470-
frame={t=2, h=1},
471-
frame_style=gui.FRAME_THIN,
472-
frame_style_l=false,
473-
frame_style_r=false,
474-
},
475489
widgets.Label{
476-
frame={l=0, t=3},
490+
frame={l=0, t=4},
477491
text={
478492
'Load',
479493
NEWLINE,
480494
'order',
481495
},
482496
},
483497
widgets.Label{
484-
frame={l=7, t=4},
498+
frame={l=7, t=5},
485499
text='Mod',
486500
},
487501
widgets.List{
488502
view_id='list',
489-
frame={t=6, b=2},
503+
frame={t=7, b=2},
490504
},
491505
widgets.Label{
492506
frame={l=0, b=0},

0 commit comments

Comments
 (0)