diff --git a/SX_Databar.toc b/SX_Databar.toc new file mode 100644 index 0000000..4394b85 --- /dev/null +++ b/SX_Databar.toc @@ -0,0 +1,20 @@ +## Interface: 60200 +## Title: SX_Databar +## Author: |cff00FF99Saxitoxin +## Notes: Adds a bottombar by the request of |cffffffffu/sammojo|r on Reddit, Icons made by |cffffffffu/sammojo|r +## SavedVariables: TEST_CONFIG + +settings.lua + +modules\config.lua +modules\social.lua +modules\micromenu.lua +modules\armor.lua +modules\talent.lua +modules\clock.lua +modules\tradeskill.lua +modules\currency.lua +modules\performance.lua +modules\system.lua +modules\gold.lua +modules\heartstone.lua \ No newline at end of file diff --git a/media/datatexts/anchor.png b/media/datatexts/anchor.png new file mode 100644 index 0000000..521fcc3 Binary files /dev/null and b/media/datatexts/anchor.png differ diff --git a/media/datatexts/exp.tga b/media/datatexts/exp.tga new file mode 100644 index 0000000..6000322 Binary files /dev/null and b/media/datatexts/exp.tga differ diff --git a/media/datatexts/fps.tga b/media/datatexts/fps.tga new file mode 100644 index 0000000..8a3204f Binary files /dev/null and b/media/datatexts/fps.tga differ diff --git a/media/datatexts/garr.tga b/media/datatexts/garr.tga new file mode 100644 index 0000000..2b7308a Binary files /dev/null and b/media/datatexts/garr.tga differ diff --git a/media/datatexts/garres.tga b/media/datatexts/garres.tga new file mode 100644 index 0000000..29fdd8e Binary files /dev/null and b/media/datatexts/garres.tga differ diff --git a/media/datatexts/gold.tga b/media/datatexts/gold.tga new file mode 100644 index 0000000..30c68b7 Binary files /dev/null and b/media/datatexts/gold.tga differ diff --git a/media/datatexts/hearth.tga b/media/datatexts/hearth.tga new file mode 100644 index 0000000..e09fd4e Binary files /dev/null and b/media/datatexts/hearth.tga differ diff --git a/media/datatexts/honor.tga b/media/datatexts/honor.tga new file mode 100644 index 0000000..c9930e5 Binary files /dev/null and b/media/datatexts/honor.tga differ diff --git a/media/datatexts/ping.tga b/media/datatexts/ping.tga new file mode 100644 index 0000000..58921fa Binary files /dev/null and b/media/datatexts/ping.tga differ diff --git a/media/datatexts/repair.tga b/media/datatexts/repair.tga new file mode 100644 index 0000000..768200c Binary files /dev/null and b/media/datatexts/repair.tga differ diff --git a/media/datatexts/reroll.tga b/media/datatexts/reroll.tga new file mode 100644 index 0000000..d7e22ae Binary files /dev/null and b/media/datatexts/reroll.tga differ diff --git a/media/datatexts/seal.tga b/media/datatexts/seal.tga new file mode 100644 index 0000000..3239d9f Binary files /dev/null and b/media/datatexts/seal.tga differ diff --git a/media/datatexts/shipcomp.tga b/media/datatexts/shipcomp.tga new file mode 100644 index 0000000..ef67c9d Binary files /dev/null and b/media/datatexts/shipcomp.tga differ diff --git a/media/homizio_bold.ttf b/media/homizio_bold.ttf new file mode 100644 index 0000000..e9618b8 Binary files /dev/null and b/media/homizio_bold.ttf differ diff --git a/media/microbar/ach.tga b/media/microbar/ach.tga new file mode 100644 index 0000000..7f27dce Binary files /dev/null and b/media/microbar/ach.tga differ diff --git a/media/microbar/char.tga b/media/microbar/char.tga new file mode 100644 index 0000000..846c259 Binary files /dev/null and b/media/microbar/char.tga differ diff --git a/media/microbar/chat.tga b/media/microbar/chat.tga new file mode 100644 index 0000000..4296bbb Binary files /dev/null and b/media/microbar/chat.tga differ diff --git a/media/microbar/guild.tga b/media/microbar/guild.tga new file mode 100644 index 0000000..75a2583 Binary files /dev/null and b/media/microbar/guild.tga differ diff --git a/media/microbar/help.tga b/media/microbar/help.tga new file mode 100644 index 0000000..56a091e Binary files /dev/null and b/media/microbar/help.tga differ diff --git a/media/microbar/journal.tga b/media/microbar/journal.tga new file mode 100644 index 0000000..8ace558 Binary files /dev/null and b/media/microbar/journal.tga differ diff --git a/media/microbar/lfg.tga b/media/microbar/lfg.tga new file mode 100644 index 0000000..6c80738 Binary files /dev/null and b/media/microbar/lfg.tga differ diff --git a/media/microbar/menu.tga b/media/microbar/menu.tga new file mode 100644 index 0000000..466f0d2 Binary files /dev/null and b/media/microbar/menu.tga differ diff --git a/media/microbar/pet.tga b/media/microbar/pet.tga new file mode 100644 index 0000000..a503c75 Binary files /dev/null and b/media/microbar/pet.tga differ diff --git a/media/microbar/pvp.tga b/media/microbar/pvp.tga new file mode 100644 index 0000000..c359b76 Binary files /dev/null and b/media/microbar/pvp.tga differ diff --git a/media/microbar/quest.tga b/media/microbar/quest.tga new file mode 100644 index 0000000..d2c932d Binary files /dev/null and b/media/microbar/quest.tga differ diff --git a/media/microbar/shop.tga b/media/microbar/shop.tga new file mode 100644 index 0000000..a1b0c57 Binary files /dev/null and b/media/microbar/shop.tga differ diff --git a/media/microbar/social.tga b/media/microbar/social.tga new file mode 100644 index 0000000..5ab130b Binary files /dev/null and b/media/microbar/social.tga differ diff --git a/media/microbar/spell.tga b/media/microbar/spell.tga new file mode 100644 index 0000000..76cdfa9 Binary files /dev/null and b/media/microbar/spell.tga differ diff --git a/media/microbar/talent.tga b/media/microbar/talent.tga new file mode 100644 index 0000000..db094a8 Binary files /dev/null and b/media/microbar/talent.tga differ diff --git a/media/profession/alchemy.tga b/media/profession/alchemy.tga new file mode 100644 index 0000000..e3d98bd Binary files /dev/null and b/media/profession/alchemy.tga differ diff --git a/media/profession/blacksmithing.tga b/media/profession/blacksmithing.tga new file mode 100644 index 0000000..8c7f024 Binary files /dev/null and b/media/profession/blacksmithing.tga differ diff --git a/media/profession/enchanting.tga b/media/profession/enchanting.tga new file mode 100644 index 0000000..ec69007 Binary files /dev/null and b/media/profession/enchanting.tga differ diff --git a/media/profession/engineering.tga b/media/profession/engineering.tga new file mode 100644 index 0000000..6c27090 Binary files /dev/null and b/media/profession/engineering.tga differ diff --git a/media/profession/herbalism.tga b/media/profession/herbalism.tga new file mode 100644 index 0000000..870328e Binary files /dev/null and b/media/profession/herbalism.tga differ diff --git a/media/profession/inscription.tga b/media/profession/inscription.tga new file mode 100644 index 0000000..48429b0 Binary files /dev/null and b/media/profession/inscription.tga differ diff --git a/media/profession/jewelcrafting.tga b/media/profession/jewelcrafting.tga new file mode 100644 index 0000000..52493c9 Binary files /dev/null and b/media/profession/jewelcrafting.tga differ diff --git a/media/profession/leatherworking.tga b/media/profession/leatherworking.tga new file mode 100644 index 0000000..b986a8e Binary files /dev/null and b/media/profession/leatherworking.tga differ diff --git a/media/profession/major.tga b/media/profession/major.tga new file mode 100644 index 0000000..bd0ed38 Binary files /dev/null and b/media/profession/major.tga differ diff --git a/media/profession/mining.tga b/media/profession/mining.tga new file mode 100644 index 0000000..0ea836a Binary files /dev/null and b/media/profession/mining.tga differ diff --git a/media/profession/minor.tga b/media/profession/minor.tga new file mode 100644 index 0000000..d0be183 Binary files /dev/null and b/media/profession/minor.tga differ diff --git a/media/profession/skinning.tga b/media/profession/skinning.tga new file mode 100644 index 0000000..3c42d4c Binary files /dev/null and b/media/profession/skinning.tga differ diff --git a/media/profession/tailoring.tga b/media/profession/tailoring.tga new file mode 100644 index 0000000..6a13e9e Binary files /dev/null and b/media/profession/tailoring.tga differ diff --git a/media/spec/DEATHKNIGHT.tga b/media/spec/DEATHKNIGHT.tga new file mode 100644 index 0000000..70e7805 Binary files /dev/null and b/media/spec/DEATHKNIGHT.tga differ diff --git a/media/spec/DRUID.tga b/media/spec/DRUID.tga new file mode 100644 index 0000000..652565d Binary files /dev/null and b/media/spec/DRUID.tga differ diff --git a/media/spec/HUNTER.tga b/media/spec/HUNTER.tga new file mode 100644 index 0000000..52b23d6 Binary files /dev/null and b/media/spec/HUNTER.tga differ diff --git a/media/spec/MAGE.tga b/media/spec/MAGE.tga new file mode 100644 index 0000000..2b632cb Binary files /dev/null and b/media/spec/MAGE.tga differ diff --git a/media/spec/MONK.tga b/media/spec/MONK.tga new file mode 100644 index 0000000..d799135 Binary files /dev/null and b/media/spec/MONK.tga differ diff --git a/media/spec/PALADIN.tga b/media/spec/PALADIN.tga new file mode 100644 index 0000000..3599b9c Binary files /dev/null and b/media/spec/PALADIN.tga differ diff --git a/media/spec/PRIEST.tga b/media/spec/PRIEST.tga new file mode 100644 index 0000000..cb62301 Binary files /dev/null and b/media/spec/PRIEST.tga differ diff --git a/media/spec/ROGUE.tga b/media/spec/ROGUE.tga new file mode 100644 index 0000000..aff13da Binary files /dev/null and b/media/spec/ROGUE.tga differ diff --git a/media/spec/SHAMAN.tga b/media/spec/SHAMAN.tga new file mode 100644 index 0000000..aa1b363 Binary files /dev/null and b/media/spec/SHAMAN.tga differ diff --git a/media/spec/WARLOCK.tga b/media/spec/WARLOCK.tga new file mode 100644 index 0000000..14de789 Binary files /dev/null and b/media/spec/WARLOCK.tga differ diff --git a/media/spec/WARRIOR.tga b/media/spec/WARRIOR.tga new file mode 100644 index 0000000..1cb0c7f Binary files /dev/null and b/media/spec/WARRIOR.tga differ diff --git a/modules/armor.lua b/modules/armor.lua new file mode 100644 index 0000000..a72f54b --- /dev/null +++ b/modules/armor.lua @@ -0,0 +1,72 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.armor.show then return end + +local armorFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +armorFrame:SetPoint("LEFT",590,0) +armorFrame:EnableMouse(true) +armorFrame:RegisterForClicks("AnyUp") + +local armorIcon = armorFrame:CreateTexture(nil,"OVERLAY",nil,7) +armorIcon:SetPoint("LEFT") +armorIcon:SetTexture(cfg.mediaFolder.."datatexts\\repair") +armorIcon:SetVertexColor(unpack(cfg.color.inactive)) + +local armorText = armorFrame:CreateFontString(nil, "OVERLAY") +armorText:SetFont(cfg.text.font, cfg.text.normalFontSize) +armorText:SetPoint("RIGHT", armorFrame,2,0) +armorText:SetTextColor(unpack(cfg.color.normal)) + +armorFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + armorIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +armorFrame:SetScript("OnLeave", function() + local durMin = 100 + for i = 1, 18 do + local durCur, durMax = GetInventoryItemDurability(i) + if ( durCur ~= durMax ) then durMin = min(durMin, durCur*(100/durMax)) end + end + if durMin >= cfg.armor.minArmor then + armorIcon:SetVertexColor(unpack(cfg.color.inactive)) + else + armorIcon:SetVertexColor(unpack(cfg.color.normal)) + end +end) + +armorFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + + end +end) + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") +eventframe:RegisterEvent("UPDATE_INVENTORY_DURABILITY") + +eventframe:SetScript("OnEvent", function(self,event, ...) + local durMin, durCol + durMin, durCol = 100, "ffffff" + for i = 1, 18 do + local durCur, durMax = GetInventoryItemDurability(i) + if ( durCur ~= durMax ) then durMin = min(durMin, durCur*(100/durMax)) end + end + + if durMin >= cfg.armor.maxArmor then + local overallilvl, equippedilvl = GetAverageItemLevel() + armorText:SetText(floor(equippedilvl).." ilvl") + else + armorText:SetText(floor(durMin).."%") + end + + if durMin >= cfg.armor.minArmor then + armorIcon:SetVertexColor(unpack(cfg.color.inactive)) + else + armorIcon:SetVertexColor(unpack(cfg.color.normal)) + end + armorFrame:SetSize(armorText:GetStringWidth()+18, 16) +end) \ No newline at end of file diff --git a/modules/clock.lua b/modules/clock.lua new file mode 100644 index 0000000..80c17a3 --- /dev/null +++ b/modules/clock.lua @@ -0,0 +1,110 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.clock.show then return end + +local hour, minu = 0,0 +local AmPmTimeText = "" + +local clockFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +clockFrame:SetSize(32, 32) +clockFrame:SetPoint("CENTER") +clockFrame:EnableMouse(true) +clockFrame:RegisterForClicks("AnyUp") + +local clockText = clockFrame:CreateFontString(nil, "OVERLAY") +clockText:SetFont(cfg.text.font, cfg.SXframe:GetHeight()-4) +clockText:SetPoint("LEFT") +clockText:SetTextColor(unpack(cfg.color.normal)) + +local amText = clockFrame:CreateFontString(nil, "OVERLAY") +amText:SetFont(cfg.text.font, cfg.text.normalFontSize) +amText:SetPoint("RIGHT") +amText:SetTextColor(unpack(cfg.color.inactive)) + +local calendarText = clockFrame:CreateFontString(nil, "OVERLAY") +calendarText:SetFont(cfg.text.font, cfg.text.smallFontSize) +calendarText:SetPoint("CENTER", clockFrame, "TOP") +if cfg.core.position ~= "BOTTOM" then + calendarText:SetPoint("CENTER", clockFrame, "BOTTOM") +end +calendarText:SetTextColor(unpack(cfg.color.normal)) + +local elapsed = 0 +clockFrame:SetScript('OnUpdate', function(self, e) + elapsed = elapsed + e + if elapsed >= 1 then + hour, minu = GetGameTime() + if minu < 10 then minu = ("0"..minu) end + if ( GetCVarBool("timeMgrUseLocalTime") ) then + if ( GetCVarBool("timeMgrUseMilitaryTime") ) then + clockText:SetText(date("%H:%M")) + amText:SetText("") + else + clockText:SetText(date("%I:%M")) + amText:SetText(date("%p")) + end + else + if ( GetCVarBool("timeMgrUseMilitaryTime") ) then + clockText:SetText(hour..":"..minu) + amText:SetText("") + else + if hour > 12 then + hour = hour - 12 + hour = ("0"..hour) + AmPmTimeText = "PM" + else + AmPmTimeText = "AM" + end + clockText:SetText(hour..":"..minu) + amText:SetText(AmPmTimeText) + end + + end + if (CalendarGetNumPendingInvites() > 0) then + calendarText:SetText(string.format("%s (|cffffff00%i|r)", "New Event!", (CalendarGetNumPendingInvites()))) + else + calendarText:SetText("") + end + clockFrame:SetWidth(clockText:GetStringWidth() + amText:GetStringWidth()) + clockFrame:SetPoint("CENTER", cfg.SXframe) + elapsed = 0 + end +end) + +--[[ + +--]] + +clockFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + clockText:SetTextColor(unpack(cfg.color.hover)) + if cfg.clock.showTooltip then + hour, minu = GetGameTime() + if minu < 10 then minu = ("0"..minu) end + GameTooltip:SetOwner(clockFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFClock|r]") + GameTooltip:AddLine(" ") + if ( GetCVarBool("timeMgrUseLocalTime") ) then + GameTooltip:AddDoubleLine("Realm Time", hour..":"..minu, 1, 1, 0, 1, 1, 1) + else + GameTooltip:AddDoubleLine("Local Time", date("%H:%M"), 1, 1, 0, 1, 1, 1) + end + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine("<Left-click>", "Open Calendar", 1, 1, 0, 1, 1, 1) + GameTooltip:AddDoubleLine("<Right-click>", "Open Clock", 1, 1, 0, 1, 1, 1) + GameTooltip:Show() + end +end) + +clockFrame:SetScript("OnLeave", function() if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end clockText:SetTextColor(unpack(cfg.color.normal)) end) + +clockFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleCalendar() + elseif button == "RightButton" then + ToggleTimeManager() + end +end) \ No newline at end of file diff --git a/modules/config.lua b/modules/config.lua new file mode 100644 index 0000000..4dc5ad9 --- /dev/null +++ b/modules/config.lua @@ -0,0 +1,268 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- + +if not cfg.useConfig then return end + +local configFrame = CreateFrame("Frame",nil,cfg.SXconfigFrame,"ButtonFrameTemplate") +configFrame:SetSize(350,400) +configFrame:ClearAllPoints() +configFrame:SetPoint("TOPLEFT",UIparent,20,-75) +--configFrame:SetScale(1.5) +configFrame:SetClampedToScreen(true) +configFrame:EnableMouse(true) +configFrame:SetMovable(true) +configFrame:RegisterForDrag("LeftButton") +configFrame:SetScript("OnDragStart",configFrame.StartMoving) +configFrame:SetScript("OnDragStop",configFrame.StopMovingOrSizing) + +local icon = configFrame:CreateTexture("$parentIcon", "OVERLAY", nil, -8) +icon:SetSize(60,60) +icon:SetPoint("TOPLEFT",-5,7) +icon:SetTexture("Interface\\FriendsFrame\\Battlenet-Portrait") +--SetPortraitTexture(icon, "Interface\\FriendsFrame\\Battlenet-Portrait") +--icon:SetTexCoord(0,1,0,1) + +local configFrameText = configFrame:CreateFontString(nil, "OVERLAY") +configFrameText:SetFont(STANDARD_TEXT_FONT, cfg.text.normalFontSize, "OUTLINE") +configFrameText:SetPoint("TOP",0,-6) +configFrameText:SetText(addon.." Configuration") + +local globalCheckButton = CreateFrame("CheckButton", "globalCheckButton", configFrame, "UICheckButtonTemplate") +globalCheckButton:ClearAllPoints() +globalCheckButton:SetPoint("TOPLEFT",60,-25) +_G[globalCheckButton:GetName() .. "Text"]:SetText("Use Module Coloring") +globalCheckButton:SetScript("OnClick", function(self,event,arg1) + if self:GetChecked() then + UIDropDownMenu_EnableDropDown(globalModuleDropdown) + globalActiveModuleText:SetTextColor(1,1,1,1) + else + UIDropDownMenu_DisableDropDown(globalModuleDropdown) + UIDropDownMenu_SetText(dropDown, "Select Module") + globalActiveModuleText:SetTextColor(1,1,1,0.4) + end +end) + + +local resetButton = CreateFrame("Button", "MyButton", configFrame, "UIPanelButtonTemplate") +resetButton:SetSize(80 ,22) -- width, height +resetButton:SetText("Reset Color") +resetButton:SetPoint("TOPRIGHT",-10,-30) +resetButton:SetScript("OnClick", function() + if IsShiftKeyDown() then + cfg.color = { + normal = {1,1,1,.75}, + inactive = {1,1,1,.25}, + hover = {cfg.cc.r,cfg.cc.g,cfg.cc.b,.75}, + barcolor = {.094,.094,.102,.45}, + } + print"The colors have been set to default." + else + print"Hold <Shift> if you want to set the colors to default." + end +end) + + +local activeModuleText = configFrame:CreateFontString(nil, "OVERLAY") +activeModuleText:SetFont(STANDARD_TEXT_FONT, cfg.text.normalFontSize, "OUTLINE") +activeModuleText:SetPoint("TOPRIGHT",configFrame,"TOP",-20,-75) +activeModuleText:SetText("Active Module:") +globalActiveModuleText = activeModuleText + +local dropDown = CreateFrame("frame", "selectModuleDropDown", configFrame, "UIDropDownMenuTemplate") +dropDown:SetPoint("LEFT",activeModuleText, "RIGHT", -10,-5) +UIDropDownMenu_SetText(dropDown, "Select Module") +UIDropDownMenu_JustifyText(dropDown, "LEFT") + +globalModuleDropdown = dropDown + +local modules = { + "None", + "Micromenu", + "Armor", + "Talent", + "Clock", + "Trade Skill", + "Currency", + "System", + "Gold", + "Heartstone", +} + +local function OnClick(self) + UIDropDownMenu_SetSelectedID(dropDown, self:GetID()) + if self:GetID() == 1 then + + elseif self:GetID() == 2 then + + elseif self:GetID() == 3 then + + elseif self:GetID() == 4 then + + elseif self:GetID() == 5 then + + elseif self:GetID() == 6 then + + elseif self:GetID() == 7 then + + elseif self:GetID() == 8 then + + elseif self:GetID() == 9 then + + elseif self:GetID() == 10 then + + end +end + +local function initialize(self, level) + local info = UIDropDownMenu_CreateInfo() + for k,v in pairs(modules) do + info = UIDropDownMenu_CreateInfo() + info.text = v + info.value = v + info.func = OnClick + UIDropDownMenu_AddButton(info, level) + end +end + +UIDropDownMenu_Initialize(dropDown, initialize) +UIDropDownMenu_SetWidth(dropDown, 100); +UIDropDownMenu_SetButtonWidth(dropDown, 75) + + +local function showColorPicker(r,g,b,a,callback) + ColorPickerFrame:SetColorRGB(r,g,b) + ColorPickerFrame.hasOpacity, ColorPickerFrame.opacity = (a ~= nil), a + ColorPickerFrame.previousValues = {r,g,b,a} + ColorPickerFrame.func, ColorPickerFrame.opacityFunc, ColorPickerFrame.cancelFunc = callback, callback, callback + ColorPickerFrame:Hide() -- Need to run the OnShow handler. + ColorPickerFrame:Show() +end + +local barColorFrame = CreateFrame("FRAME",nil,configFrame) +barColorFrame:SetSize(18,18) +barColorFrame:SetPoint("TOPLEFT",configFrame,15,-100) +--text +barColorFrame.text = barColorFrame:CreateFontString(nil, "OVERLAY") +barColorFrame.text:SetFont(STANDARD_TEXT_FONT, 16, "OUTLINE") +barColorFrame.text:SetPoint("CENTER") +barColorFrame.text:SetText("Bar Color") +barColorFrame.text:SetTextColor(1,1,1,.75) +barColorFrame:SetWidth(barColorFrame.text:GetStringWidth()) + +local normalColor = CreateFrame("FRAME",nil,configFrame) +normalColor:SetSize(100,20) +normalColor:SetPoint("TOPLEFT",barColorFrame,0,-40) +--text +normalColor.text = normalColor:CreateFontString(nil, "OVERLAY") +normalColor.text:SetFont(STANDARD_TEXT_FONT, 16, "OUTLINE") +normalColor.text:SetPoint("CENTER") +normalColor.text:SetText("Normal Color") +normalColor.text:SetTextColor(1,1,1,.75) +normalColor:SetWidth(normalColor.text:GetStringWidth()) + +local inactiveColor = CreateFrame("FRAME",nil,configFrame) +inactiveColor:SetSize(100,20) +inactiveColor:SetPoint("TOPLEFT",normalColor,0,-40) +--text +inactiveColor.text = inactiveColor:CreateFontString(nil, "OVERLAY") +inactiveColor.text:SetFont(STANDARD_TEXT_FONT, 16, "OUTLINE") +inactiveColor.text:SetPoint("CENTER") +inactiveColor.text:SetText("Inactive Color") +inactiveColor.text:SetTextColor(1,1,1,.25) +inactiveColor:SetWidth(normalColor.text:GetStringWidth()) + +local hoverColorFrame = CreateFrame("FRAME",nil,configFrame) +hoverColorFrame:SetSize(18,18) +hoverColorFrame:SetPoint("TOPLEFT",inactiveColor,0,-40) +--text +hoverColorFrame.text = hoverColorFrame:CreateFontString(nil, "OVERLAY") +hoverColorFrame.text:SetFont(STANDARD_TEXT_FONT, 16, "OUTLINE") +hoverColorFrame.text:SetPoint("CENTER") +hoverColorFrame.text:SetText("Hover Color") +hoverColorFrame.text:SetTextColor(cfg.cc.r,cfg.cc.g,cfg.cc.b,.75) +hoverColorFrame:SetWidth(hoverColorFrame.text:GetStringWidth()) + +--recolor callback function +normalColor.recolorTexture = function(color) + local r,g,b,a + if color then + r,g,b,a = unpack(color) + else + r,g,b = ColorPickerFrame:GetColorRGB() + a = OpacitySliderFrame:GetValue() + end + normalColor.text:SetTextColor(r,g,b,a) + cfg.color.normal = {r,g,b,a} + globalNormColSlider:SetValue(a*100) + globalNormColEditBox:SetNumber(a*100) +end +normalColor:EnableMouse(true) +normalColor:SetScript("OnMouseDown", function(self,button,...) + if button == "LeftButton" then + local r,g,b,a = self.text:GetTextColor() + showColorPicker(r,g,b,a,self.recolorTexture) + end +end) + +local normalClassColorCheckButton = CreateFrame("CheckButton", "classColorNormalCheckButton", normalColor, "UIRadioButtonTemplate") +normalClassColorCheckButton:ClearAllPoints() +normalClassColorCheckButton:SetPoint("RIGHT",50,0) +_G[normalClassColorCheckButton:GetName() .. "Text"]:SetText("Class color") +normalClassColorCheckButton:SetScript("OnClick", function(self,event,arg1) + if self:GetChecked() then + normalColor.text:SetTextColor(cfg.cc.r,cfg.cc.g,cfg.cc.b) + normalColor:EnableMouse(false) + globalNormColEditBox:Enable() + globalNormColSlider:Enable() + globalNormColSlider:SetAlpha(1) + else + normalColor.text:SetTextColor(1,1,1,.75) + normalColor:EnableMouse(true) + globalNormColEditBox:Disable() + globalNormColSlider:Disable() + globalNormColSlider:SetAlpha(.4) + end +end) + +local slider = CreateFrame("Slider","MyExampleSlider",normalClassColorCheckButton,"OptionsSliderTemplate") --frameType, frameName, frameParent, frameTemplate +slider:SetPoint("TOPLEFT",0,-30) +slider.textLow = _G["MyExampleSlider".."Low"] +slider.textHigh = _G["MyExampleSlider".."High"] +slider.text = _G["MyExampleSlider".."Text"] +slider:SetMinMaxValues(0, 100) +slider.minValue, slider.maxValue = slider:GetMinMaxValues() +slider.textLow:SetText(slider.minValue) +slider.textHigh:SetText(slider.maxValue) +slider.text:SetText("Class Color Alpha:") +slider:SetValue(100) +slider:SetValueStep(1) +slider:Disable() +slider:SetAlpha(.4) +slider:SetScript("OnValueChanged", function(self,event,arg1) + normalColor.text:SetAlpha(event/100) + globalNormColEditBox:SetNumber(event) +end) +globalNormColSlider = slider + +local EditBox = CreateFrame("EditBox",nil,slider) +EditBox:SetWidth(32) +EditBox:SetHeight(16) +EditBox:SetPoint("LEFT",slider.text,"RIGHT",2,0) +EditBox:SetFontObject(GameFontNormal) +EditBox:SetAutoFocus(false) +EditBox:SetMaxLetters(3) +EditBox:SetNumeric() +EditBox:SetScript("OnEnterPressed", function(self) + self:ClearFocus() + globalNormColSlider:SetValue(EditBox:GetNumber()) +end) + +globalNormColEditBox = EditBox + +--[ +UIDropDownMenu_DisableDropDown(globalModuleDropdown) +globalActiveModuleText:SetTextColor(1,1,1,0.4) +globalNormColEditBox:Disable() +--]] \ No newline at end of file diff --git a/modules/currency.lua b/modules/currency.lua new file mode 100644 index 0000000..8f02ad7 --- /dev/null +++ b/modules/currency.lua @@ -0,0 +1,324 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.currency.show then return end + +local currencyFrame = CreateFrame("Frame",nil, cfg.SXframe) +currencyFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 340,0) +currencyFrame:SetSize(16, 16) + +--------------------------------------------- +-- XP BAR +--------------------------------------------- +local xpFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +xpFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 350,0) +xpFrame:SetSize(16, 16) +xpFrame:EnableMouse(true) +xpFrame:RegisterForClicks("AnyUp") + +local xpIcon = xpFrame:CreateTexture(nil,"OVERLAY",nil,7) +xpIcon:SetSize(16, 16) +xpIcon:SetPoint("LEFT") +xpIcon:SetTexture(cfg.mediaFolder.."datatexts\\exp") +xpIcon:SetVertexColor(unpack(cfg.color.normal)) + +local xpText = xpFrame:CreateFontString(nil, "OVERLAY") +xpText:SetFont(cfg.text.font, cfg.text.normalFontSize) +xpText:SetPoint("RIGHT",xpFrame,2,0 ) +xpText:SetTextColor(unpack(cfg.color.normal)) + +local xpStatusbar = CreateFrame("StatusBar", nil, xpFrame) +xpStatusbar:SetStatusBarTexture(1,1,1) +xpStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) +xpStatusbar:SetPoint("TOPLEFT", xpText, "BOTTOMLEFT",0,-2) + +local xpStatusbarBG = xpStatusbar:CreateTexture(nil,"BACKGROUND",nil,7) +xpStatusbarBG:SetPoint("TOPLEFT", xpText, "BOTTOMLEFT",0,-2) +xpStatusbarBG:SetColorTexture(unpack(cfg.color.inactive)) + +xpFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + xpIcon:SetVertexColor(unpack(cfg.color.hover)) + xpStatusbar:SetStatusBarColor(unpack(cfg.color.hover)) + if not cfg.currency.showTooltip then return end + local mxp = UnitXPMax("player") + local xp = UnitXP("player") + local nxp = mxp - xp + local rxp = GetXPExhaustion() + local name, standing, minrep, maxrep, value = GetWatchedFactionInfo() + + if cfg.core.position ~= "BOTTOM" then + GameTooltip:SetOwner(xpStatusbar, cfg.tooltipPos) + else + GameTooltip:SetOwner(xpFrame, cfg.tooltipPos) + end + + GameTooltip:AddLine("[|cff6699FFExperience Bar|r]") + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine(COMBAT_XP_GAIN, format(cfg.SVal(xp)).."|cffffd100/|r"..format(cfg.SVal(mxp)).." |cffffd100/|r "..floor((xp/mxp)*1000)/10 .."%",NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1) + GameTooltip:AddDoubleLine(NEED, format(cfg.SVal(nxp)).." |cffffd100/|r "..floor((nxp/mxp)*1000)/10 .."%",NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1) + if rxp then + GameTooltip:AddDoubleLine(TUTORIAL_TITLE26, format(cfg.SVal(rxp)) .." |cffffd100/|r ".. floor((rxp/mxp)*1000)/10 .."%", NORMAL_FONT_COLOR.r,NORMAL_FONT_COLOR.g,NORMAL_FONT_COLOR.b,1,1,1) + end + GameTooltip:Show() +end) + +xpFrame:SetScript("OnLeave", function() + xpIcon:SetVertexColor(unpack(cfg.color.normal)) + xpStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end +end) + +--------------------------------------------- +-- REROLL +--------------------------------------------- +local rerollFrame = CreateFrame("BUTTON",nil, currencyFrame) +rerollFrame:SetPoint("LEFT") +rerollFrame:SetSize(16, 16) +rerollFrame:EnableMouse(true) +rerollFrame:RegisterForClicks("AnyUp") + +local rerollIcon = rerollFrame:CreateTexture(nil,"OVERLAY",nil,7) +rerollIcon:SetSize(16, 16) +rerollIcon:SetPoint("RIGHT") +rerollIcon:SetTexture(cfg.mediaFolder.."datatexts\\reroll") +rerollIcon:SetVertexColor(unpack(cfg.color.inactive)) + +local rerollText = rerollFrame:CreateFontString(nil, "OVERLAY") +rerollText:SetFont(cfg.text.font, cfg.text.normalFontSize) +rerollText:SetPoint("RIGHT",rerollIcon,"LEFT",-2,0) +rerollText:SetTextColor(unpack(cfg.color.inactive)) + +rerollFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + rerollIcon:SetVertexColor(unpack(cfg.color.hover)) + if not cfg.currency.showTooltip then return end + GameTooltip:SetOwner(currencyFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFReroll|r]") + GameTooltip:AddLine(" ") + local SoIFname, SoIFamount, SoIFicon, SoIFearnedThisWeek, SoIFweeklyMax, SoIFtotalMax, SoIFisDiscovered = GetCurrencyInfo(1129) + if SoIFamount > 0 then + GameTooltip:AddLine(SoIFname,1,1,0) + GameTooltip:AddDoubleLine("|cffffff00Weekly: |cffffffff"..SoIFearnedThisWeek.."|cffffff00/|cffffffff"..SoIFweeklyMax, "|cffffff00Total: |cffffffff"..SoIFamount.."|cffffff00/|cffffffff"..SoIFtotalMax) + else + local SoTFname, SoTFamount, SoTFicon, SoTFearnedThisWeek, SoTFweeklyMax, SoTFtotalMax, SoTFisDiscovered = GetCurrencyInfo(994) + if SoTFamount > 0 then + GameTooltip:AddDoubleLine(SoTFname, "|cffffff00Total: |cffffffff"..SoTFamount.."|cffffff00/|cffffffff"..SoTFtotalMax) + end + end + GameTooltip:Show() +end) + +rerollFrame:SetScript("OnLeave", function() + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end + rerollIcon:SetVertexColor(unpack(cfg.color.inactive)) +end) + +rerollFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleCharacter("TokenFrame") + end +end) + +--------------------------------------------- +-- HONOR +--------------------------------------------- + +local honorFrame = CreateFrame("BUTTON",nil, currencyFrame) +honorFrame:SetPoint("LEFT",rerollFrame,"RIGHT",2,0) +honorFrame:SetSize(16, 16) +honorFrame:EnableMouse(true) +honorFrame:RegisterForClicks("AnyUp") + +local honorIcon = honorFrame:CreateTexture(nil,"OVERLAY",nil,7) +honorIcon:SetSize(16, 16) +honorIcon:SetPoint("RIGHT") +honorIcon:SetTexture(cfg.mediaFolder.."datatexts\\honor") +honorIcon:SetVertexColor(unpack(cfg.color.inactive)) + +local honorText = honorFrame:CreateFontString(nil, "OVERLAY") +honorText:SetFont(cfg.text.font, cfg.text.normalFontSize) +honorText:SetPoint("LEFT") +honorText:SetTextColor(unpack(cfg.color.inactive)) + +honorFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + honorIcon:SetVertexColor(unpack(cfg.color.hover)) + if not cfg.currency.showTooltip then return end + GameTooltip:SetOwner(currencyFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFPvP Currency|r]") + GameTooltip:AddLine(" ") + local concName, concAmount, _, concEarnedThisWeek, concWeeklyMax, concTotalMax, concIsDiscovered = GetCurrencyInfo(390) + local honorName, honorAmount, _, honorEarnedThisWeek, honorWeeklyMax, honorTotalMax, honorIsDiscovered = GetCurrencyInfo(392) + + GameTooltip:AddDoubleLine(concName,"|cffffff00Weekly: |cffffffff"..concEarnedThisWeek.."|cffffff00/|cffffffff"..format(cfg.SVal(concWeeklyMax))) + + GameTooltip:AddDoubleLine(honorName, "|cffffff00Total: |cffffffff"..honorAmount.."|cffffff00/|cffffffff"..format(cfg.SVal(honorTotalMax))) + GameTooltip:Show() +end) + +honorFrame:SetScript("OnLeave", function() + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end + honorIcon:SetVertexColor(unpack(cfg.color.inactive)) +end) + +honorFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleCharacter("TokenFrame") + end +end) + +--------------------------------------------- +-- GARRISON RECOURCES +--------------------------------------------- + +local garrisonFrame = CreateFrame("BUTTON",nil, currencyFrame) +garrisonFrame:SetPoint("LEFT",honorFrame,"RIGHT",2,0) +garrisonFrame:SetSize(16, 16) +garrisonFrame:EnableMouse(true) +garrisonFrame:RegisterForClicks("AnyUp") + +local garrisonIcon = garrisonFrame:CreateTexture(nil,"OVERLAY",nil,7) +garrisonIcon:SetSize(16, 16) +garrisonIcon:SetPoint("RIGHT") +garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\garres") +garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) + +local garrisonText = garrisonFrame:CreateFontString(nil, "OVERLAY") +garrisonText:SetFont(cfg.text.font, cfg.text.normalFontSize) +garrisonText:SetPoint("LEFT") +garrisonText:SetTextColor(unpack(cfg.color.inactive)) + +garrisonFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + garrisonIcon:SetVertexColor(unpack(cfg.color.hover)) + if not cfg.currency.showTooltip then return end + GameTooltip:SetOwner(currencyFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFGarrison Recources|r]") + GameTooltip:AddLine(" ") + local grName, grAmount, _, _, _, grTotalMax = GetCurrencyInfo(824) + local oilName, oilAmount, _, _, _, oilTotalMax, oilIsDiscovered = GetCurrencyInfo(1101) + local apexisName, apexisAmount = GetCurrencyInfo(823) + local DICName, DICAmount, _, _, _, DICTotalMax = GetCurrencyInfo(980) + + GameTooltip:AddDoubleLine(grName, "|cffffffff"..format(cfg.SVal(grAmount)).."|cffffff00/|cffffffff"..format(cfg.SVal(grTotalMax))) + if oilIsDiscovered then + GameTooltip:AddDoubleLine(oilName, "|cffffffff"..format(cfg.SVal(oilAmount)).."|cffffff00/|cffffffff"..format(cfg.SVal(oilTotalMax))) + end + GameTooltip:AddDoubleLine(apexisName, "|cffffffff"..format(cfg.SVal(apexisAmount))) + if DICAmount > 0 then + GameTooltip:AddDoubleLine(DICName, "|cffffffff"..format(cfg.SVal(DICAmount)).."|cffffff00/|cffffffff"..format(cfg.SVal(DICTotalMax))) + end + GameTooltip:Show() +end) + +garrisonFrame:SetScript("OnLeave", function() + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end + garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) +end) + +garrisonFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleCharacter("TokenFrame") + end +end) + + +--------------------------------------------- +-- FUNCTIONS +--------------------------------------------- +local function updateXP(xp, mxp) + if UnitLevel("player") == MAX_PLAYER_LEVEL or not cfg.currency.showXPbar then + xpFrame:Hide() + xpFrame:EnableMouse(false) + currencyFrame:Show() + else + currencyFrame:Hide() + xpFrame:Show() + xpFrame:EnableMouse(true) + xpStatusbar:SetMinMaxValues(0, mxp) + xpStatusbar:SetValue(xp) + xpText:SetText("LEVEL "..UnitLevel("player").." "..cfg.CLASS) + xpFrame:SetSize(xpText:GetStringWidth()+18, 16) + xpStatusbar:SetSize(xpText:GetStringWidth(),3) + xpStatusbarBG:SetSize(xpText:GetStringWidth(),3) + end +end + +--------------------------------------------- +-- EVENT HANDELING +--------------------------------------------- + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") +eventframe:RegisterEvent("PLAYER_XP_UPDATE") +eventframe:RegisterEvent("PLAYER_LEVEL_UP") +eventframe:RegisterEvent("CURRENCY_DISPLAY_UPDATE") +eventframe:RegisterEvent("CHAT_MSG_CURRENCY") +eventframe:RegisterEvent("TRADE_CURRENCY_CHANGED") +eventframe:RegisterEvent("MODIFIER_STATE_CHANGED") + +eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...) + --if event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_XP_UPDATE" or event == "PLAYER_LEVEL_UP" then + if UnitLevel("player") ~= MAX_PLAYER_LEVEL and cfg.currency.showXPbar then + mxp = UnitXPMax("player") + xp = UnitXP("player") + updateXP(xp, mxp) + currencyFrame:Hide() + else + xpFrame:Hide() + end + + if event == "MODIFIER_STATE_CHANGED" then + if InCombatLockdown() then return end + if arg1 == "LSHIFT" or arg1 == "RSHIFT" then + if UnitLevel("player") == MAX_PLAYER_LEVEL or not cfg.currency.showXPbar then return end + if arg2 == 1 then + xpFrame:Hide() + xpFrame:EnableMouse(false) + currencyFrame:Show() + elseif arg2 == 0 then + currencyFrame:Hide() + xpFrame:EnableMouse(true) + xpFrame:Show() + end + end + end + + + + + -- reroll currency + local SoIFname, SoIFamount, _, _, _, SoIFtotalMax, SoIFisDiscovered = GetCurrencyInfo(1129) + if SoIFamount > 0 then + rerollText:SetText(SoIFamount) + else + local SoTFname, SoTFamount, _, _, _, SoTFtotalMax, SoTFisDiscovered = GetCurrencyInfo(994) + if SoTFamount > 0 then rerollText:SetText(SoTFamount) end + end + rerollFrame:SetSize(rerollText:GetStringWidth()+18, 16) + + -- honor currency + local concName, concAmount, _, concEarnedThisWeek, concWeeklyMax, concTotalMax, concIsDiscovered = GetCurrencyInfo(390) + if concAmount > 0 then + honorText:SetText(concAmount) + else + local honorName, honorAmount, _, honorEarnedThisWeek, honorWeeklyMax, honorTotalMax, honorIsDiscovered = GetCurrencyInfo(392) + if honorAmount > 0 then honorText:SetText(honorAmount) end + end + honorFrame:SetSize(honorText:GetStringWidth()+18, 16) + + currencyFrame:SetSize(rerollFrame:GetWidth()+honorFrame:GetWidth()+6,16) + + -- garrison currency + local grName, grAmount, _, grEarnedThisWeek, grWeeklyMax, grTotalMax, grIsDiscovered = GetCurrencyInfo(824) + garrisonText:SetText(grAmount) + garrisonFrame:SetSize(garrisonText:GetStringWidth()+18, 16) + + currencyFrame:SetSize(rerollFrame:GetWidth()+honorFrame:GetWidth()+garrisonFrame:GetWidth()+6,16) +end) + diff --git a/modules/gold.lua b/modules/gold.lua new file mode 100644 index 0000000..f3d098a --- /dev/null +++ b/modules/gold.lua @@ -0,0 +1,225 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.gold.show then return end + +local onHover = false + +local function goldConverter(money) + local g, s, c = abs(money/10000), abs(mod(money/100, 100)), abs(mod(money, 100)) + local cash + if ( g < 1 ) then g = "" else g = string.format("|cffffffff%d|cffffd700g|r ", g) end + if ( s < 1 ) then s = "" else s = string.format("|cffffffff%d|cffc7c7cfs|r ", s) end + if ( c == 0 ) then c = "" else c = string.format("|cffffffff%d|cffeda55fc|r", c) end + cash = string.format("%s%s%s", g, s, c) + if money == 0 then cash = "|cffffffff0" end + return cash +end + +local playerName, playerFaction, playerRealm = UnitName("player"), UnitFactionGroup("player"), GetRealmName() + +local positiveSign = "|cff00ff00+ " +local negativeSign = "|cffff0000- " + +local goldFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +goldFrame:SetPoint("RIGHT",-230,0) +goldFrame:SetSize(16, 16) +goldFrame:EnableMouse(true) +goldFrame:RegisterForClicks("AnyUp") + + local function goldFrameOnEnter() + if not cfg.gold.showTooltip then return end + if not onHover then return end + GameTooltip:SetOwner(goldFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFGold|r]") + GameTooltip:AddLine(" ") + --------------------------------------------------- + + local gold = GetMoney() + local logDate = ns.playerData.lastLoginDate + + local sessionGold = ns.playerData["money_on_session_start"] + local sessionGoldIcon = "" + sessionGold = sessionGold - gold + + if sessionGold < 0 then + sessionGoldIcon = positiveSign + elseif sessionGold > 0 then + sessionGoldIcon = negativeSign + else + end + + local dayGold = ns.playerData["money_on_first_login_today"] + local dayGoldIcon = "" + dayGold = dayGold - gold + + if dayGold < 0 then + dayGoldIcon = positiveSign + elseif dayGold > 0 then + dayGoldIcon = negativeSign + else + end + + + local weekGold = ns.playerData["money_on_first_weekday"] + local weekGoldIcon = "" + weekGold = weekGold - gold + + if weekGold < 0 then + weekGoldIcon = positiveSign + elseif weekGold > 0 then + weekGoldIcon = negativeSign + else + end + + + local totalGold = 0 + for key, val in pairs(ns.realmData[playerFaction]) do + for k, v in pairs(val) do + if k == "money_on_log_out" then + totalGold = totalGold + v + end + end + end + + local realmDailyGold = 0 + for key, val in pairs(ns.realmData[playerFaction]) do + for k, v in pairs(val) do + if k == "money_on_first_login_today" then + realmDailyGold = realmDailyGold + v + end + end + end + + local realmDayGoldIcon = "" + realmDailyGold = realmDailyGold - totalGold + + if realmDailyGold < 0 then + realmDayGoldIcon = positiveSign + elseif realmDailyGold > 0 then + realmDayGoldIcon = negativeSign + else + end + + + local realmWeeklyGold = 0 + for key, val in pairs(ns.realmData[playerFaction]) do + for k, v in pairs(val) do + if k == "money_on_first_weekday" then + realmWeeklyGold = realmWeeklyGold + v + end + end + end + + local realmWeekGoldIcon = "" + realmWeeklyGold = realmWeeklyGold - totalGold + + if realmWeeklyGold < 0 then + realmWeekGoldIcon = positiveSign + elseif realmWeeklyGold > 0 then + realmWeekGoldIcon = negativeSign + else + end + + GameTooltip:AddDoubleLine(playerName.."|r's Gold",format(goldConverter(gold))) + GameTooltip:AddLine(" ") + + if IsShiftKeyDown() then + GameTooltip:AddDoubleLine("Realm Daily Balance",realmDayGoldIcon..format(goldConverter(realmDailyGold))) + GameTooltip:AddDoubleLine("Realm Weekly Balance",realmWeekGoldIcon..format(goldConverter(realmWeeklyGold))) + GameTooltip:AddLine(" ") + for key, val in pairs(ns.realmData[playerFaction]) do + for k, v in pairs(val) do + if k == "money_on_log_out" then + GameTooltip:AddDoubleLine(key,format(goldConverter(v))) + end + end + end + + else + GameTooltip:AddDoubleLine("Session Balance",sessionGoldIcon..format(goldConverter(sessionGold))) + GameTooltip:AddDoubleLine("Daily Balance",dayGoldIcon..format(goldConverter(dayGold))) + GameTooltip:AddDoubleLine("Weekly Balance",weekGoldIcon..format(goldConverter(weekGold))) + + end + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine("Realm Gold","|cffffffff"..format(goldConverter(totalGold))) + if not IsShiftKeyDown() then + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine("<Shift-hold>", "Show the |cffffff00"..playerRealm.." - "..playerFaction.."|r gold", 1, 1, 0, 1, 1, 1) + end + GameTooltip:Show() + end + +local goldIcon = goldFrame:CreateTexture(nil,"OVERLAY",nil,7) +goldIcon:SetPoint("LEFT") +goldIcon:SetTexture(cfg.mediaFolder.."datatexts\\gold") +goldIcon:SetVertexColor(unpack(cfg.color.normal)) + +local goldText = goldFrame:CreateFontString(nil, "OVERLAY") +goldText:SetFont(cfg.text.font, cfg.text.normalFontSize) +goldText:SetPoint("RIGHT", goldFrame,2,0) +goldText:SetTextColor(unpack(cfg.color.normal)) + +goldFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + goldIcon:SetVertexColor(unpack(cfg.color.hover)) + onHover = true + goldFrameOnEnter() +end) + +goldFrame:SetScript("OnLeave", function() if ( GameTooltip:IsShown() ) then GameTooltip:Hide() onHover = false end goldIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +goldFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + OpenAllBags() + elseif button == "RightButton" then + CloseAllBags() + end +end) + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") +eventframe:RegisterEvent("PLAYER_MONEY") +eventframe:RegisterEvent("SEND_MAIL_MONEY_CHANGED") +eventframe:RegisterEvent("SEND_MAIL_COD_CHANGED") +eventframe:RegisterEvent("PLAYER_TRADE_MONEY") +eventframe:RegisterEvent("TRADE_MONEY_CHANGED") +eventframe:RegisterEvent("TRADE_CLOSED") +eventframe:RegisterEvent("MODIFIER_STATE_CHANGED") + +eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...) + +goldFrameOnEnter() +if event == "MODIFIER_STATE_CHANGED" then + if InCombatLockdown() then return end + if arg1 == "LSHIFT" or arg1 == "RSHIFT" then + if arg2 == 1 then + goldFrameOnEnter() + elseif arg2 == 0 then + goldFrameOnEnter() + end + end + end + + + local gold = GetMoney() + + ns.playerData["money_on_log_out"] = gold + + local g, s, c = abs(gold/10000), abs(mod(gold/100, 100)), abs(mod(gold, 100)) + + if g > 1 then + goldText:SetText(floor(g).."g") + elseif s > 1 then + goldText:SetText(floor(s).."s") + else + goldText:SetText(floor(c).."c") + end + if gold == 0 then goldText:SetText("0") end + + + goldFrame:SetSize(goldText:GetStringWidth()+18, 16) +end) \ No newline at end of file diff --git a/modules/heartstone.lua b/modules/heartstone.lua new file mode 100644 index 0000000..af8be69 --- /dev/null +++ b/modules/heartstone.lua @@ -0,0 +1,251 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.heartstone.show then return end + +local garrOnHover = false +local hsOnHover = false + +local teleportFrame = CreateFrame("Frame",nil, cfg.SXframe) +teleportFrame:SetPoint("RIGHT",-4,0) +teleportFrame:SetSize(16, 16) +--------------------------------------------------------------------- +local HSFrame = CreateFrame("BUTTON","hsButton", teleportFrame, "SecureActionButtonTemplate") +HSFrame:SetPoint("RIGHT") +HSFrame:SetSize(16, 16) +HSFrame:EnableMouse(true) +HSFrame:RegisterForClicks("AnyUp") +HSFrame:SetAttribute("type", "macro") + +local HSText = HSFrame:CreateFontString(nil, "OVERLAY") +HSText:SetFont(cfg.text.font, cfg.text.normalFontSize) +HSText:SetPoint("RIGHT") +HSText:SetTextColor(unpack(cfg.color.normal)) + +local HSIcon = HSFrame:CreateTexture(nil,"OVERLAY",nil,7) +HSIcon:SetSize(16, 16) +HSIcon:SetPoint("RIGHT", HSText,"LEFT",-2,0) +HSIcon:SetTexture(cfg.mediaFolder.."datatexts\\hearth") +HSIcon:SetVertexColor(unpack(cfg.color.normal)) + +HSFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + HSIcon:SetVertexColor(unpack(cfg.color.hover)) + if not cfg.heartstone.showTooltip then return end + local startTime, duration = GetItemCooldown(6948) + if startTime ~= 0 then + local CDremaining = (startTime+duration)-GetTime() + GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) + GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) + GameTooltip:Show() + end + hsOnHover = true +end) + +HSFrame:SetScript("OnLeave", function() + hsOnHover = false + if IsUsableItem(6948) and GetItemCooldown(6948) == 0 or IsPlayerSpell(556) and GetSpellCooldown(556) == 0 then + HSIcon:SetVertexColor(unpack(cfg.color.normal)) + else + HSIcon:SetVertexColor(unpack(cfg.color.inactive)) + end +end) + +-- Change the button action before the click reaches it: +function HSFrame:ChangeAction(action) + if InCombatLockdown() then return end -- can't change attributes in combat + self:SetAttribute("macrotext", action) +end + +HSFrame:SetScript("PreClick", function(self) + if InCombatLockdown() then return end -- can't change attributes in combat + + -- Innkeeper's Daughter + if IsUsableItem(64488) and GetItemCooldown(64488) == 0 then + local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(64488) + return self:ChangeAction("/use " .. itemName) + + -- Hearthstone + elseif IsUsableItem(6948) and GetItemCooldown(6948) == 0 then + local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(6948) + return self:ChangeAction("/use " .. itemName) + + -- Astral Recall + elseif IsPlayerSpell(556) and GetSpellCooldown(556) == 0 then + local spellName, _, spellIcon = GetSpellInfo(556) + return self:ChangeAction("/cast " .. spellName) + end + + local playerLevel = UnitLevel("player") + + if playerLevel > 70 and IsUsableItem(44315) and GetItemCooldown(44315) == 0 then + return self:SetAttribute("macrotext", "/use Scroll of Recall III") + + elseif playerLevel > 40 and IsUsableItem(44314) and GetItemCooldown(44314) == 0 then + return self:SetAttribute("macrotext", "/use Scroll of Recall II") + + elseif playerLevel <= 39 and IsUsableItem(37118) and GetItemCooldown(37118) == 0 then + return self:SetAttribute("macrotext", "/use Scroll of Recall") + + end +end) +--------------------------------------------------------------------- +local garrisonFrame = CreateFrame("BUTTON","garrisonButton", teleportFrame, "SecureActionButtonTemplate") +garrisonFrame:SetPoint("LEFT") +garrisonFrame:SetSize(16, 16) +garrisonFrame:EnableMouse(true) +garrisonFrame:RegisterForClicks("AnyUp") +garrisonFrame:SetAttribute("*type1", "macro") + +-- Change the button action before the click reaches it: +function garrisonFrame:ChangeAction(action) + if InCombatLockdown() then return end -- can't change attributes in combat + self:SetAttribute("macrotext", action) +end + +garrisonFrame:SetScript("PreClick", function(self) + if InCombatLockdown() then return end -- can't change attributes in combat + + if IsShiftKeyDown() then + if IsUsableItem(128353) and GetItemCooldown(128353) == 0 then + local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(128353) + return self:ChangeAction("/use " .. itemName) + end + else + if IsUsableItem(110560) and GetItemCooldown(110560) == 0 then + local itemName, itemLink, _, _, _, _, _, _, _, itemIcon = GetItemInfo(110560) + return self:ChangeAction("/use " .. itemName) + end + end +end) + + +local garrisonIcon = garrisonFrame:CreateTexture(nil,"OVERLAY",nil,7) +garrisonIcon:SetSize(16, 16) +garrisonIcon:SetPoint("LEFT") +garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\garr") +garrisonIcon:SetVertexColor(unpack(cfg.color.normal)) + +local garrisonText = garrisonFrame:CreateFontString(nil, "OVERLAY") +garrisonText:SetFont(cfg.text.font, cfg.text.normalFontSize) +garrisonText:SetPoint("LEFT", garrisonIcon,"RIGHT",2,0) +garrisonText:SetText("GARRISON") +garrisonText:SetTextColor(unpack(cfg.color.normal)) + +garrisonFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + local startTime, duration = GetItemCooldown(110560) + if startTime ~= 0 then + local CDremaining = (startTime+duration)-GetTime() + GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) + GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) + GameTooltip:Show() + end + garrisonIcon:SetVertexColor(unpack(cfg.color.hover)) + garrOnHover = true +end) + +garrisonFrame:SetScript("OnLeave", function() + garrOnHover = false + if IsUsableItem(110560) and GetItemCooldown(110560) == 0 then + garrisonIcon:SetVertexColor(unpack(cfg.color.normal)) + else + garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) + end + GameTooltip:Hide() +end) + +local function hsHover() +local startTime, duration = GetItemCooldown(6948) + if startTime ~= 0 then + local CDremaining = (startTime+duration)-GetTime() + GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) + GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) + GameTooltip:Show() + end + HSIcon:SetVertexColor(unpack(cfg.color.hover)) +end + +local function garrHover() +local startTime, duration = GetItemCooldown(110560) + if startTime ~= 0 then + local CDremaining = (startTime+duration)-GetTime() + GameTooltip:SetOwner(teleportFrame, cfg.tooltipPos) + GameTooltip:AddDoubleLine("Cooldown",SecondsToTime(CDremaining),1,1,0,1,1,1) + GameTooltip:Show() + end + garrisonIcon:SetVertexColor(unpack(cfg.color.hover)) +end + +local function updateTeleportText() +local playerLevel = UnitLevel("player") + if IsUsableItem(64488) and GetItemCooldown(64488) == 0 + or IsUsableItem(6948) and GetItemCooldown(6948) == 0 + or IsPlayerSpell(556) and GetSpellCooldown(556) == 0 + or playerLevel > 70 and IsUsableItem(44315) and GetItemCooldown(44315) == 0 + or playerLevel > 40 and IsUsableItem(44314) and GetItemCooldown(44314) == 0 + or playerLevel <= 39 and IsUsableItem(37118) and GetItemCooldown(37118) == 0 + then + HSIcon:SetVertexColor(unpack(cfg.color.normal)) + HSText:SetTextColor(unpack(cfg.color.normal)) + else + HSIcon:SetVertexColor(unpack(cfg.color.inactive)) + HSText:SetTextColor(unpack(cfg.color.inactive)) + end + + if IsUsableItem(110560) and GetItemCooldown(110560) == 0 then + garrisonIcon:SetVertexColor(unpack(cfg.color.normal)) + garrisonText:SetTextColor(unpack(cfg.color.normal)) + else + garrisonIcon:SetVertexColor(unpack(cfg.color.inactive)) + garrisonText:SetTextColor(unpack(cfg.color.inactive)) + end +end + +local elapsed = 0 +teleportFrame:SetScript('OnUpdate', function(self, e) + elapsed = elapsed + e + if elapsed >= 1 then + updateTeleportText() + if garrOnHover then garrHover() end + if hsOnHover then hsHover() end + elapsed = 0 + end +end) + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") +eventframe:RegisterEvent("BAG_UPDATE") +eventframe:RegisterEvent("HEARTHSTONE_BOUND") +eventframe:RegisterEvent("MODIFIER_STATE_CHANGED") + +eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...) +if InCombatLockdown() then return end + +HSText:SetText(strupper(GetBindLocation())) +HSFrame:SetSize(HSText:GetStringWidth()+16, 16) + + +if IsUsableItem(110560) then + garrisonFrame:Show() +else + garrisonFrame:Hide() +end + +if event == "MODIFIER_STATE_CHANGED" then + if arg1 == "LSHIFT" or arg1 == "RSHIFT" then + if arg2 == 1 then + if IsUsableItem(128353) then + garrisonText:SetText("SHIPYARD") + garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\shipcomp") + end + elseif arg2 == 0 then + garrisonText:SetText("GARRISON") + garrisonIcon:SetTexture(cfg.mediaFolder.."datatexts\\garr") + end + end +end + garrisonFrame:SetSize(garrisonText:GetStringWidth()+16, 16) + teleportFrame:SetSize(HSFrame:GetWidth()+garrisonFrame:GetWidth()+8, 16) +end) \ No newline at end of file diff --git a/modules/micromenu.lua b/modules/micromenu.lua new file mode 100644 index 0000000..54f23ae --- /dev/null +++ b/modules/micromenu.lua @@ -0,0 +1,371 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.micromenu.show then return end +--------------------------------------------- +-- GAME MENU +--------------------------------------------- + +PlayerFrame.name:SetFont("Interface\\AddOns\\oUF_Drk\\media\\BigNoodleTitling.ttf", 11, "THINOUTLINE") +TargetFrame.name:SetFont("Interface\\AddOns\\oUF_Drk\\media\\BigNoodleTitling.ttf", 11, "THINOUTLINE") + +local isBeautiful = IsAddOnLoaded("Blizzard_RaidUI") --!Beautycase check + +if isBeautiful then + subframes.name:SetFont("Interface\\AddOns\\oUF_Drk\\media\\BigNoodleTitling.ttf",11,"THINOUTLINE") +end + + +local gameMenuFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +gameMenuFrame:SetSize(32, 32) +gameMenuFrame:SetPoint("LEFT",2,0) +gameMenuFrame:EnableMouse(true) +gameMenuFrame:RegisterForClicks("AnyUp") +local gameMenuIcon = gameMenuFrame:CreateTexture(nil,"OVERLAY",nil,7) +gameMenuIcon:SetPoint("CENTER") +gameMenuIcon:SetTexture(cfg.mediaFolder.."microbar\\menu") +gameMenuIcon:SetVertexColor(unpack(cfg.color.normal)) + +gameMenuFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + gameMenuIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +gameMenuFrame:SetScript("OnLeave", function() gameMenuIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +gameMenuFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleFrame(GameMenuFrame) + elseif button == "RightButton" then + if IsShiftKeyDown() then ReloadUI() + elseif IsAltKeyDown() then + if cfg.useConfig then + --if cfg.SXconfigFrame:IsShown() then + ToggleFrame(cfg.SXconfigFrame) + --else + --ToggleFrame(cfg.SXconfigFrame) + --end + end + else ToggleFrame(AddonList) end + end +end) + +--------------------------------------------- +-- CHARACTER FRAME +--------------------------------------------- + +local characterFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +characterFrame:SetSize(32, 32) +characterFrame:SetPoint("LEFT",174,0) +characterFrame:EnableMouse(true) +characterFrame:RegisterForClicks("AnyUp") +local characterFrameIcon = characterFrame:CreateTexture(nil,"OVERLAY",nil,7) +characterFrameIcon:SetAllPoints() +characterFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\char") +characterFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +characterFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + characterFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +characterFrame:SetScript("OnLeave", function() characterFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +characterFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleCharacter("PaperDollFrame") + end +end) + +--------------------------------------------- +-- SPELLS +--------------------------------------------- + +local spellFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +spellFrame:SetSize(32, 32) +spellFrame:SetPoint("LEFT",characterFrame,"RIGHT",4,0) +spellFrame:EnableMouse(true) +spellFrame:RegisterForClicks("AnyUp") +local spellFrameIcon = spellFrame:CreateTexture(nil,"OVERLAY",nil,7) +spellFrameIcon:SetSize(32,32) +spellFrameIcon:SetPoint("CENTER") +spellFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\spell") +spellFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +spellFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + spellFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +spellFrame:SetScript("OnLeave", function() spellFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +spellFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleFrame(SpellBookFrame) + end +end) + +--------------------------------------------- +-- TALENT +--------------------------------------------- + +local talentFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +talentFrame:SetSize(32, 32) +talentFrame:SetPoint("LEFT",spellFrame,"RIGHT",4,0) +talentFrame:EnableMouse(true) +talentFrame:RegisterForClicks("AnyUp") +local talentFrameIcon = talentFrame:CreateTexture(nil,"OVERLAY",nil,7) +talentFrameIcon:SetSize(32,32) +talentFrameIcon:SetPoint("CENTER") +talentFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\talent") +talentFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +talentFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + talentFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +talentFrame:SetScript("OnLeave", function() talentFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +talentFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + TalentMicroButton:Click() + end +end) + +--------------------------------------------- +-- ACHIV +--------------------------------------------- + +local achievementFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +achievementFrame:SetSize(32, 32) +achievementFrame:SetPoint("LEFT",talentFrame,"RIGHT",4,0) +achievementFrame:EnableMouse(true) +achievementFrame:RegisterForClicks("AnyUp") +local achievementFrameIcon = achievementFrame:CreateTexture(nil,"OVERLAY",nil,7) +achievementFrameIcon:SetSize(32,32) +achievementFrameIcon:SetPoint("CENTER") +achievementFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\ach") +achievementFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +achievementFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + achievementFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +achievementFrame:SetScript("OnLeave", function() achievementFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +achievementFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + securecall(ToggleAchievementFrame) + end +end) + +--------------------------------------------- +-- QUEST +--------------------------------------------- + +local questFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +questFrame:SetSize(32, 32) +questFrame:SetPoint("LEFT",achievementFrame,"RIGHT",4,0) +questFrame:EnableMouse(true) +questFrame:RegisterForClicks("AnyUp") +local questFrameIcon = questFrame:CreateTexture(nil,"OVERLAY",nil,7) +questFrameIcon:SetSize(32,32) +questFrameIcon:SetPoint("CENTER") +questFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\quest") +questFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +questFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + questFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +questFrame:SetScript("OnLeave", function() questFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +questFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + QuestLogMicroButton:Click() + end +end) + +--------------------------------------------- +-- LFG +--------------------------------------------- + +local lfgFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +lfgFrame:SetSize(32, 32) +lfgFrame:SetPoint("LEFT",questFrame,"RIGHT",4,0) +lfgFrame:EnableMouse(true) +lfgFrame:RegisterForClicks("AnyUp") +local lfgFrameIcon = lfgFrame:CreateTexture(nil,"OVERLAY",nil,7) +lfgFrameIcon:SetSize(32,32) +lfgFrameIcon:SetPoint("CENTER") +lfgFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\lfg") +lfgFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +lfgFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + lfgFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +lfgFrame:SetScript("OnLeave", function() lfgFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +lfgFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + securecall(PVEFrame_ToggleFrame, 'GroupFinderFrame') + end +end) + +--------------------------------------------- +-- ADVENTURE GUIDE +--------------------------------------------- + +local adventureFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +adventureFrame:SetSize(32, 32) +adventureFrame:SetPoint("LEFT",lfgFrame,"RIGHT",4,0) +adventureFrame:EnableMouse(true) +adventureFrame:RegisterForClicks("AnyUp") +local adventureFrameIcon = adventureFrame:CreateTexture(nil,"OVERLAY",nil,7) +adventureFrameIcon:SetSize(32,32) +adventureFrameIcon:SetPoint("CENTER") +adventureFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\journal") +adventureFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +adventureFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + adventureFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +adventureFrame:SetScript("OnLeave", function() adventureFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +adventureFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + EJMicroButton:Click() + end +end) + +--------------------------------------------- +-- PvP +--------------------------------------------- + +local pvpFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +pvpFrame:SetSize(32, 32) +pvpFrame:SetPoint("LEFT",adventureFrame,"RIGHT",4,0) +pvpFrame:EnableMouse(true) +pvpFrame:RegisterForClicks("AnyUp") +local pvpFrameIcon = pvpFrame:CreateTexture(nil,"OVERLAY",nil,7) +pvpFrameIcon:SetSize(32,32) +pvpFrameIcon:SetPoint("CENTER") +pvpFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\pvp") +pvpFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +pvpFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + pvpFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +pvpFrame:SetScript("OnLeave", function() pvpFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +pvpFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + securecall(PVEFrame_ToggleFrame, 'PVPUIFrame', HonorFrame) + end +end) + +--------------------------------------------- +-- MOUNTS +--------------------------------------------- + +local mountFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +mountFrame:SetSize(32, 32) +mountFrame:SetPoint("LEFT",pvpFrame,"RIGHT",4,0) +mountFrame:EnableMouse(true) +mountFrame:RegisterForClicks("AnyUp") +local mountFrameIcon = mountFrame:CreateTexture(nil,"OVERLAY",nil,7) +mountFrameIcon:SetSize(32,32) +mountFrameIcon:SetPoint("CENTER") +mountFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\pet") +mountFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +mountFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + mountFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +mountFrame:SetScript("OnLeave", function() mountFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +mountFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + securecall(ToggleCollectionsJournal, 1) + end +end) + +--------------------------------------------- +-- SHOP +--------------------------------------------- + +local shopFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +shopFrame:SetSize(32, 32) +shopFrame:SetPoint("LEFT",mountFrame,"RIGHT",4,0) +shopFrame:EnableMouse(true) +shopFrame:RegisterForClicks("AnyUp") +local shopFrameIcon = shopFrame:CreateTexture(nil,"OVERLAY",nil,7) +shopFrameIcon:SetSize(32,32) +shopFrameIcon:SetPoint("CENTER") +shopFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\shop") +shopFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +shopFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + shopFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +shopFrame:SetScript("OnLeave", function() shopFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +shopFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + StoreMicroButton:Click() + end +end) + +--------------------------------------------- +-- HELP +--------------------------------------------- + +local helpFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +helpFrame:SetSize(32, 32) +helpFrame:SetPoint("LEFT",shopFrame,"RIGHT",4,0) +helpFrame:EnableMouse(true) +helpFrame:RegisterForClicks("AnyUp") +local helpFrameIcon = helpFrame:CreateTexture(nil,"OVERLAY",nil,7) +helpFrameIcon:SetSize(32,32) +helpFrameIcon:SetPoint("CENTER") +helpFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\help") +helpFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +helpFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + helpFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +helpFrame:SetScript("OnLeave", function() helpFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +helpFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + securecall(ToggleHelpFrame) + end +end) \ No newline at end of file diff --git a/modules/social.lua b/modules/social.lua new file mode 100644 index 0000000..0f70414 --- /dev/null +++ b/modules/social.lua @@ -0,0 +1,272 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.micromenu.show then return end + +local chatFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +chatFrame:SetSize(32, 32) +chatFrame:SetPoint("LEFT",52,0) +chatFrame:EnableMouse(true) +chatFrame:RegisterForClicks("AnyUp") +local chatFrameIcon = chatFrame:CreateTexture(nil,"OVERLAY",nil,7) +chatFrameIcon:SetSize(32,32) +chatFrameIcon:SetPoint("CENTER") +chatFrameIcon:SetTexture(cfg.mediaFolder.."microbar\\chat") +chatFrameIcon:SetVertexColor(unpack(cfg.color.normal)) + +chatFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + chatFrameIcon:SetVertexColor(unpack(cfg.color.hover)) +end) + +chatFrame:SetScript("OnLeave", function() chatFrameIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +chatFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ChatMenu:SetScale(cfg.core.scale) + ChatMenu:ClearAllPoints() + if not ChatMenu:IsShown() then + if cfg.core.position == "BOTTOM" then + ChatMenu:SetPoint("BOTTOMLEFT", chatFrame, "TOPLEFT") + else + ChatMenu:SetPoint("TOPLEFT", chatFrame, "BOTTOMLEFT") + end + ChatFrameMenuButton:Click() + else ChatMenu:Hide() end + end +end) + + +local guildFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +guildFrame:SetSize(32, 32) +guildFrame:SetPoint("LEFT",chatFrame,36,0) +guildFrame:EnableMouse(true) +guildFrame:RegisterForClicks("AnyUp") + +local guildIcon = guildFrame:CreateTexture(nil,"OVERLAY",nil,7) +guildIcon:SetPoint("CENTER") +guildIcon:SetTexture(cfg.mediaFolder.."microbar\\guild") +guildIcon:SetVertexColor(unpack(cfg.color.normal)) + +local guildText = guildFrame:CreateFontString(nil, "OVERLAY") +guildText:SetFont(cfg.text.font, cfg.text.smallFontSize) +guildText:SetPoint("CENTER", guildFrame, "TOP") +if cfg.core.position ~= "BOTTOM" then + guildText:SetPoint("CENTER", guildFrame, "BOTTOM") +end + +local guildTextBG = guildFrame:CreateTexture(nil,"OVERLAY",nil,7) +guildTextBG:SetPoint("CENTER",guildText) +guildTextBG:SetColorTexture(unpack(cfg.color.barcolor)) + +guildFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + guildIcon:SetVertexColor(unpack(cfg.color.hover)) + if not cfg.micromenu.showTooltip then return end +if ( IsInGuild() ) then + GameTooltip:SetOwner(guildFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFGuild|r]") + GameTooltip:AddLine(" ") + -------------------------- + + guildList = {} + guildName, guildRank, _ = GetGuildInfo("player") + guildMotto = GetGuildRosterMOTD() + + GameTooltip:AddDoubleLine("Guild:", guildName, 1, 1, 0, 0, 1, 0) + for i = 0, select(1, GetNumGuildMembers()) do + local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName, achievementPoints, achievementRank, isMobile, canSoR = GetGuildRosterInfo(i) + if ( online ) then + if status == 0 then status = "" elseif status == 1 then status = "AFK" elseif status == 2 then status = "DND" end + local cCol = string.format("%02X%02X%02X", RAID_CLASS_COLORS[classFileName].r*255, RAID_CLASS_COLORS[classFileName].g*255, RAID_CLASS_COLORS[classFileName].b*255) + local lineL = string.format("%s |cff%s%s|r %s %s", level, cCol, name, status, note) + local lineR = string.format("%s|cffffffff %s", isMobile and "|cffffff00[M]|r " or "", zone or "") + GameTooltip:AddDoubleLine(lineL,lineR) + end + end +else + --GameTooltip:AddLine("No Guild") +end +GameTooltip:AddLine(" ") +if ( IsInGuild() ) then GameTooltip:AddDoubleLine("<Left-click>", "Open Guild Page", 1, 1, 0, 1, 1, 1) end +----------------------- +GameTooltip:Show() +end) + +guildFrame:SetScript("OnLeave", function() if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end guildIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +guildFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + if ( IsInGuild() ) then + ToggleGuildFrame() + GuildFrameTab2:Click() + else + print"|cff6699FFSXUI|r: You are not in a guild" + end + end +end) + +local friendFrame = CreateFrame("BUTTON",nil, cfg.SXframe) +friendFrame:SetSize(32, 32) +friendFrame:SetPoint("LEFT",guildFrame,36,0) +friendFrame:EnableMouse(true) +friendFrame:RegisterForClicks("AnyUp") + +local friendIcon = friendFrame:CreateTexture(nil,"OVERLAY",nil,7) +friendIcon:SetSize(32,32) +friendIcon:SetPoint("CENTER") +friendIcon:SetTexture(cfg.mediaFolder.."microbar\\social") +friendIcon:SetVertexColor(unpack(cfg.color.normal)) + +local friendText = guildFrame:CreateFontString(nil, "OVERLAY") +friendText:SetFont(cfg.text.font, cfg.text.smallFontSize) +friendText:SetPoint("CENTER", friendFrame, "TOP") +if cfg.core.position ~= "BOTTOM" then + friendText:SetPoint("CENTER", friendFrame, "BOTTOM") +end + +local friendTextBG = guildFrame:CreateTexture(nil,"OVERLAY",nil,7) +friendTextBG:SetColorTexture(unpack(cfg.color.barcolor)) + + +friendFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + friendIcon:SetVertexColor(unpack(cfg.color.hover)) + if not cfg.micromenu.showTooltip then return end + local totalBNet, numBNetOnline = BNGetNumFriends() + if numBNetOnline then + GameTooltip:SetOwner(friendFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFSocial|r]") + GameTooltip:AddLine(" ") + -------------------------- + local onlineBnetFriends = false + for j = 1, BNGetNumFriends() do + local BNid, BNname, battleTag, _, toonname, toonid, client, online, lastonline, isafk, isdnd, broadcast, note = BNGetFriendInfo(j) + if ( online ) then + + if (not battleTag) then battleTag = "[noTag]" end + local status = "" + + local statusIcon = "Interface\\FriendsFrame\\StatusIcon-Online.blp" + if ( isafk ) then + statusIcon = "Interface\\FriendsFrame\\StatusIcon-Away.blp" + status = "(AFK)" + end + if ( isdnd ) == "D3" then + statusIcon = "Interface\\FriendsFrame\\StatusIcon-DnD.blp" + status = "(DND)" + end + + local gameIcon = "Interface\\Icons\\INV_Misc_QuestionMark.blp" + if client == "App" then + gameIcon = "Interface\\FriendsFrame\\Battlenet-Battleneticon.blp" + client = "Bnet" + elseif client == "D3" then + gameIcon = "Interface\\FriendsFrame\\Battlenet-D3icon.blp" + client = "Diablo III" + elseif client == "Hero" then + gameIcon = "Interface\\FriendsFrame\\Battlenet-HotSicon.blp" + client = "Hero of the Storm" + elseif client == "S2" then + gameIcon = "Interface\\FriendsFrame\\Battlenet-Sc2icon.blp" + client = "Starcraft 2" + elseif client == "WoW" then + gameIcon = "Interface\\FriendsFrame\\Battlenet-WoWicon.blp" + elseif client == "WTCG" then + gameIcon = "Interface\\FriendsFrame\\Battlenet-WTCGicon.blp" + client = "Heartstone" + end + if client == "WoW" then + toonname = ("(|cffecd672"..toonname.."|r)") + else + toonname = "" + end + + if not note then + note = "" + else + note = ("(|cffecd672"..note.."|r)") + end + + local lineL = string.format("|T%s:16|t|cff82c5ff %s|r %s",statusIcon, BNname, note) + local lineR = string.format("%s %s |T%s:16|t",toonname, client or "", gameIcon) + GameTooltip:AddDoubleLine(lineL,lineR) + onlineBnetFriends = true + end + end + +if onlineBnetFriends then GameTooltip:AddLine(" ") end + +local onlineFriends = false + for i = 1, GetNumFriends() do + local name, lvl, class, area, online, status, note = GetFriendInfo(i) + if ( online ) then + local status = "" + local statusIcon = "Interface\\FriendsFrame\\StatusIcon-Online.blp" + if ( isafk ) then + statusIcon = "Interface\\FriendsFrame\\StatusIcon-Away.blp" + status = "(AFK)" + end + if ( isdnd ) == "D3" then + statusIcon = "Interface\\FriendsFrame\\StatusIcon-DnD.blp" + status = "(DND)" + end + local lineL = string.format("|T%s:16|t %s, lvl:%s %s", statusIcon, name, lvl, class) + local lineR = string.format("%s", area or "") + GameTooltip:AddDoubleLine(lineL,lineR) + onlineFriends = true + end + end +if onlineFriends then GameTooltip:AddLine(" ") end +GameTooltip:AddDoubleLine("<Left-click>", "Open Friends List", 1, 1, 0, 1, 1, 1) +----------------------- +GameTooltip:Show() +end +end) + +friendFrame:SetScript("OnLeave", function() if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end friendIcon:SetVertexColor(unpack(cfg.color.normal)) end) + +friendFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleFriendsFrame() + end +end) + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") + +eventframe:RegisterEvent("FRIENDLIST_UPDATE") +eventframe:RegisterEvent("BN_FRIEND_ACCOUNT_ONLINE") +eventframe:RegisterEvent("BN_FRIEND_ACCOUNT_OFFLINE") + +eventframe:RegisterEvent("GUILD_ROSTER_UPDATE") +eventframe:RegisterEvent("GUILD_TRADESKILL_UPDATE") +eventframe:RegisterEvent("GUILD_MOTD") +eventframe:RegisterEvent("GUILD_NEWS_UPDATE") +eventframe:RegisterEvent("PLAYER_GUILD_UPDATE") + +eventframe:SetScript("OnEvent", function(self,event, ...) + local numOnline = "" + if IsInGuild() then + _, numOnline, _ = GetNumGuildMembers() + end + guildText:SetText(numOnline) + guildTextBG:SetSize(guildText:GetWidth()+4,guildText:GetHeight()+2) + guildTextBG:SetPoint("CENTER",guildText) + + local totalBNet, numBNetOnline = BNGetNumFriends() + friendText:SetText(numBNetOnline) + + if numBNetOnline == 0 then + friendText:SetText("") + else + + end + friendTextBG:SetSize(friendText:GetWidth()+4,friendText:GetHeight()+2) + friendTextBG:SetPoint("CENTER",friendText) + +end) \ No newline at end of file diff --git a/modules/system.lua b/modules/system.lua new file mode 100644 index 0000000..bec0ae8 --- /dev/null +++ b/modules/system.lua @@ -0,0 +1,223 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.system.show then return end + +local onHover = false + + local memformat = function(number) + if number > 1024 then + return string.format("%.2f|r mb", (number / 1024)) + else + return string.format("%.1f|r kb", floor(number)) + end + end + +local systemFrame = CreateFrame("Frame",nil, cfg.SXframe) +systemFrame:SetPoint("RIGHT", -290,0) +systemFrame:SetSize(120, 16) +--------------------------------------------------------------------- + +local addoncompare = function(a, b) + return a.memory > b.memory +end + + local function systemBarOnEnter() + if not cfg.system.showTooltip then return end + GameTooltip:SetOwner(systemFrame, cfg.tooltipPos) + GameTooltip:AddLine("[|cff6699FFPerformance|r]") + GameTooltip:AddLine(" ") + --------------------------------------------------- + local color = { r=1, g=1, b=0 } + local blizz = collectgarbage("count") + local addons = {} + local enry, memory + local total = 0 + local nr = 0 + local numberOfAddons = 0 + UpdateAddOnMemoryUsage() + if IsShiftKeyDown() then + GameTooltip:AddLine("Top "..cfg.system.addonListShift.." AddOns", 1,1,0) + else + GameTooltip:AddLine("Top "..cfg.system.addonList.." AddOns", 1,1,0) + end + GameTooltip:AddLine(" ") + for i=1, GetNumAddOns(), 1 do + if (GetAddOnMemoryUsage(i) > 0 ) then + memory = GetAddOnMemoryUsage(i) + entry = {name = GetAddOnInfo(i), memory = memory} + table.insert(addons, entry) + total = total + memory + end + end + table.sort(addons, addoncompare) + for _, entry in pairs(addons) do + if IsShiftKeyDown() then + numberOfAddons = cfg.system.addonListShift + else + numberOfAddons = cfg.system.addonList + end + if nr < numberOfAddons then + GameTooltip:AddDoubleLine(entry.name, memformat(entry.memory), 1, 1, 0, 1, 1, 1) + nr = nr+1 + end + end + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine("Total", memformat(total), 1,1,0, 1,1,0) + GameTooltip:AddDoubleLine("Total incl. Blizzard", memformat(blizz), 1,1,0, 1,1,0) + GameTooltip:AddLine(" ") + GameTooltip:AddDoubleLine("<Left-click>", "Force garbage collection", 1, 1, 0, 1, 1, 1) + if not IsShiftKeyDown() then + GameTooltip:AddDoubleLine("<Shift-hold>", "Show |cffffff00"..cfg.system.addonListShift.."|r addons", 1, 1, 0, 1, 1, 1) + end + ------------------------------------------- + GameTooltip:Show() +end + +local function systemBarOnLeave() + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end +end + +--------------------------------------------------------------------- + +local pingFrame = CreateFrame("BUTTON",nil, systemFrame) +pingFrame:SetPoint("CENTER") +pingFrame:SetSize(16, 16) +pingFrame:EnableMouse(true) +pingFrame:RegisterForClicks("AnyUp") + +local pingIcon = pingFrame:CreateTexture(nil,"OVERLAY",nil,7) +pingIcon:SetSize(16, 16) +pingIcon:SetPoint("CENTER") +pingIcon:SetTexture(cfg.mediaFolder.."datatexts\\ping") +pingIcon:SetVertexColor(unpack(cfg.color.normal)) + +local pingText = pingFrame:CreateFontString(nil, "OVERLAY") +pingText:SetFont(cfg.text.font, cfg.text.normalFontSize) +pingText:SetPoint("LEFT", pingIcon,"RIGHT",2,0) +pingText:SetTextColor(unpack(cfg.color.normal)) + +pingFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + pingIcon:SetVertexColor(unpack(cfg.color.hover)) + onHover = true + systemBarOnEnter() +end) + +pingFrame:SetScript("OnLeave", function() + pingIcon:SetVertexColor(unpack(cfg.color.normal)) + onHover = false + systemBarOnLeave() +end) + +pingFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + UpdateAddOnMemoryUsage() + local before = gcinfo() + collectgarbage() + UpdateAddOnMemoryUsage() + local after = gcinfo() + print("|cff6699FFSXUI|r: Cleaned: |cffffff00"..memformat(before-after)) + elseif button == "RightButton" then + ToggleFrame(VideoOptionsFrame) + end +end) +--------------------------------------------------------------------- +local fpsFrame = CreateFrame("BUTTON",nil, systemFrame) +fpsFrame:SetPoint("LEFT") +fpsFrame:SetSize(16, 16) +fpsFrame:EnableMouse(true) +fpsFrame:RegisterForClicks("AnyUp") + +local fpsIcon = fpsFrame:CreateTexture(nil,"OVERLAY",nil,7) +fpsIcon:SetSize(16, 16) +fpsIcon:SetPoint("LEFT") +fpsIcon:SetTexture(cfg.mediaFolder.."datatexts\\fps") +fpsIcon:SetVertexColor(unpack(cfg.color.normal)) + +local fpsText = fpsFrame:CreateFontString(nil, "OVERLAY") +fpsText:SetFont(cfg.text.font, cfg.text.normalFontSize) +fpsText:SetPoint("LEFT", fpsIcon,"RIGHT",2,0) +fpsText:SetTextColor(unpack(cfg.color.normal)) + +fpsFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + fpsIcon:SetVertexColor(unpack(cfg.color.hover)) + onHover = true + systemBarOnEnter() +end) + +fpsFrame:SetScript("OnLeave", function() + fpsIcon:SetVertexColor(unpack(cfg.color.normal)) + onHover = false + systemBarOnLeave() +end) + +fpsFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + UpdateAddOnMemoryUsage() + local before = gcinfo() + collectgarbage() + UpdateAddOnMemoryUsage() + local after = gcinfo() + print("|cff6699FFSXUI|r: Cleaned: |cffffff00"..memformat(before-after)) + elseif button == "RightButton" then + ToggleFrame(VideoOptionsFrame) + end +end) +--------------------------------------------------------------------- + +local function SXUImemory() +local t = 0 +UpdateAddOnMemoryUsage() +for i=1, GetNumAddOns(), 1 do + t = t + GetAddOnMemoryUsage(i) +end +return cfg.memformat(t) + +end + +local function updatePerformanceText() + local fps = floor(GetFramerate()) + local BWIn, BWOut, LCHome, LCWorld = GetNetStats() + pingText:SetText(LCHome.."ms") + pingFrame:SetSize(pingText:GetStringWidth()+18, 16) + fpsText:SetText(fps.."fps") + fpsFrame:SetSize(fpsText:GetStringWidth()+18, 16) + if onHover then + systemBarOnEnter() + end +end + +local elapsed = 0 +systemFrame:SetScript('OnUpdate', function(self, e) + elapsed = elapsed + e + if elapsed >= 1 then + updatePerformanceText() + elapsed = 0 + end +end) + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("MODIFIER_STATE_CHANGED") + +eventframe:SetScript("OnEvent", function(this, event, arg1, arg2, arg3, arg4, ...) + +if event == "MODIFIER_STATE_CHANGED" then + if InCombatLockdown() then return end + if arg1 == "LSHIFT" or arg1 == "RSHIFT" then + if arg2 == 1 then + if onHover then + systemBarOnEnter() + end + elseif arg2 == 0 then + if onHover then + systemBarOnEnter() + end + end + end + end +end) \ No newline at end of file diff --git a/modules/talent.lua b/modules/talent.lua new file mode 100644 index 0000000..8117c75 --- /dev/null +++ b/modules/talent.lua @@ -0,0 +1,228 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.talent.show then return end + +local currentSpec = 0 -- from 1-4 +local currentSpecID, currentSpecName = 0,0 --global id +local lootspecid = 0 +local id, name = 0,0 + +local talentFrame = CreateFrame("Frame",'SX_TalentFrame', cfg.SXframe) +talentFrame:SetPoint("RIGHT", cfg.SXframe, "CENTER", -110,0) +talentFrame:SetSize(16, 16) +--------------------------------------------- +-- LOOTSPEC FRAME +--------------------------------------------- +local lootSpecFrame = CreateFrame("BUTTON",'SX_LootSpecFrame', talentFrame) +if cfg.core.position ~= "BOTTOM" then + lootSpecFrame:SetPoint("TOP", talentFrame, "BOTTOM", 0,-6) +else + lootSpecFrame:SetPoint("BOTTOM", talentFrame, "TOP", 0,8) +end +lootSpecFrame:RegisterForClicks("AnyUp") +lootSpecFrame:Hide() +lootSpecFrame:EnableMouse(true) + +lootSpecFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "RightButton" then + lootSpecFrame:Hide() + end +end) + +local lootSpecText = lootSpecFrame:CreateFontString(nil, "OVERLAY") +lootSpecText:SetFont(cfg.text.font, cfg.text.normalFontSize) +lootSpecText:SetPoint("TOP") +lootSpecText:SetText("LOOT SPECIALIZATION") +lootSpecText:SetTextColor(unpack(cfg.color.normal)) + +local defaultLootTypeButton = CreateFrame("BUTTON",nil, lootSpecFrame) +defaultLootTypeButton:SetSize(lootSpecText:GetStringWidth(),cfg.text.normalFontSize) +defaultLootTypeButton:SetPoint("CENTER",lootSpecText) +defaultLootTypeButton:EnableMouse(true) +defaultLootTypeButton:RegisterForClicks("AnyUp") + +defaultLootTypeButton:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + if GetLootSpecialization() ~= 0 then + SetLootSpecialization(0) + print("|cffffff00Loot Specialization set to: Current Specialization") + lootSpecFrame:Hide() + end + elseif button == "RightButton" then + lootSpecFrame:Hide() + end +end) + +local lootSpectBG = lootSpecFrame:CreateTexture(nil,"OVERLAY",nil,7) +lootSpectBG:SetPoint("TOP") +lootSpectBG:SetColorTexture(unpack(cfg.color.barcolor)) +globalLootSpecFrame = lootSpecFrame + +--------------------------------------------- +-- PRIMARY SPEC FRAME +--------------------------------------------- + +local primarySpecFrame = CreateFrame("BUTTON",nil, talentFrame) +primarySpecFrame:SetPoint("RIGHT") +primarySpecFrame:SetSize(16, 16) +primarySpecFrame:EnableMouse(true) +primarySpecFrame:RegisterForClicks("AnyUp") + +local primarySpecText = primarySpecFrame:CreateFontString(nil, "OVERLAY") +primarySpecText:SetFont(cfg.text.font, cfg.text.normalFontSize) +primarySpecText:SetPoint("RIGHT") +primarySpecText:SetTextColor(unpack(cfg.color.normal)) + +local primarySpecIcon = primarySpecFrame:CreateTexture(nil,"OVERLAY",nil,7) +primarySpecIcon:SetSize(16, 16) +primarySpecIcon:SetPoint("RIGHT", primarySpecText,"LEFT",-2,0) +primarySpecIcon:SetVertexColor(unpack(cfg.color.normal)) + +primarySpecFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + GameTooltip:SetOwner(talentFrame, cfg.tooltipPos) + currentSpec = GetSpecialization() + currentSpecID, currentSpecName = GetSpecializationInfo(currentSpec) + lootspecid = GetLootSpecialization() + if lootspecid == 0 then lootspecid = currentSpecID end + id, name = GetSpecializationInfoByID(lootspecid) + if currentSpecID ~= id then + GameTooltip:AddLine("|cffffffffLoot is currently set to |cffffff00"..name.."|cffffffff spec") + GameTooltip:AddDoubleLine("<Right-Click>", "Change lootspec", 1, 1, 0, 1, 1, 1) + end + primarySpecIcon:SetVertexColor(unpack(cfg.color.hover)) + GameTooltip:Show() +end) + +primarySpecFrame:SetScript("OnLeave", function() + if GetActiveSpecGroup() == 1 then + primarySpecIcon:SetVertexColor(unpack(cfg.color.normal)) + else + primarySpecIcon:SetVertexColor(unpack(cfg.color.inactive)) + end + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end +end) + +primarySpecFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + ToggleTalentFrame(1) + elseif button == "RightButton" then + if globalLootSpecFrame:IsShown() then + globalLootSpecFrame:Hide() + else + globalLootSpecFrame:Show() + end + end +end) +--------------------------------------------------------------------- + +local function createLootSpecButtons() +for index = 1,4 do + local id, name = GetSpecializationInfo(index) + if ( name ) then + lootSpecFrame:SetSize(lootSpecText:GetStringWidth()+16, (index+1)*18) + lootSpectBG:SetSize(lootSpecFrame:GetSize()) + currentSpecID, currentSpecName = GetSpecializationInfo(index) + + local lootSpecButton = CreateFrame("BUTTON",nil, lootSpecFrame) + lootSpecButton:SetPoint("TOPLEFT", lootSpecText, 0, index*-18) + lootSpecButton:SetSize(16, 16) + lootSpecButton:EnableMouse(true) + lootSpecButton:RegisterForClicks("AnyUp") + + + local lootSpecbuttonText = lootSpecButton:CreateFontString(nil, "OVERLAY") + lootSpecbuttonText:SetFont(cfg.text.font, cfg.text.smallFontSize) + lootSpecbuttonText:SetPoint("RIGHT") + if currentSpecName then currentSpecName = string.upper(currentSpecName) end + lootSpecbuttonText:SetText(currentSpecName) + + local lootSpecbuttonIcon = lootSpecButton:CreateTexture(nil,"OVERLAY",nil,7) + lootSpecbuttonIcon:SetSize(16, 16) + lootSpecbuttonIcon:SetPoint("LEFT") + lootSpecbuttonIcon:SetTexture(cfg.mediaFolder.."spec\\"..cfg.CLASS) + lootSpecbuttonIcon:SetTexCoord(unpack(cfg.specCoords[index])) + + local id = GetSpecializationInfo(index) + if GetLootSpecialization() == id then + lootSpecbuttonText:SetTextColor(unpack(cfg.color.normal)) + lootSpecbuttonIcon:SetVertexColor(unpack(cfg.color.normal)) + else + lootSpecbuttonText:SetTextColor(unpack(cfg.color.inactive)) + lootSpecbuttonIcon:SetVertexColor(unpack(cfg.color.inactive)) + end + lootSpecButton:SetSize(lootSpecbuttonText:GetStringWidth()+18,16) + + lootSpecButton:SetScript("OnEnter", function() if InCombatLockdown() then return end lootSpecbuttonIcon:SetVertexColor(unpack(cfg.color.hover)) end) + lootSpecButton:SetScript("OnLeave", function() + local id = GetSpecializationInfo(index) + if GetLootSpecialization() == id then + lootSpecbuttonText:SetTextColor(unpack(cfg.color.normal)) + lootSpecbuttonIcon:SetVertexColor(unpack(cfg.color.normal)) + else + lootSpecbuttonText:SetTextColor(unpack(cfg.color.inactive)) + lootSpecbuttonIcon:SetVertexColor(unpack(cfg.color.inactive)) + end + end) + + lootSpecButton:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + local id = GetSpecializationInfo(index) + SetLootSpecialization(id) + lootSpecbuttonText:SetTextColor(unpack(cfg.color.normal)) + lootSpecbuttonIcon:SetVertexColor(unpack(cfg.color.normal)) + lootSpecFrame:Hide() + elseif button == "RightButton" then + lootSpecFrame:Hide() + end + end) + end +end +end + +--------------------------------------------- +-- EVENTS +--------------------------------------------- + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") +eventframe:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED") +eventframe:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED") +eventframe:RegisterEvent("PLAYER_LOOT_SPEC_UPDATED") +eventframe:RegisterEvent("PLAYER_REGEN_DISABLED") + +eventframe:SetScript("OnEvent", function(self,event, ...) + if event == ("PLAYER_ENTERING_WORLD") then + createLootSpecButtons() + end + if event == ("PLAYER_REGEN_DISABLED") then + if lootSpecFrame:IsShown() then + lootSpecFrame:Hide() + end + end + + local primarySpec = GetSpecialization(false, false, 1) + if primarySpec ~= nil then + local id, name = GetSpecializationInfo(primarySpec) + if name then name = string.upper(name) end + --name = string.upper(name) + primarySpecText:SetText(name) + primarySpecIcon:SetTexture(cfg.mediaFolder.."spec\\"..cfg.CLASS) + primarySpecIcon:SetTexCoord(unpack(cfg.specCoords[primarySpec])) + primarySpecFrame:SetSize(primarySpecText:GetStringWidth()+18, 16) + primarySpecFrame:Show() + primarySpecFrame:EnableMouse(true) + else + primarySpecFrame:Hide() + primarySpecFrame:EnableMouse(false) + end + primarySpecIcon:SetVertexColor(unpack(cfg.color.normal)) + primarySpecText:SetTextColor(unpack(cfg.color.normal)) + talentFrame:SetSize((primarySpecFrame:GetWidth()), 16) +end) diff --git a/modules/tradeskill.lua b/modules/tradeskill.lua new file mode 100644 index 0000000..4852711 --- /dev/null +++ b/modules/tradeskill.lua @@ -0,0 +1,274 @@ +local addon, ns = ... +local cfg = ns.cfg +local unpack = unpack +-------------------------------------------------------------- +if not cfg.tradeSkill.show then return end + +local proffessions = { + ['ALCHEMY'] = {"Alchemical Catalyst", "Secrets of Draenor Alchemy", "Northrend Alchemy Research"}, + ['BLACKSMITHING'] = {"Truesteel Ignot", "Secrets of Draenor Blacksmithing"}, + ['ENCHANTING'] = {"Temporal Crystal", "Secrets of Draenor Enchanting"}, + ['ENGINEERING'] = {"Gearsoring Parts", "Secrets of Draenor Engineering"}, + ['INSCRIPTION'] = {"War Paints", "Secrets of Draenor Inscription","Draenor Merchant Order"}, + ['JEWELCRAFTING'] = {"Taladite Crystal", "Secrets of Draenor Jewelcrafting"}, + ['LEATHERWORKING'] = {"Burnished Leather", "Secrets of Draenor Leatherworking"}, + ['TAILORING'] = {"Hexweave Cloth", "Secrets of Draenor Tailoring"}, +} + +local prof1OnCooldown = false +local prof2OnCooldown = false + +local tradeSkillFrame = CreateFrame("Frame",nil, cfg.SXframe) +tradeSkillFrame:SetPoint("LEFT", cfg.SXframe, "CENTER", 110,0) +tradeSkillFrame:SetSize(16, 16) +--------------------------------------------------------------------- +local primaryTradeSkillFrame = CreateFrame("BUTTON",nil, tradeSkillFrame) +primaryTradeSkillFrame:SetSize(16, 16) +primaryTradeSkillFrame:SetPoint("LEFT") +primaryTradeSkillFrame:EnableMouse(true) +primaryTradeSkillFrame:RegisterForClicks("AnyUp") + +local primaryTradeSkillIcon = primaryTradeSkillFrame:CreateTexture(nil,"OVERLAY",nil,7) +primaryTradeSkillIcon:SetSize(16, 16) +primaryTradeSkillIcon:SetPoint("LEFT") +primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + +local primaryTradeSkillText = primaryTradeSkillFrame:CreateFontString(nil, "OVERLAY") +primaryTradeSkillText:SetFont(cfg.text.font, cfg.text.normalFontSize) +primaryTradeSkillText:SetPoint("RIGHT",primaryTradeSkillFrame,2,0 ) +primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + +local primaryTradeSkillStatusbar = CreateFrame("StatusBar", nil, primaryTradeSkillFrame) +primaryTradeSkillStatusbar:SetStatusBarTexture(1,1,1) +primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) +primaryTradeSkillStatusbar:SetPoint("TOPLEFT", primaryTradeSkillText, "BOTTOMLEFT",0,-2) + +local primaryTradeSkillStatusbarBG = primaryTradeSkillStatusbar:CreateTexture(nil,"BACKGROUND",nil,7) +primaryTradeSkillStatusbarBG:SetPoint("TOPLEFT", primaryTradeSkillText, "BOTTOMLEFT",0,-2) +primaryTradeSkillStatusbarBG:SetColorTexture(unpack(cfg.color.inactive)) + +primaryTradeSkillFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.hover)) + primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.hover)) + if not cfg.tradeSkill.showTooltip then return end + GameTooltip:SetOwner(tradeSkillFrame, cfg.tooltipPos) + addCooldownsToTooltip() + GameTooltip:Show() +end) + +primaryTradeSkillFrame:SetScript("OnLeave", function() + if prof1OnCooldown then + primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive)) + primaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive)) + else + primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + end + primaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end +end) + +primaryTradeSkillFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + local prof1, prof2 = GetProfessions() + if prof1 then + if (GetProfessionInfo(prof1) == ('Herbalism')) then + ToggleSpellBook(BOOKTYPE_PROFESSION) + elseif(GetProfessionInfo(prof1) == ('Skinning')) then + ToggleSpellBook(BOOKTYPE_PROFESSION) + elseif(GetProfessionInfo(prof1) == ('Mining')) then + CastSpellByName("Smelting") + else + CastSpellByName((GetProfessionInfo(prof1))) + end + end + elseif button == "RightButton" then + ToggleSpellBook(BOOKTYPE_PROFESSION) + end +end) +--------------------------------------------------------------------- +local secondaryTradeSkillFrame = CreateFrame("BUTTON",nil, tradeSkillFrame) +secondaryTradeSkillFrame:SetPoint("RIGHT") +secondaryTradeSkillFrame:SetSize(16, 16) +secondaryTradeSkillFrame:EnableMouse(true) +secondaryTradeSkillFrame:RegisterForClicks("AnyUp") + +local secondaryTradeSkillIcon = secondaryTradeSkillFrame:CreateTexture(nil,"OVERLAY",nil,7) +secondaryTradeSkillIcon:SetSize(16, 16) +secondaryTradeSkillIcon:SetPoint("LEFT") +secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + +local secondaryTradeSkillText = secondaryTradeSkillFrame:CreateFontString(nil, "OVERLAY") +secondaryTradeSkillText:SetFont(cfg.text.font, cfg.text.normalFontSize) +secondaryTradeSkillText:SetPoint("LEFT", secondaryTradeSkillIcon,"RIGHT",2,0) +secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + +local secondaryTradeSkillStatusbar = CreateFrame("StatusBar", nil, secondaryTradeSkillFrame) +secondaryTradeSkillStatusbar:SetStatusBarTexture(1,1,1) +secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) +secondaryTradeSkillStatusbar:SetPoint("TOPLEFT", secondaryTradeSkillText, "BOTTOMLEFT",0,-2) + +local secondaryTradeSkillStatusbarBG = secondaryTradeSkillStatusbar:CreateTexture(nil,"BACKGROUND",nil,7) +secondaryTradeSkillStatusbarBG:SetPoint("TOPLEFT", secondaryTradeSkillText, "BOTTOMLEFT",0,-2) +secondaryTradeSkillStatusbarBG:SetColorTexture(unpack(cfg.color.inactive)) + +secondaryTradeSkillFrame:SetScript("OnEnter", function() + if InCombatLockdown() then return end + secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.hover)) + secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.hover)) + if not cfg.tradeSkill.showTooltip then return end + GameTooltip:SetOwner(tradeSkillFrame, cfg.tooltipPos) + addCooldownsToTooltip() + GameTooltip:Show() +end) + +secondaryTradeSkillFrame:SetScript("OnLeave", function() + if prof2OnCooldown then + secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive)) + secondaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive)) + else + secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + end + secondaryTradeSkillStatusbar:SetStatusBarColor(unpack(cfg.color.normal)) + if ( GameTooltip:IsShown() ) then GameTooltip:Hide() end +end) + +secondaryTradeSkillFrame:SetScript("OnClick", function(self, button, down) + if InCombatLockdown() then return end + if button == "LeftButton" then + local prof1, prof2 = GetProfessions() + if prof2 then + if (GetProfessionInfo(prof2) == ('Herbalism')) then + ToggleSpellBook(BOOKTYPE_PROFESSION) + elseif(GetProfessionInfo(prof2) == ('Skinning')) then + ToggleSpellBook(BOOKTYPE_PROFESSION) + elseif(GetProfessionInfo(prof2) == ('Mining')) then + CastSpellByName("Smelting") + else + CastSpellByName((GetProfessionInfo(prof2))) + end + end + elseif button == "RightButton" then + ToggleSpellBook(BOOKTYPE_PROFESSION) + end +end) +--------------------------------------------------------------------- + +local eventframe = CreateFrame("Frame") +eventframe:RegisterEvent("PLAYER_ENTERING_WORLD") +eventframe:RegisterEvent("TRADE_SKILL_UPDATE") +eventframe:RegisterEvent("TRAINER_CLOSED") +eventframe:RegisterEvent("SPELLS_CHANGED") +eventframe:RegisterUnitEvent("UNIT_SPELLCAST_STOP", "player") + +eventframe:SetScript("OnEvent", function(self,event, ...) + local prof1, prof2 = GetProfessions() + if prof1 then + local prof1Name, _, prof1Rank, prof1MaxRank = GetProfessionInfo(prof1) + prof1Name = string.upper(prof1Name) + primaryTradeSkillText:SetText(prof1Name) + primaryTradeSkillIcon:SetTexture(cfg.mediaFolder.."profession\\"..prof1Name) + if prof1Rank == prof1MaxRank then + primaryTradeSkillStatusbar:Hide() + else + primaryTradeSkillStatusbar:Show() + end + primaryTradeSkillStatusbar:SetMinMaxValues(0, prof1MaxRank) + primaryTradeSkillStatusbar:SetValue(prof1Rank) + primaryTradeSkillFrame:SetSize(primaryTradeSkillText:GetStringWidth()+18, 16) + primaryTradeSkillStatusbar:SetSize(primaryTradeSkillText:GetStringWidth(),3) + primaryTradeSkillStatusbarBG:SetSize(primaryTradeSkillText:GetStringWidth(),3) + primaryTradeSkillFrame:Show() + primaryTradeSkillFrame:EnableMouse(true) + + primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + + --[[for i=1,GetNumTradeSkills() do + local cooldown = GetTradeSkillCooldown(i) + if cooldown then + local name = GetTradeSkillInfo(i) + for k, v in pairs(proffessions) do + for u = 1, #v do + if k == prof1Name then + if v[u] == name then + if not prof1OnCooldown then prof1OnCooldown = true end + primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive)) + primaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive)) + if not prof1OnCooldown then + primaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + primaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + end + end + end + end + end + end + end]]-- + else + primaryTradeSkillFrame:Hide() + primaryTradeSkillFrame:EnableMouse(false) + end + + if prof2 then + local prof2Name, _, prof2rank, prof2maxRank = GetProfessionInfo(prof2) + prof2Name = string.upper(prof2Name) + secondaryTradeSkillText:SetText(prof2Name) + secondaryTradeSkillIcon:SetTexture(cfg.mediaFolder.."profession\\"..prof2Name) + if prof2rank == prof2maxRank then + secondaryTradeSkillStatusbar:Hide() + else + secondaryTradeSkillStatusbar:Show() + end + secondaryTradeSkillStatusbar:SetMinMaxValues(0, prof2maxRank) + secondaryTradeSkillStatusbar:SetValue(prof2rank) + secondaryTradeSkillFrame:SetSize(secondaryTradeSkillText:GetStringWidth()+18, 16) + secondaryTradeSkillStatusbar:SetSize(secondaryTradeSkillText:GetStringWidth(),3) + secondaryTradeSkillStatusbarBG:SetSize(secondaryTradeSkillText:GetStringWidth(),3) + secondaryTradeSkillFrame:Show() + secondaryTradeSkillFrame:EnableMouse(true) + + secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + + --[[for i=1,GetNumTradeSkills() do + local cooldown = GetTradeSkillCooldown(i) + if cooldown then + local name = GetTradeSkillInfo(i) + for k, v in pairs(proffessions) do + for u = 1, #v do + if k == prof2Name then + if v[u] == name then + if not prof2OnCooldown then prof2OnCooldown = true end + secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.inactive)) + secondaryTradeSkillText:SetTextColor(unpack(cfg.color.inactive)) + if not prof2OnCooldown then + secondaryTradeSkillIcon:SetVertexColor(unpack(cfg.color.normal)) + secondaryTradeSkillText:SetTextColor(unpack(cfg.color.normal)) + end + end + end + end + end + end + end]]-- + else + secondaryTradeSkillFrame:Hide() + secondaryTradeSkillFrame:EnableMouse(false) + end + tradeSkillFrame:SetSize((primaryTradeSkillFrame:GetWidth())+(secondaryTradeSkillFrame:GetWidth()+4), 16) +end) + + +function addCooldownsToTooltip() + for i,v in pairs(C_TradeSkillUI.GetFilteredRecipeIDs()) do + local _, cooldown, secondsToCooldown, dunno = C_TradeSkillUI.GetRecipeCooldown(v) + if cooldown then + local name = C_TradeSkillUI.GetRecipeInfo(v).name + GameTooltip:AddDoubleLine(name, SecondsToTime(secondsToCooldown), 1, 1, 0, 1, 1, 1) + end + end +end diff --git a/settings.lua b/settings.lua new file mode 100644 index 0000000..07976aa --- /dev/null +++ b/settings.lua @@ -0,0 +1,314 @@ +----------------------------------------------------------------- +-- CONFIGURATION FILE DO NOT TOUCH ANYTHING BELLOW HERE +----------------------------------------------------------------- +local addon, ns = ... +local cfg = {} +ns.cfg = cfg + + +cfg.NAME = UnitName("player") +cfg.CLASS = select(2, UnitClass("player")) +cfg.cc = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[cfg.CLASS] --CLASS COLOR + +--media path +cfg.mediaFolder = "Interface\\AddOns\\"..addon.."\\media\\" + +--------------------------------------------- +-- DO NOT TOUCH ANYTHING ABOVE HERE +--------------------------------------------- + +cfg.color = { + normal = {1,1,1,.75}, -- SETS THE SAME COLOR FOR THE TEXT + inactive = {1,1,1,.25}, -- SET THE COLOR FOR THE INACTICE ICONS + hover = {cfg.cc.r,cfg.cc.g,cfg.cc.b,.75}, -- DOES NOT CHANGE THE TEXTCOLOR + barcolor = {.094,.094,.094,.75}, -- THE COLOR OF THE BAR + --barcolor = {.05,.05,.05,0}, -- THE COLOR OF THE BAR +} +if cfg.CLASS == "PRIEST" then cfg.color.hover = {.5,.5,0,.75} end -- ADDED BEACUSE NORMALY THE PRIEST COLOR IS THE SAME AS THE NORMAL COLOR + +cfg.text = { + font = cfg.mediaFolder.."homizio_bold.ttf", -- SETS THE FONT + normalFontSize = 12, -- SET THE SIZE OF THE TEXTS + smallFontSize = 11, -- SETS THE SIZE OF THE SMALLER TEXTS +} + +cfg.core = { + height = 35, + position = "BOTTOM", -- THE POSITION OF THE BAR USE "BOTTOM" OR "TOP" + scale = 0.83, -- SCALE BAR TO GET ROOM FOR ALL THE ICONS AND TEXT + strata = "HIGH", -- AT WHAT STRATA THE BAR SHOULD BE AT +} + +cfg.micromenu = { + show = true, -- USES THIS MODULE + showTooltip = true, -- ADDS TOOLTIPS FOR THE SOSIAL FRAMES +} + +cfg.armor = { + show = true, -- USES THIS MODULE + minArmor = 20, -- WHEN THE ANVIL GOES FROM INACTIVE TO ACTIVE + maxArmor = 75, -- AT WHAT % IT WILL SHOW ARMORTEXT INSTEAD OF ILVL +} + +cfg.talent = { + show = true, -- USES THIS MODULE +} + +cfg.clock = { + show = true, -- USES THIS MODULE + showTooltip = true, -- SHOWS SOME INFO AND REALMTIME OR LOCAL TIME +} + +cfg.tradeSkill = { + show = true, -- USES THIS MODULE + showTooltip = true, -- SHOW WHAT TRADESKILLS THAT ARE ON COOLDOWN +} + +cfg.currency = { + show = true, -- USES THIS MODULE + showXPbar = true, -- SHOW A XP-BAR ON YOUR CHARACTERS THAT HAS NOT REACHED MAX LVL + showTooltip = true, -- SHOWS YOUR RECOURCES ACCORING TO THE DESCRIPTION OR YOUR XP INFO +} + +cfg.system = { + show = true, -- USES THIS MODULE + showTooltip = true, -- SHOWS A LIST OF ADDONS AND HOW MUCH SYSTEM THEY USE + addonList = 10, -- SHOW HOW MANY ADDONS TO SHOW ON HOVER + addonListShift = 25, -- SHOW HOW MANY ADDONS TO SHOW ON HOVER WHILE SHIFT IS DOWN +} + +cfg.gold = { + showTooltip = true, -- SHOWS THE GOLD OF YOUR OTHER CHARACTERS ON THE SAME SERVER AND SAME SIDE + show = true, -- USES THIS MODULE + firstWeekday = 2, -- 1 is Sunday, 2 is Monday, different countries have different first day of the week +} + +cfg.heartstone = { + show = true, -- USES THIS MODULE + showTooltip = true, -- SHOWS THE COOLDOWN ON MOUSEOVER +} + +cfg.useConfig = false -- !! DO NOT TOUCH !! +--------------------------------------------- +-- DO NOT TOUCH ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING !! +--------------------------------------------- +-- CREATE THE CORE FRAME +--------------------------------------------- + +local unpack = unpack +local SX_bottombar = CreateFrame("Frame","SX_bottombar", UIParent) +SX_bottombar:SetSize(0, cfg.core.height) +SX_bottombar:SetScale(cfg.core.scale) +SX_bottombar:SetFrameStrata(cfg.core.strata) + +SX_bottombar:SetPoint(cfg.core.position) +SX_bottombar:SetPoint("LEFT") +SX_bottombar:SetPoint("RIGHT") + +cfg.SXframe = SX_bottombar + +local coreTexture = SX_bottombar:CreateTexture(nil,"BACKGROUND",nil,-8) +coreTexture:SetAllPoints() +coreTexture:SetColorTexture(unpack(cfg.color.barcolor)) + +cfg.tooltipPos = "ANCHOR_TOP" +if cfg.core.position ~= "BOTTOM" then + cfg.tooltipPos = "ANCHOR_BOTTOM",0,-20 +end + + +local SX_databarConfig = CreateFrame("Frame",nil, UIParent) + +SX_databarConfig:SetPoint("CENTER") +--SX_databarConfig:Hide() + +cfg.SXconfigFrame = nil +if cfg.useConfig then + cfg.SXconfigFrame = SX_databarConfig +end + +local eventframe = CreateFrame("Frame",nil, UIParent) +eventframe:RegisterEvent("PET_BATTLE_OPENING_START") +eventframe:RegisterEvent("PET_BATTLE_CLOSE") +eventframe:SetScript("OnEvent", function(self,event, ...) + if (event == "PET_BATTLE_OPENING_START") then + SX_bottombar:Hide() + elseif (event == "PET_BATTLE_CLOSE") then + SX_bottombar:Show() + end +end) +--------------------------------------------- +-- SAVED VARIABLES TABLE +--------------------------------------------- + +-- copies missing fields from source table +function CopyTable(src, dest) + if type(dest) ~= "table" then + dest = {} + end + + for k, v in pairs(src) do + if type(v) == "table" then + dest[k] = CopyTable(v, dest[k]) + elseif type(v) ~= type(dest[k]) then + dest[k] = v + end + end + + return dest +end + +-- removes everything that is present in source table from another table +function DiffTable(src, dest) + if type(dest) ~= "table" then + return {} + end + + if type(src) ~= "table" then + return dest + end + + for k, v in pairs(dest) do + if type(v) == "table" then + if not next(DiffTable(src[k], v)) then + dest[k] = nil + end + elseif v == src[k] then + dest[k] = nil + end + end + + return dest +end + +local function ConvertDateToNumber(month, day, year) + month = gsub(month, "(%d)(%d?)", function(d1, d2) return d2 == "" and "0"..d1 or d1..d2 end) -- converts M to MM + day = gsub(day, "(%d)(%d?)", function(d1, d2) return d2 == "" and "0"..d1 or d1..d2 end) -- converts D to DD + + return tonumber(year..month..day) +end + +-------------- +-- DEFAULTS -- +-------------- + +local D = { + ["money_related_stuff"] = {} +} + +----------- +-- STUFF -- +----------- + +local function Controller_OnEvent(self, event, arg) + if event == "ADDON_LOADED" and arg == addon then -- "test" is addon name +local CONFIG = CopyTable(D, TEST_CONFIG) +ns.CONFIG = CONFIG -- makes this table available throughout addon + +local playerName, playerFaction, playerRealm = UnitName("player"), UnitFactionGroup("player"), GetRealmName() + +if not CONFIG["money_related_stuff"][playerRealm] then + CONFIG["money_related_stuff"][playerRealm] = {} -- creates a table if it doesn't exist +end + +local realmData = CONFIG["money_related_stuff"][playerRealm] -- just an alias +ns.realmData = realmData + +if not realmData[playerFaction] then + realmData[playerFaction] = {} -- creates a table if it doesn't exist +end + +local factionData = realmData[playerFaction] +ns.factionData = factionData + +if not factionData[playerName] then + factionData[playerName] = {} -- creates a table if it doesn't exist +end + +ns.playerData = factionData[playerName] + +self:UnregisterEvent("ADDON_LOADED") + elseif event == "PLAYER_LOGIN" then + local playerData = ns.playerData + + if not playerData["CLASS"] then + playerData["CLASS"] = cfg.CLASS + end + + local weekday, month, day, year = CalendarGetDate() + local today = ConvertDateToNumber(month, day, year) + local updateData + + if playerData.lastLoginDate then + if playerData.lastLoginDate < today then -- is true, if last time player logged in was the day before or even earlier + playerData.lastLoginDate = today + updateData = true + end + else + playerData.lastLoginDate = today + updateData = true + end + + if updateData then -- daily updates + if playerData["money_on_first_weekday"] then + if weekday == cfg.gold.firstWeekday then -- 1 is Sunday, 2 is Monday, different countries have different first day of the week + playerData["money_on_first_weekday"] = GetMoney() + end + else + playerData["money_on_first_weekday"] = GetMoney() + end + + playerData["money_on_first_login_today"] = GetMoney() + end + + playerData["money_on_session_start"] = GetMoney() -- this one resets on every single login or UI reload + + self:UnregisterEvent("PLAYER_LOGIN") + elseif event == "PLAYER_LOGOUT" then + TEST_CONFIG = DiffTable(D, ns.CONFIG) -- writes data into TEST_CONFIG table + end +end + +local Controller = CreateFrame("Frame") +Controller:RegisterEvent("ADDON_LOADED") +Controller:RegisterEvent("PLAYER_LOGIN") +Controller:RegisterEvent("PLAYER_LOGOUT") +Controller:SetScript("OnEvent", Controller_OnEvent) + +--------------------------------------------- +-- SHORTENER FUNCTIONS +--------------------------------------------- +cfg.specCoords = { +-- index left right top bottom + [ 1] = { 0.00, 0.25, 0.00, 1 }, + [ 2] = { 0.25, 0.50, 0.00, 1 }, + [ 3] = { 0.50, 0.75, 0.00, 1 }, + [ 4] = { 0.75, 1.00, 0.00, 1 }, +} + +cfg.SVal = function(val) + if val > 1E10 then + return (floor(val/1E9)).."b" + elseif val > 1E9 then + return (floor((val/1E9)*10)/10).."b" + elseif val > 1E7 then + return (floor(val/1E6)).."m" + elseif val > 1E6 then + return (floor((val/1E6)*10)/10).."m" + elseif val > 1E4 then + return (floor(val/1E3)).."k" + elseif val >= 1E3 then + return (floor(val/1E3)) .. (" %03d"):format(val % 1E3) + else + return val + end +end + +function cfg.hex(r, g, b) + if r then + if (type(r) == "table") then + if(r.r) then r, g, b = r.r, r.g, r.b else r, g, b = unpack(r) end + end + return ("|cff%02x%02x%02x"):format(r * 255, g * 255, b * 255) + end +end