Skip to content
Browse files

Tooltips and Update Button

Added tooltips for addon info when mousing over buttons
Added update button to easily update profiles
  • Loading branch information...
1 parent eb87568 commit b01f2ad81f90446424fbeee9a6d042a655a10692 @Safturento committed Nov 29, 2012
Showing with 33 additions and 18 deletions.
  1. +17 −14 stAddonManager/profiles.lua
  2. +15 −3 stAddonManager/stAddonManager.lua
  3. +1 −1 stAddonManager/stAddonManager.toc
View
31 stAddonManager/profiles.lua
@@ -13,12 +13,11 @@ StaticPopupDialogs['STADDONMANAGER_OVERWRITEPROFILE'] = {
preferredIndex = 3,
}
-function stAM.NewAddonProfile(self, popup, overwrite)
- local name = popup.editBox:GetText()
+function stAM:NewAddonProfile(name, overwrite)
if stAM_Profiles[name] and (not overwrite) then
local dialog = StaticPopupDialogs['STADDONMANAGER_OVERWRITEPROFILE']
- dialog.text = 'There is already a profile named ' .. name .. '. DO you want to overwrite it?'
- dialog.OnAccept = function(self) stAM:NewAddonProfile(popup, true) end
+ dialog.text = 'There is already a profile named ' .. name .. '. Do you want to overwrite it?'
+ dialog.OnAccept = function(self) stAM:NewAddonProfile(name, true) end
StaticPopup_Show('STADDONMANAGER_OVERWRITEPROFILE')
return end
@@ -43,29 +42,29 @@ StaticPopupDialogs['STADDONMANAGER_NEWPROFILE'] = {
hasEditBox = true,
whileDead = true,
hideOnEscape = true,
- OnAccept = function(self) stAM:NewAddonProfile(self) end,
+ OnAccept = function(self) stAM:NewAddonProfile(self.editBox:GetText()) end,
preferredIndex = 3,
}
-function stAM.InitProfiles(self)
+function stAM:InitProfiles()
if self.profileMenu then return end
local profileMenu = CreateFrame('Frame', self:GetName()..'_ProfileMenu', self)
profileMenu:SetPoint('TOPLEFT', self.profiles, 'TOPRIGHT', 9, 0)
- profileMenu:SetSize(225, 50)
+ profileMenu:SetSize(250, 50)
profileMenu:SetTemplate()
profileMenu:SetFrameLevel(self:GetFrameLevel()-1)
----------------------------------------------------
-- PULLOUT MENU ------------------------------------
----------------------------------------------------
local pullout = CreateFrame('Frame', profileMenu:GetName()..'_PulloutMenu', profileMenu)
- pullout:SetWidth(stAM:GetWidth() - stAM.buttonWidth - 45)
+ pullout:SetWidth(profileMenu:GetWidth() - stAM.buttonWidth - 40)
pullout:SetHeight(stAM.buttonHeight)
pullout:Hide()
--[[ "SET TO" BUTTON ]]
- pullout.setTo = st.CreateButton(profileMenu:GetName()..'_SetToButton', pullout, (pullout:GetWidth()-10)/3, stAM.buttonHeight, {'LEFT', pullout, 0, 0}, 'Set To', function(self, btn)
+ pullout.setTo = st.CreateButton(profileMenu:GetName()..'_SetToButton', pullout, pullout:GetWidth()/4, stAM.buttonHeight, {'LEFT', pullout, 0, 0}, 'Set To', function(self, btn)
local profileName = self:GetParent():GetParent().text:GetText()
--if shift key is pressed, don't disable current addons
if not IsShiftKeyDown() then
@@ -79,7 +78,7 @@ function stAM.InitProfiles(self)
end)
--[[ "REMOVE FROM" BUTTON ]]
- pullout.removeFrom = st.CreateButton(profileMenu:GetName()..'_RemoveButton', pullout, (pullout:GetWidth()-10)/3, stAM.buttonHeight, {'LEFT', pullout.setTo, 'RIGHT', 5, 0}, 'Remove', function(self, btn)
+ pullout.removeFrom = st.CreateButton(profileMenu:GetName()..'_RemoveButton', pullout, pullout:GetWidth()/4, stAM.buttonHeight, {'LEFT', pullout.setTo, 'RIGHT', 5, 0}, 'Remove', function(self, btn)
local profileName = self:GetParent():GetParent().text:GetText()
for _,addonName in pairs(stAM_Profiles[profileName]) do
DisableAddOn(addonName)
@@ -102,19 +101,23 @@ function stAM.InitProfiles(self)
}
--[[ "DELETE PROFILE" BUTTON ]]
- pullout.deleteProfile = st.CreateButton(profileMenu:GetName().."_DeleteProfileButton", pullout, (pullout:GetWidth()-10)/3, stAM.buttonHeight, {'LEFT', pullout.removeFrom, 'RIGHT', 5, 0}, 'Delete', function(self, btn)
+ pullout.deleteProfile = st.CreateButton(profileMenu:GetName().."_DeleteProfileButton", pullout, pullout:GetWidth()/4, stAM.buttonHeight, {'LEFT', pullout.removeFrom, 'RIGHT', 5, 0}, 'Delete', function(self, btn)
local profileName = self:GetParent():GetParent().text:GetText()
local dialog = StaticPopupDialogs['STADDONMANAGER_DELETECONFIRMATION']
--Modify static popup information to specific button
- dialog.text = "Are you sure you want to delete "..profileName.."?"
+ dialog.text = format("Are you sure you want to delete %s?", profileName)
dialog.OnAccept = function(self, data, data2)
stAM_Profiles[profileName] = nil
stAM:UpdateProfiles()
end
StaticPopup_Show('STADDONMANAGER_DELETECONFIRMATION')
end)
+ pullout.updateprofile = st.CreateButton(profileMenu:GetName().."_UpdateProfileButton", pullout, pullout:GetWidth()/4, stAM.buttonHeight, {'LEFT', pullout.deleteProfile, 'RIGHT', 5, 0}, 'Update', function(self, btn)
+ stAM:NewAddonProfile(self:GetParent():GetParent().text:GetText(), true)
+ end)
+
--[[ ANCHOR FUNCTION - Used to change which button the pullout is set to ]]
pullout.AnchorToButton = function(self, button)
local profileName = button.text:GetText()
@@ -162,7 +165,7 @@ function stAM.InitProfiles(self)
self.profileMenu = profileMenu
end
-function stAM.UpdateProfiles(self)
+function stAM:UpdateProfiles()
local profiles = {}
local profileMenu = self.profileMenu
local buttons = self.profileMenu.buttons
@@ -219,7 +222,7 @@ function stAM.UpdateProfiles(self)
profileMenu:SetHeight((#profiles+2)*(stAM.buttonHeight+5) + 15)
end
-function stAM.ToggleProfiles(self)
+function stAM:ToggleProfiles()
if not self.profileMenu then
self:InitProfiles()
else
View
18 stAddonManager/stAddonManager.lua
@@ -96,15 +96,27 @@ function stAM.UpdateAddonList(self)
self.addons.buttons[i] = btn
button = self.addons.buttons[i]
end
-
-
-
--Check if an addon actually exists to place on this button (and hide the button if there isn't an addon to show)
if addonIndex <= GetNumAddOns() then
local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(addonIndex)
+ local requireddeps, optionaldeps = GetAddOnDependencies(addonIndex), GetAddOnOptionalDependencies(addonIndex)
button.text:SetText(title)
button:Show()
button:SetChecked(enabled)
+ button:SetScript('OnEnter', function()
+ GameTooltip:SetOwner(button, 'ANCHOR_CURSOR')
+ GameTooltip:ClearLines()
+ GameTooltip:AddLine(title)
+ GameTooltip:AddLine(notes)
+ if requireddeps then
+ GameTooltip:AddDoubleLine('Required Dependencies', requireddeps)
+ end
+ if optionaldeps then
+ GameTooltip:AddDoubleLine('Optional Dependencies', optionaldeps)
+ end
+ GameTooltip:Show()
+ end)
+ button:HookScript('Onleave', function() GameTooltip:Hide() end)
button:SetScript("OnClick", function()
if enabled then
DisableAddOn(name)
View
2 stAddonManager/stAddonManager.toc
@@ -1,6 +1,6 @@
## Interface: 50001
## Author: Safturento
-## Version: 1.2.3
+## Version: 1.2.5
## Title: |cff00aaffst|rAddonManager
## Notes: A simple and minimalistic addon to disable/enabled addons without logging out.
## OptionalDependencies: Tukui, ElvUI, Aurora

0 comments on commit b01f2ad

Please sign in to comment.
Something went wrong with that request. Please try again.