Refactor keybindings. Add new MC bosses to boss list

This commit is contained in:
Sica 2025-08-22 00:57:11 +02:00
parent 409dca83b2
commit 651177709e
6 changed files with 73 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<Bindings>
<Binding name="Toggle options window" header="ROLLFOR">_RollFor.options_popup.toggle()</Binding>
<Binding name="Toggle SR import window" header="ROLLFOR">_RollFor.softres_gui.toggle()</Binding>
<Binding name="Toggle winners window" header="ROLLFOR">_RollFor.winners_popup.toggle()</Binding>
<Binding name="Toggle options window" header="ROLLFOR">RollFor.key_bindings.options_toggle()</Binding>
<Binding name="Toggle SR import window">RollFor.key_bindings.softres_toggle()</Binding>
<Binding name="Toggle winners window">RollFor.key_bindings.winners_toggle()</Binding>
</Bindings>

View File

@ -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

View File

@ -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

63
src/BindingsHandler.lua Normal file
View File

@ -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

View File

@ -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",

View File

@ -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." },