Allow edited action to keep its name when editing it (fixes: #1), made dialogs respond to enter and escape, Confirm dialog now shows dark red color for dangerous operations and prevents enter for accepting it

This commit is contained in:
2021-02-10 22:21:53 -06:00
parent 9999026969
commit 3cc4c204a7
12 changed files with 94 additions and 44 deletions

View File

@@ -2,8 +2,10 @@ module TAC
class Dialog
class ConfirmDialog < Dialog
def build
@dialog_root.style.border_color = [ Palette::ALERT, darken(Palette::ALERT, 50) ]
@titlebar.style.background = [ Palette::ALERT, darken(Palette::ALERT, 50) ]
color = @options[:dangerous] ? Palette::DANGEROUS : Palette::ALERT
@dialog_root.style.border_color = [ color, darken(color, 50) ]
@titlebar.style.background = [ color, darken(color, 50) ]
background Gosu::Color::GRAY
label @options[:message]
@@ -12,7 +14,14 @@ module TAC
button "Cancel", width: 0.475 do
close
end
button "Proceed", width: 0.475, **TAC::THEME_DANGER_BUTTON do
try_commit(true)
end
end
def try_commit(force = false)
if not @options[:dangerous] || force
close
@options[:callback_method].call