Skip to content

Commit

Permalink
Merge pull request #921 from myk002/myk_quickcmd
Browse files Browse the repository at this point in the history
[gui/quickcmd] use HotkeyLabels for hotkeys
  • Loading branch information
myk002 authored Jan 4, 2024
2 parents e7b7c0f + 751226b commit a51727e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Template for new versions:
- `confirm`: added confirmation dialog for right clicking out of the trade agreement screen (so your trade agreement selections aren't lost)
- `gui/autobutcher`: interface redesigned to better support mouse control
- `gui/launcher`: now persists the most recent 32KB of command output even if you close it and bring it back up
- `gui/quickcmd`: clickable buttons for command add/remove/edit operations

## Removed

Expand Down
31 changes: 20 additions & 11 deletions gui/quickcmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,26 @@ function QCMDDialog:init(info)
text={'Command list is empty.', NEWLINE, 'Hit "A" to add one!'},
visible=function() return #self.commands == 0 end,
},
widgets.Label{
frame={b=0, h=2},
text={
{key='CUSTOM_SHIFT_A', text=': Add command',
on_activate=self:callback('onAddCommand')}, ' ',
{key='CUSTOM_SHIFT_D', text=': Delete command',
on_activate=self:callback('onDelCommand')}, NEWLINE,
{key='CUSTOM_SHIFT_E', text=': Edit command',
on_activate=self:callback('onEditCommand')},
},
widgets.HotkeyLabel{
frame={b=1, l=0},
key='CUSTOM_SHIFT_A',
label='Add command',
auto_width=true,
on_activate=self:callback('onAddCommand'),
},
widgets.HotkeyLabel{
frame={b=1, l=19},
key='CUSTOM_SHIFT_D',
label='Delete command',
auto_width=true,
on_activate=self:callback('onDelCommand'),
},
widgets.HotkeyLabel{
frame={b=0, l=0},
key='CUSTOM_SHIFT_E',
label='Edit command',
auto_width=true,
on_activate=self:callback('onEditCommand'),
},
}

Expand All @@ -92,7 +102,6 @@ end

function QCMDDialog:submit(idx, choice)
local screen = self.parent_view
local parent = screen._native.parent
dfhack.screen.hideGuard(screen, function()
dfhack.run_command(choice.command)
end)
Expand Down

0 comments on commit a51727e

Please sign in to comment.