-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeveloperSuiteShared.lua
223 lines (195 loc) · 5.97 KB
/
DeveloperSuiteShared.lua
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
-- Developer Suite
-- The MIT License © Arthur Corenzan
local NAMESPACE = "DeveloperSuite"
local VERSION = "Version 0.3.0 (Jul 16 2017)"
--
--
--
function DeveloperSuite_TopLevelControl_Restore(self)
if not (self.savedVars.offsetX == 0 and self.savedVars.offsetY == 0) then
self.control:ClearAnchors()
self.control:SetAnchor(TOPLEFT, nil, TOPLEFT, self.savedVars.offsetX, self.savedVars.offsetY)
end
self.control:SetDimensions(self.savedVars.width, self.savedVars.height)
self.control:SetHidden(self.savedVars.isHidden)
end
function DeveloperSuite_TopLevelControl_Initialize(self, control, savedVars)
self.control = control
self.savedVars = savedVars
local function onShow()
self.savedVars.isHidden = false
end
self.control:SetHandler("OnShow", onShow)
local function onHide()
self.savedVars.isHidden = true
end
self.control:SetHandler("OnHide", onHide)
local function onMoveStop()
self.savedVars.offsetX = self.control:GetLeft()
self.savedVars.offsetY = self.control:GetTop()
end
self.control:SetHandler("OnMoveStop", onMoveStop)
local function onResizeStop()
self.savedVars.width = self.control:GetWidth()
self.savedVars.height = self.control:GetHeight()
if self.list then
ZO_ScrollList_SetHeight(self.list, self.list:GetHeight())
ZO_ScrollList_Commit(self.list)
end
end
self.control:SetHandler("OnResizeStop", onResizeStop)
DeveloperSuite_TopLevelControl_Restore(self)
end
function DeveloperSuite_TopLevelControl_Show(control)
control:SetHidden(false)
SCENE_MANAGER:SetInUIMode(true)
end
function DeveloperSuite_TopLevelControl_Hide(control)
control:SetHidden(true)
end
function DeveloperSuite_TopLevelControl_Toggle(control, editBox)
if control:IsHidden() then
DeveloperSuite_TopLevelControl_Show(control)
if editBox then
editBox:TakeFocus()
end
else
if editBox then
if editBox:HasFocus() then
editBox:LoseFocus()
DeveloperSuite_TopLevelControl_Hide(control)
else
DeveloperSuite_TopLevelControl_Show(control)
editBox:TakeFocus()
end
else
DeveloperSuite_TopLevelControl_Hide(self.control)
end
end
end
--
--
--
function DeveloperSuite_Binding_Reload()
SLASH_COMMANDS["/reloadui"]()
end
function DeveloperSuite_Binding_Inspector()
DEVELOPER_SUITE_INSPECTOR:Inspect(moc())
end
function DeveloperSuite_Binding_Library()
DEVELOPER_SUITE_LIBRARY:Toggle(true)
end
function DeveloperSuite_Binding_Explorer()
DEVELOPER_SUITE_EXPLORER:Toggle(true)
end
function DeveloperSuite_Binding_Console()
DEVELOPER_SUITE_CONSOLE:Toggle(true)
end
--
--
--
ZO_CreateStringId("SI_DEVELOPER_SUITE_VERSION", VERSION)
ZO_CreateStringId("SI_BINDING_NAME_DEVELOPER_SUITE_LIBRARY", "Toggle Library")
ZO_CreateStringId("SI_BINDING_NAME_DEVELOPER_SUITE_EXPLORER", "Toggle Explorer")
ZO_CreateStringId("SI_BINDING_NAME_DEVELOPER_SUITE_CONSOLE", "Toggle Console")
ZO_CreateStringId("SI_BINDING_NAME_DEVELOPER_SUITE_RELOADUI", "Reload Interface")
ZO_CreateStringId("SI_BINDING_NAME_DEVELOPER_SUITE_INSPECTOR", "Inspect Control")
--
--
--
local defaultSavedVars =
{
["about"] =
{
["isHidden"] = false,
["width"] = 360,
["height"] = 160,
["offsetX"] = 0,
["offsetY"] = 0,
},
["console"] =
{
["isHidden"] = true,
["width"] = 520,
["height"] = 320,
["offsetX"] = 0,
["offsetY"] = 0,
["output"] = "",
["history"] = {},
},
["explorer"] =
{
["isHidden"] = true,
["width"] = 640,
["height"] = 320,
["offsetX"] = 0,
["offsetY"] = 0,
["search"] =
{
["query"] = "",
["types"] =
{
["function"] = true,
["table"] = true,
["userdata"] = true,
["number"] = true,
["string"] = true,
["boolean"] = true,
}
}
},
["library"] =
{
["isHidden"] = true,
["width"] = 400,
["height"] = 640,
["offsetX"] = 0,
["offsetY"] = 0,
["search"] =
{
["query"] = "",
["type"] = "texture"
}
},
["inspector"] =
{
["isHidden"] = true,
["width"] = 100,
["height"] = 100,
["offsetX"] = 0,
["offsetY"] = 0,
},
}
local function OnAddOnLoaded(event, addOnName)
if (addOnName == NAMESPACE) then
EVENT_MANAGER:UnregisterForEvent(NAMESPACE, EVENT_ADD_ON_LOADED)
local savedVars = ZO_SavedVars:NewAccountWide("DeveloperSuite_SavedVars", 1, nil, defaultSavedVars)
do
local mt = getmetatable(savedVars)
local __newindex = mt.__newindex
function mt.__newindex(self, key, value)
CALLBACK_MANAGER:FireCallbacks(NAMESPACE.."_OnSavedVarChanged", key, value, self[key])
__newindex(self, key, value)
end
end
CALLBACK_MANAGER:FireCallbacks(NAMESPACE.."_OnAddOnLoaded", savedVars)
-- Free the chat!
-- CHAT_SYSTEM:SetContainerExtents(
-- CHAT_SYSTEM.minContainerWidth,
-- GuiRoot:GetWidth(),
-- CHAT_SYSTEM.minContainerHeight,
-- GuiRoot:GetHeight()
-- )
-- Shortcut for /scritp d(...)
SLASH_COMMANDS["/d"] = function(src)
SLASH_COMMANDS["/script"](string.format("d(%s)", src))
end
-- Warning for missing TorchBug
-- if (SLASH_COMMANDS["/tbug"] == nil) then
-- SLASH_COMMANDS["/tbug"] = function()
-- d("TorchBug is required for some features to work properly. Go get it at esoui.com.")
-- end
-- end
end
end
EVENT_MANAGER:RegisterForEvent(NAMESPACE, EVENT_ADD_ON_LOADED, OnAddOnLoaded)