Jump to content

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 403
  • kekw 1
  • Eyes 4
  • Sad 1
  • Smile Tear 1
  • Think 5
  • Scream 1
  • Lmao 2
  • Good 77
  • muscle 1
  • Love 19
  • Love 195
Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/
Share on other sites

  • Active+ Member

@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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-149890
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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-149897
Share on other sites

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
Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-149898
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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-149899
Share on other sites

  • Honorable Member

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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-149901
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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-149902
Share on other sites

  • Active+ Member

@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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-150022
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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-150030
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
  • muscle 1
if pc.get_sex() == true and npc.get_sex() == false then
	npc.purge()
end

 

Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-151380
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 4
  • Good 2
  • Love 3
Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-151520
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
  • Love 1
Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-152036
Share on other sites

  • 5 months later...
  • 2 months later...
  • Active+ Member

  

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
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-158109
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

Anotaci-n-2024-06-28-185820.png

 

 

Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-162334
Share on other sites

  • 11 months later...
  • Premium
On 1/13/2024 at 10:03 PM, josehdelaro said:

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
 

 

 

Hello, I Have installed this system on my TMP4 files and when installing the main version, long bonus names were getting out of the tooltip,
I still had the issue with some stones descriptions, a syserr client ":: Cannot find item by XXXXX"
I tried what filipw1 posted and it worked fine on long bonus name but it restrain that fix to attributs.
I tried what Artvr3 post for the syserr part and it worked good.
His modification in "def AppendTextLine()" in the class ItemToolTip(ToolTip) worked for the items descriptions and
Stone descriptions and other tooltips like 6/7 bonus.

From what i have noticed
 "def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = TRUE):" is found two times in uitooltip.py:

in class ItemToolTip(ToolTip) :

if you put Artvr3 modification here it will work only on items but don't replace all function adapt it because in this class it's also use to display the red font for item you can't wear.

and in class ToolTip(ui.ThinBoard)
this is what i have done thanks to Artvr3: 

Spoiler
#edit def AppendTextLine function in class Tooltip:
  	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)
		## TOOLTIP WIDTH FIX for skills and items attributs credit Artvr3 ##		
		(textWidth, textHeight)=textLine.GetTextSize()

		textWidth += 20

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

		self.toolTipHeight += self.TEXT_LINE_HEIGHT
		self.AlignTextLineHorizonalCenter()
		##END of fix

		#Original part:
		#self.toolTipHeight += self.TEXT_LINE_HEIGHT
		#self.ResizeToolTip()
		
		return textLine
        
#Add in same class Tooltip:
  def AlignTextLineHorizonalCenter(self):
      for child in self.childrenList:
          if type(child).__name__ == "TextLine":
              (x, y) = child.GetLocalPosition()
              child.SetPosition(self.toolTipWidth / 2, y)

      self.ResizeToolTip()

 

 as Artvr3 said i don't know if this is good but only with the main system from owsap and this modification the tooltips are fine even for all items with bonus and stones and for skills too.

 

I still got an issue regarding stone attaching though:

the tooltip is still out.

EDIT: i found an issue regarding item icon's in tooltip not being displayed corectly, it seems to be coming from the use of AlignTextLine in AppendTextline, and metin socket  are displayed wrong when an item wearing a stone is in shop (i've only noticed in shop) so for now i will not use this as it is 

Edited by ARiver
icon tooltip messed up
  • Love 2
Link to comment
https://metin2.dev/topic/29207-item-tooltip-width-fix/#findComment-168657
Share on other sites

  • 3 months later...

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.