Squashed 'deps/nostalgia/' changes from 89ae226b..9676ea59
9676ea59 [turbine/glfw] Fix programmatic shutdown to invoke shutdownHandler de8ac106 [turbine/glfw] Fix closing when no shutdown handler is set 88a6cd59 [turbine/glfw] Treat close window event like other events with regard to a mandatory refresh period cd43fb7f [turbine,studio] Fix confirm app close pop up to work with Ctrl-Q 136f4224 [nostalgia] Update release notes e773d6f0 [studio] Rename StudioContext to Context 7da2f68d [nostalgia/sample_project] Add assets d20889ae [nostalgia/gfx/studio] Update for Ox changes 50c8302f [ox] Rename itoa to intToStr d8195d30 [olympic,nostalgia] Address unsafe buffer warnings a8c1387d [ox] Address unsafe buffer warnings ff1e8f26 [studio] Add popup to warn about UUID duplication d4329981 [studio,nostalgia] Cleanup 00034543 [studio,nostalgia/gfx/studio] Cleanup 8c6b2234 [olympic/util] Make pkg-gba script check return code of subprocesses aad4b8a4 [studio] Cleanup 7cab1331 [keel] Add ability to log UUID duplication 640ac85d [nostalgia/gfx/studio/palette] Make page rename dialog accept on enter if input focused b8d76586 [nostalgia/studio] Update generated icondata.cpp with Clang fix 2503bb3b [nostalgia/sample_project] Update type descriptors e5dd448f [turbine,studio] Make Studio confirm with user before closing app if any unsaved changes 4770bb6a [olympic/util] Cleanup c0bac696 [nostalgia/gfx/studio/paletteeditor] Fix color number key range 95f7c334 [studio] Change Studio font 535d8876 [keel] Cleanup 845e4332 [turbine] Fix Mac build 5169a607 [turbine] Disable useless window icon on Mac, it causes GLFW warning 8f03af99 [keel] Style updates ee63a4a1 [keel] Cleanup git-subtree-dir: deps/nostalgia git-subtree-split: 9676ea59787215b01498dfa82f88d426363b3cfd
This commit is contained in:
@@ -238,7 +238,7 @@ uint_t spriteCount(Context &ctx) noexcept;
|
||||
|
||||
ox::Error initConsole(Context &ctx) noexcept;
|
||||
|
||||
void puts(Context &ctx, int column, int row, ox::StringViewCR str) noexcept;
|
||||
void consoleWrite(Context &ctx, int column, int row, ox::StringViewCR str) noexcept;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -36,13 +36,13 @@ OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
setBgStatus(*ctx, 0, true);
|
||||
clearBg(*ctx, 0);
|
||||
auto const serr = ox::sfmt<ox::IString<23>>("Error code: {}", static_cast<int64_t>(err));
|
||||
puts(*ctx, 32 + 1, 1, "SADNESS...");
|
||||
puts(*ctx, 32 + 1, 4, "UNEXPECTED STATE:");
|
||||
puts(*ctx, 32 + 2, 6, panicMsg);
|
||||
consoleWrite(*ctx, 32 + 1, 1, "SADNESS...");
|
||||
consoleWrite(*ctx, 32 + 1, 4, "UNEXPECTED STATE:");
|
||||
consoleWrite(*ctx, 32 + 2, 6, panicMsg);
|
||||
if (err) {
|
||||
puts(*ctx, 32 + 2, 8, serr);
|
||||
consoleWrite(*ctx, 32 + 2, 8, serr);
|
||||
}
|
||||
puts(*ctx, 32 + 1, 15, "PLEASE RESTART THE SYSTEM");
|
||||
consoleWrite(*ctx, 32 + 1, 15, "PLEASE RESTART THE SYSTEM");
|
||||
// print to terminal if in mGBA
|
||||
oxErrf("\033[31;1;1mPANIC:\033[0m [{}:{}]: {}\n", file, line, panicMsg);
|
||||
if (err.msg) {
|
||||
|
@@ -251,7 +251,7 @@ ox::Error initConsole(Context &ctx) noexcept {
|
||||
return loadBgPalette(ctx, 0, PaletteAddr);
|
||||
}
|
||||
|
||||
void puts(
|
||||
void consoleWrite(
|
||||
Context &ctx,
|
||||
int const column,
|
||||
int const row,
|
||||
|
@@ -50,22 +50,25 @@ void PaletteEditorImGui::PageRenameDialog::draw(turbine::Context &tctx) noexcept
|
||||
return;
|
||||
}
|
||||
if (ig::BeginPopup(tctx, "Rename Page", m_show)) {
|
||||
if (ImGui::IsWindowAppearing()) {
|
||||
ImGui::SetKeyboardFocusHere();
|
||||
}
|
||||
ig::InputText("Name", m_name);
|
||||
switch (ig::PopupControlsOkCancel(m_show)) {
|
||||
case ig::PopupResponse::OK:
|
||||
inputSubmitted.emit(m_name);
|
||||
[[fallthrough]];
|
||||
case ig::PopupResponse::Cancel:
|
||||
close();
|
||||
default:
|
||||
break;
|
||||
auto const nameInputFocused = ImGui::IsItemFocused();
|
||||
auto const resp = ig::PopupControlsOkCancel(m_show);
|
||||
if ((nameInputFocused && ImGui::IsKeyPressed(ImGuiKey_Enter))
|
||||
|| resp == ig::PopupResponse::OK) {
|
||||
inputSubmitted.emit(m_name);
|
||||
close();
|
||||
} else if (resp == ig::PopupResponse::Cancel) {
|
||||
close();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringParam path):
|
||||
PaletteEditorImGui::PaletteEditorImGui(studio::Context &sctx, ox::StringParam path):
|
||||
Editor(sctx, std::move(path)),
|
||||
m_sctx(sctx),
|
||||
m_tctx(sctx.tctx),
|
||||
@@ -74,7 +77,7 @@ PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringPa
|
||||
m_pageRenameDlg.inputSubmitted.connect(this, &PaletteEditorImGui::renamePage);
|
||||
}
|
||||
|
||||
void PaletteEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
void PaletteEditorImGui::draw(studio::Context&) noexcept {
|
||||
auto const paneSize = ImGui::GetContentRegionAvail();
|
||||
{
|
||||
ImGui::BeginChild("Pages", {280, paneSize.y}, true);
|
||||
@@ -102,13 +105,13 @@ void PaletteEditorImGui::navigateTo(ox::StringViewCR arg) noexcept {
|
||||
auto const &color = args[0];
|
||||
auto const &page = args[1];
|
||||
{
|
||||
auto const [c, err] = atoi(color);
|
||||
auto const [c, err] = strToInt(color);
|
||||
if (!err && static_cast<size_t>(c) < colorCnt(m_pal)) {
|
||||
m_selectedColorRow = static_cast<size_t>(c);
|
||||
}
|
||||
}
|
||||
{
|
||||
auto const [pg, err] = atoi(page);
|
||||
auto const [pg, err] = strToInt(page);
|
||||
if (!err && static_cast<size_t>(pg) < m_pal.pages.size()) {
|
||||
m_page = static_cast<size_t>(pg);
|
||||
}
|
||||
@@ -131,7 +134,7 @@ void PaletteEditorImGui::numShortcuts(size_t &val, size_t const sizeRange) noexc
|
||||
auto const lastElem = sizeRange - 1;
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_0)) {
|
||||
val = ox::min<size_t>(9, lastElem);
|
||||
} else for (auto i = 9u; i < 10; --i) {
|
||||
} else for (auto i = 8u; i < 9; --i) {
|
||||
auto const key = static_cast<ImGuiKey>(ImGuiKey_1 + i);
|
||||
if (ImGui::IsKeyPressed(key)) {
|
||||
val = ox::min<size_t>(i, lastElem);
|
||||
|
@@ -31,16 +31,16 @@ class PaletteEditorImGui: public studio::Editor {
|
||||
constexpr bool isOpen() const noexcept { return m_show; }
|
||||
void draw(turbine::Context &tctx) noexcept;
|
||||
} m_pageRenameDlg;
|
||||
studio::StudioContext &m_sctx;
|
||||
studio::Context &m_sctx;
|
||||
turbine::Context &m_tctx;
|
||||
Palette m_pal;
|
||||
size_t m_selectedColorRow = 0;
|
||||
size_t m_page = 0;
|
||||
|
||||
public:
|
||||
PaletteEditorImGui(studio::StudioContext &sctx, ox::StringParam path);
|
||||
PaletteEditorImGui(studio::Context &sctx, ox::StringParam path);
|
||||
|
||||
void draw(studio::StudioContext&) noexcept final;
|
||||
void draw(studio::Context&) noexcept final;
|
||||
|
||||
protected:
|
||||
ox::Error saveItem() noexcept final;
|
||||
@@ -53,7 +53,7 @@ class PaletteEditorImGui: public studio::Editor {
|
||||
static void drawColumn(ox::CStringView txt) noexcept;
|
||||
|
||||
static void drawColumn(ox::Integer_c auto i) noexcept {
|
||||
drawColumn(ox::itoa(i));
|
||||
drawColumn(ox::intToStr(i));
|
||||
}
|
||||
|
||||
static void numShortcuts(size_t &val, size_t sizeRange) noexcept;
|
||||
|
@@ -12,15 +12,15 @@
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
static class: public studio::Module {
|
||||
ox::Vector<studio::EditorMaker> editors(studio::StudioContext &ctx) const noexcept final {
|
||||
ox::Vector<studio::EditorMaker> editors(studio::Context &ctx) const noexcept final {
|
||||
return {
|
||||
studio::editorMaker<TileSheetEditorImGui>(ctx, {FileExt_ng, FileExt_nts}),
|
||||
studio::editorMaker<PaletteEditorImGui>(ctx, FileExt_npal),
|
||||
};
|
||||
}
|
||||
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept final {
|
||||
ox::Vector<ox::UniquePtr<studio::ItemMaker>> out;
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::Context&) const noexcept final {
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> out;
|
||||
out.emplace_back(ox::make<studio::ItemMakerT<TileSheet>>("Tile Sheet", "TileSheets", FileExt_nts));
|
||||
out.emplace_back(ox::make<studio::ItemMakerT<Palette>>("Palette", "Palettes", FileExt_npal, Palette{
|
||||
.colorNames = {},
|
||||
|
@@ -35,8 +35,10 @@ ox::Error gfx::DeleteTilesCommand::redo() noexcept {
|
||||
auto const src = &p[srcPos];
|
||||
auto const dst1 = &p[m_deletePos];
|
||||
auto const dst2 = &p[(p.size() - m_deleteSz)];
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
ox::memmove(dst1, src, p.size() - srcPos);
|
||||
ox::memset(dst2, 0, m_deleteSz * sizeof(decltype(p[0])));
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -47,8 +49,10 @@ ox::Error DeleteTilesCommand::undo() noexcept {
|
||||
auto const dst1 = &p[m_deletePos + m_deleteSz];
|
||||
auto const dst2 = src;
|
||||
auto const sz = p.size() - m_deletePos - m_deleteSz;
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
ox::memmove(dst1, src, sz);
|
||||
ox::memcpy(dst2, m_deletedPixels.data(), m_deletedPixels.size());
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,8 @@ InsertTilesCommand::InsertTilesCommand(
|
||||
}
|
||||
}
|
||||
|
||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||
|
||||
ox::Error InsertTilesCommand::redo() noexcept {
|
||||
auto &s = getSubSheet(m_img, m_idx);
|
||||
auto &p = s.pixels;
|
||||
@@ -55,6 +57,8 @@ ox::Error InsertTilesCommand::undo() noexcept {
|
||||
return {};
|
||||
}
|
||||
|
||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||
|
||||
int InsertTilesCommand::commandId() const noexcept {
|
||||
return static_cast<int>(CommandId::InsertTile);
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ static ox::Error toPngFile(
|
||||
8)));
|
||||
}
|
||||
|
||||
TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringParam path):
|
||||
TileSheetEditorImGui::TileSheetEditorImGui(studio::Context &sctx, ox::StringParam path):
|
||||
Editor(sctx, std::move(path)),
|
||||
m_sctx{sctx},
|
||||
m_tctx{m_sctx.tctx},
|
||||
@@ -129,7 +129,7 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key const key, bool const do
|
||||
if (!down) {
|
||||
return;
|
||||
}
|
||||
if (key == turbine::Key::Escape) {
|
||||
if (ig::mainWinHasFocus() && key == turbine::Key::Escape) {
|
||||
m_subsheetEditor.close();
|
||||
m_exportMenu.close();
|
||||
m_palPicker.close();
|
||||
@@ -188,7 +188,7 @@ void TileSheetEditorImGui::keyStateChanged(turbine::Key const key, bool const do
|
||||
}
|
||||
}
|
||||
|
||||
void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept {
|
||||
void TileSheetEditorImGui::draw(studio::Context&) noexcept {
|
||||
if (ig::mainWinHasFocus() && m_tool == TileSheetTool::Select) {
|
||||
if (ImGui::IsKeyDown(ImGuiKey_ModCtrl) && !m_palPathFocused) {
|
||||
if (ImGui::IsKeyPressed(ImGuiKey_A)) {
|
||||
@@ -549,7 +549,7 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
|
||||
ImGui::PushID(static_cast<int>(i));
|
||||
// Column: color idx
|
||||
ImGui::TableNextColumn();
|
||||
auto const label = ox::itoa(i + 1);
|
||||
auto const label = ox::intToStr(i + 1);
|
||||
auto const rowSelected = i == m_view.palIdx();
|
||||
if (ImGui::Selectable(
|
||||
label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
|
||||
|
@@ -45,7 +45,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
constexpr bool isOpen() const noexcept { return m_show; }
|
||||
};
|
||||
static constexpr float s_palViewWidth = 335;
|
||||
studio::StudioContext &m_sctx;
|
||||
studio::Context &m_sctx;
|
||||
turbine::Context &m_tctx;
|
||||
ox::Vector<ox::String> m_paletteList;
|
||||
SubSheetEditor m_subsheetEditor;
|
||||
@@ -60,7 +60,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
ox::Vector<ox::UPtr<studio::UndoCommand>, 1> m_deferredCmds;
|
||||
|
||||
public:
|
||||
TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringParam path);
|
||||
TileSheetEditorImGui(studio::Context &sctx, ox::StringParam path);
|
||||
|
||||
~TileSheetEditorImGui() override = default;
|
||||
|
||||
@@ -77,7 +77,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
||||
|
||||
void keyStateChanged(turbine::Key key, bool down) override;
|
||||
|
||||
void draw(studio::StudioContext&) noexcept override;
|
||||
void draw(studio::Context&) noexcept override;
|
||||
|
||||
void drawSubsheetSelector(TileSheet::SubSheet&, TileSheet::SubSheetIdx &path);
|
||||
|
||||
|
@@ -45,7 +45,7 @@ Palette const TileSheetEditorModel::s_defaultPalette = {
|
||||
};
|
||||
|
||||
TileSheetEditorModel::TileSheetEditorModel(
|
||||
studio::StudioContext &sctx, ox::StringParam path, studio::UndoStack &undoStack):
|
||||
studio::Context &sctx, ox::StringParam path, studio::UndoStack &undoStack):
|
||||
m_sctx(sctx),
|
||||
m_tctx(m_sctx.tctx),
|
||||
m_path(std::move(path)),
|
||||
|
@@ -22,7 +22,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
|
||||
private:
|
||||
static Palette const s_defaultPalette;
|
||||
studio::StudioContext &m_sctx;
|
||||
studio::Context &m_sctx;
|
||||
turbine::Context &m_tctx;
|
||||
ox::String m_path;
|
||||
ox::String m_palPath;
|
||||
@@ -39,7 +39,7 @@ class TileSheetEditorModel: public ox::SignalHandler {
|
||||
bool m_updated = false;
|
||||
|
||||
public:
|
||||
TileSheetEditorModel(studio::StudioContext &sctx, ox::StringParam path, studio::UndoStack &undoStack);
|
||||
TileSheetEditorModel(studio::Context &sctx, ox::StringParam path, studio::UndoStack &undoStack);
|
||||
|
||||
~TileSheetEditorModel() override = default;
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
TileSheetEditorView::TileSheetEditorView(
|
||||
studio::StudioContext &sctx, ox::StringViewCR path, studio::UndoStack &undoStack):
|
||||
studio::Context &sctx, ox::StringViewCR path, studio::UndoStack &undoStack):
|
||||
m_model(sctx, path, undoStack),
|
||||
m_pixelsDrawer(m_model) {
|
||||
glBindVertexArray(0);
|
||||
|
@@ -56,7 +56,7 @@ class TileSheetEditorView: public ox::SignalHandler {
|
||||
std::size_t m_palIdx = 0;
|
||||
|
||||
public:
|
||||
TileSheetEditorView(studio::StudioContext &sctx, ox::StringViewCR path, studio::UndoStack &undoStack);
|
||||
TileSheetEditorView(studio::Context &sctx, ox::StringViewCR path, studio::UndoStack &undoStack);
|
||||
|
||||
~TileSheetEditorView() override = default;
|
||||
|
||||
|
@@ -5,12 +5,13 @@
|
||||
#include <ox/claw/write.hpp>
|
||||
|
||||
#include <nostalgia/gfx/consts.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
|
||||
#include "tilesheetpixelgrid.hpp"
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
void TileSheetGrid::setPixelSizeMod(float sm) noexcept {
|
||||
void TileSheetGrid::setPixelSizeMod(float const sm) noexcept {
|
||||
m_pixelSizeMod = sm;
|
||||
}
|
||||
|
||||
@@ -18,10 +19,11 @@ ox::Error TileSheetGrid::buildShader() noexcept {
|
||||
auto const pixelLineVshad = ox::sfmt(VShad, gl::GlslVersion);
|
||||
auto const pixelLineFshad = ox::sfmt(FShad, gl::GlslVersion);
|
||||
auto const pixelLineGshad = ox::sfmt(GShad, gl::GlslVersion);
|
||||
return glutils::buildShaderProgram(pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(m_shader);
|
||||
return glutils::buildShaderProgram(
|
||||
pixelLineVshad, pixelLineFshad, pixelLineGshad).moveTo(m_shader);
|
||||
}
|
||||
|
||||
void TileSheetGrid::draw(bool update, ox::Vec2 const&scroll) noexcept {
|
||||
void TileSheetGrid::draw(bool const update, ox::Vec2 const&scroll) noexcept {
|
||||
// the lines just show up bigger on Windows for some reason
|
||||
if constexpr(ox::defines::OS == ox::OS::Windows) {
|
||||
glLineWidth(3 * m_pixelSizeMod * 0.25f);
|
||||
@@ -51,7 +53,8 @@ void TileSheetGrid::initBufferSet(ox::Vec2 const&paneSize, TileSheet::SubSheet c
|
||||
// vbo layout
|
||||
auto const pt1Attr = static_cast<GLuint>(glGetAttribLocation(m_shader, "vPt1"));
|
||||
glEnableVertexAttribArray(pt1Attr);
|
||||
glVertexAttribPointer(pt1Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), nullptr);
|
||||
glVertexAttribPointer(
|
||||
pt1Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float), nullptr);
|
||||
auto const pt2Attr = static_cast<GLuint>(glGetAttribLocation(m_shader, "vPt2"));
|
||||
glEnableVertexAttribArray(pt2Attr);
|
||||
glVertexAttribPointer(pt2Attr, 2, GL_FLOAT, GL_FALSE, VertexVboRowLength * sizeof(float),
|
||||
@@ -70,18 +73,18 @@ void TileSheetGrid::update(ox::Vec2 const&paneSize, TileSheet::SubSheet const&su
|
||||
}
|
||||
|
||||
void TileSheetGrid::setBufferObject(
|
||||
ox::Point pt1,
|
||||
ox::Point pt2,
|
||||
Color32 c,
|
||||
float *vbo,
|
||||
ox::Point const pt1,
|
||||
ox::Point const pt2,
|
||||
Color32 const c,
|
||||
ox::Span<float> const vbo,
|
||||
ox::Vec2 const&pixSize) noexcept {
|
||||
auto const x1 = static_cast<float>(pt1.x) * pixSize.x - 1.f;
|
||||
auto const y1 = 1.f - static_cast<float>(pt1.y) * pixSize.y;
|
||||
auto const x2 = static_cast<float>(pt2.x) * pixSize.x - 1.f;
|
||||
auto const y2 = 1.f - static_cast<float>(pt2.y) * pixSize.y;
|
||||
// don't worry, this memcpy gets optimized to something much more ideal
|
||||
// don't worry, this gets optimized to something much more ideal
|
||||
ox::Array<float, VertexVboLength> const vertices = {x1, y1, x2, y2, redf(c), greenf(c), bluef(c)};
|
||||
memcpy(vbo, vertices.data(), sizeof(vertices));
|
||||
ox::spancpy(vbo, ox::SpanView<float>{vertices});
|
||||
}
|
||||
|
||||
void TileSheetGrid::setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept {
|
||||
@@ -92,7 +95,8 @@ void TileSheetGrid::setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubShee
|
||||
}
|
||||
auto const pixSize = pixelSize(paneSize);
|
||||
auto const set = [&](std::size_t i, ox::Point pt1, ox::Point pt2, Color32 c) {
|
||||
auto const vbo = &m_bufferSet.vertices[i * VertexVboLength];
|
||||
auto const idx = i * VertexVboLength;
|
||||
auto const vbo = ox::Span{m_bufferSet.vertices} + idx;
|
||||
setBufferObject(pt1, pt2, c, vbo, pixSize);
|
||||
};
|
||||
// set buffer length
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include <glutils/glutils.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
#include <nostalgia/gfx/tilesheet.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
@@ -74,7 +73,7 @@ class TileSheetGrid {
|
||||
void update(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept;
|
||||
|
||||
private:
|
||||
static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, float *vbo, ox::Vec2 const&pixSize) noexcept;
|
||||
static void setBufferObject(ox::Point pt1, ox::Point pt2, Color32 c, ox::Span<float> vbo, ox::Vec2 const&pixSize) noexcept;
|
||||
|
||||
void setBufferObjects(ox::Vec2 const&paneSize, TileSheet::SubSheet const&subsheet) noexcept;
|
||||
|
||||
|
@@ -2,8 +2,6 @@
|
||||
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||
*/
|
||||
|
||||
#include <nostalgia/gfx/consts.hpp>
|
||||
#include <nostalgia/gfx/ptidxconv.hpp>
|
||||
#include "tilesheeteditormodel.hpp"
|
||||
#include "tilesheetpixels.hpp"
|
||||
|
||||
@@ -88,11 +86,11 @@ ox::Vec2 TileSheetPixels::pixelSize(ox::Vec2 const&paneSize) const noexcept {
|
||||
|
||||
void TileSheetPixels::setPixelBufferObject(
|
||||
ox::Vec2 const&paneSize,
|
||||
unsigned vertexRow,
|
||||
unsigned const vertexRow,
|
||||
float x, float y,
|
||||
Color16 color,
|
||||
float *vbo,
|
||||
GLuint *ebo) const noexcept {
|
||||
Color16 const color,
|
||||
ox::Span<float> const vbo,
|
||||
ox::Span<GLuint> const ebo) const noexcept {
|
||||
auto const [xmod, ymod] = pixelSize(paneSize);
|
||||
x *= xmod;
|
||||
y *= -ymod;
|
||||
@@ -106,12 +104,12 @@ void TileSheetPixels::setPixelBufferObject(
|
||||
x + xmod, y + ymod, r, g, b, // top right
|
||||
x, y + ymod, r, g, b, // top left
|
||||
};
|
||||
memcpy(vbo, vertices.data(), sizeof(vertices));
|
||||
ox::spancpy(vbo, ox::SpanView<float>{vertices});
|
||||
std::array const elms = {
|
||||
vertexRow + 0, vertexRow + 1, vertexRow + 2,
|
||||
vertexRow + 2, vertexRow + 3, vertexRow + 0,
|
||||
};
|
||||
memcpy(ebo, elms.data(), sizeof(elms));
|
||||
ox::spancpy(ebo, ox::SpanView<GLuint>{elms});
|
||||
}
|
||||
|
||||
void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept {
|
||||
@@ -137,8 +135,8 @@ void TileSheetPixels::setBufferObjects(ox::Vec2 const&paneSize) noexcept {
|
||||
auto const pt = idxToPt(static_cast<int>(i), subSheet.columns);
|
||||
auto const fx = static_cast<float>(pt.x);
|
||||
auto const fy = static_cast<float>(pt.y);
|
||||
auto const vbo = &m_bufferSet.vertices[i * vboLen];
|
||||
auto const ebo = &m_bufferSet.elements[i * VertexEboLength];
|
||||
auto const vbo = ox::Span{m_bufferSet.vertices} + i * vboLen;
|
||||
auto const ebo = ox::Span{m_bufferSet.elements} + i * VertexEboLength;
|
||||
if (i * vboLen + vboLen > m_bufferSet.vertices.size()) {
|
||||
return;
|
||||
}
|
||||
|
@@ -6,11 +6,9 @@
|
||||
|
||||
#include <ox/std/vec.hpp>
|
||||
|
||||
#include <glutils/glutils.hpp>
|
||||
#include <studio/studio.hpp>
|
||||
|
||||
#include <nostalgia/gfx/color.hpp>
|
||||
#include <nostalgia/gfx/gfx.hpp>
|
||||
|
||||
#include <glutils/glutils.hpp>
|
||||
|
||||
namespace nostalgia::gfx {
|
||||
|
||||
@@ -44,15 +42,15 @@ class TileSheetPixels {
|
||||
|
||||
private:
|
||||
void setPixelBufferObject(
|
||||
ox::Vec2 const&paneS,
|
||||
ox::Vec2 const&paneSize,
|
||||
unsigned vertexRow,
|
||||
float x,
|
||||
float y,
|
||||
Color16 color,
|
||||
float *vbo,
|
||||
GLuint *ebo) const noexcept;
|
||||
ox::Span<float> vbo,
|
||||
ox::Span<GLuint> ebo) const noexcept;
|
||||
|
||||
void setBufferObjects(ox::Vec2 const&paneS) noexcept;
|
||||
void setBufferObjects(ox::Vec2 const&paneSize) noexcept;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -9,13 +9,13 @@
|
||||
namespace nostalgia::sound {
|
||||
|
||||
static class: public studio::Module {
|
||||
ox::Vector<studio::EditorMaker> editors(studio::StudioContext&) const noexcept final {
|
||||
ox::Vector<studio::EditorMaker> editors(studio::Context&) const noexcept final {
|
||||
return {
|
||||
};
|
||||
}
|
||||
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::StudioContext&) const noexcept final {
|
||||
ox::Vector<ox::UniquePtr<studio::ItemMaker>> out;
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> itemMakers(studio::Context&) const noexcept final {
|
||||
ox::Vector<ox::UPtr<studio::ItemMaker>> out;
|
||||
return out;
|
||||
}
|
||||
} const mod;
|
||||
|
@@ -69,7 +69,7 @@ static ox::Error runTest(turbine::Context &tctx) {
|
||||
OX_RETURN_ERROR(gfx::loadSpriteTileSheet(*cctx, "/TileSheets/Charset.nts"));
|
||||
OX_RETURN_ERROR(gfx::loadSpritePalette(*cctx, "/Palettes/Chester.npal"));
|
||||
OX_RETURN_ERROR(gfx::initConsole(*cctx));
|
||||
gfx::puts(*cctx, 10, 9, "DOPENESS!!!");
|
||||
gfx::consoleWrite(*cctx, 10, 9, "DOPENESS!!!");
|
||||
turbine::setUpdateHandler(tctx, testUpdateHandler);
|
||||
turbine::setKeyEventHandler(tctx, testKeyEventHandler);
|
||||
return turbine::run(tctx);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
static constexpr ox::Array<uint8_t, 134> WindowIcon16Data {
|
||||
static const ox::Array<uint8_t, 134> WindowIcon16Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10,
|
||||
0x00, 0x00, 0x00, 0x10, 0x02, 0x03, 0x00, 0x00, 0x00, 0x62,
|
||||
@@ -24,7 +24,7 @@ static constexpr ox::Array<uint8_t, 134> WindowIcon16Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon16() noexcept { return WindowIcon16Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 149> WindowIcon24Data {
|
||||
static const ox::Array<uint8_t, 149> WindowIcon24Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x18,
|
||||
0x00, 0x00, 0x00, 0x18, 0x02, 0x03, 0x00, 0x00, 0x00, 0x9d,
|
||||
@@ -44,7 +44,7 @@ static constexpr ox::Array<uint8_t, 149> WindowIcon24Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon24() noexcept { return WindowIcon24Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 4249> WindowIcon32Data {
|
||||
static const ox::Array<uint8_t, 4249> WindowIcon32Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20,
|
||||
0x00, 0x00, 0x00, 0x20, 0x02, 0x03, 0x00, 0x00, 0x00, 0x0e,
|
||||
@@ -474,7 +474,7 @@ static constexpr ox::Array<uint8_t, 4249> WindowIcon32Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon32() noexcept { return WindowIcon32Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 334> WindowIcon40Data {
|
||||
static const ox::Array<uint8_t, 334> WindowIcon40Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x28,
|
||||
0x00, 0x00, 0x00, 0x28, 0x08, 0x03, 0x00, 0x00, 0x00, 0xbb,
|
||||
@@ -513,7 +513,7 @@ static constexpr ox::Array<uint8_t, 334> WindowIcon40Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon40() noexcept { return WindowIcon40Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 163> WindowIcon48Data {
|
||||
static const ox::Array<uint8_t, 163> WindowIcon48Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x30,
|
||||
0x00, 0x00, 0x00, 0x30, 0x02, 0x03, 0x00, 0x00, 0x00, 0x2a,
|
||||
@@ -535,7 +535,7 @@ static constexpr ox::Array<uint8_t, 163> WindowIcon48Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon48() noexcept { return WindowIcon48Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 8148> WindowIcon128Data {
|
||||
static const ox::Array<uint8_t, 8148> WindowIcon128Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x80,
|
||||
0x00, 0x00, 0x00, 0x80, 0x02, 0x03, 0x00, 0x00, 0x00, 0xbe,
|
||||
@@ -1355,7 +1355,7 @@ static constexpr ox::Array<uint8_t, 8148> WindowIcon128Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon128() noexcept { return WindowIcon128Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 275> WindowIcon264Data {
|
||||
static const ox::Array<uint8_t, 275> WindowIcon264Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x01, 0x08,
|
||||
0x00, 0x00, 0x01, 0x08, 0x02, 0x03, 0x00, 0x00, 0x00, 0xde,
|
||||
@@ -1388,7 +1388,7 @@ static constexpr ox::Array<uint8_t, 275> WindowIcon264Data {
|
||||
|
||||
ox::SpanView<uint8_t> WindowIcon264() noexcept { return WindowIcon264Data; }
|
||||
|
||||
static constexpr ox::Array<uint8_t, 851> WindowIcon1080Data {
|
||||
static const ox::Array<uint8_t, 851> WindowIcon1080Data {
|
||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
|
||||
0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x03, 0x48,
|
||||
0x00, 0x00, 0x03, 0x48, 0x02, 0x03, 0x00, 0x00, 0x00, 0x80,
|
||||
|
Reference in New Issue
Block a user