[nostalgia] Rename common package to geo
This commit is contained in:
parent
0aa71f1dbb
commit
320df614a9
@ -2,7 +2,7 @@
|
|||||||
#project packages
|
#project packages
|
||||||
|
|
||||||
add_subdirectory(core)
|
add_subdirectory(core)
|
||||||
add_subdirectory(common)
|
add_subdirectory(geo)
|
||||||
add_subdirectory(scene)
|
add_subdirectory(scene)
|
||||||
add_subdirectory(world)
|
add_subdirectory(world)
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
#include <nostalgia/common/point.hpp>
|
#include <nostalgia/geo/point.hpp>
|
||||||
|
|
||||||
#include "context.hpp"
|
#include "context.hpp"
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "event.hpp"
|
#include "event.hpp"
|
||||||
#include "input.hpp"
|
#include "input.hpp"
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
class Size;
|
class Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ class Context {
|
|||||||
friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept;
|
friend constexpr void setConstantRefresh(Context *ctx, bool) noexcept;
|
||||||
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
friend bool bgStatus(Context *ctx, unsigned bg) noexcept;
|
||||||
friend bool buttonDown(Context *ctx, Key) noexcept;
|
friend bool buttonDown(Context *ctx, Key) noexcept;
|
||||||
friend common::Size getScreenSize(Context *ctx) noexcept;
|
friend geo::Size getScreenSize(Context *ctx) noexcept;
|
||||||
friend int getScreenHeight(Context *ctx) noexcept;
|
friend int getScreenHeight(Context *ctx) noexcept;
|
||||||
friend int getScreenWidth(Context *ctx) noexcept;
|
friend int getScreenWidth(Context *ctx) noexcept;
|
||||||
friend ox::Error initGfx(Context *ctx) noexcept;
|
friend ox::Error initGfx(Context *ctx) noexcept;
|
||||||
|
@ -108,7 +108,7 @@ int getScreenHeight(Context*) noexcept {
|
|||||||
return 160;
|
return 160;
|
||||||
}
|
}
|
||||||
|
|
||||||
common::Size getScreenSize(Context*) noexcept {
|
geo::Size getScreenSize(Context*) noexcept {
|
||||||
return {240, 160};
|
return {240, 160};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
#include <ox/model/def.hpp>
|
#include <ox/model/def.hpp>
|
||||||
#include <nostalgia/common/point.hpp>
|
#include <nostalgia/geo/point.hpp>
|
||||||
#include <nostalgia/common/size.hpp>
|
#include <nostalgia/geo/size.hpp>
|
||||||
|
|
||||||
#include "color.hpp"
|
#include "color.hpp"
|
||||||
#include "context.hpp"
|
#include "context.hpp"
|
||||||
@ -47,7 +47,7 @@ struct NostalgiaGraphic {
|
|||||||
ox::Vector<uint8_t> pixels;
|
ox::Vector<uint8_t> pixels;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr auto getPixel4Bpp(const common::Point &pt) const noexcept {
|
constexpr auto getPixel4Bpp(const geo::Point &pt) const noexcept {
|
||||||
oxAssert(bpp == 4, "NostalgiaGraphic::getPixel4Bpp: wrong bpp");
|
oxAssert(bpp == 4, "NostalgiaGraphic::getPixel4Bpp: wrong bpp");
|
||||||
const auto idx = ptToIdx(pt, this->columns);
|
const auto idx = ptToIdx(pt, this->columns);
|
||||||
if (idx & 1) {
|
if (idx & 1) {
|
||||||
@ -58,14 +58,14 @@ struct NostalgiaGraphic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr auto getPixel8Bpp(const common::Point &pt) const noexcept {
|
constexpr auto getPixel8Bpp(const geo::Point &pt) const noexcept {
|
||||||
oxAssert(bpp == 8, "NostalgiaGraphic::getPixel8Bpp: wrong bpp");
|
oxAssert(bpp == 8, "NostalgiaGraphic::getPixel8Bpp: wrong bpp");
|
||||||
const auto idx = ptToIdx(pt, this->columns);
|
const auto idx = ptToIdx(pt, this->columns);
|
||||||
return this->pixels[idx];
|
return this->pixels[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr auto getPixel(const common::Point &pt) const noexcept {
|
constexpr auto getPixel(const geo::Point &pt) const noexcept {
|
||||||
if (this->bpp == 4) {
|
if (this->bpp == 4) {
|
||||||
return getPixel4Bpp(pt);
|
return getPixel4Bpp(pt);
|
||||||
} else {
|
} else {
|
||||||
@ -73,7 +73,7 @@ struct NostalgiaGraphic {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void setPixel(const common::Point &pt, uint8_t palIdx) noexcept {
|
constexpr void setPixel(const geo::Point &pt, uint8_t palIdx) noexcept {
|
||||||
const auto idx = ptToIdx(pt, this->columns);
|
const auto idx = ptToIdx(pt, this->columns);
|
||||||
if (bpp == 4) {
|
if (bpp == 4) {
|
||||||
if (idx & 1) {
|
if (idx & 1) {
|
||||||
@ -127,7 +127,7 @@ int getScreenWidth(Context *ctx) noexcept;
|
|||||||
int getScreenHeight(Context *ctx) noexcept;
|
int getScreenHeight(Context *ctx) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
common::Size getScreenSize(Context *ctx) noexcept;
|
geo::Size getScreenSize(Context *ctx) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
uint8_t bgStatus(Context *ctx) noexcept;
|
uint8_t bgStatus(Context *ctx) noexcept;
|
||||||
|
@ -99,7 +99,7 @@ int getScreenHeight(Context *ctx) noexcept {
|
|||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
common::Size getScreenSize(Context *ctx) noexcept {
|
geo::Size getScreenSize(Context *ctx) noexcept {
|
||||||
auto id = ctx->windowerData<GlfwImplData>();
|
auto id = ctx->windowerData<GlfwImplData>();
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
glfwGetFramebufferSize(id->window, &w, &h);
|
glfwGetFramebufferSize(id->window, &w, &h);
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nostalgia/common/point.hpp>
|
#include <nostalgia/geo/point.hpp>
|
||||||
|
|
||||||
#include "consts.hpp"
|
#include "consts.hpp"
|
||||||
|
|
||||||
@ -22,12 +22,12 @@ constexpr std::size_t ptToIdx(int x, int y, int c) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr std::size_t ptToIdx(const common::Point &pt, int c) noexcept {
|
constexpr std::size_t ptToIdx(const geo::Point &pt, int c) noexcept {
|
||||||
return ptToIdx(pt.x, pt.y, c * TileWidth);
|
return ptToIdx(pt.x, pt.y, c * TileWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr common::Point idxToPt(int i, int c) noexcept {
|
constexpr geo::Point idxToPt(int i, int c) noexcept {
|
||||||
const auto t = i / PixelsPerTile; // tile number
|
const auto t = i / PixelsPerTile; // tile number
|
||||||
const auto iti = i % PixelsPerTile; // in tile index
|
const auto iti = i % PixelsPerTile; // in tile index
|
||||||
const auto tc = t % c; // tile column
|
const auto tc = t % c; // tile column
|
||||||
@ -40,13 +40,13 @@ constexpr common::Point idxToPt(int i, int c) noexcept {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static_assert(idxToPt(4, 1) == common::Point{4, 0});
|
static_assert(idxToPt(4, 1) == geo::Point{4, 0});
|
||||||
static_assert(idxToPt(8, 1) == common::Point{0, 1});
|
static_assert(idxToPt(8, 1) == geo::Point{0, 1});
|
||||||
static_assert(idxToPt(8, 2) == common::Point{0, 1});
|
static_assert(idxToPt(8, 2) == geo::Point{0, 1});
|
||||||
static_assert(idxToPt(64, 2) == common::Point{8, 0});
|
static_assert(idxToPt(64, 2) == geo::Point{8, 0});
|
||||||
static_assert(idxToPt(128, 2) == common::Point{0, 8});
|
static_assert(idxToPt(128, 2) == geo::Point{0, 8});
|
||||||
static_assert(idxToPt(129, 2) == common::Point{1, 8});
|
static_assert(idxToPt(129, 2) == geo::Point{1, 8});
|
||||||
static_assert(idxToPt(192, 2) == common::Point{8, 8});
|
static_assert(idxToPt(192, 2) == geo::Point{8, 8});
|
||||||
static_assert(idxToPt(384, 8) == common::Point{48, 0});
|
static_assert(idxToPt(384, 8) == geo::Point{48, 0});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include <nostalgia/common/point.hpp>
|
|
||||||
#include <nostalgia/core/media.hpp>
|
#include <nostalgia/core/media.hpp>
|
||||||
|
#include <nostalgia/geo/point.hpp>
|
||||||
|
|
||||||
#include "tilesheeteditor-imgui.hpp"
|
#include "tilesheeteditor-imgui.hpp"
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ void TileSheetEditorImGui::paste() {
|
|||||||
void TileSheetEditorImGui::draw(core::Context*) noexcept {
|
void TileSheetEditorImGui::draw(core::Context*) noexcept {
|
||||||
const auto paneSize = ImGui::GetContentRegionAvail();
|
const auto paneSize = ImGui::GetContentRegionAvail();
|
||||||
const auto tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);
|
const auto tileSheetParentSize = ImVec2(paneSize.x - m_palViewWidth, paneSize.y);
|
||||||
const auto fbSize = common::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
const auto fbSize = geo::Vec2(tileSheetParentSize.x - 16, tileSheetParentSize.y - 16);
|
||||||
ImGui::BeginChild("child1", ImVec2(tileSheetParentSize.x, tileSheetParentSize.y), true);
|
ImGui::BeginChild("child1", ImVec2(tileSheetParentSize.x, tileSheetParentSize.y), true);
|
||||||
drawTileSheet(fbSize);
|
drawTileSheet(fbSize);
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
@ -59,8 +59,8 @@ void TileSheetEditorImGui::draw(core::Context*) noexcept {
|
|||||||
void TileSheetEditorImGui::saveItem() {
|
void TileSheetEditorImGui::saveItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditorImGui::drawTileSheet(const common::Vec2 &fbSize) noexcept {
|
void TileSheetEditorImGui::drawTileSheet(const geo::Vec2 &fbSize) noexcept {
|
||||||
const auto fbSizei = common::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
|
const auto fbSizei = geo::Size(static_cast<int>(fbSize.x), static_cast<int>(fbSize.y));
|
||||||
if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) {
|
if (m_framebuffer.width != fbSizei.width || m_framebuffer.height != fbSizei.height) {
|
||||||
m_framebuffer = glutils::generateFrameBuffer(fbSizei.width, fbSizei.height);
|
m_framebuffer = glutils::generateFrameBuffer(fbSizei.width, fbSizei.height);
|
||||||
m_tileSheetEditor.resize(fbSize);
|
m_tileSheetEditor.resize(fbSize);
|
||||||
@ -87,7 +87,7 @@ void TileSheetEditorImGui::drawTileSheet(const common::Vec2 &fbSize) noexcept {
|
|||||||
m_tileSheetEditor.scrollH(fbSize, wheelh);
|
m_tileSheetEditor.scrollH(fbSize, wheelh);
|
||||||
}
|
}
|
||||||
if (io.MouseDown[0]) {
|
if (io.MouseDown[0]) {
|
||||||
auto clickPos = common::Vec2(io.MousePos);
|
auto clickPos = geo::Vec2(io.MousePos);
|
||||||
const auto &winPos = ImGui::GetWindowPos();
|
const auto &winPos = ImGui::GetWindowPos();
|
||||||
clickPos.x -= winPos.x + 10;
|
clickPos.x -= winPos.x + 10;
|
||||||
clickPos.y -= winPos.y + 10;
|
clickPos.y -= winPos.y + 10;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include <ox/model/def.hpp>
|
#include <ox/model/def.hpp>
|
||||||
|
|
||||||
#include <nostalgia/common/bounds.hpp>
|
#include <nostalgia/geo/bounds.hpp>
|
||||||
#include <nostalgia/common/vec.hpp>
|
#include <nostalgia/geo/vec.hpp>
|
||||||
#include <nostalgia/core/gfx.hpp>
|
#include <nostalgia/core/gfx.hpp>
|
||||||
#include <nostalgia/glutils/glutils.hpp>
|
#include <nostalgia/glutils/glutils.hpp>
|
||||||
#include <nostalgia/studio/studio.hpp>
|
#include <nostalgia/studio/studio.hpp>
|
||||||
@ -62,7 +62,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ox::String palettePath(const ox::String &palettePath) const;
|
ox::String palettePath(const ox::String &palettePath) const;
|
||||||
|
|
||||||
void drawTileSheet(const common::Vec2 &fbSize) noexcept;
|
void drawTileSheet(const geo::Vec2 &fbSize) noexcept;
|
||||||
|
|
||||||
void drawPalettePicker() noexcept;
|
void drawPalettePicker() noexcept;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <nostalgia/common/point.hpp>
|
#include <nostalgia/geo/point.hpp>
|
||||||
#include <nostalgia/core/consts.hpp>
|
#include <nostalgia/core/consts.hpp>
|
||||||
#include <nostalgia/core/media.hpp>
|
#include <nostalgia/core/media.hpp>
|
||||||
#include <nostalgia/core/ptidxconv.hpp>
|
#include <nostalgia/core/ptidxconv.hpp>
|
||||||
@ -40,7 +40,7 @@ void TileSheetEditor::draw() noexcept {
|
|||||||
m_updated = false;
|
m_updated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditor::scrollV(const common::Vec2 paneSz, float wheel, bool zoomMod) noexcept {
|
void TileSheetEditor::scrollV(const geo::Vec2 paneSz, float wheel, bool zoomMod) noexcept {
|
||||||
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
||||||
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_img.columns) * TileWidth,
|
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_img.columns) * TileWidth,
|
||||||
pixelSize.y * static_cast<float>(m_img.rows) * TileHeight);
|
pixelSize.y * static_cast<float>(m_img.rows) * TileHeight);
|
||||||
@ -57,7 +57,7 @@ void TileSheetEditor::scrollV(const common::Vec2 paneSz, float wheel, bool zoomM
|
|||||||
m_scrollOffset.y = ox::clamp(m_scrollOffset.y, 0.f, sheetSize.y / 2);
|
m_scrollOffset.y = ox::clamp(m_scrollOffset.y, 0.f, sheetSize.y / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditor::scrollH(const common::Vec2 paneSz, float wheelh) noexcept {
|
void TileSheetEditor::scrollH(const geo::Vec2 paneSz, float wheelh) noexcept {
|
||||||
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
const auto pixelSize = m_pixelsDrawer.pixelSize(paneSz);
|
||||||
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_img.columns) * TileWidth,
|
const ImVec2 sheetSize(pixelSize.x * static_cast<float>(m_img.columns) * TileWidth,
|
||||||
pixelSize.y * static_cast<float>(m_img.rows) * TileHeight);
|
pixelSize.y * static_cast<float>(m_img.rows) * TileHeight);
|
||||||
@ -65,7 +65,7 @@ void TileSheetEditor::scrollH(const common::Vec2 paneSz, float wheelh) noexcept
|
|||||||
m_scrollOffset.x = ox::clamp(m_scrollOffset.x, -(sheetSize.x / 2), 0.f);
|
m_scrollOffset.x = ox::clamp(m_scrollOffset.x, -(sheetSize.x / 2), 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditor::clickPixel(const common::Vec2 &paneSize, const common::Vec2 &clickPos) noexcept {
|
void TileSheetEditor::clickPixel(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept {
|
||||||
auto [x, y] = clickPos;
|
auto [x, y] = clickPos;
|
||||||
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
const auto pixDrawSz = m_pixelsDrawer.pixelSize(paneSize);
|
||||||
x /= paneSize.x;
|
x /= paneSize.x;
|
||||||
@ -74,13 +74,13 @@ void TileSheetEditor::clickPixel(const common::Vec2 &paneSize, const common::Vec
|
|||||||
y += m_scrollOffset.y / 2;
|
y += m_scrollOffset.y / 2;
|
||||||
x /= pixDrawSz.x;
|
x /= pixDrawSz.x;
|
||||||
y /= pixDrawSz.y;
|
y /= pixDrawSz.y;
|
||||||
const auto pt = common::Point(static_cast<int>(x * 2), static_cast<int>(y * 2));
|
const auto pt = geo::Point(static_cast<int>(x * 2), static_cast<int>(y * 2));
|
||||||
const uint8_t palIdx = 0;
|
const uint8_t palIdx = 0;
|
||||||
m_img.setPixel(pt, palIdx);
|
m_img.setPixel(pt, palIdx);
|
||||||
m_updated = true;
|
m_updated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditor::resize(const common::Vec2 &sz) noexcept {
|
void TileSheetEditor::resize(const geo::Vec2 &sz) noexcept {
|
||||||
m_pixelsDrawer.initBufferSet(sz, m_img, *m_pal);
|
m_pixelsDrawer.initBufferSet(sz, m_img, *m_pal);
|
||||||
m_pixelGridDrawer.initBufferSet(sz, m_img);
|
m_pixelGridDrawer.initBufferSet(sz, m_img);
|
||||||
}
|
}
|
||||||
@ -104,15 +104,15 @@ void TileSheetEditor::ackUpdate() noexcept {
|
|||||||
void TileSheetEditor::saveItem() {
|
void TileSheetEditor::saveItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetEditor::getFillPixels(bool *pixels, common::Point pt, int oldColor) const {
|
void TileSheetEditor::getFillPixels(bool *pixels, geo::Point pt, int oldColor) const {
|
||||||
const auto tileIdx = [this](const common::Point &pt) noexcept {
|
const auto tileIdx = [this](const geo::Point &pt) noexcept {
|
||||||
return ptToIdx(pt, m_img.columns) / PixelsPerTile;
|
return ptToIdx(pt, m_img.columns) / PixelsPerTile;
|
||||||
};
|
};
|
||||||
// get points
|
// get points
|
||||||
const auto leftPt = pt + common::Point(-1, 0);
|
const auto leftPt = pt + geo::Point(-1, 0);
|
||||||
const auto rightPt = pt + common::Point(1, 0);
|
const auto rightPt = pt + geo::Point(1, 0);
|
||||||
const auto topPt = pt + common::Point(0, -1);
|
const auto topPt = pt + geo::Point(0, -1);
|
||||||
const auto bottomPt = pt + common::Point(0, 1);
|
const auto bottomPt = pt + geo::Point(0, 1);
|
||||||
// calculate indices
|
// calculate indices
|
||||||
const auto idx = ptToIdx(pt, m_img.columns);
|
const auto idx = ptToIdx(pt, m_img.columns);
|
||||||
const auto leftIdx = ptToIdx(leftPt, m_img.columns);
|
const auto leftIdx = ptToIdx(leftPt, m_img.columns);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include <ox/model/def.hpp>
|
#include <ox/model/def.hpp>
|
||||||
|
|
||||||
#include <nostalgia/common/bounds.hpp>
|
#include <nostalgia/geo/bounds.hpp>
|
||||||
#include <nostalgia/common/vec.hpp>
|
#include <nostalgia/geo/vec.hpp>
|
||||||
#include <nostalgia/core/gfx.hpp>
|
#include <nostalgia/core/gfx.hpp>
|
||||||
#include <nostalgia/glutils/glutils.hpp>
|
#include <nostalgia/glutils/glutils.hpp>
|
||||||
#include <nostalgia/studio/studio.hpp>
|
#include <nostalgia/studio/studio.hpp>
|
||||||
@ -48,7 +48,7 @@ constexpr auto toString(TileSheetTool t) noexcept {
|
|||||||
struct PixelChunk {
|
struct PixelChunk {
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.PixelChunk";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.core.studio.PixelChunk";
|
||||||
static constexpr auto TypeVersion = 1;
|
static constexpr auto TypeVersion = 1;
|
||||||
common::Point pt;
|
geo::Point pt;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,8 +65,8 @@ struct TileSheetClipboard {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
ox::Vector<int> m_pixels;
|
ox::Vector<int> m_pixels;
|
||||||
common::Point m_p1;
|
geo::Point m_p1;
|
||||||
common::Point m_p2;
|
geo::Point m_p2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addPixel(int color);
|
void addPixel(int color);
|
||||||
@ -74,15 +74,15 @@ struct TileSheetClipboard {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
|
|
||||||
void pastePixels(const common::Point &pt, ox::Vector<int> *tgt, int tgtColumns) const;
|
void pastePixels(const geo::Point &pt, ox::Vector<int> *tgt, int tgtColumns) const;
|
||||||
|
|
||||||
void setPoints(const common::Point &p1, const common::Point &p2);
|
void setPoints(const geo::Point &p1, const geo::Point &p2);
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
common::Point point1() const;
|
geo::Point point1() const;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
common::Point point2() const;
|
geo::Point point2() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ class TileSheetEditor {
|
|||||||
NostalgiaGraphic m_img;
|
NostalgiaGraphic m_img;
|
||||||
AssetRef<NostalgiaPalette> m_pal;
|
AssetRef<NostalgiaPalette> m_pal;
|
||||||
float m_pixelSizeMod = 1;
|
float m_pixelSizeMod = 1;
|
||||||
common::Vec2 m_scrollOffset;
|
geo::Vec2 m_scrollOffset;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditor(Context *ctx, const ox::String &path);
|
TileSheetEditor(Context *ctx, const ox::String &path);
|
||||||
@ -119,13 +119,13 @@ class TileSheetEditor {
|
|||||||
|
|
||||||
void draw() noexcept;
|
void draw() noexcept;
|
||||||
|
|
||||||
void clickPixel(const common::Vec2 &paneSize, const common::Vec2 &clickPos) noexcept;
|
void clickPixel(const geo::Vec2 &paneSize, const geo::Vec2 &clickPos) noexcept;
|
||||||
|
|
||||||
void scrollV(const common::Vec2 paneSz, float wheel, bool zoomMod) noexcept;
|
void scrollV(const geo::Vec2 paneSz, float wheel, bool zoomMod) noexcept;
|
||||||
|
|
||||||
void scrollH(const common::Vec2 paneSz, float wheel) noexcept;
|
void scrollH(const geo::Vec2 paneSz, float wheel) noexcept;
|
||||||
|
|
||||||
void resize(const common::Vec2 &sz) noexcept;
|
void resize(const geo::Vec2 &sz) noexcept;
|
||||||
|
|
||||||
const NostalgiaGraphic &img() const;
|
const NostalgiaGraphic &img() const;
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ class TileSheetEditor {
|
|||||||
protected:
|
protected:
|
||||||
void saveItem();
|
void saveItem();
|
||||||
|
|
||||||
void getFillPixels(bool *pixels, common::Point pt, int oldColor) const;
|
void getFillPixels(bool *pixels, geo::Point pt, int oldColor) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPalette();
|
void setPalette();
|
||||||
|
@ -18,7 +18,7 @@ ox::Error TileSheetGrid::buildShader() noexcept {
|
|||||||
return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader);
|
return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(&m_shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetGrid::draw(bool update, const common::Vec2 &scroll) noexcept {
|
void TileSheetGrid::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||||
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
glLineWidth(3 * m_pixelSizeMod * 0.5f);
|
||||||
glUseProgram(m_shader);
|
glUseProgram(m_shader);
|
||||||
glBindVertexArray(m_bufferSet.vao);
|
glBindVertexArray(m_bufferSet.vao);
|
||||||
@ -30,7 +30,7 @@ void TileSheetGrid::draw(bool update, const common::Vec2 &scroll) noexcept {
|
|||||||
glDrawArrays(GL_POINTS, 0, m_bufferSet.vertices.size() / VertexVboRowLength);
|
glDrawArrays(GL_POINTS, 0, m_bufferSet.vertices.size() / VertexVboRowLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetGrid::initBufferSet(const common::Vec2 &paneSize, const NostalgiaGraphic &img) noexcept {
|
void TileSheetGrid::initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img) noexcept {
|
||||||
// vao
|
// vao
|
||||||
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
||||||
glBindVertexArray(m_bufferSet.vao);
|
glBindVertexArray(m_bufferSet.vao);
|
||||||
@ -52,7 +52,7 @@ void TileSheetGrid::initBufferSet(const common::Vec2 &paneSize, const NostalgiaG
|
|||||||
reinterpret_cast<void*>(4 * sizeof(float)));
|
reinterpret_cast<void*>(4 * sizeof(float)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetGrid::setBufferObject(common::Point pt1, common::Point pt2, Color32 c, float *vbo, const common::Vec2 &pixSize) noexcept {
|
void TileSheetGrid::setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept {
|
||||||
const auto x1 = static_cast<float>(pt1.x) * pixSize.x - 1.f;
|
const auto x1 = static_cast<float>(pt1.x) * pixSize.x - 1.f;
|
||||||
const auto y1 = 1.f - static_cast<float>(pt1.y) * pixSize.y;
|
const auto y1 = 1.f - static_cast<float>(pt1.y) * pixSize.y;
|
||||||
const auto x2 = static_cast<float>(pt2.x) * pixSize.x - 1.f;
|
const auto x2 = static_cast<float>(pt2.x) * pixSize.x - 1.f;
|
||||||
@ -62,9 +62,9 @@ void TileSheetGrid::setBufferObject(common::Point pt1, common::Point pt2, Color3
|
|||||||
memcpy(vbo, vertices, sizeof(vertices));
|
memcpy(vbo, vertices, sizeof(vertices));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetGrid::setBufferObjects(const common::Vec2 &paneSize, const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept {
|
void TileSheetGrid::setBufferObjects(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept {
|
||||||
const auto pixSize = pixelSize(paneSize);
|
const auto pixSize = pixelSize(paneSize);
|
||||||
const auto set = [bg, pixSize](unsigned i, common::Point pt1, common::Point pt2, Color32 c) {
|
const auto set = [bg, pixSize](unsigned i, geo::Point pt1, geo::Point pt2, Color32 c) {
|
||||||
const auto vbo = &bg->vertices[i * VertexVboLength];
|
const auto vbo = &bg->vertices[i * VertexVboLength];
|
||||||
setBufferObject(pt1, pt2, c, vbo, pixSize);
|
setBufferObject(pt1, pt2, c, vbo, pixSize);
|
||||||
};
|
};
|
||||||
@ -98,7 +98,7 @@ void TileSheetGrid::setBufferObjects(const common::Vec2 &paneSize, const Nostalg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common::Vec2 TileSheetGrid::pixelSize(const common::Vec2 &paneSize) const noexcept {
|
geo::Vec2 TileSheetGrid::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||||
const auto [sw, sh] = paneSize;
|
const auto [sw, sh] = paneSize;
|
||||||
constexpr float ymod = 0.35f / 10.0f;
|
constexpr float ymod = 0.35f / 10.0f;
|
||||||
const auto xmod = ymod * sh / sw;
|
const auto xmod = ymod * sh / sw;
|
||||||
|
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nostalgia/common/point.hpp>
|
|
||||||
#include <nostalgia/common/vec.hpp>
|
|
||||||
#include <nostalgia/core/gfx.hpp>
|
#include <nostalgia/core/gfx.hpp>
|
||||||
|
#include <nostalgia/geo/point.hpp>
|
||||||
|
#include <nostalgia/geo/vec.hpp>
|
||||||
#include <nostalgia/glutils/glutils.hpp>
|
#include <nostalgia/glutils/glutils.hpp>
|
||||||
#include <nostalgia/studio/studio.hpp>
|
#include <nostalgia/studio/studio.hpp>
|
||||||
|
|
||||||
@ -67,17 +67,17 @@ class TileSheetGrid {
|
|||||||
|
|
||||||
ox::Error buildShader() noexcept;
|
ox::Error buildShader() noexcept;
|
||||||
|
|
||||||
void draw(bool update, const common::Vec2 &scroll) noexcept;
|
void draw(bool update, const geo::Vec2 &scroll) noexcept;
|
||||||
|
|
||||||
void initBufferSet(const common::Vec2 &paneSize, const NostalgiaGraphic &img) noexcept;
|
void initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img) noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void setBufferObject(common::Point pt1, common::Point pt2, Color32 c, float *vbo, const common::Vec2 &pixSize) noexcept;
|
static void setBufferObject(geo::Point pt1, geo::Point pt2, Color32 c, float *vbo, const geo::Vec2 &pixSize) noexcept;
|
||||||
|
|
||||||
void setBufferObjects(const common::Vec2 &paneSize, const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept;
|
void setBufferObjects(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, glutils::BufferSet *bg) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
common::Vec2 pixelSize(const common::Vec2 &paneSize) const noexcept;
|
geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ ox::Error TileSheetPixels::buildShader() noexcept {
|
|||||||
return glutils::buildShaderProgram(Vshad, Fshad).moveTo(&m_shader);
|
return glutils::buildShaderProgram(Vshad, Fshad).moveTo(&m_shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetPixels::draw(bool update, const common::Vec2 &scroll) noexcept {
|
void TileSheetPixels::draw(bool update, const geo::Vec2 &scroll) noexcept {
|
||||||
glUseProgram(m_shader);
|
glUseProgram(m_shader);
|
||||||
glBindVertexArray(m_bufferSet.vao);
|
glBindVertexArray(m_bufferSet.vao);
|
||||||
if (update) {
|
if (update) {
|
||||||
@ -29,7 +29,7 @@ void TileSheetPixels::draw(bool update, const common::Vec2 &scroll) noexcept {
|
|||||||
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(m_bufferSet.elements.size()), GL_UNSIGNED_INT, nullptr);
|
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(m_bufferSet.elements.size()), GL_UNSIGNED_INT, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetPixels::initBufferSet(const common::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept {
|
void TileSheetPixels::initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept {
|
||||||
// vao
|
// vao
|
||||||
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
m_bufferSet.vao = glutils::generateVertexArrayObject();
|
||||||
glBindVertexArray(m_bufferSet.vao);
|
glBindVertexArray(m_bufferSet.vao);
|
||||||
@ -49,14 +49,14 @@ void TileSheetPixels::initBufferSet(const common::Vec2 &paneSize, const Nostalgi
|
|||||||
reinterpret_cast<void*>(2 * sizeof(float)));
|
reinterpret_cast<void*>(2 * sizeof(float)));
|
||||||
}
|
}
|
||||||
|
|
||||||
common::Vec2 TileSheetPixels::pixelSize(const common::Vec2 &paneSize) const noexcept {
|
geo::Vec2 TileSheetPixels::pixelSize(const geo::Vec2 &paneSize) const noexcept {
|
||||||
const auto [sw, sh] = paneSize;
|
const auto [sw, sh] = paneSize;
|
||||||
constexpr float ymod = 0.35f / 10.0f;
|
constexpr float ymod = 0.35f / 10.0f;
|
||||||
const auto xmod = ymod * sh / sw;
|
const auto xmod = ymod * sh / sw;
|
||||||
return {xmod * m_pixelSizeMod, ymod * m_pixelSizeMod};
|
return {xmod * m_pixelSizeMod, ymod * m_pixelSizeMod};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetPixels::setPixelBufferObject(const common::Vec2 &paneSize, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) noexcept {
|
void TileSheetPixels::setPixelBufferObject(const geo::Vec2 &paneSize, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) noexcept {
|
||||||
const auto [xmod, ymod] = pixelSize(paneSize);
|
const auto [xmod, ymod] = pixelSize(paneSize);
|
||||||
x *= xmod;
|
x *= xmod;
|
||||||
y *= -ymod;
|
y *= -ymod;
|
||||||
@ -78,7 +78,7 @@ void TileSheetPixels::setPixelBufferObject(const common::Vec2 &paneSize, unsigne
|
|||||||
memcpy(ebo, elms, sizeof(elms));
|
memcpy(ebo, elms, sizeof(elms));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileSheetPixels::setBufferObjects(const common::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept {
|
void TileSheetPixels::setBufferObjects(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept {
|
||||||
const auto setPixel = [this, paneSize, bg, img, pal](std::size_t i, uint8_t p) {
|
const auto setPixel = [this, paneSize, bg, img, pal](std::size_t i, uint8_t p) {
|
||||||
const auto color = pal.colors[p];
|
const auto color = pal.colors[p];
|
||||||
const auto pt = idxToPt(static_cast<int>(i), img.columns);
|
const auto pt = idxToPt(static_cast<int>(i), img.columns);
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <nostalgia/common/vec.hpp>
|
|
||||||
#include <nostalgia/core/gfx.hpp>
|
#include <nostalgia/core/gfx.hpp>
|
||||||
|
#include <nostalgia/geo/vec.hpp>
|
||||||
#include <nostalgia/glutils/glutils.hpp>
|
#include <nostalgia/glutils/glutils.hpp>
|
||||||
#include <nostalgia/studio/studio.hpp>
|
#include <nostalgia/studio/studio.hpp>
|
||||||
|
|
||||||
@ -46,17 +46,17 @@ class TileSheetPixels {
|
|||||||
|
|
||||||
ox::Error buildShader() noexcept;
|
ox::Error buildShader() noexcept;
|
||||||
|
|
||||||
void draw(bool update, const common::Vec2 &scroll) noexcept;
|
void draw(bool update, const geo::Vec2 &scroll) noexcept;
|
||||||
|
|
||||||
void initBufferSet(const common::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept;
|
void initBufferSet(const geo::Vec2 &paneSize, const NostalgiaGraphic &img, const NostalgiaPalette &pal) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
common::Vec2 pixelSize(const common::Vec2 &paneSize) const noexcept;
|
geo::Vec2 pixelSize(const geo::Vec2 &paneSize) const noexcept;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPixelBufferObject(const common::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) noexcept;
|
void setPixelBufferObject(const geo::Vec2 &paneS, unsigned vertexRow, float x, float y, Color16 color, float *vbo, GLuint *ebo) noexcept;
|
||||||
|
|
||||||
void setBufferObjects(const common::Vec2 &paneS, const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept;
|
void setBufferObjects(const geo::Vec2 &paneS, const NostalgiaGraphic &img, const NostalgiaPalette &pal, glutils::BufferSet *bg) noexcept;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ install(
|
|||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
bounds.hpp
|
bounds.hpp
|
||||||
common.hpp
|
geo.hpp
|
||||||
point.hpp
|
point.hpp
|
||||||
size.hpp
|
size.hpp
|
||||||
vec.hpp
|
vec.hpp
|
@ -1,9 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "bounds.hpp"
|
#include "bounds.hpp"
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
|
|
||||||
Bounds::Bounds(int x, int y, int w, int h) noexcept {
|
Bounds::Bounds(int x, int y, int w, int h) noexcept {
|
||||||
this->x = x;
|
this->x = x;
|
@ -6,12 +6,12 @@
|
|||||||
|
|
||||||
#include "point.hpp"
|
#include "point.hpp"
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
|
|
||||||
class Bounds {
|
class Bounds {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Bounds";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Bounds";
|
||||||
static constexpr auto TypeVersion = 1;
|
static constexpr auto TypeVersion = 1;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#include <ox/std/error.hpp>
|
#include <ox/std/error.hpp>
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
|
|
||||||
class Point {
|
class Point {
|
||||||
public:
|
public:
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Point";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Point";
|
||||||
static constexpr auto TypeVersion = 1;
|
static constexpr auto TypeVersion = 1;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
@ -19,22 +19,22 @@ class Point {
|
|||||||
|
|
||||||
constexpr Point(int x, int y) noexcept;
|
constexpr Point(int x, int y) noexcept;
|
||||||
|
|
||||||
constexpr Point operator+(const common::Point &p) const noexcept;
|
constexpr Point operator+(const geo::Point &p) const noexcept;
|
||||||
|
|
||||||
constexpr Point operator-(const common::Point &p) const noexcept;
|
constexpr Point operator-(const geo::Point &p) const noexcept;
|
||||||
|
|
||||||
constexpr Point operator*(const common::Point &p) const noexcept;
|
constexpr Point operator*(const geo::Point &p) const noexcept;
|
||||||
|
|
||||||
constexpr Point operator/(const common::Point &p) const noexcept;
|
constexpr Point operator/(const geo::Point &p) const noexcept;
|
||||||
|
|
||||||
|
|
||||||
constexpr Point operator+=(const common::Point &p) noexcept;
|
constexpr Point operator+=(const geo::Point &p) noexcept;
|
||||||
|
|
||||||
constexpr Point operator-=(const common::Point &p) noexcept;
|
constexpr Point operator-=(const geo::Point &p) noexcept;
|
||||||
|
|
||||||
constexpr Point operator*=(const common::Point &p) noexcept;
|
constexpr Point operator*=(const geo::Point &p) noexcept;
|
||||||
|
|
||||||
constexpr Point operator/=(const common::Point &p) noexcept;
|
constexpr Point operator/=(const geo::Point &p) noexcept;
|
||||||
|
|
||||||
|
|
||||||
constexpr Point operator+(int i) const noexcept;
|
constexpr Point operator+(int i) const noexcept;
|
||||||
@ -66,53 +66,53 @@ constexpr Point::Point(int x, int y) noexcept {
|
|||||||
this->y = y;
|
this->y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator+(const common::Point &p) const noexcept {
|
constexpr Point Point::operator+(const geo::Point &p) const noexcept {
|
||||||
auto out = *this;
|
auto out = *this;
|
||||||
out.x += x;
|
out.x += x;
|
||||||
out.y += y;
|
out.y += y;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator-(const common::Point &p) const noexcept {
|
constexpr Point Point::operator-(const geo::Point &p) const noexcept {
|
||||||
auto out = *this;
|
auto out = *this;
|
||||||
out.x -= p.x;
|
out.x -= p.x;
|
||||||
out.y -= p.y;
|
out.y -= p.y;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator*(const common::Point &p) const noexcept {
|
constexpr Point Point::operator*(const geo::Point &p) const noexcept {
|
||||||
auto out = *this;
|
auto out = *this;
|
||||||
out.x *= x;
|
out.x *= x;
|
||||||
out.y *= y;
|
out.y *= y;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator/(const common::Point &p) const noexcept {
|
constexpr Point Point::operator/(const geo::Point &p) const noexcept {
|
||||||
auto out = *this;
|
auto out = *this;
|
||||||
out.x /= p.x;
|
out.x /= p.x;
|
||||||
out.y /= p.y;
|
out.y /= p.y;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator+=(const common::Point &p) noexcept {
|
constexpr Point Point::operator+=(const geo::Point &p) noexcept {
|
||||||
x += p.x;
|
x += p.x;
|
||||||
y += p.y;
|
y += p.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator-=(const common::Point &p) noexcept {
|
constexpr Point Point::operator-=(const geo::Point &p) noexcept {
|
||||||
x -= p.x;
|
x -= p.x;
|
||||||
y -= p.y;
|
y -= p.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator*=(const common::Point &p) noexcept {
|
constexpr Point Point::operator*=(const geo::Point &p) noexcept {
|
||||||
x *= p.x;
|
x *= p.x;
|
||||||
y *= p.y;
|
y *= p.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Point Point::operator/=(const common::Point &p) noexcept {
|
constexpr Point Point::operator/=(const geo::Point &p) noexcept {
|
||||||
x /= p.x;
|
x /= p.x;
|
||||||
y /= p.y;
|
y /= p.y;
|
||||||
return *this;
|
return *this;
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
#include <ox/std/error.hpp>
|
#include <ox/std/error.hpp>
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
|
|
||||||
class Size {
|
class Size {
|
||||||
public:
|
public:
|
||||||
static constexpr auto TypeName = "net.drinkingtea.nostalgia.common.Size";
|
static constexpr auto TypeName = "net.drinkingtea.nostalgia.geo.Size";
|
||||||
static constexpr auto TypeVersion = 1;
|
static constexpr auto TypeVersion = 1;
|
||||||
int width = 0;
|
int width = 0;
|
||||||
int height = 0;
|
int height = 0;
|
||||||
@ -19,22 +19,22 @@ class Size {
|
|||||||
|
|
||||||
constexpr Size(int width, int height) noexcept;
|
constexpr Size(int width, int height) noexcept;
|
||||||
|
|
||||||
constexpr Size operator+(common::Size p) const noexcept;
|
constexpr Size operator+(geo::Size p) const noexcept;
|
||||||
|
|
||||||
constexpr Size operator-(common::Size p) const noexcept;
|
constexpr Size operator-(geo::Size p) const noexcept;
|
||||||
|
|
||||||
constexpr Size operator*(common::Size p) const noexcept;
|
constexpr Size operator*(geo::Size p) const noexcept;
|
||||||
|
|
||||||
constexpr Size operator/(common::Size p) const noexcept;
|
constexpr Size operator/(geo::Size p) const noexcept;
|
||||||
|
|
||||||
|
|
||||||
constexpr Size operator+=(common::Size p) noexcept;
|
constexpr Size operator+=(geo::Size p) noexcept;
|
||||||
|
|
||||||
constexpr Size operator-=(common::Size p) noexcept;
|
constexpr Size operator-=(geo::Size p) noexcept;
|
||||||
|
|
||||||
constexpr Size operator*=(common::Size p) noexcept;
|
constexpr Size operator*=(geo::Size p) noexcept;
|
||||||
|
|
||||||
constexpr Size operator/=(common::Size p) noexcept;
|
constexpr Size operator/=(geo::Size p) noexcept;
|
||||||
|
|
||||||
|
|
||||||
constexpr Size operator+(int i) const noexcept;
|
constexpr Size operator+(int i) const noexcept;
|
||||||
@ -66,51 +66,51 @@ constexpr Size::Size(int width, int height) noexcept {
|
|||||||
this->height = height;
|
this->height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator+(common::Size p) const noexcept {
|
constexpr Size Size::operator+(geo::Size p) const noexcept {
|
||||||
p.width += width;
|
p.width += width;
|
||||||
p.height += height;
|
p.height += height;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator-(common::Size p) const noexcept {
|
constexpr Size Size::operator-(geo::Size p) const noexcept {
|
||||||
auto out = *this;
|
auto out = *this;
|
||||||
out.width -= p.width;
|
out.width -= p.width;
|
||||||
out.height -= p.height;
|
out.height -= p.height;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator*(common::Size p) const noexcept {
|
constexpr Size Size::operator*(geo::Size p) const noexcept {
|
||||||
p.width *= width;
|
p.width *= width;
|
||||||
p.height *= height;
|
p.height *= height;
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator/(common::Size p) const noexcept {
|
constexpr Size Size::operator/(geo::Size p) const noexcept {
|
||||||
auto out = *this;
|
auto out = *this;
|
||||||
out.width /= p.width;
|
out.width /= p.width;
|
||||||
out.height /= p.height;
|
out.height /= p.height;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator+=(common::Size p) noexcept {
|
constexpr Size Size::operator+=(geo::Size p) noexcept {
|
||||||
width += p.width;
|
width += p.width;
|
||||||
height += p.height;
|
height += p.height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator-=(common::Size p) noexcept {
|
constexpr Size Size::operator-=(geo::Size p) noexcept {
|
||||||
width -= p.width;
|
width -= p.width;
|
||||||
height -= p.height;
|
height -= p.height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator*=(common::Size p) noexcept {
|
constexpr Size Size::operator*=(geo::Size p) noexcept {
|
||||||
width *= p.width;
|
width *= p.width;
|
||||||
height *= p.height;
|
height *= p.height;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Size Size::operator/=(common::Size p) noexcept {
|
constexpr Size Size::operator/=(geo::Size p) noexcept {
|
||||||
width /= p.width;
|
width /= p.width;
|
||||||
height /= p.height;
|
height /= p.height;
|
||||||
return *this;
|
return *this;
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "vec.hpp"
|
#include "vec.hpp"
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
|
|
||||||
#ifndef OX_OS_BareMetal // doesn't compile in devKitPro for some reason
|
#ifndef OX_OS_BareMetal // doesn't compile in devKitPro for some reason
|
||||||
static_assert([] {
|
static_assert([] {
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include <ox/std/types.hpp>
|
#include <ox/std/types.hpp>
|
||||||
|
|
||||||
namespace nostalgia::common {
|
namespace nostalgia::geo {
|
||||||
|
|
||||||
struct Vec2 {
|
struct Vec2 {
|
||||||
float x = 0;
|
float x = 0;
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
|
|
||||||
#include <nostalgia/common/bounds.hpp>
|
#include <nostalgia/geo/bounds.hpp>
|
||||||
|
|
||||||
#include "projectexplorer.hpp"
|
#include "projectexplorer.hpp"
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace nostalgia::world {
|
namespace nostalgia::world {
|
||||||
|
|
||||||
using namespace common;
|
using namespace geo;
|
||||||
using namespace core;
|
using namespace core;
|
||||||
|
|
||||||
ox::Error Zone::init(Context *ctx, Bounds bnds, ox::FileAddress tileSheet, ox::FileAddress palette) {
|
ox::Error Zone::init(Context *ctx, Bounds bnds, ox::FileAddress tileSheet, ox::FileAddress palette) {
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
#include <ox/mc/mc.hpp>
|
#include <ox/mc/mc.hpp>
|
||||||
#include <ox/std/std.hpp>
|
#include <ox/std/std.hpp>
|
||||||
|
|
||||||
#include <nostalgia/common/common.hpp>
|
|
||||||
#include <nostalgia/core/core.hpp>
|
#include <nostalgia/core/core.hpp>
|
||||||
|
#include <nostalgia/geo/geo.hpp>
|
||||||
|
|
||||||
namespace nostalgia::world {
|
namespace nostalgia::world {
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ struct Zone {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
static constexpr auto Fields = 2;
|
static constexpr auto Fields = 2;
|
||||||
common::Bounds m_bounds;
|
geo::Bounds m_bounds;
|
||||||
Tile *m_tiles = nullptr;
|
Tile *m_tiles = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -47,7 +47,7 @@ struct Zone {
|
|||||||
|
|
||||||
~Zone();
|
~Zone();
|
||||||
|
|
||||||
ox::Error init(core::Context *ctx, common::Bounds bnds, ox::FileAddress tileSheet, ox::FileAddress palette = {});
|
ox::Error init(core::Context *ctx, geo::Bounds bnds, ox::FileAddress tileSheet, ox::FileAddress palette = {});
|
||||||
|
|
||||||
void draw(core::Context *ctx);
|
void draw(core::Context *ctx);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user