Alert Rework (2.1.0)

This commit is contained in:
mikx 2020-11-30 11:41:27 -05:00
parent c67d374828
commit 6111ec4c2d
11 changed files with 192 additions and 64 deletions

View File

@ -10,6 +10,7 @@ local L = LibStub("AceLocale-3.0"):GetLocale("MxW");
local numItems local numItems
local iLink local iLink
local value local value
local by = 300
local LOOT_OPENED_Frame = CreateFrame("Frame") local LOOT_OPENED_Frame = CreateFrame("Frame")
LOOT_OPENED_Frame:RegisterEvent("LOOT_OPENED") LOOT_OPENED_Frame:RegisterEvent("LOOT_OPENED")
@ -22,18 +23,36 @@ LOOT_OPENED_Frame:SetScript("OnEvent",
numItems = GetNumLootItems() numItems = GetNumLootItems()
-- loop each loot slot -- loop each loot slot
for i = 1, numItems do for i = 1, numItems do
-- get lootslotinfo to get item stack size
lootIcon, lootName, lootQuantity, currencyID, lootQuality, locked, isQuestItem, questID, isActive = GetLootSlotInfo(i)
-- get loot slot link to get iteminfo, we can't use item name due to API limitation -- get loot slot link to get iteminfo, we can't use item name due to API limitation
iLink = GetLootSlotLink(i) iLink = GetLootSlotLink(i)
-- get the iteminfo and continue only if the itemlink is not empty (EXEMPLE: money in a slot = empty) -- get the iteminfo and continue only if the itemlink is not empty (EXEMPLE: money in a slot = empty)
if (iLink ~= nil) then if (iLink ~= nil) then
-- get the iteminfo using the slot itemlink name, link, quality, iLevel, reqLevel, class, subclass, stack, equipSlot, texture, vendorPrice = GetItemInfo(iLink)
name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(iLink)
-- get the item value using the link, return nil if the item has no value -- get the item value using the link, return nil if the item has no value
local itemId = MX:ToItemID(link); local itemId = MX:ToItemID(link);
if (itemId ~= nil) then if (itemId ~= nil) then
value = MX.TSM:GetItemValue(itemId, "DBMinBuyout"); value = MX.TSM:GetItemValue(itemId, "DBMinBuyout");
end end
MX:SendAlert(iLink,lootQuantity,value,by)
by = by - 85
end
if (value ~= nil) then
Farmer_Money_LootSession = Farmer_Money_LootSession + value;
MX:MainUIUpdate()
value = nil
iLink = nil
end
end
by = 300
end
end)
function MX:SendAlert(link,lootQuantity,value,y)
-- get the iteminfo using the slot itemlink
name, link, quality, iLevel, reqLevel, class, subclass, stack, equipSlot, texture, vendorPrice = GetItemInfo(link)
-- MINIMUM QUALITY SETTINGS ------ -- MINIMUM QUALITY SETTINGS ------
local eq = 2 -- equipable quality local eq = 2 -- equipable quality
local mq = 1 -- mats quality local mq = 1 -- mats quality
@ -46,44 +65,34 @@ LOOT_OPENED_Frame:SetScript("OnEvent",
if (value ~= nil and Settings_Alert_Enabled) then if (value ~= nil and Settings_Alert_Enabled) then
if(class == L["Alert_Class_Armor"]) then if(class == L["Alert_Class_Armor"]) then
if (value >= Farmer_Logic_MinAlert and quality >= eq) then if (value >= Farmer_Logic_MinAlert and quality >= eq) then
MX:SendAlert(link,value); MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value); MX:ChatGuildLootMessage(link,value);
end end
elseif(class == L["Alert_Class_Weapon"]) then elseif(class == L["Alert_Class_Weapon"]) then
if (value >= Farmer_Logic_MinAlert and quality >= eq) then if (value >= Farmer_Logic_MinAlert and quality >= eq) then
MX:SendAlert(link,value); MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value); MX:ChatGuildLootMessage(link,value);
end end
elseif(class == L["Alert_Class_TradeGoods"]) then elseif(class == L["Alert_Class_TradeGoods"]) then
if (value >= Farmer_Logic_MinAlert and quality >= mq) then if (value >= Farmer_Logic_MinAlert and quality >= mq) then
MX:SendAlert(link,value); MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value); MX:ChatGuildLootMessage(link,value);
end end
elseif(class == L["Alert_Class_Consumable"]) then elseif(class == L["Alert_Class_Consumable"]) then
if (value >= Farmer_Logic_MinAlert and quality >= cq) then if (value >= Farmer_Logic_MinAlert and quality >= cq) then
MX:SendAlert(link,value); MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value); MX:ChatGuildLootMessage(link,value);
end end
elseif(class == L["Alert_Class_Misc"]) then elseif(class == L["Alert_Class_Misc"]) then
if (value >= Farmer_Logic_MinAlert and quality >= oq) then if (value >= Farmer_Logic_MinAlert and quality >= oq) then
MX:SendAlert(link,value); MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value); MX:ChatGuildLootMessage(link,value);
end end
elseif(class == "Recipe") then elseif(class == "Recipe") then
if (value >= Farmer_Logic_MinAlert and quality >= rq) then if (value >= Farmer_Logic_MinAlert and quality >= rq) then
MX:SendAlert(link,value); MX:ShowAlert(link,lootQuantity,value,y);
MX:ChatGuildLootMessage(link,value); MX:ChatGuildLootMessage(link,value);
end end
end end
end end
if (value ~= nil) then
Farmer_Money_LootSession = Farmer_Money_LootSession + value;
MX:MainUIUpdate()
value = nil
iLink = nil
end end
end
end
end
end)

88
Frame/Frame_Alert.lua Normal file
View File

@ -0,0 +1,88 @@
-- 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)
AlertUI:SetFrameStrata("BACKGROUND")
AlertUI:SetWidth(300)
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

View File

@ -38,31 +38,38 @@ MainUI:SetBackdrop(
}); });
MainUI:SetBackdropColor(0.20,0.20,0.20,1); MainUI:SetBackdropColor(0.20,0.20,0.20,1);
-- Label - Title + version -- Label - Titleersion
MainUI.title = MainUI:CreateFontString(nil, "ARTWORK"); MainUI.title = MainUI:CreateFontString(nil, "ARTWORK");
MainUI.title:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10); MainUI.title:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 14);
MainUI.title:SetPoint("CENTER",0,27); MainUI.title:SetPoint("CENTER",0,30);
MainUI.title:SetTextColor(1.00,0.49,0.04); MainUI.title:SetTextColor(1.00,0.49,0.04);
MainUI.title:SetText("MxW " .. mxwVersion); MainUI.title:SetText("MxW");
-- Label - Version
MainUI.version = MainUI:CreateFontString(nil, "ARTWORK");
MainUI.version:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8);
MainUI.version:SetPoint("CENTER",0,23);
MainUI.version:SetTextColor(1.00,0.49,0.04);
MainUI.version:SetText(mxwVersion);
-- Label - Daily -- Label - Daily
MainUI.daily = MainUI:CreateFontString(nil, "ARTWORK"); MainUI.daily = MainUI:CreateFontString(nil, "ARTWORK");
MainUI.daily:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8); MainUI.daily:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 11);
MainUI.daily:SetPoint("LEFT",4,10); MainUI.daily:SetPoint("LEFT",4,10);
-- Label - Monthly -- Label - Monthly
MainUI.monthly = MainUI:CreateFontString(nil, "ARTWORK"); MainUI.monthly = MainUI:CreateFontString(nil, "ARTWORK");
MainUI.monthly:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8); MainUI.monthly:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 11);
MainUI.monthly:SetPoint("LEFT",4,2); MainUI.monthly:SetPoint("LEFT",4,0);
-- Label - Record -- Label - Record
MainUI.record = MainUI:CreateFontString(nil, "ARTWORK"); MainUI.record = MainUI:CreateFontString(nil, "ARTWORK");
MainUI.record:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8); MainUI.record:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 11);
MainUI.record:SetPoint("LEFT",4,-13); MainUI.record:SetPoint("LEFT",4,-13);
-- Label - Session Loot -- Label - Session Loot
MainUI.loot = MainUI:CreateFontString(nil, "ARTWORK"); MainUI.loot = MainUI:CreateFontString(nil, "ARTWORK");
MainUI.loot:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8); MainUI.loot:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 11);
MainUI.loot:SetPoint("LEFT",4,-23); MainUI.loot:SetPoint("LEFT",4,-23);
-- Button - Config -- Button - Config
@ -137,8 +144,8 @@ MainUI:Show()
function MX:MainUIUpdate() function MX:MainUIUpdate()
local DayColor = "|cff1ead01"; local DayColor = "|cff1ead01";
local GoldMedian = floor(Farmer_Money_MonthGlobal / DayCounter); local GoldMedian = floor(Farmer_Money_MonthGlobal / DayCounter);
MainUI.daily:SetText(format("%s (%s)", MX:FormatMoney(Farmer_Money_DayGlobal),L["MainForm_Label_Money_Lab_Today"])) MainUI.daily:SetText(format("%s (%s)", MX:FormatMoneyGoldOnly(Farmer_Money_DayGlobal),L["MainForm_Label_Money_Lab_Today"]))
MainUI.monthly:SetText(format("%s (%s)", MX:FormatMoney(Farmer_Money_MonthGlobal),L["MainForm_Label_Money_Lab_Month"])) MainUI.monthly:SetText(format("%s (%s)", MX:FormatMoneyGoldOnly(Farmer_Money_MonthGlobal),L["MainForm_Label_Money_Lab_Month"]))
MainUI.record:SetText(format("%s %s", MX:FormatMoneyGoldOnly(DailyRecord), L["Chat_ChatGuildDailyRecordUI"])) MainUI.record:SetText(format("%s %s", MX:FormatMoneyGoldOnly(DailyRecord), L["Chat_ChatGuildDailyRecordUI"]))
MainUI.loot:SetText(format("%s (Loot)", MX:FormatMoneyGoldOnly(Farmer_Money_LootSession))) MainUI.loot:SetText(format("%s (Loot)", MX:FormatMoneyGoldOnly(Farmer_Money_LootSession)))
end end

View File

@ -1,3 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Frame_Main.lua"/> <Script file="Frame_Main.lua"/>
<Script file="Frame_Alert.lua"/>
</Ui> </Ui>

View File

@ -45,14 +45,14 @@ function CookAlert(frame, item, fvalue)
frame.Backdrop = CreateFrame("Frame", name.."Backdrop", f, "BackdropTemplate"); frame.Backdrop = CreateFrame("Frame", name.."Backdrop", f, "BackdropTemplate");
frame.Backdrop:SetAllPoints(); frame.Backdrop:SetAllPoints();
frame.Backdrop.backdropInfo = { frame.Backdrop.backdropInfo = {
bgFile = "Interface\Tooltips\UI-Tooltip-Background", bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface\Tooltips\UI-Tooltip-Border", edgeFile = "Interface/Buttons/WHITE8x8",
edgeSize = 2, tile = true, tileSize = 16, edgeSize = 1,
insets = { left = 11, right = 12, top = 12, bottom = 9, }, insets = { left = 2, right = 2, top = 2, bottom = 2 },
}; };
frame.Backdrop:SetBackdrop(frame.Backdrop.backdropInfo); frame.Backdrop:SetBackdrop(frame.Backdrop.backdropInfo);
--frame:SetBackdrop(backdrop) --frame:SetBackdrop(backdrop)
frame.Backdrop:SetBackdropColor(51, 51, 51); frame.Backdrop:SetBackdropColor(0.20,0.20,0.20,1);
frame.Backdrop:SetBackdropBorderColor(0, 0, 0); frame.Backdrop:SetBackdropBorderColor(0, 0, 0);
--local iconBorder = frame.Icon.Overlay; --local iconBorder = frame.Icon.Overlay;
--iconBorder:SetTexture("Interface\\AchievementFrame\\UI-Achievement-IconFrame"); --iconBorder:SetTexture("Interface\\AchievementFrame\\UI-Achievement-IconFrame");

View File

@ -1,5 +1,4 @@
<Ui xmlns="http://www.blizzard.com/wow/ui/"> <Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="Alert.lua"/>
<Script file="DB.lua"/> <Script file="DB.lua"/>
<Script file="Chat.lua"/> <Script file="Chat.lua"/>
<Script file="Item.lua"/> <Script file="Item.lua"/>

View File

@ -19,3 +19,8 @@ function MX.TSM:GetItemValue(itemID, priceSource)
local itemLink = "i:" .. tostring(itemID); local itemLink = "i:" .. tostring(itemID);
return TSM_API.GetCustomPriceValue(priceSource, itemLink) return TSM_API.GetCustomPriceValue(priceSource, itemLink)
end end
function MX.TSM:GetItemQuantity(itemID)
local itemLink = "i:" .. tostring(itemID);
return TSM_API.GetPlayerTotals(itemLink)
end

View File

@ -51,3 +51,9 @@ L["Alert_Class_Consumable"] = "Consommable";
L["Alert_Class_TradeGoods"] = "Artisanat"; L["Alert_Class_TradeGoods"] = "Artisanat";
L["Alert_Class_Weapon"] = "Arme"; L["Alert_Class_Weapon"] = "Arme";
L["Alert_Class_Armor"] = "Armure"; L["Alert_Class_Armor"] = "Armure";
-- Alert Frame
L["Alert_Frame_Title"] = "MxW (Alerte)";
L["Alert_Frame_Thresold"] = "Seuil : ";
L["Alert_Frame_Stack"] = "Pile : ";
L["Alert_Frame_Quantity"] = "Inventaire : ";

View File

@ -51,3 +51,9 @@ L["Alert_Class_Consumable"] = "Consumable";
L["Alert_Class_TradeGoods"] = "Trade Goods"; L["Alert_Class_TradeGoods"] = "Trade Goods";
L["Alert_Class_Weapon"] = "Weapon"; L["Alert_Class_Weapon"] = "Weapon";
L["Alert_Class_Armor"] = "Armor"; L["Alert_Class_Armor"] = "Armor";
-- Alert Frame
L["Alert_Frame_Title"] = "MxW (Alert)";
L["Alert_Frame_Thresold"] = "Thresold: ";
L["Alert_Frame_Stack"] = "Stack: ";
L["Alert_Frame_Quantity"] = "Inventory: ";

View File

@ -1,6 +1,6 @@
## Interface: 90001 ## Interface: 90001
## Title: |cff1784d1MxW|r ## Title: |cff1784d1MxW|r
## Version: 2.0.0 ## Version: 2.1.0
## Author: mikx ## Author: mikx
## Notes: MxW Addon ## Notes: MxW Addon
## RequiredDeps: TradeSkillMaster ## RequiredDeps: TradeSkillMaster

View File

@ -165,6 +165,13 @@ local function MyAddonCommands(msg, editbox)
end end
elseif (msg == 'config') then elseif (msg == 'config') then
MX:ShowSettingsUI(); MX:ShowSettingsUI();
elseif (msg == 'atest') then
local by = 300;
for i = 4,1,-1 do
MX:ShowAlert("\124cff1eff00\124Hitem:171830::::::::60:::::\124h[Oxxein Ore]\124h\124r",4,50000000,by);
by = by - 90;
end
local by = 300;
else else
print(L["ChatCMD_Help"]) print(L["ChatCMD_Help"])
end end