Squashed 'deps/nostalgia/' changes from f847289b..671b8eda
671b8eda [ox/std] Make StringLiteral constructors consteval 952637a1 Merge commit 'cbf4414fcaf00c00a2abf73b5c04a055180ad980' 7569698e [nostalgia,studio] Add FileExts_TileSheet const, and corresponding FilePickerPopup constructor 21713ba9 [ox/std] Fix StringLiteral::operator= to work with DevkitARM 73273b6f [nostalgia/gfx] Add isTileSheet function for checking paths against both file extensions 9f040392 [olympic,nostalgia] Cleanup style f4f7e5d0 Merge commit '9b5f7886cadc5c3dc826d00fa5b2e71696151dfd' c27726a4 Merge commit '6bbcae10cc7b21b73171ec0ff196f4baf6304404' bd24a775 Merge commit '7371df429534f264c179684412f6197f7968ebfa' 4419dff2 Merge commit '7688c05bac8c20bc267cae62ec78d55e5d0c493b' 536999c0 Merge commit '47eee1d56d591e3631d16e95a78ea3629ee312ee' a5535ef5 Merge commit '08236fc790e711afe886b6ef545511d35e4e5c6c' a90380f3 Merge commit 'e90dd887477452922f783535edb3d4c55e9a0d2c' 2000b2de [nostalgia/gfx/studio] Cleanup 7d92400f [nostalgia/gfx/studio] Add type specific navigateTo functions git-subtree-dir: deps/nostalgia git-subtree-split: 671b8edaadefe1872fb8954ad13d221b24f676c0
This commit is contained in:
17
deps/ox/src/ox/std/stringliteral.hpp
vendored
17
deps/ox/src/ox/std/stringliteral.hpp
vendored
@ -16,35 +16,28 @@ namespace ox {
|
|||||||
* StringLiteral is used for functions that want to ensure that they are taking
|
* StringLiteral is used for functions that want to ensure that they are taking
|
||||||
* string literals, and not strings outside of the data section of the program
|
* string literals, and not strings outside of the data section of the program
|
||||||
* that might get deleted.
|
* that might get deleted.
|
||||||
* This type cannot force you to use it correctly, so don't give it something
|
|
||||||
* that is not a literal.
|
|
||||||
* If you do this:
|
|
||||||
* StringLiteral(str.c_str())
|
|
||||||
* the resulting segfault is on you.
|
|
||||||
*/
|
*/
|
||||||
class StringLiteral: public detail::BaseStringView {
|
class StringLiteral: public detail::BaseStringView {
|
||||||
public:
|
public:
|
||||||
constexpr StringLiteral() noexcept = default;
|
consteval StringLiteral() noexcept = default;
|
||||||
|
|
||||||
constexpr StringLiteral(StringLiteral const &sv) noexcept = default;
|
constexpr StringLiteral(StringLiteral const &sv) noexcept = default;
|
||||||
|
|
||||||
constexpr explicit StringLiteral(std::nullptr_t) noexcept {}
|
consteval explicit StringLiteral(std::nullptr_t) noexcept {}
|
||||||
|
|
||||||
constexpr explicit StringLiteral(const char *str, std::size_t len) noexcept: BaseStringView(str, len) {}
|
consteval explicit StringLiteral(char const *str, std::size_t const 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)) {}
|
consteval 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr const char *c_str() const noexcept {
|
constexpr char const *c_str() const noexcept {
|
||||||
return data();
|
return data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -114,10 +114,10 @@ struct InitParams {
|
|||||||
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const ¶ms = {}) noexcept;
|
ox::Result<ox::UPtr<Context>> init(turbine::Context &tctx, InitParams const ¶ms = {}) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
int tileColumns(Context&) noexcept;
|
int tileColumns(Context const&) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
int tileRows(Context&) noexcept;
|
int tileRows(Context const&) noexcept;
|
||||||
|
|
||||||
ox::Error loadBgPalette(
|
ox::Error loadBgPalette(
|
||||||
Context &ctx,
|
Context &ctx,
|
||||||
|
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,11 @@ namespace nostalgia::gfx {
|
|||||||
constexpr auto GbaTileColumns = 32;
|
constexpr auto GbaTileColumns = 32;
|
||||||
constexpr auto GbaTileRows = 32;
|
constexpr auto GbaTileRows = 32;
|
||||||
|
|
||||||
int tileColumns(Context&) noexcept {
|
int tileColumns(Context const&) noexcept {
|
||||||
return GbaTileColumns;
|
return GbaTileColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tileRows(Context&) noexcept {
|
int tileRows(Context const&) noexcept {
|
||||||
return GbaTileRows;
|
return GbaTileRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
class NewProject: public studio::Popup {
|
class NewProject: public Popup {
|
||||||
public:
|
public:
|
||||||
enum class Stage {
|
enum class Stage {
|
||||||
Closed,
|
Closed,
|
||||||
|
@ -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;
|
||||||
|
@ -28,7 +28,7 @@ struct Selection {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) {
|
constexpr auto iterateSelection(Selection const &sel, auto const &cb) {
|
||||||
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
||||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||||
@ -44,7 +44,7 @@ constexpr auto iterateSelection(studio::Selection const&sel, auto const&cb) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr auto iterateSelectionRows(studio::Selection const&sel, auto const&cb) {
|
constexpr auto iterateSelectionRows(Selection const &sel, auto const &cb) {
|
||||||
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
constexpr auto retErr = ox::is_same_v<decltype(cb(0, 0)), ox::Error>;
|
||||||
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
for (auto y = sel.a.y; y <= sel.b.y; ++y) {
|
||||||
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
for (auto x = sel.a.x; x <= sel.b.x; ++x) {
|
||||||
|
@ -12,7 +12,7 @@ namespace studio {
|
|||||||
|
|
||||||
class NoChangesException: public ox::Exception {
|
class NoChangesException: public ox::Exception {
|
||||||
public:
|
public:
|
||||||
inline NoChangesException(std::source_location sloc = std::source_location::current()):
|
explicit NoChangesException(std::source_location sloc = std::source_location::current()):
|
||||||
ox::Exception(1, "Command makes no changes.", sloc) {}
|
ox::Exception(1, "Command makes no changes.", sloc) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
void Popup::drawWindow(turbine::Context &ctx, bool &open, std::function<void()> const &drawContents) {
|
void Popup::drawWindow(turbine::Context &ctx, bool &open, std::function<void()> const &drawContents) {
|
||||||
studio::ig::centerNextWindow(ctx);
|
ig::centerNextWindow(ctx);
|
||||||
ImGui::SetNextWindowSize(static_cast<ImVec2>(m_size));
|
ImGui::SetNextWindowSize(static_cast<ImVec2>(m_size));
|
||||||
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
constexpr auto modalFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
|
||||||
if (ImGui::BeginPopupModal(m_title.c_str(), &open, modalFlags)) {
|
if (ImGui::BeginPopupModal(m_title.c_str(), &open, modalFlags)) {
|
||||||
|
@ -28,7 +28,7 @@ class ClipboardObject: public BaseClipboardObject {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ox::String getClipboardText(Context &ctx) noexcept;
|
ox::String getClipboardText(Context const &ctx) noexcept;
|
||||||
|
|
||||||
void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept;
|
void setClipboardText(Context &ctx, ox::StringViewCR text) noexcept;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
namespace turbine {
|
namespace turbine {
|
||||||
|
|
||||||
ox::String getClipboardText(Context&) noexcept {
|
ox::String getClipboardText(Context const &) noexcept {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace turbine {
|
namespace turbine {
|
||||||
|
|
||||||
ox::String getClipboardText(Context &ctx) noexcept {
|
ox::String getClipboardText(Context const &ctx) noexcept {
|
||||||
return ox::String(glfwGetClipboardString(ctx.window));
|
return ox::String(glfwGetClipboardString(ctx.window));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user