Jump to content
  • We need you!

    You must register to discover all the features of our community!

  • 0

ui.py


TMP4

Question

2 answers to this question

Recommended Posts

  • 0
Posted (edited)

Ah it doesn't contains the gauge's tooltip what i looking for.

 

Anyway can you or anyone look into this code?

class Gauge(Window):

	SLOT_WIDTH = 16
	SLOT_HEIGHT = 7

	GAUGE_TEMPORARY_PLACE = 12
	GAUGE_WIDTH = 16

	def __init__(self):
		Window.__init__(self)
		self.width = 0
		
		#HIDRA
		self.showtooltipevent = None
		self.showtooltiparg = None
		self.hidetooltipevent = None
		self.hidetooltiparg = None
		self.ToolTipText = None
		#HIDRA
		
	def __del__(self):
		Window.__del__(self)
		
		#HIDRA
		self.showtooltipevent = None
		self.showtooltiparg = None
		self.hidetooltipevent = None
		self.hidetooltiparg = None
		#HIDRA

	#HIDRA START
	def SetShowToolTipEvent(self, func, *args):
		self.showtooltipevent = func
		self.showtooltiparg = args

	def SetHideToolTipEvent(self, func, *args):
		self.hidetooltipevent = func
		self.hidetooltiparg = args

	def ShowToolTip(self):
		if self.ToolTipText:
			self.ToolTipText.Show()

	def HideToolTip(self):
		if self.ToolTipText:
			self.ToolTipText.Hide()

	def SetToolTipText(self, text, x=0, y = -19):
		self.SetFormToolTipText("TEXT", text, x, y)

	def SetFormToolTipText(self, type, text, x, y):
		if not self.ToolTipText: 
			toolTip=createToolTipWindowDict[type]()
			toolTip.SetParent(self)
			toolTip.SetSize(0, 0)
			toolTip.SetHorizontalAlignCenter()
			toolTip.SetOutline()
			toolTip.Hide()
			toolTip.SetPosition(x + self.GetWidth()/2, y)
			self.ToolTipText=toolTip

		self.ToolTipText.SetText(text)
	#HIDRA END

	def MakeGauge(self, width, color):

		self.width = max(48, width)

		imgSlotLeft = ImageBox()
		imgSlotLeft.SetParent(self)
		imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
		imgSlotLeft.Show()

		imgSlotRight = ImageBox()
		imgSlotRight.SetParent(self)
		imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
		imgSlotRight.Show()
		imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)

		imgSlotCenter = ExpandedImageBox()
		imgSlotCenter.SetParent(self)
		imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
		imgSlotCenter.Show()
		imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
		imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)

		imgGauge = ExpandedImageBox()
		imgGauge.SetParent(self)
		imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_" + color + ".tga")
		imgGauge.Show()
		imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
		imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)

		imgSlotLeft.AddFlag("attach")
		imgSlotCenter.AddFlag("attach")
		imgSlotRight.AddFlag("attach")

		self.imgLeft = imgSlotLeft
		self.imgCenter = imgSlotCenter
		self.imgRight = imgSlotRight
		self.imgGauge = imgGauge

		self.SetSize(width, self.SLOT_HEIGHT)

	def SetPercentage(self, curValue, maxValue):

		# PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
		if maxValue > 0.0:
			percentage = min(1.0, float(curValue)/float(maxValue))
		else:
			percentage = 0.0
		# END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR

		gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
		self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)

uiminimap.py __LoadWindow

                self.MastHp.OnMouseOverIn = ui.__mem_func__(self.MastHp.ShowToolTip)
                self.MastHp.OnMouseOverOut = ui.__mem_func__(self.MastHp.HideToolTip)
                self.MastHp.SetShowToolTipEvent(self.MastHp.OnMouseOverIn)
                self.MastHp.SetHideToolTipEvent(self.MastHp.OnMouseOverOut)

 

uiminimap.py end: 

        def SetMastHP(self, hp):
            self.MastHp.SetPercentage(hp, 500000000)
            self.MastHp.SetToolTipText("HP:  %d /500000000" % hp)

        def SetMastWindow(self, i):
            if i:
                self.MastWindow.Show()
            else:
                self.MastWindow.Hide()

uiscript:

		{
			"name" : "MastWindow",
			"type" : "thinboard",

			"x" : 35-17,
			"y" : 160+22,

			"width" : 105,
			"height" : 37,
			"children" :
			(
				{
					"name" : "MastText",
					"type" : "text",

					"text_horizontal_align" : "center",

					"x" : 35,
					"y" : 8,

					"text" : uiScriptLocale.DEFANCE_WAWE_MAST_TEXT,
				},
				{
					"name" : "MastHp",
					"type" : "gauge",

					"x" : 10,
					"y" : 23,

					"width" : 85,
					"color" : "red",
					
					"tooltip_text" : uiScriptLocale.DEFANCE_WAWE_GAUGE_TOOLTIP,
				},
			),
		},

The guage itself works and updating okey (self.MastHp.SetPercentage) but the tooltip does not show.

Me and the python is very far away so maybe it's obvious why it's bad but i don't have a single clue. 

Edited by TMP4 (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Current Donation Goals

  • Activity

    1. 11

      Mysql56 to Mysql8

    2. 0

      Does anyone have Kami-Sama's Contact?

    3. 1

      [Trailer][1/3]NerviL2 The return of the Legend

    4. 0

      Won " price" change

    5. 10

      Inferna - The new "metin3"?

    6. 6

      We need you!

    7. 2

      Highlight system bug

  • Recently Browsing

    No registered users viewing this page.

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.