Skip to content

Commit

Permalink
Merge old and new
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjafelicijan committed Jul 10, 2024
1 parent 5d7e8fc commit c85d739
Show file tree
Hide file tree
Showing 21 changed files with 964 additions and 0 deletions.
24 changes: 24 additions & 0 deletions AutoRepair.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local feature = ns.Register({
identifier = "AutoRepair",
description = "Automatically initiates gear repairs upon interacting with a merchant.",
category = "automation",
config = {}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("MERCHANT_SHOW")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end

if IsShiftKeyDown() then return end
if CanMerchantRepair() then
local RepairCost, CanRepair = GetRepairAllCost()
if RepairCost > 0 and GetMoney() >= RepairCost then
RepairAllItems()
print(string.format("|cff00ff00Gear repaired: |cffffffff%s", GetCoinText(RepairCost)))
end
end
end)
22 changes: 22 additions & 0 deletions CastbarPosition.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local feature = ns.Register({
identifier = "CastbarPosition",
description = "Adjust the position of the casting bar higher.",
category = "interface",
config = {}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("UI_SCALE_CHANGED")
frame:RegisterEvent("DISPLAY_SIZE_CHANGED")
frame:RegisterEvent("UNIT_SPELLCAST_SENT")
frame:RegisterEvent("SPELL_UPDATE_USABLE")
frame:RegisterEvent("UNIT_AURA")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end

CastingBarFrame:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 270)
end)
15 changes: 15 additions & 0 deletions ChatArrowKeys.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
local feature = ns.Register({
identifier = "ChatArrowKeys",
description = "Allows arrow keys to be used in chat windows.",
category = "social",
config = {}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end
ChatFrameEditBox:SetAltArrowKeyMode(false);
end)
41 changes: 41 additions & 0 deletions ChatScrolling.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
local feature = ns.Register({
identifier = "ChatScrolling",
description = "Allows to scroll in chat using the mouse wheel.",
category = "social",
config = {
scrollSpeed = 1,
}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")

local function ChatOnMouseWheel()
if arg1 > 0 then
if IsShiftKeyDown() then
this:ScrollToTop()
else
for i=1, feature.config.scrollSpeed do
this:ScrollUp()
end
end
elseif arg1 < 0 then
if IsShiftKeyDown() then
this:ScrollToBottom()
else
for i=1, feature.config.scrollSpeed do
this:ScrollDown()
end
end
end
end

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end

for i=1, NUM_CHAT_WINDOWS do
_G["ChatFrame" .. i]:EnableMouseWheel(true)
_G["ChatFrame" .. i]:SetScript("OnMouseWheel", ChatOnMouseWheel)
end
end)
111 changes: 111 additions & 0 deletions CompareTooltip.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
local feature = ns.Register({
identifier = "CompareTooltip",
description = "Shows compare tooltips while the shift key is pressed.",
category = "interface",
config = {},
})

local frame = CreateFrame("Frame", nil, GameTooltip)

local itemtypes = {
["enUS"] = {
["INVTYPE_WAND"] = "Wand",
["INVTYPE_THROWN"] = "Thrown",
["INVTYPE_GUN"] = "Gun",
["INVTYPE_CROSSBOW"] = "Crossbow",
["INVTYPE_PROJECTILE"] = "Projectile",
},
}

-- set globals for all inventory types
for key, value in pairs(itemtypes[GetLocale()]) do setglobal(key, value) end
INVTYPE_WEAPON_OTHER = INVTYPE_WEAPON.."_other";
INVTYPE_FINGER_OTHER = INVTYPE_FINGER.."_other";
INVTYPE_TRINKET_OTHER = INVTYPE_TRINKET.."_other";

local slots = {
[INVTYPE_2HWEAPON] = "MainHandSlot",
[INVTYPE_BODY] = "ShirtSlot",
[INVTYPE_CHEST] = "ChestSlot",
[INVTYPE_CLOAK] = "BackSlot",
[INVTYPE_FEET] = "FeetSlot",
[INVTYPE_FINGER] = "Finger0Slot",
[INVTYPE_FINGER_OTHER] = "Finger1Slot",
[INVTYPE_HAND] = "HandsSlot",
[INVTYPE_HEAD] = "HeadSlot",
[INVTYPE_HOLDABLE] = "SecondaryHandSlot",
[INVTYPE_LEGS] = "LegsSlot",
[INVTYPE_NECK] = "NeckSlot",
[INVTYPE_RANGED] = "RangedSlot",
[INVTYPE_RELIC] = "RangedSlot",
[INVTYPE_ROBE] = "ChestSlot",
[INVTYPE_SHIELD] = "SecondaryHandSlot",
[INVTYPE_SHOULDER] = "ShoulderSlot",
[INVTYPE_TABARD] = "TabardSlot",
[INVTYPE_TRINKET] = "Trinket0Slot",
[INVTYPE_TRINKET_OTHER] = "Trinket1Slot",
[INVTYPE_WAIST] = "WaistSlot",
[INVTYPE_WEAPON] = "MainHandSlot",
[INVTYPE_WEAPON_OTHER] = "SecondaryHandSlot",
[INVTYPE_WEAPONMAINHAND] = "MainHandSlot",
[INVTYPE_WEAPONOFFHAND] = "SecondaryHandSlot",
[INVTYPE_WRIST] = "WristSlot",
[INVTYPE_WAND] = "RangedSlot",
[INVTYPE_GUN] = "RangedSlot",
[INVTYPE_PROJECTILE] = "AmmoSlot",
[INVTYPE_CROSSBOW] = "RangedSlot",
[INVTYPE_THROWN] = "RangedSlot",
}

local function ShowCompare(tooltip)
-- abort if shift is not pressed
if not IsShiftKeyDown() then
ShoppingTooltip1:Hide()
ShoppingTooltip2:Hide()
return
end

for i=1,tooltip:NumLines() do
local tmpText = _G[tooltip:GetName() .. "TextLeft"..i]

for slotType, slotName in pairs(slots) do
if tmpText:GetText() == slotType then
local slotID = GetInventorySlotInfo(slotName)

-- determine screen part
local x = GetCursorPosition() / UIParent:GetEffectiveScale()
local anchor = x < GetScreenWidth() / 2 and "BOTTOMLEFT" or "BOTTOMRIGHT"
local relative = x < GetScreenWidth() / 2 and "BOTTOMRIGHT" or "BOTTOMLEFT"

-- overwrite position for tooltips without owner
local pos, parent = tooltip:GetPoint()
if parent and parent == UIParent and pos == "BOTTOMRIGHT" then
anchor = "BOTTOMRIGHT"
relative = "BOTTOMLEFT"
end

-- first tooltip
ShoppingTooltip1:SetOwner(tooltip, "ANCHOR_NONE");
ShoppingTooltip1:ClearAllPoints();
ShoppingTooltip1:SetPoint(anchor, tooltip, relative, 0, 0);
ShoppingTooltip1:SetInventoryItem("player", slotID)
ShoppingTooltip1:Show()

-- second tooltip
if slots[slotType .. "_other"] then
local slotID_other = GetInventorySlotInfo(slots[slotType .. "_other"])
ShoppingTooltip2:SetOwner(tooltip, "ANCHOR_NONE");
ShoppingTooltip2:ClearAllPoints();
ShoppingTooltip2:SetPoint(anchor, ShoppingTooltip1, relative, 0, 0);
ShoppingTooltip2:SetInventoryItem("player", slotID_other)
ShoppingTooltip2:Show();
end
end
end
end
end

frame:SetScript("OnUpdate", function()
if not ns.IsEnabled(feature.identifier) then return end
ShowCompare(GameTooltip)
end)
89 changes: 89 additions & 0 deletions Core.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
_G = getfenv(0)

if TurtleTweaksDB == nil then
TurtleTweaksDB = {}
end

ns = {}
ns.Features = {}
ns.Config = {
ManaBarColor = { r = 0.0, g = 0.6, b = 1 }
}

ns.Register = function(feature)
if TurtleTweaksDB[feature.identifier] == nil then
TurtleTweaksDB[feature.identifier] = false
end

tinsert(ns.Features, feature)
return feature
end

ns.IsEnabled = function(identifier)
if TurtleTweaksDB[identifier] ~= nil then
return TurtleTweaksDB[identifier]
end
end

ns.KVStorage = {}

ns.KVStorage.defaults = function()
TurtleTweaksDB.KV = {}
end

ns.KVStorage.Get = function(key)
if not TurtleTweaksDB.KV then ns.KVStorage.defaults() end

if key and TurtleTweaksDB.KV[key] then
return TurtleTweaksDB.KV[key]
end
end

ns.KVStorage.Set = function(key, value)
if not TurtleTweaksDB.KV then ns.KVStorage.defaults() end

if key then
TurtleTweaksDB.KV[key] = value
end
end

ns.KVStorage.Del = function(key)
if not TurtleTweaksDB.KV then ns.KVStorage.defaults() end

if key and TurtleTweaksDB.KV[key] then
TurtleTweaksDB.KV[key] = nil
end
end

do
SLASH_TweeksReload1 = "/reloadui"
SLASH_TweeksReload2 = "/reload"
SLASH_TweeksReload3 = "/rl"

SlashCmdList["TweeksReload"] = function(msg, editbox)
ConsoleExec("reloadui")
end
end

function print(message)
DEFAULT_CHAT_FRAME:AddMessage(tostring(message))
end

function ShowErrorMessage(message)
UIErrorsFrame:AddMessage(message, 1.0, 0.9, 0.4)
end

function GetCoinText(money)
if type(money) ~= "number" then return "-" end

local gold = floor(money/100/100)
local silver = floor(mod((money/100),100))
local copper = floor(mod(money,100))

local parts = {}
if gold > 0 then table.insert(parts, string.format("%dg", gold)) end
if silver > 0 then table.insert(parts, string.format("%ds", silver)) end
if copper > 0 then table.insert(parts, string.format("%dc", copper)) end

return table.concat(parts, " ")
end
20 changes: 20 additions & 0 deletions EnvironmentGlow.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local feature = ns.Register({
identifier = "EnvironmentGlow",
description = "Disable screen glow which makes the environment less hazy.",
category = "interface",
config = {}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then
-- Reset to default game values.
SlashCmdList["CONSOLE"]("ffxGlow 1")
return
end

SlashCmdList["CONSOLE"]("ffxGlow 0")
end)
19 changes: 19 additions & 0 deletions FixCastbarVisibility.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local feature = ns.Register({
identifier = "FixCastbarVisibility",
description = "Fixes castbar still being shown after casting.",
category = "utility",
config = {}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("SPELLCAST_FAILED")
frame:RegisterEvent("SPELLCAST_STOP")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end

-- TODO: Find which event is needed to fix this mess.
-- CastingBarFrame:Hide()
end)
44 changes: 44 additions & 0 deletions FreeBagSlots.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local feature = ns.Register({
identifier = "FreeBagSlots",
description = "Displays the number of free bag slots.",
category = "interface",
config = {}
})

local frame = CreateFrame("Frame")

frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("BAG_UPDATE")

frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end

if event == "PLAYER_LOGIN" or event == "BAG_UPDATE" then
if not MainMenuBarBackpackButton then return end

if not MainMenuBarBackpackButton.text then
MainMenuBarBackpackButton.text = MainMenuBarBackpackButton:CreateFontString(nil, "OVERLAY", "NumberFontNormal")
MainMenuBarBackpackButton.text:SetTextColor(1, 1, 1)
MainMenuBarBackpackButton.text:SetPoint("BOTTOMRIGHT", MainMenuBarBackpackButton, "BOTTOMRIGHT", -3, 3)
MainMenuBarBackpackButton.text:SetDrawLayer("OVERLAY", 2)
end

local totalFree = 0
local freeSlots = 0

for i = 0, NUM_BAG_SLOTS do
freeSlots = 0
for slot = 1, GetContainerNumSlots(i) do
local texture = GetContainerItemInfo(i, slot)
if not (texture) then
freeSlots = freeSlots + 1
end
end
totalFree = totalFree + freeSlots
end

MainMenuBarBackpackButton.freeSlots = totalFree
MainMenuBarBackpackButton.text:SetText(string.format("%s", totalFree))
end
end)
Loading

0 comments on commit c85d739

Please sign in to comment.