MxW_Addon/init.lua

187 lines
4.9 KiB
Lua
Raw Normal View History

2018-01-05 06:40:15 -05:00
-- MxW (MxW Addon)
-- By mikx
2020-11-13 14:41:52 -05:00
-- https://git.mikx.xyz/mikx/MxW_Addon
2018-01-05 06:40:15 -05:00
-- Licensed under the GNU General Public License 3.0
-- See included License file for more informations.
2018-01-18 09:34:24 -05:00
local MX = LibStub("AceAddon-3.0"):NewAddon("MxW", "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0");
2018-01-05 06:40:15 -05:00
local L = LibStub("AceLocale-3.0"):GetLocale("MxW");
2018-01-18 09:34:24 -05:00
local AceGUI = LibStub("AceGUI-3.0")
2018-01-05 06:40:15 -05:00
2020-11-13 14:41:52 -05:00
local date = C_DateAndTime.GetCurrentCalendarTime();
2019-06-13 20:10:19 -04:00
local weekday, month, day, year = date.weekday, date.month, date.monthDay, date.year;
2018-01-05 06:40:15 -05:00
local MXLDB = LibStub("LibDataBroker-1.1"):NewDataObject("MxW", {
type = "data source",
text = "MxW",
icon = "Interface\\Icons\\Inv_misc_herb_goldclover",
2018-11-16 23:41:09 -05:00
OnClick = function() MX:ShowMainUI(); end,
2018-01-05 06:40:15 -05:00
})
local icon = LibStub("LibDBIcon-1.0")
2018-01-18 09:34:24 -05:00
local defaults = {
profile = {
debug = false,
version = 0,
minimapIcon = { hide = false, minimapPos = 220, radius = 80, },
mainUI = 0
}
}
2018-01-05 06:40:15 -05:00
function MX:OnInitialize()
2018-01-18 09:34:24 -05:00
self.db = LibStub:GetLibrary("AceDB-3.0"):New("MxWDB")
-- Init Saved Variables
if (Farmer_Logic_Day == nil) then
Farmer_Logic_Day = day;
end
if (Farmer_Money_DayGlobal == nil) then
Farmer_Money_DayGlobal = 0;
end
if (Farmer_Money_MonthGlobal == nil) then
Farmer_Money_MonthGlobal = 0;
end
2020-11-13 14:41:52 -05:00
if (Farmer_Money_LootSession == nil) then
Farmer_Money_LootSession = 0;
end
2018-01-18 09:34:24 -05:00
if (Farmer_Logic_MinUI == nil) then
2018-01-30 05:54:25 -05:00
Farmer_Logic_MinUI = 500000; -- 50 golds
2018-01-18 09:34:24 -05:00
end
if (Farmer_Logic_MinAlert == nil) then
2018-01-30 05:54:25 -05:00
Farmer_Logic_MinAlert = 1000000; -- 100 golds
2018-01-18 09:34:24 -05:00
end
2018-11-16 23:41:09 -05:00
if (Settings_Alert_Enabled == nil) then
Settings_Alert_Enabled = true;
end
if (Settings_GuildMessage_Enabled == nil) then
Settings_GuildMessage_Enabled = true;
end
local parentHeight = UIParent:GetHeight()
2018-01-05 06:40:15 -05:00
2018-01-18 09:34:24 -05:00
if (self.db.profile.mainUI == nil) then
2018-11-16 23:41:09 -05:00
self.db.profile.mainUI = { ["height"] = 100, ["top"] = parentHeight-50, ["left"] = 50, ["width"] = 300, }
2018-01-18 09:34:24 -05:00
end
if (self.db.profile.lootlistUI == nil) then
2018-11-16 23:41:09 -05:00
self.db.profile.lootlistUI = { ["height"] = 100, ["top"] = parentHeight-50, ["left"] = 50, ["width"] = 300, }
end
if (self.db.profile.settingsUI == nil) then
self.db.profile.settingsUI = { ["height"] = 140, ["top"] = parentHeight-50, ["left"] = 50, ["width"] = 250, }
end
if (DailyTen == nil) then
DailyTen = false
end
if (DailyTwenty == nil) then
DailyTwenty = false
end
if (DailyThirty == nil) then
DailyThirty = false
end
if (DailyForty == nil) then
DailyForty = false
end
if (DailyFifty == nil) then
DailyFifty = false
end
if (DailySixty == nil) then
DailySixty = false
end
if (DailySeventy == nil) then
DailySeventy = false
end
if (DailyEighty == nil) then
DailyEighty = false
end
if (DailyNinety == nil) then
DailyNinety = false
end
if (DailyHundred == nil) then
DailyHundred = false
end
if (DayCounter == nil) then
DayCounter = 1;
2018-01-18 09:34:24 -05:00
end
-- Meta Data
local mxwVersion = GetAddOnMetadata("MxW", "Version")
self.db.profile.version = mxwVersion
-- Message
print("MxW v." .. self.db.profile.version .. L["Message_Loaded"]);
2018-01-05 06:40:15 -05:00
end
2018-11-16 23:41:09 -05:00
local function MyAddonCommands(msg, editbox)
if msg == 'restore' then
if (Farmer_Logic_Day ~= day) then
Farmer_Money_DayGlobal = 0;
Farmer_Money_MonthGlobal = Farmer_Money_MonthBack;
ReloadUI();
elseif (Farmer_Logic_Day == day) then
Farmer_Money_MonthGlobal = Farmer_Money_MonthBack + Farmer_Money_DayGlobal;
ReloadUI();
end
elseif (msg == 'reset') then
if (Farmer_Logic_Day ~= day) then
Farmer_Money_DayGlobal = 0;
Farmer_Money_MonthBack = Farmer_Money_MonthGlobal;
Farmer_Money_MonthGlobal = 0;
DayCounter = 1;
DailyRecord = 1;
DailyRecordFlag = false;
ReloadUI();
else
Farmer_Money_MonthBack = Farmer_Money_MonthGlobal;
Farmer_Money_MonthGlobal = Farmer_Money_DayGlobal;
Farmer_Money_DayGlobal = 0;
DayCounter = 1;
DailyRecord = 1;
DailyRecordFlag = false;
ReloadUI();
end
2020-11-13 14:41:52 -05:00
elseif (msg == 'resetd' or msg == 'resetday') then
2019-06-13 20:10:19 -04:00
Farmer_Money_DayGlobal = 0;
ReloadUI();
2020-11-13 14:41:52 -05:00
elseif (msg == 'resetl' or msg == 'resetloot') then
Farmer_Money_LootSession = 0;
ReloadUI();
2018-11-16 23:41:09 -05:00
elseif (msg == 'alert') then
if (Settings_Alert_Enabled) then
Settings_Alert_Enabled = false;
print(L["Settings_Alert_Disabled"])
else
Settings_Alert_Enabled = true;
print(L["Settings_Alert_Enabled"] .. MX:FormatMoney(Farmer_Logic_MinAlert))
end
elseif (msg == 'gmsg') then
if (Settings_GuildMessage_Enabled) then
Settings_GuildMessage_Enabled = false;
print(L["Settings_GuildMessage_Disabled"])
else
Settings_GuildMessage_Enabled = true;
print(L["Settings_GuildMessage_Enabled"])
end
elseif (msg == 'config') then
MX:ShowSettingsUI();
2020-11-30 11:41:27 -05:00
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;
2018-11-16 23:41:09 -05:00
else
print(L["ChatCMD_Help"])
end
end
SLASH_MXW1 = '/mxw'
SlashCmdList["MXW"] = MyAddonCommands
2018-01-18 09:34:24 -05:00
function MX:OnEnable()
2020-11-29 20:38:58 -05:00
--MX:ShowMainUI();
2018-01-18 09:34:24 -05:00
end