iShadoW 3 Posted August 13, 2020 Share Posted August 13, 2020 (edited) 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 September 4, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Finnael 478 Posted August 14, 2020 Share Posted August 14, 2020 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 More sharing options...
valizrt 1 Posted August 14, 2020 Share Posted August 14, 2020 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 More sharing options...
iShadoW 3 Posted August 14, 2020 Author Share Posted August 14, 2020 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 Link to comment Share on other sites More sharing options...
Solution valizrt 1 Posted August 14, 2020 Solution Share Posted August 14, 2020 (edited) 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 August 14, 2020 by valizrt 1 Link to comment Share on other sites More sharing options...
iShadoW 3 Posted August 14, 2020 Author Share Posted August 14, 2020 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 More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now