Quantcast

- Change Ammo NA to "--"

urnati [09-27-19 - 03:25]
- Change Ammo NA to "--"
- Ammo : Add tooltip text
- Regen : removed MP show / hide; coded to hide MP if no Mana present; changed tooltip for non Mana users
Filename
TitanClassic/locale/Localization.lua
TitanClassicAmmo/TitanClassicAmmo.lua
TitanClassicRegen/TitanClassicRegen.lua
diff --git a/TitanClassic/locale/Localization.lua b/TitanClassic/locale/Localization.lua
index 2bac62a..c7a30a6 100644
--- a/TitanClassic/locale/Localization.lua
+++ b/TitanClassic/locale/Localization.lua
@@ -2,7 +2,7 @@ local L = LibStub("AceLocale-3.0"):NewLocale("TitanClassic","enUS",true)

 L["TITAN_PANEL"] = "Titan Panel Classic";
 local TITAN_PANEL = "Titan Panel Classic";
-L["TITAN_PANEL_ONLY"] = "Titan Panel";
+TITAN_PANEL_ONLY = "Titan Panel";
 L["TITAN_DEBUG"] = "<Titan>";
 L["TITAN_PRINT"] = "Titan";

@@ -249,9 +249,11 @@ L["TITAN_AMMO_BUTTON_LABEL_THROWN"] = "Thrown: ";
 L["TITAN_AMMO_BUTTON_LABEL_AMMO_THROWN"] = "Ammo/Thrown: ";
 L["TITAN_AMMO_TOOLTIP"] = "Equipped Ammo/Thrown Count";
 L["TITAN_AMMO_MENU_TEXT"] = "Ammo/Thrown";
-L["TITAN_AMMO_BUTTON_NOAMMO"] = "No Ammo";
+L["TITAN_AMMO_BUTTON_NOAMMO"] = "--";
 L["TITAN_AMMO_MENU_REFRESH"] = "Refresh Display";
-L["TITAN_AMMO_BULLET_NAME"] = "Show Ammo Name";
+L["TITAN_AMMO_THROWN"] = "Thrown";
+L["TITAN_AMMO_GUN"] = "Bullets";
+L["TITAN_AMMO_BOW"] = "Arrows";

 L["TITAN_BAG_FORMAT"] = "%d/%d";
 L["TITAN_BAG_BUTTON_LABEL"] = "Bags: ";
diff --git a/TitanClassicAmmo/TitanClassicAmmo.lua b/TitanClassicAmmo/TitanClassicAmmo.lua
index 769d581..fd5d09c 100644
--- a/TitanClassicAmmo/TitanClassicAmmo.lua
+++ b/TitanClassicAmmo/TitanClassicAmmo.lua
@@ -24,6 +24,10 @@ local LIM_GOOD = 2
 local LIM_OK   = 1.5
 local LIM_BAD  = .5

+local BOW = "INVTYPE_RANGED"
+local GUN = "INVTYPE_RANGEDRIGHT"
+local THROWN = "INVTYPE_THROWN"
+
 local TITAN_AMMO_THRESHOLD_TABLE = { -- Use ammo stack and threshold limits above to calc colored text
 	["INVTYPE_RANGEDRIGHT"] = {
 		 Values = { SHOOT_STACK*LIM_BAD, SHOOT_STACK*LIM_OK, SHOOT_STACK*LIM_GOOD }, -- 125,375,500
@@ -53,8 +57,8 @@ local L = LibStub("AceLocale-3.0"):GetLocale("TitanClassic", true)
 -- ******************************** Functions *******************************
 local function ClrAmmoInfo()
 	ammo_count = 0;
-	ammo_type  = "";
-	ammo_name  = ""
+	ammo_type  = L["TITAN_AMMO_BUTTON_NOAMMO"];
+	ammo_name  = L["TITAN_AMMO_BUTTON_NOAMMO"]
 	ammo_link  = "";
 	ammo_show  = false
 end
@@ -110,6 +114,7 @@ function TitanPanelAmmoButton_OnLoad(self)
 			menuText = L["TITAN_AMMO_MENU_TEXT"],
 			buttonTextFunction = "TitanPanelAmmoButton_GetButtonText",
 			tooltipTitle = L["TITAN_AMMO_TOOLTIP"],
+            tooltipTextFunction = "TitanPanelAmmoButton_GetTooltipText",
 			icon = "Interface\\AddOns\\TitanClassicAmmo\\TitanClassicThrown",
 			iconWidth = 16,
 			controlVariables = {
@@ -302,4 +307,17 @@ function TitanPanelRightClickMenu_PrepareAmmoMenu()

 	TitanPanelRightClickMenu_AddSpacer();
 	TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], TITAN_AMMO_ID, TITAN_PANEL_MENU_FUNC_HIDE);
-end
\ No newline at end of file
+end
+
+function TitanPanelAmmoButton_GetTooltipText()
+	local txt = ""
+	local atype = {INVTYPE_RANGED = L["TITAN_AMMO_BOW"],
+		INVTYPE_RANGEDRIGHT = L["TITAN_AMMO_GUN"],
+		INVTYPE_THROWN = L["TITAN_AMMO_THROWN"],
+		}
+	txt = txt
+		.."Type: "..(atype[ammo_type] or "--").."\n"
+		.."Name: "..(ammo_name or "--")
+	return txt
+end
+
diff --git a/TitanClassicRegen/TitanClassicRegen.lua b/TitanClassicRegen/TitanClassicRegen.lua
index 7637636..a4b2de8 100644
--- a/TitanClassicRegen/TitanClassicRegen.lua
+++ b/TitanClassicRegen/TitanClassicRegen.lua
@@ -63,7 +63,6 @@ function TitanPanelRegenButton_OnLoad(self)
 		  },
           savedVariables = {
               ShowLabelText = 1,
-              ShowMPRegen = 1,
               ShowHPRegen = 1,
               ShowPercentage = false,
               ShowColoredText = false
@@ -82,11 +81,8 @@ end
 -- DESC : Parse events registered to addon and act on them
 -- **************************************************************************
 function TitanPanelRegenButton_OnEvent(self, event, a1, a2, ...)
-     if ( event == "PLAYER_ENTERING_WORLD") then
-          if (UnitPowerMax("player", 0) == 0) then
-               TitanSetVar(TITAN_REGEN_ID, "ShowMPRegen", 0);
-          end
-     end
+	if ( event == "PLAYER_ENTERING_WORLD") then
+	end

      if ( event == "PLAYER_REGEN_DISABLED") then
           TITAN_RegenMPDuringCombat = 0;
@@ -119,31 +115,32 @@ function TitanPanelRegenButton_OnEvent(self, event, a1, a2, ...)
           end
      end

-     if (TitanGetVar(TITAN_REGEN_ID,"ShowMPRegen") == 1) then
-          if ( event == "UNIT_POWER_UPDATE" and a1 == "player"  and a2 == "MANA") then
-               currMana = UnitPower("player");
-               runUpdate = 1;
-               if ( currMana  > TITAN_RegenCurrMana and TITAN_RegenCurrMana ~= 0 ) then
-                    TITAN_RegenMP = currMana-TITAN_RegenCurrMana;
+	local pval, ptype = UnitPowerType("player")
+	if (pval == 0) then -- Mana
+		if ( event == "UNIT_POWER_UPDATE" and a1 == "player" and a2 == "MANA") then
+			currMana = UnitPower("player");
+			runUpdate = 1;
+			if ( currMana  > TITAN_RegenCurrMana and TITAN_RegenCurrMana ~= 0 ) then
+				TITAN_RegenMP = currMana-TITAN_RegenCurrMana;

-                    if (TITAN_RegenMPCombatTrack == 1) then
-                         TITAN_RegenMPDuringCombat = TITAN_RegenMPDuringCombat + TITAN_RegenMP;
-                    end
+				if (TITAN_RegenMPCombatTrack == 1) then
+					TITAN_RegenMPDuringCombat = TITAN_RegenMPDuringCombat + TITAN_RegenMP;
+				end

-                    if (TITAN_RegenMP > TITAN_RegenMaxMPRate) then
-                         TITAN_RegenMaxMPRate = TITAN_RegenMP;
-                    end
-                    if (TITAN_RegenMP < TITAN_RegenMinMPRate or TITAN_RegenMinMPRate == 9999) then
-                         TITAN_RegenMinMPRate = TITAN_RegenMP;
-                    end
-               end
-               TITAN_RegenCurrMana = currMana;
-          end
-     end
-
-     if (runUpdate == 1) then
-         TitanPanelPluginHandle_OnUpdate(updateTable)
-     end
+				if (TITAN_RegenMP > TITAN_RegenMaxMPRate) then
+					TITAN_RegenMaxMPRate = TITAN_RegenMP;
+				end
+				if (TITAN_RegenMP < TITAN_RegenMinMPRate or TITAN_RegenMinMPRate == 9999) then
+					TITAN_RegenMinMPRate = TITAN_RegenMP;
+				end
+			end
+			TITAN_RegenCurrMana = currMana;
+		end
+	end
+
+	if (runUpdate == 1) then
+		TitanPanelPluginHandle_OnUpdate(updateTable)
+	end
 end

 -- **************************************************************************
@@ -152,54 +149,55 @@ end
 -- VARS : id = button ID
 -- **************************************************************************
 function TitanPanelRegenButton_GetButtonText(id)
-     local labelTextHP = "";
-     local valueTextHP = "";
-     local labelTextMP = "";
-     local valueTextMP = "";
-     local OutputStr = "";
-
-     if UnitHealth("player") == UnitHealthMax("player") then
-          TITAN_RegenHP = 0;
-     end
-     if UnitPower("player") == UnitPowerMax("player", 0) then
-          TITAN_RegenMP = 0;
-     end
+	local labelTextHP = "";
+	local valueTextHP = "";
+	local labelTextMP = "";
+	local valueTextMP = "";
+	local OutputStr = "";
+
+	if UnitHealth("player") == UnitHealthMax("player") then
+		TITAN_RegenHP = 0;
+	end
+	if UnitPower("player") == UnitPowerMax("player", 0) then
+		TITAN_RegenMP = 0;
+	end

-     -- safety in case both are off, then cant ever turn em on
-     if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil and TitanGetVar(TITAN_REGEN_ID,"ShowMPRegen") == nil) then
-          TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1);
-     end
-
-     if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == 1) then
-          labelTextHP = L["TITAN_REGEN_BUTTON_TEXT_HP"];
-          if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then
-               valueTextHP = format(TITAN_REGEN_HP_FORMAT_PERCENT, (TITAN_RegenHP/UnitHealthMax("player"))*100);
-          else
-               valueTextHP = format(TITAN_REGEN_HP_FORMAT, TITAN_RegenHP);
-          end
-          if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then
-               valueTextHP = TitanUtils_GetGreenText(valueTextHP);
-          else
-               valueTextHP = TitanUtils_GetHighlightText(valueTextHP);
-          end
-     end
+	-- safety in case both are off, then cant ever turn em on
+	if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil) then
+		TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1);
+	end
+
+	if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == 1) then
+		labelTextHP = L["TITAN_REGEN_BUTTON_TEXT_HP"];
+		if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then
+			valueTextHP = format(TITAN_REGEN_HP_FORMAT_PERCENT, (TITAN_RegenHP/UnitHealthMax("player"))*100);
+		else
+			valueTextHP = format(TITAN_REGEN_HP_FORMAT, TITAN_RegenHP);
+		end
+		if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then
+			valueTextHP = TitanUtils_GetGreenText(valueTextHP);
+		else
+			valueTextHP = TitanUtils_GetHighlightText(valueTextHP);
+		end
+	end

-     if (TitanGetVar(TITAN_REGEN_ID,"ShowMPRegen") == 1) then
-          labelTextMP = L["TITAN_REGEN_BUTTON_TEXT_MP"];
-          if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then
-               valueTextMP = format(TITAN_REGEN_MP_FORMAT_PERCENT, (TITAN_RegenMP/UnitPowerMax("player", 0))*100);
-          else
-               valueTextMP = format(TITAN_REGEN_MP_FORMAT, TITAN_RegenMP);
-          end
-          if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then
-               valueTextMP = TitanRegenTemp_GetColoredTextRGB(valueTextMP, 0.0, 0.0, 1.0);
-          else
-               valueTextMP = TitanUtils_GetHighlightText(valueTextMP);
-          end
-     end
+	local pval, ptype = UnitPowerType("player")
+	if (pval == 0) then -- Mana only
+		labelTextMP = L["TITAN_REGEN_BUTTON_TEXT_MP"];
+		if (TitanGetVar(TITAN_REGEN_ID,"ShowPercentage") == 1) then
+			valueTextMP = format(TITAN_REGEN_MP_FORMAT_PERCENT, (TITAN_RegenMP/UnitPowerMax("player", 0))*100);
+		else
+			valueTextMP = format(TITAN_REGEN_MP_FORMAT, TITAN_RegenMP);
+		end
+		if (TitanGetVar(TITAN_REGEN_ID, "ShowColoredText")) then
+			valueTextMP = TitanRegenTemp_GetColoredTextRGB(valueTextMP, 0.0, 0.0, 1.0);
+		else
+			valueTextMP = TitanUtils_GetHighlightText(valueTextMP);
+		end
+	end

-     -- supports turning off labels
-     return labelTextHP, valueTextHP, labelTextMP, valueTextMP;
+	-- supports turning off labels
+	return labelTextHP, valueTextHP, labelTextMP, valueTextMP;
 end

 -- **************************************************************************
@@ -207,33 +205,39 @@ end
 -- DESC : Display tooltip text
 -- **************************************************************************
 function TitanPanelRegenButton_GetTooltipText()
+	local minHP = TITAN_RegenMinHPRate;
+	local minMP = TITAN_RegenMinMPRate;

-     local minHP = TITAN_RegenMinHPRate;
-     local minMP = TITAN_RegenMinMPRate;
-
-     if minHP == 9999 then minHP = 0 end;
-     if minMP == 9999 then minMP = 0 end;
+	if minHP == 9999 then minHP = 0 end;
+	if minMP == 9999 then minMP = 0 end;

-     if (TitanGetVar(TITAN_REGEN_ID,"ShowMPRegen") == 1) then
-          local regenPercent;
-          regenPercent = (TITAN_RegenMPDuringCombat/UnitPowerMax("player", 0))*100;
-
-          return ""..
-               format(L["TITAN_REGEN_TOOLTIP1"], UnitHealth("player"),UnitHealthMax("player"),UnitHealthMax("player")-UnitHealth("player")).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP2"], UnitPower("player"),UnitPowerMax("player", 0),UnitPowerMax("player", 0)-UnitPower("player")).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP3"], TITAN_RegenMaxHPRate).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP4"], minHP).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP5"], TITAN_RegenMaxMPRate).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP6"], minMP).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP7"], TITAN_RegenMPDuringCombat, regenPercent).."\n"
-               ;
-     else
-          return ""..
-               format(L["TITAN_REGEN_TOOLTIP1"], UnitHealth("player"),UnitHealthMax("player"),UnitHealthMax("player")-UnitHealth("player")).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP3"], TITAN_RegenMaxHPRate).."\n"..
-               format(L["TITAN_REGEN_TOOLTIP4"], minHP).."\n"
-               ;
-     end
+	local txt = ""
+
+	txt = txt..
+		format(L["TITAN_REGEN_TOOLTIP1"], UnitHealth("player"),UnitHealthMax("player"),UnitHealthMax("player")-UnitHealth("player")).."\n"..
+		format(L["TITAN_REGEN_TOOLTIP3"], TITAN_RegenMaxHPRate).."\n"..
+		format(L["TITAN_REGEN_TOOLTIP4"], minHP).."\n"
+
+	local pval, ptype = UnitPowerType("player")
+	if (pval == 0) then
+		local regenPercent = 0
+		regenPercent = (TITAN_RegenMPDuringCombat/UnitPowerMax("player", 0))*100;
+
+		txt = txt.."\n"..
+			format(L["TITAN_REGEN_TOOLTIP2"], UnitPower("player"),UnitPowerMax("player", 0),UnitPowerMax("player", 0)-UnitPower("player")).."\n"..
+			format(L["TITAN_REGEN_TOOLTIP5"], TITAN_RegenMaxMPRate).."\n"..
+			format(L["TITAN_REGEN_TOOLTIP6"], minMP).."\n"..
+			format(L["TITAN_REGEN_TOOLTIP7"], TITAN_RegenMPDuringCombat, regenPercent).."\n"
+	else
+		-- L["TITAN_REGEN_TOOLTIP2"] = "Mana: \t"..GREEN_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." / " ..HIGHLIGHT_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." ("..RED_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE..")";
+		POWER = GREEN_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE.." / " ..HIGHLIGHT_FONT_COLOR_CODE.."%d"..FONT_COLOR_CODE_CLOSE
+		txt = txt.."\n"..
+			ptype.." \t"..
+			format(POWER, UnitPower("player"),UnitPowerMax("player", pval)).."\n"
+			-- Energy : The formula is (energyRegen)*(1+hastePercent)
+	end
+
+	return txt
 end

 -- **************************************************************************
@@ -241,39 +245,33 @@ end
 -- DESC : Display rightclick menu options
 -- **************************************************************************
 function TitanPanelRightClickMenu_PrepareRegenMenu()
-     local id = TITAN_REGEN_ID;
-     local info;
+	local id = TITAN_REGEN_ID;
+	local info;

-     TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText);
-
-     info = {};
-     info.text = L["TITAN_REGEN_MENU_SHOW2"];
-     info.func = TitanRegen_ShowHPRegen;
-     info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen");
-     L_UIDropDownMenu_AddButton(info);
-
-     info = {};
-     info.text = L["TITAN_REGEN_MENU_SHOW3"];
-     info.func = TitanRegen_ShowMPRegen;
-     info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowMPRegen");
-     L_UIDropDownMenu_AddButton(info);
-
-     info = {};
-     info.text = L["TITAN_REGEN_MENU_SHOW4"];
-     info.func = TitanRegen_ShowPercentage;
-     info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowPercentage");
-     L_UIDropDownMenu_AddButton(info);
-
-     TitanPanelRightClickMenu_AddSpacer();
-
-     info = {};
-     info.text = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"];
-     info.func = TitanRegen_ShowColoredText;
-     info.checked = TitanGetVar(TITAN_REGEN_ID, "ShowColoredText");
-     L_UIDropDownMenu_AddButton(info);
-
-     TitanPanelRightClickMenu_AddToggleLabelText("TitanRegen");
-     TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], id, TITAN_PANEL_MENU_FUNC_HIDE);
+	TitanPanelRightClickMenu_AddTitle(TitanPlugins[id].menuText);
+
+	info = {};
+	info.text = L["TITAN_REGEN_MENU_SHOW2"];
+	info.func = TitanRegen_ShowHPRegen;
+	info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen");
+	L_UIDropDownMenu_AddButton(info);
+
+	info = {};
+	info.text = L["TITAN_REGEN_MENU_SHOW4"];
+	info.func = TitanRegen_ShowPercentage;
+	info.checked = TitanGetVar(TITAN_REGEN_ID,"ShowPercentage");
+	L_UIDropDownMenu_AddButton(info);
+
+	TitanPanelRightClickMenu_AddSpacer();
+
+	info = {};
+	info.text = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"];
+	info.func = TitanRegen_ShowColoredText;
+	info.checked = TitanGetVar(TITAN_REGEN_ID, "ShowColoredText");
+	L_UIDropDownMenu_AddButton(info);
+
+	TitanPanelRightClickMenu_AddToggleLabelText("TitanRegen");
+	TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], id, TITAN_PANEL_MENU_FUNC_HIDE);
 end

 -- **************************************************************************
@@ -282,7 +280,7 @@ end
 -- **************************************************************************
 function TitanRegen_UpdateSettings()
      -- safety in case both are off, then cant ever turn em on
-     if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil and TitanGetVar(TITAN_REGEN_ID,"ShowMPRegen") == nil) then
+     if (TitanGetVar(TITAN_REGEN_ID,"ShowHPRegen") == nil) then
           TitanSetVar(TITAN_REGEN_ID,"ShowHPRegen",1);
      end
      TitanPanelButton_UpdateButton(TITAN_REGEN_ID);
@@ -298,15 +296,6 @@ function TitanRegen_ShowHPRegen()
 end

 -- **************************************************************************
--- NAME : TitanRegen_ShowMPRegen()
--- DESC : Show MP regeneration option on button
--- **************************************************************************
-function TitanRegen_ShowMPRegen()
-     TitanToggleVar(TITAN_REGEN_ID, "ShowMPRegen");
-     TitanRegen_UpdateSettings();
-end
-
--- **************************************************************************
 -- NAME : TitanRegen_ShowPercentage()
 -- DESC : Show values as percentage option on button
 -- **************************************************************************