예제 #1
0
	def draw(self,screen):
		#print str(self.active_x)
		for item in self.data:
			itemid = item[0]
			if self.positions[itemid][2] == self.page:
				x = self.positions[itemid][0]
				y = self.positions[itemid][1]
				start_x = self.borders + (x-1)*self.menu_size_x + (x-1)*self.gap_x
				start_y = self.borders + (y-1)*self.menu_size_y + (y-1)*self.gap_y
				screen.blit(self.menu_img,(start_x,start_y))
				if (x==self.active_x and y==self.active_y):
					screen.blit(self.menu_img_selected,(start_x,start_y))
				use_icon = item[4]
				icon = item[3]
				if (use_icon):
					ico_start_x = 0.5*(self.menu_size_x-icon.get_width())+start_x
					ico_start_y = 0.5*(self.menu_size_y-icon.get_height())+start_y
					screen.blit(icon,(ico_start_x,ico_start_y))
				title=item[1]
				font = pygame.font.Font(None, 20)
				text = fonts.textOutline(font,title,[10,10,10],[255,255,255])
				#text = font.render(title, True, [0,0,0])
				textRect = text.get_rect()
				textRect.x = start_x + 0.5*(self.menu_size_x-textRect.width)
				textRect.y = start_y + self.menu_size_y - 1.5*textRect.height
				screen.blit(text, textRect)
예제 #2
0
	def __init__(self):
		print "Starting Menu"
		self.fail=False
		#Should read settings first
		self.get_settings()

		if self.settings.get('useJoystick') not in self.settings.false():
			self.joy=joystick.Joystick()
			if (self.joy.errors!=[]):
				for error in self.joy.errors:
					print error
					self.use_joystick=False
			else:
				self.use_joystick=True
		else:
			print "Ignoring any joystick due useJoystick in properties"
			self.use_joystick=False
			
		self.menuEntries = menuEntry.MenuEntry(self.num_entries_x,self.num_entries_y)
		self.menuEntries.settings(self.borders,self.gap_x,self.gap_y,self.menu_size_x,self.menu_size_y)
		self.readMenuFile()
		self.menuOutOfDate=False
		self.menuEntries.defined()
		if (self.settings.get('use_sound')):
			self.setupSounds()
		if (os.path.exists(self.settings.get('image_dir')+"/background.jpg")):
			self.background = pygame.image.load(os.path.join(self.settings.get('image_dir'),"background.jpg"))
			self.background = pygame.transform.scale(self.background,(self.screen_size_x,self.screen_size_y))
			self.use_background=True
		else:
			self.use_background = False
		self.init_filewatcher()
		iptool = netutils.ip_tool()
		self.ip = iptool.get_ip()
		print "Detected IP as", self.ip
		self.qrip = qr.QRImage('http://'+self.ip)
		self.qrip.prepare()
		pygame.init()
		font = pygame.font.Font(None, 20)
		self.iptext = fonts.textOutline(font,"To configure games go to "+self.ip+" or use the QR code.",[10,10,10],[255,255,255])

		
		# Set the height and width of the screen
		size=[self.screen_size_x,self.screen_size_y]
		#self.screen=pygame.display.set_mode(size,pygame.NOFRAME)
		if self.settings.get('fullscreen') in self.settings.true():
			self.screen=pygame.display.set_mode(size,pygame.FULLSCREEN|pygame.NOFRAME)
		else:
			self.screen=pygame.display.set_mode(size,pygame.NOFRAME)
		pygame.display.set_caption("GameMenu")
		# Used to manage how fast the screen updates
		self.clock=pygame.time.Clock()