NotQuiteParadise2

Generic

Fancy Font

Font

UI Button

class UIButton(game: Game, content, pos: pygame.Vector2, push_down: bool = True, size: pygame.Vector2 = <Vector2(10, 10)>, colour=(255, 255, 255))[source]

Bases: object

__init__(game: Game, content, pos: pygame.Vector2, push_down: bool = True, size: pygame.Vector2 = <Vector2(10, 10)>, colour=(255, 255, 255))[source]
draw(surf, offset=(0, 0))[source]
property pressed
update(delta_time: float)[source]

UI Frame

class UIFrame(game: Game, pos: pygame.Vector2, font: None | Font | FancyFont = None, is_selectable: bool = False, max_width: Optional[int] = None, max_height: Optional[int] = None, image: None | Image | Animation = None, text_relative_position: TextRelativePosition = None, tooltip_key: str | None = None)[source]

Bases: nqp.base_classes.ui_element.UIElement

A complex ui element. Works as an extension of UIElement to offer more functionality within a helpful wrapper.

__init__(game: Game, pos: pygame.Vector2, font: None | Font | FancyFont = None, is_selectable: bool = False, max_width: Optional[int] = None, max_height: Optional[int] = None, image: None | Image | Animation = None, text_relative_position: TextRelativePosition = None, tooltip_key: str | None = None)[source]
add_tier_background(tier: int)[source]

Add a background to the frame, based on the tier given. Tiers can be 1-4.

draw(surface: pygame.Surface)[source]
pause_animation()[source]

Pause the animation, if there is one

play_animation()[source]

Play the animation, if there is one

reset_animation()[source]

Reset the animation, if there is one

set_text(text: str)[source]

Update the font text.

stop_animation()[source]

Stop the animation, if there is one

update(delta_time: float)[source]

UI Input Box

class UIInputBox(game, size: pygame.math.Vector2, pos: pygame.math.Vector2 = <Vector2(0, 0)>, colour=(255, 255, 255), input_type='all', text='', font=None)[source]

Bases: object

__init__(game, size: pygame.math.Vector2, pos: pygame.math.Vector2 = <Vector2(0, 0)>, colour=(255, 255, 255), input_type='all', text='', font=None)[source]
draw(surf, offset: pygame.math.Vector2 = <Vector2(0, 0)>)[source]
focus()[source]
property should_focus
unfocus()[source]
update(delta_time: float)[source]
property value

UI Panel

class UIPanel(game: Game, elements: List[UIElementLike], is_active: bool = False)[source]

Bases: object

A container class for UIElements. Offers support for selection management. Note that UIPanel doesnt have a position or size so one is inferred from it’s contained elements.

__init__(game: Game, elements: List[UIElementLike], is_active: bool = False)[source]
draw(surface: pygame.Surface)[source]
property height: int
property is_active: bool
select_first_element()[source]

Selects the first element and sets the rest to previously_selected.

select_next_element(play_sound: bool = True)[source]
select_previous_element(play_sound: bool = True)[source]
property selected_element: UIElement | None
property selected_index: int
set_active(is_active: bool)[source]
set_selectable(is_selectable: bool)[source]
set_selected_index(new_index: int)[source]

Change selection to a given index. Note: Don’t use within panel due to recursion issues.

unselect_all_elements()[source]

Sets all elements is_selected to False and resets current_selected_index.

update(delta_time: float)[source]
property width: int
property x: int
property y: int

UI Tooltip

class UITooltip(game: Game, pos: pygame.Vector2, tooltip_key: str | None = None, tooltip_content: Tuple[str, str, str] | None = None)[source]

Bases: nqp.ui_elements.generic.ui_window.UIWindow

A UIWindow subclass for showing specific information about a hovered item.

Needs either tooltip_key or tooltip_content. tooltip_key takes precedent over tooltip_content, if both are provided only the key is used.

__init__(game: Game, pos: pygame.Vector2, tooltip_key: str | None = None, tooltip_content: Tuple[str, str, str] | None = None)[source]

Needs either tooltip_key or tooltip_content. tooltip_key takes precedent over tooltip_content, if both are provided only the key is used.

draw(surface: pygame.Surface)[source]
update(delta_time: float)[source]

UI Window

class UIWindow(game: Game, window_type: WindowType, pos: pygame.Vector2, size: pygame.Vector2, elements: List[UIElementLike], is_active: bool = False)[source]

Bases: nqp.ui_elements.generic.ui_panel.UIPanel

A more feature rich UIPanel, containing its own visual style.

__init__(game: Game, window_type: WindowType, pos: pygame.Vector2, size: pygame.Vector2, elements: List[UIElementLike], is_active: bool = False)[source]
draw(surface: pygame.Surface)[source]
property height: int
property width: int
property x: int
property y: int