From 462375aa5d228d46174face9f961121974718b60 Mon Sep 17 00:00:00 2001
From: Gary Talent <gary@drinkingtea.net>
Date: Wed, 16 Feb 2022 20:25:00 -0600
Subject: [PATCH] [nostalgia/core] Rename NostalgiaGraphic and NostalgiaPalette
 to TileSheet and Palette

---
 src/nostalgia/core/gba/gfx.cpp                |  8 ++++----
 src/nostalgia/core/gfx.hpp                    | 10 +++++-----
 src/nostalgia/core/studio/tilesheeteditor.hpp |  8 ++++----
 .../core/studio/tilesheeteditormodel.cpp      |  4 ++--
 .../core/studio/tilesheeteditormodel.hpp      | 20 +++++++++----------
 .../core/studio/tilesheetpixelgrid.cpp        |  4 ++--
 .../core/studio/tilesheetpixelgrid.hpp        |  4 ++--
 src/nostalgia/core/studio/tilesheetpixels.cpp |  4 ++--
 src/nostalgia/core/studio/tilesheetpixels.hpp |  4 ++--
 src/nostalgia/core/userland/gfx.cpp           |  4 ++--
 10 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/nostalgia/core/gba/gfx.cpp b/src/nostalgia/core/gba/gfx.cpp
index 40785363..42d63348 100644
--- a/src/nostalgia/core/gba/gfx.cpp
+++ b/src/nostalgia/core/gba/gfx.cpp
@@ -23,14 +23,14 @@ constexpr uint16_t DispStat_irq_hblank = 1 << 4;
 constexpr uint16_t DispStat_irq_vcount = 1 << 5;
 
 struct GbaPaletteTarget {
-	static constexpr auto TypeName = NostalgiaPalette::TypeName;
-	static constexpr auto TypeVersion = NostalgiaPalette::TypeVersion;
+	static constexpr auto TypeName = Palette::TypeName;
+	static constexpr auto TypeVersion = Palette::TypeVersion;
 	volatile uint16_t *palette = nullptr;
 };
 
 struct GbaTileMapTarget {
-	static constexpr auto TypeName = NostalgiaGraphic::TypeName;
-	static constexpr auto TypeVersion = NostalgiaGraphic::TypeVersion;
+	static constexpr auto TypeName = TileSheet::TypeName;
+	static constexpr auto TypeVersion = TileSheet::TypeVersion;
 	volatile uint16_t *bgCtl = nullptr;
 	ox::FileAddress defaultPalette;
 	GbaPaletteTarget pal;
diff --git a/src/nostalgia/core/gfx.hpp b/src/nostalgia/core/gfx.hpp
index ce14e4f5..6d20f86a 100644
--- a/src/nostalgia/core/gfx.hpp
+++ b/src/nostalgia/core/gfx.hpp
@@ -29,13 +29,13 @@ enum class TileSheetSpace {
 	Sprite
 };
 
-struct NostalgiaPalette {
+struct Palette {
 	static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.NostalgiaPalette";
 	static constexpr auto TypeVersion = 1;
 	ox::Vector<Color16> colors;
 };
 
-struct NostalgiaGraphic {
+struct TileSheet {
 	static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.NostalgiaGraphic";
 	static constexpr auto TypeVersion = 1;
 	int8_t bpp = 0;
@@ -43,7 +43,7 @@ struct NostalgiaGraphic {
 	int rows = 1;
 	int columns = 1;
 	ox::FileAddress defaultPalette;
-	NostalgiaPalette pal;
+	Palette pal;
 	ox::Vector<uint8_t> pixels;
 
 	[[nodiscard]]
@@ -110,11 +110,11 @@ struct NostalgiaGraphic {
 	}
 };
 
-oxModelBegin(NostalgiaPalette)
+oxModelBegin(Palette)
 	oxModelField(colors)
 oxModelEnd()
 
-oxModelBegin(NostalgiaGraphic)
+oxModelBegin(TileSheet)
 	oxModelField(bpp)
 	oxModelField(rows)
 	oxModelField(columns)
diff --git a/src/nostalgia/core/studio/tilesheeteditor.hpp b/src/nostalgia/core/studio/tilesheeteditor.hpp
index 0ba5df11..9ca85b28 100644
--- a/src/nostalgia/core/studio/tilesheeteditor.hpp
+++ b/src/nostalgia/core/studio/tilesheeteditor.hpp
@@ -71,10 +71,10 @@ class TileSheetEditor {
 		void resizeView(const geo::Vec2 &sz) noexcept;
 
 		[[nodiscard]]
-		constexpr const NostalgiaGraphic &img() const noexcept;
+		constexpr const TileSheet &img() const noexcept;
 
 		[[nodiscard]]
-		constexpr const NostalgiaPalette &pal() const noexcept;
+		constexpr const Palette &pal() const noexcept;
 
 		constexpr auto setPalIdx(auto palIdx) noexcept {
 			m_palIdx = palIdx;
@@ -118,11 +118,11 @@ class TileSheetEditor {
 
 };
 
-constexpr const NostalgiaGraphic &TileSheetEditor::img() const noexcept {
+constexpr const TileSheet &TileSheetEditor::img() const noexcept {
 	return m_model.img();
 }
 
-constexpr const NostalgiaPalette &TileSheetEditor::pal() const noexcept {
+constexpr const Palette &TileSheetEditor::pal() const noexcept {
 	return m_model.pal();
 }
 
diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.cpp b/src/nostalgia/core/studio/tilesheeteditormodel.cpp
index 19850129..973f170d 100644
--- a/src/nostalgia/core/studio/tilesheeteditormodel.cpp
+++ b/src/nostalgia/core/studio/tilesheeteditormodel.cpp
@@ -9,9 +9,9 @@
 namespace nostalgia::core {
 
 TileSheetEditorModel::TileSheetEditorModel(Context *ctx, const ox::String &path) {
-	oxRequireT(img, readObj<NostalgiaGraphic>(ctx, path.c_str()));
+	oxRequireT(img, readObj<TileSheet>(ctx, path.c_str()));
 	m_img = *img;
-	oxThrowError(readObj<NostalgiaPalette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
+	oxThrowError(readObj<Palette>(ctx, m_img.defaultPalette).moveTo(&m_pal));
 }
 
 void TileSheetEditorModel::cut() {
diff --git a/src/nostalgia/core/studio/tilesheeteditormodel.hpp b/src/nostalgia/core/studio/tilesheeteditormodel.hpp
index 349b8264..36970ff7 100644
--- a/src/nostalgia/core/studio/tilesheeteditormodel.hpp
+++ b/src/nostalgia/core/studio/tilesheeteditormodel.hpp
@@ -28,13 +28,13 @@ struct DrawCommand: public studio::UndoCommand {
 			uint32_t idx = 0;
 			uint16_t oldPalIdx = 0;
 		};
-		NostalgiaGraphic *m_img = nullptr;
+		TileSheet *m_img = nullptr;
 		ox::Vector<Change, 8> m_changes;
 		int m_palIdx = 0;
 		bool *m_modelUpdated = nullptr;
 
 	public:
-		constexpr DrawCommand(bool *updated, NostalgiaGraphic *img, std::size_t idx, int palIdx) noexcept {
+		constexpr DrawCommand(bool *updated, TileSheet *img, std::size_t idx, int palIdx) noexcept {
 			m_modelUpdated = updated;
 			m_img = img;
 			m_changes.emplace_back(idx, m_img->getPixel(idx));
@@ -114,8 +114,8 @@ oxModelEnd()
 class TileSheetEditorModel {
 
 	private:
-		NostalgiaGraphic m_img;
-		AssetRef<NostalgiaPalette> m_pal;
+		TileSheet m_img;
+		AssetRef<Palette> m_pal;
 		studio::UndoStack m_undoStack;
 		DrawCommand *m_ongoingDrawCommand = nullptr;
 		bool m_updated = false;
@@ -132,13 +132,13 @@ class TileSheetEditorModel {
 		void paste();
 
 		[[nodiscard]]
-		constexpr const NostalgiaGraphic &img() const noexcept;
+		constexpr const TileSheet &img() const noexcept;
 
 		[[nodiscard]]
-		constexpr NostalgiaGraphic &img() noexcept;
+		constexpr TileSheet &img() noexcept;
 
 		[[nodiscard]]
-		constexpr const NostalgiaPalette &pal() const noexcept;
+		constexpr const Palette &pal() const noexcept;
 
 		void drawCommand(const geo::Point &pt, std::size_t palIdx) noexcept;
 
@@ -175,15 +175,15 @@ class TileSheetEditorModel {
 
 };
 
-constexpr const NostalgiaGraphic &TileSheetEditorModel::img() const noexcept {
+constexpr const TileSheet &TileSheetEditorModel::img() const noexcept {
 	return m_img;
 }
 
-constexpr NostalgiaGraphic &TileSheetEditorModel::img() noexcept {
+constexpr TileSheet &TileSheetEditorModel::img() noexcept {
 	return m_img;
 }
 
-constexpr const NostalgiaPalette &TileSheetEditorModel::pal() const noexcept {
+constexpr const Palette &TileSheetEditorModel::pal() const noexcept {
 	return *m_pal;
 }
 
diff --git a/src/nostalgia/core/studio/tilesheetpixelgrid.cpp b/src/nostalgia/core/studio/tilesheetpixelgrid.cpp
index d629b58f..534ec425 100644
--- a/src/nostalgia/core/studio/tilesheetpixelgrid.cpp
+++ b/src/nostalgia/core/studio/tilesheetpixelgrid.cpp
@@ -30,7 +30,7 @@ void TileSheetGrid::draw(bool update, const geo::Vec2 &scroll) noexcept {
 	glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(m_bufferSet.vertices.size() / VertexVboRowLength));
 }
 
-void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img) noexcept {
+void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const TileSheet &img) noexcept {
 	// vao
 	m_bufferSet.vao = glutils::generateVertexArrayObject();
 	glBindVertexArray(m_bufferSet.vao);
@@ -62,7 +62,7 @@ void TileSheetGrid::setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, f
 	memcpy(vbo, vertices, sizeof(vertices));
 }
 
-void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept {
+void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const TileSheet &img, glutils::BufferSet *bg) noexcept {
 	const auto pixSize = pixelSize(paneSize);
 	const auto set = [bg, pixSize](unsigned i, geo::Point pt1, geo::Point pt2, Color32 c) {
 		const auto vbo = &bg->vertices[i * VertexVboLength];
diff --git a/src/nostalgia/core/studio/tilesheetpixelgrid.hpp b/src/nostalgia/core/studio/tilesheetpixelgrid.hpp
index 2b7c1db7..7fc44085 100644
--- a/src/nostalgia/core/studio/tilesheetpixelgrid.hpp
+++ b/src/nostalgia/core/studio/tilesheetpixelgrid.hpp
@@ -69,12 +69,12 @@ class TileSheetGrid {
 
 		void draw(bool update, const geo::Vec2 &scroll) noexcept;
 
-		void initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img) noexcept;
+		void initBufferSet(const geo::Vec2 &paneSize, const TileSheet &img) noexcept;
 
 	private:
 		static void setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept;
 
-		void setBufferObjects(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept;
+		void setBufferObjects(const geo::Vec2 &paneSize, const TileSheet &img, glutils::BufferSet *bg) noexcept;
 
 		[[nodiscard]]
 		geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
diff --git a/src/nostalgia/core/studio/tilesheetpixels.cpp b/src/nostalgia/core/studio/tilesheetpixels.cpp
index e2ad28e0..a0b7060f 100644
--- a/src/nostalgia/core/studio/tilesheetpixels.cpp
+++ b/src/nostalgia/core/studio/tilesheetpixels.cpp
@@ -29,7 +29,7 @@ void TileSheetPixels::draw(bool update, const geo::Vec2 &scroll) noexcept {
 	glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(m_bufferSet.elements.size()), GL_UNSIGNED_INT, nullptr);
 }
 
-void TileSheetPixels::initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept {
+void TileSheetPixels::initBufferSet(const geo::Vec2 &paneSize, const TileSheet &img, const Palette &pal) noexcept {
 	// vao
 	m_bufferSet.vao = glutils::generateVertexArrayObject();
 	glBindVertexArray(m_bufferSet.vao);
@@ -78,7 +78,7 @@ void TileSheetPixels::setPixelBufferObject(const geo::Vec2 &paneSize, unsigned v
 	memcpy(ebo, elms, sizeof(elms));
 }
 
-void TileSheetPixels::setBufferObjects(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept {
+void TileSheetPixels::setBufferObjects(const geo::Vec2 &paneSize, const TileSheet &img, const Palette &pal, glutils::BufferSet *bg) noexcept {
 	const auto setPixel = [this, paneSize, bg, img, pal](std::size_t i, uint8_t p) {
 		const auto color = pal.colors[p];
 		const auto pt = idxToPt(static_cast<int>(i), img.columns);
diff --git a/src/nostalgia/core/studio/tilesheetpixels.hpp b/src/nostalgia/core/studio/tilesheetpixels.hpp
index a8750913..42d622ab 100644
--- a/src/nostalgia/core/studio/tilesheetpixels.hpp
+++ b/src/nostalgia/core/studio/tilesheetpixels.hpp
@@ -48,7 +48,7 @@ class TileSheetPixels {
 
 		void draw(bool update, const geo::Vec2 &scroll) noexcept;
 
-		void initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept;
+		void initBufferSet(const geo::Vec2 &paneSize, const TileSheet &img, const Palette &pal) noexcept;
 
 		[[nodiscard]]
 		geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
@@ -56,7 +56,7 @@ class TileSheetPixels {
 	private:
 		void setPixelBufferObject(const geo::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) const noexcept;
 
-		void setBufferObjects(const geo::Vec2 &paneS, const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept;
+		void setBufferObjects(const geo::Vec2 &paneS, const TileSheet &img, const Palette &pal, glutils::BufferSet *bg) noexcept;
 
 };
 
diff --git a/src/nostalgia/core/userland/gfx.cpp b/src/nostalgia/core/userland/gfx.cpp
index 19b27442..bf6623f0 100644
--- a/src/nostalgia/core/userland/gfx.cpp
+++ b/src/nostalgia/core/userland/gfx.cpp
@@ -27,8 +27,8 @@ ox::Error loadBgTileSheet(Context *ctx,
                           int section,
                           const ox::FileAddress &tilesheetPath,
                           const ox::FileAddress &palettePath) noexcept {
-	oxRequire(tilesheet, readObj<NostalgiaGraphic>(ctx, tilesheetPath));
-	oxRequire(palette, readObj<NostalgiaPalette>(ctx, palettePath ? palettePath : tilesheet->defaultPalette));
+	oxRequire(tilesheet, readObj<TileSheet>(ctx, tilesheetPath));
+	oxRequire(palette, readObj<Palette>(ctx, palettePath ? palettePath : tilesheet->defaultPalette));
 	const unsigned bytesPerTile = tilesheet->bpp == 8 ? 64 : 32;
 	const auto tiles = tilesheet->pixels.size() / bytesPerTile;
 	constexpr int width = 8;