def __init__(self, world): self.width = 180 self.height = 95 Gui.__init__( self, 'character', (0, 200), pygame.Surface((self.width, self.height), pygame.SRCALPHA, 32), True) self.image.convert_alpha() self.player_image = world.player.image.copy() self.time_passed = 0.0 self.player_image = pygame.transform.scale( self.player_image, (self.player_image.get_width() / 2, self.player_image.get_height() / 2)) self.name = render_textrect(world.player.name, 30, self.image.get_rect(), (255, 255, 255)) self.time_passed_text = render_textrect(self.time_passed, 30, pygame.Rect(0, 0, 30, 30), (255, 255, 255), (54, 54, 54)) self.exp = Bar(world.player.exp, world.player.stats['EXP'], 'Lvl {0}'.format(world.player.lvl), (50, 255, 10), (5, 20)) self.hp = Bar(world.player.hp, world.player.stats['HP'], 'HP', (224, 52, 52), (5, 45)) self.mp = Bar(world.player.mp, world.player.stats['MP'], 'MP', (96, 132, 224), (5, 70)) register_handler(TIME_PASSED, self.handle_event)
def __init__(self): self.width = WIDTH - MENU_WIDTH self.height = CONSOLE_HEIGHT Gui.__init__(self, 'console', (0, HEIGHT - CONSOLE_HEIGHT), pygame.Surface((self.width, self.height)), True) self.log = [] self.log_processed = [] register_handler(POST_TO_CONSOLE, self.handle_event)
def polling(self): """ Checks if a message is sent by the service script. If a message is in the buffer, it reads the command and reacts according to the given command. """ while True: time.sleep(0.1) refresh = False self.__mutex.acquire(True) if self.__connection.poll(): data = self.__connection.recv() if data == str(Command.COMPUTER_STATUS): multi_user = self.__connection.recv() ret = str(self.is_locked(multi_user)) self.__connection.send(ret) elif data == Codes.GUI_UPDATE: uid = self.__connection.recv() self.update_gui(uid) elif data == Codes.FIND_SERIAL_DEVICES: if self.__connection.recv() == "True": Gui.notify("Das Gerät ist bereits angeschlossen") else: Gui.notify( "Es wurde kein Smock Gerät gefunden.\n" "Vergewissern Sie sich, dass das Gerät angeschlossen ist.\n" ) elif data == Codes.REFRESH: refresh = True self.__mutex.release() if refresh: self.gui.refresh_list()
def __init__(self, world): self.world = world self.tile_size = 6 self.width = 192 self.height = 192 self.camera = pygame.Rect((0, 0), (self.width, self.height)).copy() self.map = Map() self.map.load_dungeon(world.map.dungeon, True, self.tile_size) self.zoom_in_arrow = ZoomArrow(0, (174, 10)) self.zoom_in_arrow.create() self.zoom_out_arrow = ZoomArrow(1, (174, 20)) self.zoom_out_arrow.create() Gui.__init__(self, 'minimap', (4, 4), pygame.Surface((self.width, self.height)), True) x = self.world.player.x * self.tile_size y = self.world.player.y * self.tile_size self.camera.center = (x, y) self.map.draw(self.image, self.camera, self.world.map.explored_tiles) self.image.fill((0, 255, 0), pygame.Rect((x - self.camera.x, y - self.camera.y), (self.tile_size, self.tile_size))) self.image.blit(self.zoom_in_arrow.arrow, (self.zoom_in_arrow.rect.x, self.zoom_in_arrow.rect.y)) self.image.blit( self.zoom_out_arrow.arrow, (self.zoom_out_arrow.rect.x, self.zoom_out_arrow.rect.y)) register_handler([TIME_PASSED, pygame.MOUSEBUTTONDOWN], self.handle_event)
def main(): app = QApplication(sys.argv) from src.gui.gui import Gui gui = Gui() gui.show() sys.exit(app.exec_())
def __init__(self, world): self.width = MENU_WIDTH self.height = 95 self.world = world Gui.__init__(self, 'character', (0, 200), pygame.Surface((self.width, self.height), pygame.SRCALPHA, 32), True) self.image.convert_alpha() self.generate_bars() register_handler([TIME_PASSED, pygame.MOUSEMOTION], self.handle_event)
def __init__(self): self.width = WIDTH - MENU_WIDTH self.height = CONSOLE_HEIGHT self.max_messages = int(CONSOLE_HEIGHT / CONSOLE_FONT_SIZE) - 3 Gui.__init__(self, 'console', (0, HEIGHT - CONSOLE_HEIGHT), pygame.Surface((self.width, self.height)), True) self.log = [] self.log_processed = [] self.fill_message = None register_handler( [POST_TO_CONSOLE, CLEAR_CONSOLE, FILL_CONSOLE, CLEAR_FILL_CONSOLE], self.handle_event)
def __init__(self, world): self.width = MENU_WIDTH self.height = 95 self.world = world Gui.__init__( self, 'character', (0, 200), pygame.Surface((self.width, self.height), pygame.SRCALPHA, 32), True) self.image.convert_alpha() self.generate_bars() register_handler([TIME_PASSED, pygame.MOUSEMOTION], self.handle_event)
def __init__(self): self.width = MENU_WIDTH self.height = 80 Gui.__init__(self, 'explorer', (30, 400), pygame.Surface((self.width, self.height), pygame.SRCALPHA, 32).convert_alpha(), False) self.slots = [] self.slots_rect = [] for y in range(0, 2): for x in range(0, 4): self.slots_rect.append(pygame.Rect(5 + x * 35, 5 + y * 35, 32, 32)) self.slots.append(Slot(5 + x * 35, 5 + y * 35)) register_handler([GUI_EXPLORER_ITEMS, GUI_EXPLORER_CLEAR, PLAYER_PICKUP_ITEM], self.handle_event)
def __init__(self, world): self.world = world self.data = None self.orientation = None image = pygame.Surface((200, 300), pygame.SRCALPHA, 32) self.options = {} self.show_window = False self.tooltip_delay = 0 self.item_tooltip = None self.mouse = Mouse_select(world) Gui.__init__(self, 'character', (0, 0), image, True) register_handler( [GUI_TOOLTIP_CLEAR, TIME_PASSED, GUI_TOOLTIP_POST, pygame.MOUSEBUTTONDOWN], self.handle_event)
def __init__(self, world): self.world = world self.data = None image = pygame.Surface((200, 100), pygame.SRCALPHA, 32) #image.convert_alpha() self.options = {} self.target = None self.show_window = False self.item_tooltip = None self.mouse = Mouse_select(world) Gui.__init__(self, 'character', (0, 0), image, True) register_handler( [GUI_TOOLTIP_CLEAR, GUI_TOOLTIP_POST, GUI_EXAMINE_ITEM, GUI_EXAMINE_ITEM_CLEAR, pygame.MOUSEBUTTONDOWN], self.handle_event)
def __init__(self, world): self.world = world self.data = None image = pygame.Surface((200, 100), pygame.SRCALPHA, 32) #image.convert_alpha() self.options = {} self.target = None self.show_window = False self.item_tooltip = None self.mouse = Mouse_select(world) Gui.__init__(self, 'character', (0, 0), image, True) register_handler([ GUI_TOOLTIP_CLEAR, GUI_TOOLTIP_POST, GUI_EXAMINE_ITEM, GUI_EXAMINE_ITEM_CLEAR, pygame.MOUSEBUTTONDOWN ], self.handle_event)
def __init__(self, world): self.world = world self.data = None self.orientation = None image = pygame.Surface((200, 300), pygame.SRCALPHA, 32) self.options = {} self.show_window = False self.tooltip_delay = 0 self.item_tooltip = None self.mouse = Mouse_select(world) Gui.__init__(self, 'character', (0, 0), image, True) register_handler([ GUI_TOOLTIP_CLEAR, TIME_PASSED, GUI_TOOLTIP_POST, pygame.MOUSEBUTTONDOWN ], self.handle_event)
def __init__(self, world): self.width = 180 self.height = 95 Gui.__init__(self, 'character', (0, 200), pygame.Surface((self.width, self.height), pygame.SRCALPHA, 32), True) self.image.convert_alpha() self.player_image = world.player.image.copy() self.time_passed = 0.0 self.player_image = pygame.transform.scale(self.player_image, (self.player_image.get_width() / 2, self.player_image.get_height() / 2)) self.name = render_textrect(world.player.name, 30, self.image.get_rect(), (255, 255, 255)) self.time_passed_text = render_textrect(self.time_passed, 30, pygame.Rect(0, 0, 30, 30), (255, 255, 255), (54, 54, 54)) self.exp = Bar(world.player.exp, world.player.stats['EXP'], 'Lvl {0}'.format(world.player.lvl), (50, 255, 10), (5, 20)) self.hp = Bar(world.player.hp, world.player.stats['HP'], 'HP', (224, 52, 52), (5, 45)) self.mp = Bar(world.player.mp, world.player.stats['MP'], 'MP', (96, 132, 224), (5, 70)) register_handler(TIME_PASSED, self.handle_event)
def __init__(self, world): self.world = world self.tile_size = 6 self.width = 192 self.height = 192 self.camera = pygame.Rect((0, 0), (self.width, self.height)).copy() self.map = Map() self.map.load_dungeon(world.map.dungeon, True, self.tile_size) self.zoom_in_arrow = ZoomArrow(0, (174, 10)) self.zoom_in_arrow.create() self.zoom_out_arrow = ZoomArrow(1, (174, 20)) self.zoom_out_arrow.create() Gui.__init__(self, 'minimap', (4, 4), pygame.Surface((self.width, self.height)), True) x = self.world.player.x * self.tile_size y = self.world.player.y * self.tile_size self.camera.center = (x, y) self.map.draw(self.image, self.camera, self.world.map.explored_tiles) self.image.fill((0, 255, 0), pygame.Rect((x - self.camera.x, y - self.camera.y), (self.tile_size, self.tile_size))) self.image.blit(self.zoom_in_arrow.arrow, (self.zoom_in_arrow.rect.x, self.zoom_in_arrow.rect.y)) self.image.blit(self.zoom_out_arrow.arrow, (self.zoom_out_arrow.rect.x, self.zoom_out_arrow.rect.y)) register_handler([TIME_PASSED, pygame.MOUSEBUTTONDOWN], self.handle_event)
def main(): app = Gui() app.mainloop()