More refactoring of summary screen code, added module UIActionHandlers

This commit is contained in:
Maruno17
2024-08-28 21:19:55 +01:00
parent 2abdf333db
commit 9a7dfbb587
4 changed files with 273 additions and 129 deletions

View File

@@ -97,6 +97,10 @@ module MenuHandlers
@@handlers[menu]&.clear
end
def get(menu, option)
return @@handlers[menu][option]
end
def each(menu)
return if !@@handlers.has_key?(menu)
@@handlers[menu].each { |option, hash| yield option, hash }
@@ -125,3 +129,34 @@ module MenuHandlers
return option_hash[function].call(*args)
end
end
#===============================================================================
#
#===============================================================================
module UIActionHandlers
@@handlers = {}
module_function
def add(menu, action, hash)
@@handlers[menu] = HandlerHash.new if !@@handlers.has_key?(menu)
@@handlers[menu].add(action, hash)
end
def remove(menu, action)
@@handlers[menu]&.remove(action)
end
def clear(menu)
@@handlers[menu]&.clear
end
def get(menu, action)
return @@handlers[menu][action]
end
def each(menu)
return if !@@handlers.has_key?(menu)
@@handlers[menu].each { |action, hash| yield action, hash }
end
end