library TextTag
	import Players

	public struct TextTag
		private static texttag array minimapLabels
		private static integer labelIndex = -1

		static method minimapLabel takes string s, real x, real y returns texttag
			texttag tt = CreateTextTag()
			SetTextTagPermanent(tt, true)
			SetTextTagPos(tt, x - 10. * StringLength(s), y, 0.)
			SetTextTagText(tt, s, 12. * .00225)
			SetTextTagVisibility(tt, true)

			labelIndex++
			minimapLabels[labelIndex] = tt

			return tt
		end

		static method resetMinimapLabels takes nothing returns nothing
			integer index = 0
			loop
				exitwhen index > labelIndex
				DestroyTextTag(minimapLabels[index])
				index++
			end
			labelIndex = -1
		end

		static method bounty takes real x, real y, integer val, player whom returns nothing
			texttag t = CreateTextTag()
			SetTextTagColor(t, 255, R2I(255 * 12 / 15), 0, 255)
			SetTextTagLifespan(t, 2.)
			SetTextTagFadepoint(t, 1.)
			SetTextTagPermanent(t, false)
			SetTextTagPos(t, x, y, 25.)
			SetTextTagText(t, "+" + I2S(val), 12.*.0023)
			SetTextTagVelocity(t, 100.*Cos(PI / 2.)*.071/128., 100.*Sin(PI / 2.)*.071/128.)
			SetTextTagVisibility(t, false)

			if Players.locl == whom then
				SetTextTagVisibility(t, true)
			end
		end

		static method regeneration takes real x, real y, player whom returns nothing
			texttag t = CreateTextTag()
			SetTextTagColor(t, 33, 120, 68, R2I(255 * 3 / 4))
			SetTextTagLifespan(t, 2.)
			SetTextTagFadepoint(t, 1.)
			SetTextTagPermanent(t, false)
			SetTextTagPos(t, x, y, 25.)
			SetTextTagText(t, "+1", 10.*.0023)
			SetTextTagVelocity(t, 50.*Cos(PI / 2.)*.071/128., 50.*Sin(PI / 2.)*.071/128.)
			SetTextTagVisibility(t, false)

			if Players.locl == whom then
				SetTextTagVisibility(t, true)
			end
		end
	end
endlibrary
