Jump to content

Recommended Posts

  • 1 month later...
  • Active Member

For martysama 5.7 & 5.8 i have tested right now and solved the problem.

359e53d010c461128a06adea1bf6151a.gif

After doing the tutorial that @ Owsap posted, continue with this:
in uitooltip.py def AppendTextLine replace the whole function with:

    def AppendTextLine(self, text, color=FONT_COLOR, centerAlign=True, show=True):
        textLine = ui.TextLine()
        textLine.SetParent(self)
        textLine.SetFontName(self.defFontName)
        textLine.SetPackedFontColor(color)
        textLine.SetText(text)
        textLine.SetOutline()
        textLine.SetFeather(False)
    
        if show:
            textLine.Show()
    
        textWidth, _ = textLine.GetTextSize()
        textWidth += 20  # padding
    
        tooltipWidthChanged = False
        if self.toolTipWidth < textWidth:
            self.toolTipWidth = textWidth
            tooltipWidthChanged = True
    
        self.childrenList.append(textLine)
    
        if centerAlign:
            textLine.SetHorizontalAlignCenter()
            textLine.SetPosition(self.toolTipWidth / 2, self.toolTipHeight)
        else:
            textLine.SetPosition(10, self.toolTipHeight)
    
        self.toolTipHeight += self.TEXT_LINE_HEIGHT
        self.ResizeToolTip()
    
        if tooltipWidthChanged:
            self.AlignTextLineHorizonalCenter()
    
        return textLine



and def __CalculateToolTipWidth replace whole function with:

Spoiler
def __CalculateToolTipWidth(self):
        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:
                self.toolTipWidth += max(affectTextLineLenList) + 25

        self.AlignTextLineHorizonalCenter()

 



and also for the ShopEX (to center the required item when the text/stone's name is long and gets resized):
in def AddSHOPEXItem change:

itemImage.SetPosition(75, self.toolTipHeight)

with:
 

itemImage.SetPosition(self.toolTipWidth // 2 - itemImage.GetWidth() // 2, self.toolTipHeight)

 

Edited by Metin2 Dev International
Core X - External 2 Internal
  • muscle 1
  • Love 4
  • Honorable Member

Update

Spoiler
''' 1. '''
## Search and replace
	def __CalculateToolTipWidth(self):
		desc_string_list = []
		affect_string_list = []
		metin_affect_string_list = []

		for desc_type in range(2):
			if desc_type == 0:
				desc = item.GetItemDescription()
			else:
				desc = item.GetItemSummary()

			if not desc:
				continue

			if localeInfo.IsEUROPE():
				lines = SplitDescription(desc, DESC_WESTERN_MAX_COLS)
				desc_string_list.extend(lines)
			else:
				line_count = grpText.GetSplitingTextLineCount(desc, DESC_DEFAULT_MAX_COLS)
				for i in xrange(line_count):
					line = grpText.GetSplitingTextLine(desc, DESC_DEFAULT_MAX_COLS, i)
					desc_string_list.append(line)

		for i in xrange(item.ITEM_APPLY_MAX_NUM):
			affect_type, affect_value = item.GetAffect(i)
			if affect_value == 0:
				continue

			affect_string = self.GetAffectString(affect_type, affect_value)
			if affect_string:
				affect_string_list.append(affect_string)

		if self.attrSlot:
			for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
				affect_type, affect_value = self.attrSlot[i]
				if affect_value == 0:
					continue

				affect_string = self.GetAffectString(affect_type, affect_value)
				if affect_string:
					affect_string_list.append(affect_string)

		has_slot = False
		has_realtime_flag = False

		for i in xrange(item.LIMIT_MAX_NUM):
			(limit_type, limit_value) = item.GetLimit(i)
			if item.LIMIT_REAL_TIME == limit_type:
				has_realtime_flag = True
				break

		if self.metinSlot and not has_realtime_flag:
			item_type = item.GetItemType()
			sub_type = item.GetItemSubType()

			if sub_type in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR) or item_type == item.ITEM_TYPE_BELT:
				if self.metinSlot[0] > 0:
					has_slot = True
			elif item.IsEquipmentVID(self.itemVnum) and item_type != item.ITEM_TYPE_COSTUME:
				for data in self.metinSlot:
					item_index = self.GetMetinItemIndex(data)
					if item_index == 0:
						continue

					item.SelectItem(item_index)
					for i in xrange(item.ITEM_APPLY_MAX_NUM):
						affect_type, affect_value = item.GetAffect(i)
						if affect_value == 0:
							continue

						affect_string = self.GetAffectString(affect_type, affect_value)
						if affect_string:
							metin_affect_string_list.append(affect_string)
							has_slot = True

				item.SelectItem(self.itemVnum)

		total_strings = desc_string_list + affect_string_list + metin_affect_string_list
		if not total_strings:
			return

		max_text = max(total_strings, key = len) if total_strings else ""
		width = app.GetTextWidth(max_text) + 14

		if has_slot:
			max_metin_attr_text = max(metin_affect_string_list, key = len) if metin_affect_string_list else ""
			max_attr_text = max(affect_string_list, key = len) if affect_string_list else ""

			metin_attr_text_width = app.GetTextWidth(max_metin_attr_text)
			attr_text_width = app.GetTextWidth(max_attr_text)

			slot_gap = 43
			if metin_attr_text_width + slot_gap > attr_text_width:
				width = max(self.toolTipWidth, metin_attr_text_width + 14 + slot_gap)
			else:
				width += slot_gap

		if width > self.toolTipWidth:
			self.toolTipWidth = width
			self.AlignTextLineHorizonalCenter()

''' 2. '''
## Search
		if not item.GetItemDescription():
			self.__CalculateToolTipWidth()

## Replace with
		self.__CalculateToolTipWidth()

 

Also add this,

What has changed?

  • Fixed issue with accessory sockets causing "cannot find item by vnum" and not properly adjusting the width.
  • Fixed issue with default bonuses not adjusting the tooltip width.
  • Fixed issue with real time equipment (Quiver, Young Heroes Weapons, etc...)
  • Added support for item description and summary. (I don't think it's really needed on the default font, so you can remove it if you want)
  • Support for bigger fonts.

 

Edited by Owsap
  • Metin2 Dev 3
  • Love 2
  • Premium
On 5/10/2025 at 4:49 PM, Owsap said:

Update

  Reveal hidden contents
''' 1. '''
## Search and replace
	def __CalculateToolTipWidth(self):
		desc_string_list = []
		affect_string_list = []
		metin_affect_string_list = []

		for desc_type in range(2):
			if desc_type == 0:
				desc = item.GetItemDescription()
			else:
				desc = item.GetItemSummary()

			if not desc:
				continue

			if localeInfo.IsEUROPE():
				lines = SplitDescription(desc, DESC_WESTERN_MAX_COLS)
				desc_string_list.extend(lines)
			else:
				line_count = grpText.GetSplitingTextLineCount(desc, DESC_DEFAULT_MAX_COLS)
				for i in xrange(line_count):
					line = grpText.GetSplitingTextLine(desc, DESC_DEFAULT_MAX_COLS, i)
					desc_string_list.append(line)

		for i in xrange(item.ITEM_APPLY_MAX_NUM):
			affect_type, affect_value = item.GetAffect(i)
			if affect_value == 0:
				continue

			affect_string = self.GetAffectString(affect_type, affect_value)
			if affect_string:
				affect_string_list.append(affect_string)

		if self.attrSlot:
			for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
				affect_type, affect_value = self.attrSlot[i]
				if affect_value == 0:
					continue

				affect_string = self.GetAffectString(affect_type, affect_value)
				if affect_string:
					affect_string_list.append(affect_string)

		has_slot = False

		if self.metinSlot:
			item_type = item.GetItemType()
			sub_type = item.GetItemSubType()

			if sub_type in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR) or item_type == item.ITEM_TYPE_BELT:
				if self.metinSlot[0] > 0:
					has_slot = True
			elif item.IsEquipmentVID(self.itemVnum) and item_type != item.ITEM_TYPE_COSTUME:
				for data in self.metinSlot:
					item_index = self.GetMetinItemIndex(data)
					if item_index == 0:
						continue

					item.SelectItem(item_index)
					for i in xrange(item.ITEM_APPLY_MAX_NUM):
						affect_type, affect_value = item.GetAffect(i)
						if affect_value == 0:
							continue

						affect_string = self.GetAffectString(affect_type, affect_value)
						if affect_string:
							metin_affect_string_list.append(affect_string)
							has_slot = True

				item.SelectItem(self.itemVnum)

		total_strings = desc_string_list + affect_string_list + metin_affect_string_list
		if not total_strings:
			return

		max_text = max(total_strings, key = len) if total_strings else ""
		width = app.GetTextWidth(max_text) + 14

		if has_slot:
			max_metin_attr_text = max(metin_affect_string_list, key = len) if metin_affect_string_list else ""
			max_attr_text = max(affect_string_list, key = len) if affect_string_list else ""

			metin_attr_text_width = app.GetTextWidth(max_metin_attr_text)
			attr_text_width = app.GetTextWidth(max_attr_text)

			slot_gap = 43
			if metin_attr_text_width + slot_gap > attr_text_width:
				width = max(self.toolTipWidth, metin_attr_text_width + 14 + slot_gap)
			else:
				width += slot_gap

		if width > self.toolTipWidth:
			self.toolTipWidth = width
			self.AlignTextLineHorizonalCenter()

''' 2. '''
## Search
		if not item.GetItemDescription():
			self.__CalculateToolTipWidth()

## Replace with
		self.__CalculateToolTipWidth()

 

Also add this,

What has changed?

  • Fixed issue with accessory sockets causing "cannot find item by vnum" and not properly adjusting the width.
  • Fixed issue with default bonuses not adjusting the tooltip width.
  • Added support for item description and summary. (I don't think it's really needed on the default font, so you can remove it if you want)
  • Support for bigger fonts.

 

Thank you for the update that's amazing and solve the problem of long stone texts out of tooltip and long attributs names.

Maybe some people will need that to make the update work : 

 

Spoiler
#add in class ItemToolTip(ToolTip) def __Init__:
		self.attrSlot = []
        
#add in class ItemToolTip(ToolTip) def __del__:
		self.attrSlot = None
        
#Search in def AddItemData:
		self.metinSlot = metinSlot


#Add:
		self.attrSlot = attrSlot
            
#replace in the updated def __CalculateToolTipWidth (x3):
self.GetAffectString

#by:
self.__GetAffectString

 

 

regarding the tooltip for the 6th and 7th availability and the LEFT_TIME :

Spoiler

I have a problem with putting AlignTextLineHorizonalCenter in def AppendTextline 

In my case it's messing up with the icon of item in the private search shop window and in hyperlinks

even when i adjust all itemImage positons to :

 

itemImage.SetPosition(self.toolTipWidth // 2 - itemImage.GetWidth() // 2, self.toolTipHeight)

So i edited the def __CalculateToolTipWidth function like this : 
 

##for the 6th and 7th bonus availability tooltip:
#Search:
		if self.attrSlot:
			for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
				affect_type, affect_value = self.attrSlot[i]
				if affect_value == 0:
					continue

				affect_string = self.GetAffectString(affect_type, affect_value)
				if affect_string:
					affect_string_list.append(affect_string)

#replace:
		if self.attrSlot:
			count = 0
			for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
				affect_type, affect_value = self.attrSlot[i]
				if affect_type != 0 and affect_value != 0:
					count += 1
				if affect_value == 0:
					continue
				affect_string = self.GetAffectString(affect_type, affect_value)
				if affect_string:
					affect_string_list.append(affect_string)
					if app.BL_67_ATTR and 5 <= count <= 6:
						affect_string_list.append(localeInfo.ATTR_6TH_7TH_POSSIBILITY)
                        
##For Time remaining tooltip getting out of the border:
#Find:
		has_realtime_flag = False

		for i in xrange(item.LIMIT_MAX_NUM):
			(limit_type, limit_value) = item.GetLimit(i)
			if item.LIMIT_REAL_TIME == limit_type:
				has_realtime_flag = True
				break
                
##Add:
		if has_realtime_flag:
			realtime_text = localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(2591999)
			affect_string_list.append(realtime_text)
        ## I use 2591999 because it's the highest value for time limit -1 second To enlarge it 
        ##I guess we can do it another way but it wasn't working for me with "limit_value"

 

 

To fix the Skills Tooltip I added Anielle Noir def AppendTextLine in the class SkillTooltip, since there is only text in this class 

It seems to work fine.

 

Best regards ARiver

Edited by ARiver
self.attrSlot update, attr67 possibility tooltip, left time tooltip, skill tooltip
  • Love 1
  • 1 month later...
On 5/3/2025 at 9:12 AM, Anielle Noir said:

For martysama 5.7 & 5.8 i have tested right now and solved the problem.

359e53d010c461128a06adea1bf6151a.gif

After doing the tutorial that @ Owsap posted, continue with this:
in uitooltip.py def AppendTextLine replace the whole function with:

    def AppendTextLine(self, text, color=FONT_COLOR, centerAlign=True, show=True):
        textLine = ui.TextLine()
        textLine.SetParent(self)
        textLine.SetFontName(self.defFontName)
        textLine.SetPackedFontColor(color)
        textLine.SetText(text)
        textLine.SetOutline()
        textLine.SetFeather(False)
    
        if show:
            textLine.Show()
    
        textWidth, _ = textLine.GetTextSize()
        textWidth += 20  # padding
    
        tooltipWidthChanged = False
        if self.toolTipWidth < textWidth:
            self.toolTipWidth = textWidth
            tooltipWidthChanged = True
    
        self.childrenList.append(textLine)
    
        if centerAlign:
            textLine.SetHorizontalAlignCenter()
            textLine.SetPosition(self.toolTipWidth / 2, self.toolTipHeight)
        else:
            textLine.SetPosition(10, self.toolTipHeight)
    
        self.toolTipHeight += self.TEXT_LINE_HEIGHT
        self.ResizeToolTip()
    
        if tooltipWidthChanged:
            self.AlignTextLineHorizonalCenter()
    
        return textLine



and def __CalculateToolTipWidth replace whole function with:

  Reveal hidden contents
def __CalculateToolTipWidth(self):
        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:
                self.toolTipWidth += max(affectTextLineLenList) + 25

        self.AlignTextLineHorizonalCenter()

 



and also for the ShopEX (to center the required item when the text/stone's name is long and gets resized):
in def AddSHOPEXItem change:

itemImage.SetPosition(75, self.toolTipHeight)

with:
 

itemImage.SetPosition(self.toolTipWidth // 2 - itemImage.GetWidth() // 2, self.toolTipHeight)

 

Your suggestion fixed the issue i was having with the tooltip size but now the stone icons are stuck to the very far left. Does anyone know how to fix this ?


spacer.png

Edited by ShadowsPR0
Core X - External 2 Internal
5 hours ago, ShadowsPR0 said:

Your suggestion fixed the issue i was having with the tooltip size but now the stone icons are stuck to the very far left. Does anyone know how to fix this ?


spacer.png

I have managed to fix this issue by doing the below changes:

in uitooltip.py
 

Search for:
	def ClearToolTip(self):
		self.toolTipHeight = 12
		self.childrenList = []

Add under self.childrenList = []:
		self.centeredTextLines = []
    
Change AppendTextLine function to this:
  	def AppendTextLine(self, text, color=FONT_COLOR, centerAlign=True, show=True):
		textLine = ui.TextLine()
		textLine.SetParent(self)
		textLine.SetFontName(self.defFontName)
		textLine.SetPackedFontColor(color)
		textLine.SetText(text)
		textLine.SetOutline()
		textLine.SetFeather(False)

		if show:
			textLine.Show()

		textWidth, _ = textLine.GetTextSize()
		textWidth += 20  # padding

		tooltipWidthChanged = False
		if self.toolTipWidth < textWidth:
			self.toolTipWidth = textWidth
			tooltipWidthChanged = True

		self.childrenList.append(textLine)

		if centerAlign:
			textLine.SetHorizontalAlignCenter()
			textLine.SetPosition(self.toolTipWidth / 2, self.toolTipHeight)
			if not hasattr(self, "centeredTextLines"):
				self.centeredTextLines = []
			self.centeredTextLines.append(textLine)
		else:
			textLine.SetHorizontalAlignLeft()
			textLine.SetPosition(10, self.toolTipHeight)

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

		if tooltipWidthChanged and hasattr(self, "centeredTextLines"):
			for line in self.centeredTextLines:
				line.SetPosition(self.toolTipWidth / 2, line.GetLocalPosition()[1])
				line.SetHorizontalAlignCenter()

		return textLine

 

  • Love 1

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.