UI Rework (2.0.0)
This commit is contained in:
251
Frame/Frame_Main.lua
Normal file
251
Frame/Frame_Main.lua
Normal file
@@ -0,0 +1,251 @@
|
||||
-- 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 EditBoxMinAlert = AceGUI:Create("EditBox")
|
||||
|
||||
local date = C_DateAndTime.GetCurrentCalendarTime();
|
||||
local weekday, month, day, year = date.weekday, date.month, date.monthDay, date.year;
|
||||
|
||||
local MainUI = CreateFrame("Frame", nil, self, BackdropTemplateMixin and "BackdropTemplate")
|
||||
MainUI:SetFrameStrata("BACKGROUND")
|
||||
MainUI:SetWidth(150)
|
||||
MainUI:SetHeight(80)
|
||||
--MainUI:SetPoint("CENTER", 0, 0)
|
||||
|
||||
MainUI:SetMovable(true)
|
||||
MainUI:SetUserPlaced(true)
|
||||
MainUI:EnableMouse(true)
|
||||
MainUI:RegisterForDrag("LeftButton")
|
||||
MainUI:SetScript("OnDragStart", MainUI.StartMoving)
|
||||
MainUI:SetScript("OnDragStop", MainUI.StopMovingOrSizing)
|
||||
|
||||
MainUI: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 }
|
||||
});
|
||||
MainUI:SetBackdropColor(0.20,0.20,0.20,1);
|
||||
|
||||
-- Label - Title + version
|
||||
MainUI.title = MainUI:CreateFontString(nil, "ARTWORK");
|
||||
MainUI.title:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 10);
|
||||
MainUI.title:SetPoint("CENTER",0,27);
|
||||
MainUI.title:SetTextColor(1.00,0.49,0.04);
|
||||
MainUI.title:SetText("MxW " .. mxwVersion);
|
||||
|
||||
-- Label - Daily
|
||||
MainUI.daily = MainUI:CreateFontString(nil, "ARTWORK");
|
||||
MainUI.daily:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8);
|
||||
MainUI.daily:SetPoint("LEFT",4,10);
|
||||
|
||||
-- Label - Monthly
|
||||
MainUI.monthly = MainUI:CreateFontString(nil, "ARTWORK");
|
||||
MainUI.monthly:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8);
|
||||
MainUI.monthly:SetPoint("LEFT",4,2);
|
||||
|
||||
-- Label - Record
|
||||
MainUI.record = MainUI:CreateFontString(nil, "ARTWORK");
|
||||
MainUI.record:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8);
|
||||
MainUI.record:SetPoint("LEFT",4,-13);
|
||||
|
||||
-- Label - Session Loot
|
||||
MainUI.loot = MainUI:CreateFontString(nil, "ARTWORK");
|
||||
MainUI.loot:SetFont("Interface\\Addons\\MxW\\Media\\Font\\Consola.ttf", 8);
|
||||
MainUI.loot:SetPoint("LEFT",4,-23);
|
||||
|
||||
-- Button - Config
|
||||
local buttonConfig = CreateFrame("Button", nil, MainUI)
|
||||
buttonConfig:SetSize(16 ,12) -- width, height
|
||||
buttonConfig:SetText("C")
|
||||
buttonConfig:SetPoint("RIGHT", MainUI, "RIGHT", -4, 20)
|
||||
buttonConfig:SetNormalFontObject("GameFontNormal")
|
||||
buttonConfig:SetScript("OnClick", function()
|
||||
MX:ShowSettingsUI()
|
||||
end)
|
||||
|
||||
local ntex = buttonConfig:CreateTexture()
|
||||
ntex:SetTexture("Interface\\Addons\\MxW\\Media\\Texture\\Black8x8")
|
||||
ntex:SetTexCoord(0, 0, 0, 0)
|
||||
ntex:SetAllPoints()
|
||||
buttonConfig:SetNormalTexture(ntex)
|
||||
|
||||
-- Button - Reset Day
|
||||
local buttonResetDay = CreateFrame("Button", nil, MainUI)
|
||||
buttonResetDay:SetSize(16 ,12) -- width, height
|
||||
buttonResetDay:SetText("RD")
|
||||
buttonResetDay:SetPoint("RIGHT", MainUI, "RIGHT", -4, 6)
|
||||
buttonResetDay:SetNormalFontObject("GameFontNormal")
|
||||
buttonResetDay:SetScript("OnClick", function()
|
||||
Farmer_Money_DayGlobal = 0;
|
||||
ReloadUI();
|
||||
end)
|
||||
|
||||
local ntex = buttonResetDay:CreateTexture()
|
||||
ntex:SetTexture("Interface\\Addons\\MxW\\Media\\Texture\\Black8x8")
|
||||
ntex:SetTexCoord(0, 0, 0, 0)
|
||||
ntex:SetAllPoints()
|
||||
buttonResetDay:SetNormalTexture(ntex)
|
||||
|
||||
-- Button - Reset Month
|
||||
local buttonResetMonth = CreateFrame("Button", nil, MainUI)
|
||||
buttonResetMonth:SetSize(16 ,12) -- width, height
|
||||
buttonResetMonth:SetText("RM")
|
||||
buttonResetMonth:SetPoint("RIGHT", MainUI, "RIGHT", -4, -8)
|
||||
buttonResetMonth:SetNormalFontObject("GameFontNormal")
|
||||
buttonResetMonth:SetScript("OnClick", function()
|
||||
Farmer_Money_MonthGlobal = 0;
|
||||
ReloadUI();
|
||||
end)
|
||||
|
||||
local ntex = buttonResetMonth:CreateTexture()
|
||||
ntex:SetTexture("Interface\\Addons\\MxW\\Media\\Texture\\Black8x8")
|
||||
ntex:SetTexCoord(0, 0, 0, 0)
|
||||
ntex:SetAllPoints()
|
||||
buttonResetMonth:SetNormalTexture(ntex)
|
||||
|
||||
-- Button - Reset Loot
|
||||
local buttonResetLoot = CreateFrame("Button", nil, MainUI)
|
||||
buttonResetLoot:SetSize(16 ,12) -- width, height
|
||||
buttonResetLoot:SetText("RL")
|
||||
buttonResetLoot:SetPoint("RIGHT", MainUI, "RIGHT", -4, -22)
|
||||
buttonResetLoot:SetNormalFontObject("GameFontNormal")
|
||||
buttonResetLoot:SetScript("OnClick", function()
|
||||
Farmer_Money_LootSession = 0;
|
||||
ReloadUI();
|
||||
end)
|
||||
|
||||
local ntex = buttonResetLoot:CreateTexture()
|
||||
ntex:SetTexture("Interface\\Addons\\MxW\\Media\\Texture\\Black8x8")
|
||||
ntex:SetTexCoord(0, 0, 0, 0)
|
||||
ntex:SetAllPoints()
|
||||
buttonResetLoot:SetNormalTexture(ntex)
|
||||
|
||||
MainUI:Show()
|
||||
|
||||
function MX:MainUIUpdate()
|
||||
local DayColor = "|cff1ead01";
|
||||
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.monthly:SetText(format("%s (%s)", MX:FormatMoney(Farmer_Money_MonthGlobal),L["MainForm_Label_Money_Lab_Month"]))
|
||||
MainUI.record:SetText(format("%s %s", MX:FormatMoneyGoldOnly(DailyRecord), L["Chat_ChatGuildDailyRecordUI"]))
|
||||
MainUI.loot:SetText(format("%s (Loot)", MX:FormatMoneyGoldOnly(Farmer_Money_LootSession)))
|
||||
end
|
||||
|
||||
local MainFrame_Event_PLAYER_ENTERING_WORLD = CreateFrame("Frame")
|
||||
MainFrame_Event_PLAYER_ENTERING_WORLD :RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MainFrame_Event_PLAYER_ENTERING_WORLD :SetScript("OnEvent", function(self, event, ...)
|
||||
-- Init gold variable
|
||||
CurrentGold = GetMoney()
|
||||
-- Reset Global Daily Counter
|
||||
if(DailyRecord == nil) then
|
||||
DailyRecord = Farmer_Money_DayGlobal;
|
||||
DailyRecordFlag = false;
|
||||
end
|
||||
if (day ~= 0 and Farmer_Logic_Day ~= day) then
|
||||
if(DailyRecordFlag) then
|
||||
DailyRecordFlag = false;
|
||||
end
|
||||
Farmer_Money_DayGlobal = 0;
|
||||
Farmer_Logic_Day = day;
|
||||
DailyTen = false;
|
||||
DailyTwenty = false;
|
||||
DailyThirty = false;
|
||||
DailyForty = false;
|
||||
DailyFifty = false;
|
||||
DailySixty = false;
|
||||
DailySeventy = false;
|
||||
DailyEighty = false;
|
||||
DailyNinety = false;
|
||||
DailyHundred = false;
|
||||
end
|
||||
MX:RestorePosition();
|
||||
MX:MainUIUpdate();
|
||||
end)
|
||||
|
||||
local MainFrame_Event_PLAYER_LEAVING_WORLD = CreateFrame("Frame")
|
||||
MainFrame_Event_PLAYER_LEAVING_WORLD :RegisterEvent("PLAYER_LEAVING_WORLD")
|
||||
MainFrame_Event_PLAYER_LEAVING_WORLD :SetScript("OnEvent", function(self, event, ...)
|
||||
MX:SavePosition();
|
||||
end)
|
||||
|
||||
function MX:ShowSettingsUI()
|
||||
local SETTINGS_UI = AceGUI:Create("Window")
|
||||
SETTINGS_UI:SetHeight(150)
|
||||
SETTINGS_UI:SetTitle(L["MainForm_Button_Settings"])
|
||||
SETTINGS_UI:SetStatusTable(self.db.profile.settingsUI)
|
||||
SETTINGS_UI:SetLayout("List")
|
||||
SETTINGS_UI:SetWidth(300)
|
||||
|
||||
EditBoxMinAlert:SetLabel(L["SettingsUI_EditBox_MinAlert"])
|
||||
local money = floor(Farmer_Logic_MinAlert / (COPPER_PER_SILVER * SILVER_PER_GOLD))
|
||||
EditBoxMinAlert:SetText(money)
|
||||
EditBoxMinAlert:SetCallback("OnEnterPressed",
|
||||
function()
|
||||
local value = EditBoxMinAlert:GetText()
|
||||
local fv = floor(value * (COPPER_PER_SILVER * SILVER_PER_GOLD))
|
||||
Farmer_Logic_MinAlert = fv
|
||||
ReloadUI();
|
||||
end
|
||||
)
|
||||
SETTINGS_UI:AddChild(EditBoxMinAlert)
|
||||
|
||||
local labSpace = AceGUI:Create("Label")
|
||||
labSpace:SetFont("Fonts\\FRIZQT__.TTF", 10)
|
||||
labSpace:SetColor(1, 1, 1)
|
||||
labSpace:SetFullWidth(true)
|
||||
labSpace:SetText(" ")
|
||||
SETTINGS_UI:AddChild(labSpace)
|
||||
|
||||
local BUTTON_RESET = AceGUI:Create("Button")
|
||||
BUTTON_RESET:SetAutoWidth(true)
|
||||
BUTTON_RESET:SetText(L["SettingsUI_Button_Reset"])
|
||||
BUTTON_RESET:SetPoint("RIGHT", 5, 15)
|
||||
BUTTON_RESET:SetCallback("OnClick",
|
||||
function()
|
||||
if (Farmer_Logic_Day ~= day) then
|
||||
Farmer_Money_DayGlobal = 0;
|
||||
Farmer_Money_MonthBack = Farmer_Money_MonthGlobal;
|
||||
Farmer_Money_MonthGlobal = 0;
|
||||
ReloadUI();
|
||||
else
|
||||
Farmer_Money_MonthBack = Farmer_Money_MonthGlobal;
|
||||
Farmer_Money_MonthGlobal = Farmer_Money_DayGlobal;
|
||||
Farmer_Money_DayGlobal = 0;
|
||||
ReloadUI();
|
||||
end
|
||||
end
|
||||
)
|
||||
SETTINGS_UI:AddChild(BUTTON_RESET)
|
||||
end
|
||||
|
||||
function MX:SavePosition()
|
||||
local s = MainUI:GetEffectiveScale();
|
||||
MainUI_X = MainUI:GetLeft() * s;
|
||||
MainUI_Y = MainUI:GetTop() * s;
|
||||
end
|
||||
|
||||
function MX:RestorePosition()
|
||||
MainUI:ClearAllPoints();
|
||||
local x = MainUI_X;
|
||||
local y = MainUI_Y;
|
||||
|
||||
if not x or not y then
|
||||
return MainUI:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
|
||||
end
|
||||
|
||||
local s = MainUI:GetEffectiveScale();
|
||||
MainUI:ClearAllPoints();
|
||||
MainUI:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x / s, y / s);
|
||||
end
|
||||
@@ -1,3 +1,3 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/">
|
||||
<Script file="MainFrame.lua"/>
|
||||
<Script file="Frame_Main.lua"/>
|
||||
</Ui>
|
||||
|
||||
Reference in New Issue
Block a user