From 9a9c7716e601170f5bedf075e3651fc8da2e4769 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 12 Feb 2012 21:58:44 +0000
Subject: [PATCH] fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@4846 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/PlayerDisplay.lua     |  9 +++++++--
 game/modules/tome/class/uiset/Minimalist.lua  | 20 +++++++++++--------
 .../modules/tome/data/timed_effects/other.lua |  5 ++---
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/game/modules/tome/class/PlayerDisplay.lua b/game/modules/tome/class/PlayerDisplay.lua
index 22f44923fe..6c25de1493 100644
--- a/game/modules/tome/class/PlayerDisplay.lua
+++ b/game/modules/tome/class/PlayerDisplay.lua
@@ -376,8 +376,13 @@ function _M:display()
 	local quiver = player:getInven("QUIVER")
 	local ammo = quiver and quiver[1]
 	if ammo and ammo.combat then
-		local shots_left = ammo.combat.shots_left or 0
-		self:mouseTooltip(self.TOOLTIP_COMBAT_AMMO, self:makeTexture(("#ANTIQUE_WHITE#Ammo:       #ffffff#%d"):format(shots_left), 0, h, 255, 255, 255)) h = h + self.font_h
+		local amt, max = 0, 0
+		if ammo.type == "alchemist-gem" then
+			amt = ammo:getNumber()
+		else
+			amt, max = ammo.combat.shots_left, ammo.combat.capacity
+		end
+		self:mouseTooltip(self.TOOLTIP_COMBAT_AMMO, self:makeTexture(("#ANTIQUE_WHITE#Ammo:       #ffffff#%d"):format(amt), 0, h, 255, 255, 255)) h = h + self.font_h
 	end
 
 	if savefile_pipe.saving then
diff --git a/game/modules/tome/class/uiset/Minimalist.lua b/game/modules/tome/class/uiset/Minimalist.lua
index fd749131df..422787ac38 100644
--- a/game/modules/tome/class/uiset/Minimalist.lua
+++ b/game/modules/tome/class/uiset/Minimalist.lua
@@ -834,24 +834,28 @@ function _M:displayResources(scale, bx, by, a)
 		local quiver = player:getInven("QUIVER")
 		local ammo = quiver and quiver[1]
 		if ammo then
-			local amt = ammo.combat.shots_left
+			local amt, max = 0, 0
 			local shad, bg
-			if ammo.type == "alchemist-gem" then shad, bg = _M["ammo_shadow_alchemist-gem"], _M["ammo_alchemist-gem"]
-			else shad, bg = _M["ammo_shadow_"..ammo.subtype] or ammo_shadow_default, _M["ammo_"..ammo.subtype] or ammo_default
+			if ammo.type == "alchemist-gem" then
+				shad, bg = _M["ammo_shadow_alchemist-gem"], _M["ammo_alchemist-gem"]
+				amt = ammo:getNumber()
+			else
+				shad, bg = _M["ammo_shadow_"..ammo.subtype] or ammo_shadow_default, _M["ammo_"..ammo.subtype] or ammo_default
+				amt, max = ammo.combat.shots_left, ammo.combat.capacity
 			end
 
 			shad[1]:toScreenFull(x, y, shad[6], shad[7], shad[2], shad[3], 1, 1, 1, a)
 			bg[1]:toScreenFull(x, y, bg[6], bg[7], bg[2], bg[3], 1, 1, 1, a)
 
-			if not self.res.ammo or self.res.ammo.vc ~= amt then
+			if not self.res.ammo or self.res.ammo.vc ~= amt or self.res.ammo.vm ~= max then
 				self.res.ammo = {
-					vc = amt,
-					cur = {core.display.drawStringBlendedNewSurface(font_sha, ("%d"):format(amt), 255, 255, 255):glTexture()},
+					vc = amt, vm = max,
+					cur = {core.display.drawStringBlendedNewSurface(font_sha, (max > 0) and ("%d/%d"):format(amt,max) or ("%d"):format(amt), 255, 255, 255):glTexture()},
 				}
 			end
 			local dt = self.res.ammo.cur
-			dt[1]:toScreenFull(2+x+44, 2+y+3 + (bg[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 0, 0, 0, 0.7 * a)
-			dt[1]:toScreenFull(x+44, y+3 + (bg[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 1, 1, 1, a)
+			dt[1]:toScreenFull(2+x+40, 2+y+3 + (bg[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 0, 0, 0, 0.7 * a)
+			dt[1]:toScreenFull(x+40, y+3 + (bg[7]-dt[7])/2, dt[6], dt[7], dt[2], dt[3], 1, 1, 1, a)
 
 			x, y = self:resourceOrientStep(orient, bx, by, scale, x, y, fshat[6], fshat[7])
 		end
diff --git a/game/modules/tome/data/timed_effects/other.lua b/game/modules/tome/data/timed_effects/other.lua
index 72c9bb79ca..5765a06ae0 100644
--- a/game/modules/tome/data/timed_effects/other.lua
+++ b/game/modules/tome/data/timed_effects/other.lua
@@ -1300,7 +1300,6 @@ newEffect{
 	end,
 }
 
-
 newEffect{
 	name = "RELOADING", image = "talents/reload.png",
 	desc = "Reloading",
@@ -1317,12 +1316,12 @@ newEffect{
 	end,
 	on_timeout = function(self, eff)
 		for i = 1, eff.shots_per_turn do
-			eff.ammo.combat.shots_left = eff.ammo.combat.shots_left + 1
+			eff.ammo.combat.shots_left = util.bound(eff.ammo.combat.shots_left + 1, 0, eff.ammo.combat.capacity)
 			if eff.ammo.combat.shots_left == eff.ammo.combat.capacity then
 				game.logPlayer(self, "Your %s is full.", eff.ammo.name)
 				self:breakReloading()
 				break
-			end	
+			end
 		end
 	end,
 }
-- 
GitLab