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
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()
def __init__(self, sys, data): super().__init__(sys, data) monnom, monip, self.own = data # ajout d'une image lisdir = os.listdir(bge.ppath + "images/") lisdir.sort() lisdir.reverse() img = lisdir.pop(0) nom = bge.ppath + "images/" + img print("IMAGEEEEE ", nom) self.img = bgui.Image(self, nom, size=[.1, .1], pos=[.0, .0], options=bgui.BGUI_DEFAULT | bgui.BGUI_CACHE) #self.img = bgui.Image(self, nom, size=[.1, .1], pos=[.0, .0], # options = bgui.BGUI_DEFAULT|bgui.BGUI_CENTERX|bgui.BGUI_CACHE) # ajout de bouton self.btnfermeimage = bgui.FrameButton(self, text='X', size=[.02, .02], pos=[.02, .02], options=bgui.BGUI_DEFAULT) self.btnfermeimage.on_click = self.on_click_fermeimage
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
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
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)
def __init__(self, parent, name, aspect=None, size=[1, 1], pos=[0, 0], sub_theme='', options=bgui.BGUI_THEMED): bgui.Widget.__init__(self, parent, name, aspect, size, pos, sub_theme, options) self.part = bgui.Image(self, 'part', './data/textures/ui/ui_middle.png', pos=[32, 0], size=[self.size[0] - 32, self.size[1]], options=bgui.BGUI_CACHE, interpolate='NEAREST') self.left = bgui.Image(self, 'left', './data/textures/ui/ui_left.png', pos=[0, 0], size=[32, self.size[1]], options=bgui.BGUI_CACHE, interpolate='NEAREST') self.right = bgui.Image(self, 'right', './data/textures/ui/ui_right.png', pos=[size[0], 0], size=[32, self.size[1]], options=bgui.BGUI_CACHE, interpolate='NEAREST') image_size = self.part.image_size ratio = [self.size[0] / image_size[0], self.size[1] / image_size[1]] self.part._color, self.left._color, self.right._color = [ 1, 1, 1, .4 ], [1, 1, 1, .4], [1, 1, 1, .4] self.part.texco = [(0, 0), (ratio[0], 0), (ratio[0], ratio[1]), (0, ratio[1])] self.left.texco = [(0, 0), (1, 0), (1, ratio[1]), (0, ratio[1])] self.right.texco = [(0, 0), (1, 0), (1, ratio[1]), (0, ratio[1])]
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)
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)
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)
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
def __init__(self, parent, name, size=[0, 0], pos=[0, 0], options=bgui.BGUI_DEFAULT): super().__init__(parent, name, size=size, pos=pos, options=options) # Corners w = self.size[0] h = self.size[1] self.bg_top_left = bgui.Image( self, 'bg_top_left', img='./data/textures/ui/button_border.png', size=[10, 10], pos=[0, h - 10], texco=((0, .75), (.25, .75), (.25, 1), (0, 1)), options=bgui.BGUI_THEMED) self.bg_top_right = bgui.Image( self, 'bg_top_right', img='./data/textures/ui/button_border.png', size=[10, 10], pos=[w - 10, h - 10], texco=((.75, .75), (1, .75), (1, 1), (.75, 1)), options=bgui.BGUI_THEMED) self.bg_bot_left = bgui.Image( self, 'bg_bot_left', img='./data/textures/ui/button_border.png', size=[10, 10], pos=[0, 0], texco=((0, 0), (.25, 0), (.25, .25), (0, .25)), options=bgui.BGUI_THEMED) self.bg_bot_right = bgui.Image( self, 'bg_bot_right', img='./data/textures/ui/button_border.png', size=[10, 10], pos=[w - 10, 0], texco=((.75, 0), (1, 0), (1, .25), (.75, .25)), options=bgui.BGUI_THEMED) # Sides self.bg_left = bgui.Image(self, 'bg_left', img='./data/textures/ui/button_border.png', size=[10, h - 20], pos=[0, 10], texco=((0, .25), (.25, .25), (.25, .75), (0, .75)), options=bgui.BGUI_THEMED) self.bg_right = bgui.Image(self, 'bg_right', img='./data/textures/ui/button_border.png', size=[10, h - 20], pos=[w - 10, 10], texco=((.75, .25), (1, .25), (1, .75), (.75, .75)), options=bgui.BGUI_THEMED) self.bg_top = bgui.Image(self, 'bg_top', img='./data/textures/ui/button_border.png', size=[w - 20, 10], pos=[10, h - 10], texco=((.25, .75), (.75, .75), (.75, 1), (.25, 1)), options=bgui.BGUI_THEMED) self.bg_bot = bgui.Image(self, 'bg_bot', img='./data/textures/ui/button_border.png', size=[w - 20, 10], pos=[10, 0], texco=((.25, 0), (.75, 0), (.75, .25), (.25, .25)), options=bgui.BGUI_THEMED)
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)
percent=0.0, size=[pbar_dims[0], pbar_dims[1]], pos=[0.975 - pbar_dims[0], pbar_dims[1] + image_dims[1]], sub_theme='RedGUI', options=bgui.BGUI_DEFAULT) widget = bgui.ProgressBar(gui, "player_noise", percent=0.0, size=[pbar_dims[0], pbar_dims[1]], pos=[0.975 - pbar_dims[0], pbar_dims[1]], sub_theme='RedGUI', options=bgui.BGUI_DEFAULT) img = path.join(images_path, 'depth.blender.png') widget = bgui.Image(gui, 'player_depth', img, size=[widget_dims[0], widget_dims[1]], pos=[0.1 * widget_dims[0], 0.1 * widget_dims[1]], options=bgui.BGUI_DEFAULT | bgui.BGUI_CACHE) img = path.join(images_path, 'depth.blender.Indicator.png') bgui.Image(widget, 'player_depth_indicator', img, size=[1.0, 1.0], pos=[0.0, 0.0], options=bgui.BGUI_DEFAULT | bgui.BGUI_CACHE) img = path.join(images_path, 'throttle_rudder.blender.png') widget = bgui.Image(gui, 'player_throttle', img, size=[widget_dims[0], widget_dims[1]], pos=[1.2 * widget_dims[0], 0.1 * widget_dims[1]],
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, 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()
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
def test_memory_leak_image(self): w = bgui.Image(self.system, "examples/simple/img.jpg") self.system = None gc.collect() self.assertListEqual(gc.garbage, [])