From 1d54231e3a4745e88f30a7ae4ba3e217f795286e Mon Sep 17 00:00:00 2001 From: Cjewett Date: Mon, 18 Nov 2019 23:36:03 -0500 Subject: [PATCH] Alter slash commands - Change what /honorassist does - Add /honorassist help - Add /honorassist log - Add /honorassist show - Add /honorassist hide --- HonorAssist.lua | 37 +++++++++++++++++++++++++++++++++++-- HonorAssist.toc | 2 +- HonorAssistTrackerUi.lua | 16 +++++++++++++++- HonorAssistUtils.lua | 26 +++++++++++++++++++++----- 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/HonorAssist.lua b/HonorAssist.lua index 648f806..db760ca 100644 --- a/HonorAssist.lua +++ b/HonorAssist.lua @@ -75,7 +75,40 @@ function HonorAssist:OnUpdateTimer(timeSinceLastUpdate) end SLASH_HONORASSIST1 = "/honorassist" +SLASH_HONORASSIST2 = "/honorassist help" +SLASH_HONORASSIST3 = "/honorassist log" +SLASH_HONORASSIST4 = "/honorassist show" +SLASH_HONORASSIST5 = "/honorassist hide" SlashCmdList["HONORASSIST"] = function(msg) - HonorAssistLogging = not HonorAssistLogging - print('Honor assist logging set to ' .. tostring(HonorAssistLogging)) + if HonorAssist:StringIsNullOrEmpty(msg) then + HonorAssist:PrintHelpInformation() + end + + local slashCommandMsg = AutoInvite:SplitString(msg, " ") + local subCommand = slashCommandMsg[1] + + if subCommand == "help" then + HonorAssist:PrintHelpInformation() + end + + if subCommand == "log" then + HonorAssistLogging = not HonorAssistLogging + print('Honor assist logging set to ' .. tostring(HonorAssistLogging)) + end + + if subCommand == "show" then + HonorAssist:ShowTrackerUi(true) + end + + if subCommand == "hide" then + HonorAssist:ShowTrackerUi(false) + end +end + +function HonorAssist:PrintHelpInformation() + print("HonorAssist Help Information") + print("/honorassist, /honorassist help -- Displays help information for AutoInvite addon.") + print("/honorassist log -- Enables and disablesdetailed messages to chat about how much honor a kill was worth based on diminishing returns.") + print("/honorassist show -- Shows the Honor Assist (Daily) tracker.") + print("/honorassist hide -- Hides the Honor Assist (Daily) tracker.") end \ No newline at end of file diff --git a/HonorAssist.toc b/HonorAssist.toc index c1f1ab8..8d880f7 100644 --- a/HonorAssist.toc +++ b/HonorAssist.toc @@ -2,7 +2,7 @@ ## Title: HonorAssist ## Author: Eulav, CptMerlot ## Version: 0.2 -## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY +## SavedVariablesPerCharacter: HonorAssistData, HonorAssistLogging, HonorAssistTrackerFramePositionX, HonorAssistTrackerFramePositionY, HonorAssistShowTrackerUi HonorAssist.lua HonorAssistUtils.lua diff --git a/HonorAssistTrackerUi.lua b/HonorAssistTrackerUi.lua index b0cf9b8..955f799 100644 --- a/HonorAssistTrackerUi.lua +++ b/HonorAssistTrackerUi.lua @@ -7,7 +7,12 @@ function HonorAssist:LoadTrackerUiSettings() HonorAssistTrackerFramePositionY = 0 end + if HonorAssistShowTrackerUi == nil then + HonorAssistShowTrackerUi = true + end + HonorAssist:SetPosition() + HonorAssist:ShowTrackerUi(HonorAssistShowTrackerUi) end HonorAssist.trackerFrame = CreateFrame("Frame", addonName, UIParent) @@ -62,7 +67,16 @@ HonorAssist.avgHonorPerHour:SetText("0 honor/hour") -- Show HonorAssist.trackerFrame HonorAssist.trackerFrame:SetPoint("CENTER", 0, 0) -HonorAssist.trackerFrame:Show() + +function HonorAssist:ShowTrackerUi(enable) + if enable == true then + HonorAssistShowTrackerUi = true + HonorAssist.trackerFrame:Show() + elseif enable == false then + HonorAssistShowTrackerUi = false + HonorAssist.trackerFrame:Hide() + end +end function HonorAssist:SetPosition() if HonorAssistTrackerFramePositionX == nil and HonorAssistTrackerFramePositionY == nil then diff --git a/HonorAssistUtils.lua b/HonorAssistUtils.lua index 026e6e5..387d05e 100644 --- a/HonorAssistUtils.lua +++ b/HonorAssistUtils.lua @@ -40,7 +40,7 @@ function HonorAssist:GetHonorDayStartTimeEpochBasedOnRegion() elseif (regionId == 4) then -- Taiwan. TODO: We don't know Taiwan's honor reset time. elseif (regionId == 5) then -- China. TODO: We don't know China's honor reset time. end - + return todaysResetTimeUtc, currentTimeThresholdUtc end @@ -54,12 +54,28 @@ function HonorAssist:CalculateRealisticHonor(timesKilled, estimatedHonorGained) return percentage, realisticHonor end -function HonorAssist:Round(num, numDecimalPlaces) - return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) -end - function HonorAssist:GetPlayerDailyKillCount(playerName) local dailyTotalKills = HonorAssist:GetTotalKillsDailyDatabase(playerName) local totalKills = HonorAssist:GetTotalKillsMasterDatabase(playerName) return dailyTotalKills, totalKills end + +function HonorAssist:Round(num, numDecimalPlaces) + return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num)) +end + +function HonorAssist:StringIsNullOrEmpty(s) + if s == nil or s == '' then + return true + end +end + +function HonorAssist:SplitString(slashCommand, delimiter) + result = {} + + for match in (slashCommand .. delimiter):gmatch("(.-)" .. delimiter) do + table.insert(result, match) + end + + return result +end \ No newline at end of file