FangEngine.screen_manager.dialog_box
This module contains the base dialog box class
Class DialogBox
This class is the class all dialog boxes must inherit from
__init__(self, screen_parent: base_screen.BaseScreen, args, kwargs)
Parameter screen_parent:
Parameter args:
Parameter kwargs:
__del__(self)
broadcast_message(self, message: typing.Union[list, tuple, str], sender = None)
Broadcasts a message
Parameter message:
Parameter sender: default is this dialog box
center_dialog_box(self)
Re-calculates the position to draw the dialog box in order to ensure it is centered
Returns
center_mouse(self)
Moves the mouse cursor to the center of the screen
center_mouse_x(self)
Moves the mouse cursor so it is centered along the x axis
center_mouse_y(self)
Moves the mouse cursor so it is centered along the y axis
close(self)
Closes this dialog box
convert_coords(self, x: float, y: float) -> typing.Tuple[float, float]
This method converts coordinates so (0, 0) is the top left corner of the dialog box, and not the window
Parameter x:
Parameter y:
dialog_render(self, buffer: Surface)
This is the method to override for dialog box rendering
draw_close_button(self)
This method is responsible for creating the close button
Once the buttoh has been drawn it does not need to be drawn again
(unless you want the appearance of the button to change)
get_cursor_pos(self) -> typing.Tuple[float, float]
Returns the mouse cursor's position
The position is automatically scaled so this is the safest way to get the position
get_size(self, screen_w: float, screen_h: float) -> tuple
This method must return the width and height of the dialog box
The screen size will be provided if you wish to make the box a scaled percentage of the screen
Parameter screen_w:
Parameter screen_h:
Returns the size to make the dialog box
handle_input(self, keys: list, mouse: tuple, delta_t: float)
hide_mouse(self)
Hides the mouse cursor
is_showing_dialog_box(self) -> bool
Returns if there are any dialog boxes currently being displayed
on_create(self)
This event is triggered when the screen is created
It is run once and only once
on_joystick_axis_motion(self, joystick, axis, value)
on_joystick_ball_motion(self, joystick, ball, rel)
on_joystick_button_down(self, joystick, button)
on_joystick_button_up(self, joystick, button)
on_joystick_hat_motion(self, joystick, hat, value)
on_key_down(self, unicode, key, mod)
on_key_up(self, key, mod)
on_message_receive(self, message: str, sender)
This event is triggered whenever a message is sent
Parameter message:
Parameter sender: the object which broadcast the message
on_mouse_button_down(self, pos, button)
This event is triggered when the box is clicked
Parameter pos:
Parameter button:
Returns
on_mouse_button_up(self, pos, button)
on_mouse_motion(self, pos, rel, buttons)
on_screen_enter(self, previous_screen: str)
on_screen_leave(self, next_screen: str)
play_sound(self, sound: Sound, loops: int = 0, left: float = 1.0, right: float = 1.0)
Plays a sound
Parameter sound: the Pygame Sound object to play
Parameter loops:
Parameter left: the left volume to play the sound (0-1)
Parameter right: the right volume to play the sound (0-1)
For example, if left is 0 and right is 1, then the sound will only be played out of the right speaker/earphone
render(self, buffer: Surface)
This method draws the dialog box to the specified buffer
show_dialog_box(self, box: dialog_box.DialogBox.__class__, args, kwargs)
Shows a new dialog box
Parameter box: the reference to the dialog box class to show
Parameter args:
Parameter kwargs:
show_mouse(self)
Shows the mouse cursor
update(self, delta_t: float)