Compare commits

..

1 Commits

Author SHA1 Message Date
9229713ba2 [nostalgia/studio] Set version to d2025.05.0
All checks were successful
Build / build (push) Successful in 1m22s
2025-05-07 20:27:06 -05:00
19 changed files with 97 additions and 103 deletions

View File

@@ -11,7 +11,6 @@
# "Python Busy Box" - adds cross-platform equivalents to Unix commands that
# don't translate well to that other operating system
import multiprocessing
import os
import platform
import shutil
@@ -58,11 +57,7 @@ def cmake_build(base_path: str, target: Optional[str]) -> int:
path = os.path.join(base_path, d)
if not os.path.isdir(path):
continue
args = ['cmake', '--build', path, f'-j{multiprocessing.cpu_count()}']
if path.endswith('release'):
args.append('--config=release')
elif path.endswith('debug'):
args.append('--config=debug')
args = ['cmake', '--build', path]
if target is not None:
args.extend(['--target', target])
err = subprocess.run(args).returncode

View File

@@ -24,6 +24,9 @@ enum class FileAddressType: int8_t {
Inode,
};
template<typename T>
constexpr Error model(T *h, CommonPtrWith<class FileAddress> auto *fa) noexcept;
class FileAddress {
template<typename T>

View File

@@ -213,22 +213,22 @@ class BasicString {
[[nodiscard]]
constexpr const char *c_str() const noexcept {
return m_buff.data();
return static_cast<const char*>(m_buff.data());
}
[[nodiscard]]
constexpr explicit operator const char*() const {
inline explicit operator const char*() const {
return c_str();
}
#if __has_include(<string>)
[[nodiscard]]
std::string toStdString() const {
inline std::string toStdString() const {
return c_str();
}
[[nodiscard]]
explicit operator std::string() const {
inline explicit operator std::string() const {
return c_str();
}
#endif

View File

@@ -1,22 +1,13 @@
# d2025.05.1
* TileSheetEditor: Fix overrun errors when switching subsheets, clear selection
on switch (261e324acd)
* Fix new build error that occurs in MSVC (26d5048e6720c4c2d52508a6ee44c67dd9fe3ee5)
# d2025.05.0
* Add app icon for both window and file
* Change application font to Roboto Medium
* Closing application will now confirm with user if any files have unsaved
changes.
* UUID duplicates will now be reported when opening a project
* Deleting a directory now closes files in that directory
* Delete key now initiates deletion of selected directory
* Remove ability to re-order tabs. There were bugs associated with that.
* TileSheetEditor: Fix selection clearing in to work when clicking outside
image.
* TileSheetEditor: Fix Delete Tile functionality, which was completely broken
* PaletteEditor: Fix color number key range in. Previously, pressing A caused
the editor to jump to the last color.
* PaletteEditor: page rename will now take effect upon pressing enter if the

View File

@@ -27,14 +27,11 @@ CutPasteCommand::CutPasteCommand(
TileSheet::SubSheetIdx subSheetIdx,
ox::Point const&dstStart,
ox::Point dstEnd,
TileSheetClipboard const&cb):
TileSheetClipboard const&cb) noexcept:
m_commandId(commandId),
m_img(img),
m_subSheetIdx(std::move(subSheetIdx)) {
auto const&ss = getSubSheet(m_img, m_subSheetIdx);
if (dstStart.x >= ss.columns * TileWidth || dstStart.y >= ss.rows * TileHeight) {
throw ox::Exception{1, "paste starts beyond the bounds of target"};
}
dstEnd.x = std::min(ss.columns * TileWidth - 1, dstEnd.x);
dstEnd.y = std::min(ss.rows * TileHeight - 1, dstEnd.y);
for (auto const&p : cb.pixels()) {

View File

@@ -69,7 +69,7 @@ class CutPasteCommand: public TileSheetCommand {
TileSheet::SubSheetIdx subSheetIdx,
ox::Point const&dstStart,
ox::Point dstEnd,
TileSheetClipboard const&cb);
TileSheetClipboard const&cb) noexcept;
ox::Error redo() noexcept final;

View File

@@ -8,14 +8,14 @@
namespace nostalgia::gfx {
DeleteTilesCommand::DeleteTilesCommand(
gfx::DeleteTilesCommand::DeleteTilesCommand(
TileSheet &img,
TileSheet::SubSheetIdx idx,
std::size_t const tileIdx,
std::size_t const tileCnt) noexcept:
std::size_t tileIdx,
std::size_t tileCnt) noexcept:
m_img(img),
m_idx(std::move(idx)) {
constexpr unsigned bytesPerTile = PixelsPerTile;
const unsigned bytesPerTile = m_img.bpp == 4 ? PixelsPerTile / 2 : PixelsPerTile;
m_deletePos = tileIdx * bytesPerTile;
m_deleteSz = tileCnt * bytesPerTile;
m_deletedPixels.resize(m_deleteSz);
@@ -28,20 +28,16 @@ DeleteTilesCommand::DeleteTilesCommand(
}
}
ox::Error DeleteTilesCommand::redo() noexcept {
ox::Error gfx::DeleteTilesCommand::redo() noexcept {
auto &s = getSubSheet(m_img, m_idx);
auto &p = s.pixels;
auto const srcPos = m_deletePos + m_deleteSz;
auto srcPos = m_deletePos + m_deleteSz;
auto const src = &p[srcPos];
auto const dst1 = &p[m_deletePos];
auto const dst2 = &p[(p.size() - m_deleteSz)];
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
if (srcPos < p.size()) {
auto const src = &p[srcPos];
ox::memmove(dst1, src, p.size() - srcPos);
ox::memset(dst2, 0, m_deleteSz * sizeof(decltype(p[0])));
} else {
ox::memset(dst1, 0, p.size() - m_deletePos);
}
ox::memmove(dst1, src, p.size() - srcPos);
ox::memset(dst2, 0, m_deleteSz * sizeof(decltype(p[0])));
OX_ALLOW_UNSAFE_BUFFERS_END
return {};
}
@@ -50,14 +46,11 @@ ox::Error DeleteTilesCommand::undo() noexcept {
auto &s = getSubSheet(m_img, m_idx);
auto &p = s.pixels;
auto const src = &p[m_deletePos];
auto const sz = p.size() - m_deletePos - m_deleteSz;
auto const srcPos = m_deletePos + m_deleteSz;
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
if (srcPos < p.size()) {
auto const dst1 = &p[m_deletePos + m_deleteSz];
ox::memmove(dst1, src, sz);
}
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 {};

View File

@@ -9,19 +9,20 @@ namespace nostalgia::gfx {
InsertTilesCommand::InsertTilesCommand(
TileSheet &img,
TileSheet::SubSheetIdx idx,
std::size_t const tileIdx,
std::size_t const tileCnt) noexcept:
m_img{img},
m_idx{std::move(idx)} {
m_insertPos = tileIdx * PixelsPerTile;
m_insertCnt = tileCnt * PixelsPerTile;
std::size_t tileIdx,
std::size_t tileCnt) noexcept:
m_img(img),
m_idx(std::move(idx)) {
const unsigned bytesPerTile = m_img.bpp == 4 ? PixelsPerTile / 2 : PixelsPerTile;
m_insertPos = tileIdx * bytesPerTile;
m_insertCnt = tileCnt * bytesPerTile;
m_deletedPixels.resize(m_insertCnt);
// copy pixels to be erased
{
auto &s = getSubSheet(m_img, m_idx);
auto &p = s.pixels;
auto const dst = m_deletedPixels.begin();
auto const src = p.begin() + p.size() - m_insertCnt;
auto dst = m_deletedPixels.begin();
auto src = p.begin() + p.size() - m_insertCnt;
ox::copy_n(src, m_insertCnt, dst);
}
}
@@ -31,7 +32,7 @@ OX_ALLOW_UNSAFE_BUFFERS_BEGIN
ox::Error InsertTilesCommand::redo() noexcept {
auto &s = getSubSheet(m_img, m_idx);
auto &p = s.pixels;
auto const dstPos = m_insertPos + m_insertCnt;
auto dstPos = m_insertPos + m_insertCnt;
auto const src = &p[m_insertPos];
if (dstPos < p.size()) {
auto const dst = &p[dstPos];

View File

@@ -6,7 +6,7 @@
namespace nostalgia::gfx {
UpdateSubSheetCommand::UpdateSubSheetCommand(
gfx::UpdateSubSheetCommand::UpdateSubSheetCommand(
TileSheet &img,
TileSheet::SubSheetIdx idx,
ox::StringParam name,

View File

@@ -46,13 +46,13 @@ Palette const TileSheetEditorModel::s_defaultPalette = {
TileSheetEditorModel::TileSheetEditorModel(
studio::Context &sctx, ox::StringParam path, studio::UndoStack &undoStack):
m_sctx{sctx},
m_tctx{m_sctx.tctx},
m_path{std::move(path)},
m_img{*readObj<TileSheet>(keelCtx(m_tctx), m_path).unwrapThrow()},
m_sctx(sctx),
m_tctx(m_sctx.tctx),
m_path(std::move(path)),
m_img(*readObj<TileSheet>(keelCtx(m_tctx), m_path).unwrapThrow()),
// ignore failure to load palette
m_pal{readObj<Palette>(keelCtx(m_tctx), m_img.defaultPalette).value},
m_undoStack{undoStack} {
m_pal(readObj<Palette>(keelCtx(m_tctx), m_img.defaultPalette).value),
m_undoStack(undoStack) {
normalizeSubsheets(m_img.subsheet);
m_pal.updated.connect(this, &TileSheetEditorModel::markUpdated);
m_undoStack.changeTriggered.connect(this, &TileSheetEditorModel::markUpdatedCmdId);
@@ -67,27 +67,19 @@ void TileSheetEditorModel::cut() {
TileSheetClipboard blankCb;
auto cb = ox::make_unique<TileSheetClipboard>();
auto const&s = activeSubSheet();
if (iterateSelectionRows(*m_selection, [&](int const x, int const y) {
iterateSelectionRows(*m_selection, [&](int const x, int const y) {
auto pt = ox::Point{x, y};
auto const idx = gfx::idx(s, pt);
if (idx >= s.pixels.size()) {
return ox::Error{1, "invalid idx"};
}
auto const c = s.pixels[idx];
auto const c = getPixel(s, idx);
pt -= m_selection->a;
cb->addPixel(pt, c);
blankCb.addPixel(pt, 0);
return ox::Error{};
})) {
return;
}
});
auto const pt1 = m_selection->a;
auto const pt2 = ox::Point{s.columns * TileWidth, s.rows * TileHeight};
turbine::setClipboardObject(m_tctx, std::move(cb));
if (auto const cmd = ox::makeCatch<CutPasteCommand>(
CommandId::Cut, m_img, m_activeSubsSheetIdx, pt1, pt2, blankCb); cmd.ok()) {
std::ignore = pushCommand(cmd.value);
}
std::ignore = pushCommand(ox::make<CutPasteCommand>(
CommandId::Cut, m_img, m_activeSubsSheetIdx, pt1, pt2, blankCb));
}
void TileSheetEditorModel::copy() {
@@ -95,20 +87,14 @@ void TileSheetEditorModel::copy() {
return;
}
auto cb = ox::make_unique<TileSheetClipboard>();
if (iterateSelectionRows(*m_selection, [&](int const x, int const y) {
iterateSelectionRows(*m_selection, [&](int const x, int const y) {
auto pt = ox::Point{x, y};
auto const&s = activeSubSheet();
auto const idx = gfx::idx(s, pt);
if (idx >= s.pixels.size()) {
return ox::Error{1, "invalid idx"};
}
auto const c = s.pixels[idx];
auto const c = getPixel(s, idx);
pt -= m_selection->a;
cb->addPixel(pt, c);
return ox::Error{};
})) {
return;
}
});
turbine::setClipboardObject(m_tctx, std::move(cb));
}
@@ -125,10 +111,8 @@ void TileSheetEditorModel::paste() {
auto const&s = activeSubSheet();
auto const pt1 = m_selection->a;
auto const pt2 = ox::Point{s.columns * TileWidth, s.rows * TileHeight};
if (auto const cmd = ox::makeCatch<CutPasteCommand>(
CommandId::Paste, m_img, m_activeSubsSheetIdx, pt1, pt2, *cb); cmd.ok()) {
std::ignore = pushCommand(cmd.value);
}
std::ignore = pushCommand(ox::make<CutPasteCommand>(
CommandId::Paste, m_img, m_activeSubsSheetIdx, pt1, pt2, *cb));
}
bool TileSheetEditorModel::acceptsClipboardPayload() const noexcept {
@@ -168,7 +152,7 @@ void TileSheetEditorModel::drawCommand(ox::Point const &pt, std::size_t const pa
auto const idx = gfx::idx(activeSubSheet, pt);
if (m_ongoingDrawCommand) {
m_updated = m_updated || m_ongoingDrawCommand->append(idx);
} else if (activeSubSheet.pixels[idx] != palIdx) {
} else if (getPixel(activeSubSheet, idx) != palIdx) {
std::ignore = pushCommand(ox::make<DrawCommand>(
m_img, m_activeSubsSheetIdx, idx, static_cast<int>(palIdx)));
}
@@ -229,7 +213,6 @@ ox::Error TileSheetEditorModel::updateSubsheet(
void TileSheetEditorModel::setActiveSubsheet(TileSheet::SubSheetIdx const&idx) noexcept {
m_activeSubsSheetIdx = idx;
this->activeSubsheetChanged.emit(m_activeSubsSheetIdx);
clearSelection();
}
void TileSheetEditorModel::fill(ox::Point const&pt, int const palIdx) noexcept {
@@ -398,7 +381,7 @@ void TileSheetEditorModel::getFillPixels(
int const oldColor) const noexcept {
auto const idx = ptToIdx(pt, activeSubSheet.columns);
auto const relIdx = idx % PixelsPerTile;
if (pixels[relIdx] || activeSubSheet.pixels[idx] != oldColor) {
if (pixels[relIdx] || getPixel(activeSubSheet, idx) != oldColor) {
return;
}
// mark pixels to update
@@ -436,7 +419,7 @@ void TileSheetEditorModel::setPalPath() noexcept {
}
ox::Error TileSheetEditorModel::pushCommand(studio::UndoCommand *cmd) noexcept {
std::ignore = m_undoStack.push(ox::UPtr{cmd});
std::ignore = m_undoStack.push(ox::UPtr<studio::UndoCommand>{cmd});
m_ongoingDrawCommand = dynamic_cast<DrawCommand*>(cmd);
m_updated = true;
return {};

View File

@@ -15,7 +15,7 @@ target_link_libraries(
target_compile_definitions(
NostalgiaStudio PUBLIC
OLYMPIC_APP_VERSION="d2025.05.1"
OLYMPIC_APP_VERSION="d2025.05.0"
)
install(

View File

@@ -18,7 +18,7 @@
<string>APPL</string>
<key>CFBundleVersion</key>
<string>d2025.05.1</string>
<string>d2025.05.0</string>
<key>LSMinimumSystemVersion</key>
<string>12.0.0</string>

View File

@@ -12,6 +12,8 @@
namespace keel {
class Context;
class Context {
public:
ox::UPtr<ox::FileSystem> rom;

View File

@@ -182,7 +182,7 @@ ox::Result<ox::CStringView> uuidToPath(Context &ctx, ox::UUID const&uuid) noexce
#endif
}
ox::Error reloadAsset(Context &ctx, ox::StringViewCR assetId) noexcept {
ox::Error reloadAsset(keel::Context &ctx, ox::StringViewCR assetId) noexcept {
if (beginsWith(assetId, "uuid://")) {
return ctx.assetManager.reloadAsset(substr(assetId, 7));
} else {

View File

@@ -13,10 +13,22 @@ extern ox::String appVersion;
namespace studio {
AboutPopup::AboutPopup(turbine::Context &ctx) noexcept: Popup("About") {
AboutPopup::AboutPopup(turbine::Context &ctx) noexcept {
m_text = ox::sfmt("{} - {}", keelCtx(ctx).appName, olympic::appVersion);
}
void AboutPopup::open() noexcept {
m_stage = Stage::Opening;
}
void AboutPopup::close() noexcept {
m_stage = Stage::Closed;
}
bool AboutPopup::isOpen() const noexcept {
return m_stage == Stage::Open;
}
void AboutPopup::draw(Context &sctx) noexcept {
if (ImGui::IsKeyPressed(ImGuiKey_Escape)) {
close();
@@ -35,7 +47,7 @@ void AboutPopup::draw(Context &sctx) noexcept {
ig::centerNextWindow(sctx.tctx);
auto open = true;
if (ImGui::BeginPopupModal("About", &open, modalFlags)) {
ImGui::Text("%s\n\nBuild date: %s", m_text.c_str(), __DATE__);
ImGui::Text("%s", m_text.c_str());
ImGui::NewLine();
ImGui::Dummy({148.0f, 0.0f});
ImGui::SameLine();

View File

@@ -13,14 +13,29 @@
namespace studio {
class AboutPopup final: public ig::Popup {
class AboutPopup: public studio::Popup {
public:
enum class Stage {
Closed,
Opening,
Open,
};
private:
Stage m_stage = Stage::Closed;
ox::String m_text;
public:
explicit AboutPopup(turbine::Context &ctx) noexcept;
void draw(Context &sctx) noexcept override;
void open() noexcept override;
void close() noexcept override;
[[nodiscard]]
bool isOpen() const noexcept override;
void draw(studio::Context &sctx) noexcept override;
};

View File

@@ -65,7 +65,10 @@ OX_MODEL_END()
StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept:
m_sctx{*this, ctx},
m_tctx{ctx},
m_projectDataDir{std::move(projectDataDir)} {
m_projectDataDir{std::move(projectDataDir)},
m_projectExplorer{keelCtx(m_tctx)},
m_newProject{m_projectDataDir},
m_aboutPopup{m_tctx} {
{
ImFontConfig fontCfg;
fontCfg.FontDataOwnedByAtlas = false;
@@ -252,7 +255,7 @@ void StudioUI::drawMenu() noexcept {
void StudioUI::drawTabBar() noexcept {
auto const viewport = ImGui::GetContentRegionAvail();
ImGui::BeginChild("TabWindow##MainWindow##Studio", ImVec2(viewport.x, viewport.y));
constexpr auto tabBarFlags = ImGuiTabBarFlags_TabListPopupButton;
constexpr auto tabBarFlags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_TabListPopupButton;
if (ImGui::BeginTabBar("TabBar##TabWindow##MainWindow##Studio", tabBarFlags)) {
drawTabs();
ImGui::EndTabBar();

View File

@@ -36,7 +36,7 @@ class StudioUI: public ox::SignalHandler {
TaskRunner m_taskRunner;
ox::Vector<ox::UPtr<BaseEditor>> m_editors;
ox::HashMap<ox::String, EditorMaker::Func> m_editorMakers;
ProjectExplorer m_projectExplorer{keelCtx(m_tctx)};
ProjectExplorer m_projectExplorer;
ox::Vector<ox::String> m_openFiles;
BaseEditor *m_activeEditorOnLastDraw = nullptr;
BaseEditor *m_activeEditor = nullptr;
@@ -45,7 +45,6 @@ class StudioUI: public ox::SignalHandler {
ox::Vector<ox::Pair<ox::String>> m_queuedMoves;
ox::Vector<ox::Pair<ox::String>> m_queuedDirMoves;
NewMenu m_newMenu{keelCtx(m_tctx)};
AboutPopup m_aboutPopup{m_tctx};
DeleteConfirmation m_deleteConfirmation;
NewDir m_newDirDialog;
ig::QuestionPopup m_closeFileConfirm{"Close File?", "This file has unsaved changes. Close?"};
@@ -56,7 +55,8 @@ class StudioUI: public ox::SignalHandler {
ig::MessagePopup m_messagePopup{"Message", ""};
MakeCopyPopup m_copyFilePopup;
RenameFile m_renameFile;
NewProject m_newProject{m_projectDataDir};
NewProject m_newProject;
AboutPopup m_aboutPopup;
ox::Array<Widget*, 10> const m_widgets {
&m_closeFileConfirm,
&m_closeAppConfirm,

View File

@@ -34,4 +34,3 @@ mkdir_p(dmg_dir)
shutil.copytree('dist/darwin-arm64-release/NostalgiaStudio.app', f'{dmg_dir}/NostalgiaStudio.app')
os.symlink('/Applications', f'{dmg_dir}/Applications')
run(['hdiutil', 'create', '-srcfolder', dmg_dir, dmg])
rm(dmg_dir)