Back to Home

ESO Lua File v100035

ingame/retrait/zo_retraitstation_manager.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
local RetraitStationManager = ZO_CallbackObject:Subclass()
function RetraitStationManager:New(...)
    local obj = ZO_CallbackObject.New(self)
    obj:Initialize(...)
    return obj
end
function RetraitStationManager:Initialize()
end
function RetraitStationManager:InitializeTraitData()
    self.traitInfo = {
        [ITEM_TRAIT_TYPE_CATEGORY_WEAPON] = {},
        [ITEM_TRAIT_TYPE_CATEGORY_ARMOR] = {},
        [ITEM_TRAIT_TYPE_CATEGORY_JEWELRY] = {},
    }
    local traitItems = ZO_CraftingUtils_GetSmithingTraitItemInfo()
    for _, traitItemInfo in ipairs(traitItems) do
        local traitCategory = GetItemTraitTypeCategory(traitItemInfo.type)
        local traitName = GetString("SI_ITEMTRAITTYPE", traitItemInfo.type)
        if self.traitInfo[traitCategory] then
            table.insert(self.traitInfo[traitCategory], {
                traitType = traitItemInfo.type,
                traitItemIcon = traitItemInfo.icon,
                traitName = zo_strformat(SI_SMITHING_RESEARCH_TRAIT_NAME_FORMAT, traitName)
            })
        end
    end
end
function RetraitStationManager:RegisterForEvents()
    EVENT_MANAGER:RegisterForEvent("RetraitStationManager", EVENT_RETRAIT_STATION_INTERACT_START, function(eventCode) SYSTEMS:ShowScene("retrait") end)
    EVENT_MANAGER:RegisterForEvent("RetraitStationManager", EVENT_RETRAIT_RESPONSE, function(eventCode, result) SYSTEMS:GetObject("retrait"):OnRetraitResult(result) end)
    local function HandleDirtyEvent()
        self:FireCallbacks("OnRetraitDirtyEvent")
    end
    EVENT_MANAGER:RegisterForEvent("RetraitStationManager", EVENT_INVENTORY_FULL_UPDATE, HandleDirtyEvent)
    EVENT_MANAGER:RegisterForEvent("RetraitStationManager", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, HandleDirtyEvent)
    EVENT_MANAGER:RegisterForEvent("RetraitStationManager", EVENT_SMITHING_TRAIT_RESEARCH_STARTED, HandleDirtyEvent)
    EVENT_MANAGER:RegisterForEvent("RetraitStationManager", EVENT_SMITHING_TRAIT_RESEARCH_COMPLETED, HandleDirtyEvent)
end
do
    local retraitScenes = {}
    function RetraitStationManager:RegisterRetraitScene(retraitSceneName)
        retraitScenes[retraitSceneName] = true
    end
    function RetraitStationManager:IsRetraitSceneShowing()
        local showingSceneName = SCENE_MANAGER:GetCurrentSceneName()
        if showingSceneName then
            return retraitScenes[showingSceneName] == true
        end
        return false
    end
    function RetraitStationManager:IsRetraitFragmentShowing()
        if IsInGamepadPreferredMode() then
            return GAMEPAD_RETRAIT_FRAGMENT:IsShowing()
        else
            return RETRAIT_STATION_RETRAIT_FRAGMENT:IsShowing()
        end
    end
    function RetraitStationManager:IsReconstructFragmentShowing()
        if IsInGamepadPreferredMode() then
            return GAMEPAD_RECONSTRUCT_FRAGMENT:IsShowing()
        else
            return RETRAIT_STATION_RECONSTRUCT_FRAGMENT:IsShowing()
        end
    end
end
function RetraitStationManager:GetTraitInfo()
    return self.traitInfo
end
function RetraitStationManager:GetTraitInfoForCategory(itemTraitTypeCategory)
    return self.traitInfo[itemTraitTypeCategory]
end
ZO_RETRAIT_STATION_MANAGER = RetraitStationManager:New()