Merge commit 'a1a34f27f9d873bff520a1e890f5071faa20f170'
This commit is contained in:
commit
943c1bf48b
@ -264,8 +264,8 @@ class Signal<Error(Args...)> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cleanup(Signal *signal) noexcept final {
|
void cleanup(Signal *signal) noexcept final {
|
||||||
auto err = m_receiver->destruction.disconnectSignal(signal);
|
std::ignore = m_receiver->destruction.disconnectSignal(signal);
|
||||||
oxErrorf("{}", toStr(err));
|
//oxErrorf("{}", toStr(err));
|
||||||
//oxAssert(err, "Signal could not notify receiver that it is being destroyed. Destruction of receiver will cause use-after-free.");
|
//oxAssert(err, "Signal could not notify receiver that it is being destroyed. Destruction of receiver will cause use-after-free.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ install(
|
|||||||
stringview.hpp
|
stringview.hpp
|
||||||
strongint.hpp
|
strongint.hpp
|
||||||
strconv.hpp
|
strconv.hpp
|
||||||
|
stringparam.hpp
|
||||||
strops.hpp
|
strops.hpp
|
||||||
trace.hpp
|
trace.hpp
|
||||||
typeinfo.hpp
|
typeinfo.hpp
|
||||||
|
@ -234,12 +234,16 @@ constexpr auto itoa(Integer v) noexcept {
|
|||||||
switch (sizeof(Integer)) {
|
switch (sizeof(Integer)) {
|
||||||
case 1:
|
case 1:
|
||||||
out = 3;
|
out = 3;
|
||||||
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
out = 5;
|
out = 5;
|
||||||
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
out = 10;
|
out = 10;
|
||||||
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
out = 21;
|
out = 21;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return out + ox::is_signed_v<Integer>;
|
return out + ox::is_signed_v<Integer>;
|
||||||
}();
|
}();
|
||||||
|
1
deps/nostalgia/deps/ox/src/ox/std/std.hpp
vendored
1
deps/nostalgia/deps/ox/src/ox/std/std.hpp
vendored
@ -46,6 +46,7 @@
|
|||||||
#include "stddef.hpp"
|
#include "stddef.hpp"
|
||||||
#include "string.hpp"
|
#include "string.hpp"
|
||||||
#include "stringliteral.hpp"
|
#include "stringliteral.hpp"
|
||||||
|
#include "stringparam.hpp"
|
||||||
#include "stringview.hpp"
|
#include "stringview.hpp"
|
||||||
#include "strongint.hpp"
|
#include "strongint.hpp"
|
||||||
#include "strops.hpp"
|
#include "strops.hpp"
|
||||||
|
32
deps/nostalgia/deps/ox/src/ox/std/stringparam.hpp
vendored
Normal file
32
deps/nostalgia/deps/ox/src/ox/std/stringparam.hpp
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 - 2024 gary@drinkingtea.net
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "string.hpp"
|
||||||
|
|
||||||
|
namespace ox {
|
||||||
|
|
||||||
|
class StringParam {
|
||||||
|
private:
|
||||||
|
ox::String m_value;
|
||||||
|
public:
|
||||||
|
StringParam(StringParam const&) = delete;
|
||||||
|
constexpr StringParam(StringParam &&o) noexcept: m_value{std::move(o.m_value)} {}
|
||||||
|
constexpr StringParam(char const*value) noexcept: m_value{value} {}
|
||||||
|
constexpr StringParam(detail::BaseStringView const&value) noexcept: m_value{value} {}
|
||||||
|
constexpr StringParam(ox::String const&value) noexcept: m_value{value} {}
|
||||||
|
constexpr StringParam(ox::String &&value) noexcept: m_value{std::move(value)} {}
|
||||||
|
constexpr operator ox::String() && noexcept { return std::move(m_value); }
|
||||||
|
explicit constexpr operator ox::CStringView() const noexcept { return m_value; }
|
||||||
|
explicit constexpr operator ox::StringView() const noexcept { return m_value; }
|
||||||
|
[[nodiscard]]
|
||||||
|
constexpr ox::CStringView view() const noexcept { return m_value; }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
@ -29,7 +29,7 @@ ox::Error PaletteV2ToPaletteV3Converter::convert(
|
|||||||
dst.pages = std::move(src.pages);
|
dst.pages = std::move(src.pages);
|
||||||
if (!dst.pages.empty()) {
|
if (!dst.pages.empty()) {
|
||||||
for (size_t i = 0; i < dst.pages[0].size(); ++i) {
|
for (size_t i = 0; i < dst.pages[0].size(); ++i) {
|
||||||
dst.colorInfo.emplace_back(ox::sfmt("Color {}", i));
|
dst.colorInfo.emplace_back(ox::sfmt("Color {}", i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -17,8 +17,8 @@ namespace nostalgia::core {
|
|||||||
|
|
||||||
namespace ig = studio::ig;
|
namespace ig = studio::ig;
|
||||||
|
|
||||||
PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringView const path):
|
PaletteEditorImGui::PaletteEditorImGui(studio::StudioContext &sctx, ox::StringParam path):
|
||||||
Editor(path),
|
Editor(std::move(path)),
|
||||||
m_sctx(sctx),
|
m_sctx(sctx),
|
||||||
m_tctx(sctx.tctx),
|
m_tctx(sctx.tctx),
|
||||||
m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) {
|
m_pal(*keel::readObj<Palette>(keelCtx(m_tctx), itemPath()).unwrapThrow()) {
|
||||||
|
@ -21,7 +21,7 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
size_t m_page = 0;
|
size_t m_page = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PaletteEditorImGui(studio::StudioContext &sctx, ox::StringView path);
|
PaletteEditorImGui(studio::StudioContext &sctx, ox::StringParam path);
|
||||||
|
|
||||||
void keyStateChanged(turbine::Key key, bool down) override;
|
void keyStateChanged(turbine::Key key, bool down) override;
|
||||||
|
|
||||||
|
@ -21,13 +21,13 @@ DrawCommand::DrawCommand(
|
|||||||
DrawCommand::DrawCommand(
|
DrawCommand::DrawCommand(
|
||||||
TileSheet &img,
|
TileSheet &img,
|
||||||
TileSheet::SubSheetIdx subSheetIdx,
|
TileSheet::SubSheetIdx subSheetIdx,
|
||||||
const ox::Vector<std::size_t> &idxList,
|
ox::Vector<std::size_t> const&idxList,
|
||||||
int palIdx) noexcept:
|
int palIdx) noexcept:
|
||||||
m_img(img),
|
m_img(img),
|
||||||
m_subSheetIdx(std::move(subSheetIdx)),
|
m_subSheetIdx(std::move(subSheetIdx)),
|
||||||
m_palIdx(palIdx) {
|
m_palIdx(palIdx) {
|
||||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||||
for (const auto idx : idxList) {
|
for (auto const idx : idxList) {
|
||||||
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(subsheet, m_img.bpp, idx));
|
m_changes.emplace_back(static_cast<uint32_t>(idx), getPixel(subsheet, m_img.bpp, idx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ bool DrawCommand::append(std::size_t idx) noexcept {
|
|||||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||||
if (m_changes.back().value->idx != idx && getPixel(subsheet, m_img.bpp, idx) != m_palIdx) {
|
if (m_changes.back().value->idx != idx && getPixel(subsheet, m_img.bpp, idx) != m_palIdx) {
|
||||||
// duplicate entries are bad
|
// duplicate entries are bad
|
||||||
auto existing = ox::find_if(m_changes.cbegin(), m_changes.cend(), [idx](const auto &c) {
|
auto existing = ox::find_if(m_changes.cbegin(), m_changes.cend(), [idx](auto const&c) {
|
||||||
return c.idx == idx;
|
return c.idx == idx;
|
||||||
});
|
});
|
||||||
if (existing == m_changes.cend()) {
|
if (existing == m_changes.cend()) {
|
||||||
@ -48,7 +48,7 @@ bool DrawCommand::append(std::size_t idx) noexcept {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DrawCommand::append(const ox::Vector<std::size_t> &idxList) noexcept {
|
bool DrawCommand::append(ox::Vector<std::size_t> const&idxList) noexcept {
|
||||||
auto out = false;
|
auto out = false;
|
||||||
for (auto idx : idxList) {
|
for (auto idx : idxList) {
|
||||||
out = append(idx) || out;
|
out = append(idx) || out;
|
||||||
@ -58,7 +58,7 @@ bool DrawCommand::append(const ox::Vector<std::size_t> &idxList) noexcept {
|
|||||||
|
|
||||||
ox::Error DrawCommand::redo() noexcept {
|
ox::Error DrawCommand::redo() noexcept {
|
||||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||||
for (const auto &c : m_changes) {
|
for (auto const&c : m_changes) {
|
||||||
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(m_palIdx));
|
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(m_palIdx));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
@ -66,7 +66,7 @@ ox::Error DrawCommand::redo() noexcept {
|
|||||||
|
|
||||||
ox::Error DrawCommand::undo() noexcept {
|
ox::Error DrawCommand::undo() noexcept {
|
||||||
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
auto &subsheet = getSubSheet(m_img, m_subSheetIdx);
|
||||||
for (const auto &c : m_changes) {
|
for (auto const&c : m_changes) {
|
||||||
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(c.oldPalIdx));
|
setPixel(subsheet, m_img.bpp, c.idx, static_cast<uint8_t>(c.oldPalIdx));
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
|
@ -33,12 +33,12 @@ class DrawCommand: public TileSheetCommand {
|
|||||||
DrawCommand(
|
DrawCommand(
|
||||||
TileSheet &img,
|
TileSheet &img,
|
||||||
TileSheet::SubSheetIdx subSheetIdx,
|
TileSheet::SubSheetIdx subSheetIdx,
|
||||||
const ox::Vector<std::size_t> &idxList,
|
ox::Vector<std::size_t> const&idxList,
|
||||||
int palIdx) noexcept;
|
int palIdx) noexcept;
|
||||||
|
|
||||||
bool append(std::size_t idx) noexcept;
|
bool append(std::size_t idx) noexcept;
|
||||||
|
|
||||||
bool append(const ox::Vector<std::size_t> &idxList) noexcept;
|
bool append(ox::Vector<std::size_t> const&idxList) noexcept;
|
||||||
|
|
||||||
ox::Error redo() noexcept final;
|
ox::Error redo() noexcept final;
|
||||||
|
|
||||||
|
@ -86,11 +86,11 @@ static ox::Error toPngFile(
|
|||||||
8)));
|
8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringView const path):
|
TileSheetEditorImGui::TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringParam path):
|
||||||
Editor(path),
|
Editor(std::move(path)),
|
||||||
m_sctx(sctx),
|
m_sctx(sctx),
|
||||||
m_tctx(m_sctx.tctx),
|
m_tctx(m_sctx.tctx),
|
||||||
m_view(m_sctx, path, *undoStack()),
|
m_view(m_sctx, itemPath(), *undoStack()),
|
||||||
m_model(m_view.model()) {
|
m_model(m_view.model()) {
|
||||||
std::ignore = setPaletteSelection();
|
std::ignore = setPaletteSelection();
|
||||||
// connect signal/slots
|
// connect signal/slots
|
||||||
|
@ -67,7 +67,7 @@ class TileSheetEditorImGui: public studio::Editor {
|
|||||||
TileSheetTool m_tool = TileSheetTool::Draw;
|
TileSheetTool m_tool = TileSheetTool::Draw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringView path);
|
TileSheetEditorImGui(studio::StudioContext &sctx, ox::StringParam path);
|
||||||
|
|
||||||
~TileSheetEditorImGui() override = default;
|
~TileSheetEditorImGui() override = default;
|
||||||
|
|
||||||
|
@ -87,12 +87,12 @@ void TileSheetEditorView::clickFill(ox::Vec2 const&paneSize, ox::Vec2 const&clic
|
|||||||
void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept {
|
void TileSheetEditorView::releaseMouseButton(TileSheetTool tool) noexcept {
|
||||||
switch (tool) {
|
switch (tool) {
|
||||||
case TileSheetTool::Draw:
|
case TileSheetTool::Draw:
|
||||||
|
case TileSheetTool::Fill:
|
||||||
m_model.endDrawCommand();
|
m_model.endDrawCommand();
|
||||||
break;
|
break;
|
||||||
case TileSheetTool::Select:
|
case TileSheetTool::Select:
|
||||||
m_model.completeSelection();
|
m_model.completeSelection();
|
||||||
break;
|
break;
|
||||||
case TileSheetTool::Fill:
|
|
||||||
case TileSheetTool::None:
|
case TileSheetTool::None:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
NewMenu::NewMenu() noexcept {
|
NewMenu::NewMenu() noexcept {
|
||||||
setTitle(ox::String("New Item"));
|
setTitle("New Item");
|
||||||
setSize({230, 140});
|
setSize({230, 140});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
NewProject::NewProject(ox::String projectDatadir) noexcept: m_projectDataDir(std::move(projectDatadir)) {
|
NewProject::NewProject(ox::StringParam projectDatadir) noexcept: m_projectDataDir(std::move(projectDatadir)) {
|
||||||
setTitle(ox::String("New Project"));
|
setTitle("New Project");
|
||||||
setSize({230, 140});
|
setSize({230, 140});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class NewProject: public studio::Popup {
|
|||||||
bool m_open = false;
|
bool m_open = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NewProject(ox::String projectDatadir) noexcept;
|
NewProject(ox::StringParam projectDatadir) noexcept;
|
||||||
|
|
||||||
void open() noexcept override;
|
void open() noexcept override;
|
||||||
|
|
||||||
|
@ -41,12 +41,12 @@ oxModelBegin(StudioConfig)
|
|||||||
oxModelFieldRename(showProjectExplorer, show_project_explorer)
|
oxModelFieldRename(showProjectExplorer, show_project_explorer)
|
||||||
oxModelEnd()
|
oxModelEnd()
|
||||||
|
|
||||||
StudioUI::StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept:
|
StudioUI::StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept:
|
||||||
m_sctx(*this, ctx),
|
m_sctx(*this, ctx),
|
||||||
m_ctx(ctx),
|
m_ctx(ctx),
|
||||||
m_projectDataDir(projectDataDir),
|
m_projectDataDir(std::move(projectDataDir)),
|
||||||
m_projectExplorer(m_ctx),
|
m_projectExplorer(m_ctx),
|
||||||
m_newProject(ox::String(projectDataDir)),
|
m_newProject(m_projectDataDir),
|
||||||
m_aboutPopup(m_ctx) {
|
m_aboutPopup(m_ctx) {
|
||||||
turbine::setApplicationData(m_ctx, &m_sctx);
|
turbine::setApplicationData(m_ctx, &m_sctx);
|
||||||
m_projectExplorer.fileChosen.connect(this, &StudioUI::openFile);
|
m_projectExplorer.fileChosen.connect(this, &StudioUI::openFile);
|
||||||
@ -326,11 +326,11 @@ ox::Error StudioUI::createOpenProject(ox::CRStringView path) noexcept {
|
|||||||
return m_project->writeTypeStore();
|
return m_project->writeTypeStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error StudioUI::openProjectPath(ox::CRStringView path) noexcept {
|
ox::Error StudioUI::openProjectPath(ox::StringParam path) noexcept {
|
||||||
oxRequireM(fs, keel::loadRomFs(path));
|
oxRequireM(fs, keel::loadRomFs(path.view()));
|
||||||
oxReturnError(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
|
oxReturnError(keel::setRomFs(keelCtx(m_ctx), std::move(fs)));
|
||||||
oxReturnError(
|
oxReturnError(
|
||||||
ox::make_unique_catch<studio::Project>(keelCtx(m_ctx), ox::String(path), m_projectDataDir)
|
ox::make_unique_catch<studio::Project>(keelCtx(m_ctx), std::move(path), m_projectDataDir)
|
||||||
.moveTo(m_project));
|
.moveTo(m_project));
|
||||||
auto const sctx = applicationData<studio::StudioContext>(m_ctx);
|
auto const sctx = applicationData<studio::StudioContext>(m_ctx);
|
||||||
sctx->project = m_project.get();
|
sctx->project = m_project.get();
|
||||||
@ -364,7 +364,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
oxRequire(ext, studio::fileExt(path).to<ox::String>([](auto const&v) {return ox::String(v);}));
|
oxRequire(ext, studio::fileExt(path));
|
||||||
// create Editor
|
// create Editor
|
||||||
studio::BaseEditor *editor = nullptr;
|
studio::BaseEditor *editor = nullptr;
|
||||||
if (!m_editorMakers.contains(ext)) {
|
if (!m_editorMakers.contains(ext)) {
|
||||||
@ -392,7 +392,7 @@ ox::Error StudioUI::openFileActiveTab(ox::CRStringView path, bool makeActiveTab)
|
|||||||
m_activeEditorUpdatePending = editor;
|
m_activeEditorUpdatePending = editor;
|
||||||
}
|
}
|
||||||
// save to config
|
// save to config
|
||||||
studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&](StudioConfig &config) {
|
studio::editConfig<StudioConfig>(keelCtx(m_ctx), [&path](StudioConfig &config) {
|
||||||
if (!config.openFiles.contains(path)) {
|
if (!config.openFiles.contains(path)) {
|
||||||
config.openFiles.emplace_back(path);
|
config.openFiles.emplace_back(path);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
bool m_showProjectExplorer = true;
|
bool m_showProjectExplorer = true;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StudioUI(turbine::Context &ctx, ox::StringView projectDataDir) noexcept;
|
explicit StudioUI(turbine::Context &ctx, ox::StringParam projectDataDir) noexcept;
|
||||||
|
|
||||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
|
|
||||||
ox::Error createOpenProject(ox::CRStringView path) noexcept;
|
ox::Error createOpenProject(ox::CRStringView path) noexcept;
|
||||||
|
|
||||||
ox::Error openProjectPath(ox::CRStringView path) noexcept;
|
ox::Error openProjectPath(ox::StringParam path) noexcept;
|
||||||
|
|
||||||
ox::Error openFile(ox::CRStringView path) noexcept;
|
ox::Error openFile(ox::CRStringView path) noexcept;
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ class Editor: public studio::BaseEditor {
|
|||||||
ox::String m_itemName;
|
ox::String m_itemName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Editor(ox::StringView itemPath) noexcept;
|
Editor(ox::StringParam itemPath) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
ox::CStringView itemPath() const noexcept final;
|
ox::CStringView itemPath() const noexcept final;
|
||||||
|
@ -19,17 +19,17 @@ class ItemMaker {
|
|||||||
ox::String const parentDir;
|
ox::String const parentDir;
|
||||||
ox::String const fileExt;
|
ox::String const fileExt;
|
||||||
constexpr explicit ItemMaker(
|
constexpr explicit ItemMaker(
|
||||||
ox::StringView pName,
|
ox::StringParam pName,
|
||||||
ox::StringView pParentDir,
|
ox::StringParam pParentDir,
|
||||||
ox::StringView pFileExt) noexcept:
|
ox::StringParam pFileExt) noexcept:
|
||||||
typeName(pName),
|
typeName{std::move(pName)},
|
||||||
parentDir(pParentDir),
|
parentDir{std::move(pParentDir)},
|
||||||
fileExt(pFileExt) {
|
fileExt{std::move(pFileExt)} {
|
||||||
}
|
}
|
||||||
virtual ~ItemMaker() noexcept = default;
|
virtual ~ItemMaker() noexcept = default;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline virtual ox::String itemPath(ox::StringView pName) const noexcept {
|
virtual ox::String itemPath(ox::StringView pName) const noexcept {
|
||||||
return ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
return ox::sfmt("/{}/{}.{}", parentDir, pName, fileExt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,8 +39,7 @@ class ItemMaker {
|
|||||||
* @param pName
|
* @param pName
|
||||||
* @return path of file or error in Result
|
* @return path of file or error in Result
|
||||||
*/
|
*/
|
||||||
virtual ox::Result<ox::String> write(
|
virtual ox::Result<ox::String> write(StudioContext &ctx, ox::StringView pName) const noexcept = 0;
|
||||||
studio::StudioContext &ctx, ox::CRStringView pName) const noexcept = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -50,36 +49,36 @@ class ItemMakerT: public ItemMaker {
|
|||||||
ox::ClawFormat const m_fmt;
|
ox::ClawFormat const m_fmt;
|
||||||
public:
|
public:
|
||||||
constexpr ItemMakerT(
|
constexpr ItemMakerT(
|
||||||
ox::StringView pDisplayName,
|
ox::StringParam pDisplayName,
|
||||||
ox::StringView pParentDir,
|
ox::StringParam pParentDir,
|
||||||
ox::StringView fileExt,
|
ox::StringParam fileExt,
|
||||||
ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept:
|
ox::ClawFormat pFmt = ox::ClawFormat::Metal) noexcept:
|
||||||
ItemMaker(pDisplayName, pParentDir, fileExt),
|
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
|
||||||
m_fmt(pFmt) {
|
m_fmt(pFmt) {
|
||||||
}
|
}
|
||||||
constexpr ItemMakerT(
|
constexpr ItemMakerT(
|
||||||
ox::StringView pDisplayName,
|
ox::StringParam pDisplayName,
|
||||||
ox::StringView pParentDir,
|
ox::StringParam pParentDir,
|
||||||
ox::StringView fileExt,
|
ox::StringParam fileExt,
|
||||||
T pItem,
|
T pItem,
|
||||||
ox::ClawFormat pFmt) noexcept:
|
ox::ClawFormat pFmt) noexcept:
|
||||||
ItemMaker(pDisplayName, pParentDir, fileExt),
|
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
|
||||||
m_item(std::move(pItem)),
|
m_item(std::move(pItem)),
|
||||||
m_fmt(pFmt) {
|
m_fmt(pFmt) {
|
||||||
}
|
}
|
||||||
constexpr ItemMakerT(
|
constexpr ItemMakerT(
|
||||||
ox::StringView pDisplayName,
|
ox::StringParam pDisplayName,
|
||||||
ox::StringView pParentDir,
|
ox::StringParam pParentDir,
|
||||||
ox::StringView fileExt,
|
ox::StringParam fileExt,
|
||||||
T &&pItem,
|
T &&pItem,
|
||||||
ox::ClawFormat pFmt) noexcept:
|
ox::ClawFormat pFmt) noexcept:
|
||||||
ItemMaker(pDisplayName, pParentDir, fileExt),
|
ItemMaker(std::move(pDisplayName), std::move(pParentDir), std::move(fileExt)),
|
||||||
m_item(std::move(pItem)),
|
m_item(std::move(pItem)),
|
||||||
m_fmt(pFmt) {
|
m_fmt(pFmt) {
|
||||||
}
|
}
|
||||||
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::CRStringView pName) const noexcept override {
|
ox::Result<ox::String> write(studio::StudioContext &sctx, ox::StringView const pName) const noexcept override {
|
||||||
auto const path = itemPath(pName);
|
auto const path = itemPath(pName);
|
||||||
keel::createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
|
createUuidMapping(keelCtx(sctx.tctx), path, ox::UUID::generate().unwrap());
|
||||||
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
|
oxReturnError(sctx.project->writeObj(path, m_item, m_fmt));
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,9 @@ class Module {
|
|||||||
|
|
||||||
template<typename Editor>
|
template<typename Editor>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::CRStringView ext) noexcept {
|
studio::EditorMaker editorMaker(studio::StudioContext &ctx, ox::StringParam ext) noexcept {
|
||||||
return {
|
return {
|
||||||
{ox::String(ext)},
|
{std::move(ext)},
|
||||||
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
[&ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
return ox::makeCatch<Editor>(ctx, path);
|
return ox::makeCatch<Editor>(ctx, path);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ class Popup {
|
|||||||
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
m_size = {static_cast<float>(sz.width), static_cast<float>(sz.height)};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr void setTitle(ox::String title) noexcept {
|
constexpr void setTitle(ox::StringParam title) noexcept {
|
||||||
m_title = std::move(title);
|
m_title = std::move(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,8 +115,8 @@ void BaseEditor::setRequiresConstantRefresh(bool value) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Editor::Editor(ox::StringView itemPath) noexcept:
|
Editor::Editor(ox::StringParam itemPath) noexcept:
|
||||||
m_itemPath(itemPath),
|
m_itemPath(std::move(itemPath)),
|
||||||
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)) {
|
m_itemName(m_itemPath.substr(std::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset() + 1)) {
|
||||||
m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges);
|
m_undoStack.changeTriggered.connect(this, &Editor::markUnsavedChanges);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user