def create(self, *args): GuiState.create(self, *args) level = args[0] try: self.add(WINDOW, {'name': "leveloptions", 'cords': (300, 300), 'w': 150, 'h': 195, 'bg_color': (0, 0, 0), 'font_color': (234, 234, 234)}) self.add(TEXT, {'name': "lvloptions", 'cords': (310, 310), 'font_color': (234, 234, 234), 'font_size': 20, 'text': "Level Options"}) self.add(BUTTON, {'name': 'clear_bttn', 'cords': (330, 340), 'bg_color': (255, 255, 255), 'font_color': (0, 0, 0), 'font_size': 14, 'text': 'Clear Level', 'action': level.clear, 'close_state': True}) load_bttn = self.add(BUTTON, {'name': 'load_bttn', 'cords': (330, 380), 'bg_color': (255, 255, 255), 'font_color': (0, 0, 0), 'font_size': 14, 'text': 'Load Level', 'action': level.load, 'close_state': True}) save_bttn = self.add(BUTTON, {'name': 'save_bttn', 'cords': (330, 420), 'bg_color': (255, 255, 255), 'font_color': (0, 0, 0), 'font_size': 14, 'text': 'Save Level', 'action': level.save, 'close_state': True}) file_txtbox = self.add(TXT_BOX, {'name': 'saveas_txtbox', 'cords': (330, 460), 'bg_color': (255, 255, 255)}) file_txtbox.text = level._filename load_bttn.attach('filename', file_txtbox) save_bttn.attach('filename', file_txtbox) self.focus(file_txtbox) except (IndexError, ValueError, TypeError, KeyError): print('Error during creation of GuiLevelOptions')
def destroy(self): GuiState.destroy(self) print('destroying GuiObjSearch') self.keybindings.remove(pygame.MOUSEBUTTONUP) self.keybindings.remove(pygame.K_RETURN) self.keybindings.remove(pygame.K_UP) self.keybindings.remove(pygame.K_DOWN) self.controls[:] = [] self.listbox = None self.textbox = None self.level = None
def create(self, *args): print('Create GuiObjSearch called') GuiState.create(self, *args) try: pygame.mouse.set_visible(False) self.level = args[0] self.keybindings.add(PrePlaceObjectBind(pygame.MOUSEBUTTONUP, self, self.level)) self.keybindings.add(PrePlaceObjectBind(pygame.K_RETURN, self, self.level)) self.keybindings.add(ListboxUpBind(pygame.K_UP, "results", self)) self.keybindings.add(ListboxDownBind(pygame.K_DOWN, "results", self)) self.textbox = self.add(TXT_BOX, {'name': "c_obj", 'cords': pygame.mouse.get_pos(), 'bg_color': (255, 255, 255)}) results_pos = (self.textbox.rect.x, self.textbox.rect.y + self.textbox.rect.h + 25) self.listbox = self.add(LIST_BOX, {'name': "results", 'cords': results_pos, 'bg_color': (255, 255, 255)}) self.textbox.attach('objlist', self.listbox) self.listbox.update_list(self.get_path_results(), True) self.focus(self.textbox) except (IndexError, TypeError, LookupError, ValueError): print('Failed to create GuiObjSearch')
def __init__(self, state, *args): GuiState.__init__(self, state)
def destroy(self, *args): GuiState.destroy(self) self.controls[:] = []
def update(self): GuiState.update(self) if self.listbox: self.listbox.update_list(self.get_path_results(), True)
def __init__(self, state): GuiState.__init__(self, state) self.listbox = None self.textbox = None self.level = None
def create(self, *args): GuiState.create(self, *args) try: level = args[0] obj = args[1] if obj is None: print('none obj') return self.keybindings.add(SelectNextTxtboxBind(pygame.K_TAB, self)) self.add(WINDOW, {'name': 'editprops', 'cords': (0, 0), 'w': 300, 'h': 650, 'bg_color': (0, 0, 0), 'font_color': (234, 234, 234)}) confirm_bttn = self.add(BUTTON, {'name': 'confirm_bttn', 'cords': (220, 550), 'bg_color': (255, 255, 255), 'font_color': (0, 0, 0), 'font_size': 14, 'text': 'Confirm', 'action': level.edit_object, 'close_state': True}) # self.add(TEXT, {'name': 'namelabel', 'cords': (310, 280), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Name:"}) # namefield = self.add(TXT_BOX, {'name': 'nametxtbox', 'cords': (400, 284), 'bg_color': (255, 255, 255)}) # namefield.text = obj.name # confirm_bttn.attach('name', namefield) # # self.add(TEXT, {'name': 'xlabel', 'cords': (310, 305), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "X:"}) # xfield = self.add(TXT_BOX, {'name': 'xtxtbox', 'cords': (400, 305), 'bg_color': (255, 255, 255)}) # xfield.text = str(obj.rect.x) # confirm_bttn.attach('x', xfield) # # self.add(TEXT, {'name': 'ylabel', 'cords': (310, 330), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Y:"}) # yfield = self.add(TXT_BOX, {'name': 'ytxtbox', 'cords': (400, 330), 'bg_color': (255, 255, 255)}) # yfield.text = str(obj.rect.y) # confirm_bttn.attach('y', yfield) # # self.add(TEXT, {'name': 'wlabel', 'cords': (310, 355), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Width:"}) # wfield = self.add(TXT_BOX, {'name': 'wtxtbox', 'cords': (400, 355), 'bg_color': (255, 255, 255)}) # wfield.text = str(obj.rect.w) # confirm_bttn.attach('w', wfield) # # self.add(TEXT, {'name': 'hlabel', 'cords': (310, 380), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Height:"}) # hfield = self.add(TXT_BOX, {'name': 'htxtbox', 'cords': (400, 380), 'bg_color': (255, 255, 255)}) # hfield.text = str(obj.rect.h) # confirm_bttn.attach('h', hfield) # # self.add(TEXT, {'name': 'glabel', 'cords': (310, 405), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Gravity:"}) # gravityfield = self.add(TXT_BOX, {'name': 'gtxtbox', 'cords': (400, 405), 'bg_color': (255, 255, 255)}) # gravityfield.text = str(obj.obey_gravity) # confirm_bttn.attach('gravity', gravityfield) # # self.add(TEXT, {'name': 'clabel', 'cords': (310, 430), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Collidable:"}) # collidefield = self.add(TXT_BOX, {'name': 'ctxtbox', 'cords': (400, 430), 'bg_color': (255, 255, 255)}) # collidefield.text = str(obj.collidable) # confirm_bttn.attach('collide', collidefield) # # self.add(TEXT, {'name': 'layerlabel', 'cords': (310, 455), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Layer:"}) # layerfield = self.add(TXT_BOX, {'name': 'layertxtbox', 'cords': (400, 455), 'bg_color': (255, 255, 255)}) # layerfield.text = str(obj._layer) # confirm_bttn.attach('_layer', layerfield) # # self.add(TEXT, {'name': 'typelabel', 'cords': (310, 480), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "Type:"}) # typefield = self.add(TXT_BOX, {'name': 'typetxtbox', 'cords': (400, 480), 'bg_color': (255, 255, 255)}) # typefield.text = obj_type_str(obj.type) # confirm_bttn.attach('type', typefield) # # self.add(TEXT, {'name': 'filelabel', 'cords': (310, 505), 'font_color': (234, 234, 234), # 'font_size': 18, 'text': "File:"}) # filefield = self.add(TXT_BOX, {'name': 'filetxtbox', 'cords': (400, 505), 'bg_color': (255, 255, 255)}) # filefield.text = obj.files[0] # confirm_bttn.attach('file1', filefield) member_vars = vars(obj) x = 20 y = 20 for name, value in member_vars.items(): field_text = to_string(name, value) if field_text != '': self.add(TEXT, {'name': name + '_label', 'cords': (x, y), 'font_color': (234, 234, 234), 'font_size': 18, 'text': name}) field = self.add(TXT_BOX, {'name': name + '_txtbox', 'cords': (x + 120, y), 'bg_color': (255, 255, 255)}) field.text = to_string(name, value) confirm_bttn.attach(name, field) y += 25 except (ValueError, IndexError, LookupError, TypeError): print('Error during creation of GuiEditObject') raise
def destroy(self): print('GuiEditObj destroy called') GuiState.destroy(self) self.keybindings.remove(pygame.K_TAB) self.controls[:] = []
def __init__(self, state, *args): GuiState.__init__(self, state) self.esc_once = False self.keybindings.add(LevelQuitBind(pygame.K_ESCAPE, self)) self.toggle("Quitting")
def destroy(self, *args): GuiState.destroy(self) self.keybindings.remove(pygame.K_ESCAPE)
def create(self, *args): GuiState.create(self, *args)