forked from phuein/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.lua
More file actions
461 lines (421 loc) · 15.5 KB
/
Copy pathSettings.lua
File metadata and controls
461 lines (421 loc) · 15.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
function CreateNBUISettings()
local LAM = LibStub("LibAddonMenu-2.0")
local panelData = {
type = "panel",
name = "Notebook 2018",
displayName = ZO_HIGHLIGHT_TEXT:Colorize(GetString(SI_NBUI_ADDONOPTIONS_NAME)),
author = GetString(SI_NBUI_AUTHOR),
registerForRefresh = true,
registerForDefaults = true,
-- chat command to open settings window
slashCommand = "/nbs",
-- resets NBUI position, when reset to defaults is pressed
resetFunc = function()
NBUI.NB1MainWindow:ClearAnchors()
NBUI.NB1MainWindow:SetAnchor (CENTER, GuiRoot, CENTER, 0, -48)
_,a,_,b,x,y = NBUI.NB1MainWindow:GetAnchor()
NBUI.db.NB1_Anchor = {["a"]=a, ["b"]=b, ["x"]=x, ["y"]=y}
end
}
LAM:RegisterAddonPanel("NBUIOptions", panelData)
local optionsData = {}
-- Book category. --
table.insert(optionsData, {
type = "header",
name = ZO_HIGHLIGHT_TEXT:Colorize(GetString(SI_NBUI_HEADER_BOOK)),
})
-- Show book title.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_SHOWTITLE_NAME),
tooltip = GetString(SI_NBUI_SHOWTITLE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_ShowTitle end,
setFunc = function(value)
NBUI.db.NB1_ShowTitle = value
NBUI.NB1LeftPage_Title:SetHidden(not NBUI.db.NB1_ShowTitle)
NBUI.NB1LeftPage_Separator:SetHidden(not NBUI.db.NB1_ShowTitle)
NBUI.NB1Information_Button:SetHidden(not NBUI.db.NB1_ShowTitle)
if (NBUI.db.NB1_ShowTitle) then
NBUI.NB1LeftPage_Backdrop:SetDimensions(420, 645)
else
NBUI.NB1LeftPage_Backdrop:SetDimensions(420, 690)
end
end,
default = NBUI.settings.NB1_ShowTitle,
})
-- Title label.
table.insert(optionsData, {
type = "editbox",
name = GetString(SI_NBUI_TITLE_NAME),
tooltip = GetString(SI_NBUI_TITLE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_Title end,
setFunc = function(value)
NBUI.db.NB1_Title = value
NBUI.NB1LeftPage_Title:SetText(NBUI.db.NB1_Title)
end,
default = NBUI.settings.NB1_Title,
})
-- Notebook saves as account-wide.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_ACCOUNTWIDE_NAME),
tooltip = GetString(SI_NBUI_ACCOUNTWIDE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_AccountWide end,
setFunc = function(value)
local confirmDialog = {
title = {text = GetString(SI_NBUI_ACCOUNTWIDE_NAME)},
mainText = {text = GetString(SI_NBUI_ACCOUNTWIDE_MAINTEXT)},
buttons = {
[1]={
text = GetString(SI_NBUI_YES_LABEL), callback = function()
NBUI.dbCharacter.NB1_AccountWide = value
ReloadUI("ingame")
end
},
[2]={
text = GetString(SI_NBUI_NO_LABEL), callback = function()
zo_callLater(function() CALLBACK_MANAGER:FireCallbacks("LAM-RefreshPanel", LAM.currentAddonPanel) end, 100)
end
}
}
}
ZO_Dialogs_RegisterCustomDialog("NBUI_NB1CONFIRMDIALOG", confirmDialog)
ZO_Dialogs_ShowDialog("NBUI_NB1CONFIRMDIALOG")
end,
default = NBUI.db.NB1_AccountWide,
warning = "Will need to reload the UI!",
})
-- Overwrite the Account-Wide Notebook with the current character's pages.
-- NOTE: Display only in CharacterWide mode.
if not NBUI.db.NB1_AccountWide then
table.insert(optionsData, {
type = "button",
name = GetString(SI_NBUI_ACCOUNTDELETE),
tooltip = GetString(SI_NBUI_ACCOUNTDELETE_TOOLTIP),
-- disabled = not NBUI.db.NB1_AccountWide,
func = function(value)
local confirmDialog = {
title = {text = GetString(SI_NBUI_ACCOUNTWIDE_NAME)},
mainText = {text = GetString(SI_NBUI_ACCOUNTWIDE_MAINTEXT)},
buttons = {
[1]={
text = GetString(SI_NBUI_YES_LABEL), callback = function()
_G["NBUISVDBACCT"]["Default"][GetDisplayName()]["$AccountWide"] =
ZO_DeepTableCopy(_G["NBUISVDB"]["Default"][GetDisplayName()][GetUnitName("player")])
ReloadUI("ingame")
end
},
[2]={text = GetString(SI_NBUI_NO_LABEL)}
}
}
ZO_Dialogs_RegisterCustomDialog("NBUI_NB1CONFIRMDIALOG", confirmDialog)
ZO_Dialogs_ShowDialog("NBUI_NB1CONFIRMDIALOG")
end,
warning = "Will need to reload the UI!",
})
end
-- Default new page title.
table.insert(optionsData, {
type = "editbox",
name = GetString(SI_NBUI_NEWPAGETITLE_NAME),
tooltip = GetString(SI_NBUI_NEWPAGETITLE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_NewPageTitle end,
setFunc = function(value)
NBUI.db.NB1_NewPageTitle = value
end,
default = NBUI.settings.NB1_NewPageTitle,
})
-- Overwrite the Accountwide or Character Notebook of
-- another account or character on this machine (PC) from current active Notebook.
-- TODO: Languages implementation.
local overwriteAccount, overwriteCharacter
table.insert(optionsData, {
type = "submenu",
name = ZO_HIGHLIGHT_TEXT:Colorize("Overwrite Other Account or Character"),
controls = {
[1] = {
type = "editbox",
name = "Account Name For Overwrite",
tooltip = "The account name that will have its Account-Wide Notebook overwritten.",
getFunc = function() return "" end,
setFunc = function(value)
overwriteAccount = value
end,
width = "half",
},
[2] = {
type = "button",
name = "Overwrite Account",
tooltip = "This will create or overwrite the Account-Wide Notebook of another " ..
"account on this PC, from the current active Notebook.",
-- disabled = not NBUI.db.NB1_AccountWide,
func = function(value)
-- Must have an account name to overwrite.
if overwriteAccount == "" then return end
-- Accounts must start with an @.
local c = string.sub(overwriteAccount, 1, 1)
if c ~= "@" then
overwriteAccount = "@" .. overwriteAccount
end
-- Ignore if same as current account.
if overwriteAccount == GetDisplayName() then return end
local confirmDialog = {
title = {text = "Overwrite Other Account"},
mainText = {text = "Continue?"},
buttons = {
[1]={
text = GetString(SI_NBUI_YES_LABEL), callback = function()
-- Use active Notebook.
local t
if NBUI.db.NB1_AccountWide then
t = _G["NBUISVDBACCT"]["Default"][GetDisplayName()]["$AccountWide"]
else
t = _G["NBUISVDB"]["Default"][GetDisplayName()][GetUnitName("player")]
end
-- Create tables. Will only overwrite Account-Wide Notebook, but not individual character.
if not _G["NBUISVDBACCT"]["Default"][overwriteAccount] then
_G["NBUISVDBACCT"]["Default"][overwriteAccount] = {}
end
_G["NBUISVDBACCT"]["Default"][overwriteAccount]["$AccountWide"] = ZO_DeepTableCopy(t)
ReloadUI("ingame")
end
},
[2]={text = GetString(SI_NBUI_NO_LABEL)}
}
}
ZO_Dialogs_RegisterCustomDialog("NBUI_NB1CONFIRMDIALOG", confirmDialog)
ZO_Dialogs_ShowDialog("NBUI_NB1CONFIRMDIALOG")
end,
warning = "Will need to reload the UI!",
},
[3] = {
type = "editbox",
name = "Character Name For Overwrite",
tooltip = "The character name that will have its Character-Wide Notebook overwritten.",
getFunc = function() return "" end,
setFunc = function(value)
overwriteCharacter = value
end,
width = "half",
},
[4] = {
type = "button",
name = "Overwrite Character",
tooltip = "This will create or overwrite the Character-Wide Notebook of another " ..
"character on this PC, from the current active Notebook.",
-- disabled = not NBUI.db.NB1_AccountWide,
func = function(value)
-- Must have an account name and character name to overwrite.
if overwriteAccount == "" then return end
if overwriteCharacter == "" then return end
-- Accounts must start with an @.
local c = string.sub(overwriteAccount, 1, 1)
if c ~= "@" then
overwriteAccount = "@" .. overwriteAccount
end
-- Ignore if same character and account and current.
-- Allow overwriting between characters of the same account.
if overwriteAccount == GetDisplayName() and overwriteCharacter == GetUnitName("player") then return end
local confirmDialog = {
title = {text = "Overwrite Other Character"},
mainText = {text = "Continue?"},
buttons = {
[1]={
text = GetString(SI_NBUI_YES_LABEL), callback = function()
-- Use active Notebook.
local t
if NBUI.db.NB1_AccountWide then
t = _G["NBUISVDBACCT"]["Default"][GetDisplayName()]["$AccountWide"]
else
t = _G["NBUISVDB"]["Default"][GetDisplayName()][GetUnitName("player")]
end
-- Create tables. Do not overwrite whole table, only character's table.
if not _G["NBUISVDB"]["Default"][overwriteAccount] then
_G["NBUISVDB"]["Default"][overwriteAccount] = {}
end
_G["NBUISVDB"]["Default"][overwriteAccount][overwriteCharacter] = ZO_DeepTableCopy(t)
ReloadUI("ingame")
end
},
[2]={text = GetString(SI_NBUI_NO_LABEL)}
}
}
ZO_Dialogs_RegisterCustomDialog("NBUI_NB1CONFIRMDIALOG", confirmDialog)
ZO_Dialogs_ShowDialog("NBUI_NB1CONFIRMDIALOG")
end,
warning = "Will need to reload the UI!",
},
},
})
-- Colors category. --
table.insert(optionsData, {
type = "header",
name = ZO_HIGHLIGHT_TEXT:Colorize(GetString(SI_NBUI_HEADER_COLORS)),
})
-- Change book color.
table.insert(optionsData, {
type = "colorpicker",
name = GetString(SI_NBUI_COLOR_NAME),
tooltip = GetString(SI_NBUI_COLOR_TOOLTIP),
getFunc = function() return unpack(NBUI.db.NB1_BookColor) end,
setFunc = function(r, g, b, a)
NBUI.db.NB1_BookColor = {r, g, b, a}
NBUI.NB1MainWindow_Cover:SetColor(r, g, b, a)
NBUI.NB1MaxChatWin_ButtonTexture:SetColor(r, g, b, a)
NBUI.NB1MinChatWin_ButtonTexture:SetColor(r, g, b, a)
end,
default = { r = NBUI.settings.NB1_BookColor[1], g = NBUI.settings.NB1_BookColor[2], b = NBUI.settings.NB1_BookColor[3], a = NBUI.settings.NB1_BookColor[4]},
})
-- Text color. R, G, B, A. Between 0 to 1.
table.insert(optionsData, {
type = "colorpicker",
name = GetString(SI_NBUI_TEXTCOLOR_NAME),
tooltip = GetString(SI_NBUI_TEXTCOLOR_TOOLTIP),
getFunc = function() return unpack(NBUI.db.NB1_TextColor) end,
setFunc = function(r, g, b, a)
NBUI.db.NB1_TextColor = {r, g, b, a}
NBUI.NB1LeftPage_Title:SetColor(unpack(NBUI.db.NB1_TextColor))
NBUI.NB1LeftPage_Separator:SetColor(unpack(NBUI.db.NB1_TextColor))
NBUI.NB1RightPage_Title:SetColor(unpack(NBUI.db.NB1_TextColor))
NBUI.NB1RightPage_Contents:SetColor(unpack(NBUI.db.NB1_TextColor))
NBUI.NB1RightPage_ContentsLabel:SetColor(unpack(NBUI.db.NB1_TextColor))
Populate_NB1_ScrollList()
end,
})
-- Selection color. R, G, B, A. Between 0 to 1.
table.insert(optionsData, {
type = "colorpicker",
name = GetString(SI_NBUI_SELECTCOLOR_NAME),
tooltip = GetString(SI_NBUI_SELECTCOLOR_TOOLTIP),
getFunc = function() return unpack(NBUI.db.NB1_SelectionColor) end,
setFunc = function(r, g, b, a)
NBUI.db.NB1_SelectionColor = {r, g, b, a}
NBUI.NB1RightPage_Contents:SetSelectionColor(unpack(NBUI.db.NB1_SelectionColor))
end,
})
-- Interactive category. --
table.insert(optionsData, {
type = "header",
name = ZO_HIGHLIGHT_TEXT:Colorize(GetString(SI_NBUI_HEADER_INTERACTIVE)),
})
-- Display dialog.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_DIALOG),
tooltip = GetString(SI_NBUI_DIALOG_TOOLTIP),
getFunc = function() return NBUI.db.NB1_ShowDialog end,
setFunc = function(value)
NBUI.db.NB1_ShowDialog = value
end,
default = NBUI.settings.NB1_ShowDialog,
})
-- Lock book position.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_LOCK_NAME),
tooltip = GetString(SI_NBUI_LOCK_TOOLTIP),
getFunc = function() return NBUI.db.NB1_Locked end,
setFunc = function(value)
NBUI.db.NB1_Locked = value
NBUI.NB1MainWindow:SetMovable(not NBUI.db.NB1_Locked)
end,
default = NBUI.settings.NB1_Locked,
})
-- Toggle chat button.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_BUTTON_NAME),
tooltip = GetString(SI_NBUI_BUTTON_TOOLTIP),
getFunc = function() return NBUI.db.NB1_ChatButton end,
setFunc = function(value)
NBUI.db.NB1_ChatButton = value
NBUI.NB1MaxChatWin_Button:SetHidden(not NBUI.db.NB1_ChatButton)
NBUI.NB1MaxChatWin_ButtonTexture:SetHidden(not NBUI.db.NB1_ChatButton)
NBUI.NB1MinChatWin_Button:SetHidden(not NBUI.db.NB1_ChatButton)
NBUI.NB1MinChatWin_ButtonTexture:SetHidden(not NBUI.db.NB1_ChatButton)
end,
default = NBUI.settings.NB1_ChatButton,
})
-- Switch to Edit Mode on mouse hover over page.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_EDITMODE_HOVER_NAME),
tooltip = GetString(SI_NBUI_EDITMODE_HOVER_TOOLTIP),
getFunc = function() return NBUI.db.NB1_EditModeHover end,
setFunc = function(v) NBUI.db.NB1_EditModeHover = v end,
})
-- Switch to Edit Mode on mouse click on page.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_EDITMODE_CLICK_NAME),
tooltip = GetString(SI_NBUI_EDITMODE_CLICK_TOOLTIP),
getFunc = function() return NBUI.db.NB1_EditModeClick end,
setFunc = function(v) NBUI.db.NB1_EditModeClick = v end,
})
-- Leave Edit Mode on page lose focus.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_LEAVEEDITMODE_FOCUS_NAME),
tooltip = GetString(SI_NBUI_LEAVEEDITMODE_FOCUS_TOOLTIP),
getFunc = function() return NBUI.db.NB1_LeaveEditModeOnFocus end,
setFunc = function(v) NBUI.db.NB1_LeaveEditModeOnFocus = v end,
})
-- Leave Edit Mode on mouse exit page.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_LEAVEEDITMODE_EXIT_NAME),
tooltip = GetString(SI_NBUI_LEAVEEDITMODE_EXIT_TOOLTIP),
getFunc = function() return NBUI.db.NB1_LeaveEditModeOnExit end,
setFunc = function(v) NBUI.db.NB1_LeaveEditModeOnExit = v end,
})
-- Emote /read when opening the Notebook.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_EMOTEREAD_NAME),
tooltip = GetString(SI_NBUI_EMOTEREAD_TOOLTIP),
getFunc = function() return NBUI.db.NB1_EmoteRead end,
setFunc = function(v) NBUI.db.NB1_EmoteRead = v end,
})
-- Emote /idle after closing the Notebook.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_EMOTEIDLE_NAME),
tooltip = GetString(SI_NBUI_EMOTEIDLE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_EmoteIdle end,
setFunc = function(v) NBUI.db.NB1_EmoteIdle = v end,
})
-- Select line by triple-clicking.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_SELECTLINE_NAME),
tooltip = GetString(SI_NBUI_SELECTLINE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_SelectLine end,
setFunc = function(v) NBUI.db.NB1_SelectLine = v end,
})
-- Double-clicking selects whole page text.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_DBLCLICKPAGE_NAME),
tooltip = GetString(SI_NBUI_DBLCLICKPAGE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_DoubleClickSelectPage end,
setFunc = function(v) NBUI.db.NB1_DoubleClickSelectPage = v end,
})
-- Display Text-Formatting mode over Editbox.
table.insert(optionsData, {
type = "checkbox",
name = GetString(SI_NBUI_FORMATTEDMODE_NAME),
tooltip = GetString(SI_NBUI_FORMATTEDMODE_TOOLTIP),
getFunc = function() return NBUI.db.NB1_FormattedMode end,
setFunc = function(v)
NBUI.db.NB1_FormattedMode = v
if v then
NBUI.NB1RightPage_ContentsLabel:SetHidden(false)
NBUI.NB1RightPage_Contents:SetHidden(true)
else
NBUI.NB1RightPage_ContentsLabel:SetHidden(true)
NBUI.NB1RightPage_Contents:SetHidden(false)
end
end,
})
LAM:RegisterOptionControls("NBUIOptions", optionsData)
end