Exemplo n.º 1
0
	def __init__(self,
		rotated = False,
		width = 218,
		height = 58,
		bgcolor = COLOR_BG,
		bordercolor = COLOR,
		hoverbordercolor = COLOR_HOVER,
		borderwidth = 1,
		parent = None):
		
		colors = [(0xfce94f, 0xedd400, 0xc4a000),\
				  (0xfcaf3e, 0xf57900, 0xce5c00),\
				  (0xe9b96e, 0xc17d11, 0x8f5902),\
				  (0x8ae234, 0x73d216, 0x4e9a06),\
				  (0x729fcf, 0x3465a4, 0x204a87),\
				  (0xad7fa8, 0x75507b, 0x5c3566),\
				  (0xef2929, 0xcc0000, 0xa40000),\
				  (0xeeeeec, 0xd3d7cf, 0xbabdb6),\
				  (0x888a85, 0x555753, 0x2e3436)]
			
		self.rotated = rotated
		if rotated == True:
			width, height = height, width
		Frame.__init__(self, width, height, bgcolor, bordercolor, hoverbordercolor, borderwidth, parent)
		
		self.setPalette(colors)
Exemplo n.º 2
0
	def __init__(self,
		name = "Window",
		width = 80,
		height = 60,
		bgcolor = COLOR_BG,
		bordercolor = COLOR,
		hoverbordercolor = COLOR_HOVER,
		borderwidth = 1,
		parent = None,
		gui = None):
		
		Frame.__init__(self, width, height, bgcolor, bordercolor, hoverbordercolor, borderwidth, parent)
		self.gui = gui
		
		self.name = Label(name, width = width-21, bgcolor = COLOR_BG, borderwidth = 1, parent = self)
		self.name.setPos(0, 0)
		
		self.close_button = ImgButton(self.w-20, 0, 20, 20,
			"graphics/gui/guibase.png", 1,49,1,70,
			parent=self)
		self.close_button.setPos(self.w-20, 0)
		self.close_button.bind(self.hide)
		
		self.drag_button = ImgButton(self.w-20, 0, 20, 20,
			"graphics/gui/guibase.png", 22,49,22,70,
			parent=self)
		self.drag_button.setPos(self.w-20, self.h-20)
		
		
		
		self.click = False
		self._resize = False
Exemplo n.º 3
0
 def updateSurface(self):
     Frame.updateSurface(self)
     self.surface.blit(
         self.msg,
         (
             self.msgRect.left + self.padding,
             self.msgRect.top + self.padding,
             self.msgRect.width,
             self.msgRect.height,
         ),
     )
Exemplo n.º 4
0
    def __init__(
        self,
        text="OK",
        font=FONT,
        width=0,
        height=0,
        bgcolor=(0, 0, 0),
        bordercolor=(255, 255, 255),
        hoverbordercolor=(255, 255, 255),
        borderwidth=1,
    ):
        Frame.__init__(self, width, height, bgcolor, bordercolor, hoverbordercolor, borderwidth=1)

        self.baseText = text
        self.padding = 5
        self.font = font

        self.setText(self.baseText)
Exemplo n.º 5
0
	def __init__(self,
		minvalue = 0,
		maxvalue = 100,
		barcolor = (50,200,100),
		image = None,
		width = 100,
		height = 10,
		bgcolor = (0,0,0),
		bordercolor = (200,200,200),
		hoverbordercolor = (255,255,255),
		borderwidth = 1,
		parent = None):
		
		Frame.__init__(self, width, height, bgcolor, bordercolor, hoverbordercolor, borderwidth, parent)
		self.barcolor = barcolor
		self.minvalue = minvalue
		self.value = self.maxvalue = maxvalue
		self.image = image
		if image:
			#print 'set renderer as image'
			self.render = self.drawImage
		else:
			self.render = self.drawRect
Exemplo n.º 6
0
	def __init__(self, game):
		self.game = game
		self.screen = self.game.screen
		
		guilayout = BaseLayouter('vertical')
		toplayout = BaseLayouter()
		
		separator = Widget(0,0,0,SCREEN_HEIGHT-140)
		#print "Screen : %s %s" % (SCREEN_WIDTH, SCREEN_HEIGHT)
		#print "creating chatwindow from clientGui : %s, %s, %s, %s" % (0,SCREEN_HEIGHT*4/5.0,SCREEN_WIDTH,SCREEN_HEIGHT/5.0)
		self.chatWindow = ChatWindow(0,SCREEN_HEIGHT*4/5.0,SCREEN_WIDTH,SCREEN_HEIGHT/5.0, gui=self)
		
		self.emoteEngine = EmoteEngine(SCREEN_WIDTH-21,2, gui=self)
		
		self.configwindow = ConfigWindow(100,100, gui=self)
		
		self.menubutton = ShowFrameButton(text='Configuration:Configuration', widget = self.configwindow)
		self.chatbutton = ShowFrameButton(text='ChatWindow:ChatWindow', widget = self.chatWindow)
		
		self.barFrame = Frame(SCREEN_WIDTH/2, 40)
		self.barFrame.setPos(220, 2)
		
		
		self.hpbar = ProgressBar(0,100, width = 100, image = ImgDB["graphics/gui/progressbars.png"].subsurface(0,0,96,6), parent=self.barFrame)
		self.hpbar.setValue(1)
		
		#somehow seems that this is not shown without the width set to framesize -1... weird thing to be checked ...
		self.mpbar = ProgressBar(0,100, width = 100, image = ImgDB["graphics/gui/progressbars.png"].subsurface(0,5,96,6), parent=self.barFrame)
		self.mpbar.setValue(1)
		
		self.barFrame.autolayout()
		
		guilayout.add(toplayout)
		guilayout.add(separator)
			
		toplayout.add(self.menubutton, 2)
		toplayout.add(self.chatbutton, 2)
		guilayout.fit()
Exemplo n.º 7
0
	def updateSurface(self):
		percentage = self._getPercentage()
		length = max(int(percentage*self.width)-2*self.borderWidth-2, 0)
		Frame.updateSurface(self)
		self.render(length)
Exemplo n.º 8
0
class GameGUI(object):
	def __init__(self, game):
		self.game = game
		self.screen = self.game.screen
		
		guilayout = BaseLayouter('vertical')
		toplayout = BaseLayouter()
		
		separator = Widget(0,0,0,SCREEN_HEIGHT-140)
		#print "Screen : %s %s" % (SCREEN_WIDTH, SCREEN_HEIGHT)
		#print "creating chatwindow from clientGui : %s, %s, %s, %s" % (0,SCREEN_HEIGHT*4/5.0,SCREEN_WIDTH,SCREEN_HEIGHT/5.0)
		self.chatWindow = ChatWindow(0,SCREEN_HEIGHT*4/5.0,SCREEN_WIDTH,SCREEN_HEIGHT/5.0, gui=self)
		
		self.emoteEngine = EmoteEngine(SCREEN_WIDTH-21,2, gui=self)
		
		self.configwindow = ConfigWindow(100,100, gui=self)
		
		self.menubutton = ShowFrameButton(text='Configuration:Configuration', widget = self.configwindow)
		self.chatbutton = ShowFrameButton(text='ChatWindow:ChatWindow', widget = self.chatWindow)
		
		self.barFrame = Frame(SCREEN_WIDTH/2, 40)
		self.barFrame.setPos(220, 2)
		
		
		self.hpbar = ProgressBar(0,100, width = 100, image = ImgDB["graphics/gui/progressbars.png"].subsurface(0,0,96,6), parent=self.barFrame)
		self.hpbar.setValue(1)
		
		#somehow seems that this is not shown without the width set to framesize -1... weird thing to be checked ...
		self.mpbar = ProgressBar(0,100, width = 100, image = ImgDB["graphics/gui/progressbars.png"].subsurface(0,5,96,6), parent=self.barFrame)
		self.mpbar.setValue(1)
		
		self.barFrame.autolayout()
		
		guilayout.add(toplayout)
		guilayout.add(separator)
			
		toplayout.add(self.menubutton, 2)
		toplayout.add(self.chatbutton, 2)
		guilayout.fit()
		

	def handleEvents(self, events=[]):
		self.chatWindow.handleEvents(events)
		
		for event in events:
			if event.type == pygame.KEYDOWN:
				key = event.key
				if key == pygame.K_RETURN:
					if self.chatWindow.entry.has_focus:
						if len(self.chatWindow.entry.baseText)>0:
							self.game.SendMessagePublic(self.chatWindow.entry.baseText)
							self.chatWindow.entry.setText("")
							self.chatWindow.entry.loseFocus()
						else:
							self.chatWindow.entry.loseFocus()
					else:
						self.chatWindow.entry.getFocus()
				self.chatWindow.updateSurface()
			
		emote = self.emoteEngine.handleEvents(events)
		if emote > -1:
			self.game.SendEmote(emote)
			
		self.menubutton.handleEvents(events)
		self.chatbutton.handleEvents(events)
		self.configwindow.handleEvents(events)
		
	def blit(self):
		self.chatWindow.blit(self.screen)
		
		self.emoteEngine.blit(self.screen)
		
		#hpbar test
		self.hpbar.add(1)
		self.mpbar.add(1)
		self.barFrame.updateSurface()
		self.barFrame.blit(self.screen)
		#self.hpbar.blit(self.screen)

		#self.mpbar.blit(self.screen)
		
		self.menubutton.blit(self.screen)
		self.chatbutton.blit(self.screen)
		
		self.configwindow.blit(self.screen)