Blizzard_GuildUI/Blizzard_GuildRoster.lua

Blizzard_GuildUI/Blizzard_GuildRoster.lua (8.3.7.35662; unchanged since 8.2.0.30920)
  1. GUILD_DETAIL_NORM_HEIGHT = 175;
  2. GUILD_DETAIL_OFFICER_HEIGHT = 228;
  3. local GUILD_ROSTER_MAX_COLUMNS = 5;
  4. local GUILD_ROSTER_MAX_STRINGS = 4;
  5. local GUILD_ROSTER_BAR_MAX = 239;
  6. local GUILD_ROSTER_BUTTON_OFFSET = 2;
  7. local GUILD_ROSTER_BUTTON_HEIGHT = 20;
  8. GUILD_ROSTER_STRING_OFFSET = 6;
  9. GUILD_ROSTER_STRING_WIDTH_ADJ = 14;
  10. local currentGuildView;
  11. local GUILD_ROSTER_COLUMNS = {
  12. playerStatus = { "level", "class", "wideName", "zone" },
  13. guildStatus = { "name", "rank", "note", "online" },
  14. --[[
  15. weeklyxp = { "level", "class", "wideName", "weeklyxp" },
  16. totalxp = { "level", "class", "wideName", "totalxp" },
  17. --]]
  18. pvp = { "level", "class", "name", "bgrating", "arenarating" },
  19. achievement = { "level", "class", "wideName", "achievement" },
  20. tradeskill = { "wideName", "zone", "skill" },
  21. reputation = { "level", "class", "wideName", "reputation" },
  22. };
  23. -- global for localization changes
  24. GUILD_ROSTER_COLUMN_DATA = {
  25. level = { width = 40, text = LEVEL_ABBR, stringJustify="CENTER" },
  26. class = { width = 32, text = CLASS_ABBR, hasIcon = true },
  27. name = { width = 81, text = NAME, stringJustify="LEFT" },
  28. wideName = { width = 101, text = NAME, sortType = "name", stringJustify="LEFT" },
  29. rank = { width = 76, text = RANK, stringJustify="LEFT" },
  30. note = { width = 76, text = LABEL_NOTE, stringJustify="LEFT" },
  31. online = { width = 76, text = LASTONLINE, stringJustify="LEFT" },
  32. zone = { width = 136, text = ZONE, stringJustify="LEFT" },
  33. bgrating = { width = 83, text = BG_RATING_ABBR, stringJustify="RIGHT" },
  34. arenarating = { width = 83, text = ARENA_RATING, stringJustify="RIGHT" },
  35. weeklyxp = { width = 136, text = GUILD_XP_WEEKLY, stringJustify="RIGHT", hasBar = true },
  36. totalxp = { width = 136, text = GUILD_XP_TOTAL, stringJustify="RIGHT", hasBar = true },
  37. achievement = { width = 136, text = ACHIEVEMENT_POINTS, stringJustify="RIGHT", sortType="achievementpoints", hasBar = true },
  38. skill = { width = 63, text = SKILL_POINTS_ABBR, stringJustify="LEFT" },
  39. reputation = { width = 136, text = REPUTATION, stringJustify="LEFT" },
  40. };
  41. local MOBILE_BUSY_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat-BusyMobile:14:14:0:0:16:16:0:16:0:16|t";
  42. local MOBILE_AWAY_ICON = "|TInterface\\ChatFrame\\UI-ChatIcon-ArmoryChat-AwayMobile:14:14:0:0:16:16:0:16:0:16|t";
  43. function GuildRosterFrame_OnLoad(self)
  44. GuildFrame_RegisterPanel(self);
  45. GuildRosterContainer.update = GuildRoster_Update;
  46. HybridScrollFrame_CreateButtons(GuildRosterContainer, "GuildRosterButtonTemplate", 0, 0, "TOPLEFT", "TOPLEFT", 0, -GUILD_ROSTER_BUTTON_OFFSET, "TOP", "BOTTOM");
  47. GuildRosterContainerScrollBar.doNotHide = true;
  48. GuildRosterShowOfflineButton:SetChecked(GetGuildRosterShowOffline());
  49. self:RegisterEvent("GUILD_TRADESKILL_UPDATE");
  50. self:RegisterEvent("GUILD_ROSTER_UPDATE");
  51. self:RegisterEvent("GUILD_RECIPE_KNOWN_BY_MEMBERS");
  52. self:RegisterEvent("PLAYER_ENTERING_WORLD");
  53. GuildRoster_SetView(GetCVar("guildRosterView"));
  54. SetGuildRosterSelection(0);
  55. UIDropDownMenu_SetSelectedValue(GuildRosterViewDropdown, currentGuildView);
  56. -- right-click dropdown
  57. GuildMemberDropDown.displayMode = "MENU";
  58. self.doRecipeQuery = true;
  59. end
  60. function GuildRosterFrame_OnEvent(self, event, ...)
  61. if ( not self:IsShown() ) then
  62. return;
  63. end
  64. if ( event == "GUILD_TRADESKILL_UPDATE" ) then
  65. if ( currentGuildView == "tradeskill" ) then
  66. GuildRoster_Update();
  67. end
  68. elseif ( event == "GUILD_ROSTER_UPDATE" ) then
  69. if ( currentGuildView ~= "tradeskill" ) then
  70. local canRequestRosterUpdate = ...;
  71. if ( canRequestRosterUpdate ) then
  72. C_GuildInfo.GuildRoster();
  73. end
  74. GuildRoster_Update();
  75. end
  76. elseif ( event == "PLAYER_ENTERING_WORLD" ) then
  77. self.doRecipeQuery = true;
  78. end
  79. end
  80. function GuildRosterFrame_OnShow(self)
  81. GuildRoster_RecipeQueryCheck();
  82. GuildRoster_Update();
  83. end
  84. function GuildRoster_RecipeQueryCheck()
  85. if ( GuildRosterFrame.doRecipeQuery ) then
  86. QueryGuildRecipes();
  87. GuildRosterFrame.doRecipeQuery = nil;
  88. end
  89. end
  90. function GuildRoster_GetLastOnline(guildIndex)
  91. return RecentTimeDate( GetGuildRosterLastOnline(guildIndex) );
  92. end
  93. function GuildRoster_SortByColumn(column)
  94. if ( column.sortType ) then
  95. if ( currentGuildView == "tradeskill" ) then
  96. SortGuildTradeSkill(column.sortType);
  97. else
  98. SortGuildRoster(column.sortType);
  99. end
  100. end
  101. PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
  102. end
  103. --****** Guild members **********************************************************
  104. function GuildRosterButton_SetStringText(buttonString, text, isOnline, class)
  105. buttonString:SetText(text);
  106. if ( isOnline ) then
  107. if ( class ) then
  108. local classColor = RAID_CLASS_COLORS[class];
  109. buttonString:SetTextColor(classColor.r, classColor.g, classColor.b);
  110. else
  111. buttonString:SetTextColor(HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
  112. end
  113. else
  114. buttonString:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
  115. end
  116. end
  117. function GuildRoster_Update()
  118. local scrollFrame = GuildRosterContainer;
  119. local offset = HybridScrollFrame_GetOffset(scrollFrame);
  120. local buttons = scrollFrame.buttons;
  121. local numButtons = #buttons;
  122. local button, index, class;
  123. local totalMembers, onlineMembers, onlineAndMobileMembers = GetNumGuildMembers();
  124. local selectedGuildMember = GetGuildRosterSelection();
  125. if ( currentGuildView == "tradeskill" ) then
  126. GuildRoster_UpdateTradeSkills();
  127. return;
  128. end
  129. local guildName, guildRankName, guildRankIndex = GetGuildInfo("player");
  130. local maxRankIndex = GuildControlGetNumRanks() - 1;
  131. -- Get selected guild member info
  132. local fullName, rank, rankIndex, level, class, zone, note, officernote, online, isAway, classFileName, achievementPoints, achievementRank, isMobile = GetGuildRosterInfo(selectedGuildMember);
  133. GuildFrame.selectedName = fullName;
  134. -- If there's a selected guildmember
  135. if ( selectedGuildMember > 0 ) then
  136. -- Update the guild member details frame
  137. if ( isMobile ) then
  138. if (isAway == 2) then
  139. GuildMemberDetailName:SetText(MOBILE_BUSY_ICON..GuildFrame.selectedName);
  140. elseif (isAway == 1) then
  141. GuildMemberDetailName:SetText(MOBILE_AWAY_ICON..GuildFrame.selectedName);
  142. else
  143. GuildMemberDetailName:SetText(ChatFrame_GetMobileEmbeddedTexture(73/255, 177/255, 73/255)..GuildFrame.selectedName);
  144. end
  145. else
  146. GuildMemberDetailName:SetText(GuildFrame.selectedName);
  147. end
  148. if ( level and class) then
  149. GuildMemberDetailLevel:SetFormattedText(FRIENDS_LEVEL_TEMPLATE, level, class);
  150. else
  151. GuildMemberDetailLevel:SetText("");
  152. end
  153. local zoneText = zone;
  154. if(isMobile and not online) then zoneText = REMOTE_CHAT; end;
  155. GuildMemberDetailZoneText:SetText(zoneText);
  156. GuildMemberDetailRankText:SetText(rank);
  157. if ( online ) then
  158. GuildMemberDetailOnlineText:SetText(GUILD_ONLINE_LABEL);
  159. else
  160. GuildMemberDetailOnlineText:SetText(GuildRoster_GetLastOnline(selectedGuildMember));
  161. end
  162. -- Update public note
  163. if ( CanEditPublicNote() ) then
  164. PersonalNoteText:SetTextColor(1.0, 1.0, 1.0);
  165. if ( (not note) or (note == "") ) then
  166. note = GUILD_NOTE_EDITLABEL;
  167. end
  168. else
  169. PersonalNoteText:SetTextColor(0.65, 0.65, 0.65);
  170. end
  171. GuildMemberNoteBackground:EnableMouse(CanEditPublicNote());
  172. PersonalNoteText:SetText(note);
  173. -- Manage guild member related buttons
  174. -- check if you can promote and the member is at least 2 ranks below you, or if you can demote and the member is not in the last rank, as well as below your rank
  175. if ( ( CanGuildPromote() and rankIndex > guildRankIndex + 1 ) or ( CanGuildDemote() and rankIndex < maxRankIndex and rankIndex > guildRankIndex ) ) then
  176. GuildMemberDetailRankLabel:SetHeight(20);
  177. GuildMemberRankDropdown:Show();
  178. UIDropDownMenu_SetText(GuildMemberRankDropdown, rank);
  179. else
  180. GuildMemberDetailRankLabel:SetHeight(0);
  181. GuildMemberRankDropdown:Hide();
  182. end
  183. -- Update officer note
  184. if ( C_GuildInfo.CanViewOfficerNote() ) then
  185. if ( C_GuildInfo.CanEditOfficerNote() ) then
  186. if ( (not officernote) or (officernote == "") ) then
  187. officernote = GUILD_OFFICERNOTE_EDITLABEL;
  188. end
  189. OfficerNoteText:SetTextColor(1.0, 1.0, 1.0);
  190. else
  191. OfficerNoteText:SetTextColor(0.65, 0.65, 0.65);
  192. end
  193. GuildMemberOfficerNoteBackground:EnableMouse(C_GuildInfo.CanEditOfficerNote());
  194. OfficerNoteText:SetText(officernote);
  195. -- Resize detail frame
  196. GuildMemberDetailOfficerNoteLabel:Show();
  197. GuildMemberOfficerNoteBackground:Show();
  198. GuildMemberDetailFrame:SetHeight(GUILD_DETAIL_OFFICER_HEIGHT + GuildMemberDetailName:GetHeight() + GuildMemberDetailRankLabel:GetHeight());
  199. else
  200. GuildMemberDetailOfficerNoteLabel:Hide();
  201. GuildMemberOfficerNoteBackground:Hide();
  202. GuildMemberDetailFrame:SetHeight(GUILD_DETAIL_NORM_HEIGHT + GuildMemberDetailName:GetHeight() + GuildMemberDetailRankLabel:GetHeight());
  203. end
  204. if ( CanGuildRemove() and ( rankIndex >= 1 ) and ( rankIndex > guildRankIndex ) ) then
  205. GuildMemberRemoveButton:Enable();
  206. else
  207. GuildMemberRemoveButton:Disable();
  208. end
  209. if ( (UnitFullName("player") == fullName) or (not online) or isMobile ) then
  210. GuildMemberGroupInviteButton:Disable();
  211. else
  212. GuildMemberGroupInviteButton:Enable();
  213. end
  214. GuildFrame.selectedName = GetGuildRosterInfo(GetGuildRosterSelection());
  215. else
  216. GuildMemberDetailFrame:Hide();
  217. end
  218. -- local maxWeeklyXP, maxTotalXP = GetGuildRosterLargestContribution();
  219. local maxAchievementsPoints = GetGuildRosterLargestAchievementPoints();
  220. -- numVisible
  221. local visibleMembers = onlineAndMobileMembers;
  222. if ( GetGuildRosterShowOffline() ) then
  223. visibleMembers = totalMembers;
  224. end
  225. for i = 1, numButtons do
  226. button = buttons[i];
  227. index = offset + i;
  228. local fullName, rank, rankIndex, level, class, zone, note, officernote, online, isAway, classFileName, achievementPoints, achievementRank, isMobile, canSoR, repStanding = GetGuildRosterInfo(index);
  229. local onlineOrMobile = online or isMobile;
  230. if ( fullName and index <= visibleMembers ) then
  231. button.guildIndex = index;
  232. local displayedName = Ambiguate(fullName, "guild");
  233. if ( isMobile and not online ) then
  234. if (isAway == 2) then
  235. displayedName = MOBILE_BUSY_ICON..displayedName;
  236. elseif (isAway == 1) then
  237. displayedName = MOBILE_AWAY_ICON..displayedName;
  238. else
  239. displayedName = ChatFrame_GetMobileEmbeddedTexture(73/255, 177/255, 73/255)..displayedName;
  240. end
  241. end
  242. button.online = onlineOrMobile;
  243. if ( currentGuildView == "playerStatus" ) then
  244. GuildRosterButton_SetStringText(button.string1, level, onlineOrMobile)
  245. button.icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[classFileName]));
  246. GuildRosterButton_SetStringText(button.string2, displayedName, onlineOrMobile, classFileName)
  247. local zoneText = zone;
  248. if(isMobile and not online) then zoneText = REMOTE_CHAT; end;
  249. GuildRosterButton_SetStringText(button.string3, zoneText, onlineOrMobile)
  250. elseif ( currentGuildView == "guildStatus" ) then
  251. GuildRosterButton_SetStringText(button.string1, displayedName, onlineOrMobile, classFileName)
  252. GuildRosterButton_SetStringText(button.string2, rank, onlineOrMobile)
  253. GuildRosterButton_SetStringText(button.string3, note, onlineOrMobile)
  254. if ( onlineOrMobile ) then
  255. GuildRosterButton_SetStringText(button.string4, GUILD_ONLINE_LABEL, onlineOrMobile);
  256. else
  257. GuildRosterButton_SetStringText(button.string4, GuildRoster_GetLastOnline(index), onlineOrMobile);
  258. end
  259. --[[
  260. elseif ( currentGuildView == "weeklyxp" ) then
  261. local weeklyXP, totalXP, weeklyRank, totalRank = GetGuildRosterContribution(index);
  262. GuildRosterButton_SetStringText(button.string1, level, onlineOrMobile)
  263. button.icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[classFileName]));
  264. GuildRosterButton_SetStringText(button.string2, displayedName, onlineOrMobile, classFileName)
  265. GuildRosterButton_SetStringText(button.string3, weeklyXP, onlineOrMobile)
  266. if ( weeklyXP == 0 ) then
  267. button.barTexture:Hide();
  268. else
  269. button.barTexture:SetWidth(weeklyXP / maxWeeklyXP * GUILD_ROSTER_BAR_MAX);
  270. button.barTexture:Show();
  271. end
  272. GuildRosterButton_SetStringText(button.barLabel, "#"..weeklyRank, onlineOrMobile);
  273. elseif ( currentGuildView == "totalxp" ) then
  274. local weeklyXP, totalXP, weeklyRank, totalRank = GetGuildRosterContribution(index);
  275. GuildRosterButton_SetStringText(button.string1, level, onlineOrMobile);
  276. button.icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[classFileName]));
  277. GuildRosterButton_SetStringText(button.string2, displayedName, onlineOrMobile, classFileName);
  278. GuildRosterButton_SetStringText(button.string3, totalXP, onlineOrMobile);
  279. if ( totalXP == 0 ) then
  280. button.barTexture:Hide();
  281. else
  282. button.barTexture:SetWidth(totalXP / maxTotalXP * GUILD_ROSTER_BAR_MAX);
  283. button.barTexture:Show();
  284. end
  285. GuildRosterButton_SetStringText(button.barLabel, "#"..totalRank, onlineOrMobile);
  286. --]]
  287. elseif ( currentGuildView == "pve" ) then
  288. GuildRosterButton_SetStringText(button.string1, level, onlineOrMobile);
  289. button.icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[classFileName]));
  290. GuildRosterButton_SetStringText(button.string2, displayedName, onlineOrMobile, classFileName);
  291. GuildRosterButton_SetStringText(button.string3, nil, onlineOrMobile);
  292. GuildRosterButton_SetStringText(button.string4, nil, onlineOrMobile);
  293. elseif ( currentGuildView == "achievement" ) then
  294. GuildRosterButton_SetStringText(button.string1, level, onlineOrMobile);
  295. button.icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[classFileName]));
  296. GuildRosterButton_SetStringText(button.string2, displayedName, onlineOrMobile, classFileName);
  297. if ( achievementPoints >= 0 ) then
  298. GuildRosterButton_SetStringText(button.string3, achievementPoints, onlineOrMobile);
  299. if ( achievementPoints == 0 ) then
  300. button.barTexture:Hide();
  301. else
  302. button.barTexture:SetWidth(achievementPoints / maxAchievementsPoints * GUILD_ROSTER_BAR_MAX);
  303. button.barTexture:Show();
  304. end
  305. else
  306. GuildRosterButton_SetStringText(button.string3, NO_ROSTER_ACHIEVEMENT_POINTS, onlineOrMobile);
  307. button.barTexture:Hide();
  308. end
  309. GuildRosterButton_SetStringText(button.barLabel, "#"..achievementRank, onlineOrMobile);
  310. elseif ( currentGuildView == "reputation" ) then
  311. GuildRosterButton_SetStringText(button.string1, level, onlineOrMobile)
  312. button.icon:SetTexCoord(unpack(CLASS_ICON_TCOORDS[classFileName]));
  313. GuildRosterButton_SetStringText(button.string2, displayedName, onlineOrMobile, classFileName);
  314. GuildRosterButton_SetStringText(button.string3, GetText("FACTION_STANDING_LABEL"..repStanding), onlineOrMobile);
  315. end
  316. button:Show();
  317. if ( mod(index, 2) == 0 ) then
  318. button.stripe:SetTexCoord(0.36230469, 0.38183594, 0.95898438, 0.99804688);
  319. else
  320. button.stripe:SetTexCoord(0.51660156, 0.53613281, 0.88281250, 0.92187500);
  321. end
  322. if ( selectedGuildMember == index ) then
  323. button:LockHighlight();
  324. else
  325. button:UnlockHighlight();
  326. end
  327. else
  328. button:Hide();
  329. end
  330. end
  331. local totalHeight = visibleMembers * (GUILD_ROSTER_BUTTON_HEIGHT + GUILD_ROSTER_BUTTON_OFFSET);
  332. local displayedHeight = numButtons * (GUILD_ROSTER_BUTTON_HEIGHT + GUILD_ROSTER_BUTTON_OFFSET);
  333. HybridScrollFrame_Update(scrollFrame, totalHeight, displayedHeight);
  334. end
  335. function GuildRosterButton_OnClick(self, button)
  336. if ( currentGuildView == "tradeskill" ) then
  337. local skillID, isCollapsed, iconTexture, headerName, numOnline, numVisible, numPlayers,
  338. playerDisplayName, playerFullName, class, online, zone, skill, classFileName, isMobile = GetGuildTradeSkillInfo(self.guildIndex);
  339. if ( button == "LeftButton" ) then
  340. if ( CanViewGuildRecipes(skillID) ) then
  341. GetGuildMemberRecipes(playerFullName, skillID);
  342. end
  343. else
  344. GuildRoster_ShowMemberDropDown(playerFullName, online, isMobile);
  345. end
  346. else
  347. if ( button == "LeftButton" ) then
  348. if ( GuildMemberDetailFrame:IsShown() and self.guildIndex == GuildFrame.selectedGuildMember ) then
  349. SetGuildRosterSelection(0);
  350. GuildFrame.selectedGuildMember = 0;
  351. PlaySound(SOUNDKIT.IG_CHARACTER_INFO_CLOSE);
  352. GuildMemberDetailFrame:Hide();
  353. else
  354. SetGuildRosterSelection(self.guildIndex);
  355. GuildFrame.selectedGuildMember = self.guildIndex;
  356. PlaySound(SOUNDKIT.IG_CHARACTER_INFO_OPEN);
  357. GuildFramePopup_Show(GuildMemberDetailFrame);
  358. CloseDropDownMenus();
  359. end
  360. GuildRoster_Update();
  361. else
  362. local fullName, rank, rankIndex, level, class, zone, note, officernote, online, isAway, classFileName, achievementPoints, achievementRank, isMobile, sorEligible, rep, guid = GetGuildRosterInfo(self.guildIndex);
  363. GuildRoster_ShowMemberDropDown(fullName, online, isMobile, guid);
  364. end
  365. end
  366. end
  367. function GuildRoster_ShowMemberDropDown(name, online, isMobile, guid)
  368. local initFunc = GuildMemberDropDown_Initialize;
  369. if ( not online and not isMobile ) then
  370. initFunc = GuildMemberOfflineDropDown_Initialize;
  371. end
  372. GuildMemberDropDown.name = name;
  373. GuildMemberDropDown.isMobile = isMobile;
  374. GuildMemberDropDown.initialize = initFunc;
  375. GuildMemberDropDown.guid = guid; --Not included on tradeskill pane
  376. ToggleDropDownMenu(1, nil, GuildMemberDropDown, "cursor");
  377. end
  378. function GuildMemberDropDown_Initialize()
  379. UnitPopup_ShowMenu(UIDROPDOWNMENU_OPEN_MENU, "GUILD", nil, GuildMemberDropDown.name, { guid = GuildMemberDropDown.guid });
  380. end
  381. function GuildMemberOfflineDropDown_Initialize()
  382. UnitPopup_ShowMenu(UIDROPDOWNMENU_OPEN_MENU, "GUILD_OFFLINE", nil, GuildMemberDropDown.name);
  383. end
  384. function GuildRoster_UpdateTradeSkills()
  385. local scrollFrame = GuildRosterContainer;
  386. local offset = HybridScrollFrame_GetOffset(scrollFrame);
  387. local buttons = scrollFrame.buttons;
  388. local numButtons = #buttons;
  389. local button, index, class;
  390. local numTradeSkill = GetNumGuildTradeSkill();
  391. for i = 1, numButtons do
  392. button = buttons[i];
  393. index = offset + i;
  394. if ( index <= numTradeSkill ) then
  395. button.guildIndex = index;
  396. local skillID, isCollapsed, iconTexture, headerName, numOnline, numVisible, numPlayers, playerDisplayName, playerFullName, class, online, zone, skill, classFileName, isMobile, isAway = GetGuildTradeSkillInfo(index);
  397. button.online = online;
  398. if ( headerName ) then
  399. GuildRosterButton_SetStringText(button.string1, headerName, 1);
  400. GuildRosterButton_SetStringText(button.string2, "", 1);
  401. GuildRosterButton_SetStringText(button.string3, numOnline, 1);
  402. button.header:Show();
  403. button:UnlockHighlight();
  404. button.header.icon:SetTexture(iconTexture);
  405. button.header.name:SetText(headerName);
  406. button.header.collapsed = isCollapsed;
  407. if ( numVisible == 0 ) then
  408. button.header:Disable();
  409. button.header.icon:SetDesaturated(true);
  410. button.header.collapsedIcon:Hide();
  411. button.header.expandedIcon:Hide();
  412. if ( numPlayers > 0 and CanViewGuildRecipes(skillID) ) then
  413. button.header.allRecipes:Show();
  414. else
  415. button.header.allRecipes:Hide();
  416. end
  417. button.header.name:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b);
  418. button.header.leftEdge:SetVertexColor(0.75, 0.75, 0.75);
  419. button.header.rightEdge:SetVertexColor(0.75, 0.75, 0.75);
  420. button.header.middle:SetVertexColor(0.75, 0.75, 0.75);
  421. else
  422. button.header:Enable();
  423. button.header.icon:SetDesaturated(false);
  424. if ( CanViewGuildRecipes(skillID) ) then
  425. button.header.allRecipes:Show();
  426. else
  427. button.header.allRecipes:Hide();
  428. end
  429. button.header.name:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b);
  430. button.header.leftEdge:SetVertexColor(1, 1, 1);
  431. button.header.rightEdge:SetVertexColor(1, 1, 1);
  432. button.header.middle:SetVertexColor(1, 1, 1);
  433. if ( isCollapsed ) then
  434. button.header.collapsedIcon:Show();
  435. button.header.expandedIcon:Hide();
  436. else
  437. button.header.expandedIcon:Show();
  438. button.header.collapsedIcon:Hide();
  439. end
  440. end
  441. button.header.skillID = skillID;
  442. button:Show();
  443. elseif ( playerDisplayName ) then
  444. if ( isMobile ) then
  445. if (isAway == 2) then
  446. playerDisplayName = MOBILE_BUSY_ICON..playerDisplayName;
  447. elseif (isAway == 1) then
  448. playerDisplayName = MOBILE_AWAY_ICON..playerDisplayName;
  449. else
  450. playerDisplayName = ChatFrame_GetMobileEmbeddedTexture(73/255, 177/255, 73/255)..playerDisplayName;
  451. end
  452. end
  453. local zoneText = zone;
  454. if(isMobile and not online) then zoneText = REMOTE_CHAT; end;
  455. GuildRosterButton_SetStringText(button.string1, playerDisplayName, online, classFileName);
  456. GuildRosterButton_SetStringText(button.string2, zoneText, online);
  457. GuildRosterButton_SetStringText(button.string3, "["..skill.."]", online);
  458. button.header:Hide();
  459. button:Show();
  460. else
  461. button:Hide();
  462. end
  463. if ( mod(index, 2) == 0 ) then
  464. button.stripe:SetTexCoord(0.36230469, 0.38183594, 0.95898438, 0.99804688);
  465. else
  466. button.stripe:SetTexCoord(0.51660156, 0.53613281, 0.88281250, 0.92187500);
  467. end
  468. else
  469. button:Hide();
  470. end
  471. end
  472. local totalHeight = numTradeSkill * (GUILD_ROSTER_BUTTON_HEIGHT + GUILD_ROSTER_BUTTON_OFFSET);
  473. local displayedHeight = numButtons * (GUILD_ROSTER_BUTTON_HEIGHT + GUILD_ROSTER_BUTTON_OFFSET);
  474. HybridScrollFrame_Update(scrollFrame, totalHeight, displayedHeight);
  475. end
  476. function GuildRosterTradeSkillHeader_OnClick(self)
  477. PlaySound(SOUNDKIT.IG_MAINMENU_OPTION_CHECKBOX_ON);
  478. if ( self.collapsed ) then
  479. ExpandGuildTradeSkillHeader(self.skillID);
  480. else
  481. CollapseGuildTradeSkillHeader(self.skillID);
  482. end
  483. end
  484. --****** Dropdown ***************************************************************
  485. function GuildRoster_SetView(view)
  486. if ( not view or not GUILD_ROSTER_COLUMNS[view] ) then
  487. view = "playerStatus";
  488. end
  489. local numColumns = #GUILD_ROSTER_COLUMNS[view];
  490. local stringsInfo = { };
  491. local stringOffset = 0;
  492. local haveIcon, haveBar;
  493. -- set up columns
  494. for columnIndex = 1, GUILD_ROSTER_MAX_COLUMNS do
  495. local columnButton = _G["GuildRosterColumnButton"..columnIndex];
  496. local columnType = GUILD_ROSTER_COLUMNS[view][columnIndex];
  497. if ( columnType ) then
  498. local columnData = GUILD_ROSTER_COLUMN_DATA[columnType];
  499. columnButton:SetText(columnData.text);
  500. WhoFrameColumn_SetWidth(columnButton, columnData.width);
  501. columnButton:Show();
  502. -- by default the sort type should be the same as the column type
  503. if ( columnData.sortType ) then
  504. columnButton.sortType = columnData.sortType;
  505. else
  506. columnButton.sortType = columnType;
  507. end
  508. if ( columnData.hasIcon ) then
  509. haveIcon = true;
  510. else
  511. -- store string data for processing
  512. columnData["stringOffset"] = stringOffset;
  513. table.insert(stringsInfo, columnData);
  514. end
  515. stringOffset = stringOffset + columnData.width - 2;
  516. haveBar = haveBar or columnData.hasBar;
  517. else
  518. columnButton:Hide();
  519. end
  520. end
  521. -- process the button strings
  522. local buttons = GuildRosterContainer.buttons;
  523. local button, fontString;
  524. for buttonIndex = 1, #buttons do
  525. button = buttons[buttonIndex];
  526. for stringIndex = 1, GUILD_ROSTER_MAX_STRINGS do
  527. fontString = button["string"..stringIndex];
  528. local stringData = stringsInfo[stringIndex];
  529. if ( stringData ) then
  530. -- want strings a little inside the columns, 6 pixels from the left and 8 from the right
  531. fontString:SetPoint("LEFT", stringData.stringOffset + GUILD_ROSTER_STRING_OFFSET, 0);
  532. fontString:SetWidth(stringData.width - GUILD_ROSTER_STRING_WIDTH_ADJ);
  533. fontString:SetJustifyH(stringData.stringJustify);
  534. fontString:Show();
  535. else
  536. fontString:Hide();
  537. end
  538. end
  539. if ( haveIcon ) then
  540. button.icon:Show();
  541. else
  542. button.icon:Hide();
  543. end
  544. if ( haveBar ) then
  545. button.barLabel:Show();
  546. -- button.barTexture:Show(); -- shown status determined in GuildRoster_Update
  547. else
  548. button.barLabel:Hide();
  549. button.barTexture:Hide();
  550. end
  551. button.header:Hide();
  552. end
  553. if ( view == "tradeskill" ) then
  554. GuildRoster_RecipeQueryCheck();
  555. end
  556. currentGuildView = view;
  557. end
  558. function GuildRosterViewDropdown_OnLoad(self)
  559. UIDropDownMenu_Initialize(self, GuildRosterViewDropdown_Initialize);
  560. UIDropDownMenu_SetWidth(GuildRosterViewDropdown, 150);
  561. end
  562. function GuildRosterViewDropdown_Initialize()
  563. local info = UIDropDownMenu_CreateInfo();
  564. info.func = GuildRosterViewDropdown_OnClick;
  565. info.text = PLAYER_STATUS;
  566. info.value = "playerStatus";
  567. UIDropDownMenu_AddButton(info);
  568. info.text = GUILD_STATUS;
  569. info.value = "guildStatus";
  570. UIDropDownMenu_AddButton(info);
  571. info.text = ACHIEVEMENT_POINTS;
  572. info.value = "achievement";
  573. UIDropDownMenu_AddButton(info);
  574. info.text = TRADE_SKILLS;
  575. info.value = "tradeskill";
  576. UIDropDownMenu_AddButton(info);
  577. info.text = GUILD_REPUTATION;
  578. info.value = "reputation";
  579. UIDropDownMenu_AddButton(info);
  580. UIDropDownMenu_SetSelectedValue(GuildRosterViewDropdown, currentGuildView);
  581. end
  582. function GuildRosterViewDropdown_OnClick(self)
  583. GuildRoster_SetView(self.value);
  584. C_GuildInfo.GuildRoster();
  585. GuildRoster_Update();
  586. SetCVar("guildRosterView", currentGuildView);
  587. UIDropDownMenu_SetSelectedValue(GuildRosterViewDropdown, currentGuildView);
  588. end
  589. --****** Promote/Demote *********************************************************
  590. function GuildFrameDemoteButton_OnClick(self)
  591. local memberIndex = GetGuildRosterSelection();
  592. local fullName, rank, rankIndex = GetGuildRosterInfo(memberIndex);
  593. local targetRank = rankIndex + 1; -- demoting increases rank index
  594. local validRank = GetDemotionRank(memberIndex);
  595. if ( validRank > targetRank ) then
  596. local badRankName = GuildControlGetRankName(targetRank + 1); -- GuildControlGetRankName uses 1-based index
  597. local goodRankName = GuildControlGetRankName(validRank + 1); -- GuildControlGetRankName uses 1-based index
  598. local dialog = StaticPopup_Show("GUILD_DEMOTE_CONFIRM", string.format(AUTHENTICATOR_CONFIRM_GUILD_DEMOTE, Ambiguate(fullName, "guild"), badRankName, goodRankName));
  599. dialog.data = fullName;
  600. else
  601. GuildDemote(GuildFrame.selectedName);
  602. PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON);
  603. GuildFrameDemoteButton:Disable();
  604. end
  605. end
  606. function GuildFramePromoteButton_OnClick(self)
  607. local memberIndex = GetGuildRosterSelection();
  608. local fullName, rank, rankIndex = GetGuildRosterInfo(memberIndex);
  609. local targetRank = rankIndex - 1; -- promoting decreases rank index
  610. local validRank = GetPromotionRank(memberIndex);
  611. if ( validRank < targetRank ) then
  612. local badRankName = GuildControlGetRankName(targetRank + 1); -- GuildControlGetRankName uses 1-based index
  613. local goodRankName = GuildControlGetRankName(validRank + 1); -- GuildControlGetRankName uses 1-based index
  614. local dialog = StaticPopup_Show("GUILD_PROMOTE_CONFIRM", string.format(AUTHENTICATOR_CONFIRM_GUILD_PROMOTE, Ambiguate(fullName, "guild"), badRankName, goodRankName));
  615. dialog.data = fullName;
  616. else
  617. GuildPromote(GuildFrame.selectedName);
  618. PlaySound(SOUNDKIT.U_CHAT_SCROLL_BUTTON);
  619. GuildFramePromoteButton:Disable();
  620. end
  621. end
  622. function GuildMemberRankDropdown_OnLoad(self)
  623. UIDropDownMenu_Initialize(self, GuildMemberRankDropdown_Initialize);
  624. UIDropDownMenu_SetWidth(GuildMemberRankDropdown, 159 - GuildMemberDetailRankLabel:GetWidth());
  625. UIDropDownMenu_JustifyText(GuildMemberRankDropdown, "LEFT");
  626. end
  627. function GuildMemberRankDropdown_Initialize(self)
  628. local numRanks = GuildControlGetNumRanks();
  629. local memberIndex = GetGuildRosterSelection();
  630. local _, _, memberRankIndex = GetGuildRosterInfo(GetGuildRosterSelection());
  631. memberRankIndex = memberRankIndex + 1; -- adjust to 1-based
  632. local _, _, userRankIndex = GetGuildInfo("player");
  633. userRankIndex = userRankIndex + 1; -- adjust to 1-based
  634. local highestRank = userRankIndex + 1;
  635. if not ( CanGuildPromote() ) then
  636. highestRank = memberRankIndex;
  637. end
  638. local lowestRank = numRanks;
  639. if not ( CanGuildDemote() ) then
  640. lowestRank = memberRankIndex;
  641. end
  642. for listRank = highestRank, lowestRank do
  643. local info = UIDropDownMenu_CreateInfo();
  644. info.text = GuildControlGetRankName(listRank);
  645. info.func = GuildMemberRankDropdown_OnClick;
  646. info.checked = listRank == memberRankIndex;
  647. info.value = listRank;
  648. info.arg1 = listRank;
  649. -- check
  650. if ( not info.checked ) then
  651. local allowed, reason = IsGuildRankAssignmentAllowed(memberIndex, listRank);
  652. if ( not allowed and reason == "authenticator" ) then
  653. info.disabled = true;
  654. info.tooltipWhileDisabled = 1;
  655. info.tooltipTitle = GUILD_RANK_UNAVAILABLE;
  656. info.tooltipText = GUILD_RANK_UNAVAILABLE_AUTHENTICATOR;
  657. info.tooltipOnButton = 1;
  658. end
  659. end
  660. UIDropDownMenu_AddButton(info);
  661. end
  662. end
  663. function GuildMemberRankDropdown_OnClick(self, newRankIndex)
  664. local fullName, rank, rankIndex = GetGuildRosterInfo(GetGuildRosterSelection());
  665. rankIndex = rankIndex + 1;
  666. if ( rankIndex ~= newRankIndex ) then
  667. SetGuildMemberRank(GetGuildRosterSelection(), newRankIndex);
  668. end
  669. end