Back to Home

ESO Lua File v100023

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
local ICON_KEEP = "EsoUI/Art/Guild/Gamepad/gp_ownership_icon_keep.dds"
local ICON_TRADER = "EsoUI/Art/Guild/Gamepad/gp_ownership_icon_guildTrader.dds"
local GUILD_RESOURCE_ICONS =
{
    [RESOURCETYPE_WOOD] = "EsoUI/Art/Guild/Gamepad/gp_ownership_icon_lumberMill.dds",
    [RESOURCETYPE_ORE] = "EsoUI/Art/Guild/Gamepad/gp_ownership_icon_mine.dds",
    [RESOURCETYPE_FOOD] = "EsoUI/Art/Guild/Gamepad/gp_ownership_icon_farm.dds",
}
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 = {}
    self.scrollControl = container:GetNamedChild("TextScrollContainer")
    local scrollChild = self.scrollControl: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(ICON_TRADER)
    self.traderName = trader:GetNamedChild("Name")
    local guildMasterContainer = scrollChild:GetNamedChild("GuildMaster")
    local guildMasterTitle = guildMasterContainer:GetNamedChild("Title")
    guildMasterTitle:SetText(GetString(SI_GAMEPAD_GUILD_HEADER_GUILD_MASTER_LABEL))
    self.guildMasterBodyLabel = guildMasterContainer:GetNamedChild("Body")
    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")
    local privilegesControl = container:GetNamedChild("Privileges")
    self.privilegeBankControl = privilegesControl:GetNamedChild("Bank")
    self.privilegeHeraldryControl = privilegesControl:GetNamedChild("Heraldry")
    self.privilegeTradingHouseControl = privilegesControl:GetNamedChild("TradingHouse")
end
function ZO_GamepadGuildInfo:RefreshScreen()
    self.scrollControl:ResetToTop()
    self:RefreshMOTD()
    self:RefreshHeader()
    self:RefreshFooter()
end
function ZO_GamepadGuildInfo:SetGuildId(guildId)
    self.guildId = guildId
end
local function RefreshPrivilege(privilegeControl, enabled)
    local label = privilegeControl:GetNamedChild("Name")
    local icon = privilegeControl:GetNamedChild("Icon")
    local color = enabled and ZO_SELECTED_TEXT or ZO_DISABLED_TEXT
    local r, g, b = color:UnpackRGB()
    label:SetColor(r, g, b)
    icon:SetColor(r, g, b)
end
function ZO_GamepadGuildInfo:RefreshPrivileges()
    local canDepositToBank = DoesGuildHavePrivilege(self.guildId, GUILD_PRIVILEGE_BANK_DEPOSIT)
    RefreshPrivilege(self.privilegeBankControl, canDepositToBank)
    local canUseHeraldry = DoesGuildHavePrivilege(self.guildId, GUILD_PRIVILEGE_HERALDRY)
    RefreshPrivilege(self.privilegeHeraldryControl, canUseHeraldry)
    local canUseTradingHouse = DoesGuildHavePrivilege(self.guildId, GUILD_PRIVILEGE_TRADING_HOUSE)
    RefreshPrivilege(self.privilegeTradingHouseControl, canUseTradingHouse)
end
function ZO_GamepadGuildInfo:RefreshHeader()
    local headerData = self.headerData
    headerData.titleText = GetGuildName(self.guildId)
end
function ZO_GamepadGuildInfo:InitializeFooter()
    self.footerData = {
        data1HeaderText = GetString(SI_GAMEPAD_GUILD_HEADER_MEMBERS_ONLINE_LABEL),
    }
end
function ZO_GamepadGuildInfo:RefreshFooter()
    local numGuildMembers, numOnline = GetGuildInfo(self.guildId)
    self.footerData.data1Text = zo_strformat(GetString(SI_GAMEPAD_GUILD_HEADER_MEMBERS_ONLINE_FORMAT), numOnline, numGuildMembers)
    GAMEPAD_GENERIC_FOOTER:Refresh(self.footerData)
end
--------------
-- Messages --
--------------
function ZO_GamepadGuildInfo:RefreshGuildMaster()
    local guildMaster = select(3, GetGuildInfo(self.guildId))
    self.guildMasterBodyLabel:SetText(ZO_FormatUserFacingDisplayName(guildMaster))
end
function ZO_GamepadGuildInfo:RefreshMOTD()
    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 = ICON_KEEP
        if(keepType == KEEPTYPE_RESOURCE) then
            local resourceType = GetKeepResourceType(keepId)
            icon = GUILD_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(ICON_KEEP)
        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