mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-15 22:30:13 -05:00
- added the ability to duplicate an existing custom bar
This commit is contained in:
@ -195,11 +195,13 @@ end
|
||||
function IceCore.prototype:AddNewDynamicModule(module, hasSettings)
|
||||
if not hasSettings then
|
||||
self.settings.modules[module.elementName] = module:GetDefaultSettings()
|
||||
elseif type(hasSettings) == "table" then
|
||||
self.settings.modules[module.elementName] = IceHUD.deepcopy(hasSettings)
|
||||
end
|
||||
|
||||
module:SetDatabase(self.settings)
|
||||
|
||||
if not hasSettings then
|
||||
if not hasSettings or type(hasSettings) == "table" then
|
||||
local numExisting = self:GetNumCustomModules(module, module:GetDefaultSettings().customBarType)
|
||||
self:RenameDynamicModule(module, "MyCustom"..module:GetDefaultSettings().customBarType..(numExisting+1))
|
||||
end
|
||||
|
58
IceHUD.lua
58
IceHUD.lua
@ -9,7 +9,7 @@ local AceSerializer = LibStub("AceSerializer-3.0", 1)
|
||||
|
||||
local pendingModuleLoads = {}
|
||||
local bReadyToRegisterModules = false
|
||||
local lastCustomModule = 1
|
||||
local lastCustomModule = "Bar"
|
||||
|
||||
IceHUD.CurrTagVersion = 3
|
||||
IceHUD.debugging = false
|
||||
@ -17,7 +17,7 @@ IceHUD.debugging = false
|
||||
IceHUD.WowVer = select(4, GetBuildInfo())
|
||||
|
||||
IceHUD.validBarList = { "Bar", "HiBar", "RoundBar", "ColorBar", "RivetBar", "RivetBar2", "CleanCurves", "GlowArc", "BloodGlaives", "ArcHUD", "FangRune" }
|
||||
IceHUD.validCustomModules = {"Buff/Debuff watcher", "Buff/Debuff stack counter", "Ability cooldown bar", "Health bar", "Mana bar"}
|
||||
IceHUD.validCustomModules = {Bar="Buff/Debuff watcher", Counter="Buff/Debuff stack counter", CD="Ability cooldown bar", Health="Health bar", Mana="Mana bar"}
|
||||
|
||||
local function deepcopy(object)
|
||||
local lookup_table = {}
|
||||
@ -37,6 +37,8 @@ local function deepcopy(object)
|
||||
return _copy(object)
|
||||
end
|
||||
|
||||
IceHUD.deepcopy = deepcopy
|
||||
|
||||
IceHUD.Location = "Interface\\AddOns\\IceHUD"
|
||||
IceHUD.options =
|
||||
{
|
||||
@ -599,30 +601,7 @@ Expand "|cffffdc42Module Settings|r", expand PlayerInfo (or TargetInfo for targe
|
||||
name = "Create",
|
||||
desc = "Creates the selected custom module",
|
||||
func = function()
|
||||
local v = lastCustomModule
|
||||
local newMod = nil
|
||||
local popupMsg
|
||||
if v == 1 then -- custom bar
|
||||
newMod = IceCustomBar:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_BAR_CREATED"
|
||||
elseif v == 2 then -- custom counter
|
||||
newMod = IceCustomCount:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_COUNTER_CREATED"
|
||||
elseif v == 3 then -- cooldown bar
|
||||
newMod = IceCustomCDBar:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_CD_CREATED"
|
||||
elseif v == 4 then -- custom health bar
|
||||
newMod = IceCustomHealth:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_HEALTH_CREATED"
|
||||
elseif v == 5 then -- custom mana bar
|
||||
newMod = IceCustomMana:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_MANA_CREATED"
|
||||
end
|
||||
if newMod ~= nil then
|
||||
IceHUD.IceCore:AddNewDynamicModule(newMod)
|
||||
ConfigDialog:SelectGroup("IceHUD", "modules", newMod.elementName)
|
||||
StaticPopup_Show(popupMsg)
|
||||
end
|
||||
IceHUD:CreateCustomModuleAndNotify(lastCustomModule)
|
||||
end,
|
||||
order = 94.6,
|
||||
},
|
||||
@ -1292,3 +1271,30 @@ function IceHUD:UpdateMedia(event, mediatype, key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function IceHUD:CreateCustomModuleAndNotify(moduleKey, settings)
|
||||
local newMod = nil
|
||||
local popupMsg
|
||||
if moduleKey == "Bar" then -- custom bar
|
||||
newMod = IceCustomBar:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_BAR_CREATED"
|
||||
elseif moduleKey == "Counter" then -- custom counter
|
||||
newMod = IceCustomCount:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_COUNTER_CREATED"
|
||||
elseif moduleKey == "CD" then -- cooldown bar
|
||||
newMod = IceCustomCDBar:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_CD_CREATED"
|
||||
elseif moduleKey == "Health" then -- custom health bar
|
||||
newMod = IceCustomHealth:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_HEALTH_CREATED"
|
||||
elseif moduleKey == "Mana" then -- custom mana bar
|
||||
newMod = IceCustomMana:new()
|
||||
popupMsg = "ICEHUD_CUSTOM_MANA_CREATED"
|
||||
end
|
||||
|
||||
if newMod ~= nil then
|
||||
IceHUD.IceCore:AddNewDynamicModule(newMod, settings)
|
||||
ConfigDialog:SelectGroup("IceHUD", "modules", newMod.elementName)
|
||||
StaticPopup_Show(popupMsg)
|
||||
end
|
||||
end
|
||||
|
@ -161,6 +161,16 @@ function IceCustomBar.prototype:GetOptions()
|
||||
order = 20.1,
|
||||
}
|
||||
|
||||
opts["duplicateme"] = {
|
||||
type = 'execute',
|
||||
name = 'Duplicate me',
|
||||
desc = 'Creates a new module of this same type and with all the same settings.',
|
||||
func = function()
|
||||
IceHUD:CreateCustomModuleAndNotify(self.moduleSettings.customBarType, self.moduleSettings)
|
||||
end,
|
||||
order = 20.2,
|
||||
}
|
||||
|
||||
opts["name"] = {
|
||||
type = 'input',
|
||||
name = 'Bar name',
|
||||
|
@ -148,6 +148,16 @@ function IceCustomCDBar.prototype:GetOptions()
|
||||
order = 20.1,
|
||||
}
|
||||
|
||||
opts["duplicateme"] = {
|
||||
type = 'execute',
|
||||
name = 'Duplicate me',
|
||||
desc = 'Creates a new module of this same type and with all the same settings.',
|
||||
func = function()
|
||||
IceHUD:CreateCustomModuleAndNotify(self.moduleSettings.customBarType, self.moduleSettings)
|
||||
end,
|
||||
order = 20.2,
|
||||
}
|
||||
|
||||
opts["name"] = {
|
||||
type = 'input',
|
||||
name = 'Bar name',
|
||||
|
@ -37,6 +37,16 @@ function IceCustomCount.prototype:GetOptions()
|
||||
order = 20.1,
|
||||
}
|
||||
|
||||
opts["duplicateme"] = {
|
||||
type = 'execute',
|
||||
name = 'Duplicate me',
|
||||
desc = 'Creates a new module of this same type and with all the same settings.',
|
||||
func = function()
|
||||
IceHUD:CreateCustomModuleAndNotify(self.moduleSettings.customBarType, self.moduleSettings)
|
||||
end,
|
||||
order = 20.2,
|
||||
}
|
||||
|
||||
opts["name"] = {
|
||||
type = 'input',
|
||||
name = 'Counter name',
|
||||
|
@ -52,6 +52,16 @@ function IceCustomHealth.prototype:GetOptions()
|
||||
order = 20.1,
|
||||
}
|
||||
|
||||
opts["duplicateme"] = {
|
||||
type = 'execute',
|
||||
name = 'Duplicate me',
|
||||
desc = 'Creates a new module of this same type and with all the same settings.',
|
||||
func = function()
|
||||
IceHUD:CreateCustomModuleAndNotify(self.moduleSettings.customBarType, self.moduleSettings)
|
||||
end,
|
||||
order = 20.2,
|
||||
}
|
||||
|
||||
opts["name"] = {
|
||||
type = 'input',
|
||||
name = 'Bar name',
|
||||
|
@ -53,6 +53,16 @@ function IceCustomMana.prototype:GetOptions()
|
||||
order = 20.1,
|
||||
}
|
||||
|
||||
opts["duplicateme"] = {
|
||||
type = 'execute',
|
||||
name = 'Duplicate me',
|
||||
desc = 'Creates a new module of this same type and with all the same settings.',
|
||||
func = function()
|
||||
IceHUD:CreateCustomModuleAndNotify(self.moduleSettings.customBarType, self.moduleSettings)
|
||||
end,
|
||||
order = 20.2,
|
||||
}
|
||||
|
||||
opts["name"] = {
|
||||
type = 'input',
|
||||
name = 'Bar name',
|
||||
|
Reference in New Issue
Block a user