[nostalgia] Replace unnecessary ox::Strings with ox::StringViews
This commit is contained in:
parent
5a09918b64
commit
6cfa8dd40d
@ -2,7 +2,8 @@
|
|||||||
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
* Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ox/std/memory.hpp"
|
#include <ox/std/memory.hpp>
|
||||||
|
|
||||||
#include "paletteeditor-imgui.hpp"
|
#include "paletteeditor-imgui.hpp"
|
||||||
#include "tilesheeteditor-imgui.hpp"
|
#include "tilesheeteditor-imgui.hpp"
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ ox::Vector<studio::EditorMaker> Module::editors(core::Context *ctx) noexcept {
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
{"ng"},
|
{"ng"},
|
||||||
[ctx](const ox::String &path) -> ox::Result<studio::BaseEditor*> {
|
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
try {
|
try {
|
||||||
return ox::make<TileSheetEditorImGui>(ctx, path);
|
return ox::make<TileSheetEditorImGui>(ctx, path);
|
||||||
} catch (const ox::Exception &ex) {
|
} catch (const ox::Exception &ex) {
|
||||||
@ -24,7 +25,7 @@ ox::Vector<studio::EditorMaker> Module::editors(core::Context *ctx) noexcept {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
{"npal"},
|
{"npal"},
|
||||||
[ctx](const ox::String &path) -> ox::Result<studio::BaseEditor*> {
|
[ctx](ox::CRStringView path) -> ox::Result<studio::BaseEditor*> {
|
||||||
return PaletteEditorImGui::make(ctx, path);
|
return PaletteEditorImGui::make(ctx, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, const ox::String &path) noexcept {
|
ox::Result<PaletteEditorImGui*> PaletteEditorImGui::make(Context *ctx, ox::CRStringView path) noexcept {
|
||||||
auto out = ox::UniquePtr<PaletteEditorImGui>(new PaletteEditorImGui);
|
auto out = ox::UniquePtr<PaletteEditorImGui>(new PaletteEditorImGui);
|
||||||
out->m_ctx = ctx;
|
out->m_ctx = ctx;
|
||||||
out->m_itemPath = path;
|
out->m_itemPath = path;
|
||||||
|
@ -21,7 +21,7 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
PaletteEditorImGui() noexcept = default;
|
PaletteEditorImGui() noexcept = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ox::Result<PaletteEditorImGui*> make(Context *ctx, const ox::String &path) noexcept;
|
static ox::Result<PaletteEditorImGui*> make(Context *ctx, ox::CRStringView path) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of item being edited.
|
* Returns the name of item being edited.
|
||||||
|
@ -38,7 +38,7 @@ ox::Error toPngFile(const ox::String &path, const TileSheet::SubSheet &s, const
|
|||||||
return OxError(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8));
|
return OxError(lodepng_encode_file(path.c_str(), outData.data(), width, height, fmt, 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
TileSheetEditorImGui::TileSheetEditorImGui(Context *ctx, const ox::String &path): m_tileSheetEditor(ctx, path) {
|
TileSheetEditorImGui::TileSheetEditorImGui(Context *ctx, ox::CRStringView path): m_tileSheetEditor(ctx, path) {
|
||||||
m_ctx = ctx;
|
m_ctx = ctx;
|
||||||
m_itemPath = path;
|
m_itemPath = path;
|
||||||
const auto lastSlash = ox::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
const auto lastSlash = ox::find(m_itemPath.rbegin(), m_itemPath.rend(), '/').offset();
|
||||||
|
@ -54,7 +54,7 @@ class TileSheetEditorImGui: public studio::BaseEditor {
|
|||||||
Tool m_tool = Tool::Draw;
|
Tool m_tool = Tool::Draw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditorImGui(Context *ctx, const ox::String &path);
|
TileSheetEditorImGui(Context *ctx, ox::CRStringView path);
|
||||||
|
|
||||||
~TileSheetEditorImGui() override = default;
|
~TileSheetEditorImGui() override = default;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
TileSheetEditorView::TileSheetEditorView(Context *ctx, const ox::String &path): m_model(ctx, path), m_pixelsDrawer(&m_model) {
|
TileSheetEditorView::TileSheetEditorView(Context *ctx, ox::CRStringView path): m_model(ctx, path), m_pixelsDrawer(&m_model) {
|
||||||
// build shaders
|
// build shaders
|
||||||
oxThrowError(m_pixelsDrawer.buildShader());
|
oxThrowError(m_pixelsDrawer.buildShader());
|
||||||
oxThrowError(m_pixelGridDrawer.buildShader());
|
oxThrowError(m_pixelGridDrawer.buildShader());
|
||||||
|
@ -49,7 +49,7 @@ class TileSheetEditorView: public ox::SignalHandler {
|
|||||||
std::size_t m_palIdx = 0;
|
std::size_t m_palIdx = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TileSheetEditorView(Context *ctx, const ox::String &path);
|
TileSheetEditorView(Context *ctx, ox::CRStringView path);
|
||||||
|
|
||||||
~TileSheetEditorView() override = default;
|
~TileSheetEditorView() override = default;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace nostalgia::studio {
|
|||||||
class ItemMaker;
|
class ItemMaker;
|
||||||
|
|
||||||
struct EditorMaker {
|
struct EditorMaker {
|
||||||
using Func = std::function<ox::Result<class BaseEditor*>(const ox::String&)>;
|
using Func = std::function<ox::Result<class BaseEditor*>(ox::CRStringView)>;
|
||||||
ox::Vector<ox::String> fileTypes;
|
ox::Vector<ox::String> fileTypes;
|
||||||
Func make;
|
Func make;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user