forked from isalcedo/VanillaGuide
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDisplay.lua
160 lines (135 loc) · 4.16 KB
/
Display.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
--[[--------------------------------------------------
Connection:
--]]--------------------------------------------------
--local VGuide = VGuide
Dv(" VGuide Display.lua Start")
objDisplay = {}
objDisplay.__index = objDisplay
function objDisplay:new(oSettings, oGuideTables)
local obj = {}
setmetatable(obj, self)
local tGuideValues = oSettings:GetSettingsGuideValues()
obj.CurrentStep = tGuideValues.Step
obj.CurrentGuideID = tGuideValues.GuideID
obj.CurrentStepCount = nil
obj.GuideTitle = nil
obj.StepFrameDisplay = nil
obj.ScrollFrameDisplay = {}
obj.StepInfoDisplay = {}
obj.ScrollFrameDisplayWipe = function(self)
for k, _ in ipairs(obj.ScrollFrameDisplay) do
obj.ScrollFrameDisplay[k] = nil
end
end
obj.StepInfoDisplayWipe = function(self)
for k, _ in ipairs(obj.StepInfoDisplay) do
obj.StepInfoDisplay[k] = nil
end
end
obj.RetriveData = function(self)
local t = oGuideTables:GetGuide(obj.CurrentGuideID)
--Dtprint(t, 4)
local count = 0
obj.GuideTitle = t.title
obj.StepFrameDisplay = t.items[obj.CurrentStep].str
obj:ScrollFrameDisplayWipe()
obj:StepInfoDisplayWipe()
for k, v in ipairs(t.items) do
count = count + 1
obj.ScrollFrameDisplay[k] = v.str
obj.StepInfoDisplay[k] = {}
obj.StepInfoDisplay[k].x = v.x or nil
obj.StepInfoDisplay[k].y = v.y or nil
obj.StepInfoDisplay[k].zone = v.zone or nil
end
obj.CurrentStepCount = count
obj:UpdateGuideValuesSettings()
end
obj.RetriveTableDDM = function(self)
local t = oGuideTables:GetTableDDM()
return t
end
obj.UpdateGuideValuesSettings = function(self)
tGuideValues.Step = obj.CurrentStep
tGuideValues.GuideID = obj.CurrentGuideID
oSettings:SetSettingsGuideValues(tGuideValues)
end
obj.GuideByID = function(self, nGuideID)
local bChange = false
obj.CurrentGuideID = nGuideID
obj.CurrentStep = 1
obj:RetriveData()
bChange = true
return bChange
end
obj.StepByID = function(self, nStep)
obj.CurrentStep = nStep
obj:RetriveData()
end
-- bMode tells us if we need to position CurrentStep to the last
-- step of the guide (in case we used PrevStep)
obj.PrevGuide = function(self, bPrevStepBackGuide)
if obj.CurrentGuideID > 1 then
obj.CurrentGuideID = obj.CurrentGuideID - 1
obj.CurrentStep = 1
obj:RetriveData()
if bPrevStepBackGuide then
obj.CurrentStep = obj.CurrentStepCount
obj.StepFrameDisplay = obj.ScrollFrameDisplay[obj.CurrentStep]
end
else
Dv(" -- Already at GuideID 1")
end
end
obj.NextGuide = function(self)
if obj.CurrentGuideID < oGuideTables.GuideCount then
obj.CurrentGuideID = obj.CurrentGuideID + 1
obj.CurrentStep = 1
obj:RetriveData()
else
Dv(" -- Already at last GuideID (" .. oGuideTables.GuideCount .. ")")
end
end
obj.PrevStep = function(self)
if obj.CurrentStep > 1 then
obj.CurrentStep = obj.CurrentStep - 1
obj.StepFrameDisplay = obj.ScrollFrameDisplay[obj.CurrentStep]
obj:UpdateGuideValuesSettings()
else
obj:PrevGuide(true)
end
end
obj.NextStep = function(self)
if obj.CurrentStep < obj.CurrentStepCount then
obj.CurrentStep = obj.CurrentStep + 1
obj.StepFrameDisplay = obj.ScrollFrameDisplay[obj.CurrentStep]
obj:UpdateGuideValuesSettings()
else
obj:NextGuide()
end
end
obj.GetCurrentStep = function(self)
return obj.CurrentStep
end
obj.GetCurrentGuideID = function(self)
return obj.CurrentGuideID
end
obj.GetCurrentStepCount = function(self)
return obj.CurrentStepCount
end
obj.GetCurrentStepInfo = function(self)
return obj.StepInfoDisplay[obj.CurrentStep]
end
obj.GetStepLabel = function(self)
return obj.StepFrameDisplay
end
obj.GetGuideTitle = function(self)
return obj.GuideTitle
end
obj.GetScrollFrameDisplay = function(self)
return obj.ScrollFrameDisplay
end
obj:RetriveData()
return obj
end
Dv(" VGuide Display.lua End")