Jazz2/Editor/Shell/TileSetsDialog.h file

Namespaces

namespace Jazz2
Root namespace of Jazz² Resurrection.
namespace Jazz2::Formats
The game's own level and tile set formats.
namespace Jazz2::UI
User interface and menus.
namespace Jazz2::UI::Windows
Toolkit of windows, panels and controls, compiled only if WITH_UI_WINDOWS.
namespace Jazz2::Editor

Classes

struct Jazz2::Editor::TileTarget
Where tiles are added to.
struct Jazz2::Editor::AddTilesOptions
How the tiles of an image are cut and matched to the colors, see AddTilesFromImageAsync().

Functions

auto GetTileSetLabel(StringView name) -> String
Returns the name of a tile set as it's shown.
auto IsLevelTileSet(const LevelDocument& document, std::uint8_t source) -> bool
Returns true if a tile set of the level (as TileRef::Source) is stored in the level itself.
auto ReadTileSetOf(IEditorContext& session, std::uint8_t source, Formats::TileSetData& tileSet) -> bool
Reads a whole tile set of the level (as TileRef::Source), from its file or from the level, returns false if it can't.
auto SerializeTileSet(const Formats::TileSetData& tileSet, SmallVectorImpl<std::uint8_t>& bytes) -> bool
Writes a whole tile set into bytes as its file stores it.
void BakeRemapping(Formats::TileSetData& tileSet, const std::uint8_t* remapping)
Puts the colors an extra tile set is matched to into its 8-bit tiles, see Formats::ExtraTileSetRecord::Remapped.
auto CanAddTileIds(IEditorContext& session, std::int32_t added) -> bool
Returns true if the level can refer to added more tiles of its tile sets.
auto SuggestTileSetName(StringView base, StringView suffix) -> String
Returns a name for a new tile set made of base and suffix, as tile sets are named, that isn't taken yet.
auto IsOwnTileSetCopy(StringView name) -> bool
Returns true if the tile set file used is the copy in the user content, which is written over then.
void GetLevelPalette(IEditorContext& session, std::uint32_t(&palette)[256])
Fills the palette the level is shown in, its own one or the one of its default tile set, the first entry transparent.
void AddTileTargetRow(IEditorContext& session, Stack* row, std::shared_ptr<TileTarget> target)
Adds a dropdown to choose where tiles are added to into a row, with the name of a new tile set next to it.
void AddTileTargetNote(IEditorContext& session, Stack* parent, std::shared_ptr<TileTarget> target)
Adds a note about where the tiles go, for a tile set file shadowed by its copy in the user content, say.
void ShowTileSetsDialog(IEditorContext& session)
Shows the tile sets of the level — the default one and the extra ones that follow it.
void ShowExportTileSetImageDialog(IEditorContext& session, std::uint8_t source)
Asks where to save the tiles of a tile set of the level (as TileRef::Source) as an image.
auto SetDefaultTileSet(IEditorContext& session, StringView name) -> bool
Makes a tile set the default one of the level as an undoable step, returns false if it can't be read.
auto AddExtraTileSet(IEditorContext& session, StringView name, std::int32_t matchColors = -1) -> bool
Adds an extra tile set with all of its tiles as an undoable step, returns false if it can't be.
void ShowAddTilesFromImageDialog(IEditorContext& session)
Asks for an image and adds its tiles to the end of a tile set of the level.
auto AddTilesFromImage(IEditorContext& session, const TileTarget& target, StringView imagePath, bool skipExisting, bool dither) -> bool
Adds the tiles of an image to the end of a tile set, as ShowAddTilesFromImageDialog() does.
void AddTilesFromImageAsync(IEditorContext& session, const TileTarget& target, StringView imagePath, const AddTilesOptions& options, Function<void(bool)>&& onDone)
Adds the tiles of an image to the end of a tile set as AddTilesFromImage() does, cut off the user interface.
auto AppendTiles(IEditorContext& session, const TileTarget& target, const Formats::TileSetData& tiles, TileRef& first) -> bool
Adds all tiles of tiles to the end of a tile set, as one undoable step.
auto CopyTileIntoLevel(IEditorContext& session, const TileRef& tile, TileRef& copy) -> bool
Copies a tile into the tiles of this level, and the level shows the copy everywhere it showed the tile.

Variables

char LevelTileSetName constexpr
Name of the extra tile set a level stores in itself, see Formats::ExtraTileSetRecord::Embedded.

Function documentation

void BakeRemapping(Formats::TileSetData& tileSet, const std::uint8_t* remapping)

Puts the colors an extra tile set is matched to into its 8-bit tiles, see Formats::ExtraTileSetRecord::Remapped.

The tiles then have the indices of the palette of the level, as they were shown, and the tile set doesn't need to be matched anymore. Only a tile set the level stores in itself can be changed so, a file is shared by levels.

bool CanAddTileIds(IEditorContext& session, std::int32_t added)

Returns true if the level can refer to added more tiles of its tile sets.

Tile IDs are 16-bit and the animated tiles take the last ones, shows a message if it can't.

String SuggestTileSetName(StringView base, StringView suffix)

Returns a name for a new tile set made of base and suffix, as tile sets are named, that isn't taken yet.

Only the file name of base is taken, lowercase, without other characters than letters, digits, dashes and underscores, short enough for the number added to make it unique.

void ShowTileSetsDialog(IEditorContext& session)

Shows the tile sets of the level — the default one and the extra ones that follow it.

The tiles of the level follow every change of the tile sets, so a tile shows the same picture after an extra tile set is moved or another one before it is removed. Tiles of a removed tile set are cleared. New tile sets are made there too, tiles added to them, their images exported and the default one rearranged.

void ShowExportTileSetImageDialog(IEditorContext& session, std::uint8_t source)

Asks where to save the tiles of a tile set of the level (as TileRef::Source) as an image.

Rows of 10 tiles, as the original tile sets were drawn, with an image of their masks next to it.

bool AddExtraTileSet(IEditorContext& session, StringView name, std::int32_t matchColors = -1)

Adds an extra tile set with all of its tiles as an undoable step, returns false if it can't be.

With matchColors of -1, the colors of an 8-bit tile set of another palette than the level are matched to the palette of the level, 1 matches them and 0 doesn't, see Formats::ExtraTileSetRecord::Remapped.

void ShowAddTilesFromImageDialog(IEditorContext& session)

Asks for an image and adds its tiles to the end of a tile set of the level.

The tiles get the closest colors of the palette of the tile set, the tile set is saved into the user content, or into the level if it's the one the level stores in itself. Its tiles that were there keep their places, so does every tile of the level.

bool AddTilesFromImage(IEditorContext& session, const TileTarget& target, StringView imagePath, bool skipExisting, bool dither)

Adds the tiles of an image to the end of a tile set, as ShowAddTilesFromImageDialog() does.

With skipExisting, a tile the tile set has already isn't added again. Returns false if nothing was added.

void AddTilesFromImageAsync(IEditorContext& session, const TileTarget& target, StringView imagePath, const AddTilesOptions& options, Function<void(bool)>&& onDone)

Adds the tiles of an image to the end of a tile set as AddTilesFromImage() does, cut off the user interface.

How far it is is shown in a window that can stop it. onDone gets whether tiles were added, on the main thread.

bool AppendTiles(IEditorContext& session, const TileTarget& target, const Formats::TileSetData& tiles, TileRef& first)

Adds all tiles of tiles to the end of a tile set, as one undoable step.

The tiles are taken as they are, true color ones stay true color. A tile set file is saved into the user content. first is then the first added tile as the level refers to it. Returns false if they can't be added.

bool CopyTileIntoLevel(IEditorContext& session, const TileRef& tile, TileRef& copy)

Copies a tile into the tiles of this level, and the level shows the copy everywhere it showed the tile.

The copy is as the level showed the tile, changed in the level or not, so it can be changed further in true color, only in this level. All of it is one undoable step. Returns false if it can't be copied.

Variable documentation

char LevelTileSetName constexpr

Name of the extra tile set a level stores in itself, see Formats::ExtraTileSetRecord::Embedded.

It can't be the name of a tile set file.