Squashed 'deps/nostalgia/' changes from a3d6a58c..d68e6493

d68e6493 [nostalgia/core/studio/tilesheeteditor] Add support for dragging palette to palette selector
1cbc5762 [studio] Complete drag/drop support for files
500b9356 [studio] Make new dir window OK on Enter key
800ca851 [ox/std] Fix possible error that occurs with appending on boundary of small string size
cc466a9f [studio] Add support for adding and deleting directories
9d115584 [nostalgia] Rename player from 'nostalgia' to 'Nostalgia'
a2139c09 [studio] Cleanup unused member
a3e5f27a [ox/std] Fix Mac build
643f95ec [studio] Add confirmation dialog for file deletion, move deletion to Project
69241476 [studio] Add ability to add file through dir context menu
6e2b4fa7 [nostalgia] Cleanup player run in Makefile
4e5c7499 [studio] Add support for deleting files
66229de7 [ox/fs] FileSystem fixes with removing files
7eb37c53 [nostalgia/core/studio/paletteeditor] Fix adding page if there is no existing page
7a21b207 [nostalgia/core] Replace ContextDeleter with safeDelete(Context*)
894be237 [ox/std] Drop ox:: qualifier from safeDelete function for pointee
92e9d9cb [keel,studio] Add support for New Item templates
b29b9a9b [ox/std] Add UAnyPtr
721f8442 [nostalgia/core/studio/tilesheeteditor] Fix subsheet and palette scrolling

git-subtree-dir: deps/nostalgia
git-subtree-split: d68e64931b37d7d8bbaff7b43bf131c7acf2aa97
This commit is contained in:
2025-01-19 13:31:44 -06:00
parent 50b1ed33df
commit 7b7d59cf63
45 changed files with 1024 additions and 239 deletions

View File

@ -17,11 +17,9 @@ namespace nostalgia::core {
class Context;
struct ContextDeleter {
void operator()(Context *p) noexcept;
};
void safeDelete(Context *ctx) noexcept;
using ContextUPtr = ox::UPtr<Context, ContextDeleter>;
using ContextUPtr = ox::UPtr<Context>;
ox::Result<ContextUPtr> init(turbine::Context &tctx, InitParams const&params = {}) noexcept;

View File

@ -10,8 +10,8 @@
namespace nostalgia::core {
void ContextDeleter::operator()(Context *p) noexcept {
ox::safeDelete(p);
void safeDelete(Context *ctx) noexcept {
delete ctx;
}
Context::Context(turbine::Context &tctx) noexcept: turbineCtx(tctx) {

View File

@ -7,8 +7,8 @@
namespace nostalgia::core {
void ContextDeleter::operator()(Context *p) noexcept {
ox::safeDelete(p);
void safeDelete(Context *ctx) noexcept {
delete ctx;
}
Context::Context(turbine::Context &tctx, InitParams const&params) noexcept:

View File

@ -1,6 +1,7 @@
target_sources(
NostalgiaCore-Studio PRIVATE
commands/addcolorcommand.cpp
commands/addpagecommand.cpp
commands/applycolorallpagescommand.cpp
commands/duplicatepagecommand.cpp
commands/movecolorcommand.cpp

View File

@ -0,0 +1,28 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include "commands.hpp"
#include "addpagecommand.hpp"
namespace nostalgia::core {
AddPageCommand::AddPageCommand(Palette &pal) noexcept:
m_pal(pal) {}
int AddPageCommand::commandId() const noexcept {
return static_cast<int>(PaletteEditorCommandId::AddPage);
}
ox::Error AddPageCommand::redo() noexcept {
m_pal.pages.emplace_back(ox::sfmt("Page {}", m_pal.pages.size() + 1), ox::Vector<PaletteColor>{});
return {};
}
ox::Error AddPageCommand::undo() noexcept {
m_pal.pages.pop_back();
return {};
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#pragma once
#include <studio/studio.hpp>
#include <nostalgia/core/palette.hpp>
namespace nostalgia::core {
class AddPageCommand: public studio::UndoCommand {
private:
Palette &m_pal;
public:
explicit AddPageCommand(Palette &pal) noexcept;
~AddPageCommand() noexcept override = default;
[[nodiscard]]
int commandId() const noexcept final;
ox::Error redo() noexcept final;
ox::Error undo() noexcept final;
};
}

View File

@ -9,6 +9,7 @@ namespace nostalgia::core {
enum class PaletteEditorCommandId {
ApplyColorAllPages,
RenamePage,
AddPage,
DuplicatePage,
RemovePage,
AddColor,

View File

@ -23,7 +23,7 @@ int DuplicatePageCommand::commandId() const noexcept {
}
ox::Error DuplicatePageCommand::redo() noexcept {
m_pal.pages.emplace(m_dstIdx, "", std::move(m_page));
m_pal.pages.emplace(m_dstIdx, ox::sfmt("Page {}", m_pal.pages.size() + 1), std::move(m_page));
return {};
}

View File

@ -7,6 +7,7 @@
#include <keel/media.hpp>
#include "commands/addcolorcommand.hpp"
#include "commands/addpagecommand.hpp"
#include "commands/applycolorallpagescommand.hpp"
#include "commands/duplicatepagecommand.hpp"
#include "commands/movecolorcommand.hpp"
@ -196,7 +197,11 @@ void PaletteEditorImGui::drawPagesEditor() noexcept {
constexpr auto toolbarHeight = 40;
auto const btnSz = ImVec2{paneSz.x / 4 - 5.5f, 24};
if (ImGui::Button("Add", btnSz)) {
std::ignore = pushCommand<DuplicatePageCommand>(m_pal, 0u, m_pal.pages.size());
if (m_pal.pages.empty()) {
std::ignore = pushCommand<AddPageCommand>(m_pal);
} else {
std::ignore = pushCommand<DuplicatePageCommand>(m_pal, 0u, m_pal.pages.size());
}
m_page = m_pal.pages.size() - 1;
}
ImGui::SameLine();

View File

@ -234,7 +234,7 @@ void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept {
ImGui::BeginChild("SubSheets", {s_palViewWidth - 24, ySize / 2.f}, true);
{
static constexpr auto btnHeight = ig::BtnSz.y;
auto const btnSize = ImVec2{btnHeight, btnHeight};
auto constexpr btnSize = ImVec2{btnHeight, btnHeight};
if (ig::PushButton("+", btnSize)) {
auto insertOnIdx = m_model.activeSubSheetIdx();
auto const&parent = m_model.activeSubSheet();
@ -258,16 +258,19 @@ void TileSheetEditorImGui::draw(studio::StudioContext&) noexcept {
m_exportMenu.show();
}
TileSheet::SubSheetIdx path;
static constexpr auto flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_NoBordersInBody;
if (ImGui::BeginTable("Subsheets", 4, flags)) {
ImGui::TableSetupColumn("Subsheet", ImGuiTableColumnFlags_NoHide);
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 25);
ImGui::TableSetupColumn("Columns", ImGuiTableColumnFlags_WidthFixed, 50);
ImGui::TableSetupColumn("Rows", ImGuiTableColumnFlags_WidthFixed, 50);
ImGui::TableHeadersRow();
drawSubsheetSelector(m_view.img().subsheet, path);
ImGui::EndTable();
}
static constexpr auto flags =
ImGuiTableFlags_RowBg |
ImGuiTableFlags_NoBordersInBody |
ImGuiTableFlags_ScrollY;
if (ImGui::BeginTable("Subsheets", 4, flags)) {
ImGui::TableSetupColumn("Subsheet", ImGuiTableColumnFlags_NoHide);
ImGui::TableSetupColumn("ID", ImGuiTableColumnFlags_WidthFixed, 25);
ImGui::TableSetupColumn("Columns", ImGuiTableColumnFlags_WidthFixed, 50);
ImGui::TableSetupColumn("Rows", ImGuiTableColumnFlags_WidthFixed, 50);
ImGui::TableHeadersRow();
drawSubsheetSelector(m_view.img().subsheet, path);
ImGui::EndTable();
}
}
ImGui::EndChild();
}
@ -440,6 +443,16 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
if (ig::ComboBox("Palette", files, m_selectedPaletteIdx)) {
oxLogError(m_model.setPalette(files[m_selectedPaletteIdx]));
}
if (ig::DragDropTarget const dragDropTarget; dragDropTarget) {
auto const [ref, err] = ig::getDragDropPayload<studio::FileRef>("FileRef");
if (!err) {
auto const oldVal = m_selectedPaletteIdx;
std::ignore = ox::findIdx(files.begin(), files.end(), ref.path).moveTo(m_selectedPaletteIdx);
if (oldVal != m_selectedPaletteIdx) {
oxLogError(m_model.setPalette(files[m_selectedPaletteIdx]));
}
}
}
auto const pages = m_model.pal().pages.size();
if (pages > 1) {
ig::IndentStackItem const indentStackItem{20};
@ -462,8 +475,12 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
}
}
// header
auto constexpr palTblFlags =
ImGuiTableFlags_RowBg |
ImGuiTableFlags_SizingStretchProp |
ImGuiTableFlags_ScrollY;
if (ImGui::BeginTable(
"PaletteTable", 4, ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp)) {
"PaletteTable", 4, palTblFlags)) {
ImGui::TableSetupColumn("Idx", 0, 0.6f);
ImGui::TableSetupColumn("", 0, 0.22f);
ImGui::TableSetupColumn("Name", 0, 3);

View File

@ -1,26 +1,26 @@
add_executable(
nostalgia WIN32
Nostalgia WIN32
app.cpp
)
# enable LTO
if(NOT WIN32)
set_property(TARGET nostalgia PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
set_property(TARGET Nostalgia PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
if(COMMAND OBJCOPY_FILE)
set_target_properties(nostalgia
set_target_properties(Nostalgia
PROPERTIES
LINK_FLAGS ${LINKER_FLAGS}
COMPILER_FLAGS "-mthumb -mthumb-interwork"
)
OBJCOPY_FILE(nostalgia)
#PADBIN_FILE(nostalgia)
OBJCOPY_FILE(Nostalgia)
#PADBIN_FILE(Nostalgia)
endif()
target_link_libraries(
nostalgia
Nostalgia
NostalgiaKeelModules
NostalgiaProfile
OlympicApplib
@ -29,7 +29,7 @@ target_link_libraries(
install(
TARGETS
nostalgia
Nostalgia
DESTINATION
bin
)

View File

@ -1,8 +0,0 @@
/*
* Copyright 2016 - 2025 Gary Talent (gary@drinkingtea.net). All rights reserved.
*/
#include <ox/std/memory.hpp>
#include <ox/fs/fs.hpp>
typename ox::Error run(ox::UniquePtr<ox::FileSystem> &&fs) noexcept;