lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [trunk/] [KragenPlugs/] [KragenBars/] [ClassBar.lua] - Rev 127

Compare with Previous | Blame | View Log

import "Turbine.UI";
import "Turbine.UI.Lotro";
import "Turbine.Gameplay";
import "KragenPlugs.Utils";
import "KragenPlugs.KragenBars";

ClassBar = class( );

function ClassBar:Constructor()
        
        -- inialize the setupWindow
        self.setup = SetupWindow();
        self.setupglobals = self.setup.setupglobals;
        self.setupbb = self.setup.setupbb;
        self.setupf = self.setup.setupf;
        self.setupqs = self.setup.setupqs;
        
        -- inialize tables
        self.windows = { };
        self.bars = { };
        self.skills = { };
        self.multi = { };
        
        self.barlist = { };
        self.effectlist = {};
        self.barcount = 0;
        self.currentedit = nil;
        self.currentkey = nil;

        -- SET AND UPDATE DEFAULT SETTINGS
    if (not settings.class) then
        settings.class = vars.playerclass;
        self:DefaultSettings();
    else
        self.settings = settings.classinfo;
        if (settings.vers ~= vars.vers) then
                self:UpdateSettings();
        end
    end 
        
        self.setup:SetWantsKeyEvents(true);
        
        self.setup.KeyDown = function(sender, args)
        if args.Action == 0x100000B3 then
                        self.setup:SetWantsUpdates(true);
                end
        end
        
        self.setup.Update = function(sender, args)
        for k,v in pairs(self.skills) do
                        v:RefreshBorders();
                end
                self.setup:SetWantsUpdates(false);
        end
        
        -- BUILD ALL WINDOWS AND USERCONF BARS
        for k,v in pairs(self.settings.userconf) do
                self.barlist[v.id] = k;
                self.windows[k] = SkillWindow(v);
                self.bars[k] = SkillBar(self.windows[k], 1, 1, v.size[1], v.size[2], true, false);
                self.barcount = self.barcount + 1;
        end
        
        for k,v in pairs(self.settings.preconf) do
                self.barlist[v.id] = k;
                self.windows[k] = SkillWindow(v);
                self.barcount = self.barcount + 1;
        end
        
        -- Combat Event
        AddCallback(vars.player, "InCombatChanged", function(sender, args)
                KragenBars:CombatChange(vars.player:IsInCombat());
        end);
        
        -- Effect Events
    AddCallback(vars.effects, "EffectAdded", function(sender, args)
                KragenBars:AddEffect( args.Index );
        end);

        AddCallback(vars.effects, "EffectRemoved", function(sender, args)
                if (args.Effect ~= nil) then
                        KragenBars:RemoveEffect( args.Effect );
                end
        end);
        
end

-- Index and Position Bars
function ClassBar:InitBars()
        self.DefineEffectList();
        
        for k,v in pairs(self.bars) do
                v.index = k;
        end
        
        if(settings.skilldata ~=nil) then
                for k,v in pairs(self.skills) do
                        if (settings.skilldata[k] ~= nil) then
                            local data = settings.skilldata[k];
                            data.parent = self.bars[settings.skilldata[k].parent]
                                v:LoadPosition(data);
                        end
                        if (v.parent ~= nil) then
                                v.parent:AddSkill(v);
                        end
                        v:RefreshBorders();
                end
        end
        
        if(settings.multidata ~=nil) then
                for k,v in pairs(self.multi) do
                        if (settings.multidata[k] ~= nil) then
                                local data = settings.multidata[k];
                            data.parent = self.bars[settings.multidata[k].parent]
                                v:LoadPosition(data);
                        end
                        if (v.parent ~= nil) then
                                v.parent:AddSkill(v);
                        end
                end
        end
        
        if (settings.customslots ~= nil) then
                self.customslots = { };
                for k,v in pairs(settings.customslots) do
                        if (v.parent ~= nil) then
                                self.customslots[k] = ItemSlot(self.bars[v.parent], v.x, v.y, true, {active=true,data=v.data,type=v.type});
                        else
                                self.customslots[k] = ItemSlot(limbo, v.x, v.y, true, {active=true,data=v.data,type=v.type});
                        end
                        if (v.parent ~= nil) then
                                self.bars[v.parent]:AddSkill(self.customslots[k]);
                        end
                end
        end
        
        for k,v in pairs(self.windows) do
                v:SetVisible(v.active);
        end
        
        for i = 1, vars.effects:GetCount() do
                self:AddEffect(i);
        end
        
        self.setup.VisibleChanged = function(sender, args)
                self:EditBars(self.setup:IsVisible());
        end
        
        if (settings.classinfo == nil) then self:ShowSetup() end;
        self:SaveSettings();
        kbbutton = KBButton(settings.kbbutton.x, settings.kbbutton.y);
        
end

function ClassBar:SaveBarOptions(index)
        self.windows[index]:SetBackColor(Turbine.UI.Color(nil));
        self.setupbb.barsnamebox:SetWantsUpdates(false);
        self.setupbb.barsactive:SetWantsUpdates(false);
        self.setupbb.barscombat:SetWantsUpdates(false);
        self.setupbb.barswidth:SetWantsUpdates(false);
        self.setupbb.barsheight:SetWantsUpdates(false);
        self.windows[index].dragBar:SetRotator(true);
        self.windows[index].dragBar:SetRotatorOffset(3, 23);

end

function ClassBar:SetBarOptions(index)
        if (self.settings.preconf[self.barlist[index]] ~= nil) then
                self.currentedit = self.settings.preconf[self.barlist[index]];
                self.currentkey = self.barlist[index];
                self.setupbb.barsnamebox:SetText(self.currentedit.name);
                self.setupbb.barsnamebox:SetEnabled(false);
                self.setupbb.barsnamebox:SetVisible(true);
                self.setupbb.barsnamebox:SetWantsUpdates(false);
                self.setupbb.barsactive:SetChecked(self.currentedit.active);
                self.setupbb.barsactive:SetVisible(true);
                self.setupbb.barsactive:SetWantsUpdates(true);
                self.setupbb.barscombat:SetVisible(true);
                self.setupbb.barscombat:SetSelection(self.windows[self.currentkey]:GetCombat());
                self.setupbb.barswidth:SetVisible(false);
                self.setupbb.barswidth:SetWantsUpdates(false);
                self.setupbb.barsheight:SetVisible(false);
                self.setupbb.barsheight:SetWantsUpdates(false);
                self.setupbb.barsbuttonremove:SetVisible(false);
                self.windows[self.currentkey]:SetBackColor(Turbine.UI.Color( 0, 0, 1 ));
                self.windows[self.currentkey].dragBar:SetRotator(false);
                --self:EditBar(self.currentkey);
        elseif (self.settings.userconf[self.barlist[index]] ~= nil) then
                self.currentedit = self.settings.userconf[self.barlist[index]];
                self.currentkey = self.barlist[index];
                self.setupbb.barsnamebox:SetText(self.currentedit.name);
                self.setupbb.barsnamebox:SetVisible(true);
                self.setupbb.barsnamebox:SetWantsUpdates(true);
                self.setupbb.barsnamebox:SetEnabled(true);
                self.setupbb.barsactive:SetChecked(self.currentedit.active);
                self.setupbb.barsactive:SetVisible(true);
                self.setupbb.barsactive:SetWantsUpdates(true);
                self.setupbb.barscombat:SetVisible(true);
                self.setupbb.barscombat:SetSelection(self.windows[self.currentkey]:GetCombat());
                self.setupbb.barswidth:SetValue(self.windows[self.currentkey].width);
                self.setupbb.barswidth:SetVisible(true);
                self.setupbb.barswidth:SetWantsUpdates(true);
                self.setupbb.barsheight:SetValue(self.windows[self.currentkey].height);
                self.setupbb.barsheight:SetVisible(true);
                self.setupbb.barsheight:SetWantsUpdates(true);
                self.setupbb.barsbuttonremove:SetVisible(true);
                self.windows[self.currentkey]:SetBackColor(Turbine.UI.Color( 0, 0, 1 ));
                self.windows[self.currentkey].dragBar:SetRotator(false);
                --self:EditBar(self.currentkey);
        else
                self.setupbb.barsnamebox:SetVisible(false);
                self.setupbb.barsnamebox:SetWantsUpdates(false);
                self.setupbb.barsactive:SetVisible(false);
                self.setupbb.barsactive:SetWantsUpdates(false);
                self.setupbb.barscombat:SetVisible(false);
                self.setupbb.barswidth:SetVisible(false);
                self.setupbb.barswidth:SetWantsUpdates(false);
                self.setupbb.barsheight:SetVisible(false);
                self.setupbb.barsheight:SetWantsUpdates(false);
                self.setupbb.barsbuttonremove:SetVisible(false);
                --self:EditBar(nil);
                self.currentedit = nil;
                self.currentkey = nil;
        end

end

function ClassBar:ShowSetup()
        self.setup:SetVisible(true);
        if (vars.playerclass == "Loremaster") then
                self:SetupPets();
        end

        self.setupbb.barslist.listBox:ClearItems();
        self.setupbb.barslist:AddItem(" ", 0);
        for k,v in pairs(self.barlist) do
                if (self.settings.preconf[v] ~= nil) then
                        self.setupbb.barslist:AddItem(self.settings.preconf[v].name, k);
                elseif (self.settings.userconf[v] ~= nil) then
                        self.setupbb.barslist:AddItem(self.settings.userconf[v].name, k);
                end
        end
        self:SetBarOptions(self.currentkey);
        
        self.setupbb.barslist.SelectedIndexChanged = function(sender, args)
        if (self.currentkey ~= nil) then
            self:SaveBarOptions(self.currentkey);
        end
                self.currentkey = args.selection;
                self:SetBarOptions(self.currentkey);
    end

    self.setupbb.barsbuttonnew.Click = function(sender, args)
        local newbar = self:CreateBar();
                self.setupbb.barslist:AddItem(self.settings.userconf[self.barlist[newbar]].name, newbar);
                self.setupbb.barslist:SetSelection(newbar);
    end
        
        self.setupbb.barsbuttonremove.Click = function(sender, args)
                local deletebar = self.currentkey;
                self.setupbb.barslist:SetSelection(0); 
                self:DeleteBar(deletebar);
                self.setupbb.barslist.listBox:ClearItems();
                self.setupbb.barslist:AddItem(" ", 0);
                for k,v in pairs(self.barlist) do
                        if (self.settings.preconf[v] ~= nil) then
                                self.setupbb.barslist:AddItem(self.settings.preconf[v].name, k);
                        elseif (self.settings.userconf[v] ~= nil) then
                                self.setupbb.barslist:AddItem(self.settings.userconf[v].name, k);
                        end
                end
    end 

    self.setupbb.barsnamebox.Update = function(sender, args)
                self:RenameBar(self.currentkey, self.setupbb.barsnamebox:GetText());
        self.setupbb.barslist:UpdateSelectionText(self.setupbb.barsnamebox:GetText());
    end

        self.setupbb.barsactive.Update = function(sender, args)
                if (self.currentedit ~= nil) then self.currentedit.active = self.setupbb.barsactive:IsChecked(); end
                if (self.windows[self.currentkey] ~= nil) then self.windows[self.currentkey]:Refresh(self.setupbb.barsactive:IsChecked()); end
        end
        
        self.setupbb.barscombat.SelectedIndexChanged = function(sender, args)
                self:BarCombat(self.currentkey, args.selection);
        end

        self.setupbb.barswidth.Update = function(sender, args)
                self.currentedit.size = { self.setupbb.barswidth:GetValue(), self.setupbb.barsheight:GetValue() };
                self:ResizeBar(self.currentkey, self.currentedit.size);
        end

        self.setupbb.barsheight.Update = function(sender, args)
                self.currentedit.size = { self.setupbb.barswidth:GetValue(), self.setupbb.barsheight:GetValue() };
                self:ResizeBar(self.currentkey, self.currentedit.size);
        end
        
        self.setupglobals.opacityslider:SetValue(settings.opacity * 100);
        self.setupglobals.checkboxlock:SetChecked(settings.lockslots);
        self.setupglobals.checkboxgrid:SetChecked(settings.snaptogrid);
        if (settings.advanceonclick == nil) then
                self.setupglobals.checkboxmulticlick:SetChecked(false);
        else
                self.setupglobals.checkboxmulticlick:SetChecked(settings.advanceonclick);
        end
        if (settings.gridspacing == nil) then
                self.setupglobals.gridsizeslider:SetValue(36);
        else
                self.setupglobals.gridsizeslider:SetValue(settings.gridspacing * 36 / 35);
        end
        self.setupglobals.combolangbox:SetSelection(settings.language);
        
        -- Prep Features Window
        if (self.setupf.titlebars[1] == nil) then
                local rownumber = 0;
                local countbox = 0;

                self.setupf:AddTitleBar("Traits");
                for k,v in pairs(self.settings.traits) do countbox = countbox + 1 end
                if (math.mod(countbox, 2) == 0) then
                        rownumber = countbox / 2;
                else
                        rownumber = (countbox + 1) / 2;
                end
                for i = 1,rownumber do self.setupf:AddCheckboxRow(self.setupf.traits) end
                
                countbox = 0;
                self.setupf:AddTitleBar("Features");
                for k,v in pairs(self.settings.features) do countbox = countbox + 1 end
                if (math.mod(countbox, 2) == 0) then
                        rownumber = countbox / 2;
                else
                        rownumber = (countbox + 1) / 2;
                end
                for i = 1,rownumber do self.setupf:AddCheckboxRow(self.setupf.features) end
                
                countbox = 0;
                self.setupf:AddTitleBar("Defaults");
                for k,v in pairs(self.settings.defaults) do countbox = countbox + 1 end
                for i = 1,countbox do self.setupf:AddComboBox(self.setupf.defaults) end
        end
                
        for k,v in pairs(self.settings.traits) do               self.setupf.traits[v.id]:SetActive(v.name, v.active) end
        for k,v in pairs(self.settings.features) do     self.setupf.features[v.id]:SetActive(v.name, v.active) end
        for k,v in pairs(self.settings.defaults) do
                self.setupf.defaults[v.id].combobox.listBox:ClearItems();
                self.setupf.defaults[v.id].label:SetText(v.name);
                self.setupf.defaults[v.id].label:SetVisible(true);
                for key,value in pairs(v.list) do
                        self.setupf.defaults[v.id].combobox:AddItem(value, key);
                end
                self.setupf.defaults[v.id].combobox:SetVisible(true);
                self.setupf.defaults[v.id].combobox:SetSelection(v.selected);
        end
        for k,v in pairs(self.settings.quickslots) do   self.setupqs:ActivateQuickslot(self.setupqs.quickslots[v.id], v.name, v.active, v.type, v.data) end
end

function ClassBar:SetupClosing()
        self.setupbb.barslist:SetSelection(0);

        if (vars.playerclass == "Loremaster") then
                KragenBars:SetupPetsClosing();
        end

        settings.opacity = (self.setupglobals.opacityslider:GetValue() / 100);
        settings.lockslots = self.setupglobals.checkboxlock:IsChecked();
        settings.snaptogrid = self.setupglobals.checkboxgrid:IsChecked();
        settings.advanceonclick = self.setupglobals.checkboxmulticlick:IsChecked();
        settings.language = self.setupglobals.combolangbox:GetSelection();
        settings.gridspacing = (self.setupglobals.gridsizeslider:GetValue() * 35 / 36);
        
        -- for k, v in pairs (self.settings.preconf) do         v.active = self.setupbb.buttonbars[v.id]:IsChecked() end
        -- for k, v in pairs (self.settings.userconf) do        v.active = self.setupbb.buttonbars[v.id]:IsChecked() end
        for k, v in pairs (self.settings.traits) do     v.active = self.setupf.traits[v.id]:IsChecked() end
        for k, v in pairs (self.settings.features) do   v.active = self.setupf.features[v.id]:IsChecked() end
        for k, v in pairs (self.settings.defaults) do   v.selected = self.setupf.defaults[v.id].combobox:GetSelection() end
        for k, v in pairs (self.settings.quickslots) do
                if (self.setupqs.quickslots[v.id].quickslot:GetShortcut():GetData() ~= "" ) then
                        v.active = self.setupqs.quickslots[v.id].checkbox:IsChecked();
                        v.type = self.setupqs.quickslots[v.id].quickslot:GetShortcut():GetType();
                        v.data = self.setupqs.quickslots[v.id].quickslot:GetShortcut():GetData();
                else
                        v.active = false;
                        v.type = Turbine.UI.Lotro.ShortcutType.Undefined;
                        v.data = "";
                end
        end
        
        self:SaveSettings();
        self:Refresh();
end

-- Swap Slots
function ClassBar:SwapSlots(ref, code, type, item)
        local swap = nil;
        local swaptype = 1;
        if (not settings.lockslots) then
                for k,v in pairs(self.skills) do
                        if (not item) then
                                if (v:CheckShortcut(code)) then
                                        swap = v;
                                        swaptype = 1;
                                end
                        else
                                if (v.item ~= nil and v.item:GetName() == code) then
                                        swap = v;
                                        swaptype = 1;
                                end
                        end
                end
                if (self.customslots ~= nil) then
                        for k,v in pairs(self.customslots) do
                                if (not item) then
                                        if (v:CheckShortcut(code)) then
                                                swap = v;
                                                swaptype = 1;
                                        end
                                else
                                        if (v.item ~= nil and v.item:GetName() == code) then
                                                swap = v;
                                                swaptype = 1;
                                        end
                                end
                        end
                end
                for k,v in pairs(self.multi) do
                        if (not item) then
                                if (v:CheckShortcut(code)) then
                                        swap = v;
                                        swaptype = 2;
                                end
                        else
                                if (v.item ~= nil and v.item:GetName() == code ) then
                                        swap = v;
                                        swaptype = 2;
                                end
                        end
                end
        
                if (swap ~= nil) then
                        if (swap:GetParent() == limbo or swap:GetParent() == nil)  then
                                if (not ref:GetParent().exclusive and ref:GetParent() == ref.parent) then
                                                swap:SwapPosition(ref);
                                end
                        else
                                if( (ref:GetParent() == swap:GetParent() or ( not ref:GetParent().exclusive and not swap:GetParent().exclusive)) and (ref:GetParent() == ref.parent and swap:GetParent() == swap.parent)) then
                                        if (swaptype == 1) then
                                                ref:SwapPosition(swap);
                                        else
                                                swap:SwapPosition(ref);
                                        end
                                end
                        end
                else
                        if (settings.customslots == nil) then
                                settings.customslots = { };
                        end
                        if (self.customslots == nil) then
                                self.customslots = { };
                        end
                        
                        settings.customslots[#settings.customslots+1] = {parent = ref.parent.index, x = ref.x, y = ref.y, type = type, data = code};
                        self.customslots[#settings.customslots] = ItemSlot(ref.parent, ref.x, ref.y, true, { active = true, data = code, type = type });
                        
                        if (not ref.blank) then
                                ref:SetParent(limbo);
                                ref.parent = nil;
                                ref:SetPosition(0,0);
                                ref.x = 1;
                                ref.y = 1;
                        end
                end
        end
        if (swap ~= nil and swap.parent.index == self.currentkey) then
                swap:SetOpacity(1);
                swap:ResetQuickslot();
        end
        ref:ResetQuickslot();
end

-- Rotate Window
function ClassBar:RotateWindow(ref)
        local rotatebar = { };
        local counter=1
        for k,v in pairs(self.bars) do
                if(v:GetParent() == ref) then
                        v:RotateBar();
                        rotatebar[counter] = v;
                        counter = counter + 1;
                end
        end
        
        for k,v in pairs(self.skills) do
                for i=1, counter do
                        if(v:GetParent() == rotatebar[i]) then
                                v:RotateBar();
                        end
                end
        end
        
        for k,v in pairs(self.multi) do
                for i=1, counter do
                        if(v:GetParent() == rotatebar[i]) then
                                v:RotateBar();
                        end
                end
        end
end

-- Save Settings
function ClassBar:SaveSettings()

        if (self.settings.preconf ~= nil) then
                for k,v in pairs(self.settings.preconf) do
                        v.pos = { };
                        v.pos[1], v.pos[2] = self.windows[k]:GetPosition();
                        v.size = { self.windows[k].width, self.windows[k].height };
                        v.combat = { self.windows[k].incombat, self.windows[k].outcombat };
                        v.rotate = self.windows[k].rotate;
                end
                
                for k,v in pairs(self.settings.userconf) do
                        v.name = self.windows[k].heading;
                        v.pos = { };
                        v.pos[1], v.pos[2] = self.windows[k]:GetPosition();
                        v.size = { self.windows[k].width, self.windows[k].height };
                        v.combat = { self.windows[k].incombat, self.windows[k].outcombat };
                end
        else
                for k,v in pairs(self.windows) do
                        self.settings[k].x, self.settings[k].y = self.windows[k]:GetPosition();
                        self.settings[k].rotate = self.windows[k].rotate;
                end
        end
        
    local skilldata = { };
    for k,v in pairs(self.skills) do
                if (v:GetParent() == limbo or v.parent == nil) then
                        skilldata[k] = { pos = {v.x, v.y}, parent = nil };
                else
                        skilldata[k] = { pos = {v.x, v.y}, parent = v.parent.index };
                end
        end
        
        local multidata = { };
        for k,v in pairs(self.multi) do
                if (v:GetParent() == limbo or v.parent == nil) then
                        multidata[k] = { current = v.currentshortcut, layer = v.currentlayer, lock = v.lock, pos = { v.x, v.y }, parent = nil };
                else
                        multidata[k] = { current = v.currentshortcut, layer = v.currentlayer, lock = v.lock, pos = { v.x, v.y }, parent = v.parent.index };
                end
        end
        
        local customdata = { };
        local c = 0;
        if (self.customslots ~= nil) then
                for k,v in pairs(self.customslots) do
                        if (v.GetParent() ~= limbo) then
                                c = c+1;
                                customdata[c] = { parent = v.parent.index, x = v.x, y = v.y, data = v.data, type = v.type };
                                settings.customslots[c] = settings.customslots[k];
                                self.customslots[c] = v;
                        end
                end
        end
        
        for k,v in pairs(self.windows) do
                v:SetVisible(v.active);
        end

        --Turbine.Shell.WriteLine("KragenBars: " .. settings.class .. " Bars settings saved successfully.");

        settings.multidata = multidata;
        settings.skilldata = skilldata;
        settings.customslots = customdata;
        settings.classinfo = self.settings;
        SaveSettings();
end

-- Refresh Player Level and Window and Skill States
function ClassBar:RefreshBars()
        -- Refresh Player Level
        vars.playerlevel = vars.player:GetLevel();
        
        if (self.settings.preconf ~= nil) then
                -- Refresh Windows
                for k,v in pairs(self.settings.preconf) do
                        self.windows[k]:Refresh(v.active);
                end
                
                for k,v in pairs(self.settings.userconf) do
                        self.windows[k]:Refresh(v.active);
                end
        else
                -- Refresh Windows
                for k,v in pairs(self.windows) do
                        self.windows[k]:Refresh(self.settings[k].active);
                end
        end
        
        -- Refresh Skills
        for k,v in pairs(self.skills) do
                self.skills[k]:Refresh();
        end
end

function ClassBar:DefaultPosition()
    -- Refresh Windows
        for k,v in pairs(self.windows) do
        self.windows[k]:DefaultPosition();
        end
end

function ClassBar:RecalculateBorders()
        -- Refresh Skills
        for k,v in pairs(self.skills) do
                v.border:SetPosition(v:PointToScreen(1, 1));
        end
end

function ClassBar:CombatChange(combat)
        for k,v in pairs(self.skills) do
                self.skills[k]:RefreshCombat();
        end
        
        for k,v in pairs(self.multi) do
                self.multi[k]:RefreshCombat();
        end
        
        for k,v in pairs(self.bars) do
                self.bars[k]:RefreshCombat();
        end
end

function ClassBar:EditBars(bol)
        self.edit = bol;
        if (bol) then
                for k,v in pairs(self.bars) do
                        for key,value in pairs(self.skills) do
                                value:SetOpacity(1);
                                value.edit = true;
                                value:ResetQuickslot();
                        end
                        for key,value in pairs(self.multi) do
                                value:SetOpacity(1);
                                value.edit = true;
                                value:ResetQuickslot();
                        end
                        v.parent.edit = true;
                        v.parent:SetVisible(v.parent.active);
                        v:SetVisible(true);
                end
        else
                for k,v in pairs(self.bars) do
                        for key,value in pairs(self.skills) do
                                value.edit = false;
                                value:Refresh();
                        end
                        for key,value in pairs(self.multi) do
                                value.edit = false;
                                value:Refresh();
                        end
                        v.parent.edit = false;
                        v:RefreshCombat();
                end
        end
end

function ClassBar:CreateBar()
        local name = "UserBar"..tostring(settings.userbars + 1);
        local v = nil;
        
        settings.userbars = settings.userbars + 1;
        self.barcount = self.barcount + 1;
        
        v = { id = self.barcount, name = name, defpos = {0,0}, size = {1, 1} , pos = {800, 200+(35*settings.userbars)}, combat = {true,true}, active = true };
        self.windows[name] = SkillWindow(v);
        self.bars[name] = SkillBar(self.windows[name], 1, 1, 1, 1, true, false);
        self.bars[name].index = name;
        
        self.settings.userconf[name] = v;
        self.barlist[v.id] = name;
        
        return v.id;
end

function ClassBar:ResizeBar(key, size)
        self.bars[key]:ChangeSize(size[1], size[2]);
end

function ClassBar:RenameBar(key, name)
        if (self.windows[key] ~= nil) then
                self.windows[key]:SetName(name);
                self.settings.userconf[key].name = name;
        end
end

function ClassBar:BarCombat(key, num)
        self.windows[key]:SetCombat(num ~= 3, num ~= 2);
        self:CombatChange();
end

function ClassBar:DeleteBar(key)
        local id = nil
        
        self.barcount = 0;
        
        if (self.windows[key] ~= nil and self.settings.userconf[key] ~= nil) then
                id = self.settings.userconf[key].id;
                self.bars[key]:ChangeSize(0,0);
                self.bars[key]:SetVisible(false);
                self.windows[key]:Trash();
                self.windows[key] = nil;
                self.bars[key] = nil;
                self.settings.userconf[key] = nil;
                
                self.barlist = { };
                
                for k,v in pairs (self.settings.preconf) do
                        self.barlist[v.id] = k;
                        self.barcount = self.barcount + 1;
                end
                
                for k,v in pairs (self.settings.userconf) do
                        if (v.id > id) then
                                v.id = v.id - 1;
                        end
                        self.barlist[v.id] = k;
                        self.barcount = self.barcount + 1;
                end
                
                -- self.setupbb["checkboxbb"..tostring(self.barcount+1)]:SetVisible(false);
        end
end

Compare with Previous | Blame


All times are GMT -5. The time now is 02:20 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui