Ejemplo n.º 1
0
    def redraw(self):
        """ Re-calculate what items are where """
        for item in self.items:
            # Remove any existing images
            self._remove_widget(item)

        self.items = []

        if self.inventory is not None:  # The inventory is None in the swap screen
            for grid_id, (item_id,
                          item_amount) in self.inventory._items.items():
                pos = self.inventory.get_pos(grid_id)

                icon = './data/textures/inventory_icons/' + Item.items[
                    item_id].icon
                size = Item.items[item_id].size
                item = bgui.Image(self,
                                  'item_' + str(grid_id),
                                  img=icon,
                                  size=[size[0] * 50, size[1] * 50],
                                  pos=[pos[0] * 50, pos[1] * 50],
                                  options=bgui.BGUI_NONE)
                if self.inventory.primary_weapon and grid_id == self.inventory.primary_weapon.grid_id:
                    bgui.Frame(item,
                               'frame__' + str(grid_id),
                               size=[1, 1],
                               pos=[0, 0],
                               sub_theme='equip')

                # display the number of items in the stack, and give it a shadow
                item.label1 = bgui.Label(item,
                                         'amount1',
                                         str(item_amount),
                                         pos=[6, 4],
                                         sub_theme='inventory_amount_shadow',
                                         options=bgui.BGUI_THEMED)
                item.label2 = bgui.Label(item,
                                         'amount2',
                                         str(item_amount),
                                         pos=[5, 5],
                                         sub_theme='inventory_amount',
                                         options=bgui.BGUI_THEMED)

                # Assign item data
                item.item_id = item_id
                item.grid_id = grid_id
                item.item_amount = item_amount
                item.item_size = size
                item.item_name = Item.items[item_id].name
                item.item_description = Item.items[item_id].description

                # Setup event callbacks
                item.on_hover = self.handle_item_hover
                item._handle_mouse_exit = self.handle_item_exit
                item._handle_click = self.handle_item_click
                item._handle_release = self.handle_item_release

                self.items.append(item)

        self.remove_context_menu()
Ejemplo n.º 2
0
    def __init__(self,
                 parent,
                 name,
                 aspect=None,
                 text='Click me',
                 shadow=[-2, 2],
                 size=[1, 1],
                 pos=[0, 0],
                 sub_theme='',
                 image='./data/textures/ui/fut_menu_active.png',
                 options=bgui.BGUI_THEMED):
        bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme,
                             options)

        csize = self.size[1] * .3
        self.image_back = bgui.Image(self,
                                     'image_back',
                                     './data/textures/ui/fut_menu.png',
                                     pos=[0, 0],
                                     size=[1, 1],
                                     options=bgui.BGUI_CACHE
                                     | bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED)
        self.image = bgui.Image(self,
                                'back',
                                image,
                                pos=[0, 0],
                                size=[1, 1],
                                options=bgui.BGUI_CACHE | bgui.BGUI_DEFAULT
                                | bgui.BGUI_CENTERED)
        self.image_back.texco = [(.003, .003), (.999, .003), (.999, .999),
                                 (.003, .999)]
        self.image.texco = self.image_back.texco
        self.image.visible = 0
        self.image_back.color = [.4, .7, .9, .5]
        self.image.color = [.4, .7, .9, .5]

        self.text1 = bgui.Label(self,
                                'text1',
                                text=text,
                                pt_size=18,
                                color=[0, 0, 0, 1],
                                pos=[7, self.size[1] - 23],
                                font='./data/fonts/olney_light.otf',
                                options=bgui.BGUI_NONE)
        off = [
            self.text1.position[0] + shadow[0] - self.position[0],
            self.text1.position[1] + shadow[1] - self.position[1]
        ]
        self.text2 = bgui.Label(self,
                                'text2',
                                text=text,
                                pos=off,
                                pt_size=18,
                                color=[1, 1, 1, 1],
                                font='./data/fonts/olney_light.otf',
                                options=bgui.BGUI_NONE)

        self.active = 0
        self.sound_played = 0
Ejemplo n.º 3
0
	def display_dialogue(self, text):
		""" Format text to fit into dialogue box """
		self.visible = True
		self.done = False
		self.top = 0
		self.more_button.text = 'More'

		for line in self.lines:
			self._remove_widget(line)

		self.lines = []

		lines = text.split('\n')
		i = 0

		# If there is a name set, add the name
		if self.name != '':
			self.lines.append(bgui.Label(self, 'line_0', text=self.name, pos=[MessageBox.PADDING,
				self.size[1] - (i + 1) * self.char_height - MessageBox.PADDING], sub_theme='message_box_name',
				options=bgui.BGUI_THEMED))
			i += 1

		# Now add the dialogue
		for line in lines:
			words = line.split(' ')

			line = bgui.Label(self, 'line_' + str(i), '', pos=[MessageBox.PADDING,
				self.size[1] - (i + 1) * self.char_height - i * MessageBox.LINE_PADDING - MessageBox.PADDING],
				sub_theme='message_box', options=bgui.BGUI_THEMED)

			while words:
				# try to add a word
				line.text += ' ' + words[0]

				if line.size[0] + MessageBox.PADDING * 2 > self.size[0] - MessageBox.PADDING * 2 - 10:
					# the line is too big, add the remaining words to a new line
					line.text = line.text[0:-len(words[0])]  # remove the last word
					self.lines.append(line)
					i += 1
					line = bgui.Label(self, 'line_' + str(i), '', pos=[MessageBox.PADDING,
						self.size[1] - (i + 1) * self.char_height - i * MessageBox.LINE_PADDING - MessageBox.PADDING],
						sub_theme='message_box', options=bgui.BGUI_THEMED)
				else:
					# the word fits
					words.pop(0)

			self.lines.append(line)
			i += 1

		# resize scrollbar
		self.scrollbar.slider_size = (self.scrollbar.size[1] / ((i) * self.char_height + (i - 1) * MessageBox.LINE_PADDING)) * self.scrollbar.size[1]
		self.scrollbar.slider_position = self.scrollbar.size[1] - self.scrollbar.slider_size
		if self.scrollbar.slider_size == self.scrollbar.size[1]:
			self.scrollbar.visible = False
		else:
			self.scrollbar.visible = True

		self.handle_overflow()
Ejemplo n.º 4
0
	def __init__(self, parent):
		super().__init__(parent, 'screen_loading')

		self.frame = bgui.Frame(self, 'frame', size=[1,1], pos=[0,0])
		self.frame.colors = [[0,0,0,0]] * 4

		self.label = bgui.Label(self, 'label', text="Loading...", color=[1,1,0,0], sub_theme='Large',
			options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED)

		self.output = bgui.Label(self, 'output', text='', pos=[0,0.5])

		self.fade_out = False
Ejemplo n.º 5
0
    def __init__(self, parent, name):
        super().__init__(parent, name, blocking=True)

        ww = parent.size[0]
        wh = parent.size[1]

        # a frame to darken the game screen
        self.backdrop = bgui.Frame(self, 'backdrop', size=[1, 1], pos=[0, 0])
        self.backdrop.colors = [(0, 0, 0, 0.55)] * 4

        self.player_inventory = ui.InventoryWindow(
            self,
            'player_inventory',
            game.Game.singleton.world.player.inventory,
            pos=[ww // 2 - 310, 0],
            options=bgui.BGUI_CENTERY)

        self.other_inventory = ui.InventoryWindow(self,
                                                  'other_inventory',
                                                  None,
                                                  pos=[ww // 2 + 10, 0],
                                                  options=bgui.BGUI_CENTERY)

        self.player_label = bgui.Label(self,
                                       'player_label',
                                       'Player',
                                       pt_size=48,
                                       color=[1, 1, 1, 1],
                                       font='./data/fonts/olney_light.otf',
                                       pos=[ww // 2 - 310, wh // 2 + 220 + 10],
                                       options=bgui.BGUI_NONE)
        self.other_label = bgui.Label(self,
                                      'other_label',
                                      '',
                                      pt_size=48,
                                      color=[1, 1, 1, 1],
                                      font='./data/fonts/olney_light.otf',
                                      pos=[ww // 2 + 10, wh // 2 + 220 + 10],
                                      options=bgui.BGUI_NONE)

        self.return_but = ui.Fut_Button(
            self,
            'return',
            pos=[ww // 2 + 320 - 182, wh // 2 - 210 - 45 - 10],
            size=[182, 45],
            text="BACK",
            options=bgui.BGUI_NONE)
        self.return_but.on_click = self.return_
        self.tweener = tweener.TweenManager()
        self.hook = 0.0  # for tweener
Ejemplo n.º 6
0
    def __init__(self, sys, data):
        super().__init__(sys, data)
        monnom, monip, self.own = data
        # ajout d'une image
        self.img = bgui.Image(self,
                              'img.jpg',
                              size=[.5, .4],
                              pos=[.05, .5],
                              options=bgui.BGUI_DEFAULT)

        # ajout d'un listbox
        self.block = bgui.ListBox(self,
                                  items=['banane', 'pomme', 'orange', 'poire'],
                                  size=[0.4, 0.6],
                                  pos=[0.6, 0.3])

        # ajout d'etiquette
        self.lbl = bgui.Label(self,
                              text="Liste des participants inscrits",
                              pos=[0.6, 0.9],
                              sub_theme='Large',
                              options=bgui.BGUI_DEFAULT)
        # ajout de bouton
        self.btndemarre = bgui.FrameButton(self,
                                           text='Demarrer la simulation',
                                           size=[.25, .06],
                                           pos=[.6, .14],
                                           options=bgui.BGUI_DEFAULT)
        if bge.c.egoserveur != 1:
            self.btndemarre.frozen = 1

        self.btndemarre.on_click = self.on_demarre_simulation
Ejemplo n.º 7
0
	def __init__(self, parent, name, aspect=None, size=[1, 1], pos=[0, 0],
				sub_theme='', options=bgui.BGUI_DEFAULT):
		bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme, options)
		area = self.parent.image_back
		self.frame = bgui.Frame(self, 'frame', pos=area.position, size=area.size, options=bgui.BGUI_CENTERX)
		self.frame.colors = [[0, 0, 0, 0]] * 4

		self.back1 = Fut_Box(self.frame, 'back1', pos=[250, 0], size=[500, 450], options=bgui.BGUI_NONE)
		self.back1.border = 0
		blurb = ""
		self.lbl = bgui.Label(self.back1, 'label', text=blurb, pt_size=18, pos=[10, 100], options=bgui.BGUI_THEMED)
		self.button = Fut_Button(self.back1, 'button', text='NEW GAME', size=[182, 45], pos=[10, 400],
				options=bgui.BGUI_NONE)
		self.button.on_click = self.start_game
		self.input = Fut_Input(self.back1, 'input', text=game.Game.singleton.default_cell, size=[160, 30], pos=[230, 410],
				options=bgui.BGUI_NONE)
		self.button2 = Fut_Button(self.back1, 'button2', text='LOAD GAME', size=[182, 45], pos=[10, 300],
				options=bgui.BGUI_NONE)
		# Setup an on_click callback for the image
		self.button2.on_click = self.load_game
		self.input2 = Fut_Input(self.back1, 'input2', text="default.sav", size=[160, 30], pos=[230, 320],
				options=bgui.BGUI_NONE)

		self.button3 = Fut_Button(self.back1, 'button3', text='SAVE GAME', size=[182, 45], pos=[10, 200],
				options=bgui.BGUI_NONE)
		# Setup an on_click callback for the image
		self.button3.on_click = self.save_game
		self.input3 = Fut_Input(self.back1, 'input3', text="default.sav", size=[160, 30], pos=[230, 220],
				options=bgui.BGUI_NONE)
Ejemplo n.º 8
0
    def __init__(self,
                 parent,
                 name,
                 aspect=None,
                 size=[1, 1],
                 pos=[0, 0],
                 sub_theme='',
                 options=bgui.BGUI_DEFAULT):
        bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme,
                             options)

        theme = self.theme[self.theme_section] if self.theme else None

        self.bg = bgui.Frame(self,
                             'background',
                             size=[1, 1],
                             pos=[0, 0],
                             options=bgui.BGUI_DEFAULT)
        self.bg.colors = [(0, 0, 0, 1) for i in range(4)]
        self.win = bgui.Frame(self,
                              'win',
                              size=[741, 450],
                              pos=[0, 700],
                              options=bgui.BGUI_THEMED | bgui.BGUI_CENTERED)
        self.win.img = bgui.Image(self.win,
                                  'image',
                                  safepath('./data/textures/nt.png'),
                                  size=[731, 235],
                                  pos=[5, 210],
                                  options=bgui.BGUI_THEMED | bgui.BGUI_CENTERX
                                  | bgui.BGUI_CACHE)

        self.button = bgui.FrameButton(self.win,
                                       'button',
                                       text='ENTER GAME',
                                       size=[110, 30],
                                       pos=[100, 120],
                                       options=bgui.BGUI_THEMED)
        # Setup an on_click callback for the image
        self.button.on_click = self.start_game

        blurb = "NOVUS TERRA : Alpha v0.2 : Thanks for waiting!"
        self.lbl = bgui.Label(self.win,
                              'label',
                              text=blurb,
                              pos=[100, 180],
                              options=bgui.BGUI_THEMED)
        #tweener.singleton.add(self, 'color', '[*,*,*,1]', length=2.0)

        self.input = bgui.TextInput(self.win,
                                    'input',
                                    "dynamic.cell",
                                    size=[160, 30],
                                    pos=[220, 120],
                                    pt_size=32,
                                    input_options=bgui.BGUI_INPUT_SELECT_ALL,
                                    options=bgui.BGUI_THEMED)
        #self.input.activate()
        self.input.on_enter_key = self.on_input_enter
Ejemplo n.º 9
0
    def __init__(self, parent, name):
        super().__init__(parent, name, blocking=False)

        self.interact_label = bgui.Label(self,
                                         'interact_label',
                                         '',
                                         pos=[0.5, 0.8],
                                         sub_theme='interact',
                                         options=bgui.BGUI_DEFAULT
                                         | bgui.BGUI_CENTERX)
        self.interact_icon = bgui.Image(self, 'interact_icon', None)
Ejemplo n.º 10
0
    def __init__(self):
        # Initialize the system
        bgui.System.__init__(self)
        self.clear_time = time.time()
        self.note_visible = False

        self.frame = bgui.Frame(self,
                                aspect=(4 / 3),
                                options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED)
        self.frame.visible = False
        # Create the note
        self.note = bgui.Frame(self,
                               border=1,
                               size=[.25, .25],
                               pos=[0.7, -0.3],
                               options=bgui.BGUI_DEFAULT)
        self.note.colors = [[0, 0, 1, 0.5]] * 4
        self.note_hdr = bgui.Label(self.note,
                                   text="Notification:",
                                   pt_size=42,
                                   pos=[0.05, 0.8])
        self.note_msg = bgui.Label(self.note,
                                   text="The button was clicked!",
                                   pos=[0.1, 0],
                                   options=bgui.BGUI_DEFAULT
                                   | bgui.BGUI_CENTERY)

        # Create the button
        self.button = bgui.FrameButton(self,
                                       text='Click Me!',
                                       size=[0.4, 0.2],
                                       pos=[0.3, 0.4])
        self.button.on_click = self.display_note

        # Create a keymap for keyboard input
        self.keymap = {
            getattr(bge.events, val): getattr(bgui, val)
            for val in dir(bge.events)
            if val.endswith('KEY') or val.startswith('PAD')
        }
Ejemplo n.º 11
0
    def __init__(self,
                 parent,
                 name,
                 aspect=None,
                 text='item name',
                 image='./data/textures/ui/blur.png',
                 shadow=[-2, 2],
                 size=[1, 1],
                 pos=[0, 0],
                 sub_theme='',
                 options=bgui.BGUI_THEMED):
        Nbutton.__init__(self,
                         parent,
                         name,
                         aspect,
                         image=image,
                         size=size,
                         pos=pos,
                         sub_theme=sub_theme,
                         options=options)
        self.image.visible = 1
        self._remove_widget(self.text1)
        self._remove_widget(self.text2)
        self.text1 = bgui.Label(self,
                                'text1',
                                text=text,
                                pt_size=14,
                                color=[1, 1, 1, 1],
                                font='./data/fonts/olney_light.otf',
                                options=bgui.BGUI_CENTERX)
        self.text1.position = [0, 6]

        self.amount = bgui.Label(self,
                                 'amount',
                                 text="",
                                 pt_size=32,
                                 color=[1, .9, 0, 1],
                                 pos=[self.size[0] * .5, self.size[0] * .75],
                                 font='./data/fonts/olney_light.otf',
                                 options=bgui.BGUI_NONE)
Ejemplo n.º 12
0
    def __init__(self, sys, data):
        super().__init__(sys, data)
        monnom,monip,self.own=data
        # ajout d'une image
        self.img = bgui.Image(self, 'splash.jpg', size=[.9, .7], pos=[.01, .3],
            options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)
        
        # ajout d'etiquette
        self.lbl = bgui.Label(self, text="Votre nom", pos=[0.1, 0.25],
            sub_theme='Large', options = bgui.BGUI_DEFAULT )
        self.lbl = bgui.Label(self, text="IP du serveur", pos=[0.1, 0.15],
            sub_theme='Large', options = bgui.BGUI_DEFAULT)
        self.lbl = bgui.Label(self, text="IP du client", pos=[0.1, 0.05],
            sub_theme='Large', options = bgui.BGUI_DEFAULT)

        # ajout de bouton
        self.btnserveur = bgui.FrameButton(self, text='Creer un serveur', size=[.25, .06], pos=[.6, .14],
            options = bgui.BGUI_DEFAULT)

        self.btnserveur.on_click = self.on_click_serveur
        
        # un autre bouton
        self.btnclient = bgui.FrameButton(self, text='Creer un client', size=[.25, .06], pos=[.6, .03],
            options = bgui.BGUI_DEFAULT)

        self.btnclient.on_click = self.on_click_client

        # ajout de champs de texte
        self.inNom = bgui.TextInput(self, text=monnom, size=[.4, .04], pos=[.3, 0.24],
            input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)
        self.inNom.activate()
        
        # on aurait pu utiliser un Label (statique)
        self.inIPcreeServeur = bgui.TextInput(self, text=monip, size=[.4, .04], pos=[.3, 0.14],
            input_options = bgui.BGUI_INPUT_SELECT_ALL, options = bgui.BGUI_DEFAULT)
        self.inIPcreeServeur.frozen=1

        self.inIPconnecteClient= bgui.TextInput(self, text=monip, size=[.4, .04], pos=[.3, 0.04],
            options = bgui.BGUI_DEFAULT)
Ejemplo n.º 13
0
	def __init__(self, viewport):
		# Initialize the system
		bgui.System.__init__(self, '../../themes/default')
		
		# viewport = [x, y, width, height]		
		# Use a frame to store all of our widgets
		self.frame = bgui.Frame(self, border=0, size=viewport[2:], pos=viewport[:2])
		self.frame.colors = [(0, 0, 0, 0)] * 4

		# A themed frame
		self.win = bgui.Frame(self.frame, size=[0.6, 0.8],
			options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)
			
		# Create an image to display
		self.win.img = bgui.Image(self.win, 'img.jpg', size=[.92, .7], pos=[.01, .24],
			options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE)
		
		# A button
		self.button = bgui.FrameButton(self.win, text='Click Me!', size=[.14, .09], pos=[.815, .03],
			options = bgui.BGUI_DEFAULT)
		# Setup an on_click callback for the image
		self.button.on_click = self.on_img_click

		# Add a label
		self.lbl = bgui.Label(self.frame, text="I'm a label!", pos=[0, 0.9],
			sub_theme='Large', options = bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
		
		# A couple of progress bars to demonstrate sub themes
		self.progress = bgui.ProgressBar(self.win, percent=0.0, size=[0.92, 0.06], pos=[.2, 0.17],
											sub_theme="Progress", options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
											
		self.health = bgui.ProgressBar(self.win, percent=0.5, size=[0.92, 0.02], pos=[0, 0.14],
											sub_theme="Health",	options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX)
			
		# A few TextInput widgets
		self.input = bgui.TextInput(self.win, text="I'm active.", font="myfont.otf", size=[.4, .04], pos=[.04, 0.02],
			input_options = bgui.BGUI_INPUT_NONE, options = bgui.BGUI_DEFAULT)
		self.input.activate()
		self.input.on_enter_key = self.on_input_enter
		
		self.input2 = bgui.TextInput(self.win, text="I select all when activated.", size=[.4, .04], pos=[.04, 0.08],
			input_options = bgui.BGUI_INPUT_SELECT_ALL, options = bgui.BGUI_DEFAULT)
		
		# A counter property used for the on_img_click() method
		self.counter = 0
		
		# Create a keymap for keyboard input
		self.keymap = {getattr(bge.events, val): getattr(bgui, val) for val in dir(bge.events) if val.endswith('KEY') or val.startswith('PAD')}
		
		# Now setup the scene callback so we can draw
		bge.logic.getCurrentScene().post_draw.append(self.render)
Ejemplo n.º 14
0
	def __init__(self, parent, name, items=[], pos=[0, 0], sub_theme=''):
		""" Items is a tuple of (label, callable) pairs """

		super().__init__(parent, name, size=[1, 1], pos=pos)

		PADDING = 10

		self.lines = []
		for i, item in enumerate(items):
			line = bgui.Label(self, 'line_' + str(i), item[0], sub_theme='context_menu')
			line.action = item[1]
			self.lines.append(line)

		# Get the max width and height any line
		height = 0
		width = 0
		for line in self.lines:
			if line.size[0] > width:
				width = line.size[0]
			if line.size[1] > height:
				height = line.size[1]

		ww = self.parent.size[0]
		wh = self.parent.size[1]

		# Reposition everything based on the new max width and height values
		self.size = [(width + PADDING * 2) / ww, (0 + (height + PADDING) * len(self.lines)) / wh]
		self.position[1] -= self.size[1]

		# A frame to store the lines in
		self.frame = bgui.Frame(self, 'frame', size=[1, 1], pos=[0, 0], sub_theme='context_menu')

		# A cursor for highlighting the line the mouse is over
		self.cursor = bgui.Frame(self, 'cursor', size=[self.size[0] - 4, self.size[1] / len(self.lines) - 4],
			pos=[2, 0], sub_theme='context_menu_cursor', options=bgui.BGUI_THEMED)

		# The following is done here because the size of each line had
		# to be determined before positioning could happen
		for i, line in enumerate(self.lines[::-1]):
			# Bring each line to the front
			self._remove_widget(line)
			self._attach_widget(line)

			# Position each line
			line.position = [PADDING / self.size[0], (PADDING / 2 + i * (height + PADDING)) / self.size[1]]
Ejemplo n.º 15
0
	def __init__(self, parent):
		super().__init__(parent, 'console', size=[1,1])
		self.frozen = True
		self.z_index = 1000000000
		
		self.frame = bgui.Frame(self, 'window', border=0)
		self.frame.colors = [(0, 0, 0, 0) for i in range(4)]
		self.frame.z_index = 0

		self.bg = bgui.Frame(self, 'bg', border=0)
		self.bg.colors = [(0, 0, 0, 0.5) for i in range(4)]
		self.bg.z_index = -1

		self.bg.size = [0, 0]
		self.bg.position = [0, 0.999]

		self.label = bgui.Label(self.frame, "label", text="", font=logic.expandPath("//UbuntuMono-B.ttf"), pt_size=29, pos=[0, 0], options=bgui.BGUI_DEFAULT)

		self.next_text = ""
Ejemplo n.º 16
0
	def __init__(self, parent):
		super().__init__(parent, 'screen_pause', blocking=True)

		#self.info = Ninfo( self, 'info', pos=[10,10], size=[40,40], options=bgui.BGUI_NONE)
		#print(self.info.size, self.info.position)

		self.current = None  # this is where the widget for the individual screens will go

		self.frame = bgui.Frame(self, 'frame', size=[1, 1], options=bgui.BGUI_CENTERED | bgui.BGUI_DEFAULT)
		self.frame.colors = [[0, 0, 0, 1]] * 4
		self.image_back = bgui.Image(self.frame, 'image_back', './data/textures/ui/show.png', pos=[0, 0], size=[900, 600],
				options=bgui.BGUI_CACHE | bgui.BGUI_NONE | bgui.BGUI_CENTERED)

		self.image_back.color = [.4, .7, .9, .4]

		self.frame.menu_back = Fut_Box(self, 'menu_back', pos=self.image_back.position, size=[193, 450], options=bgui.BGUI_NONE)

		self.title = bgui.Label(self.image_back, 'title', text="Novus: Terra", pt_size=48, font='./data/fonts/olney_light.otf',
				color=[1, 1, 1, 1], pos=[0, 550], options=bgui.BGUI_THEMED)

		self.button1 = Fut_Button(self.image_back, 'game', pos=[5, 400], size=[182, 45], text="GAME", options=bgui.BGUI_NONE)
		self.button2 = Fut_Button(self.image_back, 'options', pos=[5, 350], size=[182, 45], text="OPTIONS", options=bgui.BGUI_NONE)
		self.button3 = Fut_Button(self.image_back, 'inventory', pos=[5, 300], size=[182, 45], text="INVENTORY", options=bgui.BGUI_NONE)
		self.button4 = Fut_Button(self.image_back, 'button4', pos=[5, 250], size=[182, 45], text="PLAYER", options=bgui.BGUI_NONE)

		# Create the button
		self.main_menu = [self.button1, self.button2, self.button3, self.button4]
		for entry in self.main_menu:
			entry.button_logic = self.button_logic

		self.screens = {'gamescreen': GameScreen(self, 'gamescreen'),
						'options': OptionsScreen(self, 'options'),
						'invscreen': ui.InventoryWindow(self, 'invscreen',
							game.Game.singleton.world.player.inventory, pos=[0, 50],
							options=bgui.BGUI_CENTERED | bgui.BGUI_THEMED)}

		for screen in self.screens.values():
			screen.visible = 0
		self.button_logic(self.button1)
Ejemplo n.º 17
0
    def __init__(self,
                 parent,
                 name,
                 aspect=None,
                 text="option 1",
                 pos=[0, 0],
                 size=[1, 1],
                 sub_theme='',
                 options=bgui.BGUI_NONE):
        bgui.Widget.__init__(self,
                             parent,
                             name,
                             aspect=aspect,
                             size=size,
                             pos=pos,
                             sub_theme=sub_theme,
                             options=options)

        self.state = 0
        self.text = bgui.Label(self,
                               'text',
                               text=text,
                               pos=[0, 0],
                               pt_size=14,
                               color=[1, 1, 1, 1],
                               font='./data/fonts/olney_light.otf',
                               options=bgui.BGUI_NONE)
        self.box = bgui.Frame(self,
                              'box',
                              border=1,
                              aspect=aspect,
                              size=[10, 10],
                              pos=[self.size[0] - 10, 0],
                              sub_theme=sub_theme,
                              options=options)
        self.box.colors = [[0, 0, 0, 1]] * 4
        self.box.border = 2
        self.box.border_color = [.4, .7, .9, .3]
Ejemplo n.º 18
0
	def __init__(self, parent, name, aspect=None, size=[1, 1], pos=[0, 0],
				sub_theme='', options=bgui.BGUI_DEFAULT):
		bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme, options)
		area = self.parent.image_back
		self.frame = bgui.Frame(self, 'frame', pos=area.position, size=area.size, options=bgui.BGUI_CENTERX)
		self.frame.colors = [[0, 0, 0, 0]] * 4

		#save the option settings
		self.button = Fut_Button(self.frame, 'button', text='APPLY', size=[160, 45], pos=[230, 0],
				options=bgui.BGUI_NONE)
		self.button.on_click = self.apply

		self.text = bgui.Label(self.frame, 'text', text='Graphics Options', pos=[230, 440],
				pt_size=18, color=[1, 1, 1, 1], font='./data/fonts/olney_light.otf', options=bgui.BGUI_NONE)

		self.graphic_options = []
		i = 0
		for entry in game.Game.singleton.graphics_options:
			if type(game.Game.singleton.graphics_options[entry]) == bool:
				i += 1
				self.graphic_options.append(Fut_Radio(self.frame, str(entry), aspect=None, text=str(entry),
						pos=[230, 430 - i * 20], size=[130, 15], sub_theme='', options=bgui.BGUI_NONE))
				if game.Game.singleton.graphics_options[entry]:
					self.graphic_options[-1].toggle()
Ejemplo n.º 19
0
	def display_options(self, options):
		""" Insert several options beneath the current text in the message box """
		self.visible = True
		self.done = False
		self.top = 0
		self.more_button.text = 'Cancel'

		self.option_start = {}
		self.option_lines = {}

		i = len(self.lines)

		# Add divider
		if len(self.lines) != 0:
			self.lines.append(MessageBox.Divider(self, 'line_' + str(i), pos=[MessageBox.PADDING,
				self.size[1] - (i + 0.5) * self.char_height - (i) * MessageBox.LINE_PADDING - MessageBox.PADDING]))
			i += 1

		# Add options
		for j, option in enumerate(options):
			# j = option number
			# i = line number
			words = option.split(' ')

			line = bgui.Label(self, 'line_' + str(i), '', pos=[MessageBox.PADDING,
				self.size[1] - (i + 1) * self.char_height - (i) * MessageBox.LINE_PADDING - MessageBox.PADDING],
				sub_theme='message_box', options=bgui.BGUI_THEMED)
			line.on_hover = self.hover_option
			line.on_click = self.click_option
			line.option = j

			self.option_start[j] = i
			self.option_lines[j] = 1

			while words:
				# try to add a word
				line.text += ' ' + words[0]

				if line.size[0] + MessageBox.PADDING * 2 > self.size[0]:
					# the line is too big, add the remaining words to a new line
					line.text = line.text[0:-len(words[0]) + 1]  # remove the last word
					line.size[1] += 4
					line.position[1] -= 4
					self.lines.append(line)
					i += 1
					self.option_lines[j] += 1
					line = bgui.Label(self, 'line_' + str(i), '', pos=[MessageBox.PADDING,
						self.size[1] - (i + 1) * self.char_height - (i) * MessageBox.LINE_PADDING - MessageBox.PADDING],
						sub_theme='message_box', options=bgui.BGUI_THEMED)
					line.on_hover = self.hover_option
					line.on_click = self.click_option
					line.option = j
				else:
					# the word fits
					words.pop(0)

			self.lines.append(line)
			i += 1
			if j != len(options) - 1:
				self.lines.append(bgui.Widget(self, 'line_' + str(i)))
				i += 1

		# Resize scrollbar
		self.scrollbar.slider_size = (self.scrollbar.size[1] / ((i) * self.char_height + (i - 1) * MessageBox.LINE_PADDING)) * self.scrollbar.size[1]
		self.scrollbar.slider_position = self.scrollbar.size[1] - self.scrollbar.slider_size
		if self.scrollbar.slider_size == self.scrollbar.size[1]:
			self.scrollbar.visible = False
		else:
			self.scrollbar.visible = True

		self.handle_overflow()
Ejemplo n.º 20
0
	def __init__(self, parent):
		ww = bge.render.getWindowWidth()
		wh = bge.render.getWindowHeight()

		w = ww * 0.7  # width of the message window is 70% of horinztonal screen space
		h = wh * 0.4  # 40% of vertical space

		PADDING = MessageBox.PADDING
		super().__init__(parent, name='message_box', size=[w, h], pos=[0, 15],
			options=bgui.BGUI_THEMED | bgui.BGUI_CENTERX)

		# Make the background image
		# Corners
		self.bg_top_left = bgui.Image(self, 'bg_top_left', img='./data/textures/ui/dialogue_back.png',
			size=[30, 30], pos=[0, h - 30], texco=((0, .8828), (.1172, .8828), (.1172, 1), (0, 1)),
			options=bgui.BGUI_THEMED)
		self.bg_top_right = bgui.Image(self, 'bg_top_right', img='./data/textures/ui/dialogue_back.png',
			size=[30, 30], pos=[w - 30, h - 30], texco=((.8828, .8828), (1, .8828), (1, 1), (.8828, 1)),
			options=bgui.BGUI_THEMED)
		self.bg_bot_left = bgui.Image(self, 'bg_bot_left', img='./data/textures/ui/dialogue_back.png',
			size=[30, 30], pos=[0, 0], texco=((0, 0), (0, .1172), (.1172, .1172), (0, .1172)),
			options=bgui.BGUI_THEMED)
		self.bg_bot_right = bgui.Image(self, 'bg_bot_right', img='./data/textures/ui/dialogue_back.png',
			size=[30, 30], pos=[w - 30, 0], texco=((.8828, 0), (1, 0), (1, .1172), (.8828, .1172)),
			options=bgui.BGUI_THEMED)

		# Sides
		self.bg_left = bgui.Image(self, 'bg_left', img='./data/textures/ui/dialogue_back.png',
			size=[30, h - 60], pos=[0, 30], texco=((0, .1172), (.1172, .1172), (.1172, .8828), (0, .8828)),
			options=bgui.BGUI_THEMED)
		self.bg_right = bgui.Image(self, 'bg_right', img='./data/textures/ui/dialogue_back.png',
			size=[30, h - 60], pos=[w - 30, 30], texco=((.8828, .1172), (1, .1172), (1, .8828), (.8828, .8828)),
			options=bgui.BGUI_THEMED)
		self.bg_top = bgui.Image(self, 'bg_top', img='./data/textures/ui/dialogue_back.png',
			size=[w - 60, 30], pos=[30, h - 30], texco=((.1172, .8828), (.8828, .8828), (.8828, 1), (.1172, 1)),
			options=bgui.BGUI_THEMED)
		self.bg_bot = bgui.Image(self, 'bg_bot', img='./data/textures/ui/dialogue_back.png',
			size=[w - 60, 30], pos=[30, 0], texco=((.1172, 0), (.8828, 0), (.8828, .1172), (.1172, .1172)),
			options=bgui.BGUI_THEMED)

		# Centre piece
		self.bg_centre = bgui.Image(self, 'bg_centre', img='./data/textures/ui/dialogue_back.png',
			size=[w - 60, h - 60], pos=[30, 30], texco=((.1172, .1172), (.8828, .1172), (.8828, .8828), (.1172, .8828)),
			options=bgui.BGUI_THEMED)

		# The additional 30 that is floating around in position and size values bleow is for the
		# vertical space taken up by the more button
		self.scrollbar = ui.Scrollbar(self, 'messsage_box_scrollbar', pos=[w - PADDING - 10, PADDING + 30],\
			size=[10, h - PADDING * 2 - 30], direction=bgui.BGUI_VERTICAL_SCROLLBAR,
			sub_theme='message_box', options=bgui.BGUI_THEMED)
		self.scrollbar.on_scroll = self.scroll
		self.top = 0  # the line of text that is displayed at the top of the window

		# Calculate line height
		line = bgui.Label(self, "tmp", "Mj|")
		self._remove_widget(line)
		char_height = line.size[1]  # TODO replace this block with constant value
		self.char_height = char_height

		# Name of the NPC talking
		self.name = ''

		# list of bgui.Label's
		self.lines = []

		# highlights the selected option
		self.option_box = bgui.Frame(self, 'option_box', size=[w - MessageBox.PADDING * 2 - 8, self.char_height],
			pos=[MessageBox.PADDING - 4, 100], options=bgui.BGUI_THEMED)
		self.option_box.visible = False
		self.option_lines = {}  # a map for how many lines of text each option contains
		self.option_start = {}  # a map for which line index each option starts at

		# button for displaying the next node
		self.more_button = bgui.Label(self, 'message_box_more_button', text='More',\
			font='./data/fonts/Sansation_Regular.ttf', pt_size=24, color=(0.8, 0.2, 0.25, 1.0),
			pos=[w - 30 - 60, 30], options=bgui.BGUI_THEMED)

		self.more_button.visible = True
		self.more_button.on_click = self.more

		# When true, the more button has been pressed
		self.done = False

		# the index of the option thats been selected, when None no options
		# has been selected
		self.selected_option = None
Ejemplo n.º 21
0
    def __init__(self,
                 parent,
                 name,
                 aspect=None,
                 text='Click me',
                 shadow=[-2, 2],
                 size=[1, 1],
                 pos=[0, 0],
                 sub_theme='',
                 image='./data/textures/ui/blur.png',
                 options=bgui.BGUI_THEMED):
        bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme,
                             options)

        csize = self.size[1] * .3

        self.image = bgui.Image(self,
                                'blur',
                                image,
                                pos=[0, 0],
                                size=[1, 1],
                                options=bgui.BGUI_CACHE | bgui.BGUI_DEFAULT
                                | bgui.BGUI_CENTERED)
        self.image.visible = 0

        self.corner1 = bgui.Image(self,
                                  'corner1',
                                  './data/textures/ui/nbutton_corner.png',
                                  pos=[0, 0],
                                  size=[csize, csize],
                                  options=bgui.BGUI_CACHE,
                                  interpolate='NEAREST')
        self.corner1.visible = 0

        self.corner2 = bgui.Image(self,
                                  'corner2',
                                  './data/textures/ui/nbutton_corner.png',
                                  pos=[self.size[0] - csize, 0],
                                  size=[csize, csize],
                                  options=bgui.BGUI_CACHE,
                                  interpolate='NEAREST')
        self.corner2.visible = 0

        self.corner3 = bgui.Image(self,
                                  'corner3',
                                  './data/textures/ui/nbutton_corner.png',
                                  pos=[0, self.size[1] - csize],
                                  size=[csize, csize],
                                  options=bgui.BGUI_CACHE,
                                  interpolate='NEAREST')
        self.corner3.visible = 0

        self.corner4 = bgui.Image(
            self,
            'corner4',
            './data/textures/ui/nbutton_corner.png',
            pos=[self.size[0] - csize, self.size[1] - csize],
            size=[csize, csize],
            options=bgui.BGUI_CACHE,
            interpolate='NEAREST')
        self.corner4.visible = 0

        self.corner1.texco = [(0, 1), (0, 0), (1, 0), (1, 1)]
        self.corner2.texco = [(1, 1), (0, 1), (0, 0), (1, 0)]
        self.corner4.texco = [(1, 0), (1, 1), (0, 1), (0, 0)]
        self.corners = [self.corner1, self.corner2, self.corner3, self.corner4]

        self.text1 = bgui.Label(self,
                                'text1',
                                text=text,
                                pt_size=39,
                                color=[0, 0, 0, 1],
                                font='./data/fonts/olney_light.otf',
                                options=bgui.BGUI_CENTERED)

        off = [
            self.text1.position[0] + shadow[0] - self.position[0],
            self.text1.position[1] + shadow[1] - self.position[1]
        ]
        self.text2 = bgui.Label(self,
                                'text2',
                                text=text,
                                pos=off,
                                pt_size=39,
                                color=[1, 1, 1, 1],
                                font='./data/fonts/olney_light.otf',
                                options=bgui.BGUI_NONE)

        self.active = 0
    def __init__(self, sys, data):
        super().__init__(sys, data)

        #Use a frame to store all of our widgets
        self.frame = bgui.Frame(self,
                                border=0,
                                options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
        self.frame.colors = [(0, 0, 0, 0) for i in range(4)]

        # Add a label for the title
        self.titlelbl = bgui.Label(self.frame,
                                   text=empty.getPropertyNames()[0],
                                   pos=[0.4, .95],
                                   sub_theme='Large',
                                   pt_size=50,
                                   options=bgui.BGUI_DEFAULT)

        self.timerlbl = bgui.Label(self.frame,
                                   text="0:00",
                                   pos=[0.1, .95],
                                   sub_theme='Large',
                                   pt_size=50,
                                   options=bgui.BGUI_DEFAULT)

        if 'pragmatic' not in empty.getPropertyNames():
            # Add a label for the figure
            self.figurelbl = bgui.Label(self.frame,
                                        text='Figure: ',
                                        pos=[.1, .9],
                                        sub_theme='Large',
                                        pt_size=50,
                                        options=bgui.BGUI_DEFAULT)
            # Add a label for the ground
            self.groundlbl = bgui.Label(self.frame,
                                        text='Ground: ',
                                        pos=[.7, .9],
                                        sub_theme='Large',
                                        pt_size=50,
                                        options=bgui.BGUI_DEFAULT)

            self.confirmlbl = bgui.Label(
                self.frame,
                text='Press Enter to Confirm this selection',
                pos=[0.3, .5],
                sub_theme='Large',
                color=(0, 1, 0, 1),
                outline_color=(1, 0, 0, 1),
                outline_size=2,
                pt_size=50,
                options=bgui.BGUI_DEFAULT)
            self.confirmlbl.visible = False

            if 'sfg' in empty.getPropertyNames():
                self.allselectedlbl = bgui.Label(
                    self.frame,
                    text=
                    'Press Enter to Confirm that you have selected all pairs in the scene',
                    pos=[0.1, .5],
                    sub_theme='Large',
                    color=(0, 1, 0, 1),
                    outline_color=(1, 0, 0, 1),
                    outline_size=2,
                    pt_size=50,
                    options=bgui.BGUI_DEFAULT)
                self.allselectedlbl.visible = False

            if "p" not in empty.getPropertyNames():
                # A label for the given preposition
                p = random_preposition_list[0]
                self.prepositionlbl = bgui.Label(self.frame,
                                                 text='Preposition: ' + p,
                                                 pos=[0, 0.9],
                                                 sub_theme='Large',
                                                 pt_size=50,
                                                 options=bgui.BGUI_DEFAULT
                                                 | bgui.BGUI_CENTERX)

            if "p" in empty.getPropertyNames():
                # A themed frame to store text input widget
                self.win = bgui.Frame(self.frame,
                                      size=[.6, .1],
                                      pos=[0, 0.1],
                                      border=0.2,
                                      options=bgui.BGUI_DEFAULT
                                      | bgui.BGUI_CENTERX)

                self.prepositionlbl = bgui.Label(self.frame,
                                                 text="",
                                                 pos=[0, 0.9],
                                                 sub_theme='Large',
                                                 pt_size=50,
                                                 options=bgui.BGUI_DEFAULT
                                                 | bgui.BGUI_CENTERX)

                # A TextInput widget
                self.input = bgui.TextInput(self.win,
                                            text="",
                                            input_options=bgui.BGUI_INPUT_NONE,
                                            pt_size=50,
                                            options=bgui.BGUI_DEFAULT)
                self.input.activate()
                self.input.on_enter_key = self.on_input_enter

        if 'pragmatic' in empty.getPropertyNames():
            # Add a label for the title
            self.instructionlbl0 = bgui.Label(
                self.frame,
                text=
                'Imagine you want the robot to bring you the highlighted object.',
                pos=[0.18, .9],
                sub_theme='Large',
                pt_size=50,
                options=bgui.BGUI_DEFAULT)
            self.instructionlbl1 = bgui.Label(
                self.frame,
                text='Provide the robot with a description of its location',
                pos=[0.21, .85],
                sub_theme='Large',
                pt_size=50,
                options=bgui.BGUI_DEFAULT)
            # A TextInput widget
            # A themed frame to store text input widget
            self.win = bgui.Frame(self.frame,
                                  size=[.6, .1],
                                  pos=[0, 0.1],
                                  border=0.2,
                                  options=bgui.BGUI_DEFAULT
                                  | bgui.BGUI_CENTERX)
            self.input = bgui.TextInput(self.win,
                                        text="",
                                        input_options=bgui.BGUI_INPUT_NONE,
                                        pt_size=50,
                                        options=bgui.BGUI_DEFAULT)
            self.input.activate()
            self.input.on_enter_key = self.on_input_enter

            if 'f' in empty.getPropertyNames():
                # Add a label for the figure
                self.figurelbl = bgui.Label(self.frame,
                                            text='Object: ',
                                            pos=[0, .8],
                                            sub_theme='Large',
                                            pt_size=50,
                                            options=bgui.BGUI_DEFAULT
                                            | bgui.BGUI_CENTERX)
Ejemplo n.º 23
0
    def __init__(self, sys, data):
        super().__init__(sys, data)
        monnom, monip, self.own = data
        self.params = []
        #self.imgfond = bgui.Image(self, 'fond.jpg', size=[1, .6], pos=[0, 0.4],
        #    options = bgui.BGUI_DEFAULT|bgui.BGUI_CACHE)
        # ajout d'une image
        self.img = bgui.Image(self,
                              'splash.jpg',
                              size=[.4, .4],
                              pos=[.05, .5],
                              options=bgui.BGUI_DEFAULT | bgui.BGUI_CACHE)
        #PARAMS
        self.cadreParams = bgui.Frame(self,
                                      size=[.4, .4],
                                      pos=[.55, 0.5],
                                      border=3)
        self.cadreParamChamp = bgui.Frame(self.cadreParams,
                                          size=[.9, .15],
                                          pos=[.05, 0.75],
                                          border=1)
        self.cadreParamboutons = bgui.Frame(self.cadreParams,
                                            size=[.9, .15],
                                            pos=[.05, 0.55],
                                            border=1)
        self.cadreParamListe = bgui.Frame(self.cadreParams,
                                          size=[.9, .4],
                                          pos=[.05, 0.05],
                                          border=1)

        # ajout de champs de saisie des params
        self.inParam = bgui.TextInput(self.cadreParamChamp,
                                      text="test",
                                      size=[.9, .9],
                                      pos=[.05, 0.05],
                                      input_options=bgui.BGUI_INPUT_NONE,
                                      options=bgui.BGUI_DEFAULT)
        self.inParam.activate()

        # un autre bouton
        self.btnAjoutParam = bgui.FrameButton(self.cadreParamboutons,
                                              text='Ajoute',
                                              size=[.2, .9],
                                              pos=[.05, .05],
                                              options=bgui.BGUI_DEFAULT)

        self.btnAjoutParam.on_click = self.on_click_ajout_param

        # un autre bouton
        self.btnRetireParam = bgui.FrameButton(self.cadreParamboutons,
                                               text='Retire',
                                               size=[.2, .9],
                                               pos=[.3, .05],
                                               options=bgui.BGUI_DEFAULT)

        self.btnRetireParam.frozen = 1

        self.btnRetireParam.on_click = self.on_click_retire_param

        # ajout d'un listbox pouyr afficher les params
        self.trouveItems()
        self.listParams = bgui.ListBox(self.cadreParamListe,
                                       items=self.params,
                                       size=[0.9, 0.9],
                                       pos=[0.05, 0.05])
        self.listParams.on_click = self.clickliste

        # FIN PARAMS

        # ajout d'etiquette
        self.lbl = bgui.Label(self,
                              text="Votre nom",
                              pos=[0.1, 0.25],
                              sub_theme='Large',
                              options=bgui.BGUI_DEFAULT)
        self.lbl = bgui.Label(self,
                              text="IP du serveur",
                              pos=[0.1, 0.15],
                              sub_theme='Large',
                              options=bgui.BGUI_DEFAULT)
        self.lbl = bgui.Label(self,
                              text="IP du client",
                              pos=[0.1, 0.05],
                              sub_theme='Large',
                              options=bgui.BGUI_DEFAULT)

        #self.lblvider = bgui.Label(self, text="Vider la console", pos=[0.6, 0.25],
        #    sub_theme='Large', options = bgui.BGUI_DEFAULT)

        # ajout de bouton
        self.btnvider = bgui.FrameButton(self,
                                         text='Vider la console',
                                         size=[.25, .06],
                                         pos=[0.6, 0.25],
                                         options=bgui.BGUI_DEFAULT)

        self.btnvider.on_click = self.videconsole

        # ajout de bouton
        self.btnserveur = bgui.FrameButton(self,
                                           text='Creer un serveur',
                                           size=[.25, .06],
                                           pos=[.6, .14],
                                           options=bgui.BGUI_DEFAULT)

        self.btnserveur.on_click = self.on_click_serveur

        # un autre bouton
        self.btnclient = bgui.FrameButton(self,
                                          text='Creer un client',
                                          size=[.25, .06],
                                          pos=[.6, .03],
                                          options=bgui.BGUI_DEFAULT)

        self.btnclient.on_click = self.on_click_client

        # ajout de champs de texte
        self.inNom = bgui.TextInput(self,
                                    text=monnom,
                                    size=[.4, .04],
                                    pos=[.3, 0.24],
                                    input_options=bgui.BGUI_INPUT_NONE,
                                    options=bgui.BGUI_DEFAULT)
        self.inNom.activate()

        # on aurait pu utiliser un Label (statique)
        self.inIPcreeServeur = bgui.TextInput(
            self,
            text=monip,
            size=[.4, .04],
            pos=[.3, 0.14],
            input_options=bgui.BGUI_INPUT_SELECT_ALL,
            options=bgui.BGUI_DEFAULT)
        self.inIPcreeServeur.frozen = 1

        self.inIPconnecteClient = bgui.TextInput(self,
                                                 text=monip,
                                                 size=[.4, .04],
                                                 pos=[.3, 0.04],
                                                 options=bgui.BGUI_DEFAULT)
Ejemplo n.º 24
0
    def __init__(self, sys, data):
        super().__init__(sys, data)

        # Use a frame to store all of our widgets
        self.frame = bgui.Frame(self, border=0)
        self.frame.colors = [(0, 0, 0, 0) for i in range(4)]

        # A themed frame
        self.win = bgui.Frame(self,
                              size=[0.6, 0.8],
                              options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERED)

        # Create an image to display
        self.win.img = bgui.Image(self.win,
                                  'img.jpg',
                                  size=[.92, .7],
                                  pos=[.01, .24],
                                  options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX
                                  | bgui.BGUI_CACHE)

        # A button
        self.button = bgui.FrameButton(self.win,
                                       text='Click Me!',
                                       size=[.14, .09],
                                       pos=[.815, .03],
                                       options=bgui.BGUI_DEFAULT)
        self.audio_button = bgui.ImageButton(self.win,
                                             sub_theme='Audio',
                                             size=[0.05, 0.05],
                                             pos=[0.75, 0.05])
        # Setup an on_click callback for the image
        self.button.on_click = self.on_img_click

        # Add a label
        self.lbl = bgui.Label(self,
                              text="I'm a label!",
                              pos=[0, 0.9],
                              sub_theme='Large',
                              options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)

        # A couple of progress bars to demonstrate sub themes
        self.progress = bgui.ProgressBar(self.win,
                                         percent=0.0,
                                         size=[0.92, 0.06],
                                         pos=[.2, 0.17],
                                         sub_theme="Progress",
                                         options=bgui.BGUI_DEFAULT
                                         | bgui.BGUI_CENTERX)

        self.health = bgui.ProgressBar(self.win,
                                       percent=0.5,
                                       size=[0.92, 0.02],
                                       pos=[0, 0.14],
                                       sub_theme="Health",
                                       options=bgui.BGUI_DEFAULT
                                       | bgui.BGUI_CENTERX)

        # A few TextInput widgets
        self.input = bgui.TextInput(self.win,
                                    text="I'm active.",
                                    font="myfont.otf",
                                    size=[.4, .04],
                                    pos=[.04, 0.02],
                                    input_options=bgui.BGUI_INPUT_NONE,
                                    options=bgui.BGUI_DEFAULT)
        self.input.activate()
        self.input.on_enter_key = self.on_input_enter

        self.input2 = bgui.TextInput(self.win,
                                     text="I select all when activated.",
                                     size=[.4, .04],
                                     pos=[.04, 0.08],
                                     input_options=bgui.BGUI_INPUT_SELECT_ALL,
                                     options=bgui.BGUI_DEFAULT)

        # A counter property used for the on_img_click() method
        self.counter = 0
Ejemplo n.º 25
0
    def __init__(self,
                 parent,
                 name,
                 inventory=None,
                 pos=[0, 0],
                 size=[6, 8],
                 options=bgui.BGUI_NONE):
        """ pos is in grid spaces, not pixels! One grid space is 50x50 px
		don't pass size in normalized values!
		"""
        super().__init__(parent,
                         name,
                         size=[size[0] * 50, size[1] * 50],
                         pos=pos,
                         options=options)

        self.border = ui.MetalBorder(self,
                                     'border',
                                     size=[320, 420],
                                     pos=[-10, -10],
                                     options=bgui.BGUI_NONE)
        self.bg = bgui.Image(self,
                             'bg',
                             img='./data/textures/ui/inventory_back.png',
                             size=[300, 400],
                             pos=[0, 0],
                             options=bgui.BGUI_NONE)

        # The description window displays info and stats about the item the mouse is hovered over
        self.description_window = bgui.Frame(self,
                                             'description_window',
                                             size=[200, 100],
                                             pos=[0, 0],
                                             sub_theme='description_window',
                                             options=bgui.BGUI_THEMED)
        self.description_window.visible = False
        self.description = bgui.Label(self.description_window,
                                      'description',
                                      '',
                                      sub_theme='description',
                                      pos=[5, 80],
                                      options=bgui.BGUI_THEMED)

        self.context_menu = None  # The context menu is created when its required
        self.context_item = None  # The grid_id that the context menu was requested for
        self.delete_context_menu = False  # When true, context menu will be deleted at end of frame

        self.inventory = inventory  # The inventory which is being displayed
        self.linked_inventory = None  # other inventory that can be dragged to
        self.items = []  # A list of bgui.Images, arranged in a grid fashion

        self.hover_item = None  # The bgui.Image the mouse is hovering over
        self.hover_time = 0.0  # The time when the mouse began hovering

        self.drag_item = None  # The image being dragged
        self.dragging = False  # True when an image is being dragged
        self.drag_offset = [0, 0]  # mouse_pos - image_pos
        self.drag_start = [
            0, 0
        ]  # The grid coordinates where the dragged image began
        self.drag_grid_id = 0  # The grid id of the dragged image

        self.redraw()
Ejemplo n.º 26
0
    def __init__(self):
        # Initialize the system
        bgui.System.__init__(self, './resources/GUI')

        # Use an invisible frame to store all of our widgets
        self.frame = bgui.Frame(self, 'window', border=0, sub_theme='Root')

        # -----------------------------------------
        # Create a main campaigns menu window
        # -----------------------------------------
        self.campMenu = bgui.Frame(self,
                                   'campaigns',
                                   size=[0.6, 0.8],
                                   options=bgui.BGUI_DEFAULT
                                   | bgui.BGUI_CENTERED)

        # Add the label
        bgui.Label(self.campMenu,
                   'campLabel',
                   text="Select a Campaign",
                   pos=[0.5, 0.9],
                   sub_theme='Large',
                   options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)

        # Create the campaingns buttons
        N = NCAMPS_PER_PAGE
        dy = 0.8 / (3.0 * N + 1.0)
        for i in range(N):
            button = bgui.FrameButton(self.campMenu,
                                      'campButton{0}'.format(i),
                                      text='{0}:'.format(i),
                                      size=[0.9, 2.0 * dy],
                                      pos=[0.05, 0.9 - (3 + 3 * i) * dy],
                                      options=bgui.BGUI_DEFAULT)
            button.on_click = self._on_select_camp

        # Pages navigation
        self.campPag = 1
        bgui.Label(self.campMenu,
                   'campPages',
                   text="1 / 1",
                   pos=[0.5, 0.05],
                   options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
        button = bgui.FrameButton(self.campMenu,
                                  'campPrev'.format(i),
                                  text='<',
                                  size=[0.08, 0.08],
                                  pos=[0.3, 0.025],
                                  options=bgui.BGUI_DEFAULT)
        button.on_click = self._on_prev_camp_page
        button = bgui.FrameButton(self.campMenu,
                                  'campNext'.format(i),
                                  text='>',
                                  size=[0.08, 0.08],
                                  pos=[0.62, 0.025],
                                  options=bgui.BGUI_DEFAULT)
        button.on_click = self._on_next_camp_page

        # -----------------------------------------
        # Create a missions menu window
        # -----------------------------------------
        self.missMenu = bgui.Frame(self,
                                   'missions',
                                   size=[0.6, 0.6],
                                   options=bgui.BGUI_DEFAULT
                                   | bgui.BGUI_CENTERED)

        # Add the label
        bgui.Label(self.missMenu,
                   'missLabel',
                   text="Select a Mission",
                   pos=[0.5, 0.9],
                   sub_theme='Large',
                   options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)

        # Create the missions buttons
        N = NMISSS_PER_PAGE
        dy = 0.8 / (3.0 * N + 1.0)
        for i in range(N):
            button = bgui.FrameButton(self.missMenu,
                                      'missButton{0}'.format(i),
                                      text='{0}:'.format(i),
                                      size=[0.9, 2.0 * dy],
                                      pos=[0.05, 0.9 - (3 + 3 * i) * dy],
                                      options=bgui.BGUI_DEFAULT)
            button.on_click = self._on_select_miss

        # Pages navigation
        self.missPag = 1
        bgui.Label(self.missMenu,
                   'missPages',
                   text="1 / 1",
                   pos=[0.5, 0.05],
                   options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
        button = bgui.FrameButton(self.missMenu,
                                  'missPrev'.format(i),
                                  text='<',
                                  size=[0.08, 0.08],
                                  pos=[0.3, 0.025],
                                  options=bgui.BGUI_DEFAULT)
        button.on_click = self._on_prev_miss_page
        button = bgui.FrameButton(self.missMenu,
                                  'missNext'.format(i),
                                  text='>',
                                  size=[0.08, 0.08],
                                  pos=[0.62, 0.025],
                                  options=bgui.BGUI_DEFAULT)
        button.on_click = self._on_next_miss_page

        # Back to campaigns menu button
        button = bgui.FrameButton(self.missMenu,
                                  'missBack'.format(i),
                                  text='Back',
                                  size=[0.15, 0.08],
                                  pos=[0.025, 0.025],
                                  options=bgui.BGUI_DEFAULT)
        button.on_click = self._on_miss_back

        # -----------------------------------------
        # Create a progress bar window (hiden)
        # -----------------------------------------
        """
		p_bar_win = bgui.Frame(self, 'progress_bar_win', size=[0.8, 0.2],
		options=bgui.BGUI_DEFAULT|bgui.BGUI_CENTERED)
		bgui.Label(p_bar_win, 'progress_bar_label', text="", pos=[0.5, 0.75],
		sub_theme='Small', options = bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)
		bgui.ProgressBar(p_bar_win, "progress_bar_pbar", percent=0.0, size=[0.95, 0.4], pos=[0.025, 0.15],
		options=bgui.BGUI_DEFAULT | bgui.BGUI_CENTERX)											
		p_bar_win.visible = False
		"""

        # -----------------------------------------
        # Create a keymap for keyboard input
        # -----------------------------------------
        self.keymap = {}
        for val in dir(bge.events):
            if val.endswith('KEY') or val.startswith('PAD'):
                try:
                    bgeVal = getattr(bge.events, val)
                    bguiVal = getattr(bgui, val)
                    self.keymap[bgeVal] = bguiVal
                except:
                    continue

        # -----------------------------------------
        # Setup the initial GUI
        # -----------------------------------------
        self._activeCampaign = None
        self._activeMission = None

        # Initialize in the campaigns menu
        self.set_active_menu('campaigns')
        self._read_campaigns()
        self._setup_camp_GUI()
Ejemplo n.º 27
0
    def test_memory_leak_label(self):
        w = bgui.Label(self.system)
        self.system = None

        gc.collect()
        self.assertListEqual(gc.garbage, [])