Back to Home

ESO Lua File v101042

ingame/housingeditor/housingfurniturebrowser_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
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
HOUSING_BROWSER_MODE =
{
    NONE = 0,
    PLACEMENT = 1,
    PRODUCTS = 2,
    RETRIEVAL = 3,
    SETTINGS = 4,
}
ZO_HousingFurnitureBrowser_Base = ZO_Object:Subclass()
function ZO_HousingFurnitureBrowser_Base:New(...)
    local browserBase = ZO_Object.New(self)
    browserBase:Initialize(...)
    return browserBase
end
function ZO_HousingFurnitureBrowser_Base:Initialize(control, sceneName)
    self.control = control
    self.placeableListDirty = true
    self.productListDirty = true
    self.retrievableListDistancesDirty = true
    self.retrievableListHeadingsDirty = true
    SHARED_FURNITURE:RegisterCallback("PlaceableFurnitureChanged", function()
        if SCENE_MANAGER:IsShowing(sceneName) then
            self:UpdatePlaceablePanel()
        else
            self.placeableListDirty = true
        end
    end)
    SHARED_FURNITURE:RegisterCallback("RetrievableFurnitureChanged", function()
        if SCENE_MANAGER:IsShowing(sceneName) then
            self:UpdateRetrievablePanel()
        else
            self.retrievableListDirty = true
        end
    end)
    SHARED_FURNITURE:RegisterCallback("RetrievableFurnitureDistanceAndHeadingChanged", function()
        if SCENE_MANAGER:IsShowing(sceneName) then
        else
            self.retrievableListDistancesDirty = true
            self.retrievableListHeadingsDirty = true
        end
    end)
    SHARED_FURNITURE:RegisterCallback("RetrievableFurnitureHeadingChanged", function()
        if SCENE_MANAGER:IsShowing(sceneName) then
            self:UpdateRetrievablePanelHeadings()
        else
            self.retrievableListHeadingsDirty = true
        end
    end)
    SHARED_FURNITURE:RegisterCallback("MarketProductsChanged", function()
        if SCENE_MANAGER:IsShowing(sceneName) then
            self:UpdateProductsPanel()
        else
            self.productListDirty = true
        end
    end)
end
function ZO_HousingFurnitureBrowser_Base:UpdatePlaceablePanel()
    --Override
end
function ZO_HousingFurnitureBrowser_Base:UpdateRetrievablePanel()
    --Override
end
function ZO_HousingFurnitureBrowser_Base:UpdateRetrievablePanelDistancesAndHeadings()
    --Override
end
function ZO_HousingFurnitureBrowser_Base:UpdateRetrievablePanelHeadings()
    --Override
end
function ZO_HousingFurnitureBrowser_Base:UpdateProductPanel()
    --Override
end
function ZO_HousingFurnitureBrowser_Base:IsShowing()
    -- To be overridden
    assert(false)
end
function ZO_HousingFurnitureBrowser_Base:OnShowing()
    PlaySound(SOUNDS.HOUSING_EDITOR_OPEN_BROWSER) 
    if self.placeableListDirty then
        self:UpdatePlaceablePanel()
        self.placeableListDirty = false
    end
    if self.retrievableListDirty then
        self:UpdateRetrievablePanel()
    else
        if self.retrievableListHeadingsDirty then
            if self.retrievableListDistancesDirty then
                self:UpdateRetrievablePanelDistancesAndHeadings()
            else
                self:UpdateRetrievablePanelHeadings()
            end
        end
    end
    self.retrievableListDirty = false
    self.retrievableListDistancesDirty = false
    self.retrievableListHeadingsDirty = false
    if self.productListDirty then
        self:UpdateProductsPanel()
        self.productListDirty = false
    end
end
function ZO_HousingFurnitureBrowser_Base:OnHiding()
    PlaySound(SOUNDS.HOUSING_EDITOR_CLOSE_BROWSER) 
end
function ZO_HousingFurnitureBrowser_Base.PreviewFurniture(placeableData)
    if placeableData and IsCharacterPreviewingAvailable() then
        placeableData:Preview()
    end
end
function ZO_HousingFurnitureBrowser_Base.SelectFurnitureForPlacement(placeableData)
    if placeableData then
        placeableData:SelectForPlacement()
        PlaySound(SOUNDS.DEFAULT_CLICK) 
    end
end
function ZO_HousingFurnitureBrowser_Base.SelectFurnitureForReplacement(data)
    local result = HousingEditorSelectFurnitureById(data.retrievableFurnitureId)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base.SelectNodeForReplacement(data)
    local result = HousingEditorSelectPathNodeByIndex(data.furnitureId, data.pathIndex)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base.SelectFurnitureForPrecisionEdit(data)
    HousingEditorSetPlacementType(HOUSING_EDITOR_PLACEMENT_TYPE_PRECISION)
    local result = HousingEditorSelectFurnitureById(data.retrievableFurnitureId)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base.SelectNodeForPrecisionEdit(data)
    HousingEditorSetPlacementType(HOUSING_EDITOR_PLACEMENT_TYPE_PRECISION)
    local result = HousingEditorSelectPathNodeByIndex(data.furnitureId, data.pathIndex)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base.PutAwayFurniture(data)
    local result = HousingEditorRequestRemoveFurniture(data.retrievableFurnitureId)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base.PutAwayNode(data)
    local result = HousingEditorRequestRemovePathNode(data.furnitureId, data.pathIndex)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base.SetAsStartingNode(data)
    local result = HousingEditorRequestSetStartingNodeIndex(data.furnitureId, data.pathIndex)
    ZO_AlertEvent(EVENT_HOUSING_EDITOR_REQUEST_RESULT, result)
    PlaySound(SOUNDS.DEFAULT_CLICK)
end
function ZO_HousingFurnitureBrowser_Base:GetMode()
    return self.mode
end
function ZO_HousingFurnitureBrowser_Base:SetMode(mode)
    if self.mode ~= mode then
        self.mode = mode
    end
end