Back to Home

ESO Lua File v101044

ingame/retrait/keyboard/zo_retraitstation_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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
local KEYBOARD_RETRAIT_ROOT_SCENE_NAME = "retrait_keyboard_root"
ZO_RetraitStation_Keyboard = ZO_RetraitStation_Base:Subclass()
function ZO_RetraitStation_Keyboard:Initialize(control)
    ZO_RetraitStation_Base.Initialize(self, control, KEYBOARD_RETRAIT_ROOT_SCENE_NAME)
    ZO_RETRAIT_KEYBOARD = ZO_RetraitStation_Retrait_Keyboard:New(self.control:GetNamedChild("RetraitPanel"), self)
    ZO_RECONSTRUCT_KEYBOARD = ZO_RetraitStation_Reconstruct_Keyboard:New(self.control:GetNamedChild("ReconstructPanel"), self)
end
function ZO_RetraitStation_Keyboard:InitializeModeBar()
    self.modeMenu = self.control:GetNamedChild("ModeMenu")
    self.modeBar = self.modeMenu:GetNamedChild("Bar")
    local MENU_BAR_DATA =
    {
        initialButtonAnchorPoint = RIGHT,
        buttonTemplate = "ZO_MenuBarTooltipButton",
        normalSize = 51,
        downSize = 64,
        buttonPadding = -15,
        animationDuration = 180,
    }
    ZO_MenuBar_SetData(self.modeBar, MENU_BAR_DATA)
    self.tabs = ZO_SceneFragmentBar:New(self.modeBar)
    self.retraitTab =
    {
        categoryName = SI_RETRAIT_STATION_RETRAIT_MODE,
        descriptor = ZO_RETRAIT_MODE_RETRAIT,
        normal = "EsoUI/Art/Crafting/retrait_tabIcon_up.dds",
        pressed = "EsoUI/Art/Crafting/retrait_tabIcon_down.dds",
        highlight = "EsoUI/Art/Crafting/retrait_tabIcon_over.dds",
        disabled = "EsoUI/Art/Crafting/retrait_tabIcon_disabled.dds",
        callback = function() self:SetMode(ZO_RETRAIT_MODE_RETRAIT) end,
    }
    self.reconstructTab =
    {
        categoryName = SI_RETRAIT_STATION_RECONSTRUCT_MODE,
        descriptor = ZO_RETRAIT_MODE_RECONSTRUCT,
        normal = "EsoUI/Art/Crafting/reconstruct_tabIcon_up.dds",
        pressed = "EsoUI/Art/Crafting/reconstruct_tabIcon_down.dds",
        highlight = "EsoUI/Art/Crafting/reconstruct_tabIcon_over.dds",
        disabled = "EsoUI/Art/Crafting/reconstruct_tabIcon_disabled.dds",
        callback = function() self:SetMode(ZO_RETRAIT_MODE_RECONSTRUCT) end,
    }
    self.tabs:SetStartingFragment(self.retraitTab.categoryName)
end
function ZO_RetraitStation_Keyboard:InitializeInteractScene()
    KEYBOARD_RETRAIT_ROOT_SCENE = self.interactScene
    local fragment = ZO_FadeSceneFragment:New(self.control)
    self.interactScene:AddFragment(fragment)
    SYSTEMS:RegisterKeyboardRootScene("retrait", self.interactScene)
end
function ZO_RetraitStation_Keyboard:OnInteractSceneShowing()
    if not self.initializedTabs then
        local retraitFragments =
        {
            RIGHT_PANEL_BG_FRAGMENT,
            RETRAIT_STATION_RETRAIT_FRAGMENT,
            CRAFTING_RESULTS_FRAGMENT,
        }
        ZO_CombineNumericallyIndexedTables(retraitFragments, FRAGMENT_GROUP.READ_ONLY_EQUIPPED_ITEMS)
        self.tabs:Add(self.retraitTab.categoryName, retraitFragments, self.retraitTab, ZO_RETRAIT_KEYBOARD:GetKeybindDescriptor())
        local reconstructFragments =
        {
            RIGHT_BG_FRAGMENT,
            RETRAIT_STATION_RECONSTRUCT_FRAGMENT,
            CRAFTING_RESULTS_FRAGMENT,
        }
        self.tabs:Add(self.reconstructTab.categoryName, reconstructFragments, self.reconstructTab, ZO_RECONSTRUCT_KEYBOARD:GetKeybindDescriptor())
        self.initializedTabs = true
    end
    self.tabs:UpdateButtons()
    if self.mode == ZO_RETRAIT_MODE_RECONSTRUCT then
        self.tabs:SelectFragment(self.reconstructTab.categoryName)
    else
        self.tabs:SelectFragment(self.retraitTab.categoryName)
    end
end
function ZO_RetraitStation_Keyboard:OnInteractSceneHiding()
    self.tabs:Clear()
end
function ZO_RetraitStation_Keyboard:OnInteractSceneHidden()
    CRAFTING_RESULTS:SetCraftingTooltip(nil)
end
function ZO_RetraitStation_Keyboard:UpdateKeybinds()
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.tabs:GetActiveKeybind())
end
function ZO_RetraitStation_Keyboard:SetMode(mode)
    if self.mode ~= mode then
        self.mode = mode
        self:RefreshModeMenuAnchors()
    end
end
function ZO_RetraitStation_Keyboard:RefreshModeMenuAnchors()
    local modeBackground
    if self.mode == ZO_RETRAIT_MODE_RETRAIT then
        modeBackground = ZO_SharedRightPanelBackground
    elseif self.mode == ZO_RETRAIT_MODE_RECONSTRUCT then
        modeBackground = ZO_SharedRightBackground
    end
    if modeBackground then
        self.modeMenu:ClearAnchors()
        local DIVIDER_OFFSET_X = 40
        self.modeMenu:SetAnchor(TOPLEFT, modeBackground, nil, DIVIDER_OFFSET_X)
        self.modeMenu:SetAnchor(TOPRIGHT, modeBackground, nil, -DIVIDER_OFFSET_X)
    end
end
-- Global XML functions
    ZO_RETRAIT_STATION_KEYBOARD = ZO_RetraitStation_Keyboard:New(control)
end