-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathInitialization.lua
More file actions
281 lines (226 loc) · 8.38 KB
/
Initialization.lua
File metadata and controls
281 lines (226 loc) · 8.38 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
local VERSION_TEXT = "v1.0.1";
local VERSION_DATE = 1772630000;
local addonName, addon = ...
local L = {}; --Locale
local API = {}; --Custom APIs used by this addon
local DB;
addon.L = L;
addon.API = API;
addon.VERSION_TEXT = VERSION_TEXT;
local DefaultValues = {
Theme = 1,
FrameSize = 2,
FontSizeBase = 1,
FontText = "default",
FontNumber = "default",
FrameOrientation = 2, --1:Left 2:Right(Default)
HideUI = true,
ShowChatWindow = true,
HideOutlineSparkles = true,
HideUnitNames = false,
ShowCopyTextButton = false,
ShowNPCNameOnPage = false,
MarkHighestSellPrice = false,
QuestTypeText = false,
SimplifyCurrencyReward = false,
UseRoleplayName = false,
UseBlizzardTooltip = false,
CameraMovement = 1, --0:OFF 1:Zoom-In 2:Horizontal
CameraChangeFov = true,
CameraMovement1MaintainPosition = false,
CameraMovement2MaintainPosition = true,
CameraMovementMountedCamera = true,
CameraMovementDisableInstance = false,
CameraZoomMultiplier = 1, --The smaller the further
InputDevice = 1, --1:K&M 2:XBOX 3.PS 4.Mobile
UseCustomBindings = false,
PrimaryControlKey = 1, --1: Space 2:Interact Key
ScrollDownThenAcceptQuest = false,
EscapeToDeclineQuest = false,
RightClickToCloseUI = true,
CycleRewardHotkeyEnabled = false, --Press Tab to cycle through choosable rewards
DisableHotkeyForTeleport = false, --Disable gossip hotkey when select teleportation
GamePadClickFirstObject = false, --If true, when starting a new interaction, pressing PAD1 will click the first object
EmulateSwipe = true,
MobileDeviceMode = false,
WidgetManagerDummy = true, --Doesn't control anything, used as a trigger
AutoQuestPopup = true,
QuestItemDisplay = false,
QuestItemDisplayHideSeen = false,
QuestItemDisplayDynamicFrameStrata = false,
QuickSlotQuestReward = false,
AutoCompleteQuest = false,
QuickSlotUseHotkey = true,
AutoSelectGossip = false,
ForceGossip = false,
ForceGossipSkipGameObject = false,
ShowDialogHint = true,
DisableDUIInInstance = false,
NameplateDialogEnabled = false, --Experimental. Not in the settings
DisableUIMotion = false,
TTSEnabled = false,
TTSUseHotkey = true, --Default key R
TTSAutoPlay = false,
TTSSkipRecent = false, --Skip recently read texts
TTSAutoPlayDelay = false, --Add a delay before starting auto play in case the NPC is speaking
TTSAutoStop = true, --Stop when leaving
TTSStopOnNew = true, --Stop when reading new quest
TTSVoiceMale = 0, --0: System default
TTSVoiceFemale = 0,
TTSUseNarrator = false,
TTSVoiceNarrator = 0,
TTSVolume = 10,
TTSRate = 0,
TTSContentSpeaker = false,
TTSContentQuestTitle = true,
TTSContentObjective = false,
--Book Settings
BookUIEnabled = true,
BookUISize = 1,
BookKeepUIOpen = false,
BookShowLocation = false,
BookUIItemDescription = false, --Show source item's description on top of the UI
BookDarkenScreen = true,
BookTTSVoice = 0,
BookTTSClickToRead = true,
--Not shown in the Settings. Accessible by other means
TooltipShowItemComparison = false, --Tooltip
TTSReadTranslation = false, --Read original text or translation. Controlled by TTSButton modifier key
MuteTargetLostSound = true, --Mute target lost sound caused by hiding UI. Accessed through command only: /run DialogueUI_DB.MuteTargetLostSound = false
--WidgetManagerPosition = {x, y};
--QuestItemDisplayPosition = {x, y};
--Deprecated:
--WarbandCompletedQuest = true, --Always ON
};
local InheritExistingValues = {
--Newly added systems may copy the the dbValue of similar system: BookUI/DialogueUI frame size, Book/Dialogue voice
--If the new dbValue doesn't exisit and the existing dbValue isn't the default value, use the new default value
{"BookUISize", "FrameSize"},
{"BookTTSVoice", "TTSVoiceNarrator"},
{"BookTTSVoice", "TTSVoiceMale"},
{"BookTTSVoice", "TTSVoiceFemale"},
};
local TutorialFlags = {
--Saved in the DB, prefix: Tutorial_
--e.g. Tutorial_OpenSettings = true
"OpenSettings",
"WarbandCompletedQuest",
};
local function GetDBValue(dbKey)
return DB[dbKey]
end
addon.GetDBValue = GetDBValue;
local function SetDBValue(dbKey, value, userInput)
DB[dbKey] = value;
addon.CallbackRegistry:Trigger("SettingChanged."..dbKey, value, userInput);
end
addon.SetDBValue = SetDBValue;
local function LoadTutorials()
--Tutorial Flags (nil means haven't shown)
for _, flag in pairs(TutorialFlags) do
local dbKey = "Tutorial_"..flag;
if DB[dbKey] == nil then
addon.CallbackRegistry:Trigger("Tutorial."..flag);
end
end
end
local function LoadDatabase()
DialogueUI_DB = DialogueUI_DB or {};
DB = DialogueUI_DB;
DialogueUI_Saves = DialogueUI_Saves or {};
local type = type;
for _, v in ipairs(InheritExistingValues) do
if DB[v[1]] == nil then
if DB[v[2]] ~= nil and DB[v[2]] ~= DefaultValues[v[2]] then
DB[v[1]] = DB[v[2]];
end
end
end
for dbKey, defaultValue in pairs(DefaultValues) do
--Some settings are inter-connected so we load all values first
if DB[dbKey] == nil or type(DB[dbKey]) ~= type(defaultValue) then
DB[dbKey] = defaultValue;
end
end
for dbKey, defaultValue in pairs(DefaultValues) do
SetDBValue(dbKey, DB[dbKey]);
end
if not DB.installTime or type(DB.installTime) ~= "number" then
DB.installTime = VERSION_DATE;
end
DefaultValues = nil;
InheritExistingValues = nil;
LoadTutorials();
addon.CallbackRegistry:Trigger("ADDON_LOADED", DB);
end
local function SetTutorialRead(tutorialFlag)
local dbKey = "Tutorial_"..tutorialFlag;
DB[dbKey] = true;
end
addon.SetTutorialRead = SetTutorialRead;
local EL = CreateFrame("Frame");
EL:RegisterEvent("ADDON_LOADED");
EL:RegisterEvent("PLAYER_ENTERING_WORLD");
EL:RegisterEvent("LOADING_SCREEN_DISABLED");
EL:SetScript("OnEvent", function(self, event, ...)
if event == "ADDON_LOADED" then
local name = ...
if name == addonName then
self:UnregisterEvent(event);
LoadDatabase();
end
elseif event == "PLAYER_ENTERING_WORLD" then
--Keybindings are loaded after this
self:UnregisterEvent(event);
local dbKey = "PrimaryControlKey";
SetDBValue(dbKey, DB[dbKey]);
addon.CallbackRegistry:Trigger("PLAYER_ENTERING_WORLD");
elseif event == "LOADING_SCREEN_DISABLED" then
self:UnregisterEvent(event);
addon.CallbackRegistry:Trigger("InitialLoadingComplete");
end
end);
do
local currentToCVersion = select(4, GetBuildInfo());
if not currentToCVersion then
print("API Changed: GetBuildInfo()")
currentToCVersion = 999999;
end
currentToCVersion = tonumber(currentToCVersion);
local function IsToCVersionEqualOrNewerThan(targetVersion)
return currentToCVersion >= targetVersion
end
addon.IsToCVersionEqualOrNewerThan = IsToCVersionEqualOrNewerThan;
addon.IS_CLASSIC = not IsToCVersionEqualOrNewerThan(100000);
addon.IS_CATA = currentToCVersion >= 40400 and currentToCVersion < 50000;
addon.IS_MIDNIGHT = currentToCVersion >= 120000;
addon.IS_TBC = C_AddOns.GetAddOnMetadata(addonName, "X-Expansion") == "TBC";
end
local function GetDBBool(dbKey)
if DB then
return DB[dbKey] == true
end
end
addon.GetDBBool = GetDBBool;
local function FlipDBBool(dbKey, userInput)
if DB then
SetDBValue(dbKey, not GetDBBool(dbKey), userInput)
end
end
addon.FlipDBBool = FlipDBBool;
local function IsDBValue(dbKey, value)
if DB then
return DB[dbKey] == value
end
end
addon.IsDBValue = IsDBValue;
local function ResetTutorials()
for _, flag in pairs(TutorialFlags) do
local dbKey = "Tutorial_"..flag;
DB[dbKey] = nil;
end
end
addon.ResetTutorials = ResetTutorials;
do
DialogueUIAPI = {};
end