Back to Home

ESO Lua File v101041

ingame/stable/stable_base.lua

[◄ back to folders ]
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
----------------
--Initialization
----------------
ZO_Stable_Base = ZO_Object:Subclass()
function ZO_Stable_Base:New(...)
    local stables = ZO_Object.New(self)
    stables:Initialize(...)
    return stables
end
function ZO_Stable_Base:Initialize(control, sceneIdentifier)
    self.stableControl = control
    self.sceneIdentifier = sceneIdentifier
end
function ZO_Stable_Base:InitializeControls()
    --Stubbed; to be overriden
end
function ZO_Stable_Base:InitializeEvents()
    STABLE_MANAGER:RegisterCallback("StableInteractStart", function() self:OnStablesInteractStart() end)
    STABLE_MANAGER:RegisterCallback("StableInteractEnd", function() self:OnStablesInteractEnd() end)
    STABLE_MANAGER:RegisterCallback("StableMountInfoUpdated", function() self:OnMountInfoUpdate() end)
    STABLE_MANAGER:RegisterCallback("ActiveMountChanged", function() self:OnActiveMountChanged() end)
end
function ZO_Stable_Base:RegisterUpdateEvents()
    STABLE_MANAGER:RegisterCallback("StableMoneyUpdate", function() self:OnMoneyUpdated() end)
end
function ZO_Stable_Base:UnregisterUpdateEvents()
    STABLE_MANAGER:UnregisterCallback("StableMoneyUpdate")
end
-----------------
--Events Handlers
-----------------
function ZO_Stable_Base:OnStablesInteractStart()
    if self:IsPreferredScreen() then
        self:SetHidden(false)
        self:UpdateMountInfo()
    end
end
function ZO_Stable_Base:OnStablesInteractEnd()
    self:SetHidden(true)
end
function ZO_Stable_Base:OnMoneyUpdated()
    self:UpdateStrips()
end
function ZO_Stable_Base:OnMountInfoUpdate()
end
function ZO_Stable_Base:OnActiveMountChanged()
end
--------------------
--Instance Methods--
--------------------
function ZO_Stable_Base:UpdateMountInfo()
    --Stubbed; to be overriden
end
function ZO_Stable_Base:UpdateStrips()
    --Stubbed; to be overriden
end
function ZO_Stable_Base:IsPreferredScreen()
    --Stubbed; to be overriden
end
function ZO_Stable_Base:RefreshActiveMount()
    --Stubbed; to be overriden
end
function ZO_Stable_Base:SetHidden(hidden)
    if self.sceneIdentifier then
        if hidden then
            SCENE_MANAGER:Hide(self.sceneIdentifier)
        else
            SCENE_MANAGER:Show(self.sceneIdentifier)
        end
    end
end
function ZO_Stable_Base:SetupRow(control, trainingType)
    control.trainingType = trainingType
    control.trainingSound = STABLE_TRAINING_SOUNDS[trainingType]
    if control.trainButton then
        control.trainButton.trainingType = trainingType
        control.trainButton.trainingSound = control.trainingSound
    end
    control.label:SetText(GetString("SI_RIDINGTRAINTYPE", trainingType))
    ZO_StatusBar_SetGradientColor(control.bar, ZO_XP_BAR_GRADIENT_COLORS)
end
--------------------
--Global Functions--
--------------------
function ZO_StablesTrainButton_Refresh(control, canTypeBeTrained)
    local timeUntilCanBeTrained = GetTimeUntilCanBeTrained()
    control:SetHidden(not (canTypeBeTrained and timeUntilCanBeTrained == 0 and STABLE_MANAGER:CanAffordTraining()))
end
    PlaySound(control.trainingSound)
    TrainRiding(control.trainingType)
end
    control.label = control:GetNamedChild("Label")
    control.trainButton = control:GetNamedChild("TrainButton")
    control.icon = control:GetNamedChild("Icon")
    local barContainer = control:GetNamedChild("BarContainer")
    control.bar = barContainer:GetNamedChild("StatusBar"):GetNamedChild("Bar")
    control.value = barContainer:GetNamedChild("Value")
end