Squashed 'deps/nostalgia/' changes from 0c0ccd1a..227f3cd9

227f3cd9 [nostalgia/core/studio] Update itoa usages
20ff0f89 [ox/std] Rework itoa
4061b831 [ox/model] Remove broken global var
18bb5062 [ox/std] Add String::append(StringView), cleanup
6a4b4822 [nostalgia,studio] Fixes for Ox changes
d2a3cfa7 [ox/std] Remove append operators from IString
7c4e2a65 [ox/std] Cleanup IString
e30ebce4 [nostalgia] Add pyenv to .gitignore
7163947e [ox/std] Cleanup
0a0a6e30 [studio] Move UndoCommand implementation to its own file
97bc9332 [nostalgia/core] Fix TileSheetV1 to use PaletteV1
9caf7099 [keel] Fix for Ox change
fda1280d [ox/std] Make substr always take and return a StringView
59aa4ad2 [cityhash] Cleanup
1a8afa1a [nostalgia/sample_project] Add missing type descriptor
cdbc2d6c [olympic/studio] Move UndoCommand to its own file
acd93337 [ox/std] Fix Integer assignment operator return
cebd3b0a [ox/std] Fix Integer assignment operator return
43e2e215 [ox/std] Cleanup
be1f9095 [ox/std] Make safeDelete constexpr
0f2c18d5 [ox/std] Add std::string(_view) variant of MaybeView

git-subtree-dir: deps/nostalgia
git-subtree-split: 227f3cd9f584039cfddad75f1fe1275ad6cac000
This commit is contained in:
2024-05-03 21:15:51 -05:00
parent 22e6299e90
commit df22a1e51b
32 changed files with 318 additions and 283 deletions

View File

@ -27,7 +27,7 @@ struct TileSheetV1 {
int rows = 1;
int columns = 1;
ox::FileAddress defaultPalette;
Palette pal;
PaletteV1 pal;
ox::Vector<uint8_t> pixels = {};
};

View File

@ -32,8 +32,7 @@ void panic(const char *file, int line, const char *panicMsg, ox::Error const&err
std::ignore = initConsole(*ctx);
setBgStatus(*ctx, 0, true);
clearBg(*ctx, 0);
ox::IString<23> serr = "Error code: ";
serr += static_cast<int64_t>(err);
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);

View File

@ -68,12 +68,6 @@ void PaletteEditorImGui::drawColumn(ox::CStringView txt) noexcept {
ImGui::Text("%s", txt.c_str());
}
void PaletteEditorImGui::drawColumn(uint64_t i) noexcept {
ox::Array<char, 10> numStr;
ox::itoa(i, numStr.data());
drawColumn(numStr.data());
}
void PaletteEditorImGui::drawColorsEditor() noexcept {
constexpr auto tableFlags = ImGuiTableFlags_RowBg;
auto const colorsSz = ImGui::GetContentRegionAvail();

View File

@ -33,7 +33,9 @@ class PaletteEditorImGui: public studio::Editor {
private:
static void drawColumn(ox::CStringView txt) noexcept;
static void drawColumn(uint64_t i) noexcept;
static void drawColumn(ox::Integer_c auto i) noexcept {
drawColumn(ox::itoa(i));
}
void drawColorsEditor() noexcept;

View File

@ -410,14 +410,13 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept {
auto const pages = m_model.pal().pages.size();
if (pages > 1) {
ImGui::Indent(20);
ox::Array<char, 10> numStr;
ox::itoa(m_model.palettePage() + 1, numStr.data());
auto numStr = ox::itoa(m_model.palettePage() + 1);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - comboWidthSub);
if (ImGui::BeginCombo("Page", numStr.data(), 0)) {
if (ImGui::BeginCombo("Page", numStr.c_str(), 0)) {
for (auto n = 0u; n < pages; ++n) {
auto const selected = (m_model.palettePage() == n);
ox::itoa(n + 1, numStr.data());
if (ImGui::Selectable(numStr.data(), selected) && m_model.palettePage() != n) {
numStr = ox::itoa(n + 1);
if (ImGui::Selectable(numStr.c_str(), selected) && m_model.palettePage() != n) {
m_model.setPalettePage(n);
}
if (selected) {
@ -440,7 +439,7 @@ void TileSheetEditorImGui::drawPaletteSelector() noexcept {
ImGui::PushID(static_cast<int>(i));
// Column: color idx
ImGui::TableNextColumn();
auto const label = ox::IString<8>() + (i + 1);
auto const label = ox::itoa(i + 1);
auto const rowSelected = i == m_view.palIdx();
if (ImGui::Selectable(label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
m_view.setPalIdx(i);

View File

@ -29,7 +29,7 @@ static ox::Error pathToInode(
return {};
}
if (beginsWith(path, "uuid://")) {
auto const uuid = substr<ox::StringView>(path, 7);
auto const uuid = ox::substr(path, 7);
oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path));
}
oxRequire(s, dest.stat(path));

View File

@ -13,5 +13,6 @@
#include <studio/popup.hpp>
#include <studio/project.hpp>
#include <studio/task.hpp>
#include <studio/undocommand.hpp>
#include <studio/undostack.hpp>
#include <studio/widget.hpp>

View File

@ -0,0 +1,19 @@
/*
* Copyright 2016 - 2024 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
namespace studio {
class UndoCommand {
public:
virtual ~UndoCommand() noexcept = default;
virtual void redo() noexcept = 0;
virtual void undo() noexcept = 0;
[[nodiscard]]
virtual int commandId() const noexcept = 0;
virtual bool mergeWith(UndoCommand const*cmd) noexcept;
};
}

View File

@ -9,17 +9,9 @@
#include <ox/std/memory.hpp>
#include <ox/std/vector.hpp>
namespace studio {
#include "undocommand.hpp"
class UndoCommand {
public:
virtual ~UndoCommand() noexcept = default;
virtual void redo() noexcept = 0;
virtual void undo() noexcept = 0;
[[nodiscard]]
virtual int commandId() const noexcept = 0;
virtual bool mergeWith(UndoCommand const*cmd) noexcept;
};
namespace studio {
class UndoStack {
private:

View File

@ -7,6 +7,7 @@ add_library(
popup.cpp
project.cpp
task.cpp
undocommand.cpp
undostack.cpp
filedialog_nfd.cpp
)

View File

@ -0,0 +1,10 @@
#include <studio/undocommand.hpp>
namespace studio {
bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
return false;
}
}

View File

@ -6,10 +6,6 @@
namespace studio {
bool UndoCommand::mergeWith(UndoCommand const*) noexcept {
return false;
}
void UndoStack::push(ox::UPtr<UndoCommand> &&cmd) noexcept {
for (auto const i = m_stackIdx; i < m_stack.size();) {
std::ignore = m_stack.erase(i);