Repository navigation
perf(items): resolve tooltip condition and placeholder names at load - #863
Open
ezequielzacca wants to merge 389 commits into
Open
ezequielzacca wants to merge 389 commits into
ezequielzacca wants to merge 389 commits into
Conversation
…ooltip-durability
…ooltip-durability
…m-tooltip-shared-texts # Conflicts: # docs/item-data.md # src/bin/Data/Items/Group12_Wing.json # src/bin/Data/Items/Group13_Helper.json # src/source/Data/GameData/ItemData/ItemDataValidation.cpp # src/source/Data/GameData/ItemData/ItemDataValidation.h # tests/data/test_item_description_placeholders.cpp
…em-tooltip-translations
…em-tooltip-chain-values # Conflicts: # docs/item-data.md # src/source/Data/GameData/ItemData/ItemDataValidation.cpp # src/source/Data/GameData/ItemData/ItemDescriptionPlaceholders.h # src/source/Data/GameData/ItemData/ItemJsonFormat.cpp # src/source/Engine/Object/ZzzInventory.cpp
…tem-tooltip-third-chain # Conflicts: # docs/item-data.md
…em-tooltip-names # Conflicts: # docs/item-data.md # src/source/Data/GameData/ItemData/ItemDataValidation.cpp # src/source/Data/GameData/ItemData/ItemDescriptionPlaceholders.h # src/source/Data/GameData/ItemData/ItemJsonFormat.cpp
…es-from-data # Conflicts: # docs/item-data.md
…undle-names # Conflicts: # docs/item-data.md
…oltip-layouts # Conflicts: # src/source/Data/GameData/ItemData/ItemDataValidation.h
…ooltip-durability # Conflicts: # src/source/Data/DataHandler/ItemData/ItemDataHandler.cpp # src/source/Data/GameData/ItemData/ItemDataValidation.h # tests/data/test_item_database_files.cpp
…m-tooltip-shared-texts # Conflicts: # src/bin/Data/Items/Group12_Wing.json # src/source/Data/DataHandler/ItemData/ItemDataHandler.cpp # src/source/Data/GameData/ItemData/ItemDataValidation.cpp # src/source/Data/GameData/ItemData/ItemDataValidation.h # tests/data/test_item_database_files.cpp # tests/data/test_item_description_placeholders.cpp
…em-tooltip-translations # Conflicts: # src/bin/Data/Items/Group13_Helper.json
…em-tooltip-chain-values # Conflicts: # tests/data/test_item_description_placeholders.cpp
…tem-tooltip-third-chain
…ooltip-durability
…m-tooltip-shared-texts
…em-tooltip-translations
…tem-tooltip-third-chain
…em-tooltip-chain-values
…tat words aren't the game's texts
The "i" of "%% increase" leaked into seven translations of "Damage +20% increase effect" ("iefecto", "infeito",
"inувеличение", ...). The level lines' test no longer compares the Fruits' stat words with the game's texts, which
keep the words this step corrects.
…em-tooltip-chain-values
…tem-tooltip-third-chain
The tooltip is rebuilt every frame it shows, and every layout, description and name line found its conditions and placeholders by name: string comparisons through the value tables, and per shown line a std::function, a std::string and a std::wstring (CODING_RULES.md, section 12). - A condition keeps the value or state its name means (TooltipValue, TooltipState), resolved by ReadTooltipCondition; checking it is a switch. - A line's text is compiled once per language into literal pieces and resolved placeholders (a built-in value, a stat table, a skill or monster, the item's level values), and kept until the item data, the stat file or the tooltip file changes (ItemDatabase::GetVersion, which the tooltip file now bumps too). - The layout lines are written straight into the tooltip's rows; the name and description lines into a stack buffer. - ComputeItemTooltipValues no longer allocates: the item's name points at its data, and the add option's duration text is cached by its time. Every item's tooltip is unchanged (the recorded snapshot).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR's own change: compare with #836. The diff of this PR also holds every earlier step of #815, since a PR from a fork can only target this repository's branches.
Summary
The follow-up promised in #824's review (the comment): resolving the tooltip's condition and placeholder names when the files load, so drawing a tooltip compares no names and allocates nothing. Stacked last, on #836: every step of #815 changes the layout code, so this goes on top of all of them in one pass instead of being redone at each step. Only the last commit,
perf(items): resolve tooltip condition and placeholder names at load, is this change.RenderItemInforebuilds the tooltip every frame it shows. Every layout, description and name line found its conditions and placeholders by name: string comparisons through the value tables, then per shown line astd::function, astd::stringand astd::wstring(CODING_RULES.md §12). The name lines also run for the windows and ground labels.How
TooltipValue,TooltipState), resolved byReadTooltipCondition. Checking one is aswitch. The name stays for writing the file and for the editor.Engine/Object/ItemTooltipTextkeeps the compiled texts until the item data, the stat file or the tooltip file changes (ItemDatabase::GetVersion, whichSetTooltipFilenow bumps too). A compiled text keeps its source and bindings, so a text changed in place is compiled again.TextList); the name and description lines into a stack buffer. A placeholder that names nothing, or a text with a stray brace, stays as written from there on, asFillPlaceholdersdid.ComputeItemTooltipValuesno longer allocates. The item's name points at its data, and the add option's duration text is cached by its time.GetItemTooltipValue,GetItemTooltipTextandGetItemTooltipStatekeep their by-name overloads for the tests and the editor; they resolve the name first.What stays
WrapTextToWidth), as before feat(items): the tooltip's stat lines come from a tooltip layout #824.std::wstring; it's built from the stack buffer.Tests
test_item_tooltip_text.cpp:{level}and bound placeholders;Screenshots
This PR's build, for a level 400 Dark Knight. The tooltips look as on #836, since only how they're built changed.
Divine Sword of Archangel +15
Layout lines: damage, speed, durability and requirements, with their colors; the skill line's mana (
skillMana).Dragon Knight Armor +15
Layout lines: defense, durability and requirements.
Wing of Storm +15
Description lines with stat file tables at the item's level (
{table:...}).Horn of Fenrir
A name line ("+Illusion" by
excellentFlags) and its life.Large Healing Potion ×3
A shared text with a condition (
@numberOfItems,when: [durability]).Orb of Rageful Blow
Requirements of a skill orb.
Guardian Angel
A pet's description and life.
Wizards Ring
Description lines and durability.
Related issues
Follows #824's review. Builds on #836, #835, #834, #833, #830, #829, #828, #827, #825 and #824 (#815).
Checklist
docs/CODING_RULES.md.docs/build/README.md).test_item_database_filesin three random orders; the quality gate passes.