diff --git a/Bindings.xml b/Bindings.xml index 5b0a72d..0d9472a 100644 --- a/Bindings.xml +++ b/Bindings.xml @@ -1,5 +1,5 @@ - _RollFor.options_popup.toggle() - _RollFor.softres_gui.toggle() - _RollFor.winners_popup.toggle() + RollFor.key_bindings.options_toggle() + RollFor.key_bindings.softres_toggle() + RollFor.key_bindings.winners_toggle() diff --git a/RollFor.toc b/RollFor.toc index 3b83602..7a37374 100644 --- a/RollFor.toc +++ b/RollFor.toc @@ -1,7 +1,7 @@ ## Interface: 11200 ## Title: RollFor ## Author: Obszczymucha -## Version: 4.8.0 +## Version: 4.8.1 ## Notes: An automated item roller with soft ressing support via raidres.fly.dev. ## SavedVariables: RollForDb ## SavedVariablesPerCharacter: RollForCharDb @@ -39,6 +39,7 @@ src\GroupRoster.lua src\NameAutoMatcher.lua src\NameManualMatcher.lua src\NameMatchReport.lua +src\BindingsHandler.lua src\EventHandler.lua src\SoftResGui.lua src\VersionBroadcast.lua diff --git a/main.lua b/main.lua index e943cbd..3f96744 100644 --- a/main.lua +++ b/main.lua @@ -14,9 +14,6 @@ local RollSlashCommand = m.Types.RollSlashCommand local RollType = m.Types.RollType local RollingStrategy = m.Types.RollingStrategy -_RollFor = M -BINDING_HEADER_ROLLFOR = "RollFor" - local function clear_data() M.softres_gui.clear() M.name_matcher.clear( true ) @@ -919,5 +916,7 @@ function M.on_chat_msg_addon( name, message, _, sender ) end end +---@type KeyBindings +m.key_bindings = m.KeyBindings.new( M ) m.EventHandler.handle_events( M ) return M diff --git a/src/BindingsHandler.lua b/src/BindingsHandler.lua new file mode 100644 index 0000000..2a038ce --- /dev/null +++ b/src/BindingsHandler.lua @@ -0,0 +1,63 @@ +RollFor = RollFor or {} +local m = RollFor + +if m.KeyBindings then return end + +local M = {} + +BINDING_HEADER_ROLLFOR = "RollFor" + +---@class KeyBindings +---@field options_toggle fun() +---@field softres_toggle fun() +---@field winners_toggle fun( data: table) +---@field import fun() + +function M.new( main ) + local function options_toggle() + main.options_popup.toggle() + end + + local function softres_toggle() + main.softres_gui.toggle() + end + + local function winners_toggle() + main.winners_popup.toggle() + end + + local function import( data ) + math.huge = 1e99 + ---@diagnostic disable-next-line: undefined-global + local json = LibStub( "Json-0.1.2" ) + local success, json_data = pcall( function() return json.encode( data ) end ) + + if success then + local softres_data = m.encode_base64( json_data ) + + main.import_encoded_softres_data( softres_data, function() + local softres_check = main.softres_check + local result = softres_check.check_softres() + + if result ~= softres_check.ResultType.NoItemsFound then + main.softres.persist( softres_data ) + main.dropped_loot_announce.reset() + main.softres_gui.load( softres_data ) + end + end ) + else + m.error( "Encoding of SR data failed" ) + end + end + + ---@type KeyBindings + return { + options_toggle = options_toggle, + softres_toggle = softres_toggle, + winners_toggle = winners_toggle, + import = import, + } +end + +m.KeyBindings = M +return M diff --git a/src/BossList.lua b/src/BossList.lua index 8b9afc2..9ff70b3 100644 --- a/src/BossList.lua +++ b/src/BossList.lua @@ -55,6 +55,7 @@ M.zones = { [ "Molten Core" ] = { "Incindis", "Basalthar", + "Smoldaris", "Sorcerer-Thane Thaurissan", "Lucifron", "Magmadar", @@ -85,7 +86,7 @@ M.zones = { "Vem", "Lord Kri", "Princess Yauj", - "Battle Guard Sartura", + "Battleguard Sartura", "Fankriss the Unyielding", "Viscidus", "Princess Huhuran", diff --git a/src/OptionsPopup.lua b/src/OptionsPopup.lua index 66163aa..4a98c9e 100644 --- a/src/OptionsPopup.lua +++ b/src/OptionsPopup.lua @@ -145,6 +145,7 @@ function M.new( popup_builder, awarded_loot, version_broadcast, event_bus, confi this.changelog.content.parent = this.changelog local changelog = { + { ver = "4.8.1", text = "Add new MC bosses to boss list. Refactor keybindings" }, { ver = "4.8.0", text = "Added +1 handling" }, { ver = "4.7.13", text = "Add option to show player roles in rolling popup." }, { ver = "4.7.13", text = "Fix wrong zone name for Temple of Ahn'Qiraj." },