Jump to content

EXP, HP, and SP values are now displayed on the screen (not anymore as tooltip)


Recommended Posts

Greetings everyone,

I am delighted to share with you my first post. While it may not be groundbreaking, I hope that it will be useful to someone.

Typically, to view your exact percentage of EXP, HP, and SP, you need to hover your mouse over the "container" - essentially, this works as a tooltip. However, as I am currently working on a new interface, I decided to change this.

By implementing the following code, the experience percentage will always be displayed on the screen, making it more user-friendly, in my opinion. The same goes for HP and SP, although I have chosen to display only their current values.

Please note that the (x,y) coordinates provided are simply an example of where the text will appear on the screen. Feel free to adjust them as needed.

PS: I have added the level next to the experience percentage on the left side.


root/uitaskbar.py ---> Add the following classes: 
 

class ExperienceDisplay: #added display level on this class 
	def __init__(self):
		self.percentage_text = ui.TextLine()
		self.percentage_text.SetPosition(100, 40)
		self.percentage_text.SetHorizontalAlignCenter()
		self.percentage_text.Hide()

		self.level_text = ui.TextLine()
		self.level_text.SetPosition(60,40)
		self.level_text.SetHorizontalAlignCenter()
		self.level_text.Hide()

	def UpdateExperiencePercentage(self, percentage):
		self.percentage_text.SetText("{:.2f}%".format(percentage))
		self.percentage_text.SetFontColor(1.0, 1.0, 0.0) #yellow
		self.percentage_text.Show()

		level = player.GetStatus(player.LEVEL)
		self.level_text.SetText("Lv. " + str(level) + " - ")
		self.level_text.SetFontColor(1.0, 1.0, 0.0)
		self.level_text.Show()


class HPDisplay:
	def __init__(self):
		self.curPoint_text = ui.TextLine()
		self.curPoint_text.SetPosition(100, 70)
		self.curPoint_text.SetHorizontalAlignCenter()
		self.curPoint_text.Hide()

	def update_hp_text(self, curPoint):
		self.curPoint_text.SetText("HP: " + str(curPoint))
		self.curPoint_text.SetFontColor(1.0, 0.0, 0.0) #red 
		self.curPoint_text.Show()

class SPDisplay:
	def __init__(self):
		self.curPoint_text = ui.TextLine()
		self.curPoint_text.SetPosition(100, 100)
		self.curPoint_text.SetHorizontalAlignCenter()
		self.curPoint_text.Hide()

	def update_sp_text(self, curPoint):
		self.curPoint_text.SetText("SP: " + str(curPoint))
		self.curPoint_text.SetFontColor(0.0, 0.0, 1.0) #blue
		self.curPoint_text.Show()

Search:

self.tooltipEXP.SetText("%s : %.2f%%" % (localeInfo.TASKBAR_EXP, float(curPoint) / max(1, float(maxPoint)) * 100))

Replace with:
 

self.experience_display = ExperienceDisplay()
self.experience_display.UpdateExperiencePercentage(float(curPoint) / max(1, float(maxPoint)) * 100)

Search: 
 

self.tooltipHP.SetText("%s : %d / %d" % (localeInfo.TASKBAR_HP, curPoint, maxPoint))

Replace with:
 

self.hpdisplay = HPDisplay()
self.hpdisplay.update_hp_text(curPoint)

Search:
 

self.tooltipSP.SetText("%s : %d / %d" % (localeInfo.TASKBAR_SP, curPoint, maxPoint))

Replace with: 
 

self.spdisplay = SPDisplay()
self.spdisplay.update_sp_text(curPoint)


That's all, if I missed something please tell me. 

Screenshot
 

 

 

 

 

 

 

 

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Metin2 Dev 2
  • Good 1
  • 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.