Storybook: Adding language bookmarks - #2712
Conversation
TOC (table of contents), EN, and ES bookmark tabs have been added to the storybook menu to allow players to filter quests by language and still search through a single mixed list. I updated quest.gd and individual .tres quest files with ISO 639 language codes ("en" and "es") so the storybook can categorize the quests by this. Selecting a bookmark compares each quest's ISO code with it and filters the master _all_quests array, making a new list with only the matching language quests to show on the page. I also had to update func _on_left_button_pressed() to get players back to the table of contents or previous pages whenever they flip past page 0.
|
Play this branch at https://play.threadbare.game/branches/endlessm/language-bookmarks/. (This launches the game from the start, not directly at the change(s) in this pull request.) |
manuq
left a comment
There was a problem hiding this comment.
This is a great start and already working! In addition to the quests variable handling request:
The page is empty for "es" in Dev Archipelago storybooks:
Should a language bookmark/section appear if there are no quests for that language? The page would be empty so I don't think so.
Should language bookmarks/sections appear at all if all the quests have the same language? The content of that section would be the same as the table of contents, so I don't think so.
The bookmarks are now hardcoded to the existing StoryQuest languages. But what will happen when a StoryQuest in a different language is added? Maybe it's fine for now, as I don't expect contributions in languages that we can't review (note to self: we should document that somewhere).
Minor detail: the buttons fade in and out when the pages flip. They should stay in place, considering that they are not part of the pages content.
| # Saving a copy of all quests | ||
| _all_quests = quests.duplicate() |
There was a problem hiding this comment.
This does:
_all_quests = quests.duplicate()
Then show_table_of_contents() does:
quests = _all_quests.duplicate()
While it works, it's a bit odd that the script changes the exported quests property. An exported property is supposed to be changed from the outside (from the user of this storybook).
Instead, add a _flltered_quests internal property. And change _populate_quest_lists() to use _filtered_quests. Consider it the variable containing the filtered view. In show_table_of_contents() do:
_filtered_quests = quests
Note that there is no need for duplicate() at all. In the same way the filter() calls in the per-language handlers don't duplicate the quests. Arrays in Godot are always passed by reference.
Co-authored-by: Manuel Quiñones <manuq@endlessaccess.org>
I added two Spanish and one French quests. The questss that aren't in English are also put into seperate lists for their respective language. They are actually assigned a language in the loop that appends them to the array so they can be filtered by the bookmarks.
…adbare into language-bookmarks
- Hide unused language tabs by evaluating `_all_quests` on ready. This prevents players from clicking into empty quest lists when there aren't any any quests for that specific language. - Remove all language tabs if all quests share the same language. _all_quests is inspected during _update_bookmark_visibility() to count unique language codes. If only one code exists in the array, the function sets the visibility of the language filter buttons to false. - Reparent `BookmarkContainer` outside `%StoryBookContent`. This keeps the tab buttons on the screen instead of fading in and out during page flip animations.
- Introduced `_filtered_quests` property to represent the active quest view (TOC or language). - Replaced `quests.duplicate()` calls in initialization and filtering functions with direct assignments and array references. - Updated UI generation (`_populate_quest_lists`, `_create_quest_button`) and page visibility functions to use `_filtered_quests`.
TOC (table of contents), EN, and ES bookmark tabs have been added to the storybook menu to allow players to filter quests by language and still search through a single mixed list. I updated quest.gd and individual .tres quest files with ISO 639 language codes ("en" and "es") so the storybook can categorize the quests by this. Selecting a bookmark compares each quest's ISO code with it and filters the master _all_quests array, making a new list with only the matching language quests to show on the page. I also had to update func _on_left_button_pressed() to get players back to the table of contents or previous pages whenever they flip past page 0.
Resolves #2548