This commit is contained in:
Hao Tran 2024-03-17 18:33:11 -04:00
commit 3725388b2c
16 changed files with 495 additions and 0 deletions

60
Core/Commands.lua Normal file
View File

@ -0,0 +1,60 @@
local addon, ns = ...
local L = ns.L
--------------------------------------------------------------------------------
-- # CORE > COMMANDS
--------------------------------------------------------------------------------
-- reload user interface
SlashCmdList['RELOADUI'] = function()
ReloadUI()
end
SLASH_RELOADUI1 = '/rl'
-- print client patch version
SlashCmdList['PATCHNUMBER'] = function()
print('Klaz|cff1994ffScripts|r — |cnNORMAL_FONT_COLOR:'..L.COMMAND_PATCH_NUMBER..':|r |cnGREEN_FONT_COLOR:'..select(4, GetBuildInfo())..'|r')
end
SLASH_PATCHNUMBER1 = '/patch'
-- clear text in all chat frames
SlashCmdList['CLEARCHAT'] = function()
for i = 1, NUM_CHAT_WINDOWS do
_G[format('ChatFrame%d', i)]:Clear()
end
print('Klaz|cff1994ffScripts|r — |cnNORMAL_FONT_COLOR:'..L.COMMAND_CLEAR_CHAT..'.|r')
end
SLASH_CLEARCHAT1 = '/clearchat'
SLASH_CLEARCHAT2 = '/cc'
-- teleport in/out of instance
SlashCmdList['TELEPORT'] = function()
if IsInInstance() then
LFGTeleport(true)
else
LFGTeleport()
end
end
SLASH_TELEPORT1 = '/teleport'
SLASH_TELEPORT2 = '/tp'
-- leave party/raid group
SlashCmdList['LEAVEGROUP'] = function()
C_PartyInfo.LeaveParty()
end
SLASH_LEAVEGROUP1 = '/leaveparty'
SLASH_LEAVEGROUP2 = '/lp'
-- reset instances
SlashCmdList['RESETINSTANCES'] = function()
ResetInstances()
end
SLASH_RESETINSTANCES1 = '/resetinstances'
SLASH_RESETINSTANCES2 = '/ri'
-- open great vault
SlashCmdList['GREATVAULT'] = function()
LoadAddOn('Blizzard_WeeklyRewards')
WeeklyRewardsFrame:Show()
end
SLASH_GREATVAULT1 = '/gv'

39
Core/Config.lua Normal file
View File

@ -0,0 +1,39 @@
local addon, ns = ...
local L = ns.L
local T = ns.T
--------------------------------------------------------------------------------
-- # CORE > CONFIG
--------------------------------------------------------------------------------
-- ## RESET
--------------------------------------------------------------------------------
StaticPopupDialogs.KLAZSCRIPTS_RESET = {
text = L.CONFIG_POPUP_RESET,
button1 = ACCEPT,
button2 = CANCEL,
OnAccept = function()
end,
OnCancel = function() end,
showAlert = true,
timeout = 0,
whileDead = 1,
hideOnEscape = true,
preferredIndex = 5,
}
-- ## SLASH COMMAND
--------------------------------------------------------------------------------
SlashCmdList['KLAZSCRIPTS'] = function(msg)
if string.lower(msg) == 'reset' then
StaticPopup_Show('KLAZSCRIPTS_RESET')
else
print('------------------------------------------')
print('Klaz|cff1994ffScripts|r')
print('------------------------------------------')
end
end
SLASH_KLAZSCRIPTS1 = '/klazscripts'
SLASH_KLAZSCRIPTS2 = '/kscripts'

25
Core/Functions.lua Normal file
View File

@ -0,0 +1,25 @@
local addon, ns = ...
local T = {}
ns.T = T
--------------------------------------------------------------------------------
-- # CORE > FUNCTIONS
--------------------------------------------------------------------------------
T.ClassColor = RAID_CLASS_COLORS[select(2, UnitClass('player'))]
-- ## CHECK CHAT CHANNEL
--------------------------------------------------------------------------------
-- check which chat channel is appropriate to use
T.ChatChannel = function(warning)
if (not IsInGroup(LE_PARTY_CATEGORY_HOME) or not IsInRaid(LE_PARTY_CATEGORY_HOME)) and IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
return 'INSTANCE_CHAT'
elseif IsInRaid(LE_PARTY_CATEGORY_HOME) then
return 'RAID'
elseif IsInGroup(LE_PARTY_CATEGORY_HOME) then
return 'PARTY'
else
return 'SAY'
end
end

41
Core/Localization.lua Normal file
View File

@ -0,0 +1,41 @@
local addon, ns = ...
local L = {}
ns.L = L
--------------------------------------------------------------------------------
-- # CORE > LOCALIZATION
--------------------------------------------------------------------------------
-- ## ENGLISH
--------------------------------------------------------------------------------
L['COMMAND_PATCH_NUMBER'] = 'Patch'
L['COMMAND_CLEAR_CHAT'] = 'Cleared text in all chat frames'
L['CONFIG_POPUP_RESET'] = 'Klaz|cff1994ffScripts|r\n|cnNORMAL_FONT_COLOR:Apply personalized settings?|r\n|cnRED_FONT_COLOR:Warning! Changes will occur to your UI!'
L['AUTO_REPAIR'] = 'Repair cost'
L['AUTO_REPAIR_GUILD'] = 'Repaired using guild funds'
L['AUTO_REPAIR_BROKE'] = 'You do not have enough gold to auto repair'
L['AUTO_SELL_JUNK'] = 'Sold junk items'
L['MAP_CURSOR'] = 'Cursor'
L['MAP_PLAYER'] = 'Player'
L['MAP_BOUNDS'] = 'Out of bounds'
local locale = GetLocale()
if locale == 'en_GB' or locale == 'enUS' then return end -- ENGLISH
-- ## OTHER
--------------------------------------------------------------------------------
-- if locale == 'esMX' then return end -- SPANISH (MEXICO)
-- if locale == 'pt_BR' then return end -- PORTUGEUSE
-- if locale == 'de_DE' then return end -- GERMAN
-- if locale == 'es_ES' then return end -- SPANISH (SPAIN)
-- if locale == 'fr_FR' then return end -- FRENCH
-- if locale == 'it_IT' then return end -- ITALIAN
-- if locale == 'ru_RU' then return end -- RUSSIAN
-- if locale == 'ko_KR' then return end -- KOREAN
-- if locale == 'zh_TW' then return end -- CHINESE (TRADITIONAL)
-- if locale == 'zh_CN' then return end -- CHINESE (SIMPLIFIED)

20
KlazScripts.toc Normal file
View File

@ -0,0 +1,20 @@
## Interface: 100205
## Title: Klaz|cff1994ffScripts|r
## Author: Klaz
## Notes: Adds quality of life automation and adjustments to the default user interface.
## IconTexture: Interface\AddOns\KlazScripts\Media\KlazAddOnIcon.blp
Core\Localization.lua
Core\Functions.lua
Core\Commands.lua
Core\Config.lua
Modules\Announcements\Interrupts.lua
Modules\Announcements\Sound.lua
Modules\Automation\EasyDelete.lua
Modules\Automation\MailMoney.lua
Modules\Automation\NoEscape.lua
Modules\Automation\Repair.lua
Modules\Automation\ReputationTracker.lua
Modules\Automation\SellJunk.lua
Modules\Maps\WorldMap.lua

BIN
Media/KlazAddOnIcon.blp Normal file

Binary file not shown.

BIN
Media/Screenshot_Map.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 391 KiB

View File

@ -0,0 +1,35 @@
local addon, ns = ...
local T = ns.T
--------------------------------------------------------------------------------
-- # MODULES > ANNOUNCEMENTS > INTERRUPTS
--------------------------------------------------------------------------------
local announceSelf = true
local announceParty = false
local announceRaid = false
local f = CreateFrame('Frame')
f:RegisterEvent('COMBAT_LOG_EVENT_UNFILTERED')
f:SetScript('OnEvent', function()
local _, event, _, sourceGUID, _, _, _, _, destName, _, _, _, _, _, spellID = CombatLogGetCurrentEventInfo()
if not (event == 'SPELL_INTERRUPT' and sourceGUID == UnitGUID('player')) then return end
-- check instant difficulty
local _, _, difficultyID = GetInstanceInfo()
-- do not announce interrupts in open world content
if difficultyID == 0 then return end
-- check instance type
local _, instanceType = IsInInstance()
-- do not announce interrupts in pvp content
if instanceType == 'pvp' or instanceType == 'arena' then return end
if instanceType == 'raid' and announceRaid == true then
SendChatMessage(INTERRUPTED..' '..destName..': '..GetSpellLink(spellID), T.ChatChannel())
elseif (instanceType == 'party' or 'scenario') and announceParty == true then
SendChatMessage(INTERRUPTED..' '..destName..': '..GetSpellLink(spellID), T.ChatChannel())
elseif announceSelf == true then
print('|cff1994ff'..INTERRUPTED..' '..destName..':|r '..GetSpellLink(spellID))
end
end)

View File

@ -0,0 +1,58 @@
--------------------------------------------------------------------------------
-- # MODULES > ANNOUNCEMENTS > SOUND
--------------------------------------------------------------------------------
-- push ready check sound through to master channel
hooksecurefunc('ShowReadyCheck', function(self, initiator)
if initiator ~= 'player' then
PlaySound(SOUNDKIT.READY_CHECK, 'Master')
end
end)
-- push other warning sounds through to master channel
local warn = CreateFrame('Frame')
warn:RegisterEvent('UPDATE_BATTLEFIELD_STATUS')
warn:RegisterEvent('PET_BATTLE_QUEUE_PROPOSE_MATCH')
warn:RegisterEvent('LFG_PROPOSAL_SHOW')
warn:RegisterEvent('RESURRECT_REQUEST')
warn:SetScript('OnEvent', function(self, event)
if event == 'UPDATE_BATTLEFIELD_STATUS' then
for i = 1, GetMaxBattlefieldID() do
local status = GetBattlefieldStatus(i)
if status == 'confirm' then
PlaySound(SOUNDKIT.PVP_THROUGH_QUEUE, 'Master')
break
end
i = i + 1
end
elseif event == 'PET_BATTLE_QUEUE_PROPOSE_MATCH' then
PlaySound(SOUNDKIT.PVP_THROUGH_QUEUE, 'Master')
elseif event == 'LFG_PROPOSAL_SHOW' then
PlaySound(SOUNDKIT.READY_CHECK, 'Master')
elseif event == 'RESURRECT_REQUEST' then
PlaySound(37, 'Master')
end
end)
-- mute crying emote sound
-- why did blizzard curse us with this trinket - Elegy of the Eternals (Shadowlands)
MuteSoundFile(540533) -- female human
MuteSoundFile(539792) -- female dwarf
MuteSoundFile(540273) -- female gnome
MuteSoundFile(540873) -- female night elf
MuteSoundFile(539674) -- female draenei
MuteSoundFile(540736) -- male human
MuteSoundFile(539875) -- male dwarf
MuteSoundFile(540264) -- male gnome
MuteSoundFile(540957) -- male night elf
MuteSoundFile(539609) -- male draenei
MuteSoundFile(541149) -- female orc
MuteSoundFile(542815) -- female tauren
MuteSoundFile(543084) -- female troll
MuteSoundFile(542519) -- female undead
MuteSoundFile(539295) -- female blood elf
MuteSoundFile(541240) -- male orc
MuteSoundFile(542887) -- male tauren
MuteSoundFile(543090) -- male troll
MuteSoundFile(542601) -- male undead
MuteSoundFile(539355) -- male blood elf

View File

@ -0,0 +1,14 @@
--------------------------------------------------------------------------------
-- # MODULES > AUTOMATION > EASY DELETE
--------------------------------------------------------------------------------
-- never type "DELETE" ever again
local deleteDialog = StaticPopupDialogs['DELETE_GOOD_ITEM']
if deleteDialog.OnShow then
hooksecurefunc(deleteDialog, 'OnShow', function(s)
s.editBox:SetText(DELETE_ITEM_CONFIRM_STRING)
s.editBox:SetAutoFocus(false)
s.editBox:ClearFocus()
end)
end

View File

@ -0,0 +1,14 @@
--------------------------------------------------------------------------------
-- # MODULES > AUTOMATION > MAIL MONEY
--------------------------------------------------------------------------------
-- automatically enters subject line when sending money
local function MailSubject(self)
if self:GetText() ~= '' and SendMailSubjectEditBox:GetText() == '' then
SendMailSubjectEditBox:SetText(MONEY)
end
end
SendMailMoneyGold:HookScript('OnTextChanged', MailSubject)
SendMailMoneySilver:HookScript('OnTextChanged', MailSubject)
SendMailMoneyCopper:HookScript('OnTextChanged', MailSubject)

View File

@ -0,0 +1,11 @@
--------------------------------------------------------------------------------
-- # MODULES > AUTOMATION > NO ESCAPE
--------------------------------------------------------------------------------
-- prevent <Esc> from closing these pop-ups
StaticPopupDialogs.RESURRECT.hideOnEscape = nil
StaticPopupDialogs.AREA_SPIRIT_HEAL.hideOnEscape = nil
StaticPopupDialogs.PARTY_INVITE.hideOnEscape = nil
StaticPopupDialogs.CONFIRM_SUMMON.hideOnEscape = nil
StaticPopupDialogs.ADDON_ACTION_FORBIDDEN.button1 = nil
StaticPopupDialogs.TOO_MANY_LUA_ERRORS.button1 = nil

View File

@ -0,0 +1,33 @@
local addon, ns = ...
local L = ns.L
--------------------------------------------------------------------------------
-- # MODULES > AUTOMATION > REPAIR
--------------------------------------------------------------------------------
local autoRepair = true
local autoRepairGuild = true
local f = CreateFrame('Frame')
f:RegisterEvent('MERCHANT_SHOW')
f:SetScript('OnEvent', function()
if CanMerchantRepair() then
local cost = GetRepairAllCost()
if cost > 0 then
-- using guild funds
if autoRepairGuild == true and GetGuildBankWithdrawMoney() >= cost then
RepairAllItems(1)
print('Klaz|cff1994ffScripts|r — |cnYELLOW_FONT_COLOR:'..L.AUTO_REPAIR_GUILD..':|r '..GetCoinTextureString(cost, 10)) -- print using currency icons
PlaySound(SOUNDKIT.ITEM_REPAIR)
-- using personal funds
elseif autoRepair == true and GetMoney() > cost then
RepairAllItems()
print('Klaz|cff1994ffScripts|r — |cnYELLOW_FONT_COLOR:'..L.AUTO_REPAIR..':|r '..GetCoinTextureString(cost, 10)) -- print using currency icons
PlaySound(SOUNDKIT.ITEM_REPAIR)
-- no money
else
print('Klaz|cff1994ffScripts|r — |cnRED_FONT_COLOR:'..L.AUTO_REPAIR_BROKE..'.|r')
end
end
end
end)

View File

@ -0,0 +1,29 @@
--------------------------------------------------------------------------------
-- # MODULES > REPUTATION TRACKER
--------------------------------------------------------------------------------
-- switch reputation tracker to most recently earned reputation
-- ignores guild reputation
local f = CreateFrame('Frame')
f:RegisterEvent('COMBAT_TEXT_UPDATE')
f:SetScript('OnEvent', function(_, event, arg1)
local lastupdate = 0
local lastamount = 0
if (event == 'COMBAT_TEXT_UPDATE' and arg1 == 'FACTION') then
local faction, amount = GetCurrentCombatTextEventInfo()
if (faction ~= 'Guild') then
if (amount > lastamount) or (time() > lastupdate) then
for i=1,GetNumFactions() do
if faction == GetFactionInfo(i) then
SetWatchedFactionIndex(i);
end
end
end
lastamount = amount
lastupdate = time()
end
end
end)

View File

@ -0,0 +1,41 @@
local addon, ns = ...
local L = ns.L
--------------------------------------------------------------------------------
-- # MODULES > AUTOMATION > SELL JUNK
--------------------------------------------------------------------------------
local f = CreateFrame('Frame')
f:RegisterEvent('MERCHANT_SHOW')
f:SetScript('OnEvent', function()
-- local bag, slot
-- for bag = 0, 4 do
-- for slot = 0, C_Container.GetContainerNumSlots(bag) do
-- local item = C_Container.GetContainerItemLink(bag, slot)
-- if item and (select(3, GetItemInfo(item)) == 0) then
-- C_Container.UseContainerItem(bag, slot)
-- end
-- end
-- end
local totalPrice = 0
for bag = 0, 4 do
for bagSlots = 1, C_Container.GetContainerNumSlots(bag) do
CurrentItemLink = C_Container.GetContainerItemLink(bag, bagSlots)
if CurrentItemLink then
_, _, itemRarity, _, _, _, _, _, _, _, itemSellPrice = GetItemInfo(CurrentItemLink)
itemInfo = C_Container.GetContainerItemInfo(bag, bagSlots)
if itemRarity == 0 and itemSellPrice ~= 0 then
totalPrice = totalPrice + (itemSellPrice * itemInfo.stackCount)
C_Container.UseContainerItem(bag, bagSlots)
PickupMerchantItem()
end
end
end
end
if totalPrice ~= 0 then
DEFAULT_CHAT_FRAME:AddMessage('Klaz|cff1994ffScripts|r — |cnYELLOW_FONT_COLOR:'..L.AUTO_SELL_JUNK..':|r '..GetCoinTextureString(totalPrice), 255, 255, 255)
end
end)

75
Modules/Maps/WorldMap.lua Normal file
View File

@ -0,0 +1,75 @@
local addon, ns = ...
local L = ns.L
--------------------------------------------------------------------------------
-- # MODULES > MAPS > WORLD MAP
--------------------------------------------------------------------------------
-- # COORDINATES
--------------------------------------------------------------------------------
local coords = CreateFrame('Frame', 'CoordsFrame', WorldMapFrame)
coords:SetFrameLevel(WorldMapFrame.BorderFrame.TitleContainer:GetFrameLevel() + 2)
coords:SetFrameStrata(WorldMapFrame.BorderFrame.TitleContainer:GetFrameStrata())
coords.PlayerText = coords:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight')
coords.PlayerText:SetPoint('TOPLEFT', WorldMapFrame.BorderFrame.TitleContainer, 'TOPLEFT', 50, -5)
coords.PlayerText:SetJustifyH('LEFT')
coords.PlayerText:SetText(UnitName('player')..': 0, 0')
coords.MouseText = coords:CreateFontString(nil, 'ARTWORK', 'GameFontHighlight')
coords.MouseText:SetJustifyH('LEFT')
coords.MouseText:SetPoint('TOPLEFT', coords.PlayerText, 'TOPRIGHT', 10, 0)
coords.MouseText:SetText(L.MAP_CURSOR..': 0, 0')
local mapRects, tempVec2D = {}, CreateVector2D(0, 0)
local function GetPlayerMapPos(mapID)
tempVec2D.x, tempVec2D.y = UnitPosition('player')
if not tempVec2D.x then return end
local mapRect = mapRects[mapID]
if not mapRect then
local _, pos1 = C_Map.GetWorldPosFromMapPos(mapID, CreateVector2D(0, 0))
local _, pos2 = C_Map.GetWorldPosFromMapPos(mapID, CreateVector2D(1, 1))
if not pos1 or not pos2 then return end
mapRect = {pos1, pos2}
mapRect[2]:Subtract(mapRect[1])
mapRects[mapID] = mapRect
end
tempVec2D:Subtract(mapRect[1])
return (tempVec2D.y/mapRect[2].y), (tempVec2D.x/mapRect[2].x)
end
local int = 0
WorldMapFrame:HookScript('OnUpdate', function()
int = int + 1
if int >= 3 then
local unitMap = C_Map.GetBestMapForUnit('player')
local x, y = 0, 0
if unitMap then
x, y = GetPlayerMapPos(unitMap)
end
if x and y and x >= 0 and y >= 0 then
coords.PlayerText:SetFormattedText('|cff1994ff%s:|r %.2f, %.2f', UnitName('player'), x * 100, y * 100)
else
coords.PlayerText:SetText('|cff1994ff'..UnitName('player')..':|r '..'|cffff0000'..L.MAP_BOUNDS..'!|r')
end
if WorldMapFrame.ScrollContainer:IsMouseOver() then
local mouseX, mouseY = WorldMapFrame.ScrollContainer:GetNormalizedCursorPosition()
if mouseX and mouseY and mouseX >= 0 and mouseY >= 0 then
coords.MouseText:SetFormattedText('|cff1994ff%s:|r %.2f, %.2f', L.MAP_CURSOR, mouseX * 100, mouseY * 100)
else
coords.MouseText:SetText('|cff1994ff'..L.MAP_CURSOR..':|r |cffff0000'..L.MAP_BOUNDS..'!|r')
end
else
coords.MouseText:SetText('|cff1994ff'..L.MAP_CURSOR..':|r |cffff0000'..L.MAP_BOUNDS..'!|r')
end
int = 0
end
end)