Jump to content
×
×
  • Create New...
  • 0

How can i align text?


iShadoW

Question

Version of Files XXX

Hi i have a problem with the short textes, the appendtextline align long textes and all below them, but if the first bonus or the title is shorter it doesnt align

 

GIF

 

here is the part of code

		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()

			(textWidth, textHeight)=textLine.GetTextSize()

			textWidth += 55
			textHeight += 5

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

			self.childrenList.append(textLine)
			
			if centerAlign:
				textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
				textLine.SetHorizontalAlignCenter()
			else:
				textLine.SetPosition(10, self.toolTipHeight)

			
			self.toolTipHeight += textHeight
			self.ResizeToolTip()		

			return textLine

 

	def __AppendAttributeInformation(self, attrSlot, itemAbsChance = 0):
		if 0 != attrSlot:
			for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
				type = attrSlot[i][0]
				value = attrSlot[i][1]
				if 0 == value:
					continue

				affectString = self.__GetAffectString(type, value)

				if app.ENABLE_SASH_SYSTEM:
					if item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_SASH and itemAbsChance:
						value = self.CalcSashValue(value, itemAbsChance)
						affectString = self.__GetAffectString(type, value)
				
				if affectString:
					affectColor = self.__GetAttributeColor(i, value)
					self.AppendTextLine(affectString, affectColor)

 

Thanks, Sincerly,
iShadoW

 

Edited by iShadoW
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 1

try calling this function:

self.AlignHorizonalCenter()

in the body of the if statement.

It should look like this:

if self.toolTipWidth < textWidth:
	self.toolTipWidth = textWidth
	self.AlignHorizonalCenter()
                       
	

Let me know if it works

Edited by valizrt
  • Love 1
Link to comment
Share on other sites

  • 0

Try replacing your AppendTextLine function with this:

	    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
	

 

Link to comment
Share on other sites

  • 0
6 hours ago, Finnael said:

Try replacing your AppendTextLine function with this:

 

	    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
	

 

This function is ok for alignment, but the width of the tooltip will be generated according to the 'Title' text length and if the title text is too short, some longer bonus texts will get out of the tooltip. I tried to set the tooltip width using the longest text but no result so far. Any ideas?

Link to comment
Share on other sites

  • 0
7 hours ago, Finnael said:

Try replacing your AppendTextLine function with this:

 

	    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
	

got it , but this is the classic function, and the guy above is right, the longer bonuses will exit tooltip, i tried something with reversed(xrange) but nothing works, anyway is a good fix for anyway if we can get it , it is all about small things ;)

 

49 minutes ago, valizrt said:

This function is ok for alignment, but the width of the tooltip will be generated according to the 'Title' text length and if the title text is too short, some longer bonus texts will get out of the tooltip. I tried to set the tooltip width using the longest text but no result so far. Any ideas?

i'm still trying to resolve :D

Link to comment
Share on other sites

  • 0
9 hours ago, valizrt said:

try calling this function:

self.AlignHorizonalCenter()

in the body of the if statement.

It should look like this:

if self.toolTipWidth < textWidth:
	self.toolTipWidth = textWidth
	self.AlignHorizonalCenter()
                       
	

Let me know if it works

works so god damn good, ty so much for your time ❤️ 

Link to comment
Share on other sites

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
  • Recently Browsing   0 members

    • No registered users viewing this page.


  • Activity

    1. 36

      Destroy Item System

    2. 1

      Brillances

    3. 0

      Fusion.org is Looking for Staff Members

    4. 1

      Brillances

    5. 3

      ELONIA2 | PVM-MEDIUM | 11 LANGUAGES | INTERNATIONAL | A NEW STORY

    6. 4

      Spider Queen not spawining in spider dungeon v1

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.