vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_RATab_AutoPromotions = { };
2  
3 UnitPopupButtons["CTRAID_DEFAULT_LOOT_TYPE"] = { text = "Default Loot Type", dist = 0, nested = 1 };
4 UnitPopupButtons["CTRAID_LOOTMETHOD_FREEFORALL"] = { text = TEXT(LOOT_FREE_FOR_ALL), dist = 0 };
5 UnitPopupButtons["CTRAID_LOOTMETHOD_ROUNDROBIN"] = { text = TEXT(LOOT_ROUND_ROBIN), dist = 0 };
6 UnitPopupButtons["CTRAID_LOOTMETHOD_MASTER"] = { text = TEXT(LOOT_MASTER_LOOTER), dist = 0 };
7 UnitPopupButtons["CTRAID_LOOTMETHOD_GROUP"] = { text = TEXT(LOOT_GROUP_LOOT), dist = 0 };
8 UnitPopupButtons["CTRAID_LOOTMETHOD_NEEDBEFOREGREED"] = { text = TEXT(LOOT_NEED_BEFORE_GREED), dist = 0 };
9 UnitPopupMenus["CTRAID_DEFAULT_LOOT_TYPE"] = { "CTRAID_LOOTMETHOD_FREEFORALL", "CTRAID_LOOTMETHOD_ROUNDROBIN", "CTRAID_LOOTMETHOD_MASTER", "CTRAID_LOOTMETHOD_GROUP", "CTRAID_LOOTMETHOD_NEEDBEFOREGREED", "CANCEL" };
10 NEWBIE_TOOLTIP_UNIT_CTRAID_LOOTMETHOD_FREEFORALL = "Set the default loot type to Free for All, which will make CT_RaidAssist automatically set your loot type to the selected option upon creating a raid.";
11 NEWBIE_TOOLTIP_UNIT_CTRAID_LOOTMETHOD_ROUNDROBIN = "Set the default loot type to Round Robin, which will make CT_RaidAssist automatically set your loot type to the selected option upon creating a raid.";
12 NEWBIE_TOOLTIP_UNIT_CTRAID_LOOTMETHOD_MASTER = "Set the default loot type to Master Looter, which will make CT_RaidAssist automatically set your loot type to the selected option upon creating a raid.";
13 NEWBIE_TOOLTIP_UNIT_CTRAID_LOOTMETHOD_GROUP = "Set the default loot type to Group Loot, which will make CT_RaidAssist automatically set your loot type to the selected option upon creating a raid.";
14 NEWBIE_TOOLTIP_UNIT_CTRAID_LOOTMETHOD_NEEDBEFOREGREED = "Set the default loot type to Need Before Greed, which will make CT_RaidAssist automatically set your loot type to the selected option upon creating a raid.";
15 tinsert(UnitPopupMenus["SELF"], getn(UnitPopupMenus["SELF"]), "CTRAID_DEFAULT_LOOT_TYPE");
16 tinsert(UnitPopupShown, 1);
17 local lootTypeTable = UnitPopupMenus["CTRAID_DEFAULT_LOOT_TYPE"];
18  
19 local oldUnitPopup_OnClick = UnitPopup_OnClick;
20 function UnitPopup_OnClick()
21 local button = this.value;
22 oldUnitPopup_OnClick();
23 if ( strsub(button, 1, 17) == "CTRAID_LOOTMETHOD" ) then
24 local id = this:GetID();
25 CT_RATab_DefaultLootMethod = id;
26 if ( CT_RA_Level >= 2 and GetNumRaidMembers() > 0 ) then
27 local lootType = strsub(button, 19);
28 if ( lootType == "MASTER" ) then
29 SetLootMethod(lootType, UnitName("player"));
30 else
31 SetLootMethod(lootType);
32 end
33 end
34 end
35 end
36 local metaFunction = function(tbl, key, val)
37 if ( key == "selectedLootMethod" and type(tbl) == "table" ) then
38 local defaultLoot = CT_RATab_DefaultLootMethod or 4;
39 if ( defaultLoot ) then
40 local k, v = next(lootTypeTable);
41 for i = 1, (defaultLoot-1) do
42 k, v = next(lootTypeTable, k);
43 end
44 rawset(tbl, "selectedLootMethod", UnitPopupButtons[v].text);
45 return;
46 end
47 end
48 rawset(tbl, key, val);
49 end
50  
51 local oldUnitPopup_ShowMenu = UnitPopup_ShowMenu;
52 function UnitPopup_ShowMenu(dropdownMenu, which, unit, name, userData)
53 local metatable = getmetatable(dropdownMenu);
54 if ( UIDROPDOWNMENU_MENU_LEVEL == 2 and UIDROPDOWNMENU_MENU_VALUE == "CTRAID_DEFAULT_LOOT_TYPE" ) then
55 dropdownMenu.selectedLootMethod = nil;
56 metatable.__newindex = metaFunction;
57 else
58 dropdownMenu.selectedLootMethod = UnitLootMethod[GetLootMethod()].text;
59 metatable.__newindex = nil;
60 end
61 oldUnitPopup_ShowMenu(dropdownMenu, which, unit, name, userData);
62 end
63  
64 local oldUnitPopup_HideButtons = UnitPopup_HideButtons;
65 function UnitPopup_HideButtons()
66 oldUnitPopup_HideButtons();
67 local dropdownMenu = getglobal(UIDROPDOWNMENU_INIT_MENU);
68 if ( GetNumPartyMembers() == 0 ) then
69 for index, value in UnitPopupMenus[dropdownMenu.which] do
70 if ( value == "CTRAID_DEFAULT_LOOT_TYPE" ) then
71 UnitPopupShown[index] = 0;
72 return;
73 end
74 end
75 end
76 end
77  
78  
79 function CT_RATab_newRaidFrameDropDown_Initialize()
80 UnitPopup_ShowMenu(getglobal(UIDROPDOWNMENU_OPEN_MENU), "RAID", this.unit, this.name, this.id);
81 local info = {};
82 info.text = "Auto-Promote";
83 info.tooltipTitle = "Auto-Promote";
84 info.tooltipText = "When checked, this player is automatically promoted when he or she joins the raid.";
85 info.checked = CT_RATab_AutoPromotions[this.name];
86 info.value = this.id;
87 info.func = CT_RATab_AutoPromote_OnClick;
88 UIDropDownMenu_AddButton(info);
89 end
90  
91 function CT_RATab_AutoPromote_OnClick()
92 local name, rank = GetRaidRosterInfo(this.value);
93 CT_RATab_AutoPromotions[name] = not CT_RATab_AutoPromotions[name];
94 if ( CT_RA_Level and CT_RA_Level >= 2 and CT_RATab_AutoPromotions[name] and rank < 1 ) then
95 PromoteToAssistant(name);
96 CT_RA_Print("<CTRaid> Auto-Promoted |c00FFFFFF" .. name .. "|r.", 1, 0.5, 0);
97 end
98 end