Jump to content

[uitooltip]item value Display cannot be centered!


Recommended Posts

Hello, everyone.

I turned on the function of G M to view the item code, which is very convenient to test. You know,

Just to show that there's a little bit of a problem, I just added two lines of code in UI old tip,

Some displays are normal, such as weapons, pets, potions, and skill books

But other cannot be centered, where should I adjust excuse me?

Best wishes, thank you

		if chr.IsGameMaster(player.GetMainCharacterIndex()):
			self.AppendTextLine("[Vnum: %d]" % itemVnum, ToolTip.SPECIAL_POSITIVE_COLOR2)

 

代码显示错误.png

Link to comment
Share on other sites

  • Bronze

AlignHorizonalCenter centers all associated objects (from self.childrenList).
In case of centering long size TextLines it's better to use AutoAppendTextLine (which tunes the thinboard to the line width).
Consider merging those functions from newer uitooltip (I assume you are currently working on old ui):
 

AlignHorizonalCenter
AutoAppendTextLine
AppendTextLine

 

Link to comment
Share on other sites

4 hours ago, Sherer said:

AlignHorizonalCenter centers all associated objects (from self.childrenList).
In case of centering long size TextLines it's better to use AutoAppendTextLine (which tunes the thinboard to the line width).
Consider merging those functions from newer uitooltip (I assume you are currently working on old ui):
 


	def AlignHorizonalCenter(self):
		for child in self.childrenList:
			(x, y)=child.GetLocalPosition()
			child.SetPosition(self.toolTipWidth/2, y)

		self.ResizeToolTip()

	def AutoAppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):
		textLine = ui.TextLine()
		textLine.SetParent(self)
		textLine.SetFontName(self.defFontName)
		textLine.SetPackedFontColor(color)
		textLine.SetText(text)
		textLine.SetOutline()
		textLine.SetFeather(False)
		textLine.Show()

		if centerAlign:
			textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
			textLine.SetHorizontalAlignCenter()

		else:
			textLine.SetPosition(10, self.toolTipHeight)

		self.childrenList.append(textLine)

		(textWidth, textHeight)=textLine.GetTextSize()

		textWidth += 40
		textHeight += 5

		if self.toolTipWidth < textWidth:
			self.toolTipWidth = textWidth

		self.toolTipHeight += textHeight

		return textLine

	def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):
		textLine = ui.TextLine()
		textLine.SetParent(self)
		textLine.SetFontName(self.defFontName)
		textLine.SetPackedFontColor(color)
		textLine.SetText(text)
		textLine.SetOutline()
		textLine.SetFeather(False)
		textLine.Show()

		if centerAlign:
			textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
			textLine.SetHorizontalAlignCenter()

		else:
			textLine.SetPosition(10, self.toolTipHeight)

		self.childrenList.append(textLine)

		self.toolTipHeight += self.TEXT_LINE_HEIGHT
		self.ResizeToolTip()

		return textLine

 

		if chr.IsGameMaster(player.GetMainCharacterIndex()):
			self.AutoAppendTextLine("[vnum:%d]" % itemVnum, ToolTip.SPECIAL_POSITIVE_COLOR2)

@Sherer,thank you !

 

 

I try,but can't center

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • 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.