FangEngine.screen_manager.screen_manager

This module contains the ScreenManager. The backbone of the FangEngine

Class ScreenManager

This module contains the ScreenManager. The backbone of the FangEngine
The ScreenManager is responsible for handling all screens, scaling them, switching them and dispatching all events

__init__(self, screen_w: int = 800, screen_h: int = 450, fullscreen: bool = False, monitor: int = 0, show_cursor: bool = True, caption: str = FangEngine Application, framerate_cap: int = 60, icon_path: str = None)

Note that this method allows you to set fullscreen, monitor and framerate_cap.
It is best practice to allow the user choose this at runtime. This can be done by calling show_graphics_options
Parameter screen_w: The width of the working space. This will be scaled based on user window interaction
Parameter screen_h: The height of the working space. This will be scaled based on user window interaction
Parameter fullscreen:
Parameter monitor:
Parameter show_cursor:
Parameter caption: The title for the window
Parameter framerate_cap:
Parameter icon_path: the path to the image for the window icon

add_instantiated_screen(self, screen_obj: screen.BaseScreen) -> ScreenManager

Adds an already instantiated screen
WARNING: DO NOT INSTANTIATE A SCREEN OBJECT ON YOUR OWN. Let the engine handle it
Parameter screen_obj:
Returns this object so this statement can be chained

add_screen(self, name: str, screen_cls: screen.BaseScreen.__class__, args, kwargs) -> ScreenManager

Adds a new screen to the manager
Parameter name: the reference name of the screen
Parameter screen_cls: a reference to the class of the screen. It MUST inherit from BaseScreen
Parameter args:
Parameter kwargs:
Returns this object so this statement can be chained

change_screen(self, name: str) -> ScreenManager

Changes the currently selected screen
Returns this object so this statement can be chained

clear_event_queue()

Clears the event queue
Returns

draw_buffer(self)

Scales and draws the buffer (which is passed to all objects for them to do their drawing with) to the window

scale_coords(self, pos: typing.Tuple[float, float]) -> typing.Tuple[float, float]

Scales coordinates relative to the scaling of the window

show_graphics_options(self, caption: str = None, icon_path: str = None) -> ScreenManager

This method allows the users to select their graphics options
Parameter caption: default is to take the value set in the constructor
Parameter icon_path: default is to take the value set in the constructor
Returns this object so this statement can be chained

show_screen(self, initial_screen: str = None) -> ScreenManager

Launches the GUI window. It is best practice to call "start" method instead which will handle this
Parameter initial_screen: the screen to start on
Returns this object so this statement can be chained

start(self, initial_screen: str = None) -> StatusCodes

Starts the application
Parameter initial_screen: the screen to start the game on
Returns the status code as to why the game terminated. This will be a value from the StatusCodes enum

update_scale_factor(self)