diff --git a/TitanAmmo/TitanClassicAmmo.lua b/TitanAmmo/TitanClassicAmmo.lua
index 5c1a98b..39447e5 100644
--- a/TitanAmmo/TitanClassicAmmo.lua
+++ b/TitanAmmo/TitanClassicAmmo.lua
@@ -28,11 +28,6 @@ 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 NO_RANGED = "Nothing_Equipped"
-
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 }, -- 100,150,400
@@ -48,23 +43,19 @@ local TITAN_AMMO_THRESHOLD_TABLE = { -- Use ammo stack and threshold limits abov
},
};
-local PLACE = { -- for debug output
- ["INVTYPE_RANGED"] = "Bow",
- ["INVTYPE_RANGEDRIGHT"] = "Gun",
- ["INVTYPE_THROWN"] = "Throw",
- }
-
-- ******************************** Variables *******************************
local ammoSlotID = GetInventorySlotInfo("AmmoSlot")
local rangedSlotID = GetInventorySlotInfo("RangedSlot")
-- Info to show on the plugin
local display = {
- ammo_count = 0,
- ammo_type = "",
- ammo_name = "", -- L["TITAN_AMMO_BUTTON_NOAMMO"]
- weapon = "",
- weapon_type = "",
+ ammo_count = 0,
+ ammo_type = "",
+ ammo_name = "", -- L["TITAN_AMMO_BUTTON_NOAMMO"]
+ weapon = "",
+ weapon_type = "",
+ mismatch = false,
+ mismatch_text = "",
}
local L = LibStub("AceLocale-3.0"):GetLocale("TitanClassic", true)
@@ -92,10 +83,12 @@ end
local function ClrAmmoInfo()
display.ammo_count = 0;
- display.ammo_type = NO_RANGED
+ display.ammo_type = L["TITAN_AMMO_BUTTON_NOAMMO"]
display.ammo_name = ""
display.weapon = ""
display.weapon_type = ""
+ display.mismatch = false
+ display.mismatch_text = ""
end
local function GetItemLink(rangedSlotID)
@@ -116,71 +109,138 @@ local function IsAmmoClass()
return res
end
-local function IsThrown(loc)
- local res = false
- if loc == "INVTYPE_THROWN" then
- res = true
- end
- return res
-end
-
-local function IsAmmo(loc)
- local res = false
- if loc == "INVTYPE_RANGED" or loc == "INVTYPE_RANGEDRIGHT" then
- res = true
- end
- return res
-end
-
local function GetAmmoCount()
- local ammo = "";
- local wpn = "--";
- local wpnt = "--";
+ local ammo = ""
+ local mis = false
+ local mist = ""
+ local ammo_name = ""
+ local ammo_count = 0
+ local label = ""
+ local text = ""
+ local tool_tip = ""
+
+ ClrAmmoInfo()
+ -- weapon info
+ local itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount,
+ itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent
+ -- ammo info
+ local ammoName, ammoLink, ammoQuality, ammoLevel, ammoMinLevel, ammoType, ammoSubType, ammoStackCount,
+ ammoEquipLoc, ammoTexture, _, ammoID, subammoID
local weap = GetInventoryItemID("player", rangedSlotID)
if weap == nil then
-- nothing in slot
- ammo = NO_RANGED
+ ammo = L["TITAN_AMMO_BUTTON_NOAMMO"]
else
- local itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount,
+ -- get weapon info (thrown) or ammo info (guns & bows)
+ itemName, itemLink, itemQuality, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount,
itemEquipLoc, itemTexture, sellPrice, classID, subclassID, bindType, expacID, setID, isCraftingReagent
= GetItemInfo(weap)
- wpn = itemName
- wpnt = itemSubType
ammo = itemEquipLoc
-- set ammo name and count
- if IsThrown(ammo) then -- throwing knives, etc
- display.ammo_name = itemName or UNKNOWN
- if display.ammo_name == UNKNOWN then
- display.ammo_count = 0
+ if (subclassID == 16) -- Thrown
+ then
+ -- treat thrown as ther ammo with 0 count
+ ammo_name = itemName or ""
+ ammo_count = 0
+
+ ammoID = classID
+ subammoID = subclassID
+
+ label = L["TITAN_AMMO_BUTTON_LABEL_THROWN"]
+ text = TitanUtils_GetGoldText("*")
+
+ tool_tip = itemName
+ -- no mismatch
+ elseif (subclassID == 3) -- Gun
+ or (subclassID == 2) -- Bow
+ or (subclassID == 18) -- Crossbow
+ then
+ ammoName, ammoLink, ammoQuality, ammoLevel, ammoMinLevel, ammoType, ammoSubType, ammoStackCount,
+ ammoEquipLoc, ammoTexture, _, ammoID, subammoID, _, _, _, _
+ = GetItemInfo(GetInventoryItemID("player", ammoSlotID))
+-- ammo_name = select(1, GetItemInfo(GetInventoryItemID("player", ammoSlotID))) or UNKNOWN
+ ammo_name = ammoName or ""
+ if ammoName == nil then
+ ammo_count = 0
else
- display.ammo_count = GetInventoryItemCount("player", rangedSlotID) or display.ammo_count
+ ammo_count = GetInventoryItemCount("player", ammoSlotID) or display.ammo_count
+ end
+ text = format(L["TITAN_AMMO_FORMAT"], ammo_count);
+ if TitanGetVar(TITAN_AMMO_ID, "ShowAmmoName") and ammo_name ~= "" then
+ text = text.."|cffffff9a".." ("..ammo_name..")".."|r"
end
- elseif IsAmmo(ammo) then
- display.ammo_name = select(1, GetItemInfo(GetInventoryItemID("player", ammoSlotID))) or UNKNOWN
- if display.ammo_name == UNKNOWN then
- display.ammo_count = 0
+ label = L["TITAN_AMMO_BUTTON_LABEL_AMMO"]
+ tool_tip = ""
+ ..tostring(itemName)
+ .."\n"..tostring(ammo_name)..""
+
+
+ -- check for mismatch
+ if (subclassID == 3) -- Bullet
+ and (subammoID == 2) -- Arrow
+ then
+ mis = true
+ mist = ""
+ ..tostring(itemName)
+ .." <> "
+ ..tostring(ammoName)
+ mist = TitanUtils_GetRedText(mist)
+ elseif ((subclassID == 2) -- Bow
+ or (subclassID == 18)) -- Crossbow
+ and (subammoID == 3) -- Bullets
+ then
+ mis = true
+ mist = ""
+ ..tostring(itemName)
+ .." <> "
+ ..tostring(ammoName)
+ mist = TitanUtils_GetRedText(mist)
else
- display.ammo_count = GetInventoryItemCount("player", ammoSlotID) or display.ammo_count
end
- else -- bullets or arrows
- display.ammo_name = UNKNOWN
- display.ammo_count = 0
+ else
+ ammo_name = UNKNOWN
+ ammo_count = 0
+
+ -- no mismatch
end
+--[[
+local msg =
+ "GII-ammo"
+ .." ("..tostring(itemType)..""
+ .." "..tostring(classID)..""
+ .." "..tostring(subclassID) ..")"
+ .." ? ("..tostring(ammoID)..""
+ .." "..tostring(subammoID)..")"
+ .." "..tostring(mis)..""
+debug_msg(msg)
+local msg =
+ "GII-ammo > "
+ .." '"..tostring(label).."'"
+ .." '"..tostring(text).."'"
+debug_msg(msg)
+--]]
end
-
+
-- Set variables
- display.weapon = wpn
- display.weapon_type = wpnt
+ display.label = label
+ display.text = text
+ display.tool_tip = tool_tip
+ display.weapon = itemName
+ display.weapon_type = itemSubType
+ display.ammo_name = ammo_name
+ display.ammo_count = ammo_count
display.ammo_type = ammo
+ display.ammo_type_id = subclassID
+ display.mismatch = mis
+ display.mismatch_text = mist
if debug_flow then
local msg =
"Count"
- .." "..tostring(PLACE[ammo])..""
- .." '"..tostring(wpnt).."'"
- .." '"..tostring(wpn).."'"
+ .." '"..tostring(itemSubType).."'"
+ .." '"..tostring(itemName).."'"
debug_msg(msg)
else
-- not requested
@@ -259,27 +319,12 @@ function TitanPanelAmmoButton_GetButtonText(id)
local labelText, ammoText, ammoRichText, color;
- if (IsThrown(display.ammo_type)) then
- labelText = L["TITAN_AMMO_BUTTON_LABEL_THROWN"];
- ammoText = format(L["TITAN_AMMO_FORMAT"], display.ammo_count);
- labelText = display.weapon_type.." : "
- if TitanGetVar(TITAN_AMMO_ID, "ShowAmmoName") and display.ammo_name ~= "" then
- ammoText = ammoText.."|cffffff9a".." ("..display.ammo_name..")".."|r"
- end
- elseif IsAmmo(display.ammo_type) then
- labelText = L["TITAN_AMMO_BUTTON_LABEL_AMMO"];
- labelText = display.weapon_type.." : "
- ammoText = format(L["TITAN_AMMO_FORMAT"], display.ammo_count);
- if TitanGetVar(TITAN_AMMO_ID, "ShowAmmoName") and display.ammo_name ~= "" then
- ammoText = ammoText.."|cffffff9a".." ("..display.ammo_name..")".."|r"
- end
- else
- ClrAmmoInfo()
- ammoText = display.ammo_name
- labelText = display.weapon_type..""
- end
+ labelText = display.label
+ ammoText = display.text
- if (TitanGetVar(TITAN_AMMO_ID, "ShowColoredText")) then
+ if display.mismatch then
+ ammoRichText = tostring(display.mismatch_text)
+ elseif (TitanGetVar(TITAN_AMMO_ID, "ShowColoredText")) then
color = TitanUtils_GetThresholdColor(TITAN_AMMO_THRESHOLD_TABLE[display.ammo_type], display.ammo_count);
ammoRichText = TitanUtils_GetColoredText(ammoText, color);
else
@@ -290,7 +335,6 @@ function TitanPanelAmmoButton_GetButtonText(id)
local msg =
"Btn_Text"
.." '"..tostring(display.weapon_type).."'"
- .." '"..tostring(PLACE[display.ammo_type]).."'"
.." '"..tostring(ammoRichText).."'"
debug_msg(msg)
else
@@ -312,6 +356,7 @@ function TitanPanelRightClickMenu_PrepareAmmoMenu()
local info = {};
info.text = L["TITAN_AMMO_BULLET_NAME"];
info.func = function() TitanPanelRightClickMenu_ToggleVar({TITAN_AMMO_ID, "ShowAmmoName"})
+ GetAmmoCount()
TitanPanelButton_UpdateButton(TITAN_AMMO_ID);
end
info.checked = TitanUtils_Ternary(TitanGetVar(TITAN_AMMO_ID, "ShowAmmoName"), 1, nil);
@@ -329,14 +374,13 @@ function TitanPanelRightClickMenu_PrepareAmmoMenu()
end
function TitanPanelAmmoButton_GetTooltipText()
- local txt = ""
- if IsThrown(display.ammo_type) then
+ local txt = display.tool_tip
+ if display.mismatch then
txt = txt
- ..tostring(display.weapon)..""
+ .."\n\n"
+ ..tostring(display.mismatch_text)..""
else
- txt = txt
- ..tostring(display.weapon).."\n"
- ..tostring(display.ammo_name)..""
+ -- weapon and projectile match
end
return txt
end