MxW_Addon/Frame/Frame_Alert.lua

91 lines
3.6 KiB
Lua

-- MxW (MxW Addon)
-- By mikx
-- https://git.mikx.xyz/mikx/MxW_Addon
-- Licensed under the GNU General Public License 3.0
-- See included License file for more informations.
local MX = LibStub("AceAddon-3.0"):GetAddon("MxW");
local L = LibStub("AceLocale-3.0"):GetLocale("MxW");
local AceGUI = LibStub("AceGUI-3.0")
local GUI_LOOTCOLLECTED, GUI_SCROLLCONTAINER
local lootCollectedLastEntry = nil
local mxwVersion = GetAddOnMetadata("MxW", "Version")
local date = C_DateAndTime.GetCurrentCalendarTime();
local weekday, month, day, year = date.weekday, date.month, date.monthDay, date.year;
function MX:ShowAlert(item,stackqty,value,y)
local AlertUI = CreateFrame("Frame", string.format("%sAlert%d", "mxw", y), nil, "BackdropTemplate")
local AlertIcon = AlertUI:CreateTexture(nil,"ARTWORK")
local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, itemSellPrice = GetItemInfo(item)
local frameWidth = 200 + (string.len(itemLink)*2);
AlertUI:SetFrameStrata("BACKGROUND")
AlertUI:SetWidth(frameWidth)
AlertUI:SetHeight(80)
AlertUI:SetPoint("CENTER", 0, y)
AlertUI:SetBackdrop(
{
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Buttons/WHITE8x8",
tile = true, tileSize = 16, edgeSize = 1,
insets = { left = 2, right = 2, top = 2, bottom = 2 }
});
AlertUI:SetBackdropColor(0.20,0.20,0.20,1);
-- Label - Title
AlertUI.title = AlertUI:CreateFontString(nil, "ARTWORK");
AlertUI.title:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 12);
AlertUI.title:SetPoint("CENTER",35,30);
AlertUI.title:SetTextColor(1.00,0.49,0.04);
AlertUI.title:SetText(L["Alert_Frame_Title"]);
-- Label - Thresold
AlertUI.thresold = AlertUI:CreateFontString(nil, "ARTWORK");
AlertUI.thresold:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10);
AlertUI.thresold:SetPoint("CENTER",35,17);
AlertUI.thresold:SetTextColor(1,1,1);
AlertUI.thresold:SetText(L["Alert_Frame_Thresold"]..MX:FormatMoneyGoldOnly(Farmer_Logic_MinAlert));
-- Label - ItemLink
AlertUI.itemlink = AlertUI:CreateFontString(nil, "ARTWORK");
AlertUI.itemlink:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10);
AlertUI.itemlink:SetPoint("CENTER",35,0);
AlertUI.itemlink:SetTextColor(1,1,1);
AlertUI.itemlink:SetText(itemLink);
-- Label - Item Value
AlertUI.itemlink = AlertUI:CreateFontString(nil, "ARTWORK");
AlertUI.itemlink:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10);
AlertUI.itemlink:SetPoint("CENTER",35,-11);
AlertUI.itemlink:SetTextColor(1,1,1);
AlertUI.itemlink:SetText(MX:FormatMoney(value));
-- Label - Item Stack
AlertUI.itemlink = AlertUI:CreateFontString(nil, "ARTWORK");
AlertUI.itemlink:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10);
AlertUI.itemlink:SetPoint("CENTER",35,-22);
AlertUI.itemlink:SetTextColor(1,1,1);
AlertUI.itemlink:SetText(L["Alert_Frame_Stack"]..stackqty);
-- Label - Item Quantity
AlertUI.itemlink = AlertUI:CreateFontString(nil, "ARTWORK");
AlertUI.itemlink:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10);
AlertUI.itemlink:SetPoint("CENTER",35,-32);
AlertUI.itemlink:SetTextColor(1,1,1);
local itemId = MX:ToItemID(itemLink);
local qty = MX.TSM:GetItemQuantity(itemId);
local fqty = qty + stackqty;
AlertUI.itemlink:SetText(L["Alert_Frame_Quantity"]..fqty);
AlertIcon:SetPoint("LEFT", 10, 0);
PlaySoundFile("Interface\\Addons\\MxW\\Media\\Sound\\register.mp3", "Master")
AlertIcon:SetTexture(itemTexture);
UIFrameFlash(AlertUI, 1, 10, 10, false, 12, 0);
end