Register for your free account! | Forgot your password?

You last visited: Today at 02:38

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Release]Metin2 Progress Bar

Discussion on [Release]Metin2 Progress Bar within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
Eigenartig's Avatar
 
elite*gold: 0
Join Date: Sep 2012
Posts: 219
Received Thanks: 123
[Release]Metin2 Progress Bar

Video:


Code:
class ProgressBar(ui.Window):

	BACKGROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
	DARK_COLOR = grp.GenerateColor(0.4, 0.4, 0.4, 1.0)
	
	PROGRESS_COLOR = grp.GenerateColor(1.0, 0.2, 0.2, 0.4)
	
	def __init__(self, layer = "UI"):
		ui.Window.__init__(self, layer)

		self.width = 0
		self.height = 0		
		self.percentage = 0
		
		self.textLine = None
		
	def __del__(self):
		ui.Window.__del__(self)

	def SetSize(self, width, height):
		ui.Window.SetSize(self, width, height)
		self.width = width
		self.height = height

	def SetPercentage(self, num):
		if num > 100:
			self.percentage = 100
		elif num < 0:
			self.percentage = 0
		else:
			self.percentage = num
		
		if not self.textLine:		
			textLine = ui.TextLine()
			textLine.SetParent(self)
			textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
			textLine.SetVerticalAlignCenter()
			textLine.SetHorizontalAlignCenter()
			textLine.SetOutline()
			textLine.Show()
			self.textLine = textLine
		
		self.textLine.SetText('%' + str(self.percentage))

	def OnRender(self):
		xRender, yRender = self.GetGlobalPosition()
		
		widthRender = self.width
		heightRender = self.height
		grp.SetColor(self.BACKGROUND_COLOR)
		grp.RenderBar(xRender, yRender, widthRender, heightRender)
		grp.SetColor(self.DARK_COLOR)
		grp.RenderLine(xRender, yRender, widthRender, 0)
		grp.RenderLine(xRender, yRender, 0, heightRender)
		grp.RenderLine(xRender, yRender+heightRender, widthRender, 0)
		grp.RenderLine(xRender+widthRender, yRender, 0, heightRender)

		grp.SetColor(self.PROGRESS_COLOR)
		grp.RenderBar(xRender + 2, yRender + 2, (self.width - 3) * self.percentage / 100, heightRender - 3)
How to use:
Code:
		self.progressBar = ProgressBar()
		self.progressBar.SetParent(parent)
		self.progressBar.SetPosition(xPos, yPos) 
		self.progressBar.SetSize(xSize, ySize)
		self.progressBar.SetPercentage(percentage)
		self.progressBar.Show()
Bonus:

You can also change the colors
Code:
	BACKGROUND_COLOR = grp.GenerateColor(0.0, 0.0, 0.0, 1.0)
	DARK_COLOR = grp.GenerateColor(0.4, 0.4, 0.4, 1.0)
	
	PROGRESS_COLOR = grp.GenerateColor(1.0, 0.2, 0.2, 0.4)
Virustotal:


Attached Files
File Type: rar progressbar.rar (645 Bytes, 92 views)
Eigenartig is offline  
Thanks
11 Users
Old 10/03/2014, 19:18   #2
 
elite*gold: 139
Join Date: Sep 2010
Posts: 583
Received Thanks: 546
Thanks quiet useful.
.XXShuzZzle is offline  
Old 10/03/2014, 21:54   #3
Trade Restricted
 
elite*gold: 0
Join Date: Jun 2013
Posts: 1,332
Received Thanks: 534
Nice thanks you !!
Bostanin Edhe is offline  
Old 10/03/2014, 22:33   #4
 
elite*gold: 0
Join Date: Jan 2014
Posts: 4
Received Thanks: 8
Quote:
Originally Posted by Eigenartig View Post
PHP Code:
def SetPercentage(selfnum):
    if 
num 100:
        
self.percentage 100
    elif num 
0:
        
self.percentage 0
    
else:
        
self.percentage num 
To avoid some if/else controls:

€dit: Well, i made a mistake! Working version:

PHP Code:
def SetPercentage(selfnum):
    
self.percentage max(0num)
    
self.percentage min(100self.percentage
.Osiris is offline  
Old 10/03/2014, 22:36   #5
 
elite*gold: 0
Join Date: Aug 2009
Posts: 262
Received Thanks: 45
wofür dient das?
derwahrehuy is offline  
Old 10/04/2014, 10:11   #6
 
Eigenartig's Avatar
 
elite*gold: 0
Join Date: Sep 2012
Posts: 219
Received Thanks: 123
Quote:
Originally Posted by derwahrehuy View Post
wofür dient das?
if you're asking this that means it's not for you

€dit:

Quote:
Originally Posted by .Osiris View Post
To avoid some if/else controls:

PHP Code:
def SetPercentage(selfnum):
    
self.percentage max(0num)
    
self.percentage min(100num
Code:
>>> def Prcntage(num):
	axx=None

	axx=max(0, num)
	axx=min(100, num)
	return axx

>>> Prcntage(-150)
-150
>>> Prcntage(150)
100
Eigenartig is offline  
Old 10/04/2014, 17:51   #7
 
elite*gold: 0
Join Date: Jan 2014
Posts: 4
Received Thanks: 8
Quote:
Originally Posted by Eigenartig View Post

€dit:



Code:
>>> def Prcntage(num):
	axx=None

	axx=max(0, num)
	axx=min(100, num)
	return axx

>>> Prcntage(-150)
-150
>>> Prcntage(150)
100
Oh i'm sorry, of course this won't work this way

Here's the working version:

PHP Code:
def Prcntage(num):
    
axx max(0num)
    
axx min(100axx)
    return 
axx 
.Osiris is offline  
Old 10/04/2014, 18:47   #8
 
Eigenartig's Avatar
 
elite*gold: 0
Join Date: Sep 2012
Posts: 219
Received Thanks: 123
wait a sec...

Code:
	def SetPercentage(self, num):
		self.percentage = min(xrange(101), key=lambda x:abs(x-num))
btw it's DaRealFreak's solution
Eigenartig is offline  
Reply


Similar Threads Similar Threads
»UpRise« sucht für HC-Semi-Progress und Mythic-Progress
07/18/2014 - World of Warcraft - 0 Replies
Aktualisiert am 18.07.2014 »UpRise« sucht für HC-Semi-Progress und WoD-Mythic-Progress Halt! Du hast auf diesen Beitrag geklickt und nun, da du schon mal hier bist, nehme dir doch kurz die Zeit und lese was hier niedergeschrieben steht. Immerhin wissen wir doch alle, dass das Glück manchmal ganz unverhofft kommt. Wer wir sind? Im Mai 2014 wurde die Gilde »UpRise« von einigen Progressraidern gegründet. Das Ziel war von Anfang an klar gesteckt: Den aktuellen Content bestreiten! Und...
[Release]In-Progress Page by Brainfck (psd)
03/29/2014 - Metin2 PServer Designs, Websites & Scripts - 9 Replies
Hallo, Ich habe mir mal die Zeit genommen ( reine Langeweile ) und habe eine In-Progress auffang Page erstellt für euren Server,bis jetzt nur als PSD ich werde aber einen Scripter dafür suchen :). Das schwarze Feld unten Rechts dient als "Intro" dort könnt ihr dann einen Youtube Video einbinden. Das Logo ist nicht änderbar wer es dennoch in der Grafik haben möchte kann mich anschreiben es ist mit Cinema 4D erstellt worden. Das Logo kann man aber einfach Löschen und sein eigenes rein...
[DarknessFight - Testserver] Our Progress (No Release!)
03/20/2012 - Rappelz Private Server - 369 Replies
http://darknessfight.com/style/images/dflogo.png Heyho, Well, since NCarbon disbanded for a reason you all should know (I don't want to speak about it), we (The DarknessFight-Developerteam -> Xijezu, Raskim, wisp66 & Nikster) still were working on a lot of new things. What we gonna show you? Imports from 7.4 Staged Pet System



All times are GMT +1. The time now is 02:39.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.