def __init__(self, id): super().__init__() self.ui_manager = UIManager() self.id = id self.mouse_coords = (-1, -1)
class FinishView(arcade.View): """ View to show instructions """ def __init__(self): super().__init__() self.ui_manager = UIManager() self.controlador = controller.Controller() def on_show(self): """ This is run once when we switch to this view """ arcade.set_background_color(arcade.color.BLEU_DE_FRANCE) # Reset the viewport, necessary if we have a scrolling game and we need # to reset the viewport back to the start so we can see what we draw. arcade.set_viewport(0, self.controlador.SCREEN_WIDTH - 1, 0, self.controlador.SCREEN_HEIGHT - 1) def on_draw(self): """ Draw this view """ arcade.start_render() """ Set up this view. """ self.ui_manager.purge_ui_elements() backgound_menu = arcade.load_texture('assets/fim_de_jogo.jpg') arcade.draw_lrwh_rectangle_textured(0, 0, self.controlador.SCREEN_WIDTH, self.controlador.SCREEN_HEIGHT, backgound_menu) self.ui_manager.purge_ui_elements() def on_mouse_press(self, _x, _y, _button, _modifiers): self.window.show_view(self.controlador.init_view())
class LevelMenu(arcade.View): def __init__(self, window, level_manager): super().__init__() self.window = window self.ui_manager = UIManager(window) self.level_manager = level_manager def setup(self): arcade.set_background_color(arcade.color.BLACK) for x, level in enumerate(generator_data.level_list): level_button = LevelButton( level, self.window, self.ui_manager, self.level_manager, f'Level {level.lvl_id + 1}:\n {level.lvl_description}', 175 + (x % 6) * 250, 700 - (150 * (x // 6)), 200, 100) level_button.set_style_attrs(font_color=arcade.color.WHITE, font_color_hover=arcade.color.RED, font_color_press=arcade.color.WHITE, bg_color=arcade.color.BLACK, border_color=arcade.color.RED, border_color_hover=arcade.color.WHITE, border_color_press=arcade.color.WHITE) self.ui_manager.add_ui_element(level_button) def on_show_view(self): self.setup() def on_draw(self): arcade.start_render() def on_key_press(self, symbol: int, modifiers: int): if symbol == arcade.key.ESCAPE: self.ui_manager.purge_ui_elements() self.window.show_view(MainMenu(self.window))
def __init__(self, window, level_manager): super().__init__() self.window = window self.ui_manager = UIManager(window) self.level_manager = level_manager
class InstruView(arcade.View): def __init__(self, card, personagem): super().__init__() self.ui_manager = UIManager() self.controlador = controller.Controller() self.card = card self.personagem = personagem def on_draw(self): arcade.start_render() self.ui_manager.purge_ui_elements() y_slot = self.window.height // 4 left_column_x = self.window.width // 2 backgound_instru = arcade.load_texture('assets/instruções.jpg') arcade.draw_lrwh_rectangle_textured(0, 0, self.controlador.SCREEN_WIDTH, self.controlador.SCREEN_HEIGHT, backgound_instru) def on_mouse_press(self, _x, _y, _button, _modifiers): if self.card != None: choice_view = self.controlador.multi_player( 'assets/blue', 'assets/yellow') choice_view.setup(1) self.window.show_view(choice_view) else: if self.personagem == 1: choice_view = self.controlador.single_player('assets/yellow') choice_view.setup(1) self.window.show_view(choice_view) else: choice_view = self.controlador.single_player('assets/blue') choice_view.setup(1) self.window.show_view(choice_view)
def __init__(self): super().__init__() # Initializing UI Manager self.ui_manager = UIManager() # Setting up button textures self.up_button = load_texture(f"{IMAGES_DIR}/gui/up_button.png") self.down_button = load_texture(f"{IMAGES_DIR}/gui/down_button.png") self.right_button = load_texture(f"{IMAGES_DIR}/gui/right_button.png") self.left_button = load_texture(f"{IMAGES_DIR}/gui/left_button.png") self.space_bar = load_texture(f"{IMAGES_DIR}/gui/space_bar.png") self.lime_button = load_texture(f"{IMAGES_DIR}/gui/lime_button.png") # Setting up 'unpressed' textures of those buttons self.up_button_unpressed = load_texture( f"{IMAGES_DIR}/gui/up_button_unpressed.png") self.down_button_unpressed = load_texture( f"{IMAGES_DIR}/gui/down_button_unpressed.png") self.right_button_unpressed = load_texture( f"{IMAGES_DIR}/gui/right_button_unpressed.png") self.left_button_unpressed = load_texture( f"{IMAGES_DIR}/gui/left_button_unpressed.png") self.space_bar_unpressed = load_texture( f"{IMAGES_DIR}/gui/space_bar_unpressed.png") # Setting up our background self.background = load_texture( f"{IMAGES_DIR}/backgrounds/backgroundColorForest.png")
def __init__(self, window: arcade.Window): super().__init__() self.window = window self.ui_manager = UIManager(window) self.level_stats = generator_data.GeneratorData() self.music = True self.sounds = True
class CardView(arcade.View): def __init__(self, personagem): super().__init__() self.ui_manager = UIManager() self.controlador = controller.Controller() self.personagem = personagem def on_show(self): """ This is run once when we switch to this view """ arcade.set_background_color(arcade.color.BLEU_DE_FRANCE) # Reset the viewport, necessary if we have a scrolling game and we need # to reset the viewport back to the start so we can see what we draw. arcade.set_viewport(0, self.controlador.SCREEN_WIDTH - 1, 0, self.controlador.SCREEN_HEIGHT - 1) def on_draw(self): arcade.start_render() self.ui_manager.purge_ui_elements() y_slot = self.window.height // 4 left_column_x = self.window.width // 2 backgound_cards = arcade.load_texture('assets/cartas_single.jpg') arcade.draw_lrwh_rectangle_textured(0, 0, self.controlador.SCREEN_WIDTH, self.controlador.SCREEN_HEIGHT, backgound_cards) def on_mouse_press(self, _x, _y, _button, _modifiers): single = self.controlador.single_player(self.personagem) single.setup(1) self.window.show_view(single)
def __init__(self, top_bar, app, client, me): super().__init__() self.city = None self.app = app self.top_bar = top_bar self.client = client self.me = me self.backup = None self.clicked_once = False self.ui_manager = UIManager() self.buy_city_button = None self.buy_goods_button = None self.declare_war_button = None self.propose_peace_button = None self.offer_alliance_button = None self.end_alliance_button = None self.sidebar_top = self.top_bar.size_y + 0.05 popup_height = 0.2 self.city_info = EnemyCityInfo(0.3, popup_height, self.sidebar_top) left, right, _, _ = self.city_info.coords_lrtb self.center_x = (left + right) / 2 self.sidebar_width = right - left self.sidebar_top += popup_height + 0.025 self.relative_button_height = 0.075 self.button_height = int(self.relative_button_height * self.window.height) self.sidebar_top += self.relative_button_height / 2
class MyView(arcade.View): def __init__(self, window: arcade.Window): super().__init__() self.window = window self.ui_manager = UIManager(window) def on_draw(self): arcade.start_render() def on_show_view(self): arcade.set_background_color(arcade.color.BLACK) self.ui_manager.purge_ui_elements() button_normal = arcade.load_texture( ':resources:gui_basic_assets/red_button_normal.png') hovered_texture = arcade.load_texture( ':resources:gui_basic_assets/red_button_hover.png') pressed_texture = arcade.load_texture( ':resources:gui_basic_assets/red_button_press.png') self.ui_manager.add_ui_element( arcade.gui.UIImageButton( center_x=self.window.width // 2, center_y=window.height // 2, normal_texture=button_normal, hover_texture=hovered_texture, press_texture=pressed_texture, text='UIImageButton', ))
def __init__(self): super().__init__() self.ui_manager = UIManager() # One dimensional list of all sprites in the two-dimensional sprite list self.grid_sprite_list = arcade.SpriteList() # This will be a two-dimensional grid of sprites to mirror the two # dimensional grid of numbers. This points to the SAME sprites that are # in grid_sprite_list, just in a 2d manner. self.grid_sprites = [] # Create a list of solid-color sprites to represent each grid location for row in range(COLUMN_COUNT): self.grid_sprites.append([]) for column in range(ROW_COUNT): x = column * (WIDTH + MARGIN) + (WIDTH / 2 + MARGIN) y = row * (HEIGHT + MARGIN) + (HEIGHT / 2 + MARGIN) sprite = Tile() sprite.center_x = x sprite.center_y = y self.grid_sprite_list.append(sprite) self.grid_sprites[row].append(sprite) # spawn bots for _ in range(enemiesNum+1): self.grid_sprites[random.randint(0,ROW_COUNT-1)][random.randint(0,COLUMN_COUNT-1)].to_robot() px=random.randint(0,ROW_COUNT-1) py=random.randint(0,COLUMN_COUNT-1) self.grid_sprites[px][py].to_player() self.player=self.grid_sprites[px][py] self.player.x=px self.player.y=py
def __init__(self, top_bar): super().__init__() self.city = None self.building_unit_costs = None self.building_building_costs = None self.backup = None self.clicked_once = False self.ui_manager = UIManager() self.app = QApplication([]) self.top_bar = top_bar sidebar_top = self.top_bar.size_y + 0.05 popup_height = 0.6 self.city_info = CityInfo(0.3, popup_height, sidebar_top) left, right, _, _ = self.city_info.coords_lrtb center_x = (left + right) / 2 sidebar_width = right - left sidebar_top += popup_height + 0.025 relative_button_height = 0.075 button_height = int(relative_button_height * self.window.height) sidebar_top += relative_button_height / 2 self.build_unit_button = BuildUnitFlatButton( self, center_x, (1 - sidebar_top) * self.window.height, sidebar_width, button_height) sidebar_top += relative_button_height + 0.025 self.build_building_window = BuildBuildingFlatButton( self, center_x, (1 - sidebar_top) * self.window.height, sidebar_width, button_height)
def __init__(self, state, combat_mechanic: CombatMechanic, window): super().__init__(window) self.state = state self.combat_mechanic = combat_mechanic self.background_img = None self.player = None self.ui_manager = UIManager(window)
def __init__(self, game_view, score: int): super().__init__() self.initials_input_box: MyInputBox = None self.high_score_button: MyFlatButton = None self.submitted = False self.ui_manager = UIManager() self.game_view = game_view self.score = score
def __init__(self): super().__init__() self.ui_manager = UIManager() self.controlador = controller.Controller() self.player_1 = Player('assets/blue') self.player_2 = Player('assets/yellow') self.cards_list = None self.text = "Jogador azul escolha carta 0/2"
def __init__(self, view, width0, width1, height0, height1): super().__init__() self.current_view = view self.width0 = width0 self.width1 = width1 self.height0 = height0 self.height1 = height1 self.ui_manager = UIManager()
def __init__(self, player_sprite): super().__init__() self.ui_manager = UIManager(self.window) self.height = 720 self.width = 1280 self.player_sprite = player_sprite
def __init__(self, win: arcade.Window): super().__init__() self.window = win self.ui_manager = UIManager(self.window) '''self.nameInput = UIInputBox(width=300, height=100, center_x=100, center_y=100)''' self.mainMenu = mainMenuButton() self.retry = retryButton() self.ui_manager.add_ui_element(self.mainMenu) self.ui_manager.add_ui_element(self.retry)
def __init__(self): """ Initalize the InstructionView class Arguments: self (InstructionView): An instance of InstructionView contributors: Reed Hunsaker """ super().__init__() self.ui_manager = UIManager() self.texture = arcade.load_texture(constants.INSTRUCTION_BKG)
def __init__(self): super().__init__() self.ui_manager = UIManager() self.background = None # Variables used to manage our music. See setup() for giving them values. self.music_list = [] self.current_song_index = 0 self.current_music_player = None self.music = None
def __init__(self): super().__init__() self.ui_manager = UIManager() self.name = "" self.name_input = arcade.gui.UIInputBox( center_x = SCREEN_WIDTH/2, center_y = SCREEN_HEIGHT/2, width = 300, height = 40 )
def __init__(self): global score super().__init__() self.ui_manager = UIManager() self.window.set_mouse_visible(True) arcade.set_background_color(arcade.color.RED) score = 0 self.score_text = None
def __init__(self, game_mode, total_time, lives_count): """ This is run once when we switch to this view """ super().__init__() self.ui_manager = UIManager() file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) # Holds the game mode self.co_op = game_mode # Holds the lives counter self.lives_count = lives_count # Holds the game time self.total_time = total_time # Holds the ui_button self.write_btn = None # True if it is the first time that we click the button self.first_time = True # Holds the text for the input box label self.label = "" # Holds the ui_input_box self.ui_input_box = None # Holds the db connection self.database_connection = database_connection() self.cursor = self.database_connection.cursor() # Hold the records informations self.text_0 = "" self.text_1 = "" self.text_2 = "" self.text_3 = "" self.text_4 = "" # Holds the background self.background = None # Holds the tuples of the records contained in the file self.records = [] # Game finished sound self.gameover_sound = arcade.load_sound("musica/smb_world_clear.wav") # Reset the viewport, necessary if we have a scrolling game and we need # to reset the viewport back to the start so we can see what we draw. arcade.set_viewport(0, SCREEN_WIDTH - 1, 0, SCREEN_HEIGHT - 1)
def __init__(self): """Initalize the MainView class Arguments: self (MainView): An instance of MainView contributors: Reed Hunsaker Isabel Aranguren """ super().__init__() self.texture = arcade.load_texture(constants.CAMO) self.ui_manager = UIManager()
def __init__(self, window: arcade.Window): super().__init__() self.window = window self.ui_manager = UIManager(window) self.menu_music = None self.level_manager = None self.custom_settings = None self.music = True self.sounds = True
def __init__(self): super().__init__() self.ball_list = [] self.wall_list = [] self.source = None self.isMakingWall = False self.wall_start_x = None self.wall_start_y = None self.edgeAbs = [0.01, 0.01, 0.03, 0.03, 0.04, 0.07] self.freq = 125 self.ui_manager = UIManager() arcade.set_background_color(arcade.color.BLACK)
def __init__(self): arcade.View.__init__(self) self.ui_manager = UIManager() # Set the working directory (where we expect to find files) to the same # directory this .py file is in. You can leave this out of your own # code, but it is needed to easily run the examples using "python -m" # as mentioned at the top of this program. file_path = os.path.dirname(os.path.abspath(__file__)) os.chdir(file_path) self.background = None
def __init__(self): super().__init__() self.ui_manager = UIManager() self.start_with_player = StartGameWithPlayerButton( SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 + 50, self) self.start_with_bot = StartGameWithBotButton(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 40, self) self.exit = ExitButton(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2 - 170) self.ui_manager.add_ui_element(self.start_with_player) self.ui_manager.add_ui_element(self.start_with_bot) self.ui_manager.add_ui_element(self.exit)
def displayMessageBox(uiManager: UIManager, msg: str): """ Displays a message box with a single 'Ok' button to dismiss Args: uiManager: The arcade ui manager to use msg: The message to display """ messageBox: UIMessageBox = UIMessageBox(width=300, height=200, message_text=msg, buttons=["Ok"]) uiManager.add(messageBox)
def test_handler_removed(): window = Mock() msg = UIManager(window) msg.unregister_handlers() window.assert_has_calls([ call.remove_handlers(msg.on_resize, msg.on_update, msg.on_draw, msg.on_mouse_press, msg.on_mouse_release, msg.on_mouse_scroll, msg.on_mouse_motion, msg.on_key_press, msg.on_key_release, msg.on_text, msg.on_text_motion, msg.on_text_motion_select) ])