mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 14:50:13 -05:00
- changed the custom bar creation code to name each bar as the highest-numbered bar +1. e.g. if a bar "MyCustomBar4" exists and the user creates a new bar, the new bar will be called MyCustomBar5 (even if 1-3 don't exist any more, just to avoid complications). This way, each custom bar gets a unique name and users can't stomp an old custom bar by creating a new one without changing the old one's name first
This commit is contained in:
25
IceCore.lua
25
IceCore.lua
@ -115,12 +115,18 @@ end
|
|||||||
|
|
||||||
function IceCore.prototype:AddNewDynamicModule(module, hasSettings)
|
function IceCore.prototype:AddNewDynamicModule(module, hasSettings)
|
||||||
self:Register(module)
|
self:Register(module)
|
||||||
|
|
||||||
if not hasSettings then
|
if not hasSettings then
|
||||||
self.settings.modules[module.elementName] = module:GetDefaultSettings()
|
self.settings.modules[module.elementName] = module:GetDefaultSettings()
|
||||||
end
|
end
|
||||||
|
|
||||||
module:SetDatabase(self.settings)
|
module:SetDatabase(self.settings)
|
||||||
|
|
||||||
|
if not hasSettings then
|
||||||
|
local numExisting = self:GetNumCustomModules(module, true)
|
||||||
|
self:RenameDynamicModule(module, "MyCustomBar"..(numExisting+1))
|
||||||
|
end
|
||||||
|
|
||||||
module:Create(self.IceHUDFrame)
|
module:Create(self.IceHUDFrame)
|
||||||
if (module:IsEnabled()) then
|
if (module:IsEnabled()) then
|
||||||
module:Enable(true)
|
module:Enable(true)
|
||||||
@ -130,6 +136,25 @@ function IceCore.prototype:AddNewDynamicModule(module, hasSettings)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function IceCore.prototype:GetNumCustomModules(exceptMe)
|
||||||
|
local num = 0
|
||||||
|
local foundNum = 0
|
||||||
|
|
||||||
|
for i=0,table.getn(self.elements) do
|
||||||
|
if (self.elements[i] and self.elements[i] ~= exceptMe and self.elements[i].moduleSettings.isCustomBar) then
|
||||||
|
local str = self.elements[i].elementName:match("MyCustomBar%d+")
|
||||||
|
if str then
|
||||||
|
foundNum = str:match("%d+")
|
||||||
|
end
|
||||||
|
|
||||||
|
num = max(num, foundNum)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return num
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function IceCore.prototype:DeleteDynamicModule(module)
|
function IceCore.prototype:DeleteDynamicModule(module)
|
||||||
if module:IsEnabled() then
|
if module:IsEnabled() then
|
||||||
module:Disable()
|
module:Disable()
|
||||||
|
@ -600,7 +600,7 @@ StaticPopupDialogs["ICEHUD_RESET"] =
|
|||||||
|
|
||||||
StaticPopupDialogs["ICEHUD_CUSTOM_BAR_CREATED"] =
|
StaticPopupDialogs["ICEHUD_CUSTOM_BAR_CREATED"] =
|
||||||
{
|
{
|
||||||
text = "A custom bar has been created and can be configured through Module Settings => MyCustomBar. It is highly recommended that you change the bar name of this module ASAP because creating two custom bars with the same name is bad.",
|
text = "A custom bar has been created and can be configured through Module Settings => MyCustomBar. It is highly recommended that you change the bar name of this module so that it's easier to identify.",
|
||||||
button1 = OKAY,
|
button1 = OKAY,
|
||||||
timeout = 0,
|
timeout = 0,
|
||||||
whileDead = 1,
|
whileDead = 1,
|
||||||
|
Reference in New Issue
Block a user