NotQuiteParadise2

nqp.ui_elements.generic package

Submodules

nqp.ui_elements.generic.fancy_font module

class Character(character, font, owning_block, index=- 1)[source]

Bases: object

__init__(character, font, owning_block, index=- 1)[source]
draw(surf, offset=(0, 0))[source]
get_width()[source]
update()[source]
class FancyFont(text: str, pos: pygame.Vector2, line_width: int = 0, font_effects: Optional[List[FontEffects]] = None)[source]

Bases: object

A font with effects. Use ‘<![font_name]>’ in the text to indicate which font to use for the following characters. Fonts names are ‘small’, ‘big’ or ‘red’. e.g. text=’this is <!red> red’. New lines are indicated with ‘n’.

__init__(text: str, pos: pygame.Vector2, line_width: int = 0, font_effects: Optional[List[FontEffects]] = None)[source]
draw(surface: pygame.Surface)[source]
static get_character_width(characters: List[Character]) int[source]
property height: int
property length: int
refresh()[source]

Refresh the font, restarting from the beginning with the current text.

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

nqp.ui_elements.generic.font module

class Font(path: str, colour: Tuple[int, int, int], text: str, line_width: int = 0, pos: pygame.Vector2 = (0, 0))[source]

Bases: object

__init__(path: str, colour: Tuple[int, int, int], text: str, line_width: int = 0, pos: pygame.Vector2 = (0, 0))[source]
draw(surface: pygame.Surface)[source]
get_text_width(text: str) int[source]

Get the width of the given text in the font.

property height: int
property number_of_lines: int

Calculate the number of lines the given text will take up, based on the line width.

property width: int

nqp.ui_elements.generic.ui_button module

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]

nqp.ui_elements.generic.ui_frame module

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]

nqp.ui_elements.generic.ui_input_box module

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

nqp.ui_elements.generic.ui_panel module

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

nqp.ui_elements.generic.ui_tooltip module

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]

nqp.ui_elements.generic.ui_window module

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

Module contents