pymasep.interface.ui_board ========================== .. py:module:: pymasep.interface.ui_board Classes ------- .. autoapisummary:: pymasep.interface.ui_board.UIBoardMode pymasep.interface.ui_board.UIBoardModeRun pymasep.interface.ui_board.UIBoardModeSelectSquare pymasep.interface.ui_board.UIBoardModeSelectPiece pymasep.interface.ui_board.UIBoardElement pymasep.interface.ui_board.UIBoardToken pymasep.interface.ui_board.UIBoardSquare pymasep.interface.ui_board.UIBoard Module Contents --------------- .. py:class:: UIBoardMode(board) Base class for UIBoard modes. :param board: the UIBoard where this mode is defined .. py:attribute:: board the board .. py:class:: UIBoardModeRun(board) Bases: :py:obj:`UIBoardMode` UIBoard run mode. Select the agent action when a key is pressed on the board :param board: the UIBoard where this mode is defined .. py:method:: process_event(event) process the event received by the UIBoard :param event: event to process :return: true if the event has been processed .. py:method:: init() Init the mode .. py:method:: clean() Clean the mode .. py:class:: UIBoardModeSelectSquare(board) Bases: :py:obj:`UIBoardMode` UIBoard select square mode. Select a square with mouse. :param board: the UIBoard where this mode is defined .. py:method:: process_event(event) process the event received by the UIBoard :param event: event to process :return: true if the event has been processed .. py:method:: init() Init the mode .. py:method:: clean() Clean the mode. Remove already selected square .. py:class:: UIBoardModeSelectPiece(board) Bases: :py:obj:`UIBoardMode` UIBoard select a piece on the board. Select a piece with mouse. :param board: the UIBoard where this mode is defined .. py:method:: process_event(event) process the event received by the UIBoard :param event: event to process :return: true if the event has been processed .. py:method:: init() Init the mode .. py:method:: clean() Clean the mode. Remove an already selected piece .. py:class:: UIBoardElement(manager, board, board_pos, square_size, image_surface=None) Bases: :py:obj:`pygame_gui.elements.UIImage` Element that can be put on the board :param manager: Manager (from pygame_gui) :param board: Board where this element is put :param board_pos: Position where this element put (board coordinates) :param square_size: square size (in pixel) :param image_surface: image surface of the element to be displayed .. py:attribute:: STATE_HOVERED :value: 0 The element is hovered by mouse .. py:attribute:: STATE_SELECTED :value: 1 The element is selected .. py:attribute:: STATE_ERROR :value: 2 The element is displayed as an error .. py:attribute:: NB_STATES :value: 3 max number of possible states .. py:attribute:: state :value: None state of the board element .. py:attribute:: previous_state :value: None previous state of the board element .. py:attribute:: square_size square size of the element .. py:attribute:: base_alpha :value: 150 base alpha color to display over the element .. py:attribute:: alpha current alpha color of the display over the element .. py:attribute:: board board where this element is put .. py:attribute:: base_image base image surface of the element .. py:attribute:: _board_pos :value: None .. py:property:: board_pos :type: tuple return the board position. :return: the board position .. py:attribute:: hovered_for_action :value: False is the element hovered in order to make an action on it .. py:attribute:: was_hovered :value: False was the element hovered .. py:method:: update(time_delta) update the element. :param time_delta: time passed since the last call .. py:class:: UIBoardToken(manager, board, position, square_size, image_surface) Bases: :py:obj:`UIBoardElement` Token that can be put on the board. At the moment, a Token is not different from an Element :param manager: Manager (from pygame_gui) :param board: Board where this element is put :param position: Position where this element put (board coordinates) :param square_size: square size (in pixel) :param image_surface: image surface of the element to be displayed .. py:class:: UIBoardSquare(manager, board, square_size, board_pos) Bases: :py:obj:`UIBoardElement` Square of the board :param manager: Manager (from pygame_gui) :param board: Board where this element is put :param board_pos: Position where this element put (board coordinates) :param square_size: square size (in pixel) .. py:attribute:: surface .. py:class:: UIBoard(relative_rect, manager, container, sub_application, image_surface, game_data, game_class_, origin_coord_map, square_size, player_name) Bases: :py:obj:`pygame_gui.core.UIContainer` Board with square where token can be put. For information, layer of elements: background : 90 agents tokens: 100 selected square: 150 :param relative_rect: position and dimensions of the board (pixels) :param manager: Manager (from pygame_gui) :param container: Container of the board (form pygame_gui) :param sub_application: sub application instance (the interface) :param image_surface: the image surface to display the board :param game_data: the data map (see @GridTools) :param game_class_: the class of the game :param origin_coord_map: pixel coordinate of the origin of the (0, 0) map position :param square_size: size of a square of the boad :param player_name: name of the player handle by the board .. py:attribute:: RUN_MODE :value: 'Run' Mode of the board : Rune .. py:attribute:: SELECT_SQUARE_MODE :value: 'SelectSquare' Mode of the board : Select a square .. py:attribute:: SELECT_PIECE_MODE :value: 'SelectPiece' Mode of the board : Select a piece on the board .. py:attribute:: background_image bacground image of the board .. py:attribute:: game_data data of the board .. py:attribute:: game_class_ .. py:attribute:: sub_application interface pointer .. py:attribute:: origin_coord_map pixel origin of the (0, 0) map position .. py:attribute:: square_size square size of the element in pixel .. py:attribute:: player_name name of the player handle by the board .. py:attribute:: agents_tokens agent UITokens .. py:attribute:: objects_tokens object UITokens .. py:attribute:: spotlight_squares squares that are spotlight .. py:attribute:: hovered_board_pos :value: None position of the board that is hovered .. py:attribute:: modes possible mode of the board .. py:attribute:: current_mode :value: None current mode of the board .. py:attribute:: board_debug_info_idx idx of the board debug info .. py:attribute:: last_step_updated :value: None the last step when the board has been updated .. py:method:: add_spotlight_square_state(board_pos, state) Set a spotlight square at a desired state :param board_pos: Position on the board :param state: state to set see @UIBoardElement .. py:method:: remove_spotlight_square_state(board_pos, state) Remove a spotlighted square which is at a desired state :param board_pos: Position on the board :param state: state which will be removed .. py:method:: map_pos_to_surface_pos(map_pos) Convert a map position to the surface position (pixel) :param map_pos: Position on the map (tuple) :return: surface position (tuple of pixel) .. py:method:: surface_pos_to_map_pos(surface_pos) convert the surface position to a map position :param surface_pos: the surface position (pixel) :return: the map position (tuple) .. py:method:: get_spotlight_squares_from_state(state) get all the squares on the baard that are on a certain state :param state: state to find :return: List of squares .. py:method:: update_with_observation(time_delta) Part of the update directly depending on the observation and that must be called only once per observation :param time_delta: Time passed since the last call .. py:method:: update(time_delta) Update the element of the board according to the observation :param time_delta: Time passed since the last call .. py:method:: process_event(event) Process an event on the board. :param event: The event to process :return: True the event has been processed .. py:method:: set_mode(mode) Set the mode of the board. :param mode: Mode of the board.