Jazz2/Editor/Shell/WeaponTemplates.h file

Namespaces

namespace Jazz2
Root namespace of Jazz² Resurrection.
namespace Jazz2::Editor

Classes

struct Jazz2::Editor::WeaponTemplateImage
An image a template of a custom weapon takes from a PNG file next to it, with how its frames are laid out.
struct Jazz2::Editor::CustomWeaponTemplate
Template of a custom weapon, read from a .json file in Editor/Weapons/.

Functions

auto ReadCustomWeaponTemplate(const Json::Value& value, StringView sourcePath, CustomWeaponTemplate& result) -> bool
Reads a template of a custom weapon from an item of a .json file.
auto ApplyCustomWeaponTemplate(const CustomWeaponTemplate& weaponTemplate, WeaponDefinition& weapon, Function<std::int32_t(const WeaponTemplateImage&)>&& addImage, Function<std::int32_t(StringView)>&& addSound) -> bool
Makes a weapon as a template describes it.
void WriteCustomWeaponTemplate(const WeaponDefinition& weapon, const WeaponsDescription& weapons, Function<String(std::int32_t)>&& imageFile, Function<String(std::int32_t)>&& soundFile, Json::Value& result)
Describes a custom weapon as an item of a template file.
auto WriteWeaponTemplateFile(const Json::Value& value) -> std::string
Returns the text of a template file, tab-indented, numbers as short as they're typed.

Function documentation

bool ReadCustomWeaponTemplate(const Json::Value& value, StringView sourcePath, CustomWeaponTemplate& result)

Reads a template of a custom weapon from an item of a .json file.

Returns false if it isn't one, an item without "Kind": "Custom".

bool ApplyCustomWeaponTemplate(const CustomWeaponTemplate& weaponTemplate, WeaponDefinition& weapon, Function<std::int32_t(const WeaponTemplateImage&)>&& addImage, Function<std::int32_t(StringView)>&& addSound)

Makes a weapon as a template describes it.

weapon is a custom weapon made from CustomWeaponTemplate::BasedOn already, what the template doesn't describe is kept. addImage and addSound embed a file in the level and return its index, -1 if it can't be, the sprite or the sound is as in the game then. Returns false if any file couldn't be embedded.

void WriteCustomWeaponTemplate(const WeaponDefinition& weapon, const WeaponsDescription& weapons, Function<String(std::int32_t)>&& imageFile, Function<String(std::int32_t)>&& soundFile, Json::Value& result)

Describes a custom weapon as an item of a template file.

imageFile and soundFile save an embedded image or sound of the level as a file next to the template and return its name, empty if it can't be saved.