vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | BIB_MONKEYQUEST_ID = "MonkeyQuest"; |
2 | BIB_MONKEYQUEST_ICON_PATH = "Interface\\AddOns\\MonkeyLibrary\\Textures\\MonkeyBuddyIcon"; |
||
3 | BIB_MONKEYQUEST_ICON_SIZE = 16; |
||
4 | |||
5 | function BIB_MonkeyQuestButton_OnLoad() |
||
6 | -- register events |
||
7 | this:RegisterEvent("VARIABLES_LOADED"); |
||
8 | |||
9 | BM_Plugin("BIB_MonkeyQuestButton", "MonkeyQuest", BIB_MONKEYQUEST_ICON_SIZE, "MonkeyQuest"); |
||
10 | |||
11 | DEFAULT_CHAT_FRAME:AddMessage("BIB_MonkeyQuestButton loaded"); |
||
12 | end |
||
13 | |||
14 | function BIB_MonkeyQuestButton_OnEvent() |
||
15 | if (event == "VARIABLES_LOADED") then |
||
16 | BIB_MonkeyQuestButton_Initialize(); |
||
17 | --TitanPanelButtonBRL_SetIcon(); |
||
18 | end |
||
19 | end |
||
20 | |||
21 | function BIB_MonkeyQuestButton_GetButtonText() |
||
22 | if (not IsAddOnLoaded("BhaldieInfoBar")) then |
||
23 | return; |
||
24 | end |
||
25 | |||
26 | if (TitanGetVar(BIB_MONKEYQUEST_ID, "ShowLabelText")) then |
||
27 | |||
28 | local iNumEntries, iNumQuests = GetNumQuestLogEntries(); |
||
29 | |||
30 | |||
31 | if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bShowNumQuests == true) then |
||
32 | |||
33 | if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bHideTitle == false) then |
||
34 | BIB_MonkeyQuestButtonText:SetText(MONKEYQUEST_TITLE .. " " .. iNumQuests .. "/" .. MAX_QUESTLOG_QUESTS); |
||
35 | else |
||
36 | BIB_MonkeyQuestButtonText:SetText(iNumQuests .. "/" .. MAX_QUESTLOG_QUESTS); |
||
37 | end |
||
38 | |||
39 | elseif (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bHideTitle == false) then |
||
40 | BIB_MonkeyQuestButtonText:SetText(MONKEYQUEST_TITLE); |
||
41 | else |
||
42 | BIB_MonkeyQuestButtonText:SetText(""); |
||
43 | end |
||
44 | |||
45 | |||
46 | else |
||
47 | BIB_MonkeyQuestButtonText:SetText(); |
||
48 | end |
||
49 | end |
||
50 | |||
51 | function BIB_RightClickMenu_PrepareMonkeyQuestMenu() |
||
52 | local info; |
||
53 | |||
54 | TitanPanelRightClickMenu_AddTitle(MONKEYQUEST_TITLE); |
||
55 | |||
56 | |||
57 | info = {}; |
||
58 | info.text = "Lock to BIB"; |
||
59 | info.func = BIB_MonkeyQuestButton_ToggleLockBIB; |
||
60 | info.checked = MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bLockBIB; |
||
61 | UIDropDownMenu_AddButton(info); |
||
62 | |||
63 | TitanPanelRightClickMenu_AddSpacer(); |
||
64 | |||
65 | |||
66 | TitanPanelRightClickMenu_AddToggleLabelText(BIB_MONKEYQUEST_ID); |
||
67 | TitanPanelRightClickMenu_AddToggleIcon(BIB_MONKEYQUEST_ID); |
||
68 | |||
69 | end |
||
70 | |||
71 | function BIB_MonkeyQuestButton_Initialize() |
||
72 | -- This is the list of the saved vars used, values can be true, false, number, text whatever you want to save. |
||
73 | savedVariables = { |
||
74 | [1] = {name = "ShowIcon", value = true}, |
||
75 | [2] = {name = "ShowLabelText", value = true}, |
||
76 | } |
||
77 | -- Function to Initialize the saved vars if they don't exisit create them if they do exisits SWEET!! |
||
78 | for key, value in savedVariables do |
||
79 | BM_Initialize_Variables(BIB_MONKEYQUEST_ID, value.name, value.value); |
||
80 | end |
||
81 | -- Creates the Dropdown menu |
||
82 | UIDropDownMenu_Initialize(BIB_MonkeyQuestButtonRightClickMenu, BIB_RightClickMenu_PrepareMonkeyQuestMenu, "Menu"); |
||
83 | |||
84 | -- Initialize the icon |
||
85 | BIB_MonkeyQuestButton_SetIcon(); |
||
86 | |||
87 | BIB_MonkeyQuestButtonText:SetFont("Interface\\AddOns\\MonkeyLibrary\\Fonts\\adventure.ttf", BHINFOBAR_CONFIG[BM_PLAYERNAME_REALM].plugin_fontsize); |
||
88 | BIB_MonkeyQuestButtonText:SetTextColor(MONKEYLIB_TITLE_COLOUR.r, MONKEYLIB_TITLE_COLOUR.g, MONKEYLIB_TITLE_COLOUR.b); |
||
89 | |||
90 | -- initial text |
||
91 | BIB_MonkeyQuestButton_GetButtonText() |
||
92 | end |
||
93 | |||
94 | --Sets the icon to where its suppose to be if no icon skips this function |
||
95 | function BIB_MonkeyQuestButton_SetIcon() |
||
96 | local icon1 = BIB_MonkeyQuestButtonIcon; |
||
97 | |||
98 | if (TitanGetVar(BIB_MONKEYQUEST_ID, "ShowIcon")) then |
||
99 | icon1:SetTexture(BIB_MONKEYQUEST_ICON_PATH); |
||
100 | icon1:SetWidth(BIB_MONKEYQUEST_ICON_SIZE); |
||
101 | icon1:SetHeight(BIB_MONKEYQUEST_ICON_SIZE); |
||
102 | else |
||
103 | icon1:SetTexture(""); |
||
104 | icon1:SetWidth(1); |
||
105 | end |
||
106 | end |
||
107 | |||
108 | --This function is in every plugin always the same except for the 2 varables |
||
109 | function BIB_MonkeyQuestButton_OnEnter() |
||
110 | |||
111 | |||
112 | if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bLockBIB == true) then |
||
113 | -- testing |
||
114 | MonkeyQuest_Show(); |
||
115 | |||
116 | -- todo: figure out where the button is... |
||
117 | MonkeyQuestFrame:ClearAllPoints(); |
||
118 | |||
119 | if (BIB_MonkeyQuestButton:GetLeft() > 512) then |
||
120 | -- on the right |
||
121 | if (BIB_MonkeyQuestButton:GetTop() > 384) then |
||
122 | -- on the top |
||
123 | MonkeyQuestFrame:SetPoint("TOPRIGHT", "BIB_MonkeyQuestButton", "BOTTOMRIGHT", 0, 0); |
||
124 | MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_strAnchor = "ANCHOR_BOTTOMLEFT"; |
||
125 | else |
||
126 | MonkeyQuestFrame:SetPoint("BOTTOMRIGHT", "BIB_MonkeyQuestButton", "TOPRIGHT", 0, 0); |
||
127 | MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_strAnchor = "ANCHOR_TOPLEFT"; |
||
128 | end |
||
129 | else |
||
130 | -- on the left |
||
131 | if (BIB_MonkeyQuestButton:GetTop() > 384) then |
||
132 | -- on the top |
||
133 | MonkeyQuestFrame:SetPoint("TOPLEFT", "BIB_MonkeyQuestButton", "BOTTOMLEFT", 0, 0); |
||
134 | MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_strAnchor = "ANCHOR_BOTTOMRIGHT"; |
||
135 | else |
||
136 | MonkeyQuestFrame:SetPoint("BOTTOMLEFT", "BIB_MonkeyQuestButton", "TOPLEFT", 0, 0); |
||
137 | MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_strAnchor = "ANCHOR_TOPRIGHT"; |
||
138 | end |
||
139 | end |
||
140 | end |
||
141 | end |
||
142 | |||
143 | --This function is in every plugin always the same |
||
144 | function BIB_MonkeyQuestButton_OnLeave() |
||
145 | |||
146 | end |
||
147 | |||
148 | --This function is in every plugin always the same |
||
149 | function BIB_MonkeyQuestButton_OnRightClick(button) |
||
150 | if (button == "RightButton") then |
||
151 | ToggleDropDownMenu(1, nil, getglobal(this:GetName().."RightClickMenu"), this:GetName(), 0, 0); |
||
152 | GameTooltip_SetDefaultAnchor(GameTooltip, UIParent); |
||
153 | GameTooltip:Hide(); |
||
154 | end |
||
155 | end |
||
156 | |||
157 | function BIB_MonkeyQuestButton_ToggleLockBIB() |
||
158 | MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bLockBIB = not MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bLockBIB; |
||
159 | BIB_MonkeyQuestButton_GetButtonText(); |
||
160 | |||
161 | if (MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_bLockBIB == true) then |
||
162 | MonkeyQuest_Hide(); |
||
163 | else |
||
164 | MonkeyQuestConfig[MonkeyQuest.m_strPlayer].m_strAnchor = "ANCHOR_TOPLEFT"; |
||
165 | MonkeyQuest_Show(); |
||
166 | end |
||
167 | end |