diff --git a/Titan/LDBToTitan.lua b/Titan/LDBToTitan.lua
index df164ab..df834fc 100644
--- a/Titan/LDBToTitan.lua
+++ b/Titan/LDBToTitan.lua
@@ -28,6 +28,7 @@ Supported
^ user controlled show / hide
:DESC
--]]
+local L = LibStub("AceLocale-3.0"):NewLocale("Titan","enUS",true)
--[[ doc
-----------------------------------------------------------------
@@ -523,32 +524,27 @@ function TitanLDBRefreshButton()
end
end
---[[ Titan
-NAME: LDBToTitan:TitanLDBCreateObject
-DESC: New DO (Data Object) gets created here
+--[[ local
+NAME: CreateObject
+DESC: Helper for LDBToTitan:TitanLDBCreateObject
VAR: _ - not used
VAR: name - id of the plugin
VAR: obj - LDB object
-OUT: None
-NOTE:
-- This is the heart of the LDB to Titan. It reads the LDB DO (Data Object)and creates a Titan plugin.
-- This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended.
-:NOTE
+OUT: result record
--]]
-function LDBToTitan:TitanLDBCreateObject(_, name, obj)
- --TitanDebug("Attempting to register "..name..".");
-
+local function CreateObject(self, _, name, obj)
+
-- couple sanity checks
if not obj or not name then
--- TitanDebug(.."LDB request to create Titan plugin was unrecognizable!!!!")
- return
+ error("\n"..L["TITAN_PANEL_LDB_UNREC_ERROR"],2)
end
-
+
-- anything to pass to the developer / user
local notes = ""
-- sanity check for supported types
obj.type = obj.type or "Unknown"
+--TitanPrint("LDB ++ '"..(obj.type or "?").."'")
local supported = false -- assume failure
for idx in ipairs(SupportedDOTypes) do
if obj.type and obj.type == SupportedDOTypes[idx] then
@@ -573,7 +569,8 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj)
plugin_type = (obj.type or ""),
}
TitanUtils_PluginFail(plugin)
- return -- get out, there is nothing more that can be done
+ error("\n"..L["TITAN_PANEL_LDB_UNSUPPORTED_ERROR"].." '"..obj.type.."'",2)
+ -- get out, there is nothing more that can be done
end
--
@@ -655,6 +652,46 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj)
CALLBACK_PREFIX..name.."_iconB", "TitanLDBIconUpdate")
end
+ -- Set the plugin category, if it exists, else default to "General"
+ -- Per the 1.1 LDB spec we check for a tocname attribute first,
+ -- if found we use it, if not we assume that the DO "name"
+ -- attribute is the same as the actual
+ -- addon name, which might not always be the case.
+ -- Titan defaults again to "General" if no category is found
+ -- via a check in the menu implementation, later on.
+ local tempname
+ -- These checks are messy but leave notes for the developer
+ tempname = nil
+ if obj.tocname then
+ if pcall(function() IsAddOnLoaded(obj.tocname) end) then
+ tempname = obj.tocname
+ else
+ notes = notes.."\n"
+ .."The LDB tocname '"..(obj.tocname or "?").."'"
+ .." does NOT match the addon name per the LibDataBroker spec."
+ end
+ end
+ if tempname == nil and pcall(function() IsAddOnLoaded(name) end) then
+ tempname = name
+ else
+ tempname = nil
+ notes = notes.."\n"
+ .."The LDB name '"..name.."'"
+ .." does NOT match the addon name."
+ end
+ -- check for category and version from the TOC file
+ local cat, ver
+ if tempname then
+ -- Fit known categories into the Titan plugin categories
+ local cat = GetAddOnMetadata(tempname, "X-Category");
+ cat = cat and xcategories[cat] or nil
+
+ ver = GetAddOnMetadata(tempname, "Version") or nil;
+ else
+ notes = notes.."\n"
+ .."Unable to get category or version from TOC!"
+ end
+
--
-- Setup the Titan plugin for this LDB addon
--
@@ -667,6 +704,8 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj)
menuText = obj.label or name,
buttonTextFunction = "TitanLDBShowText",
icon = ldb__icon,
+ category = (cat or nil),
+ version = (ver or nil),
iconWidth = 16,
controlVariables = {
ShowIcon = true,
@@ -697,43 +736,23 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj)
iconG = (obj.iconG or nil),
};
- -- Set the plugin category, if it exists, else default to "General"
- -- Per the 1.1 LDB spec we check for a tocname attrib first,
- -- if found we use it, if not we assume that the DO "name"
- -- attribute is the same as the actual
- -- addon name, which might not always be the case.
- -- Titan defaults again to "General" if no categoy is found
- -- via a check in the menu implementation, later on.
- local addoncategory, addonversion;
- local tempname = obj.tocname or name;
- if IsAddOnLoaded(tempname) then
- addoncategory = GetAddOnMetadata(tempname, "X-Category");
- registry["category"]= addoncategory and xcategories[addoncategory] or nil
- addonversion = GetAddOnMetadata(tempname, "Version");
- registry["version"]= addonversion or nil;
- end
-
-- Depending on the LDB type set the control and saved Variables appropriately
if obj.type == LAUNCHER then
- -- controls
-- one interpretation of the LDB spec is launchers
-- should always have an icon.
registry["controlVariables"].ShowIcon = false;
registry["controlVariables"].ShowRegularText = false; -- no text
- -- defaults
registry["savedVariables"].ShowRegularText = false;
registry["savedVariables"].DisplayOnRightSide = true; -- start on right side
end
if obj.type == DATA_SOURCE then
- -- controls
registry["controlVariables"].ShowRegularText = true;
- -- defaults
registry["savedVariables"].ShowRegularText = true;
end
--
- -- Create the frame for this LDB addon
+ -- Create the frame for this LDB addon - we are committed now
--
-- Create the Titan Frame as a Combo
@@ -790,6 +809,40 @@ function LDBToTitan:TitanLDBCreateObject(_, name, obj)
if Titan__InitializedPEW then
TitanPanel_PlayerEnteringWorld()
end
+
+ return "Created"
+end
+--[[ Titan
+NAME: LDBToTitan:TitanLDBCreateObject
+DESC: New DO (Data Object) gets created here
+VAR: _ - not used
+VAR: name - id of the plugin
+VAR: obj - LDB object
+OUT: None
+NOTE:
+- This is the heart of the LDB to Titan. It reads the LDB DO (Data Object)and creates a Titan plugin.
+- This takes a stricter interpretation of the LDB 1.1 spec rather than guessing what LDB addon developers intended.
+- A helper routine is called via pcall to prevent Titan from failing
+- Warnings will be in the Titan configuration under Attempts
+:NOTE
+--]]
+function LDBToTitan:TitanLDBCreateObject(_, name, obj)
+ -- securely call the creation in case the LDB plugin fails to initialize
+ local ok, msg = pcall(CreateObject, self, _, name, obj)
+
+ if ok
+ then
+ TitanPrint("LDB :)"
+ .." '"..(name or "?").."'"
+ .." "..(msg or "nyl")
+ )
+ else
+ TitanPrint("LDB :("
+ .." '"..(name or "?").."'"
+ .." "..(msg or "nyl")
+ .."\n"..L["TITAN_PANEL_LDB_CONTACT_DEV"]
+ , "error")
+ end
end
--[[ Titan
@@ -799,7 +852,7 @@ VAR: event - string
VAR: function
OUT: None
NOTE:
-- PLAYER_LOGIN - Read through all the LDB object created so far and create cooresponding Titan plugins.
+- PLAYER_LOGIN - Read through all the LDB objects created so far and create corresponding Titan plugins.
- PLAYER_ENTERING_WORLD - Create a one time timer. This helps ensure the latest values are displayed on the plugin. Some LDB addons create their objects then update the addon values. Titan could have missed the updates as it created & registered the Titan plugin.
:NOTE
--]]
@@ -813,7 +866,6 @@ LDBToTitan:SetScript("OnEvent", function(self, event, ...)
-- Register the LDB plugins that have been created so far
for name, obj in ldb:DataObjectIterator() do
self:TitanLDBCreateObject(nil, name, obj)
- --TitanDebug("Registered "..name..".");
end
end
@@ -825,4 +877,5 @@ LDBToTitan:SetScript("OnEvent", function(self, event, ...)
TitanMovable_AdjustTimer("LDBRefresh")
end
end
-)
\ No newline at end of file
+)
+TitanPrint("LDB to Titan")
diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua
index 14825b8..bd89eb6 100755
--- a/Titan/TitanMovable.lua
+++ b/Titan/TitanMovable.lua
@@ -316,7 +316,7 @@ local MData = {
move = function () MoveFrame("TargetFrame", 0, TITAN_PANEL_PLACE_TOP) end,
addonAdj = false, },
[3] = {frameName = "PartyMemberFrame1",
- move = function () MoveFrame("PartyMemberFrame1", -128, TITAN_PANEL_PLACE_TOP) end,
+ move = function () MoveFrame("PartyMemberFrame1", 20, TITAN_PANEL_PLACE_TOP) end,
addonAdj = false, },
[4] = {frameName = "TicketStatusFrame",
move = function () MoveFrame("TicketStatusFrame", 0, TITAN_PANEL_PLACE_TOP) end,
@@ -350,12 +350,12 @@ local MData = {
move = function ()
-- account for Reputation Status Bar (doh)
local yOffset = 98
- local playerlevel = UnitLevel("player");
- if ReputationWatchStatusBar
- and ReputationWatchStatusBar:IsVisible()
- and playerlevel < _G["MAX_PLAYER_LEVEL"] then
- yOffset = yOffset + 8;
- end
+ local playerlevel = UnitLevel("player");
+ if ReputationWatchStatusBar
+ and ReputationWatchStatusBar:IsVisible()
+ and playerlevel < _G["MAX_PLAYER_LEVEL"] then
+ yOffset = yOffset + 8;
+ end
MoveFrame("MultiBarRight", yOffset, TITAN_PANEL_PLACE_BOTTOM) end,
addonAdj = false, },
[8] = {frameName = "OverrideActionBar",
diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua
index 06c7085..e169e8d 100644
--- a/Titan/TitanUtils.lua
+++ b/Titan/TitanUtils.lua
@@ -1413,7 +1413,7 @@ function TitanUtils_RegisterPluginList()
local cnt = 0
if TitanPluginToBeRegisteredNum > 0 then
if not Titan__InitializedPEW and not TitanAllGetVar("Silenced") then
- TitanDebug(L["TITAN_PANEL_REGISTER_START"], "normal")
+ TitanPrint(L["TITAN_PANEL_REGISTER_START"], "normal")
end
for index, value in ipairs(TitanPluginToBeRegistered) do
if TitanPluginToBeRegistered[index] then
@@ -1422,7 +1422,7 @@ function TitanUtils_RegisterPluginList()
cnt = cnt + 1
end
if not Titan__InitializedPEW and not TitanAllGetVar("Silenced") then
- TitanDebug((L["TITAN_PANEL_REGISTER_END"].." "..cnt), "normal")
+ TitanPrint((L["TITAN_PANEL_REGISTER_END"].." "..cnt), "normal")
end
end
end
@@ -1849,6 +1849,8 @@ function TitanPrint(message, msg_type)
dtype = "|cFFFFFF00".."Warning: ".._G["FONT_COLOR_CODE_CLOSE"]
elseif msg_type == "plain" then
pre = ""
+ elseif msg_type == "normal" then
+ ;
elseif msg_type == "header" then
local ver = TitanPanel_GetVersion()
pre = TitanUtils_GetGoldText(L["TITAN_PANEL"])
@@ -1984,6 +1986,28 @@ function TitanArgConvert (event, a1, a2, a3, a4, a4, a5, a6)
)
end
+function TitanDumpTable(tb, level)
+ if type(tb) == "table" then
+ level = level or 1
+ local spaces = string.rep(' ', level*2)
+ for k,v in pairs(tb) do
+ if type(v) ~= "table" then
+ if type(v) == "function" then
+ TitanPrint("["..level.."] '"..spaces.."["..tostring(k).."]=".."<func>")
+ else
+ TitanPrint("["..level.."]v'"..spaces.."["..tostring(k).."]='"..tostring(v).."'")
+ end
+ else
+ TitanPrint("["..level.."]t'"..spaces.."["..tostring(k).."]")
+ level = level + 1
+ TitanDumpTableL(v, level)
+ end
+ end
+ else
+ ; --not expected - fail silently
+ end
+end
+
--------------------------------------------------------------
--
-- Deprecated routines
diff --git a/Titan/locale/Localization.lua b/Titan/locale/Localization.lua
index 952fb6e..da28f20 100644
--- a/Titan/locale/Localization.lua
+++ b/Titan/locale/Localization.lua
@@ -550,3 +550,8 @@ L["TITAN_VOLUME_CONTROL_LOW"] = "Low";
L["TITAN_VOLUME_MENU_TEXT"] = "Volume Control";
L["TITAN_VOLUME_MENU_AUDIO_OPTIONS_LABEL"] = "Show Sound/Voice Options" ;
L["TITAN_VOLUME_MENU_OVERRIDE_BLIZZ_SETTINGS"] = "Override Blizzard Volume Settings";
+
+-- LDB (Lib Data Broker) plugin help and creation
+L["TITAN_PANEL_LDB_UNREC_ERROR"] = "LDB request was unrecognizable!.";
+L["TITAN_PANEL_LDB_UNSUPPORTED_ERROR"] = "LDB type not supported !.";
+L["TITAN_PANEL_LDB_CONTACT_DEV"] = " Contact addon developer.";