ESO Lua File v100011

ingame/guild/gamepad/zo_guildinfo_gamepad.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
ZO_GamepadGuildInfo = ZO_Object:Subclass()
function ZO_GamepadGuildInfo:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_GamepadGuildInfo:Initialize(control)
    if not self.initialized then
        self.initialized = true
        
        self.control = control
        GUILD_INFO_GAMEPAD_FRAGMENT = ZO_FadeSceneFragment:New(self.control, true)
        GUILD_INFO_GAMEPAD_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState)
            if newState == SCENE_SHOWING then
                self:PerformDeferredInitialization(control)
                self:RefreshScreen()
                local function OnProfanityFilterChange()
                    self:RefreshScreen()
                end
                CALLBACK_MANAGER:RegisterCallback("ProfanityFilter_Off", OnProfanityFilterChange)
                CALLBACK_MANAGER:RegisterCallback("ProfanityFilter_On", OnProfanityFilterChange)
            elseif newState == SCENE_HIDING then
                CALLBACK_MANAGER:UnregisterCallback("ProfanityFilter_Off")
                CALLBACK_MANAGER:UnregisterCallback("ProfanityFilter_On")
            end
        end)
    end
end
function ZO_GamepadGuildInfo:PerformDeferredInitialization()
    if self.deferredInitialized then return end
    self.deferredInitialized = true
    local container = self.control:GetNamedChild("Container")
    local headerContainer = container:GetNamedChild("HeaderContainer")
    self.header = headerContainer:GetNamedChild("Header")
    ZO_GamepadGenericHeader_Initialize(self.header, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE, ZO_GAMEPAD_HEADER_LAYOUTS.CONTENT_HEADER_DATA_PAIRS_LINKED)
    self.headerData = {}
    local scrollChild = container:GetNamedChild("TextScrollContainer"):GetNamedChild("ScrollChild")
    local keep = scrollChild:GetNamedChild("Keep")
    self.keepTitle = keep:GetNamedChild("Title")
    self.keepIcon = keep:GetNamedChild("Icon")
    self.keepName = keep:GetNamedChild("Name")
    self.campaignName = keep:GetNamedChild("NameExtra")
    
    local trader = scrollChild:GetNamedChild("Trader")
    self.traderTitle = trader:GetNamedChild("Title")
    self.traderIcon = trader:GetNamedChild("Icon")
    self.traderIcon:SetTexture("EsoUI/Art/Guild/ownership_icon_guildTrader.dds")
    self.traderName = trader:GetNamedChild("Name")
    local motdContainer = scrollChild:GetNamedChild("MOTD")
    local motdTitle = motdContainer:GetNamedChild("Title")
    motdTitle:SetText(GetString(SI_GUILD_MOTD_HEADER))
    self.motd = motdContainer:GetNamedChild("Body")
    local descriptionContainer = scrollChild:GetNamedChild("Description")
    local descriptionTitle = descriptionContainer:GetNamedChild("Title")
    descriptionTitle:SetText(GetString(SI_GUILD_DESCRIPTION_HEADER))
    self.description = descriptionContainer:GetNamedChild("Body")
    
end
function ZO_GamepadGuildInfo:RefreshScreen()
    self:RefreshMOD()
    self:RefreshHeader()
    self:RefreshFooter()
end
function ZO_GamepadGuildInfo:SetGuildId(guildId)
    self.guildId = guildId
end
local SERVICES_ICON_SIZE = 30
function ZO_GamepadGuildInfo:RefreshHeader()
    local status = GetPlayerStatus()
    local statusTexture = GetPlayerStatusIcon(status)
    local numGuildMembers, numOnline, guildMasterName = ZO_GetGuildData(self.guildId)
    
    SelectGuildBank(self.guildId)
    local canDepositToBank = DoesGuildHavePrivilege(self.guildId, GUILD_PRIVILEGE_BANK_DEPOSIT)
    local bankIcon = "EsoUI/Art/Guild/Gamepad/guild_bankAccess.dds"
    local bankText = GetString(SI_GAMEPAD_GUILD_HEADER_GUILD_SERVICES_BANK)
    
    if(not canDepositToBank) then
        bankIcon = "EsoUI/Art/Guild/Gamepad/guild_bankAccess_disabled.dds"
        bankText = ZO_DISABLED_TEXT:Colorize(bankText)
        bankBalance = ZO_DISABLED_TEXT:Colorize(bankBalance)
    end
    bankIcon = zo_iconFormat(bankIcon, SERVICES_ICON_SIZE, SERVICES_ICON_SIZE)
    
    local canUseHeraldry = DoesGuildHavePrivilege(self.guildId, GUILD_PRIVILEGE_HERALDRY)
    local heraldryIcon = "EsoUI/Art/Guild/Gamepad/guild_heraldryAccess.dds"
    local heraldryText = GetString(SI_GAMEPAD_GUILD_HEADER_GUILD_SERVICES_HERALDRY)
    if(not canUseHeraldry) then
        heraldryIcon = "EsoUI/Art/Guild/Gamepad/guild_heraldryAccess_disabled.dds"
        heraldryText = ZO_DISABLED_TEXT:Colorize(heraldryText)
    end
    heraldryIcon = zo_iconFormat(heraldryIcon, SERVICES_ICON_SIZE, SERVICES_ICON_SIZE)
    local canUseTradingHouse = DoesGuildHavePrivilege(self.guildId, GUILD_PRIVILEGE_TRADING_HOUSE)
    local tradingIcon = "EsoUI/Art/Guild/Gamepad/guild_tradingHouseAccess.dds"
    local tradingText = GetString(SI_GAMEPAD_GUILD_HEADER_GUILD_SERVICES_STORE)
    if(not canUseTradingHouse) then
        tradingIcon = "EsoUI/Art/Guild/Gamepad/guild_tradingHouseAccess_disabled.dds"
        tradingText = ZO_DISABLED_TEXT:Colorize(tradingText)
    end
    tradingIcon = zo_iconFormat(tradingIcon, SERVICES_ICON_SIZE, SERVICES_ICON_SIZE)
    local headerData = self.headerData
    
    headerData.titleText = GetGuildName(self.guildId)
    headerData.data1HeaderText = bankText
    headerData.data2HeaderText = heraldryText
    headerData.data3HeaderText = tradingText
    headerData.data1Text = bankIcon
    headerData.data2Text = heraldryIcon
    headerData.data3Text = tradingIcon
end
function ZO_GamepadGuildInfo:InitializeFooter()
    self.footerData = {
        data1HeaderText = GetString(SI_GAMEPAD_GUILD_HEADER_MEMBERS_ONLINE_LABEL),
        data2HeaderText = GetString(SI_GAMEPAD_GUILD_HEADER_GUILD_MASTER_LABEL),
    }
end
function ZO_GamepadGuildInfo:RefreshFooter()
    local numGuildMembers, numOnline, guildMasterName = ZO_GetGuildData(self.guildId)
    self.footerData.data1Text = zo_strformat(GetString(SI_GAMEPAD_GUILD_HEADER_MEMBERS_ONLINE_FORMAT), numOnline, numGuildMembers)
    self.footerData.data2Text = guildMasterName
    GAMEPAD_GENERIC_FOOTER:Refresh(self.footerData)
end
--------------
-- Messages --
--------------
function ZO_GamepadGuildInfo:RefreshMOD()
    local text = GetGuildMotD(self.guildId)
    if(text == "") then
        text = GetString(SI_GUILD_MOTD_EMPTY_TEXT)
    end
    self.motd:SetText(text)
end
function ZO_GamepadGuildInfo:RefreshDescription()
    local text = GetGuildDescription(self.guildId)
    if(text == "") then
        text = GetString(SI_GUILD_DESCRIPTION_EMPTY_TEXT)
    end
end
-----------
-- Icons --
-----------
function ZO_GamepadGuildInfo:RefreshKeepOwnership()
    local text = GetString(SI_GUILD_NO_CLAIMED_KEEP)
    local headerText = GetString(SI_GAMEPAD_GUILD_KEEP_OWNERSHIP_HEADER)
    if(DoesGuildHaveClaimedKeep(self.guildId)) then    
        local keepId, campaignId = GetGuildClaimedKeep(self.guildId)
        local keepType = GetKeepType(keepId)
        local icon = "EsoUI/Art/Guild/ownership_icon_keep.dds"
        if(keepType == KEEPTYPE_RESOURCE) then
            local resourceType = GetKeepResourceType(keepId)
            icon = RESOURCE_ICONS[resourceType]
        end
        self.keepIcon:SetTexture(icon)
        self.keepIcon:SetAlpha(1)
        text = zo_strformat(SI_TOOLTIP_KEEP_NAME, GetKeepName(keepId))
        
        self.campaignName:SetHidden(false)
        self.campaignName:SetText(GetCampaignName(campaignId))
    else
        self.keepIcon:SetTexture("EsoUI/Art/Guild/ownership_icon_keep.dds")
        self.keepIcon:SetAlpha(0.2)
        text = ZO_DISABLED_TEXT:Colorize(text)
        headerText = ZO_DISABLED_TEXT:Colorize(headerText)
        self.campaignName:SetHidden(true)
    end
    self.keepTitle:SetText(headerText)
    self.keepName:SetText(text)
end
function ZO_GamepadGuildInfo:RefreshTraderOwnership()
    local headerText = GetString(SI_GUILD_TRADER_OWNERSHIP_HEADER)
    local traderText = GetString(SI_GUILD_NO_HIRED_TRADER)
    
    local traderName = GetGuildOwnedKioskInfo(self.guildId)
    if(traderName) then
        self.traderIcon:SetAlpha(1)
        traderText = zo_strformat(SI_GUILD_HIRED_TRADER, traderName)
    else
        self.traderIcon:SetAlpha(0.2)
        traderText = ZO_DISABLED_TEXT:Colorize(traderText)
        headerText = ZO_DISABLED_TEXT:Colorize(headerText)
    end
    self.traderName:SetText(traderText)
    self.traderTitle:SetText(headerText)
end
                         
--------------------
    GAMEPAD_GUILD_INFO = ZO_GamepadGuildInfo:New(control)
end