diff --git a/Titan/Titan.lua b/Titan/Titan.lua
index 49cdc2e..a06da76 100644
--- a/Titan/Titan.lua
+++ b/Titan/Titan.lua
@@ -16,7 +16,6 @@ local IsTitanPanelReset = nil;
local L = LibStub("AceLocale-3.0"):GetLocale(TITAN_ID, true)
local AceTimer = LibStub("AceTimer-3.0")
local media = LibStub("LibSharedMedia-3.0")
-local AceConfigDialog = LibStub("AceConfigDialog-3.0")
-- TitanDebug (cmd.." : "..p1.." "..p2.." "..p3.." "..#cmd_list)
@@ -1124,9 +1123,14 @@ end
---local Check the change in width; snap to edge of any part goes off screen.
---@param self table Titan short bar frame
---@param width number New width
+---@param reason string Note on why this was called
---@return table result .ok boolean; .err string
-local function CheckBarBounds(self, width)
- --- This is a touchy routine - change with care!! :)
+local function CheckBarBounds(self, width, reason)
+ -- This is a touchy routine - change with care!! :)
+ --
+ -- Let WoW handle any change in game scale.
+ -- When Titan scaling changes, recalc the bar placement.
+ -- Although the user may want to move bars in response to any scale change.
local trace = false -- true false
local result = {}
result.ok = true
@@ -1136,19 +1140,29 @@ local function CheckBarBounds(self, width)
local f_name = self:GetName()
local bar_name = TitanBarData[f_name].name
local locale_name = TitanBarData[f_name].locale_name
- local escale = UIParent:GetEffectiveScale()
if TitanBarData[f_name].user_move
- and TitanBarDataVars[f_name].show
+ and TitanBarDataVars[f_name].show
then
+---[[
if trace then
print("Bounds"
.. " " .. tostring(bar_name) .. ""
.. " " .. tostring(width) .. ""
+ .. " " .. tostring(reason) .. ""
)
end
+--]]
local tscale = TitanPanelGetVar("Scale")
+ local x, y, w, scale = TitanVariables_GetBarPos(f_name)
+ local scale_change = false
+ if tscale == scale then
+ -- no need to use scaling to recalc position
+ else
+ scale_change = true
+ -- The 'set' will update the sacaling for next time
+ end
local screen = TitanUtils_ScreenSize()
local screen_right_scaled = screen.scaled_x
local screen_top_scaled = screen.scaled_y
@@ -1157,18 +1171,32 @@ local function CheckBarBounds(self, width)
local screen_right_t = screen.x * tscale
local screen_top_t = screen.y * tscale
+ local bar_left = math.floor(self:GetLeft())
+ local bar_right = math.floor(self:GetRight())
+ local bar_top = math.floor(self:GetTop())
+ local bar_bottom = math.floor(self:GetBottom())
- -- Apply the Titan scaling to get 'real' position within WoW window;
- -- Use floor to trunc decimal places where the side could be right on the edge of the screen.
local orig_w = self:GetWidth() -- * tscale --math.floor(self:GetWidth() * tscale)
- local l_off = math.floor(self:GetLeft() * tscale)
- local r_off = math.floor(self:GetRight() * tscale)
- local t_off = math.floor(self:GetTop() * tscale)
- local b_off = math.floor(self:GetBottom() * tscale)
- local hght = math.floor(t_off - b_off)
-
+ local l_off = bar_left
+ local r_off = bar_right
+ local t_off = bar_top
+ local b_off = bar_bottom
+ local hght = (t_off - b_off)
+
+ if scale_change then
+ -- Apply the Titan scaling to get 'real' position within WoW window;
+ -- Use floor to trunc decimal places where the side could be right on the edge of the screen.
+ l_off = math.floor(bar_left * tscale)
+ r_off = math.floor(bar_right * tscale)
+ t_off = math.floor(bar_top * tscale)
+ b_off = math.floor(bar_bottom * tscale)
+ else
+ -- Just check the bar position
+ end
+---[[
if trace then
print(">Bounds"
+ .. " " .. tostring(bar_name) .. ""
.. "\n"
.. " L " .. tostring(format("%0.1f", l_off)) .. ""
.. " R " .. tostring(format("%0.1f", r_off)) .. ""
@@ -1183,7 +1211,7 @@ local function CheckBarBounds(self, width)
.. " ST_t " .. tostring(format("%0.1f", screen_top_t)) .. ""
)
end
-
+--]]
local w = 0
local x_off = 0
local y_off = 0
@@ -1255,18 +1283,24 @@ local function CheckBarBounds(self, width)
-- self:SetWidth(w_off)
end
- -- Back out Titan scaling
- x_off = x_off / tscale
- y_off = y_off / tscale
+ if scale_change then
+ -- Back out Titan scaling
+ x_off = math.floor(x_off / tscale)
+ y_off = math.floor(y_off / tscale)
+ else
+ -- Accept the results of the checks
+ end
w_off = w_off --/ tscale
TitanVariables_SetBarPos(self, false, x_off, y_off, w_off)
if trace then
print(">>Bounds"
- .. " " .. tostring(result.ok) .. ""
- .. " X " .. tostring(format("%0.1f", x_off)) .. ""
- .. " Y " .. tostring(format("%0.1f", y_off)) .. ""
- .. " W " .. tostring(format("%0.1f", w_off)) .. ""
+ .. " " .. tostring(bar_name) .. ""
+ .. " " .. tostring(result.ok) .. ""
+ .. " SC " .. tostring(scale_change) .. ""
+ .." X "..tostring(format("%0.1f", x_off)).."("..tostring(bar_left)..")"
+ .. " Y " .. tostring(format("%0.1f", y_off)).."("..tostring(bar_bottom)..")"
+ .. " W " .. tostring(format("%0.1f", w_off)) .. ""
)
if err ~= "" then
TitanPrint(locale_name .. " " .. err .. "!!!!"
@@ -1304,7 +1338,7 @@ local function OnMovingStop(self)
self:StopMovingOrSizing()
self.isMoving = nil
- local res = CheckBarBounds(self, 0)
+ local res = CheckBarBounds(self, 0, "OnMovingStop")
if res.ok then
-- placement ok
else
@@ -1321,14 +1355,15 @@ end
local function OnMouseWheel(self, d)
-- Can get noisy, "Initializes" all bars at each click to ensure the bar is drawn.
if IsShiftKeyDown() then
- local old_w = self:GetWidth()
+ local msg = "OnMouseWheel"
local delta = d
if IsControlKeyDown() then
delta = d * 10
+ msg = msg.." +Alt"
else
-- use 1
end
- local res = CheckBarBounds(self, delta)
+ local res = CheckBarBounds(self, delta, msg)
if res.ok then
end
--[[
@@ -1500,8 +1535,6 @@ local function SetBar(frame)
local trace = false
local display = _G[frame];
- -- local res = CheckBarBounds(display, 0)
-
local x, y, w = TitanVariables_GetBarPos(frame)
local tscale = TitanPanelGetVar("Scale")
local show = TitanBarData[frame].show
@@ -1544,7 +1577,7 @@ function TitanPanelBarButton_Show(frame)
SetBar(frame)
---[[
-- The bar may need to be moved back onto the screen.
- local res = CheckBarBounds(display, 0)
+ local res = CheckBarBounds(display, 0, "_Show the bar")
if res.ok then
-- placement ok
else
diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua
index 97bb610..23f374b 100644
--- a/Titan/TitanConfig.lua
+++ b/Titan/TitanConfig.lua
@@ -523,6 +523,13 @@ local function ColorShown(bar)
return res
end
+---X or Y into a string (<num>.yy)
+---@param coord number
+---@return string
+local function Format_coord(coord)
+ return (tostring(format("%0.2f", coord)))
+end
+
--[[ local
NAME: TitanUpdateConfigBars
DESC: Allow the user to control each Titan bar.
@@ -665,7 +672,81 @@ local function TitanUpdateConfigBars(t, pos)
TitanPanelBarButton_DisplayBarsWanted("Bar reset to default position - " .. tostring(info[1]))
end,
}
- -- ======
+--[[
+ position = position + 1 -- spacer
+ args[v.name].args.position_spacer = {
+ order = position,
+ type = "description",
+ width = "full",
+ name = " ",
+ }
+ position = position + 1 -- reset pos
+ args[v.name].args.offset_x_num = {
+ order = position,
+ name = " X ",
+ desc = "",
+ disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM),
+ type = "input",
+ width = ".2",
+ get = function(info)
+ local frame_str = TitanVariables_GetFrameName(info[1])
+ local res = TitanBarDataVars[frame_str].off_x
+print("Config X get"
+.." ".. tostring(info[1])..""
+.." ".. tostring(frame_str)..""
+.." ".. tostring(res)..""
+)
+ return Format_coord(res)
+ end,
+ set = function(info, val)
+ local frame_str = TitanVariables_GetFrameName(info[1])
+print("Config X set"
+.." ".. tostring(frame_str)..""
+.." ".. tostring(val)..""
+)
+ local num = tonumber(val)
+ if num == nil then
+ -- invalid num yell at user :)
+ TitanPrint("error", "X not a number")
+ else
+ TitanBarDataVars[frame_str].off_x = val
+ end
+ end,
+ }
+ position = position + 1 -- reset pos
+ args[v.name].args.offset_y_num = {
+ order = position,
+ name = " Y ",
+ desc = "",
+ disabled = (v.vert == TITAN_TOP or v.vert == TITAN_BOTTOM),
+ type = "input",
+ width = ".2",
+ get = function(info)
+ local frame_str = TitanVariables_GetFrameName(info[1])
+ local res = TitanBarDataVars[frame_str].off_y
+print("Config Y get"
+.." ".. tostring(frame_str)..""
+.." ".. tostring(res)..""
+)
+ return Format_coord(res)
+ end,
+ set = function(info, val)
+ local frame_str = TitanVariables_GetFrameName(info[1])
+print("Config Y set"
+.." ".. tostring(frame_str)..""
+.." ".. tostring(val)..""
+)
+ local num = tonumber(val)
+ if num == nil then
+ -- invalid num yell at user :)
+ TitanPrint("error", "Y not a number")
+ else
+ TitanBarDataVars[frame_str].off_y = val
+ end
+ end,
+ }
+--]]
+-- ======
-- Background group
position = position + 1 -- background
args[v.name].args.back = {
diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua
index 274a38b..aa87a2f 100644
--- a/Titan/TitanHistory.lua
+++ b/Titan/TitanHistory.lua
@@ -15,6 +15,16 @@ Green - 'header' - Titan or plugin
Highlight - notes. tips. and details
--]]
Titan_Global.recent_changes = ""
+.. TitanUtils_GetGoldText("8.1.2 : 2024/08/24\n")
+.. TitanUtils_GetGreenText("Titan : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Fix for short bars drifting when using some Titan scaling other than one (1)."
+)
+.. TitanUtils_GetGreenText("Gold : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Restore starting gold for gold per hour calc. #1404\n"
+)
+.. "\n\n"
.. TitanUtils_GetGoldText("8.1.1 : 2024/08/15\n")
.. TitanUtils_GetGreenText("Titan : \n")
.. TitanUtils_GetHighlightText(""
@@ -75,33 +85,6 @@ Titan_Global.recent_changes = ""
.. "- Cleanup documentation (comments); made some routines local.\n"
)
.. "\n\n"
-.. TitanUtils_GetGoldText("8.0.15 : 2024/07/14\n")
-.. TitanUtils_GetGreenText("Location : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Fix error shown when in instances.\n"
-.. "- Options same in all versions: Show Zone Text shows text or not; Show ONLY subzone removes zone text.\n"
-)
-.. TitanUtils_GetGreenText("Auto Hide (full bars) : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Fix error on clicking 'pin' to toggle auto hide.\n"
-)
-.. "\n\n"
-.. TitanUtils_GetGoldText("8.0.14 : 2024/07/12\n")
-.. TitanUtils_GetGreenText("Titan : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Updated Classic Era version to 1.15.3."
-.. "- AutoHide : Fix tooltip error; shows Enabled / Disabled.\n"
-.. "- Deprecated Titan Child template plugin code removed.\n"
-.. "- Cleanup Titan tool tip code.\n"
-.. "- Refactor Titan code to move color codes to Titan globals.\n"
-.. "- Add debug to Titan startup code.\n"
-)
-.. TitanUtils_GetGreenText("Clock, Location, Performance, Repair, Volume, XP : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Refactor code for IDE, mostly comments; some code.\n"
-.. "- Refactor code for Titan color code changes.\n"
-)
-.. "\n\n"
--[[ Var Notes
Use for important notes in the Titan Config About
diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua
index fc2aad4..c58e1b0 100644
--- a/Titan/TitanVariables.lua
+++ b/Titan/TitanVariables.lua
@@ -1014,20 +1014,24 @@ function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off)
TitanBarDataVars[bar_frame].off_w = w_off
end
end
+ -- This is intended to prevent the bar fromk 'walking' on the screen due to rounding errors...
+ TitanBarDataVars[bar_frame].tscale = TitanPanelGetVar("Scale")
-- :GetPoint(1) results in incorrect values based on point used
end
---Titan Retrieve saved vars of bar position
----@param frame_str string Short bar name
+---@param frame_str string Bar name
---@return number off_x
---@return number off_y
---@return number off_width
+---@return number tscale last Titan scale seen for this bar
function TitanVariables_GetBarPos(frame_str)
- -- local tscale = TitanPanelGetVar("Scale")
+ -- tscale may not exist so return 0 as 'invalid'
return
- TitanBarDataVars[frame_str].off_x, --/ tscale, -- / tscale,
- TitanBarDataVars[frame_str].off_y, --/ tscale, -- / tscale,
- TitanBarDataVars[frame_str].off_w -- / tscale
+ TitanBarDataVars[frame_str].off_x,
+ TitanBarDataVars[frame_str].off_y,
+ TitanBarDataVars[frame_str].off_w,
+ (TitanBarDataVars[frame_str].tscale or 0)
end
---Titan Build the frame name from the bar name
diff --git a/TitanGold/TitanGold.lua b/TitanGold/TitanGold.lua
index 29e7116..ff9582e 100644
--- a/TitanGold/TitanGold.lua
+++ b/TitanGold/TitanGold.lua
@@ -261,6 +261,35 @@ local function NiceCash(value, show_zero, show_neg)
return outstr, gold, silver, copper
end
+---local Take the total cash and make it into a nice, colorful string of g s c (gold silver copper)
+---@param value number
+---@return string outstr Formatted cash for output
+---@return integer gold part of value
+---@return integer silver part of value
+---@return integer copper part of value
+local function NiceTextCash(value)
+ local sep = ""
+ local dec = ""
+ if (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorComma")) then
+ sep = ","
+ dec = "."
+ elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorPeriod")) then
+ sep = "."
+ dec = ","
+ elseif (TitanGetVar(TITAN_GOLD_ID, "UseSeperatorSpace")) then
+ sep = " "
+ dec = "."
+ end
+
+ local outstr, gold, silver, copper =
+ TitanUtils_CashToString(value, sep, dec,
+ TitanGetVar(TITAN_GOLD_ID, "ShowGoldOnly"),
+ true, --TitanGetVar(TITAN_GOLD_ID, "ShowCoinLabels"),
+ false, --TitanGetVar(TITAN_GOLD_ID, "ShowCoinIcons"),
+ TitanGetVar(TITAN_GOLD_ID, "ShowColoredText"))
+ return outstr, gold, silver, copper
+end
+
---local Create Show menu - list of characters in same faction
---@param faction string
---@param level number
@@ -278,7 +307,7 @@ local function ShowMenuButtons(faction, level)
local index = GoldSorted[i]
local character, charserver, char_faction = GetIndexInfo(index)
if character and (char_faction == faction) then
- info.text = character .. " - " .. charserver;
+ info.text = character .. " - " .. charserver.." "..NiceTextCash(GoldSave[index].gold).."";
info.value = character;
info.keepShownOnClick = true;
info.checked = function()
@@ -315,18 +344,11 @@ local function DeleteMenuButtons(faction, level)
local character, charserver, char_faction = GetIndexInfo(index)
info.notCheckable = true
if character and (char_faction == faction) then
- info.text = character .. " - " .. charserver;
+ info.text = character .. " - " .. charserver.." "..NiceTextCash(GoldSave[index].gold).."";
info.value = character;
info.func = function()
- print("Del"
- .. " " .. tostring(index) .. ""
- .. " " .. tostring(GoldSave[index].gold) .. ""
- )
GoldSave[index] = {}
GoldSave[index] = nil
- print("Del"
- .. " " .. tostring(GoldSave[index]) .. ""
- )
TitanPanelButton_UpdateButton(TITAN_GOLD_ID)
end
-- cannot delete current character
@@ -1218,11 +1240,11 @@ print("_OnEvent"
-- Faction is English to use as index NOT display
GOLD_INDEX = CreateIndex(player_name, realmName, player_faction)
- Initialize_Array(self);
else
-- Not this addon
end
elseif (event == "PLAYER_ENTERING_WORLD") then
+ Initialize_Array(self);
Warband.Init()
TitanPanelButton_UpdateButton(TITAN_GOLD_ID)
end