lotrointerface.com
Search Downloads

LoTROInterface SVN KragenBars

[/] [branches/] [3.21/] [KragenBars/] [ClassBar.lua] - Blame information for rev 72

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 72 Kragenwar-3044
import "Turbine.UI";
2 Kragenwar-3044
import "Turbine.UI.Lotro";
3 Kragenwar-3044
import "Turbine.Gameplay";
4 Kragenwar-3044
import "KragenPlugs.Utils";
5 Kragenwar-3044
import "KragenPlugs.KragenBars";
6 Kragenwar-3044
 
7 Kragenwar-3044
ClassBar = class( );
8 Kragenwar-3044
 
9 Kragenwar-3044
function ClassBar:Constructor()
10 Kragenwar-3044
 
11 Kragenwar-3044
        -- inialize the setupWindow
12 Kragenwar-3044
        self.setup = SetupWindow();
13 Kragenwar-3044
        self.setupbb = self.setup.setupbb;
14 Kragenwar-3044
        self.setupf = self.setup.setupf;
15 Kragenwar-3044
        self.setupqs = self.setup.setupqs;
16 Kragenwar-3044
 
17 Kragenwar-3044
        -- inialize tables
18 Kragenwar-3044
        self.windows = { };
19 Kragenwar-3044
        self.bars = { };
20 Kragenwar-3044
        self.skills = { };
21 Kragenwar-3044
        self.multi = { };
22 Kragenwar-3044
 
23 Kragenwar-3044
        self.setup:SetWantsKeyEvents(true);
24 Kragenwar-3044
 
25 Kragenwar-3044
        self.setup.KeyDown = function(sender, args)
26 Kragenwar-3044
        if args.Action == 0x100000B3 then
27 Kragenwar-3044
                        self.setup:SetWantsUpdates(true);
28 Kragenwar-3044
                end
29 Kragenwar-3044
        end
30 Kragenwar-3044
 
31 Kragenwar-3044
        self.setup.Update = function(sender, args)
32 Kragenwar-3044
        for k,v in pairs(self.skills) do
33 Kragenwar-3044
                        v:RefreshBorders();
34 Kragenwar-3044
                end
35 Kragenwar-3044
                self.setup:SetWantsUpdates(false);
36 Kragenwar-3044
        end
37 Kragenwar-3044
 
38 Kragenwar-3044
        -- Combat Event
39 Kragenwar-3044
        AddCallback(vars.player, "InCombatChanged", function(sender, args)
40 Kragenwar-3044
                KragenBars:CombatChange(vars.player:IsInCombat());
41 Kragenwar-3044
        end);
42 Kragenwar-3044
 
43 Kragenwar-3044
        -- Effect Events
44 Kragenwar-3044
    AddCallback(vars.effects, "EffectAdded", function(sender, args)
45 Kragenwar-3044
                KragenBars:AddEffect( args.Index );
46 Kragenwar-3044
        end);
47 Kragenwar-3044
 
48 Kragenwar-3044
        AddCallback(vars.effects, "EffectRemoved", function(sender, args)
49 Kragenwar-3044
                if (args.Effect ~= nil) then
50 Kragenwar-3044
                        KragenBars:RemoveEffect( args.Effect );
51 Kragenwar-3044
                end
52 Kragenwar-3044
        end);
53 Kragenwar-3044
 
54 Kragenwar-3044
end
55 Kragenwar-3044
 
56 Kragenwar-3044
-- Index and Position Bars
57 Kragenwar-3044
function ClassBar:InitBars()
58 Kragenwar-3044
        self.DefineEffectList();
59 Kragenwar-3044
 
60 Kragenwar-3044
        for k,v in pairs(self.bars) do
61 Kragenwar-3044
                v.index = k;
62 Kragenwar-3044
        end
63 Kragenwar-3044
 
64 Kragenwar-3044
        if(settings.skilldata ~=nil) then
65 Kragenwar-3044
                for k,v in pairs(self.skills) do
66 Kragenwar-3044
                        if (settings.skilldata[k] ~= nil) then
67 Kragenwar-3044
                            local data = settings.skilldata[k];
68 Kragenwar-3044
                            data.parent = self.bars[settings.skilldata[k].parent]
69 Kragenwar-3044
                                v:LoadPosition(data);
70 Kragenwar-3044
                        end
71 Kragenwar-3044
                end
72 Kragenwar-3044
        end
73 Kragenwar-3044
 
74 Kragenwar-3044
        if(settings.multidata ~=nil) then
75 Kragenwar-3044
                for k,v in pairs(self.multi) do
76 Kragenwar-3044
                        if (settings.multidata[k] ~= nil) then
77 Kragenwar-3044
                                local data = settings.multidata[k];
78 Kragenwar-3044
                            data.parent = self.bars[settings.multidata[k].parent]
79 Kragenwar-3044
                                v:LoadPosition(data);
80 Kragenwar-3044
                        end
81 Kragenwar-3044
                end
82 Kragenwar-3044
        end
83 Kragenwar-3044
 
84 Kragenwar-3044
        for k,v in pairs(self.windows) do
85 Kragenwar-3044
                v:SetVisible(v.active);
86 Kragenwar-3044
        end
87 Kragenwar-3044
 
88 Kragenwar-3044
        for k,v in pairs(self.skills) do
89 Kragenwar-3044
                if (v.parent ~= nil) then
90 Kragenwar-3044
                        v.parent:AddSkill(v);
91 Kragenwar-3044
                end
92 Kragenwar-3044
                v:RefreshBorders();
93 Kragenwar-3044
        end
94 Kragenwar-3044
 
95 Kragenwar-3044
        for i = 1, vars.effects:GetCount() do
96 Kragenwar-3044
                self:AddEffect(i);
97 Kragenwar-3044
        end
98 Kragenwar-3044
end
99 Kragenwar-3044
 
100 Kragenwar-3044
-- Swap Slots
101 Kragenwar-3044
function ClassBar:SwapSlots(ref, code)
102 Kragenwar-3044
 
103 Kragenwar-3044
        local swap = nil;
104 Kragenwar-3044
        local swaptype = 1;
105 Kragenwar-3044
        if (not settings.lockslots) then
106 Kragenwar-3044
                for k,v in pairs(self.skills) do
107 Kragenwar-3044
                        if (v.quickslot:GetShortcut():GetData() == code ) then
108 Kragenwar-3044
                                swap = v;
109 Kragenwar-3044
                                swaptype = 1;
110 Kragenwar-3044
                        end
111 Kragenwar-3044
                end
112 Kragenwar-3044
                for k,v in pairs(self.multi) do
113 Kragenwar-3044
                        if (v.quickslot:GetShortcut():GetData() == code ) then
114 Kragenwar-3044
                                --if ((ref:GetParent() == v:GetParent() or ((v:GetParent().exclusive == nil or ref:GetParent().exclusive == nil) or (not ref:GetParent().exclusive and not v:GetParent().exclusive)))) then
115 Kragenwar-3044
                                        swap = v;
116 Kragenwar-3044
                                        swaptype = 2;
117 Kragenwar-3044
                                --end
118 Kragenwar-3044
                        end
119 Kragenwar-3044
                end
120 Kragenwar-3044
        end
121 Kragenwar-3044
        if (swap ~= nil) then
122 Kragenwar-3044
                if (swap:GetParent() == limbo)  then
123 Kragenwar-3044
                        if (not ref:GetParent().exclusive and ref:GetParent() == ref.parent) then
124 Kragenwar-3044
                                        swap:SwapPosition(ref);
125 Kragenwar-3044
                        end
126 Kragenwar-3044
                else
127 Kragenwar-3044
                        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
128 Kragenwar-3044
                                if (swaptype == 1) then
129 Kragenwar-3044
                                        ref:SwapPosition(swap);
130 Kragenwar-3044
                                else
131 Kragenwar-3044
                                        swap:SwapPosition(ref);
132 Kragenwar-3044
                                end
133 Kragenwar-3044
                        end
134 Kragenwar-3044
                end
135 Kragenwar-3044
        end
136 Kragenwar-3044
        ref:ResetQuickslot();
137 Kragenwar-3044
end
138 Kragenwar-3044
 
139 Kragenwar-3044
-- Rotate Window
140 Kragenwar-3044
function ClassBar:RotateWindow(ref)
141 Kragenwar-3044
        local rotatebar = { };
142 Kragenwar-3044
        local counter=1
143 Kragenwar-3044
        for k,v in pairs(self.bars) do
144 Kragenwar-3044
                if(v:GetParent() == ref) then
145 Kragenwar-3044
                        v:RotateBar();
146 Kragenwar-3044
                        rotatebar[counter] = v;
147 Kragenwar-3044
                        counter = counter + 1;
148 Kragenwar-3044
                end
149 Kragenwar-3044
        end
150 Kragenwar-3044
 
151 Kragenwar-3044
        for k,v in pairs(self.skills) do
152 Kragenwar-3044
                for i=1, counter do
153 Kragenwar-3044
                        if(v:GetParent() == rotatebar[i]) then
154 Kragenwar-3044
                                v:RotateBar();
155 Kragenwar-3044
                        end
156 Kragenwar-3044
                end
157 Kragenwar-3044
        end
158 Kragenwar-3044
 
159 Kragenwar-3044
        for k,v in pairs(self.multi) do
160 Kragenwar-3044
                for i=1, counter do
161 Kragenwar-3044
                        if(v:GetParent() == rotatebar[i]) then
162 Kragenwar-3044
                                v:RotateBar();
163 Kragenwar-3044
                        end
164 Kragenwar-3044
                end
165 Kragenwar-3044
        end
166 Kragenwar-3044
end
167 Kragenwar-3044
 
168 Kragenwar-3044
-- Save Settings
169 Kragenwar-3044
function ClassBar:SaveSettings()
170 Kragenwar-3044
        for k,v in pairs(self.windows) do
171 Kragenwar-3044
            self.settings[k].x, self.settings[k].y = self.windows[k]:GetPosition();
172 Kragenwar-3044
                self.settings[k].rotate = self.windows[k].rotate;
173 Kragenwar-3044
        end
174 Kragenwar-3044
 
175 Kragenwar-3044
    local skilldata = { };
176 Kragenwar-3044
    for k,v in pairs(self.skills) do
177 Kragenwar-3044
                if (v.GetParent() == limbo) then
178 Kragenwar-3044
                        skilldata[k] = { pos = {v.x, v.y}, parent = nil };
179 Kragenwar-3044
                else
180 Kragenwar-3044
                        skilldata[k] = { pos = {v.x, v.y}, parent = v.parent.index };
181 Kragenwar-3044
                end
182 Kragenwar-3044
        end
183 Kragenwar-3044
 
184 Kragenwar-3044
        local multidata = { };
185 Kragenwar-3044
        for k,v in pairs(self.multi) do
186 Kragenwar-3044
                if (v.GetParent() == limbo) then
187 Kragenwar-3044
                        multidata[k] = { current = v.currentshortcut, layer = v.currentlayer, lock = v.lock, pos = { v.x, v.y }, parent = nil };
188 Kragenwar-3044
                else
189 Kragenwar-3044
                        multidata[k] = { current = v.currentshortcut, layer = v.currentlayer, lock = v.lock, pos = { v.x, v.y }, parent = v.parent.index };
190 Kragenwar-3044
                end
191 Kragenwar-3044
 
192 Kragenwar-3044
        end
193 Kragenwar-3044
 
194 Kragenwar-3044
        for k,v in pairs(self.windows) do
195 Kragenwar-3044
                v:SetVisible(v.active);
196 Kragenwar-3044
        end
197 Kragenwar-3044
 
198 Kragenwar-3044
        Turbine.Shell.WriteLine("KragenBars: " .. settings.class .. " Bars settings saved successfully.");
199 Kragenwar-3044
 
200 Kragenwar-3044
        settings.multidata = multidata;
201 Kragenwar-3044
        settings.skilldata = skilldata;
202 Kragenwar-3044
        settings.classinfo = self.settings;
203 Kragenwar-3044
        SaveSettings();
204 Kragenwar-3044
end
205 Kragenwar-3044
 
206 Kragenwar-3044
-- Refresh Player Level and Window and Skill States
207 Kragenwar-3044
function ClassBar:RefreshBars()
208 Kragenwar-3044
        -- Refresh Player Level
209 Kragenwar-3044
        vars.playerlevel = vars.player:GetLevel();
210 Kragenwar-3044
 
211 Kragenwar-3044
        -- Refresh Windows
212 Kragenwar-3044
        for k,v in pairs(self.windows) do
213 Kragenwar-3044
        self.windows[k]:Refresh(self.settings[k].active);
214 Kragenwar-3044
        end
215 Kragenwar-3044
 
216 Kragenwar-3044
        -- Refresh Skills
217 Kragenwar-3044
        for k,v in pairs(self.skills) do
218 Kragenwar-3044
                self.skills[k]:Refresh();
219 Kragenwar-3044
        end
220 Kragenwar-3044
end
221 Kragenwar-3044
 
222 Kragenwar-3044
function ClassBar:DefaultPosition()
223 Kragenwar-3044
    -- Refresh Windows
224 Kragenwar-3044
        for k,v in pairs(self.windows) do
225 Kragenwar-3044
        self.windows[k]:DefaultPosition();
226 Kragenwar-3044
        end
227 Kragenwar-3044
end
228 Kragenwar-3044
 
229 Kragenwar-3044
function ClassBar:RecalculateBorders()
230 Kragenwar-3044
        -- Refresh Skills
231 Kragenwar-3044
        for k,v in pairs(self.skills) do
232 Kragenwar-3044
                v.border:SetPosition(v:PointToScreen(1, 1));
233 Kragenwar-3044
        end
234 Kragenwar-3044
end
235 Kragenwar-3044
 
236 Kragenwar-3044
function ClassBar:CombatChange(combat)
237 Kragenwar-3044
        for k,v in pairs(self.skills) do
238 Kragenwar-3044
                self.skills[k]:RefreshCombat();
239 Kragenwar-3044
        end
240 Kragenwar-3044
 
241 Kragenwar-3044
        for k,v in pairs(self.multi) do
242 Kragenwar-3044
                self.multi[k]:RefreshCombat();
243 Kragenwar-3044
        end
244 Kragenwar-3044
end

All times are GMT -5. The time now is 06:15 PM.


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