[nostalgia] Add NewMenu for creating new files

This commit is contained in:
2022-07-29 21:38:18 -05:00
parent b14e41d057
commit 275e9dbff1
31 changed files with 630 additions and 120 deletions
+22 -22
View File
@@ -61,10 +61,10 @@ struct TileSheet {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheet.SubSheet";
static constexpr auto TypeVersion = 1;
ox::String name;
int columns = 1;
int rows = 1;
int columns = 0;
int rows = 0;
ox::Vector<SubSheet> subsheets;
ox::Vector<uint8_t> pixels = {};
ox::Vector<uint8_t> pixels;
constexpr SubSheet() noexcept = default;
constexpr SubSheet(const SubSheet &other) noexcept {
@@ -84,8 +84,8 @@ struct TileSheet {
other.columns = 0;
other.rows = 0;
}
constexpr SubSheet(const char *pName, int pColumns, int pRows) noexcept:
name(pName), columns(pColumns), rows(pRows), pixels(static_cast<std::size_t>(columns * rows * PixelsPerTile)) {
constexpr SubSheet(const char *pName, int pColumns, int pRows, int bpp) noexcept:
name(pName), columns(pColumns), rows(pRows), pixels(static_cast<std::size_t>(columns * rows * PixelsPerTile) / (bpp == 4 ? 2u : 1u)) {
}
constexpr SubSheet(const char *pName, int pColumns, int pRows, ox::Vector<uint8_t> pPixels) noexcept:
name(pName), columns(pColumns), rows(pRows), pixels(std::move(pPixels)) {
@@ -267,27 +267,27 @@ struct TileSheet {
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.TileSheet";
static constexpr auto TypeVersion = 2;
int8_t bpp = 0;
int8_t bpp = 4;
ox::FileAddress defaultPalette;
SubSheet subsheet;
SubSheet subsheet{"Root", 1, 1, bpp};
constexpr TileSheet() noexcept = default;
inline TileSheet(const TileSheet &other) noexcept {
bpp = other.bpp;
defaultPalette = other.defaultPalette;
subsheet = other.subsheet;
inline TileSheet(const TileSheet &other) noexcept:
bpp(other.bpp),
defaultPalette(other.defaultPalette),
subsheet(other.subsheet) {
}
inline TileSheet(TileSheet &&other) noexcept {
bpp = other.bpp;
defaultPalette = std::move(other.defaultPalette);
subsheet = std::move(other.subsheet);
inline TileSheet(TileSheet &&other) noexcept:
bpp(std::move(other.bpp)),
defaultPalette(std::move(other.defaultPalette)),
subsheet(std::move(other.subsheet)) {
}
inline auto &operator=(const TileSheet &other) noexcept {
bpp = other.bpp;
defaultPalette = other.defaultPalette;
subsheet = other.subsheet;
return *this;
if (this != &other) {
bpp = other.bpp;
defaultPalette = other.defaultPalette;
subsheet = other.subsheet; } return *this;
}
inline auto &operator=(TileSheet &&other) noexcept {
bpp = other.bpp;
@@ -359,10 +359,10 @@ struct TileSheet {
constexpr ox::Error addSubSheet(const SubSheetIdx &idx) noexcept {
auto &parent = getSubSheet(idx);
if (parent.subsheets.size() < 2) {
parent.subsheets.emplace_back(ox::sfmt("Subsheet {}", parent.subsheets.size()).c_str(), 1, 1);
parent.subsheets.emplace_back(ox::sfmt("Subsheet {}", parent.subsheets.size()).c_str(), 1, 1, bpp);
} else {
parent.subsheets.emplace_back("Subsheet 0", parent.columns, parent.rows);
parent.subsheets.emplace_back("Subsheet 1", 1, 1);
parent.subsheets.emplace_back("Subsheet 0", parent.columns, parent.rows, bpp);
parent.subsheets.emplace_back("Subsheet 1", 1, 1, bpp);
}
return OxError(0);
}