Commands refactor (#257)
* remove unecessary check * move command registration to core/commands
This commit is contained in:
+1
-33
@@ -212,36 +212,4 @@ function NagView:show(title, message, options, on_select)
|
||||
if #self.queue > 0 and not self.title then self:next() end
|
||||
end
|
||||
|
||||
command.add(NagView, {
|
||||
["dialog:previous-entry"] = function()
|
||||
local v = core.active_view
|
||||
local hover = v.hovered_item or 1
|
||||
v:change_hovered(hover == 1 and #v.options or hover - 1)
|
||||
end,
|
||||
["dialog:next-entry"] = function()
|
||||
local v = core.active_view
|
||||
local hover = v.hovered_item or 1
|
||||
v:change_hovered(hover == #v.options and 1 or hover + 1)
|
||||
end,
|
||||
["dialog:select-yes"] = function()
|
||||
local v = core.active_view
|
||||
if v ~= core.nag_view then return end
|
||||
v:change_hovered(findindex(v.options, "default_yes"))
|
||||
command.perform "dialog:select"
|
||||
end,
|
||||
["dialog:select-no"] = function()
|
||||
local v = core.active_view
|
||||
if v ~= core.nag_view then return end
|
||||
v:change_hovered(findindex(v.options, "default_no"))
|
||||
command.perform "dialog:select"
|
||||
end,
|
||||
["dialog:select"] = function()
|
||||
local v = core.active_view
|
||||
if v.hovered_item then
|
||||
v.on_selected(v.options[v.hovered_item])
|
||||
v:next()
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
return NagView
|
||||
return NagView
|
||||
|
||||
Reference in New Issue
Block a user