Jump to content

Item ToolTip Width Fix


Owsap

Recommended Posts

  • Honorable Member

This is the hidden content, please

Other Mirros
This is the hidden content, please
(GitHub
This is the hidden content, please
(Mega
)

Hey M2Dev, I want to share something small but visually appreciated by players that are paying attention to details.
What I'm sharing with you today will solve the issue of item tooltips with large strings, these strings overflow the width of the tooltip causing the text to hang out of the edge, especially when metin stones are attached to your weapon or armor.

BEFORE PREVIEW

Spoiler

.jpg

 

AFTER PREVIEW

Spoiler

.jpg

.

Edited by Owsap
Corrected some flaws.
  • Metin2 Dev 259
  • kekw 1
  • Eyes 4
  • Sad 1
  • Smile Tear 1
  • Think 4
  • Scream 1
  • Lmao 1
  • Good 47
  • Love 11
  • Love 92
Link to comment
Share on other sites

  • Gold

@OwsapThanks, for the release. Good job! Would be nice, if you can do something like that for question dialogs too, because when you want to drop for example 1000x pcs of some item, the text will overflow the question dialog (sometimes it happens with lower counts of item, for example books, they have a long names). Do something like when the text can overflow the question dialog width, then add 20px to question dialog width.

Edited by ReFresh
  • Metin2 Dev 2

I'll be always helpful! 👊 

Link to comment
Share on other sites

  • Honorable Member
7 minutes ago, SCOOB said:

The metin attach part is broken for me 😞 

I did everything like the tutorial.

it looks like this: 

7498db54096f0cf2902c89bc8300a1ef.jpg

 

Here is an example of the AttachMetinDialog, https://metin2.dev/bin/?d7f919364d8cf49c#2t1csJzQNkg9s4jk9tTS6DnEdtGzMPctDhDEwRnX1UMo

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
Link to comment
Share on other sites

  • Bronze
25 minutes ago, Owsap said:

thank you, all's working fine now 😄

Spoiler

 

61baf2580b9e989ae2b9d3801898fecc.jpg

 

058f6959b0492651f1606d4d4669a90b.jpg

Edited by Metin2 Dev
Core X - External 2 Internal

spacer.png

Link to comment
Share on other sites

  • Honorable Member
26 minutes ago, SCOOB said:

thank you, all's working fine now 😄

  Hide contents

 

61baf2580b9e989ae2b9d3801898fecc.jpg

 

058f6959b0492651f1606d4d4669a90b.jpg

Found another problem.. If you're on a player character, some item names are corrupted, for example:

 

u8vzRbG.png

 

Can you share with us your uittoltip.py? or do you know why does this problem occur? @ Owsap

I don't believe this is related to the fix.
No item positions, sockets, title names or bonus names where changed in any of the code, only the size of the thinboard.

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Premium

Two things @ Owsap.

1.  For sure an overlook, this should be self.newTooltip.AddItemData(itemIndex, metinSlot)
RM99Zgg.png

 

2. You forgot to tell them to add this line:
 

self.newToolTip.SetPosition(15 + self.oldToolTip.GetWidth() + 45, 38)

Before if localeInfo.IsARABIC():

Edited by Metin2 Dev
Core X - External 2 Internal
  • Good 1
  • Love 1

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Honorable Member
3 hours ago, Syreldar said:

Two things @ Owsap.

1.  For sure an overlook, this should be self.newTooltip.AddItemData(itemIndex, metinSlot)
RM99Zgg.png

 

2. You forgot to tell them to add this line:
 

self.newToolTip.SetPosition(15 + self.oldToolTip.GetWidth() + 45, 38)

Before if localeInfo.IsARABIC():

Thanks, I have updated the files.

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
  • Love 1
Link to comment
Share on other sites

  • Gold

@avertusss

File: root/uiattachmetin.py

Spoiler
Find:
  newToolTip.SetPosition(230 + 20, 38)
  
Change to:
  newToolTip.SetPosition(300 + 20, 38)

Find:
  newWidth = self.newToolTip.GetWidth() + 230 + 15 + 20

Change to:
  newWidth = self.newToolTip.GetWidth() + 300 + 15 + 20
  
Find:
  self.SetPosition(x, y)

Change to:
  self.SetCenterPosition()

File: uiscript/attachstonedialog.py

Spoiler

spacer.png

I believe this will fix your problem with font.

I'll be always helpful! 👊 

Link to comment
Share on other sites

15 hours ago, ReFresh said:

@avertusss

File: root/uiattachmetin.py

  Reveal hidden contents
Find:
  newToolTip.SetPosition(230 + 20, 38)
  
Change to:
  newToolTip.SetPosition(300 + 20, 38)

Find:
  newWidth = self.newToolTip.GetWidth() + 230 + 15 + 20

Change to:
  newWidth = self.newToolTip.GetWidth() + 300 + 15 + 20
  
Find:
  self.SetPosition(x, y)

Change to:
  self.SetCenterPosition()

File: uiscript/attachstonedialog.py

  Reveal hidden contents

spacer.png

I believe this will fix your problem with font.

It's not fix. It's just change size of tooltip. If someone will have font changer ingame it will looks weird if you make it big af but someone want use small font instead of big. 

  • Smile Tear 1
Link to comment
Share on other sites

  • 1 month later...
  • Premium

This "fix" is causing this error:

 

0820 10:31:33723 :: Cannot find item by 2972
0820 10:31:45273 :: Cannot find item by 2972
0820 10:31:45849 :: Cannot find item by 2972
0820 10:31:46098 :: Cannot find item by 2972
0820 10:31:46924 :: Cannot find item by 2972
 

 

Any ideia why? I have 100% sure it's something in uitooltip.py

If i follow all the fix i have that error, if i remove it i have none, and if i do all fix, but do not change uitooltip. Error come back!

 

Edit2

Error come from item 72702 . This item have no description and if i move the mouse over him, i see the uitooltip with no problem, but i got 

syserr  0820 10:31:33723 :: Cannot find item by 2972

 

 

Any help?

 

EDIT3

I change this function:

Spoiler
	def __CalculateToolTipWidth(self):
		affectTextLineLenList = []

		metinSocket = self.metinSlot
		if metinSocket > 0:
			for socketIndex in metinSocket:
				if socketIndex:
					item.SelectItem(socketIndex)

					affectType, affectValue = item.GetAffect(0)
					affectString = self.__GetAffectString(affectType, affectValue)
					if affectString:
						affectTextLineLenList.append(len(affectString))

			if self.itemVnum:
				item.SelectItem(self.itemVnum)
			self.metinSlot = None

		if self.toolTipWidth == self.TOOL_TIP_WIDTH:
			if affectTextLineLenList:
				self.toolTipWidth += max(affectTextLineLenList) + 10

		self.AlignTextLineHorizonalCenter()

 

with:

Spoiler
	def __CalculateToolTipWidth(self):
		affectTextLineLenList = []
		affectType, affectValue = item.GetAffect(0)
		affectString = self.__GetAffectString(affectType, affectValue)
		if affectString:
			affectTextLineLenList.append(len(affectString))

		if self.toolTipWidth == self.TOOL_TIP_WIDTH:
			if affectTextLineLenList:
				self.toolTipWidth += max(affectTextLineLenList) + 10

		self.AlignTextLineHorizonalCenter()

 

And no more syserr and i belive all tooltips are ok....

But if i have cause anyother error, let me know please

Edited by EnKor
if pc.get_sex() == true and npc.get_sex() == false then
	npc.purge()
end

 

Link to comment
Share on other sites

  • Premium
36 minutes ago, LordZiege said:

i found a litle problem with very long bonuses

gzb3z.png

Bez-tytulu-1.png

Fix is fairly simple, just replace function (uiToolTip)

Spoiler
	def __AdjustAttrMaxWidth(self, attrSlot):
		if 0 == attrSlot:
			return self.toolTipWidth

		maxWidth = self.toolTipWidth
		for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
			type = attrSlot[i][0]
			value = attrSlot[i][1]

			attrText = self.AppendTextLine(self.__GetAffectString(type, value))
			(tW, _) = attrText.GetTextSize()
			self.childrenList.remove(attrText)
			self.toolTipHeight -= self.TEXT_LINE_HEIGHT

			maxWidth = max(tW + 12, maxWidth)

		return maxWidth

 

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 3
  • Good 2
  • Love 2
Link to comment
Share on other sites

  • 4 weeks later...

@EnKor this code will solve the problems 
 

		#Cannot find item by 'xxx'
		if item.GetItemType() != item.ITEM_TYPE_ARMOR and item.GetItemType() != item.ITEM_TYPE_WEAPON:
			return

@avertusssI have adapted the code to the font size , good for those who use dynamic font
 

Preview:  https://metin2.download/video/7PY3NxZw6WpdkmH72T8q5Q1SyjCLkCO8/.mp4


here is the complete code

Spoiler
	def __CalculateToolTipWidth(self):
		if item.GetItemType() != item.ITEM_TYPE_ARMOR and item.GetItemType() != item.ITEM_TYPE_WEAPON:
			return

		affectTextLineLenList = []
		metinSocket = self.metinSlot
		
		if metinSocket:
			for socketIndex in metinSocket:
				if socketIndex:
					item.SelectItem(socketIndex)

					affectType, affectValue = item.GetAffect(0)
					affectString = self.__GetAffectString(affectType, affectValue)					
					if affectString:
						affectTextLineLenList.append(len(affectString))
	
			if self.itemVnum:
				item.SelectItem(self.itemVnum)
			self.metinSlot = None

		if self.toolTipWidth == self.TOOL_TIP_WIDTH:
			if affectTextLineLenList:
				FontSize = int(''.join(filter(str.isdigit, localeInfo.UI_DEF_FONT)))	#Tested on Tahoma font
				if FontSize <= 12:
					self.toolTipWidth += max(affectTextLineLenList) + 25	# the gaps can be adjusted by yourself
				elif FontSize <= 14:
					self.toolTipWidth += max(affectTextLineLenList) + 25 + FontSize*2.5
				elif FontSize <= 16:
					self.toolTipWidth += max(affectTextLineLenList) + 25 + FontSize*3
				elif FontSize == 17:
					self.toolTipWidth += max(affectTextLineLenList) + 25 + FontSize*4
				elif FontSize == 18:
					self.toolTipWidth += max(affectTextLineLenList) + 25 + FontSize*4.5
				else:
					self.toolTipWidth += max(affectTextLineLenList) + 25 + FontSize*8

		self.AlignTextLineHorizonalCenter()

 

 

I also shares a modification for resize a ToolTip/SkillToolTip  but it is not perfect and may have errors
if you want to use it go ahead , this is done quickly to check the effect


Previewhttps://metin2.download/video/OO2cIBUk0K1Q1bidKF49BvTONh8atFJh/.mp4

Spoiler
#found 
	def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = TRUE):

#change it

	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)

		(textWidth, textHeight)=textLine.GetTextSize()

		textWidth += 20

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

		self.toolTipHeight += self.TEXT_LINE_HEIGHT
		self.AlignTextLineHorizonalCenter()
		return textLine
      
#if you use:  self.AppendTextLine("[Vnum: %d]"

# Search @ class ItemToolTip @ def AddItemData
		if not item.GetItemDescription():
			self.__CalculateToolTipWidth()

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

 

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Good 2
Link to comment
Share on other sites

  • 5 months later...
  • 2 months later...

  

On 8/20/2022 at 11:17 PM, Trudix said:

Everything works as it should, but if I have the 6/7 bonuses and no stones on the weapon, the problem still persists.

Can you do an update about that?

spacer.pngspacer.pngspacer.pngspacer.png

 

I can confirm this. If no stone is attached to the item, 6/7 attr will overflow

Edited by Debloat
Link to comment
Share on other sites

  • 5 months later...
  • 1 month later...

Hello, first I would like to thank you, it works very well, I also applied the code that Filip left with auto adjustment, it works very well but my problem is that the stones had no effect and when inserting them into a weapon or armor there is still no change, does anyone know why what's happening?

I make it clear that following the tutorial completely, this problem still happens with the stone tooltip.

working:


Captura-de-pantalla-2024-01-13-125649.pn

 

not working:

Captura-de-pantalla-2024-01-13-125109.pn
 

 

 

Edited by Metin2 Dev International
Core X - External 2 Internal

Captura-de-pantalla-2024-03-20-112804.pn

 

Link to comment
Share on other sites

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.