1 |
175 |
Thurallor-7095 |
DirectoryWindow = class(Turbine.UI.Lotro.Window); |
2 |
|
Thurallor-7095 |
|
3 |
|
Thurallor-7095 |
function DirectoryWindow:Constructor(manager, optionsPanel) |
4 |
|
Thurallor-7095 |
Turbine.UI.Lotro.Window.Constructor(self); |
5 |
|
Thurallor-7095 |
self.manager = manager; |
6 |
177 |
Thurallor-7095 |
self.settings = manager.settings.directoryWindow or {}; |
7 |
|
Thurallor-7095 |
manager.settings.directoryWindow = self.settings; |
8 |
175 |
Thurallor-7095 |
self.optionsPanel = optionsPanel; |
9 |
177 |
Thurallor-7095 |
|
10 |
|
Thurallor-7095 |
-- Restore saved size/position |
11 |
175 |
Thurallor-7095 |
self:SetResizable(true); |
12 |
177 |
Thurallor-7095 |
self:SetMinimumSize(460, 226); |
13 |
|
Thurallor-7095 |
local left, top = unpack(self.settings.position or {0, 0}); |
14 |
|
Thurallor-7095 |
local width, height = unpack(self.settings.size or {460, 226}); |
15 |
|
Thurallor-7095 |
self:SetPosition(left, top); |
16 |
|
Thurallor-7095 |
self:SetSize(width, height); |
17 |
175 |
Thurallor-7095 |
|
18 |
177 |
Thurallor-7095 |
left, top = 20, 36; |
19 |
175 |
Thurallor-7095 |
local label = Turbine.UI.Label(); |
20 |
|
Thurallor-7095 |
label:SetParent(self); |
21 |
|
Thurallor-7095 |
label:SetMultiline(true); |
22 |
|
Thurallor-7095 |
label:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft); |
23 |
|
Thurallor-7095 |
label:SetHeight(32); |
24 |
|
Thurallor-7095 |
label:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
25 |
|
Thurallor-7095 |
label:SetForeColor(Turbine.UI.Color.PaleGoldenrod); |
26 |
|
Thurallor-7095 |
label:SetPosition(left, top); |
27 |
|
Thurallor-7095 |
self.instructions = label; |
28 |
|
Thurallor-7095 |
top = top + 32; |
29 |
|
Thurallor-7095 |
|
30 |
|
Thurallor-7095 |
self.tabs = Thurallor.UI.TabCardStack(); |
31 |
|
Thurallor-7095 |
self.tabs:SetParent(self); |
32 |
|
Thurallor-7095 |
self.tabs:SetPosition(left, top); |
33 |
|
Thurallor-7095 |
|
34 |
176 |
Thurallor-7095 |
self.tab1 = BarsGroupsTab(manager); |
35 |
177 |
Thurallor-7095 |
AddCallback(self.tab1, "Click", function () |
36 |
|
Thurallor-7095 |
self.tab1:Redraw(); |
37 |
|
Thurallor-7095 |
end); |
38 |
176 |
Thurallor-7095 |
self.tab2 = UserEventsTab(manager); |
39 |
177 |
Thurallor-7095 |
AddCallback(self.tab2, "Click", function () |
40 |
|
Thurallor-7095 |
self.tab2:Redraw(); |
41 |
|
Thurallor-7095 |
end); |
42 |
175 |
Thurallor-7095 |
self.tabs:AddTabCard(self.tab1); |
43 |
|
Thurallor-7095 |
self.tabs:AddTabCard(self.tab2); |
44 |
|
Thurallor-7095 |
|
45 |
|
Thurallor-7095 |
self:Localize(); |
46 |
|
Thurallor-7095 |
self.tab1:BringToFront(); |
47 |
|
Thurallor-7095 |
|
48 |
177 |
Thurallor-7095 |
self:SizeChanged(true); |
49 |
|
Thurallor-7095 |
self:PositionChanged(true); |
50 |
|
Thurallor-7095 |
AddCallback(Turbine.UI.Display, "SizeChanged", function() |
51 |
|
Thurallor-7095 |
self:PositionChanged(true); |
52 |
|
Thurallor-7095 |
end); |
53 |
175 |
Thurallor-7095 |
end |
54 |
|
Thurallor-7095 |
|
55 |
|
Thurallor-7095 |
function DirectoryWindow:Localize() |
56 |
|
Thurallor-7095 |
self:SetText(L:GetText("/PluginManager/OptionsTab/Directory")); |
57 |
176 |
Thurallor-7095 |
self.instructions:SetText(L:GetText("/DirectoryWindow/Instructions")); |
58 |
175 |
Thurallor-7095 |
self.tab1:Localize(); |
59 |
176 |
Thurallor-7095 |
self.tab2:Localize(); |
60 |
175 |
Thurallor-7095 |
self.tabs:RedistributeTabs(); |
61 |
|
Thurallor-7095 |
end |
62 |
|
Thurallor-7095 |
|
63 |
177 |
Thurallor-7095 |
function DirectoryWindow:SizeChanged(loading) |
64 |
175 |
Thurallor-7095 |
local width, height = self:GetSize(); |
65 |
177 |
Thurallor-7095 |
self.settings.size = {width, height}; |
66 |
|
Thurallor-7095 |
if (not loading) then |
67 |
|
Thurallor-7095 |
self.manager:SaveSettings(false); |
68 |
|
Thurallor-7095 |
end |
69 |
|
Thurallor-7095 |
|
70 |
175 |
Thurallor-7095 |
self.instructions:SetWidth(width - 40); |
71 |
|
Thurallor-7095 |
self.tabs:SetSize(width - 40, height - 96); |
72 |
|
Thurallor-7095 |
self.tabs:RedistributeTabs(); |
73 |
|
Thurallor-7095 |
end |
74 |
|
Thurallor-7095 |
|
75 |
177 |
Thurallor-7095 |
function DirectoryWindow:PositionChanged(loading) |
76 |
|
Thurallor-7095 |
local left, top = self:GetPosition(); |
77 |
|
Thurallor-7095 |
self.settings.position = {left, top}; |
78 |
|
Thurallor-7095 |
if (loading) then |
79 |
|
Thurallor-7095 |
-- Ensure the window is on the screen, in case the plugin is loading with a smaller screen size. |
80 |
|
Thurallor-7095 |
local width, height = self:GetSize(); |
81 |
|
Thurallor-7095 |
local right, bottom = left + width, top + height; |
82 |
|
Thurallor-7095 |
local screenRight, screenBottom = Turbine.UI.Display:GetSize(); |
83 |
|
Thurallor-7095 |
if (screenRight < right) then |
84 |
|
Thurallor-7095 |
left = math.max(0, screenRight - width); |
85 |
|
Thurallor-7095 |
end |
86 |
|
Thurallor-7095 |
if (screenBottom < bottom) then |
87 |
|
Thurallor-7095 |
top = math.max(0, screenBottom - height); |
88 |
|
Thurallor-7095 |
end |
89 |
|
Thurallor-7095 |
self:SetPosition(left, top); |
90 |
|
Thurallor-7095 |
else |
91 |
|
Thurallor-7095 |
self.manager:SaveSettings(false); |
92 |
|
Thurallor-7095 |
end |
93 |
|
Thurallor-7095 |
end |
94 |
|
Thurallor-7095 |
|
95 |
|
Thurallor-7095 |
function DirectoryWindow:Show(whichTab) |
96 |
175 |
Thurallor-7095 |
self:SetVisible(true); |
97 |
177 |
Thurallor-7095 |
if (whichTab == "bars") then |
98 |
|
Thurallor-7095 |
self.tab1:BringToFront(); |
99 |
|
Thurallor-7095 |
elseif (whichTab == "events") then |
100 |
|
Thurallor-7095 |
self.tab2:BringToFront(); |
101 |
|
Thurallor-7095 |
end |
102 |
175 |
Thurallor-7095 |
end |
103 |
|
Thurallor-7095 |
|
104 |
|
Thurallor-7095 |
function DirectoryWindow:Hide() |
105 |
|
Thurallor-7095 |
self:SetVisible(false); |
106 |
|
Thurallor-7095 |
end |
107 |
|
Thurallor-7095 |
|
108 |
177 |
Thurallor-7095 |
function DirectoryWindow:Redraw(updateBarDirectory, updateEventDirectory) |
109 |
|
Thurallor-7095 |
if (self.tab1:IsInFront() and updateBarDirectory) then |
110 |
175 |
Thurallor-7095 |
self.tab1:Redraw(); |
111 |
177 |
Thurallor-7095 |
elseif (self.tab2:IsInFront() and updateEventDirectory) then |
112 |
175 |
Thurallor-7095 |
self.tab2:Redraw(); |
113 |
|
Thurallor-7095 |
end |
114 |
177 |
Thurallor-7095 |
end |