Back to Home

ESO Lua File v101039

ingame/treasuremap/treasuremap.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
local gamepadKeybindStripDescriptor = nil
local TREASURE_MAP_INTERACTION =
{
    type = "treasure map interact",
    interactTypes = { INTERACTION_TREASURE_MAP },
}
local function OnGamepadSceneStateChange(oldState, newState)
    if newState == SCENE_SHOWING then
        if gamepadKeybindStripDescriptor == nil then
            gamepadKeybindStripDescriptor = {
                    alignment = KEYBIND_STRIP_ALIGN_LEFT,
                    KEYBIND_STRIP:GenerateGamepadBackButtonDescriptor(function()
                        INTERACT_WINDOW:EndInteraction(TREASURE_MAP_INTERACTION)
                        SCENE_MANAGER:HideCurrentScene()
                    end)
                }
        end
        KEYBIND_STRIP:AddKeybindButtonGroup(gamepadKeybindStripDescriptor)
    elseif newState == SCENE_HIDDEN then
        KEYBIND_STRIP:RemoveKeybindButtonGroup(gamepadKeybindStripDescriptor)
    end
end
local TreasureMap = ZO_Object:Subclass()
function TreasureMap:New(...)
    local treasureMap = ZO_Object.New(self)
    treasureMap:Initialize(...)
    return treasureMap
end
function TreasureMap:Initialize(control)
    self.image = control:GetNamedChild("Image")
    control:RegisterForEvent(EVENT_SHOW_TREASURE_MAP, function(...) self:OnShowTreasureMap(...) end)
    TREASURE_MAP_INVENTORY_SCENE = ZO_Scene:New("treasureMapInventory", SCENE_MANAGER)
    TREASURE_MAP_INVENTORY_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_HIDDEN then
            INTERACT_WINDOW:EndInteraction(TREASURE_MAP_INTERACTION)
        end
    end)
    SYSTEMS:RegisterKeyboardRootScene("treasureMapInventory", TREASURE_MAP_INVENTORY_SCENE)
    TREASURE_MAP_QUICK_SLOT_SCENE = ZO_Scene:New("treasureMapQuickSlot", SCENE_MANAGER)
    TREASURE_MAP_QUICK_SLOT_SCENE:RegisterCallback("StateChange", function(oldState, newState)
        if newState == SCENE_HIDDEN then
            INTERACT_WINDOW:EndInteraction(TREASURE_MAP_INTERACTION)
        end
    end)
    SYSTEMS:RegisterKeyboardRootScene("treasureMapQuickSlot", TREASURE_MAP_QUICK_SLOT_SCENE)
    GAMEPAD_TREASURE_MAP_INVENTORY_SCENE = ZO_Scene:New("treasureMapInventoryGamepad", SCENE_MANAGER)
    GAMEPAD_TREASURE_MAP_INVENTORY_SCENE:RegisterCallback("StateChange", OnGamepadSceneStateChange)
    SYSTEMS:RegisterGamepadRootScene("treasureMapInventory", GAMEPAD_TREASURE_MAP_INVENTORY_SCENE)
    GAMEPAD_TREASURE_MAP_QUICK_SLOT_SCENE = ZO_Scene:New("treasureMapQuickSlotGamepad", SCENE_MANAGER)
    GAMEPAD_TREASURE_MAP_QUICK_SLOT_SCENE:RegisterCallback("StateChange", OnGamepadSceneStateChange)
    SYSTEMS:RegisterGamepadRootScene("treasureMapQuickSlot", GAMEPAD_TREASURE_MAP_QUICK_SLOT_SCENE)
end
function TreasureMap:OnShowTreasureMap(eventCode, treasureMapIndex)
    local name, imagePath = GetTreasureMapInfo(treasureMapIndex)
    self.image:SetTexture(imagePath)
    INTERACT_WINDOW:OnBeginInteraction(TREASURE_MAP_INTERACTION)
    if SCENE_MANAGER:IsShowingBaseScene() then
        SYSTEMS:ShowScene("treasureMapQuickSlot")
    else
        SYSTEMS:PushScene("treasureMapInventory")
    end
end
    TREASURE_MAP = TreasureMap:New(control)
end