1 |
12 |
Thurallor-7095 |
NodeLabel = class(Turbine.UI.Label); |
2 |
|
Thurallor-7095 |
|
3 |
|
Thurallor-7095 |
function NodeLabel:Constructor(node, object) |
4 |
|
Thurallor-7095 |
Turbine.UI.Label.Constructor(self); |
5 |
|
Thurallor-7095 |
self.node = node; |
6 |
|
Thurallor-7095 |
self.object = object; |
7 |
|
Thurallor-7095 |
self:SetFont(Turbine.UI.Lotro.Font.TrajanPro15); |
8 |
|
Thurallor-7095 |
self:SetTextAlignment(Turbine.UI.ContentAlignment.MiddleLeft); |
9 |
|
Thurallor-7095 |
self:SetFontStyle(Turbine.UI.FontStyle.Outline); |
10 |
|
Thurallor-7095 |
self:SetOutlineColor(Turbine.UI.Color.Black); |
11 |
|
Thurallor-7095 |
self:SetMultiline(false); |
12 |
|
Thurallor-7095 |
self:SetHeight(20); |
13 |
|
Thurallor-7095 |
self:UpdateText(); |
14 |
|
Thurallor-7095 |
self.skipSizeChanged = 1; |
15 |
|
Thurallor-7095 |
end |
16 |
|
Thurallor-7095 |
|
17 |
|
Thurallor-7095 |
function NodeLabel:UpdateText() |
18 |
|
Thurallor-7095 |
self:SetForeColor(self.object:GetColor()); |
19 |
|
Thurallor-7095 |
self:SetText(self.object:GetName()); |
20 |
|
Thurallor-7095 |
end |
21 |
|
Thurallor-7095 |
|
22 |
|
Thurallor-7095 |
ShowHideButton = class(Turbine.UI.Lotro.Button); |
23 |
|
Thurallor-7095 |
|
24 |
|
Thurallor-7095 |
function ShowHideButton:Constructor(node, object) |
25 |
|
Thurallor-7095 |
Turbine.UI.Lotro.Button.Constructor(self); |
26 |
|
Thurallor-7095 |
self.node = node; |
27 |
|
Thurallor-7095 |
self.object = object; |
28 |
|
Thurallor-7095 |
self:SetFont(Turbine.UI.Lotro.Font.TrajanPro13); |
29 |
|
Thurallor-7095 |
self:SetWidth(ShowHideButton.buttonWidth); |
30 |
|
Thurallor-7095 |
object.HiddenChanged = function() |
31 |
|
Thurallor-7095 |
self:UpdateText(); |
32 |
|
Thurallor-7095 |
end |
33 |
|
Thurallor-7095 |
self:UpdateText(); |
34 |
|
Thurallor-7095 |
end |
35 |
|
Thurallor-7095 |
|
36 |
|
Thurallor-7095 |
function ShowHideButton:UpdateText() |
37 |
|
Thurallor-7095 |
local hidden = self.object.settings.hidden; |
38 |
18 |
Thurallor-7095 |
self:SetFont(Turbine.UI.Lotro.Font.TrajanPro13); -- reapply font for Cyrillic |
39 |
12 |
Thurallor-7095 |
if (hidden) then |
40 |
|
Thurallor-7095 |
self:SetText(ShowHideButton.showText); |
41 |
|
Thurallor-7095 |
else |
42 |
|
Thurallor-7095 |
self:SetText(ShowHideButton.hideText); |
43 |
|
Thurallor-7095 |
end |
44 |
|
Thurallor-7095 |
self:SetVisible(not self.object:IsParentHidden()); |
45 |
|
Thurallor-7095 |
end |
46 |
|
Thurallor-7095 |
|
47 |
|
Thurallor-7095 |
function ShowHideButton:Click() |
48 |
|
Thurallor-7095 |
self.object:SetHidden(not self.object:IsHidden()); |
49 |
|
Thurallor-7095 |
end |
50 |
|
Thurallor-7095 |
|
51 |
2 |
Thurallor-7095 |
OptionsPanel = class(Turbine.UI.Control); |
52 |
|
Thurallor-7095 |
|
53 |
|
Thurallor-7095 |
function OptionsPanel:Constructor(manager) |
54 |
|
Thurallor-7095 |
Turbine.UI.Control.Constructor(self); |
55 |
|
Thurallor-7095 |
|
56 |
|
Thurallor-7095 |
self.manager = manager; |
57 |
12 |
Thurallor-7095 |
self.skipSizeChanged = 0; |
58 |
|
Thurallor-7095 |
self.skipUpdate = 0; |
59 |
2 |
Thurallor-7095 |
|
60 |
12 |
Thurallor-7095 |
self.tabs = Thurallor.UI.TabCardStack(); |
61 |
|
Thurallor-7095 |
self.tabs:SetParent(self); |
62 |
|
Thurallor-7095 |
|
63 |
|
Thurallor-7095 |
self.tab1 = Thurallor.UI.TabCard(); |
64 |
|
Thurallor-7095 |
self.tab1:SetTabLeft(0); |
65 |
|
Thurallor-7095 |
self.tab1.inside = Turbine.UI.Control(); |
66 |
|
Thurallor-7095 |
self.tab1:SetInteriorControl(self.tab1.inside); |
67 |
|
Thurallor-7095 |
self.tab1:SetInteriorAlignment(Turbine.UI.ContentAlignment.TopLeft); |
68 |
|
Thurallor-7095 |
|
69 |
16 |
Thurallor-7095 |
local left, top = 10, 10; |
70 |
12 |
Thurallor-7095 |
|
71 |
|
Thurallor-7095 |
self.tab1.language = Turbine.UI.Label(); |
72 |
|
Thurallor-7095 |
self.tab1.language:SetParent(self.tab1.inside); |
73 |
|
Thurallor-7095 |
self.tab1.language:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
74 |
|
Thurallor-7095 |
self.tab1.language:SetPosition(left, top); |
75 |
|
Thurallor-7095 |
self.tab1.language:SetSize(100, 16); |
76 |
|
Thurallor-7095 |
top = top + 16; |
77 |
|
Thurallor-7095 |
|
78 |
|
Thurallor-7095 |
local languages = { "English", "German", "French", "Russian" }; |
79 |
|
Thurallor-7095 |
local peers = {}; |
80 |
|
Thurallor-7095 |
self.tab1.languageButtons = {}; |
81 |
|
Thurallor-7095 |
for l = 1, #languages do |
82 |
|
Thurallor-7095 |
language = languages[l]; |
83 |
|
Thurallor-7095 |
local radioButton = Thurallor.UI.RadioButton(self.tab1.inside); |
84 |
|
Thurallor-7095 |
radioButton.language = languages[l]; |
85 |
|
Thurallor-7095 |
radioButton:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
86 |
16 |
Thurallor-7095 |
radioButton:SetSize(300, 16); |
87 |
12 |
Thurallor-7095 |
radioButton:SetPosition(left, top); |
88 |
|
Thurallor-7095 |
radioButton.Clicked = function(sender) |
89 |
|
Thurallor-7095 |
self.manager:SetLanguage(Turbine.Language[sender.language]); |
90 |
18 |
Thurallor-7095 |
-- self:Localize(); |
91 |
|
Thurallor-7095 |
-- self:RefreshDirectory(); |
92 |
12 |
Thurallor-7095 |
end |
93 |
|
Thurallor-7095 |
self.tab1.languageButtons[radioButton.language] = radioButton; |
94 |
|
Thurallor-7095 |
table.insert(peers, radioButton); |
95 |
|
Thurallor-7095 |
top = top + 16; |
96 |
|
Thurallor-7095 |
end |
97 |
|
Thurallor-7095 |
Thurallor.UI.RadioButton.LinkPeers(peers); |
98 |
16 |
Thurallor-7095 |
|
99 |
|
Thurallor-7095 |
top = top + 16; |
100 |
|
Thurallor-7095 |
self.tab1.snapToGrid = Turbine.UI.Lotro.CheckBox(); |
101 |
|
Thurallor-7095 |
self.tab1.snapToGrid:SetParent(self.tab1.inside); |
102 |
|
Thurallor-7095 |
self.tab1.snapToGrid:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
103 |
|
Thurallor-7095 |
self.tab1.snapToGrid:SetPosition(left, top); |
104 |
|
Thurallor-7095 |
self.tab1.snapToGrid:SetSize(200, 16); |
105 |
|
Thurallor-7095 |
self.tab1.snapToGrid.CheckedChanged = function(sender) |
106 |
|
Thurallor-7095 |
self.manager:SetSnapToGrid(sender:IsChecked()); |
107 |
|
Thurallor-7095 |
end |
108 |
|
Thurallor-7095 |
|
109 |
|
Thurallor-7095 |
top = top + 32; |
110 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel = Turbine.UI.Label(); |
111 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel:SetParent(self.tab1.inside); |
112 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
113 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel:SetPosition(left, top); |
114 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel:SetSize(200, 16); |
115 |
12 |
Thurallor-7095 |
|
116 |
16 |
Thurallor-7095 |
|
117 |
|
Thurallor-7095 |
top = top + 16; |
118 |
|
Thurallor-7095 |
self.tab1.uiScale = Turbine.UI.Lotro.ScrollBar(); |
119 |
|
Thurallor-7095 |
self.tab1.uiScale:SetParent(self.tab1.inside); |
120 |
|
Thurallor-7095 |
self.tab1.uiScale:SetPosition(left, top); |
121 |
|
Thurallor-7095 |
self.tab1.uiScale:SetSize(200, 10); |
122 |
|
Thurallor-7095 |
self.tab1.uiScale:SetMinimum(13); |
123 |
|
Thurallor-7095 |
self.tab1.uiScale:SetMaximum(96); |
124 |
|
Thurallor-7095 |
self.tab1.uiScale:SetSmallChange(1); |
125 |
|
Thurallor-7095 |
self.tab1.uiScale:SetLargeChange(10); |
126 |
|
Thurallor-7095 |
self.tab1.uiScale.ValueChanged = function(sb) |
127 |
|
Thurallor-7095 |
local scale = sb:GetValue(); |
128 |
|
Thurallor-7095 |
self.manager:SetUIScale(scale); |
129 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel:SetText(L:GetText("/PluginManager/OptionsTab/GlobalSettingsTab/UiScale") .. ": " .. string.format("%d", scale * 100 / 32) .. "%"); |
130 |
|
Thurallor-7095 |
end |
131 |
|
Thurallor-7095 |
|
132 |
|
Thurallor-7095 |
top = top + 26; |
133 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel = Turbine.UI.Label(); |
134 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel:SetParent(self.tab1.inside); |
135 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
136 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel:SetPosition(left, top); |
137 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel:SetSize(200, 16); |
138 |
|
Thurallor-7095 |
|
139 |
|
Thurallor-7095 |
top = top + 16; |
140 |
|
Thurallor-7095 |
self.tab1.uiOpacity = Turbine.UI.Lotro.ScrollBar(); |
141 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetParent(self.tab1.inside); |
142 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetPosition(left, top); |
143 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetSize(200, 10); |
144 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetMinimum(0); |
145 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetMaximum(100); |
146 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetSmallChange(1); |
147 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetLargeChange(10); |
148 |
|
Thurallor-7095 |
self.tab1.uiOpacity.ValueChanged = function(sb) |
149 |
|
Thurallor-7095 |
local opacity = sb:GetValue(); |
150 |
|
Thurallor-7095 |
self.manager:SetUIOpacity(opacity / 100); |
151 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel:SetText(L:GetText("/PluginManager/OptionsTab/GlobalSettingsTab/UiOpacity") .. ": " .. opacity .. "%"); |
152 |
|
Thurallor-7095 |
end |
153 |
|
Thurallor-7095 |
|
154 |
|
Thurallor-7095 |
top = top + 16; |
155 |
|
Thurallor-7095 |
|
156 |
|
Thurallor-7095 |
local width, height = 300, top + 10; |
157 |
12 |
Thurallor-7095 |
self.tab1.inside:SetSize(width, height); |
158 |
|
Thurallor-7095 |
self:RefreshGlobalSettings(); |
159 |
|
Thurallor-7095 |
|
160 |
|
Thurallor-7095 |
self.tab2 = Thurallor.UI.TabCard(); |
161 |
|
Thurallor-7095 |
self.tab2.inside = Turbine.UI.Control(); |
162 |
|
Thurallor-7095 |
self.tab2.inside:SetSize(width, height); |
163 |
|
Thurallor-7095 |
self.tab2:SetInteriorControl(self.tab2.inside); |
164 |
|
Thurallor-7095 |
self.tab2:SetInteriorAlignment(Turbine.UI.ContentAlignment.TopCenter); |
165 |
|
Thurallor-7095 |
|
166 |
|
Thurallor-7095 |
self.tabs:SetSize(width + 20, height + 40); |
167 |
13 |
Thurallor-7095 |
self:SetSize(width + 20, height + 40); |
168 |
12 |
Thurallor-7095 |
self.tabs:AddTabCard(self.tab1); |
169 |
|
Thurallor-7095 |
self.tabs:AddTabCard(self.tab2); |
170 |
|
Thurallor-7095 |
|
171 |
2 |
Thurallor-7095 |
self.instructions = Turbine.UI.Label(); |
172 |
12 |
Thurallor-7095 |
self.instructions:SetParent(self.tab2.inside); |
173 |
2 |
Thurallor-7095 |
self.instructions:SetMultiline(true); |
174 |
12 |
Thurallor-7095 |
self.instructions.height = 32; |
175 |
|
Thurallor-7095 |
self.instructions:SetHeight(self.instructions.height); |
176 |
2 |
Thurallor-7095 |
self.instructions:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
177 |
|
Thurallor-7095 |
self.instructions:SetForeColor(Turbine.UI.Color.PaleGoldenrod); |
178 |
12 |
Thurallor-7095 |
self:Localize(); |
179 |
|
Thurallor-7095 |
|
180 |
|
Thurallor-7095 |
-- For drag-and-drop operations |
181 |
|
Thurallor-7095 |
self.carrierWindow = Turbine.UI.Window(); |
182 |
|
Thurallor-7095 |
self.carrierWindow:SetZOrder(2147483647); |
183 |
|
Thurallor-7095 |
self.carrierWindow:SetOpacity(0.75); |
184 |
|
Thurallor-7095 |
self.carrierWindow:SetMouseVisible(false); |
185 |
|
Thurallor-7095 |
|
186 |
2 |
Thurallor-7095 |
plugin.GetOptionsPanel = function() |
187 |
|
Thurallor-7095 |
return self; |
188 |
|
Thurallor-7095 |
end |
189 |
|
Thurallor-7095 |
end |
190 |
|
Thurallor-7095 |
|
191 |
|
Thurallor-7095 |
function OptionsPanel:ShowRefreshButton() |
192 |
18 |
Thurallor-7095 |
local prevContext = L:SetContext("/PluginManager/OptionsTab/"); |
193 |
2 |
Thurallor-7095 |
if (not self.refreshButton) then |
194 |
|
Thurallor-7095 |
self.refreshButton = Turbine.UI.Lotro.Button(); |
195 |
|
Thurallor-7095 |
self.refreshButton:SetSize(L:GetNumber("ShowHideButtonWidth"), 20); |
196 |
|
Thurallor-7095 |
self.refreshButton.Click = function() |
197 |
12 |
Thurallor-7095 |
self:RefreshDirectory(); |
198 |
2 |
Thurallor-7095 |
end |
199 |
|
Thurallor-7095 |
end |
200 |
18 |
Thurallor-7095 |
self.refreshButton:SetText(L:GetText("Show")); |
201 |
|
Thurallor-7095 |
self.refreshButton:SetFont(Turbine.UI.Lotro.Font.TrajanPro13); -- reapply font for Cyrillic |
202 |
12 |
Thurallor-7095 |
self.tab2:SetInteriorControl(self.refreshButton); |
203 |
18 |
Thurallor-7095 |
L:SetContext(prevContext); |
204 |
2 |
Thurallor-7095 |
end |
205 |
|
Thurallor-7095 |
|
206 |
12 |
Thurallor-7095 |
function OptionsPanel:ShowGlobalSettings() |
207 |
5 |
Thurallor-7095 |
Turbine.PluginManager.ShowOptions(Plugins.SequenceBars); |
208 |
12 |
Thurallor-7095 |
self.tabs:BringToFront(self.tab1); |
209 |
|
Thurallor-7095 |
self:RefreshGlobalSettings(); |
210 |
5 |
Thurallor-7095 |
end |
211 |
|
Thurallor-7095 |
|
212 |
12 |
Thurallor-7095 |
function OptionsPanel:ShowDirectory() |
213 |
|
Thurallor-7095 |
Turbine.PluginManager.ShowOptions(Plugins.SequenceBars); |
214 |
|
Thurallor-7095 |
self.tabs:BringToFront(self.tab2); |
215 |
|
Thurallor-7095 |
self:RefreshDirectory(); |
216 |
|
Thurallor-7095 |
end |
217 |
|
Thurallor-7095 |
|
218 |
|
Thurallor-7095 |
function OptionsPanel:Localize() |
219 |
18 |
Thurallor-7095 |
-- Reapply fonts for Cyrillic support |
220 |
|
Thurallor-7095 |
self.tab1.tabText:SetFont(Turbine.UI.Lotro.Font.TrajanPro15); |
221 |
|
Thurallor-7095 |
self.tab2.tabText:SetFont(Turbine.UI.Lotro.Font.TrajanPro15); |
222 |
|
Thurallor-7095 |
for object in values({ |
223 |
|
Thurallor-7095 |
self.tab1.language, |
224 |
|
Thurallor-7095 |
self.tab1.languageButtons["English"], |
225 |
|
Thurallor-7095 |
self.tab1.languageButtons["French"], |
226 |
|
Thurallor-7095 |
self.tab1.languageButtons["German"], |
227 |
|
Thurallor-7095 |
self.tab1.languageButtons["Russian"], |
228 |
|
Thurallor-7095 |
self.tab1.snapToGrid, |
229 |
|
Thurallor-7095 |
self.instructions, |
230 |
|
Thurallor-7095 |
self.tab1.uiScaleLabel, |
231 |
|
Thurallor-7095 |
self.tab1.uiOpacityLabel |
232 |
|
Thurallor-7095 |
}) do |
233 |
|
Thurallor-7095 |
object:SetFont(Turbine.UI.Lotro.Font.TrajanPro14); |
234 |
|
Thurallor-7095 |
end |
235 |
|
Thurallor-7095 |
|
236 |
12 |
Thurallor-7095 |
local tab1Width = L:GetNumber("/PluginManager/OptionsTab/GlobalSettingsTabWidth"); |
237 |
|
Thurallor-7095 |
self.tab1:SetTabWidth(tab1Width); |
238 |
|
Thurallor-7095 |
self.tab1:SetTabText(L:GetText("/PluginManager/OptionsTab/GlobalSettings")); |
239 |
|
Thurallor-7095 |
self.tab1.language:SetText(L:GetText("/PluginManager/OptionsTab/GlobalSettingsTab/Language")); |
240 |
|
Thurallor-7095 |
for language in keys(self.tab1.languageButtons) do |
241 |
|
Thurallor-7095 |
self.tab1.languageButtons[language]:SetText(L:GetText("/PluginManager/OptionsTab/GlobalSettingsTab/LanguageMenu/" .. language)); |
242 |
2 |
Thurallor-7095 |
end |
243 |
16 |
Thurallor-7095 |
self.tab1.snapToGrid:SetText(L:GetText("/PluginManager/OptionsTab/GlobalSettingsTab/SnapToGrid")); |
244 |
|
Thurallor-7095 |
self.tab1.uiScale:ValueChanged(); |
245 |
|
Thurallor-7095 |
self.tab1.uiOpacity:ValueChanged(); |
246 |
12 |
Thurallor-7095 |
|
247 |
|
Thurallor-7095 |
self.tab2:SetTabLeft(tab1Width); |
248 |
|
Thurallor-7095 |
self.tab2:SetTabWidth(L:GetNumber("/PluginManager/OptionsTab/DirectoryTabWidth")); |
249 |
|
Thurallor-7095 |
self.tab2:SetTabText(L:GetText("/PluginManager/OptionsTab/Directory")); |
250 |
2 |
Thurallor-7095 |
self.instructions:SetText(L:GetText("/PluginManager/OptionsTab/Instructions")); |
251 |
12 |
Thurallor-7095 |
ShowHideButton.buttonWidth = L:GetNumber("/PluginManager/OptionsTab/ShowHideButtonWidth"); |
252 |
|
Thurallor-7095 |
ShowHideButton.showText = L:GetText("/PluginManager/OptionsTab/Show"); |
253 |
|
Thurallor-7095 |
ShowHideButton.hideText = L:GetText("/PluginManager/OptionsTab/Hide"); |
254 |
|
Thurallor-7095 |
end |
255 |
2 |
Thurallor-7095 |
|
256 |
12 |
Thurallor-7095 |
function OptionsPanel:RefreshGlobalSettings() |
257 |
|
Thurallor-7095 |
for language in keys(self.tab1.languageButtons) do |
258 |
|
Thurallor-7095 |
self.tab1.languageButtons[language]:SetChecked(self.manager.settings.language == Turbine.Language[language]); |
259 |
2 |
Thurallor-7095 |
end |
260 |
16 |
Thurallor-7095 |
self.tab1.snapToGrid:SetChecked(self.manager.settings.snapToGrid); |
261 |
|
Thurallor-7095 |
self.tab1.uiScale:SetValue(self.manager.settings.uiScale); |
262 |
|
Thurallor-7095 |
self.tab1.uiOpacity:SetValue(self.manager.settings.uiOpacity * 100); |
263 |
12 |
Thurallor-7095 |
end |
264 |
|
Thurallor-7095 |
|
265 |
|
Thurallor-7095 |
function OptionsPanel:RefreshDirectory() |
266 |
|
Thurallor-7095 |
if (not self:IsDisplayed() or (not self.tab2:IsInFront())) then |
267 |
|
Thurallor-7095 |
return self:ShowRefreshButton(); |
268 |
|
Thurallor-7095 |
end |
269 |
|
Thurallor-7095 |
|
270 |
|
Thurallor-7095 |
self.tab2:SetInteriorControl(self.tab2.inside); |
271 |
|
Thurallor-7095 |
self:Localize(); |
272 |
|
Thurallor-7095 |
|
273 |
|
Thurallor-7095 |
if (self.tree) then |
274 |
|
Thurallor-7095 |
self.tree:SetPosition(10,10); |
275 |
|
Thurallor-7095 |
self.tree:SetParent(nil); |
276 |
|
Thurallor-7095 |
end |
277 |
2 |
Thurallor-7095 |
|
278 |
12 |
Thurallor-7095 |
self.tree = self:AddTreeNode(nil, self.manager); |
279 |
|
Thurallor-7095 |
self.tree:SetParent(self.tab2.inside); |
280 |
|
Thurallor-7095 |
self.tree:SetTop(self.instructions.height); |
281 |
|
Thurallor-7095 |
self.tree.SizeChanged = function() |
282 |
|
Thurallor-7095 |
local newHeight = self.instructions.height + self.tree:GetHeight(); |
283 |
|
Thurallor-7095 |
newHeight = math.max(newHeight, self.tab1.inside:GetHeight()); |
284 |
|
Thurallor-7095 |
self.tab2.inside:SetHeight(newHeight); |
285 |
|
Thurallor-7095 |
self:SetHeight(newHeight + 40); |
286 |
2 |
Thurallor-7095 |
end |
287 |
12 |
Thurallor-7095 |
self.tree.SizeChanged(); |
288 |
|
Thurallor-7095 |
self.width = 0; |
289 |
|
Thurallor-7095 |
self:SizeChanged(); |
290 |
2 |
Thurallor-7095 |
end |
291 |
|
Thurallor-7095 |
|
292 |
12 |
Thurallor-7095 |
function OptionsPanel:SetHeight(height) |
293 |
|
Thurallor-7095 |
Turbine.UI.Control.SetHeight(self, height); |
294 |
|
Thurallor-7095 |
self.tabs:SetHeight(height); |
295 |
|
Thurallor-7095 |
end |
296 |
|
Thurallor-7095 |
|
297 |
2 |
Thurallor-7095 |
function OptionsPanel:SizeChanged() |
298 |
12 |
Thurallor-7095 |
if (self.skipSizeChanged > 0) then |
299 |
|
Thurallor-7095 |
self.skipSizeChanged = self.skipSizeChanged - 1; |
300 |
|
Thurallor-7095 |
return; |
301 |
|
Thurallor-7095 |
end |
302 |
2 |
Thurallor-7095 |
local width = self:GetWidth(); |
303 |
12 |
Thurallor-7095 |
if (self.width ~= width) then |
304 |
|
Thurallor-7095 |
self.width = width; |
305 |
|
Thurallor-7095 |
self.tabs:SetWidth(self.width); |
306 |
|
Thurallor-7095 |
self.tab2.inside:SetWidth(self.width - 20); |
307 |
|
Thurallor-7095 |
if (self.tree) then |
308 |
13 |
Thurallor-7095 |
self.instructions:SetWidth(self.width - 20); |
309 |
12 |
Thurallor-7095 |
self.tree:SetWidth(self.width - 20); |
310 |
|
Thurallor-7095 |
end |
311 |
2 |
Thurallor-7095 |
end |
312 |
|
Thurallor-7095 |
end |
313 |
|
Thurallor-7095 |
|
314 |
12 |
Thurallor-7095 |
function OptionsPanel:AddTreeNode(parentNode, object) |
315 |
|
Thurallor-7095 |
local newNode = Thurallor.UI.TreeControl(); |
316 |
2 |
Thurallor-7095 |
newNode.object = object; |
317 |
|
Thurallor-7095 |
|
318 |
12 |
Thurallor-7095 |
-- Add a text box for the name of the group or bar. |
319 |
|
Thurallor-7095 |
newNode.label = NodeLabel(newNode, object); |
320 |
|
Thurallor-7095 |
newNode:AddColumn(newNode.label, 1); |
321 |
|
Thurallor-7095 |
|
322 |
2 |
Thurallor-7095 |
-- Add the "Show" or "Hide" button. |
323 |
12 |
Thurallor-7095 |
newNode.showHideButton = ShowHideButton(newNode, object); |
324 |
|
Thurallor-7095 |
newNode:AddColumn(newNode.showHideButton, 0); |
325 |
|
Thurallor-7095 |
|
326 |
|
Thurallor-7095 |
if (parentNode) then |
327 |
|
Thurallor-7095 |
parentNode:AddChild(newNode); |
328 |
2 |
Thurallor-7095 |
end |
329 |
|
Thurallor-7095 |
|
330 |
17 |
Thurallor-7095 |
-- Add subnodes, if any, alphabetized |
331 |
12 |
Thurallor-7095 |
local childIDs = {}; |
332 |
2 |
Thurallor-7095 |
if (object:CanHaveChildren()) then |
333 |
12 |
Thurallor-7095 |
childIDs = object:GetChildIDs(); |
334 |
17 |
Thurallor-7095 |
table.sort(childIDs, function (a, b) return object:GetChild(a):GetName() < object:GetChild(b):GetName(); end); |
335 |
12 |
Thurallor-7095 |
for c = 1, #childIDs, 1 do |
336 |
|
Thurallor-7095 |
local childID = childIDs[c]; |
337 |
|
Thurallor-7095 |
local child = object:GetChild(childID); |
338 |
|
Thurallor-7095 |
self:AddTreeNode(newNode, child); |
339 |
2 |
Thurallor-7095 |
end |
340 |
|
Thurallor-7095 |
end |
341 |
46 |
Thurallor-7095 |
newNode:SetExpanded(not object.nodeCollapsed); |
342 |
2 |
Thurallor-7095 |
|
343 |
12 |
Thurallor-7095 |
-- Add mouse behaviors |
344 |
46 |
Thurallor-7095 |
newNode.IconClicked = function(sender, args) |
345 |
|
Thurallor-7095 |
object.nodeCollapsed = not newNode.expanded; |
346 |
|
Thurallor-7095 |
end |
347 |
12 |
Thurallor-7095 |
newNode.label.MouseClick = function(sender, args) |
348 |
2 |
Thurallor-7095 |
-- Right-click displays the settings menu. |
349 |
|
Thurallor-7095 |
if (args.Button == Turbine.UI.MouseButton.Right) then |
350 |
5 |
Thurallor-7095 |
sender.node.object:ShowSettingsMenu(true); |
351 |
2 |
Thurallor-7095 |
end |
352 |
|
Thurallor-7095 |
end |
353 |
12 |
Thurallor-7095 |
newNode.label.MouseDoubleClick = function(sender, args) |
354 |
2 |
Thurallor-7095 |
-- Left-double-click opens the caption editor. |
355 |
|
Thurallor-7095 |
if (args.Button == Turbine.UI.MouseButton.Left) then |
356 |
12 |
Thurallor-7095 |
sender.node.object:EditCaption(newNode.label); |
357 |
2 |
Thurallor-7095 |
end |
358 |
|
Thurallor-7095 |
end |
359 |
12 |
Thurallor-7095 |
newNode.label.MouseDown = function(sender, args) |
360 |
|
Thurallor-7095 |
if ((args.Button == Turbine.UI.MouseButton.Left) and (sender ~= self.tree.label)) then |
361 |
2 |
Thurallor-7095 |
sender.mouseDown = true; |
362 |
12 |
Thurallor-7095 |
sender.originalLeft, sender.originalTop = sender.node:GetParent():PointToScreen(sender.node:GetPosition()); |
363 |
2 |
Thurallor-7095 |
sender.originalMouseX, sender.originalMouseY = Turbine.UI.Display.GetMouseX(), Turbine.UI.Display.GetMouseY(); |
364 |
|
Thurallor-7095 |
end |
365 |
|
Thurallor-7095 |
end |
366 |
12 |
Thurallor-7095 |
newNode.label.MouseMove = function(sender) |
367 |
2 |
Thurallor-7095 |
if (sender.mouseDown) then |
368 |
12 |
Thurallor-7095 |
|
369 |
|
Thurallor-7095 |
-- Detach from tree |
370 |
|
Thurallor-7095 |
if (not sender.detached) then |
371 |
|
Thurallor-7095 |
sender.originalParentNode = sender.node:GetParentTreeControl(); |
372 |
|
Thurallor-7095 |
sender.originalChildNumber = sender.originalParentNode:RemoveChild(sender.node); |
373 |
|
Thurallor-7095 |
self.carrierWindow:SetVisible(true); |
374 |
|
Thurallor-7095 |
self.carrierWindow:SetSize(sender.node:GetSize()); |
375 |
|
Thurallor-7095 |
sender.node:SetParent(self.carrierWindow); |
376 |
|
Thurallor-7095 |
sender.node:SetPosition(0, 0); |
377 |
|
Thurallor-7095 |
self.carrierWindow:SetPosition(sender.originalLeft, sender.originalTop); |
378 |
|
Thurallor-7095 |
sender.node:SetColumnWidth(3, 0); |
379 |
|
Thurallor-7095 |
sender.detached = true; |
380 |
|
Thurallor-7095 |
end |
381 |
|
Thurallor-7095 |
|
382 |
2 |
Thurallor-7095 |
local newMouseX, newMouseY = Turbine.UI.Display.GetMouseX(), Turbine.UI.Display.GetMouseY(); |
383 |
|
Thurallor-7095 |
local deltaX, deltaY = newMouseX - sender.originalMouseX, newMouseY - sender.originalMouseY; |
384 |
|
Thurallor-7095 |
local left = sender.originalLeft + deltaX; |
385 |
|
Thurallor-7095 |
local top = sender.originalTop + deltaY; |
386 |
12 |
Thurallor-7095 |
self.carrierWindow:SetPosition(left, top); |
387 |
|
Thurallor-7095 |
if (sender.previousHighlight) then |
388 |
|
Thurallor-7095 |
sender.previousHighlight:SetBackColor(nil); |
389 |
|
Thurallor-7095 |
sender.previousHighlight = nil; |
390 |
2 |
Thurallor-7095 |
end |
391 |
|
Thurallor-7095 |
|
392 |
12 |
Thurallor-7095 |
-- Figure out if we're over another textBox |
393 |
|
Thurallor-7095 |
local hoveringOverNode, target = self.tree:IsMouseInside(); |
394 |
|
Thurallor-7095 |
if (hoveringOverNode) then |
395 |
|
Thurallor-7095 |
local source = sender.node; |
396 |
|
Thurallor-7095 |
if ( |
397 |
|
Thurallor-7095 |
(target.object:CanHaveChildren()) and |
398 |
|
Thurallor-7095 |
(target ~= source) and |
399 |
|
Thurallor-7095 |
(not source.object:Contains(target.object)) and |
400 |
|
Thurallor-7095 |
(source.object.parent ~= target.object) |
401 |
|
Thurallor-7095 |
) then |
402 |
|
Thurallor-7095 |
sender.targetObject = target.object; |
403 |
2 |
Thurallor-7095 |
--Puts("target object is " .. object.settings.type .. " " .. Serialize(object.settings.caption.text)); |
404 |
12 |
Thurallor-7095 |
target.label:SetBackColor(Turbine.UI.Color(1, 0.25, 0.25, 0.75)); |
405 |
|
Thurallor-7095 |
sender.previousHighlight = target.label; |
406 |
|
Thurallor-7095 |
return; |
407 |
2 |
Thurallor-7095 |
end |
408 |
|
Thurallor-7095 |
end |
409 |
12 |
Thurallor-7095 |
sender.targetObject = nil; |
410 |
2 |
Thurallor-7095 |
end |
411 |
|
Thurallor-7095 |
end |
412 |
12 |
Thurallor-7095 |
newNode.label.MouseUp = function(sender, args) |
413 |
16 |
Thurallor-7095 |
if (args.Button == Turbine.UI.MouseButton.Left) then |
414 |
2 |
Thurallor-7095 |
sender.mouseDown = false; |
415 |
16 |
Thurallor-7095 |
if (sender.detached) then |
416 |
|
Thurallor-7095 |
local newMouseX, newMouseY = Turbine.UI.Display.GetMouseX(), Turbine.UI.Display.GetMouseY(); |
417 |
|
Thurallor-7095 |
local deltaX, deltaY = newMouseX - sender.originalMouseX, newMouseY - sender.originalMouseY; |
418 |
2 |
Thurallor-7095 |
|
419 |
16 |
Thurallor-7095 |
-- Do the object transfer |
420 |
|
Thurallor-7095 |
sender.node:SetParent(nil); |
421 |
|
Thurallor-7095 |
if (sender.targetObject) then |
422 |
|
Thurallor-7095 |
local sourceObject = sender.node.object; |
423 |
|
Thurallor-7095 |
if (sourceObject.settings.type == "bar") then |
424 |
|
Thurallor-7095 |
self.manager:TransferBar(sourceObject.objectID, sourceObject.parent, sender.targetObject); |
425 |
|
Thurallor-7095 |
else |
426 |
|
Thurallor-7095 |
self.manager:TransferGroup(sourceObject.objectID, sourceObject.parent, sender.targetObject); |
427 |
|
Thurallor-7095 |
end |
428 |
2 |
Thurallor-7095 |
else |
429 |
16 |
Thurallor-7095 |
-- Reattach to tree |
430 |
|
Thurallor-7095 |
self.carrierWindow:SetVisible(false); |
431 |
|
Thurallor-7095 |
sender.node:SetColumnWidth(3, ShowHideButton.buttonWidth); |
432 |
|
Thurallor-7095 |
sender.originalParentNode:InsertChild(sender.node, sender.originalChildNumber); |
433 |
|
Thurallor-7095 |
sender.detached = false; |
434 |
2 |
Thurallor-7095 |
end |
435 |
|
Thurallor-7095 |
end |
436 |
|
Thurallor-7095 |
end |
437 |
|
Thurallor-7095 |
end |
438 |
|
Thurallor-7095 |
|
439 |
12 |
Thurallor-7095 |
return newNode; |
440 |
2 |
Thurallor-7095 |
end |