Compare commits
13 Commits
9f040392c7
...
952637a1ea
| Author | SHA1 | Date | |
|---|---|---|---|
| 952637a1ea | |||
| 7569698e95 | |||
| 21713ba945 | |||
| 73273b6fa7 | |||
| f4f7e5d053 | |||
| c27726a4a9 | |||
| bd24a775b2 | |||
| 4419dff299 | |||
| 536999c070 | |||
| a5535ef59a | |||
| a90380f377 | |||
| 2000b2deee | |||
| 7d92400f6d |
14
deps/ox/src/ox/std/stringliteral.hpp
vendored
14
deps/ox/src/ox/std/stringliteral.hpp
vendored
@@ -20,26 +20,24 @@ namespace ox {
|
|||||||
* that is not a literal.
|
* that is not a literal.
|
||||||
* If you do this:
|
* If you do this:
|
||||||
* StringLiteral(str.c_str())
|
* StringLiteral(str.c_str())
|
||||||
* the resulting segfault is on you.
|
* the resulting segfault is on you.
|
||||||
*/
|
*/
|
||||||
class StringLiteral: public detail::BaseStringView {
|
class StringLiteral: public detail::BaseStringView {
|
||||||
public:
|
public:
|
||||||
constexpr StringLiteral() noexcept = default;
|
constexpr StringLiteral() noexcept = default;
|
||||||
|
|
||||||
constexpr StringLiteral(StringLiteral const&sv) noexcept = default;
|
constexpr StringLiteral(StringLiteral const &sv) noexcept = default;
|
||||||
|
|
||||||
constexpr explicit StringLiteral(std::nullptr_t) noexcept {}
|
constexpr explicit StringLiteral(std::nullptr_t) noexcept {}
|
||||||
|
|
||||||
constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {}
|
constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView{str, len} {}
|
||||||
|
|
||||||
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
OX_ALLOW_UNSAFE_BUFFERS_BEGIN
|
||||||
constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral(str, ox::strlen(str)) {}
|
constexpr explicit StringLiteral(char const *str) noexcept: StringLiteral{str, ox::strlen(str)} {}
|
||||||
OX_ALLOW_UNSAFE_BUFFERS_END
|
OX_ALLOW_UNSAFE_BUFFERS_END
|
||||||
|
|
||||||
constexpr StringLiteral &operator=(StringLiteral const&other) noexcept {
|
constexpr StringLiteral &operator=(StringLiteral const &other) noexcept {
|
||||||
if (&other != this) {
|
set(other.data(), other.len());
|
||||||
set(other.data(), other.len());
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,18 @@ constexpr auto TileWidth = 8;
|
|||||||
constexpr auto TileHeight = 8;
|
constexpr auto TileHeight = 8;
|
||||||
constexpr auto PixelsPerTile = TileWidth * TileHeight;
|
constexpr auto PixelsPerTile = TileWidth * TileHeight;
|
||||||
|
|
||||||
constexpr ox::StringLiteral FileExt_ng("ng");
|
constexpr ox::StringLiteral FileExt_ng{"ng"};
|
||||||
constexpr ox::StringLiteral FileExt_nts("nts");
|
constexpr ox::StringLiteral FileExt_nts{"nts"};
|
||||||
constexpr ox::StringLiteral FileExt_npal("npal");
|
constexpr ox::StringLiteral FileExt_npal{"npal"};
|
||||||
|
|
||||||
|
constexpr ox::Array<ox::StringLiteral, 2> FileExts_TileSheet{
|
||||||
|
FileExt_nts,
|
||||||
|
FileExt_ng,
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
constexpr bool isTileSheet(ox::StringViewCR path) noexcept {
|
||||||
|
return endsWith(path, FileExt_nts) || endsWith(path, FileExt_ng);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,28 @@
|
|||||||
|
|
||||||
#include <studio/studio.hpp>
|
#include <studio/studio.hpp>
|
||||||
|
|
||||||
namespace nostalgia::core {
|
#include "tilesheet.hpp"
|
||||||
|
|
||||||
|
namespace nostalgia::gfx {
|
||||||
|
|
||||||
|
inline void navigateToTileSheet(
|
||||||
|
studio::Context &ctx, ox::StringParam path, SubSheetId const subsheetId) noexcept {
|
||||||
|
studio::navigateTo(ctx, std::move(path), ox::intToStr(subsheetId));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void navigateToPalette(studio::Context &ctx, ox::StringParam path) noexcept {
|
||||||
|
studio::navigateTo(ctx, std::move(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void navigateToPalette(
|
||||||
|
studio::Context &ctx,
|
||||||
|
ox::StringParam path,
|
||||||
|
size_t const colorIdx,
|
||||||
|
size_t const palPage) noexcept {
|
||||||
|
studio::navigateTo(
|
||||||
|
ctx,
|
||||||
|
std::move(path),
|
||||||
|
ox::sfmt("{};{}", colorIdx, palPage));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#include <keel/media.hpp>
|
#include <keel/media.hpp>
|
||||||
#include <studio/studio.hpp>
|
#include <studio/studio.hpp>
|
||||||
|
|
||||||
|
#include <nostalgia/gfx/studio.hpp>
|
||||||
|
|
||||||
#include "tilesheeteditor-imgui.hpp"
|
#include "tilesheeteditor-imgui.hpp"
|
||||||
|
|
||||||
namespace nostalgia::gfx {
|
namespace nostalgia::gfx {
|
||||||
@@ -576,10 +578,10 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
|
|||||||
m_view.setPalIdx(i);
|
m_view.setPalIdx(i);
|
||||||
}
|
}
|
||||||
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||||
studio::navigateTo(
|
navigateToPalette(
|
||||||
m_sctx,
|
m_sctx,
|
||||||
m_model.palPath(),
|
m_model.palPath(),
|
||||||
ox::sfmt("{};{}", i, m_model.palettePage()));
|
i, m_model.palettePage());
|
||||||
}
|
}
|
||||||
// Column: color RGB
|
// Column: color RGB
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ class FilePickerPopup {
|
|||||||
public:
|
public:
|
||||||
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::StringParam fileExt) noexcept;
|
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::StringParam fileExt) noexcept;
|
||||||
|
|
||||||
|
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::SpanView<ox::StringLiteral> fileExts) noexcept;
|
||||||
|
|
||||||
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::Vector<ox::String> fileExts) noexcept;
|
explicit FilePickerPopup(ox::StringParam name, keel::Context &kctx, ox::Vector<ox::String> fileExts) noexcept;
|
||||||
|
|
||||||
void refresh() noexcept;
|
void refresh() noexcept;
|
||||||
|
|||||||
@@ -26,6 +26,22 @@ FilePickerPopup::FilePickerPopup(
|
|||||||
m_fileExts{std::move(fileExt)} {
|
m_fileExts{std::move(fileExt)} {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilePickerPopup::FilePickerPopup(
|
||||||
|
ox::StringParam name,
|
||||||
|
keel::Context &kctx,
|
||||||
|
ox::SpanView<ox::StringLiteral> fileExts) noexcept:
|
||||||
|
m_name{std::move(name)},
|
||||||
|
m_explorer{kctx},
|
||||||
|
m_fileExts{[fileExts] {
|
||||||
|
ox::Vector<ox::String> out;
|
||||||
|
out.reserve(fileExts.size());
|
||||||
|
for (auto &s : fileExts) {
|
||||||
|
out.emplace_back(s);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}()} {
|
||||||
|
}
|
||||||
|
|
||||||
FilePickerPopup::FilePickerPopup(
|
FilePickerPopup::FilePickerPopup(
|
||||||
ox::StringParam name,
|
ox::StringParam name,
|
||||||
keel::Context &kctx,
|
keel::Context &kctx,
|
||||||
|
|||||||
Reference in New Issue
Block a user