Encyclopaedia

class encyclopaedia.Encyclopaedia(sorting_mode: SortMode = SortMode.NUMBER, show_locked_buttons: bool = False, show_locked_entry: bool = False, list_screen: str = 'encyclopaedia_list', entry_screen: str = 'encyclopaedia_entry', hyperlink_screen: str = 'encyclopaedia_list', name: str = '')[source]

Bases: EventEmitter, object

Container to manage the behaviour of a collection of EncEntry objects.

Parameters:
sorting_mode: SortMode = SortMode.NUMBER

How entries are sorted. Default is SortMode.NUMBER.

show_locked_buttons: bool = False

If True, locked entries show a placeholder label on the listing screen.

show_locked_entry: bool = False

If True, locked entries can be viewed, but the data is hidden from view with a placeholder.

list_screen: str = 'encyclopaedia_list'

The Ren’Py screen to display the list of entries.

entry_screen: str = 'encyclopaedia_entry'

The Ren’Py screen to display an open entry.

The Ren’Py screen to display an entry opened from a hyperlink.

name: str = ''

A optional name for the Encyclopaedia.

all_entries

All entries, regardless of status.

unlocked_entries

Only unlocked entries.

filtered_entries

Entries that match a subject filter.

filtering

The subject name being used as a filter.

size_all

Length of self.all_entries.

size_unlocked

Length of self.unlocked_entries.

reverse_sorting

Should sorting occur in reverse or not.

nest_alphabetical_sort

Should alphabetical sorting display each letter as a subject.

current_position

Index for the current entry open.

subjects

Collection of every subject.

active

The currently open entry.

locked_at_bottom

True if locked entries should appear at the bottom of the entry list or not.

ClearFilter() ClearFilter[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

CloseActiveEntry() CloseActiveEntry[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

FilterBySubject(subject: str) FilterBySubject[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

NextEntry() NextEntry[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

NextPage() NextPage[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

PreviousEntry() PreviousEntry[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

PreviousPage() PreviousPage[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

ResetSubPage() ResetSubPage[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

SetEntry(given_entry: EncEntry) SetEntry[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

Sort(sorting_mode: SortMode, reverse: bool = False) SortEncyclopaedia[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Parameters:
sorting_mode: SortMode

The type of sorting to use. If None specified, use the current sorting.

reverse: bool = False

Sort in reverse.

Returns:

Screen Action

ToggleShowLockedButtons() ToggleShowLockedButtonsAction[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

ToggleShowLockedEntry() ToggleShowLockedEntryAction[source]

Wrapper around the Action of the same name.

Use with a renpy button.

Returns:

Screen Action

add_entry(entry: Book | EncEntry) None[source]

Add an entry to the Encyclopaedia’s internal lists and sorts it.

Attempts to create duplicates are softly ignored. subjects list is updated when a new entry is added.

Parameters:
entry: Book | EncEntry

The Entry to add to the Encyclopaedia

property current_entries : list[Book | EncEntry]

Get all the entries which should be visible to the user.

Returns:

List of EncEntries. If filtering, only entries that match the filter are returned.

property current_entry : Book | EncEntry

Get the entry at current_position.

If show locked entries, pull from all_entries. Else, pull from unlocked_entries.

Returns:

EncEntry

next_entry() bool[source]

Set the next entry as the current entry.

property percentage_unlocked : float

Get the percentage of the Encyclopaedia that’s unlocked.

Returns:

Number between 0.0 and 1.0

Raises:

ZeroDivisionError – If the Encyclopaedia is empty

previous_entry() bool[source]

Set the previous entry as the current entry.

property reverse_sorting : bool

Get the direction of the current sorting.

Returns:

True if sorting is reversed, else False.

set_entry(entry: Book | EncEntry) None[source]

Set an Entry as active.

Parameters:
entry: Book | EncEntry

The Entry to set.

Raises:

ValueError – If the entry cannot be set.

sort(mode: SortMode | None = None, reverse: bool = False) None[source]

Sort the entries in the Encyclopaedia.

The attribute sorting_mode will be set to the value of mode.

Parameters:
mode: SortMode | None = None

The sorting mode to use. If None, the attribute sorting_mode will be used.

reverse: bool = False

If the sorting should be done in reverse or not.

property sorting_mode : SortMode

Get the current sorting mode of the Encyclopaedia.

property viewable_entries : list[Book | EncEntry]

Get the list of entries which are currently viewable.

property word_count : int

Get the total word count for the Encyclopaedia.

Returns:

The number of words in every EncEntry in the Encyclopaedia.