Skip to content

Commit

Permalink
WIP - Record bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Neogeekmo committed Feb 13, 2024
1 parent 43fe26d commit d8aeb82
Show file tree
Hide file tree
Showing 12 changed files with 375 additions and 5 deletions.
2 changes: 1 addition & 1 deletion APR-Recorder.toc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## RequiredDeps: APR

## SavedVariables: AprRCData
## SavedVariables: AprRCData, AprRCSettings

## X-License: All Rights Reserved: You are free to fork and modify on GitHub, please ask us about anything else.
## X-Github: https://github.com/Azeroth-Pilot-Reloaded/APR-Route-Recorder
Expand Down
2 changes: 1 addition & 1 deletion Bindings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<Bindings>
<Binding name="CLICK AprRCItemButton:LeftButton" header="Use Items" category="BINDING_HEADER_APR_ROUTE_RECORDER"/>
<Binding name="CLICK AprRCItemButton:LeftButton" header="Nothing" category="BINDING_HEADER_APR_ROUTE_RECORDER"/>
</Bindings>
11 changes: 11 additions & 0 deletions Commands.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
local L = LibStub("AceLocale-3.0"):GetLocale("APR-Route-Recorder")

AprRC.command = AprRC:NewModule("Command")

function AprRC.command:SlashCmd(input)
if not AprRC.settings.profile.enableAddon then
AprRC.settings:OpenSettings(AprRC.title)
end

AprRC.settings:OpenSettings(AprRC.title)
end
240 changes: 240 additions & 0 deletions Config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
local _G = _G

-- Locale
local L = LibStub("AceLocale-3.0"):GetLocale("APR-Route-Recorder")
local L_APR = LibStub("AceLocale-3.0"):GetLocale("APR")


AprRC.settings = AprRC:NewModule("Settings", "AceConsole-3.0")

-- Ace option config table
local aceConfig = _G.LibStub("AceConfig-3.0")
local aceDialog = _G.LibStub("AceConfigDialog-3.0")

-- Databroker support -- minimapIcon
local libDataBroker = LibStub("LibDataBroker-1.1")
local libDBIcon = LibStub("LibDBIcon-1.0")

local function GetProfileOption(info) return AprRC.settings.profile[info[#info]] end

local function SetProfileOption(info, value)
AprRC.settings.profile[info[#info]] = value
end

function AprRC.settings:ResetSettings()
SettingsDB:ResetProfile()
self:RefreshProfile()
end

function AprRC.settings:InitializeBlizOptions()
self:InitializeSettings()
self:createBlizzOptions()
self:CreateMiniMapButton()

self:RegisterChatCommand("aprrc", self.ChatCommand)
end

function AprRC.settings:InitializeSettings()
-- Default setting
local settingsDBDefaults = {
profile = {
-- frame
recordBarFrame = {},
stepOptionBarFrame = {},
--debug
enableMinimapButton = true,
debug = false,
enableAddon = true,
}
}

SettingsDB = LibStub("AceDB-3.0"):New("AprRCSettings", settingsDBDefaults)

SettingsDB.RegisterCallback(self, "OnProfileChanged", "RefreshProfile")
SettingsDB.RegisterCallback(self, "OnProfileCopied", "RefreshProfile")
SettingsDB.RegisterCallback(self, "OnProfileReset", "RefreshProfile")
self.profile = SettingsDB.profile
end

function AprRC.settings.ChatCommand(input)
AprRC.command:SlashCmd(input)
end

function AprRC.settings:RefreshProfile()
self.profile = SettingsDB.profile
C_UI.Reload()
end

function AprRC.settings:createBlizzOptions()
-- Setting definition
local optionsTable = {
name = AprRC.title .. ' - ' .. AprRC.version,
type = "group",
args = {
discordButton = {
order = 1.1,
name = L_APR["JOIN_DISCORD"],
type = "execute",
width = 0.75,
func = function()
AprRC.questionDialog:CreateEditBoxPopup(L_APR["COPY_HELPER"], L["CLOSE"], AprRC.discord)
end
},
githubButton = {
order = 1.2,
name = "Github",
type = "execute",
width = 0.75,
func = function()
AprRC.questionDialog:CreateEditBoxPopup(L_APR["COPY_HELPER"], L["CLOSE"], AprRC.github)
end
},
buttonOffset = {
order = 1.3,
name = "",
type = "description",
width = 1.35,
},
resetButton = {
order = 1.4,
name = L_APR["RESET_SETTINGS"],
type = "execute",
width = 0.75,
func = function()
AprRC.questionDialog:CreateQuestionPopup(
nil,
function() AprRC.settings:ResetSettings() end
)
end
},
header_Automation = {
order = 2,
type = "header",
width = "full",
name = "Somthing :)",
},
somthing = {
order = 3,
type = "group",
name = "What a group",
inline = true,
args = {
enableAddon = {
order = 3.1,
type = "toggle",
name = L_APR["ENABLE_ADDON"],
width = "full",
get = GetProfileOption,
set = function(info, value)
SetProfileOption(info, value)
self:ToggleAddon()
end,
},
enableMinimapButton = {
name = L_APR["ENABLE_MINIMAP_BUTTON"],
desc = L_APR["ENABLE_MINIMAP_BUTTON_DESC"],
type = "toggle",
width = "full",
order = 9.20,
get = GetProfileOption,
set = function(info, value)
SetProfileOption(info, value)
if value then
libDBIcon:Show(AprRC.title)
else
libDBIcon:Hide(AprRC.title)
end
end
},
debug = {
order = 3.2,
type = "toggle",
name = L_APR["DEBUG"],
width = "full",
get = GetProfileOption,
set = SetProfileOption,
disabled = function()
return not self.profile.enableAddon
end,
},
}
},
}
}

-- Register setting to the option table
aceConfig:RegisterOptionsTable(AprRC.title, optionsTable)
-- Add settings to bliz option
AprRC.Options = aceDialog:AddToBlizOptions(AprRC.title, AprRC.title)

-- add profile to bliz option
aceConfig:RegisterOptionsTable(AprRC.title .. "/Profile", _G.LibStub("AceDBOptions-3.0"):GetOptionsTable(SettingsDB))
aceDialog:AddToBlizOptions(AprRC.title .. "/Profile", L_APR["PROFILES"], AprRC.title)
end

function AprRC.settings:CreateMiniMapButton()
if not self.profile.enableMinimapButton then return end

local minimapButton = libDataBroker:NewDataObject(AprRC.title, {
type = "launcher",
icon = "Interface\\AddOns\\assets\\logo",
OnClick = function(_, button)
if button == "RightButton" then
self.profile.enableAddon = not self.profile.enableAddon
self:ToggleAddon()
else
AprRC.settings:OpenSettings(AprRC.title)
end
end,
OnTooltipShow = function(tooltip)
local toggleAddon = ''
if self.profile.enableAddon then
toggleAddon = "|ccce0000f " .. L_APR["DISABLE"] .. "|r"
else
toggleAddon = "|c33ecc00f " .. L_APR["ENABLE"] .. "|r"
end
tooltip:AddLine(APR.title)
tooltip:AddLine(L_APR["LEFT_CLICK"] .. ": |cffeda55f" .. L_APR["SHOW_MENU"] .. "|r",
unpack(AprRC.Color.white))
tooltip:AddLine(L_APR["RIGHT_CLICK"] .. ": " .. toggleAddon .. "|cffeda55f " .. L_APR["ADDON"] .. "|r",
unpack(AprRC.Color.white))
end
})

libDBIcon:Register(AprRC.title, minimapButton, self.profile.minimap);
end

function AprRC.settings:ToggleAddon()
AprRC.record:RefreshFrameAnchor()
end

function AprRC.settings:OpenSettings(name)
if name == AprRC.title then
InterfaceOptionsFrame_OpenToCategory(AprRC.title)
AprRC.settings:OpenSettings(L_APR["PROFILES"])
end
if AprRC.Options then
if SettingsPanel then
local category = SettingsPanel:GetCategoryList():GetCategory(AprRC.Options.name)
if category then
SettingsPanel:Open()
SettingsPanel:SelectCategory(category)
if AprRC.OptionsRoute and category:HasSubcategories() then
for _, subcategory in pairs(category:GetSubcategories()) do
if subcategory:GetName() == name then
SettingsPanel:SelectCategory(subcategory)
break
end
end
end
end
return
elseif InterfaceOptionsFrame_OpenToCategory then
InterfaceOptionsFrame_OpenToCategory(AprRC.Options)
if AprRC.OptionsRoute then
InterfaceOptionsFrame_OpenToCategory(AprRC.OptionsRoute)
end
return
end
end
end
12 changes: 11 additions & 1 deletion Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ AprRC = {}
AprRC = _G.LibStub("AceAddon-3.0"):NewAddon(addon, "APR-Route-Recorder", "AceEvent-3.0")

function AprRC:OnInitialize()
local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or _G.GetAddOnMetadata

-- Init on TOC
AprRC.title = C_AddOns.GetAddOnMetadata("APR-Route-Recorder", "Title")
AprRC.version = C_AddOns.GetAddOnMetadata("APR-Route-Recorder", "Version")

AprRC.github = GetAddOnMetadata("APR-Route-Recorder", "X-Github")
AprRC.discord = GetAddOnMetadata("APR-Route-Recorder", "X-Discord")
AprRC.Color = {
white = { 1, 1, 1 },
red = { 1, 0, 0 },
}

-- Init Settings
-- APR.settings:InitializeBlizOptions()
Expand Down Expand Up @@ -90,6 +97,9 @@ end
-- - SpellTrigger
-- - NoAutoFlightMap
-- - DenyNPC
-- - TrigText
-- - Emote
-- - InstanceQuest

-- -- only in route check if needed
-- - ExtraActionB
Expand Down
4 changes: 2 additions & 2 deletions Event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ AprRC.EventFrame:RegisterEvent("ZONE_CHANGED")
AprRC.EventFrame:RegisterEvent("ZONE_CHANGED_INDOORS")
AprRC.EventFrame:RegisterEvent("ZONE_CHANGED_NEW_AREA")
AprRC.EventFrame:SetScript("OnEvent", function(self, event, ...)
if event then
return
if event == "PET_BATTLE_OPENING_START" or event == "PET_BATTLE_CLOSE" then
AprRC.record:RefreshFrameAnchor()
end
end)
Loading

0 comments on commit d8aeb82

Please sign in to comment.