Quantcast

- Add display of Realm (optional).

urnati [10-12-24 - 11:27]
- Add display of Realm (optional).
- Add display of Connected Realms to tooltip.
Filename
Titan/TitanHistory.lua
Titan/locale/Localization.lua
TitanLocation/TitanLocation.lua
diff --git a/Titan/TitanHistory.lua b/Titan/TitanHistory.lua
index aa87a2f..ae41f42 100644
--- a/Titan/TitanHistory.lua
+++ b/Titan/TitanHistory.lua
@@ -15,6 +15,13 @@ Green - 'header' - Titan or plugin
 Highlight - notes. tips. and details
 --]]
 Titan_Global.recent_changes = ""
+.. TitanUtils_GetGoldText("8.1.3 : 2024/10/12\n")
+.. TitanUtils_GetGreenText("Location : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Add display of Realm (optional)."
+.. "- Add display of Connected Realms to tooltip."
+)
+.. "\n\n"
 .. TitanUtils_GetGoldText("8.1.2 : 2024/08/24\n")
 .. TitanUtils_GetGreenText("Titan : \n")
 .. TitanUtils_GetHighlightText(""
@@ -24,6 +31,10 @@ Titan_Global.recent_changes = ""
 .. TitanUtils_GetHighlightText(""
 .. "- Restore starting gold for gold per hour calc. #1404\n"
 )
+.. TitanUtils_GetGreenText("XP : \n")
+.. TitanUtils_GetHighlightText(""
+.. "- Reduce update timer to 10 from 30 seconds.\n"
+)
 .. "\n\n"
 .. TitanUtils_GetGoldText("8.1.1 : 2024/08/15\n")
 .. TitanUtils_GetGreenText("Titan : \n")
@@ -69,22 +80,6 @@ Titan_Global.recent_changes = ""
 .. "- Cleanup documentation (comments); made some routines local.\n"
 )
 .. "\n\n"
-.. TitanUtils_GetGoldText("8.0.16 : 2024/07/22\n")
-.. TitanUtils_GetGreenText("Titan : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Updated Retail version to 11.0.0."
-)
-.. TitanUtils_GetGreenText("Gold, Repair, XP : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Gold : Fix gold display when user selects . (period) as thousands separator.\n"
-.. "- Added TitanUtils_NumToString for use in all 3.\n"
-.. "- Added TitanUtils_CashToString for use in Gold and Repair for common look of gold/silver/copper.\n"
-)
-.. TitanUtils_GetGreenText("Regen : \n")
-.. TitanUtils_GetHighlightText(""
-.. "- Cleanup documentation (comments); made some routines local.\n"
-)
-.. "\n\n"

 --[[ Var Notes
 Use for important notes in the Titan Config About
diff --git a/Titan/locale/Localization.lua b/Titan/locale/Localization.lua
index 3f18882..2baf2f3 100644
--- a/Titan/locale/Localization.lua
+++ b/Titan/locale/Localization.lua
@@ -86,6 +86,7 @@ L["TITAN_GOLD_TOOLTIP"] = "Gold Info";
 L["TITAN_GOLD_TOOLTIPTEXT"] = "Total Gold on";
 L["TITAN_GOLD_TTL_GOLD"] = "Total Gold";
 L["TITAN_LOCATION_BUTTON_LABEL"] = "Loc: ";
+L["TITAN_LOCATION_CONNECTED_REALMS"] = "Connected Realms";
 L["TITAN_LOCATION_FORMAT_COORD_LABEL"] = "Coordinate Format";
 L["TITAN_LOCATION_FORMAT_LABEL"] = "(xx , yy)";
 L["TITAN_LOCATION_FORMAT"] = "(%.d, %.d)";
@@ -98,11 +99,13 @@ L["TITAN_LOCATION_MAP_PLAYER_COORDS_TEXT"] = "Player: %s";
 L["TITAN_LOCATION_MENU_SHOW_COORDS_ON_MAP_TEXT"] = "Show Coordinates on World Map";
 L["TITAN_LOCATION_MENU_SHOW_COORDS_ON_PANEL_TEXT"] = "Show Text Coordinates";
 L["TITAN_LOCATION_MENU_SHOW_LOC_ON_MINIMAP_TEXT"] = "Show Location Name Above Minimap";
+L["TITAN_LOCATION_MENU_SHOW_REALM_ON_PANEL_TEXT"] = "Show Realm Text"
 L["TITAN_LOCATION_MENU_SHOW_SUBZONE_ON_PANEL_TEXT"] = "Show Only Subzone Text";
 L["TITAN_LOCATION_MENU_SHOW_ZONE_ON_PANEL_TEXT"] = "Show Zone Text";
 L["TITAN_LOCATION_MENU_TEXT"] = "Location";
 L["TITAN_LOCATION_MENU_UPDATE_WORLD_MAP"] = "Update World Map When Zone Changes";
 L["TITAN_LOCATION_NO_COORDS"] = "No Coords";
+L["TITAN_LOCATION_REALM"] = "Realm: ";
 L["TITAN_LOCATION_TOOLTIP_HINTS_1"] = "Hint: Shift + left-click to add location";
 L["TITAN_LOCATION_TOOLTIP_HINTS_2"] = "info to the chat message.";
 L["TITAN_LOCATION_TOOLTIP_HOMELOCATION"] = "Home Location";
diff --git a/TitanLocation/TitanLocation.lua b/TitanLocation/TitanLocation.lua
index 28c97e9..94f68b6 100755
--- a/TitanLocation/TitanLocation.lua
+++ b/TitanLocation/TitanLocation.lua
@@ -34,6 +34,10 @@ local place = {
 	factionName = "",
 	px = 0,
 	py = 0,
+	realm = "",
+	realm_connected = {},
+	realm_connected_num = 0,
+	realm_tooltip = "",
 	-- to save a few cpu cycles when map is up
 	show_on_map = false,
 	coords_style = "",
@@ -115,6 +119,31 @@ local function GetPlayerMapPosition()
 	end
 end

+---local Get the player realm and connected realms; set in place var for button text and tooltip.
+local function RealmUpdate()
+	local realmName = GetRealmName()
+--	local normalized = GetNormalizedRealmName()
+	local realm_names = GetAutoCompleteRealms() -- This returns normalized server names...
+
+	place.realm = realmName
+	place.realm_connected = realm_names
+
+	local realm_text = ""
+	if #realm_names == 0 then
+		place.realm_connected_num = 0
+		realm_text = " "..NONE.."\n"
+	else
+		place.realm_connected_num = #realm_names
+		table.sort(realm_names, function(a, b)
+			return a < b
+		end)
+
+		for i,v in pairs (realm_names) do
+			realm_text = realm_text..string.format("%2d", i).." "..v.."\n"
+		end
+	end
+	place.realm_tooltip = realm_text
+end
 ---local Function to throttle down unnecessary updates
 local function CheckForPositionUpdate()
 	local mapID = C_Map.GetBestMapForUnit("player")
@@ -146,6 +175,8 @@ local function ZoneUpdate(self)
 	place.subZoneText = GetSubZoneText();
 	place.pvpType, _, place.factionName = GetZonePVP();

+	RealmUpdate()
+
 	TitanPanelPluginHandle_OnUpdate(updateTable);
 end

@@ -449,6 +480,8 @@ end

 ---local Calculate coordinates and then display data on button.
 ---@param id string
+---@return string realm_label
+---@return string realm_text
 ---@return string plugin_label
 ---@return string plugin_text
 local function GetButtonText(id)
@@ -519,7 +552,18 @@ local function GetButtonText(id)
 		locationRichText = TitanUtils_GetHighlightText(locationRichText);
 	end

-	return L["TITAN_LOCATION_BUTTON_LABEL"], locationRichText;
+	local realm_label = ""
+	local realm = ""
+	if (TitanGetVar(TITAN_LOCATION_ID, "ShowRealmText")) then
+		realm_label = L["TITAN_LOCATION_REALM"]
+		realm = place.realm
+	else
+		realm_label = ""
+		realm = ""
+	end
+
+	return realm_label, realm,
+		L["TITAN_LOCATION_BUTTON_LABEL"], locationRichText
 end

 ---local Get tooltip text
@@ -555,12 +599,18 @@ local function GetTooltipText()
 	)
 	local bind_loc = TitanUtils_GetHighlightText(GetBindLocation())

-	return "" ..
-		L["TITAN_LOCATION_TOOLTIP_ZONE"] .. "\t" .. zone .. "\n"
+	local connected = "\n"
+		..TitanUtils_GetHighlightText(L["TITAN_LOCATION_CONNECTED_REALMS"].." - "..place.realm_connected_num).."\n"
+		..place.realm_tooltip.. "\n"
+
+	return ""
+		.."Realm:" .. "\t" .. TitanUtils_GetHighlightText(place.realm) .. "\n"
+		..L["TITAN_LOCATION_TOOLTIP_ZONE"] .. "\t" .. zone .. "\n"
 		.. sub_zone .. "\n"
 		.. TitanUtils_GetHighlightText(L["TITAN_LOCATION_TOOLTIP_HOMELOCATION"]) .. "\n"
 		.. L["TITAN_LOCATION_TOOLTIP_INN"] .. "\t" .. bind_loc .. "\n"
-		.. pvpInfoRichText .. "\n\n"
+		.. pvpInfoRichText .. "\n"
+		.. connected
 		.. TitanUtils_GetGreenText(L["TITAN_LOCATION_TOOLTIP_HINTS_1"]) .. "\n"
 		.. TitanUtils_GetGreenText(L["TITAN_LOCATION_TOOLTIP_HINTS_2"])
 end
@@ -656,6 +706,15 @@ local function CreateMenu()
 		if TitanPanelRightClickMenu_GetDropdMenuValue() == "Options" then
 			TitanPanelRightClickMenu_AddTitle(L["TITAN_PANEL_OPTIONS"], TitanPanelRightClickMenu_GetDropdownLevel());
 			info = {};
+			info.text = L["TITAN_LOCATION_MENU_SHOW_REALM_ON_PANEL_TEXT"];
+			info.func = function()
+				TitanToggleVar(TITAN_LOCATION_ID, "ShowRealmText");
+				TitanPanelButton_UpdateButton(TITAN_LOCATION_ID);
+			end
+			info.checked = TitanGetVar(TITAN_LOCATION_ID, "ShowRealmText");
+			TitanPanelRightClickMenu_AddButton(info, TitanPanelRightClickMenu_GetDropdownLevel());
+
+			info = {};
 			info.text = L["TITAN_LOCATION_MENU_SHOW_ZONE_ON_PANEL_TEXT"];
 			info.func = function()
 				TitanToggleVar(TITAN_LOCATION_ID, "ShowZoneText");
@@ -842,6 +901,7 @@ local function OnLoad(self)
 			DisplayOnRightSide = true,
 		},
 		savedVariables = {
+			ShowRealmText = false,
 			ShowZoneText = 1,
 			ShowSubZoneText = false,
 			ShowCoordsText = true,