Jump to content

Recommended Posts

This is the hidden content, please

Alternative download links →

This is the hidden content, please
 

 

 


Last night I remembered the contribution that @ Tatsumaru made some time ago for the sliderbar and I really liked the design, I did not see that nobody adapted it correctly and I was motivated to make the necessary changes to make it work correctly, it is not a big deal, but I am sure that someone will be useful.

 

improvements made

 

the drag class button is not updating correctly, now it will refresh properly when hovering the cursor

added reset button positioning as shown in the design

spacer.png

if you see that it can be done in a better way, I am open to listen

forgot to add need the designs that @ Tatsumarupublished in this contribution
 

 

Edited by DeadOfLove
forget to add the design reference
  • Metin2 Dev 32
  • Good 10
  • Love 17
Link to comment
https://metin2.dev/topic/33573-improved-slider-bar/
Share on other sites

  • 11 months later...
Spoiler
class SliderBar(Window):

	def __init__(self):
		Window.__init__(self)

		self.curPos = 1.0
		self.pageSize = 1.0
		self.eventChange = None

		self.__CreateBackGroundImage()
		self.__CreateCursor()

		self.__CreateResetButton()

	def __del__(self):
		Window.__del__(self)

	def __CreateBackGroundImage(self):
		img = ImageBox()
		img.SetParent(self)
		img.LoadImage("d:/ymir work/ui/game/slidebar/slidebar.tga")
		img.Show()
		self.backGroundImage = img

		##
		self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())

	def __CreateCursor(self):
		cursor = DragButton()
		cursor.AddFlag("movable")
		cursor.AddFlag("restrict_y")
		cursor.SetParent(self)
		cursor.SetMoveEvent(__mem_func__(self.__OnMove))
		cursor.SetUpVisual("d:/ymir work/ui/game/slidebar/slidebar_button01.tga")
		cursor.SetOverVisual("d:/ymir work/ui/game/slidebar/slidebar_button02.tga")
		cursor.SetDownVisual("d:/ymir work/ui/game/slidebar/slidebar_button01.tga")
		cursor.Show()
		self.cursor = cursor

		##
		self.startX = 7
		self.endX = 154

		self.cursor.SetRestrictMovementArea(self.startX, 0, self.endX, 0)
		self.pageSize = self.endX - self.startX - self.cursor.GetWidth()

	def __CreateResetButton(self):
		resetButton = Button()
		resetButton.SetParent(self)
		resetButton.SetPosition(170, 0)
		resetButton.SetUpVisual("d:/ymir work/ui/game/slidebar/reset01.tga")
		resetButton.SetOverVisual("d:/ymir work/ui/game/slidebar/reset02.tga")
		resetButton.SetDownVisual("d:/ymir work/ui/game/slidebar/reset03.tga")
		resetButton.SetEvent(__mem_func__(self.OnReset))
		resetButton.Show()
		self.resetButton = resetButton

	def OnReset(self, pos=0.0):
		self.SetSliderPos(pos)

		if self.eventChange:
			self.eventChange()

	def __OnMove(self):
		(xLocal, yLocal) = self.cursor.GetLocalPosition()
		self.curPos = float(xLocal - self.startX) / float(self.pageSize)

		if self.eventChange:
			self.eventChange()

	def SetSliderPos(self, pos):
		self.curPos = pos
		self.cursor.SetPosition(int(self.startX + self.pageSize * pos), 0)

	def GetSliderPos(self):
		return self.curPos

	def SetEvent(self, event):
		self.eventChange = event

	def Enable(self):
		self.cursor.Show()
		self.resetButton.Show()

	def Disable(self):
		self.cursor.Hide()
		self.resetButton.Hide()

 

This is the hidden content, please

Edited by Filachilla
  • Metin2 Dev 11
  • Love 1
Link to comment
https://metin2.dev/topic/33573-improved-slider-bar/#findComment-174731
Share on other sites

  • 5 weeks later...
On 3/9/2026 at 5:50 PM, Filachilla said:
  Reveal hidden contents
class SliderBar(Window):

	def __init__(self):
		Window.__init__(self)

		self.curPos = 1.0
		self.pageSize = 1.0
		self.eventChange = None

		self.__CreateBackGroundImage()
		self.__CreateCursor()

		self.__CreateResetButton()

	def __del__(self):
		Window.__del__(self)

	def __CreateBackGroundImage(self):
		img = ImageBox()
		img.SetParent(self)
		img.LoadImage("d:/ymir work/ui/game/slidebar/slidebar.tga")
		img.Show()
		self.backGroundImage = img

		##
		self.SetSize(self.backGroundImage.GetWidth(), self.backGroundImage.GetHeight())

	def __CreateCursor(self):
		cursor = DragButton()
		cursor.AddFlag("movable")
		cursor.AddFlag("restrict_y")
		cursor.SetParent(self)
		cursor.SetMoveEvent(__mem_func__(self.__OnMove))
		cursor.SetUpVisual("d:/ymir work/ui/game/slidebar/slidebar_button01.tga")
		cursor.SetOverVisual("d:/ymir work/ui/game/slidebar/slidebar_button02.tga")
		cursor.SetDownVisual("d:/ymir work/ui/game/slidebar/slidebar_button01.tga")
		cursor.Show()
		self.cursor = cursor

		##
		self.startX = 7
		self.endX = 154

		self.cursor.SetRestrictMovementArea(self.startX, 0, self.endX, 0)
		self.pageSize = self.endX - self.startX - self.cursor.GetWidth()

	def __CreateResetButton(self):
		resetButton = Button()
		resetButton.SetParent(self)
		resetButton.SetPosition(170, 0)
		resetButton.SetUpVisual("d:/ymir work/ui/game/slidebar/reset01.tga")
		resetButton.SetOverVisual("d:/ymir work/ui/game/slidebar/reset02.tga")
		resetButton.SetDownVisual("d:/ymir work/ui/game/slidebar/reset03.tga")
		resetButton.SetEvent(__mem_func__(self.OnReset))
		resetButton.Show()
		self.resetButton = resetButton

	def OnReset(self, pos=0.0):
		self.SetSliderPos(pos)

		if self.eventChange:
			self.eventChange()

	def __OnMove(self):
		(xLocal, yLocal) = self.cursor.GetLocalPosition()
		self.curPos = float(xLocal - self.startX) / float(self.pageSize)

		if self.eventChange:
			self.eventChange()

	def SetSliderPos(self, pos):
		self.curPos = pos
		self.cursor.SetPosition(int(self.startX + self.pageSize * pos), 0)

	def GetSliderPos(self):
		return self.curPos

	def SetEvent(self, event):
		self.eventChange = event

	def Enable(self):
		self.cursor.Show()
		self.resetButton.Show()

	def Disable(self):
		self.cursor.Hide()
		self.resetButton.Hide()

 

This is the hidden content, please

I can't edit my post, but by the way, I'm adding a screenshot as requested. I've added a min/max range + an edit interface to make it smooth.

preview

  • Metin2 Dev 1
  • kekw 1
  • muscle 2
Link to comment
https://metin2.dev/topic/33573-improved-slider-bar/#findComment-175073
Share on other sites

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.