Squashed 'deps/nostalgia/' changes from d0a32e24..fbebf4ef
fbebf4ef [nostalgia/gfx/studio/tilesheet] Fix export for 4bpp images 20513f77 [nostalgia/sample_project] Add type descriptors 25a7873e [nostalgia,studio] Fix crash that occurred when navigating to file that is not already open git-subtree-dir: deps/nostalgia git-subtree-split: fbebf4ef83626995bafb3e81754257c18f09def1
This commit is contained in:
parent
611df32bdb
commit
bceb2acc64
@ -0,0 +1,23 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "pages",
|
||||
"subscriptLevels" : 2,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
},
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint16;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.CompactPalette",
|
||||
"typeVersion" : 1
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "bpp",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "defaultPalette",
|
||||
"typeId" : "net.drinkingtea.ox.FileAddress;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.CompactTileSheet",
|
||||
"typeVersion" : 1
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "name",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "colors",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.PaletteColor;2"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.Palette.PalettePage",
|
||||
"typeVersion" : 2
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "colorNames",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pages",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.Palette.PalettePage;2"
|
||||
}
|
||||
],
|
||||
"preloadable" : true,
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.Palette",
|
||||
"typeVersion" : 5
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "r",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "g",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "b",
|
||||
"typeId" : "B.uint8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "a",
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.PaletteColor",
|
||||
"typeVersion" : 2
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "id",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "name",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "rows",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "columns",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheets",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet;5"
|
||||
},
|
||||
{
|
||||
"fieldName" : "pixels",
|
||||
"subscriptLevels" : 1,
|
||||
"subscriptStack" :
|
||||
[
|
||||
{
|
||||
"subscriptType" : 4
|
||||
}
|
||||
],
|
||||
"typeId" : "B.uint8;0"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet",
|
||||
"typeVersion" : 5
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
O1;net.drinkingtea.ox.TypeDescriptor;1;{
|
||||
"fieldList" :
|
||||
[
|
||||
{
|
||||
"fieldName" : "bpp",
|
||||
"typeId" : "B.int8;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "idIt",
|
||||
"typeId" : "B.int32;0"
|
||||
},
|
||||
{
|
||||
"fieldName" : "defaultPalette",
|
||||
"typeId" : "net.drinkingtea.ox.BasicString#8#;1"
|
||||
},
|
||||
{
|
||||
"fieldName" : "subsheet",
|
||||
"typeId" : "net.drinkingtea.nostalgia.gfx.TileSheet.SubSheet;5"
|
||||
}
|
||||
],
|
||||
"primitiveType" : 5,
|
||||
"typeName" : "net.drinkingtea.nostalgia.gfx.TileSheet",
|
||||
"typeVersion" : 5
|
||||
}
|
@ -36,21 +36,12 @@ OX_MODEL_BEGIN(TileSheetEditorConfig)
|
||||
OX_MODEL_END()
|
||||
|
||||
static ox::Vector<uint32_t> normalizePixelSizes(
|
||||
ox::Vector<uint8_t> const&inPixels,
|
||||
int const bpp) noexcept {
|
||||
uint_t const bytesPerTile = bpp == 8 ? PixelsPerTile : PixelsPerTile / 2;
|
||||
ox::Vector<uint8_t> const&inPixels) noexcept {
|
||||
ox::Vector<uint32_t> outPixels;
|
||||
if (bytesPerTile == 64) { // 8 BPP
|
||||
outPixels.resize(inPixels.size());
|
||||
for (std::size_t i = 0; i < inPixels.size(); ++i) {
|
||||
outPixels[i] = inPixels[i];
|
||||
}
|
||||
} else { // 4 BPP
|
||||
outPixels.resize(inPixels.size() * 2);
|
||||
for (std::size_t i = 0; i < inPixels.size(); ++i) {
|
||||
outPixels[i * 2 + 0] = inPixels[i] & 0xF;
|
||||
outPixels[i * 2 + 1] = inPixels[i] >> 4;
|
||||
}
|
||||
outPixels.reserve(inPixels.size());
|
||||
outPixels.resize(inPixels.size());
|
||||
for (std::size_t i = 0; i < inPixels.size(); ++i) {
|
||||
outPixels[i] = inPixels[i];
|
||||
}
|
||||
return outPixels;
|
||||
}
|
||||
@ -409,12 +400,11 @@ void TileSheetEditorImGui::showSubsheetEditor() noexcept {
|
||||
ox::Error TileSheetEditorImGui::exportSubhseetToPng(int const scale) const noexcept {
|
||||
OX_REQUIRE(path, studio::saveFile({{"PNG", "png"}}));
|
||||
// subsheet to png
|
||||
auto const&img = m_model.img();
|
||||
auto const&s = m_model.activeSubSheet();
|
||||
auto const&pal = m_model.pal();
|
||||
auto const width = s.columns * TileWidth;
|
||||
auto const height = s.rows * TileHeight;
|
||||
auto pixels = normalizePixelSizes(s.pixels, img.bpp);
|
||||
auto pixels = normalizePixelSizes(s.pixels);
|
||||
pixels = normalizePixelArrangement(pixels, s.columns, scale);
|
||||
auto const err = toPngFile(
|
||||
path,
|
||||
@ -566,8 +556,10 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
|
||||
m_view.setPalIdx(i);
|
||||
}
|
||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||
auto const rqst = ox::sfmt<ox::BasicString<100>>("{};{}", i, m_model.palettePage());
|
||||
oxLogError(studio::navigateTo(m_sctx, m_model.palPath(), rqst));
|
||||
studio::navigateTo(
|
||||
m_sctx,
|
||||
m_model.palPath(),
|
||||
ox::sfmt("{};{}", i, m_model.palettePage()));
|
||||
}
|
||||
// Column: color RGB
|
||||
ImGui::TableNextColumn();
|
||||
|
@ -18,8 +18,8 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
ox::Error navigateTo(StudioContext &ctx, ox::StringViewCR filePath, ox::StringViewCR args) noexcept {
|
||||
return ctx.ui.navigateTo(filePath, args);
|
||||
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept {
|
||||
ctx.ui.navigateTo(std::move(filePath), std::move(navArgs));
|
||||
}
|
||||
|
||||
namespace ig {
|
||||
@ -111,10 +111,8 @@ void StudioUI::handleKeyEvent(turbine::Key const key, bool const down) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
ox::Error StudioUI::navigateTo(ox::StringViewCR path, ox::StringViewCR navArgs) noexcept {
|
||||
OX_RETURN_ERROR(openFile(path));
|
||||
m_activeEditor->navigateTo(navArgs);
|
||||
return {};
|
||||
void StudioUI::navigateTo(ox::StringParam path, ox::StringParam navArgs) noexcept {
|
||||
m_navAction.emplace(std::move(path), std::move(navArgs));
|
||||
}
|
||||
|
||||
void StudioUI::draw() noexcept {
|
||||
@ -287,6 +285,11 @@ void StudioUI::drawTabs() noexcept {
|
||||
}
|
||||
m_closeActiveTab = false;
|
||||
}
|
||||
if (m_navAction) {
|
||||
oxLogError(openFile(m_navAction->path));
|
||||
m_activeEditor->navigateTo(m_navAction->args);
|
||||
m_navAction.reset();
|
||||
}
|
||||
}
|
||||
|
||||
void StudioUI::loadEditorMaker(EditorMaker const&editorMaker) noexcept {
|
||||
|
@ -62,13 +62,18 @@ class StudioUI: public ox::SignalHandler {
|
||||
&m_renameFile,
|
||||
};
|
||||
bool m_showProjectExplorer = true;
|
||||
struct NavAction {
|
||||
ox::String path;
|
||||
ox::String args;
|
||||
};
|
||||
ox::Optional<NavAction> m_navAction;
|
||||
|
||||
public:
|
||||
explicit StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept;
|
||||
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
ox::Error navigateTo(ox::StringViewCR path, ox::StringViewCR navArgs = {}) noexcept;
|
||||
void navigateTo(ox::StringParam path, ox::StringParam navArgs) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Project *project() noexcept {
|
||||
|
@ -27,6 +27,6 @@ inline keel::Context &keelCtx(StudioContext &ctx) noexcept {
|
||||
return keelCtx(ctx.tctx);
|
||||
}
|
||||
|
||||
ox::Error navigateTo(StudioContext &ctx, ox::StringViewCR filePath, ox::StringViewCR args) noexcept;
|
||||
void navigateTo(StudioContext &ctx, ox::StringParam filePath, ox::StringParam navArgs) noexcept;
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user