Back to Home

ESO Lua File v100016

ingame/housingeditor/keyboard/housingfurniturebrowser_keyboard.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
ZO_HousingFurnitureBrowser_Keyboard = ZO_HousingFurnitureBrowser_Base:Subclass()
function ZO_HousingFurnitureBrowser_Keyboard:New(...)
    local browser = ZO_Object.New(self)
    browser:Initialize(...)
    return browser
end
local DEBUG_HOUSING_DATA_TYPE = 1
function ZO_HousingFurnitureBrowser_Keyboard:Initialize(control)
    ZO_HousingFurnitureBrowser_Base.Initialize(self, control)
    self.list = control:GetNamedChild("List")
    KEYBOARD_HOUSING_FURNITURE_BROWSER_SCENE = ZO_Scene:New("keyboard_housing_furniture_scene", SCENE_MANAGER)    
    KEYBOARD_HOUSING_FURNITURE_BROWSER_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_SHOWING then
            self:OnDeferredInitialization() 
            self:OnShowing()        
            KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
        elseif newState == SCENE_FRAGMENT_HIDDEN then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
            --in case you close this menu by running since you can do that with a keyboard!
            if HousingEditorHasPendingFixture() then
                HousingEditorRequestModeChange(HOUSING_EDITOR_MODE_PLACEMENT)
            else
                HousingEditorRequestModeChange(HOUSING_EDITOR_MODE_SELECTION)
            end
        end
    end)
    SYSTEMS:RegisterKeyboardRootScene("housing_furniture_browser", KEYBOARD_HOUSING_FURNITURE_BROWSER_SCENE)
    local function RefreshMainList()
        if SCENE_MANAGER:IsShowing("keyboard_housing_furniture_scene") then
            self:RefreshMainList()
        else
            self.mainListIsDirty = true
        end
    end
    SHARED_INVENTORY:RegisterCallback("FullInventoryUpdate", RefreshMainList)
    SHARED_INVENTORY:RegisterCallback("SingleSlotInventoryUpdate", RefreshMainList)
end
function ZO_HousingFurnitureBrowser_Keyboard:OnDeferredInitialization()
    if self.isInitialized then
        return
    end
    
    local function SetupRow(rowControl, data)
        rowControl:GetNamedChild("Name"):SetText(data.name)
    end
    local ENTRY_HEIGHT = 52
    ZO_ScrollList_AddDataType(self.list, DEBUG_HOUSING_DATA_TYPE, "ZO_PlayerFurnitureSlot", ENTRY_HEIGHT, SetupRow)
    self.isInitialized = true
end
function ZO_HousingFurnitureBrowser_Keyboard:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_RIGHT,
        -- Primary
        {
            name =  "[debug] Select",
            keybind = "UI_SHORTCUT_PRIMARY", 
            callback =  function()
                            if HousingEditorHasPendingFixture() then
                                SCENE_MANAGER:HideCurrentScene()
                            end
                        end,
        },
    }
end
function ZO_HousingFurnitureBrowser_Keyboard:OnShowing()
    if self.mainListIsDirty then
        self:RefreshMainList()
    end
end
function ZO_HousingFurnitureBrowser_Keyboard:RefreshMainList()
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    local itemFurnitureCache = SHARED_FURNITURE:GetFurnitureCache(ZO_PLACEABLE_TYPE_ITEM)
    for bag, bagEntries in pairs(itemFurnitureCache) do
        for _, slotData in pairs(bagEntries) do --pairs because slotIndex can be zero
            scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(DEBUG_HOUSING_DATA_TYPE, slotData)
        end
    end
    local testFurnitureCache = SHARED_FURNITURE:GetFurnitureCache(ZO_PLACEABLE_TYPE_TEST)
    for i, furnitureInfo in ipairs(testFurnitureCache) do
        scrollData[#scrollData + 1] = ZO_ScrollList_CreateDataEntry(DEBUG_HOUSING_DATA_TYPE, furnitureInfo)
    end
    
    self.mainListIsDirty = false
end
    local data = ZO_ScrollList_GetData(self)
    if data.type == ZO_PLACEABLE_TYPE_ITEM then
        HousingEditorPreviewItemFurniture(data.bagId, data.slotIndex)
    elseif data.type == ZO_PLACEABLE_TYPE_TEST then
    end  
end
    HousingEditorRequestModeChange(HOUSING_EDITOR_MODE_PLACEMENT)
    SCENE_MANAGER:HideCurrentScene()
end
    local keyboardBrowser = ZO_HousingFurnitureBrowser_Keyboard:New(control)
    SYSTEMS:RegisterKeyboardObject("housing_furniture_browser", keyboardBrowser)
end