Initial commit

This commit is contained in:
Leonetienne 2021-08-05 18:21:47 +02:00
parent 40c17b4541
commit 431b3b38a3
3 changed files with 1197 additions and 0 deletions

22
Trackster.toc Normal file
View File

@ -0,0 +1,22 @@
## Interface: 80000
## Title: Trackster
## Author: Allpi
## Notes: This AddOn tracks new statistics and shows them alongside with some vanilla ones in the player-hud.
## Version: 1.1
# Stats stated here are saved per character.
## SavedVariablesPerCharacter: Trackster_jumpCounter, Trackster_critCounter, Trackster_castCounter, Trackster_loginCounter, Trackster_bossCounter, Trackster_chatCounter, Trackster_itemCounter, Trackster_goldCounter, Trackster_distanceTravelledCounter
# Stats stated here are saved for the whole wow client.
## SavedVariables:
# These are the settings values.
## SavedVariablesPerCharacter: Trackster_deathOffset, Trackster_killsOffset, Trackster_questsOffset, Trackster_dmgOffset, Trackster_jumpOffset, Trackster_IlvlOffset, Trackster_castOffset, Trackster_critOffset, Trackster_loginOffset, Trackster_bossOffset, Trackster_chatOffset, Trackster_itemOffset, Trackster_timeOffset, Trackster_goldOffset, Trackster_distanceTravelledOffset
# These are internal values. Just don't touch those.
## SavedVariablesPerCharacter: Trackster_showMainframe, Trackster_frameScale
main.lua
options.lua

746
main.lua Normal file
View File

@ -0,0 +1,746 @@
local mainFrame = CreateFrame("frame", "TracksterMainFrame", self, BackdropTemplateMixin and "BackdropTemplate");
Trackster = {};
Trackster_jumpCounter = 0;
Trackster_castCounter = 0;
Trackster_critCounter = 0;
Trackster_loginCounter = 0;
Trackster_bossCounter = 0;
Trackster_chatCounter = 0;
Trackster_itemCounter = 0;
Trackster_goldCounter = 0;
Trackster_distanceTravelledCounter = 0;
Trackster_frameScale = 1;
local updateOneSecondTimer = 0;
local buttonX = CreateFrame("Button", nil);
buttonX:SetPoint("TOPRIGHT", mainFrame, 6, 6);
buttonX:SetFrameStrata("Background");
buttonX:SetWidth(33);
buttonX:SetHeight(33);
local ntex = buttonX:CreateTexture();
ntex:SetTexture("Interface/Buttons/UI-Panel-MinimizeButton-Up");
ntex:SetTexCoord(0, 1, 0, 1);
ntex:SetAllPoints() ;
buttonX:SetNormalTexture(ntex);
local htex = buttonX:CreateTexture()
htex:SetTexture("Interface/Buttons/UI-Panel-MinimizeButton-Highlight");
htex:SetTexCoord(0, 1, 0, 1);
htex:SetAllPoints();
buttonX:SetHighlightTexture(htex);
local ptex = buttonX:CreateTexture();
ptex:SetTexture("Interface/Buttons/UI-Panel-MinimizeButton-Down");
ptex:SetTexCoord(0, 1, 0, 1);
ptex:SetAllPoints();
buttonX:SetPushedTexture(ptex);
local textFont = "GameFontWhite";
local textMarginB = 20;
local textMarginT = 25;
local textMarginL = 25;
local fsDeaths = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_deathOffset = 0;
local fsKills = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_killsOffset = 0;
local fsDist = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_distanceTravelledOffset = -0;
local fsQuests = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_questsOffset = -0;
--local fsDmg = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
--Trackster_dmgOffset = 0;
local fsJump = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_jumpOffset = 0;
local fsPlvl = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsIlvl = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_IlvlOffset = 0;
local fsGold = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_goldOffset = 0;
local fsCasts = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_castOffset = 0;
local fsCrits = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_critOffset = 0;
local fsLogins = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_loginOffset = 0;
local fsBoss = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_bossOffset = 0;
local fsChat = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_chatOffset = 0;
local fsItem = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_itemOffset = 0;
local fsTime = mainFrame:CreateFontString(nil, "OVERLAY", textFont);
Trackster_timeOffset = 0;
local lastConfirmedTime = 0;
local internalTimeOffset = 0;
local function InvertBool(b)
if (b == true) then
return false;
else
return true;
end
end
local function PrintMsg(s)
print("|cFFFFD044Trackster:|r " .. s);
end
mainFrame:SetBackdrop({
bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border",
tile=1, tileSize=32, edgeSize=32,
insets={left=11, right=12, top=12, bottom=11}
})
fsKills:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (0 * textMarginB)));
fsDeaths:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (1 * textMarginB)));
fsTime:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (2 * textMarginB)));
fsDist:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (3 * textMarginB)));
fsQuests:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (4 * textMarginB)));
fsPlvl:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (5 * textMarginB)));
fsIlvl:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (6 * textMarginB)));
--fsDmg:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (5 * textMarginB)));
--fsGold:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (7 * textMarginB)));
fsBoss:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (7 * textMarginB)));
fsCasts:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (8 * textMarginB)));
fsCrits:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (9 * textMarginB)));
fsLogins:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (10 * textMarginB)));
--fsItem:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (12 * textMarginB)));
fsChat:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (11 * textMarginB)));
fsJump:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (12 * textMarginB)));
mainFrame:SetWidth(220 + textMarginL);
mainFrame:SetHeight((textMarginT * 2) + (textMarginB * 13));
mainFrame:EnableMouse(true);
mainFrame:SetPoint("CENTER", 480, 0, UIParent);
mainFrame:SetMovable(true);
mainFrame:RegisterForDrag("LeftButton");
mainFrame:SetFrameStrata("Background");
mainFrame:SetUserPlaced(true);
mainFrame:SetScript("OnDragStart", mainFrame.StartMoving);
mainFrame:SetScript("OnDragStop", mainFrame.StopMovingOrSizing);
mainFrame:RegisterEvent("PLAYER_ENTERING_WORLD");
mainFrame:RegisterEvent("PLAYER_LOGOUT");
mainFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
mainFrame:RegisterEvent("PLAYER_DEAD");
mainFrame:RegisterEvent("QUEST_TURNED_IN");
mainFrame:RegisterEvent("ADDON_LOADED");
mainFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED");
mainFrame:RegisterEvent("PLAYER_MONEY");
mainFrame:RegisterEvent("PLAYER_LOGIN");
mainFrame:RegisterEvent("PLAYER_LEVEL_UP");
mainFrame:RegisterEvent("BOSS_KILL");
mainFrame:RegisterEvent("CHAT_MSG_LOOT");
mainFrame:RegisterEvent("QUEST_LOOT_RECEIVED");
mainFrame:RegisterEvent("CHAT_MSG_SAY");
mainFrame:RegisterEvent("CHAT_MSG_CHANNEL");
mainFrame:RegisterEvent("CHAT_MSG_GUILD");
mainFrame:RegisterEvent("CHAT_MSG_OFFICER");
mainFrame:RegisterEvent("CHAT_MSG_PARTY");
mainFrame:RegisterEvent("CHAT_MSG_PARTY_LEADER");
mainFrame:RegisterEvent("CHAT_MSG_RAID");
mainFrame:RegisterEvent("CHAT_MSG_RAID_LEADER");
mainFrame:RegisterEvent("CHAT_MSG_WHISPER_INFORM");
mainFrame:RegisterEvent("CHAT_MSG_YELL");
mainFrame:RegisterEvent("CHAT_MSG_INSTANCE_CHAT");
mainFrame:RegisterEvent("CHAT_MSG_INSTANCE_CHAT_LEADER");
mainFrame:RegisterEvent("TIME_PLAYED_MSG");
mainFrame:RegisterEvent("CINEMATIC_START");
mainFrame:RegisterEvent("CINEMATIC_STOP");
local function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0);
return math.floor(num * mult + 0.5) / mult;
end
local function FormatTime(t)
local secondsInDay = (60 * 60 * 24);
local secondsInHour = (60 * 60);
local secondsInMinute = (60);
local rmnTime = t;
local d = math.floor(rmnTime / secondsInDay);
rmnTime = rmnTime % secondsInDay;
local h = math.floor(rmnTime / secondsInHour);
rmnTime = rmnTime % secondsInHour;
local m = math.floor(rmnTime / secondsInMinute);
rmnTime = rmnTime % secondsInMinute;
local s = rmnTime;
return select(1, d, h, m, s);
end
function Round(f)
return math.floor(f+0.5);
end
local timer = 0;
function UpdateDistanceTravelled(self, deltaTime, forceTextUpdate)
--> Update value in background in every frame
Trackster_distanceTravelledCounter = Trackster_distanceTravelledCounter + (GetUnitSpeed("PLAYER") * 0.9144 * deltaTime);
local val = Round(Trackster_distanceTravelledCounter + Trackster_distanceTravelledOffset);
timer = timer + deltaTime;
local updateDelayS = 1;
if (val < 5000) then
updateDelayS = 0.1;
elseif (val < 10000) then
updateDelayS = 1;
else
updateDelayS = 10;
end
if (timer >= updateDelayS or forceTextUpdate) then --> Update UI text every deltaTime seconds
if (val < 10000) then
fsDist:SetText("Distance travelled: " .. val .. "m");
else
fsDist:SetText("Distance travelled: " .. Round(val/1000) .. "km");
end
timer = 0;
end
end
function UpdatePlvl()
fsPlvl:SetText("Character level: " .. UnitLevel("PLAYER"));
end
function UpdateDeaths()
Trackster_deathOffset = round(Trackster_deathOffset);
local val = select(1, GetStatistic(60));
if (val == "--") then
fsDeaths:SetText("Death count: " .. (val));
else
fsDeaths:SetText("Death count: " .. (val + Trackster_deathOffset));
end
end
local function UpdateKills()
Trackster_killsOffset = round(Trackster_killsOffset);
local val = select(1, GetStatistic(1197));
if (val == "--") then
fsKills:SetText("Kill count: " .. (val));
else
fsKills:SetText("Kill count: " .. (val + Trackster_killsOffset));
end
end
local function UpdateQuests()
Trackster_questsOffset = round(Trackster_questsOffset);
local val = select(1, GetStatistic(98));
if (val == "--") then
fsQuests:SetText("Quest count: " .. (val));
else
fsQuests:SetText("Quest count: " .. (val + Trackster_questsOffset));
end
end
local function UpdateDmg()
--Trackster_dmgOffset = round(Trackster_dmgOffset);
--
--local val = select(1, GetStatistic(197));
--
--if (val == "--") then
-- fsDmg:SetText("Total dmg: " .. (val));
--else
--
-- val = tonumber(val + Trackster_dmgOffset);
--
-- if(val >= 100000000000) then val = tostring(round(val / 1000000000, 0)) .. "B";
-- elseif(val >= 10000000000) then val = tostring(round(val / 1000000000, 1)) .. "B";
-- elseif(val >= 1000000000) then val = tostring(round(val / 1000000, 0)) .. "M";
-- elseif(val >= 100000000) then val = tostring(round(val / 1000000, 1)) .. "M";
-- elseif(val >= 100000) then val = tostring(round(val / 1000), 0) .. "K";
-- end
--
-- fsDmg:SetText("Total dmg: " .. (val));
--end
end
local function UpdateJump()
Trackster_jumpOffset = round(Trackster_jumpOffset);
fsJump:SetText("Jump count: " .. (Trackster_jumpCounter + Trackster_jumpOffset));
end
local function UpdateCasts()
Trackster_castOffset = round(Trackster_castOffset);
local val = Trackster_castCounter + Trackster_castOffset;
if(val >= 100000000000) then val = tostring(round(val / 1000000000, 0)) .. "B";
elseif(val >= 10000000000) then val = tostring(round(val / 1000000000, 1)) .. "B";
elseif(val >= 1000000000) then val = tostring(round(val / 1000000, 0)) .. "M";
elseif(val >= 100000000) then val = tostring(round(val / 1000000, 1)) .. "M";
elseif(val >= 100000) then val = tostring(round(val / 1000), 0) .. "K";
end
fsCasts:SetText("Cast count: " .. val);
end
local function UpdateCrits()
Trackster_critOffset = round(Trackster_critOffset);
fsCrits:SetText("Crit count: " .. (Trackster_critCounter + Trackster_critOffset));
end
local function UpdateLogins()
Trackster_loginOffset = round(Trackster_loginOffset);
fsLogins:SetText("Login count: " .. (Trackster_loginCounter + Trackster_loginOffset));
end
local function UpdateBoss()
Trackster_bossOffset = round(Trackster_bossOffset);
fsBoss:SetText("Boss count: " .. (Trackster_bossCounter + Trackster_bossOffset));
end
local function UpdateIlvl()
local overall, equipped = GetAverageItemLevel();
local val = math.floor(equipped + Trackster_IlvlOffset);
fsIlvl:SetText("ItemLvl: " .. val);
end
local function UpdateGold()
--local val = select(1, GetStatistic(328));
local val = GetCoinTextureString(Trackster_goldCounter + Trackster_goldOffset);
fsGold:SetText("Gold total: " .. val);
end
local function UpdateChat()
Trackster_chatOffset = round(Trackster_chatOffset);
fsChat:SetText("Chat msgs sent: " .. (Trackster_chatCounter + Trackster_chatOffset));
end
local function UpdateItem()
Trackster_itemOffset = round(Trackster_itemOffset);
fsItem:SetText("Items collected: " .. (Trackster_itemCounter + Trackster_itemOffset));
end
local function UpdateTime()
Trackster_timeOffset = round(Trackster_timeOffset);
local d, h, m, s = select(1, FormatTime(lastConfirmedTime + internalTimeOffset + Trackster_timeOffset));
fsTime:SetText("Time played: " .. d .. ":" .. h .. ":" .. m .. ":" .. s);
end
hooksecurefunc( "JumpOrAscendStart", function()
if (IsFlying() == false and UnitOnTaxi("PLAYER") == false and IsSwimming() == false) then
Trackster_jumpCounter = Trackster_jumpCounter + 1;
UpdateJump();
end
end );
Trackster.OffsetDistance = function(offset)
if(offset == nil) then return Trackster_distanceTravelledOffset; end;
Trackster_distanceTravelledOffset = offset;
UpdateDistanceTravelled(0,0,true);
end
Trackster.OffsetKills = function(offset)
if(offset == nil) then return Trackster_killsOffset; end;
Trackster_killsOffset = offset;
UpdateKills();
end
Trackster.OffsetDeaths = function(offset)
if(offset == nil) then return Trackster_deathOffset; end;
Trackster_deathOffset = offset;
UpdateDeaths();
end
Trackster.OffsetQuests = function(offset)
if(offset == nil) then return Trackster_questsOffset; end;
Trackster_questsOffset = offset;
UpdateQuests();
end
Trackster.OffsetDmg = function(offset)
--if(offset == nil) then return Trackster_dmgOffset; end;
--
--Trackster_dmgOffset = offset;
--UpdateDmg();
end
Trackster.OffsetJumps = function(offset)
if(offset == nil) then return Trackster_jumpOffset; end;
Trackster_jumpOffset = offset;
UpdateJump();
end
Trackster.OffsetCasts = function(offset)
if(offset == nil) then return Trackster_castOffset; end;
Trackster_castOffset = offset;
UpdateCasts();
end
Trackster.OffsetGold = function(offset)
if(offset == nil) then return Trackster_goldOffset; end;
Trackster_goldOffset = offset;
UpdateGold();
end
Trackster.OffsetCrits = function(offset)
if(offset == nil) then return Trackster_critOffset; end;
Trackster_critOffset = offset;
UpdateCrits();
end
Trackster.OffsetLogin = function(offset)
if(offset == nil) then return Trackster_loginOffset; end;
Trackster_loginOffset = offset;
UpdateLogins();
end
Trackster.OffsetBoss = function(offset)
if(offset == nil) then return Trackster_bossOffset; end;
Trackster_bossOffset = offset;
UpdateBoss();
end
Trackster.OffsetChat = function(offset)
if(offset == nil) then return Trackster_chatOffset; end;
Trackster_chatOffset = offset;
UpdateChat();
end
Trackster.OffsetItem = function(offset)
if(offset == nil) then return Trackster_itemOffset; end;
Trackster_itemOffset = offset;
UpdateItem();
end
Trackster.OffsetTime = function(offset)
if(offset == nil) then return Trackster_timeOffset; end;
Trackster_timeOffset = offset;
UpdateTime();
end
local function UpdateAll()
UpdateDeaths();
UpdateKills();
UpdateDistanceTravelled(0,0, true);
UpdateQuests();
--UpdateDmg();
UpdatePlvl();
UpdateIlvl();
UpdateGold();
UpdateCasts();
UpdateCrits();
UpdateLogins();
UpdateBoss();
UpdateJump();
UpdateChat();
UpdateItem();
UpdateTime();
end
mainFrame:SetScript("OnShow", UpdateAll);
local function ProcessChatMsg(...)
author = select(2, ...);
if(author == GetUnitName("player") .. "-" .. GetRealmName()) then
Trackster_chatCounter = Trackster_chatCounter + 1;
UpdateChat();
end
end
local function SyncTimePlayedWithBlizzardServer(t)
lastConfirmedTime = t;
internalTimeOffset = 0;
updateOneSecondTimer = 0;
UpdateTime();
end
function UpdateHandler(self, deltaTime)
UpdateDistanceTravelled(self, deltaTime);
updateOneSecondTimer = updateOneSecondTimer + deltaTime;
if(updateOneSecondTimer >= 1) then
updateOneSecondTimer = 0;
internalTimeOffset = internalTimeOffset + 1;
FormatTime(lastConfirmedTime + internalTimeOffset + Trackster_timeOffset);
UpdateTime();
end
end
mainFrame:SetScript("OnUpdate", UpdateHandler);
Trackster.SetFrameScale = function(s)
mainFrame:SetScale(s);
buttonX:SetScale(s);
Trackster_frameScale = round(s, 3);
end
-- This function will return the amount of gold earned when PLAYER_MONEY fires. Only call it then and only call it once per frame!
local lastGold = GetMoney();
local GetGoldDifference = function()
local tmp = GetMoney() - lastGold;
lastGold = GetMoney();
return tmp;
end
local function eventHandler(self, event, ...)
if (event == "PLAYER_ENTERING_WORLD") then
UpdateAll();
RequestTimePlayed();
elseif (event == "PLAYER_LOGOUT") then
elseif (event == "PLAYER_LEVEL_UP") then
UpdatePlvl();
elseif (event == "PLAYER_DEAD") then
UpdateDeaths();
elseif (event == "COMBAT_LOG_EVENT_UNFILTERED") then
local type, fo, foo, source = select(2, CombatLogGetCurrentEventInfo());
if(source == GetUnitName("player")) then
if (type == "UNIT_DIED") then UpdateKills();
elseif (type == "SPELL_DAMAGE") then
isCrit = select(21, CombatLogGetCurrentEventInfo());
if (isCrit) then
Trackster_critCounter = Trackster_critCounter + 1;
UpdateCrits();
end
--UpdateDmg();
elseif (type == "SPELL_PERIODIC_DAMAGE") then UpdateDmg();
elseif (type == "SPELL_CAST_SUCCESS") then
Trackster_castCounter = Trackster_castCounter + 1;
UpdateCasts();
end
end
UpdateKills();
--UpdateDmg();
elseif (event == "QUEST_TURNED_IN") then
UpdateQuests();
elseif (event == "PLAYER_EQUIPMENT_CHANGED") then
UpdateIlvl();
elseif (event == "PLAYER_MONEY") then
local goldDiff = GetGoldDifference();
if (goldDiff > 0) then
Trackster_goldCounter = Trackster_goldCounter + goldDiff;
UpdateGold();
end
elseif (event == "PLAYER_LOGIN") then
Trackster_loginCounter = Trackster_loginCounter + 1;
UpdateLogins();
elseif (event == "BOSS_KILL") then
Trackster_bossCounter = Trackster_bossCounter + 1;
UpdateBoss();
elseif (event == "CHAT_MSG_LOOT") then
local receiver = select(5, ...);
if(receiver == UnitName("player")) then
Trackster_itemCounter = Trackster_itemCounter + 1;
UpdateItem();
end
elseif (event == "QUEST_LOOT_RECEIVED") then
Trackster_itemCounter = Trackster_itemCounter + 1;
UpdateItem();
elseif (event == "TIME_PLAYED_MSG") then
local timePlayed = select(1, ...);
SyncTimePlayedWithBlizzardServer(timePlayed);
elseif (event == "CHAT_MSG_SAY") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_CHANNEL") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_GUILD") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_OFFICER") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_PARTY") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_PARTY_LEADER") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_RAID") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_RAID_LEADER") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_YELL") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_INSTANCE_CHAT") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_INSTANCE_CHAT_LEADER") then ProcessChatMsg(...);
elseif (event == "CHAT_MSG_WHISPER_INFORM") then
Trackster_chatCounter = Trackster_chatCounter + 1;
UpdateChat();
elseif (event == "CINEMATIC_START") then
mainFrame:Hide();
buttonX:Hide();
elseif (event == "CINEMATIC_STOP") then
Trackster.SetRenderMainFrame(Trackster_showMainframe);
elseif (event == "ADDON_LOADED") then
local addonName = select(1, ...);
if(addonName == "Trackster") then
mainFrame:SetUserPlaced(true);
Trackster.SetFrameScale(Trackster_frameScale);
Trackster.SetRenderMainFrame(Trackster_showMainframe);
UpdateAll();
end
end
end
mainFrame:SetScript("OnEvent", eventHandler);
Trackster.ResetAllStats = function()
Trackster_jumpCounter = 0;
Trackster_distanceTravelledCounter = 0;
Trackster_castCounter = 0;
Trackster_critCounter = 0;
Trackster_goldCounter = 0;
Trackster_loginCounter = 0;
Trackster_bossCounter = 0;
Trackster_chatCounter = 0;
Trackster_itemCounter = 0;
UpdateAll();
end
Trackster.SetRenderMainFrame = function(state)
if (state == true) then
mainFrame:Show();
buttonX:Show();
Trackster_showMainframe = true;
else
mainFrame:Hide();
Trackster_showMainframe = false;
buttonX:Hide();
end
end
buttonX:SetScript("OnClick", function(self) Trackster.SetRenderMainFrame(false) end);
SLASH_Trackster1 = "/Trackster";
SLASH_Trackster2 = "/tr";
SLASH_Trackster3 = "/trackster";
SLASH_Trackster4 = "/tracker";
SLASH_Trackster5 = "/track";
SlashCmdList["Trackster"] = function(msg)
if (msg == "") then
Trackster.SetRenderMainFrame(InvertBool(Trackster_showMainframe));
elseif (msg == "show") then
Trackster.SetRenderMainFrame(true);
elseif (msg == "open") then
Trackster.SetRenderMainFrame(true);
elseif (msg == "hide") then
Trackster.SetRenderMainFrame(false);
elseif (msg == "close") then
Trackster.SetRenderMainFrame(false);
elseif (msg == "toggle") then
Trackster.SetRenderMainFrame(InvertBool(Trackster_showMainframe));
elseif (msg == "pos") then
mainFrame:SetUserPlaced(false);
mainFrame:SetPoint("CENTER", 480, 0, UIParent);
ReloadUI();
elseif (msg == "save") then
ReloadUI();
elseif (msg == "help") then
PrintMsg("Aliases for /trackster:");
PrintMsg("/track");
PrintMsg("/tr");
PrintMsg("Commands:");
PrintMsg("/tr open -> Opens the Trackster window.");
PrintMsg("/tr close -> Closes the Trackster window.");
PrintMsg("/tr toggle -> Toggles the Trackster window.");
PrintMsg("/tr -> Toggles the Trackster window");
PrintMsg("/tr pos -> Resets the Trackster windows position.");
PrintMsg("/tr save -> Saves the stats. (Automatically on logout)");
PrintMsg("/tr help -> Displays this message.");
else
PrintMsg("Unknown command...");
PrintMsg("Type /trackster help for a list of commands.")
end
end
local enableSDEastereggPartII = false;
SLASH_SDEG1 = "/ur";
SlashCmdList["SDEG"] = function(msg)
if (msg == "mom gey") then
print("no u");
enableSDEastereggPartII = true;
elseif (msg == "mom and dad gey together") then
if (enableSDEastereggPartII == true) then
print("Darn! You might win this time...");
end
end
end

429
options.lua Normal file
View File

@ -0,0 +1,429 @@
local optionsFrame = CreateFrame("frame");
optionsFrame.name = "Trackster";
optionsFrame:RegisterEvent("ADDON_LOADED");
local resetSafeword = "Diddly-squat";
local isResetPrimed = false;
local areDefValsLoaded = false;
InterfaceOptions_AddCategory(optionsFrame);
local function InvertBool(b)
if (b == true) then
return false;
else
return true;
end
end
local buttonApply = CreateFrame("Button", nil, optionsFrame);
buttonApply:SetPoint("CENTER", optionsFrame, "BOTTOMRIGHT", -50, 20);
buttonApply:SetWidth(80);
buttonApply:SetHeight(21);
buttonApply:SetText("Apply");
buttonApply:SetNormalFontObject("GameFontNormal");
local buttonReset = CreateFrame("Button", nil, optionsFrame);
buttonReset:SetWidth(105);
buttonReset:SetHeight(21);
buttonReset:SetText("Reset all stats");
buttonReset:SetNormalFontObject("GameFontNormal");
buttonReset:SetEnabled(false);
local buttonShowhide = CreateFrame("Button", "Trackster_ButtonShowHide", optionsFrame);
buttonShowhide:SetPoint("CENTER", optionsFrame, "BOTTOMRIGHT", -50, 45);
buttonShowhide:SetWidth(80);
buttonShowhide:SetHeight(21);
buttonShowhide:SetText("Show/Hide");
buttonShowhide:SetNormalFontObject("GameFontNormal");
buttonShowhide:SetEnabled(true);
buttonShowhide:SetScript("OnClick", function(self) Trackster.SetRenderMainFrame(InvertBool(Trackster_showMainframe)) end);
local ntexA = buttonApply:CreateTexture();
ntexA:SetTexture("Interface/Buttons/UI-Panel-Button-Up");
ntexA:SetTexCoord(0, 0.625, 0, 0.6875);
ntexA:SetAllPoints() ;
buttonApply:SetNormalTexture(ntexA);
local htexA = buttonApply:CreateTexture()
htexA:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight");
htexA:SetTexCoord(0, 0.625, 0, 0.6875);
htexA:SetAllPoints();
buttonApply:SetHighlightTexture(htexA);
local ptexA = buttonApply:CreateTexture();
ptexA:SetTexture("Interface/Buttons/UI-Panel-Button-Down");
ptexA:SetTexCoord(0, 0.625, 0, 0.6875);
ptexA:SetAllPoints();
buttonApply:SetPushedTexture(ptexA);
----------------------------------------
local htexR = buttonReset:CreateTexture()
htexR:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight");
htexR:SetTexCoord(0, 0.625, 0, 0.6875);
htexR:SetAllPoints();
buttonReset:SetHighlightTexture(htexR);
local ptexR = buttonReset:CreateTexture();
ptexR:SetTexture("Interface/Buttons/UI-Panel-Button-Down");
ptexR:SetTexCoord(0, 0.625, 0, 0.6875);
ptexR:SetAllPoints();
buttonReset:SetPushedTexture(ptexR);
local ntexR = buttonReset:CreateTexture();
ntexR:SetTexture("Interface/Buttons/UI-Panel-Button-Up");
ntexR:SetTexCoord(0, 0.625, 0, 0.6875);
ntexR:SetAllPoints() ;
buttonReset:SetNormalTexture(ntexR);
----------------------------------------
local htexS = buttonShowhide:CreateTexture()
htexS:SetTexture("Interface/Buttons/UI-Panel-Button-Highlight");
htexS:SetTexCoord(0, 0.625, 0, 0.6875);
htexS:SetAllPoints();
buttonShowhide:SetHighlightTexture(htexS);
local ptexS = buttonShowhide:CreateTexture();
ptexS:SetTexture("Interface/Buttons/UI-Panel-Button-Down");
ptexS:SetTexCoord(0, 0.625, 0, 0.6875);
ptexS:SetAllPoints();
buttonShowhide:SetPushedTexture(ptexS);
local ntexS = buttonShowhide:CreateTexture();
ntexS:SetTexture("Interface/Buttons/UI-Panel-Button-Up");
ntexS:SetTexCoord(0, 0.625, 0, 0.6875);
ntexS:SetAllPoints() ;
buttonShowhide:SetNormalTexture(ntexS);
local textFont = "GameFontWhite";
local textMarginB = 27.5;
local textMarginT = 25;
local textMarginL = 25;
local editboxMarginL = 150;
local fsInfo = optionsFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
fsInfo:SetText("Thanks for using Trackster!\nPlease note, that some stats are only tracked by this AddOn, hence only count\n upwards from the point of installation. If you want some stats to be tracked\naccount wide, just change them in the .toc file in the AddOn folder!\nHave fun! -Allpi");
fsInfo:SetPoint("CENTER", 0, -200);
local fsKills = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsDeaths = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsDist = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsQuests = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
--local fsDmg = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsCasts = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsGold = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsCrits = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsLogins = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsBoss = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsItem = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsChat = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsJump = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsTime = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
local fsScale = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
fsKills:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (0 * textMarginB)))
fsDeaths:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (1 * textMarginB)))
fsTime:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (2 * textMarginB)))
fsDist:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (3 * textMarginB)))
fsQuests:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (4 * textMarginB)))
--fsDmg:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (4 * textMarginB)))
fsBoss:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (5 * textMarginB)))
fsCasts:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (6 * textMarginB)))
fsGold:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (7 * textMarginB)))
fsCrits:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (8 * textMarginB)))
fsLogins:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (9 * textMarginB)))
fsItem:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (10 * textMarginB)))
fsChat:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (11 * textMarginB)))
fsJump:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (12 * textMarginB)))
fsScale:SetPoint("TOPLEFT", textMarginL, -(textMarginT + (13 * textMarginB)))
buttonReset:SetPoint("TOPLEFT", textMarginL - 5, -(textMarginT + ((14 + 0.2) * textMarginB)));
fsKills:SetText("Kills offset:");
fsDeaths:SetText("Deaths offset:");
fsTime:SetText("Time played offset:");
fsDist:SetText("Distance(m) offset:");
fsQuests:SetText("Quests offset:");
--fsDmg:SetText("Damage offset:");
fsJump:SetText("Jumps offset:");
fsCasts:SetText("Cast offset:");
fsGold:SetText("Gold offset:");
fsCrits:SetText("Crit offset:");
fsLogins:SetText("Logins offset:");
fsBoss:SetText("Bosskills offset:");
fsChat:SetText("Chat msg offset:");
fsItem:SetText("Items offset:");
fsScale:SetText("Frame scale:");
local maxCharacters = 12;
local ebWidth = 110;
local ebKills = CreateFrame("EditBox", "editboxOffsetKills", optionsFrame, "InputBoxTemplate");
ebKills:SetFrameStrata("DIALOG");
ebKills:SetSize(ebWidth,21);
ebKills:SetMaxLetters(maxCharacters);
ebKills:SetAutoFocus(false);
ebKills:SetNumeric(false);
local ebDeaths = CreateFrame("EditBox", "editboxOffsetDeaths", optionsFrame, "InputBoxTemplate");
ebDeaths:SetFrameStrata("DIALOG");
ebDeaths:SetSize(ebWidth,21);
ebDeaths:SetMaxLetters(maxCharacters);
ebDeaths:SetAutoFocus(false);
ebDeaths:SetNumeric(false);
local ebDist = CreateFrame("EditBox", "editboxOffsetDist", optionsFrame, "InputBoxTemplate");
ebDist:SetFrameStrata("DIALOG");
ebDist:SetSize(ebWidth,21);
ebDist:SetMaxLetters(maxCharacters);
ebDist:SetAutoFocus(false);
ebDist:SetNumeric(false);
local ebQuests = CreateFrame("EditBox", "editboxOffsetQuests", optionsFrame, "InputBoxTemplate");
ebQuests:SetNumeric(false);
ebQuests:SetFrameStrata("DIALOG");
ebQuests:SetSize(ebWidth,21);
ebQuests:SetMaxLetters(maxCharacters);
ebQuests:SetAutoFocus(false);
ebQuests:SetNumeric(false);
--local ebDmg = CreateFrame("EditBox", "editboxOffsetDmg", optionsFrame, "InputBoxTemplate");
--ebDmg:SetFrameStrata("DIALOG");
--ebDmg:SetSize(ebWidth,21);
--ebDmg:SetMaxLetters(maxCharacters);
--ebDmg:SetAutoFocus(false);
--ebDmg:SetNumeric(false);
local ebBoss = CreateFrame("EditBox", "editboxOffsetBoss", optionsFrame, "InputBoxTemplate");
ebBoss:SetFrameStrata("DIALOG");
ebBoss:SetSize(ebWidth,21);
ebBoss:SetMaxLetters(maxCharacters);
ebBoss:SetAutoFocus(false);
ebBoss:SetNumeric(false);
local ebCast = CreateFrame("EditBox", "editboxOffsetCast", optionsFrame, "InputBoxTemplate");
ebCast:SetFrameStrata("DIALOG");
ebCast:SetSize(ebWidth,21);
ebCast:SetMaxLetters(maxCharacters);
ebCast:SetAutoFocus(false);
ebCast:SetNumeric(false);
local ebGold = CreateFrame("EditBox", "editboxOffsetGold", optionsFrame, "InputBoxTemplate");
ebGold:SetFrameStrata("DIALOG");
ebGold:SetSize(ebWidth,21);
ebGold:SetMaxLetters(maxCharacters);
ebGold:SetAutoFocus(false);
ebGold:SetNumeric(false);
local ebCrit = CreateFrame("EditBox", "editboxOffsetCrit", optionsFrame, "InputBoxTemplate");
ebCrit:SetFrameStrata("DIALOG");
ebCrit:SetSize(ebWidth,21);
ebCrit:SetMaxLetters(maxCharacters);
ebCrit:SetAutoFocus(false);
ebCrit:SetNumeric(false);
local ebLogin = CreateFrame("EditBox", "editboxOffsetLogin", optionsFrame, "InputBoxTemplate");
ebLogin:SetFrameStrata("DIALOG");
ebLogin:SetSize(ebWidth,21);
ebLogin:SetMaxLetters(maxCharacters);
ebLogin:SetAutoFocus(false);
ebLogin:SetNumeric(false);
local ebJumps = CreateFrame("EditBox", "editboxOffsetJumps", optionsFrame, "InputBoxTemplate");
ebJumps:SetFrameStrata("DIALOG");
ebJumps:SetSize(ebWidth,21);
ebJumps:SetMaxLetters(maxCharacters);
ebJumps:SetAutoFocus(false);
ebJumps:SetNumeric(false);
local ebChat = CreateFrame("EditBox", "editboxOffsetChat", optionsFrame, "InputBoxTemplate");
ebChat:SetFrameStrata("DIALOG");
ebChat:SetSize(ebWidth,21);
ebChat:SetMaxLetters(maxCharacters);
ebChat:SetAutoFocus(false);
ebChat:SetNumeric(false);
local ebItem = CreateFrame("EditBox", "editboxOffsetItem", optionsFrame, "InputBoxTemplate");
ebItem:SetFrameStrata("DIALOG");
ebItem:SetSize(ebWidth,21);
ebItem:SetMaxLetters(maxCharacters);
ebItem:SetAutoFocus(false);
ebItem:SetNumeric(false);
local ebTime = CreateFrame("EditBox", "editboxOffsetTime", optionsFrame, "InputBoxTemplate");
ebTime:SetFrameStrata("DIALOG");
ebTime:SetSize(ebWidth,21);
ebTime:SetMaxLetters(maxCharacters);
ebTime:SetAutoFocus(false);
ebTime:SetNumeric(false);
local ebReset = CreateFrame("EditBox", "editboxConfirmReset", optionsFrame, "InputBoxTemplate");
ebReset:SetFrameStrata("DIALOG");
ebReset:SetSize(ebWidth,21);
ebReset:SetMaxLetters(maxCharacters);
ebReset:SetAutoFocus(false);
ebReset:SetNumeric(false);
local ebScale = CreateFrame("EditBox", "editboxConfirmScale", optionsFrame, "InputBoxTemplate");
ebScale:SetFrameStrata("DIALOG");
ebScale:SetSize(ebWidth,21);
ebScale:SetMaxLetters(maxCharacters);
ebScale:SetAutoFocus(false);
ebScale:SetNumeric(false);
local fsResetInfo = optionsFrame:CreateFontString(nil, "OVERLAY", "GameFontWhite");
fsResetInfo:SetText("<- Enter \"" .. resetSafeword .. "\" to enable the reset function.");
local fsTimeUNIT = optionsFrame:CreateFontString(nil, "OVERLAY", textFont);
fsTimeUNIT:SetText("seconds");
ebKills:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (0 * textMarginB)));
ebDeaths:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (1 * textMarginB)));
ebTime:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (2 * textMarginB)));
ebDist:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (3 * textMarginB)));
ebQuests:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (4 * textMarginB)));
--ebDmg:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (4 * textMarginB)));
ebBoss:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (5 * textMarginB)));
ebCast:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (6 * textMarginB)));
ebGold:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (7 * textMarginB)));
ebCrit:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (8 * textMarginB)));
ebLogin:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (9 * textMarginB)));
ebItem:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (10 * textMarginB)));
ebChat:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (11 * textMarginB)));
ebJumps:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (12 * textMarginB)));
ebScale:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + (13 * textMarginB)));
ebReset:SetPoint("TOPLEFT", editboxMarginL, -(textMarginT + ((14 + 0.2) * textMarginB)));
fsTimeUNIT:SetPoint("TOPLEFT", editboxMarginL * 1.75, -(textMarginT + ((2 + 0.2) * textMarginB) - 2));
fsResetInfo:SetPoint("TOPLEFT", editboxMarginL * 1.85, -(textMarginT + ((14 + 0.2) * textMarginB) + 5));
local function CheckIfICanPrimeReset()
if(ebReset:GetText() == resetSafeword) then
isResetPrimed = true;
else
isResetPrimed = false;
end
end
ebReset:SetScript("OnTextChanged", CheckIfICanPrimeReset);
local function SetResetButtonEnabled(state)
if(state == false) then
buttonReset:SetNormalTexture(dtexR);
buttonReset:SetEnabled(false);
else
buttonReset:SetNormalTexture(ntexR);
buttonReset:SetEnabled(true);
end
end
SetResetButtonEnabled(true);
local function eventHandler(self, event, ...)
if(event == "ADDON_LOADED") then
local name = select(1, ...);
if(name == "Trackster") then
end
end
end
optionsFrame:SetScript("OnEvent", eventHandler);
local function LoadDefaultTexts(doAnways)
if (doAnways == nil) then doAnways = false; end
if (doAnways == true) then areDefValsLoaded = false; end
if (areDefValsLoaded == false) then
ebKills:SetText(Trackster.OffsetKills());
ebDeaths:SetText(Trackster.OffsetDeaths());
ebDist:SetText(Trackster.OffsetDistance());
ebQuests:SetText(Trackster.OffsetQuests());
--ebDmg:SetText(Trackster.OffsetDmg());
ebBoss:SetText(Trackster.OffsetBoss());
ebCast:SetText(Trackster.OffsetCasts());
ebGold:SetText(Trackster.OffsetGold());
ebCrit:SetText(Trackster.OffsetCrits());
ebLogin:SetText(Trackster.OffsetLogin());
ebItem:SetText(Trackster.OffsetItem());
ebChat:SetText(Trackster.OffsetChat());
ebJumps:SetText(Trackster.OffsetJumps());
ebTime:SetText(Trackster.OffsetTime());
ebScale:SetText(Trackster_frameScale);
areDefValsLoaded = true;
end
end
optionsFrame:SetScript("OnShow", LoadDefaultTexts);
optionsFrame:SetScript("OnEnter", LoadDefaultTexts);
buttonReset:SetScript("OnClick", function(self)
if (isResetPrimed == true) then
Trackster.ResetAllStats();
LoadDefaultTexts(true);
isResetPrimed = false;
ebReset:ClearFocus();
ebReset:SetText("");
message("All stats counted by this addon have been reset.");
else
message("Reset blocked!\nPlease enter the safeword!");
end
end);
local function UpdateOffsets()
ebKills:ClearFocus();
ebDeaths:ClearFocus();
ebDist:ClearFocus();
ebQuests:ClearFocus();
--ebDmg:ClearFocus();
ebBoss:ClearFocus();
ebCast:ClearFocus();
ebGold:ClearFocus();
ebCrit:ClearFocus();
ebLogin:ClearFocus();
ebItem:ClearFocus();
ebChat:ClearFocus();
ebJumps:ClearFocus();
ebTime:ClearFocus();
ebScale:ClearFocus();
Trackster.SetFrameScale(ebScale:GetNumber());
Trackster.OffsetKills(ebKills:GetNumber());
Trackster.OffsetDeaths(ebDeaths:GetNumber());
Trackster.OffsetDistance(ebDist:GetNumber());
Trackster.OffsetQuests(ebQuests:GetNumber());
--Trackster.OffsetDmg(ebDmg:GetNumber());
Trackster.OffsetBoss(ebBoss:GetNumber());
Trackster.OffsetCasts(ebCast:GetNumber());
Trackster.OffsetGold(ebGold:GetNumber());
Trackster.OffsetCrits(ebCrit:GetNumber());
Trackster.OffsetLogin(ebLogin:GetNumber());
Trackster.OffsetItem(ebItem:GetNumber());
Trackster.OffsetChat(ebChat:GetNumber());
Trackster.OffsetJumps(ebJumps:GetNumber());
Trackster.OffsetTime(ebTime:GetNumber());
LoadDefaultTexts(true);
end
buttonApply:SetScript("OnClick", UpdateOffsets);
ebKills:SetScript("OnEnterPressed", UpdateOffsets);
ebDeaths:SetScript("OnEnterPressed", UpdateOffsets);
ebTime:SetScript("OnEnterPressed", UpdateOffsets);
ebDist:SetScript("OnEnterPressed", UpdateOffsets);
ebQuests:SetScript("OnEnterPressed", UpdateOffsets);
--ebDmg:SetScript("OnEnterPressed", UpdateOffsets);
ebBoss:SetScript("OnEnterPressed", UpdateOffsets);
ebCast:SetScript("OnEnterPressed", UpdateOffsets);
ebGold:SetScript("OnEnterPressed", UpdateOffsets);
ebCrit:SetScript("OnEnterPressed", UpdateOffsets);
ebLogin:SetScript("OnEnterPressed", UpdateOffsets);
ebItem:SetScript("OnEnterPressed", UpdateOffsets);
ebChat:SetScript("OnEnterPressed", UpdateOffsets);
ebJumps:SetScript("OnEnterPressed", UpdateOffsets);
ebScale:SetScript("OnEnterPressed", UpdateOffsets);