NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches

Classes

struct  nnl::text::Text
 Represents an in-game text archive. More...

Typedefs

using nnl::text::IndexedString = std::vector<u16>
 A string consisting of special codes and indices into the character lookup table.

Functions

std::vector< std::string > nnl::text::Convert (const Text &text, const std::unordered_map< u16, std::string_view > &replacements=kSpecialCodeToString)
 Converts an in-game text archive to a vector of UTF-8 encoded strings.
Text nnl::text::Convert (const std::vector< std::string > &stext, const std::unordered_map< u16, std::string_view > &replacements=kSpecialCodeToString, const std::vector< u16 > &characters={})
 Converts a vector of UTF-8 encoded strings to an in-game text archive.
bool nnl::text::IsOfType (BufferView buffer)
 Tests if the provided file is a text archive.
Text nnl::text::Import (BufferView buffer)
 Parses a binary file and converts it to a Text object.
Buffer nnl::text::Export (const Text &text)
 Converts a text archive to a binary file representation.

Variables

constexpr u16 nnl::text::kSpecialCodeMask = 0xF000
 A bitmask for identifying special codes within an IndexedString.
const std::unordered_map< u16, std::string_view > nnl::text::kSpecialCodeToString
 A default mapping of special codes to string representations.

Detailed Description


Class Documentation

◆ nnl::text::Text

struct nnl::text::Text

Represents an in-game text archive.

This structure represents an in-game text archive that consists of strings. These strings may be used in dialogs, menus, and in other UI elements.

Note
This struct represents only a portion of the data required by the games to render text. Its binary representation should be used as part of larger containers (which differ between the games) that also include bitmap fonts and glyph advance widths.
See also
nnl::asset::Asset
nnl::asset::BitmapText
nnl::texture::TextureContainer

Public Attributes

std::vector< IndexedStringstrings
 Strings consisting of special codes and indices that reference the characters array.
std::vector< u16characters
 A palette of unique UCS-2 encoded characters used by the strings.

Member Data Documentation

◆ characters

std::vector<u16> nnl::text::Text::characters

A palette of unique UCS-2 encoded characters used by the strings.

◆ strings

std::vector<IndexedString> nnl::text::Text::strings

Strings consisting of special codes and indices that reference the characters array.

Typedef Documentation

◆ IndexedString

using nnl::text::IndexedString = std::vector<u16>

A string consisting of special codes and indices into the character lookup table.

See also
nnl::text::Text
nnl::text::kSpecialCodeMask
nnl::text::kSpecialCodeToString

Function Documentation

◆ Convert() [1/2]

Text nnl::text::Convert ( const std::vector< std::string > & stext,
const std::unordered_map< u16, std::string_view > & replacements = kSpecialCodeToString,
const std::vector< u16 > & characters = {} )

Converts a vector of UTF-8 encoded strings to an in-game text archive.

This function takes a vector of UTF-8 strings and converts them into Text.

Parameters
stextA vector of UTF-8 encoded strings to be converted.
replacementsAn optional map that provides replacements for certain substrings with their code representations.
charactersPrecomputed UCS-2 character set. If provided, used as the character "palette" instead of generating one from the input text.
Returns
A Text object representing the converted in-game text archive.
See also
nnl::text::Text

◆ Convert() [2/2]

std::vector< std::string > nnl::text::Convert ( const Text & text,
const std::unordered_map< u16, std::string_view > & replacements = kSpecialCodeToString )

Converts an in-game text archive to a vector of UTF-8 encoded strings.

This function takes a Text archive and converts it into a vector of UTF-8 strings. It can also apply optional replacements for special codes using the provided mapping.

Parameters
textThe Text object to be converted.
replacementsAn optional map that provides replacements for special codes with their string representations.
Returns
A vector of strings representing the converted UTF-8 text.
See also
nnl::text::kSpecialCodeToString

◆ Export()

Buffer nnl::text::Export ( const Text & text)
nodiscard

Converts a text archive to a binary file representation.

This function takes a Text object and converts it into a Buffer, which represents the binary format of the text.

Parameters
textThe Text object to be converted into a binary format.
Returns
A Buffer containing the binary representation of the text.

◆ Import()

Text nnl::text::Import ( BufferView buffer)

Parses a binary file and converts it to a Text object.

This function takes a binary representation of a text archive, parses its contents, and converts them into a Text struct for easier access and manipulation.

Parameters
bufferThe binary data to be processed.
Returns
A Text object representing the converted data.
See also
nnl::text::IsOfType
nnl::text::Export

◆ IsOfType()

bool nnl::text::IsOfType ( BufferView buffer)

Tests if the provided file is a text archive.

This function takes data representing a file and checks whether it corresponds to the in-game text archive format.

Parameters
bufferThe binary file to be tested.
Returns
Returns true if the file is identified as a text archive.
See also
nnl::text::Import

Variable Documentation

◆ kSpecialCodeMask

u16 nnl::text::kSpecialCodeMask = 0xF000
constexpr

A bitmask for identifying special codes within an IndexedString.

Values where the upper 4 bits match this mask are interpreted as formatting, control, or special characters rather than character indices.

See also
nnl::text::IndexedString

◆ kSpecialCodeToString

const std::unordered_map<u16, std::string_view> nnl::text::kSpecialCodeToString

A default mapping of special codes to string representations.

This map associates special codes that are used within indexed strings with their possible textual representations. These codes represent symbols, special or control characters in the text.

See also
nnl::text::IndexedString
nnl::text::Convert