Compare commits
3 Commits
26fc5565e8
...
03d4a5736e
Author | SHA1 | Date | |
---|---|---|---|
03d4a5736e | |||
a2e41e6527 | |||
40a7caff90 |
4
deps/ox/src/ox/std/array.hpp
vendored
4
deps/ox/src/ox/std/array.hpp
vendored
@ -181,13 +181,13 @@ constexpr Array<T, ArraySize> &Array<T, ArraySize>::operator=(Array &&other) noe
|
|||||||
|
|
||||||
template<typename T, std::size_t ArraySize>
|
template<typename T, std::size_t ArraySize>
|
||||||
constexpr T &Array<T, ArraySize>::operator[](std::size_t i) noexcept {
|
constexpr T &Array<T, ArraySize>::operator[](std::size_t i) noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Array access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Array access overflow");
|
||||||
return m_items[i];
|
return m_items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t ArraySize>
|
template<typename T, std::size_t ArraySize>
|
||||||
constexpr const T &Array<T, ArraySize>::operator[](std::size_t i) const noexcept {
|
constexpr const T &Array<T, ArraySize>::operator[](std::size_t i) const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Array access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Array access overflow");
|
||||||
return m_items[i];
|
return m_items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
deps/ox/src/ox/std/defines.hpp
vendored
6
deps/ox/src/ox/std/defines.hpp
vendored
@ -41,6 +41,12 @@ constexpr auto Debug = true;
|
|||||||
constexpr auto Debug = false;
|
constexpr auto Debug = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(OX_CHECK_BOUNDS)
|
||||||
|
constexpr auto CheckBounds = true;
|
||||||
|
#else
|
||||||
|
constexpr auto CheckBounds = Debug;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(NDEBUG)
|
#if defined(NDEBUG)
|
||||||
constexpr auto NDebug = true;
|
constexpr auto NDebug = true;
|
||||||
#else
|
#else
|
||||||
|
13
deps/ox/src/ox/std/error.hpp
vendored
13
deps/ox/src/ox/std/error.hpp
vendored
@ -330,4 +330,17 @@ constexpr void primitiveAssert(char const*file, int line, bool pass, char const*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr void boundsCheck(
|
||||||
|
char const*file,
|
||||||
|
int const line,
|
||||||
|
size_t const i,
|
||||||
|
size_t const sz,
|
||||||
|
char const*msg) noexcept {
|
||||||
|
if constexpr(defines::CheckBounds) {
|
||||||
|
if (i >= sz) [[unlikely]] {
|
||||||
|
panic(file, line, msg, ox::Error{1});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
6
deps/ox/src/ox/std/iterator.hpp
vendored
6
deps/ox/src/ox/std/iterator.hpp
vendored
@ -133,17 +133,17 @@ struct SpanIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr PtrType operator->() const noexcept {
|
constexpr PtrType operator->() const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
|
boundsCheck(__FILE__, __LINE__, m_offset, m_max, "SpanIterator access overflow");
|
||||||
return &m_t[m_offset];
|
return &m_t[m_offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr RefType operator*() const noexcept {
|
constexpr RefType operator*() const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
|
boundsCheck(__FILE__, __LINE__, m_offset, m_max, "SpanIterator access overflow");
|
||||||
return m_t[m_offset];
|
return m_t[m_offset];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr RefType operator[](std::size_t s) const noexcept {
|
constexpr RefType operator[](std::size_t s) const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, s < m_max, "SpanIterator access overflow");
|
boundsCheck(__FILE__, __LINE__, s, m_max, "SpanIterator access overflow");
|
||||||
return m_t[s];
|
return m_t[s];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
deps/ox/src/ox/std/span.hpp
vendored
8
deps/ox/src/ox/std/span.hpp
vendored
@ -129,22 +129,22 @@ class Span {
|
|||||||
}
|
}
|
||||||
|
|
||||||
constexpr T &operator[](std::size_t i) noexcept {
|
constexpr T &operator[](std::size_t i) noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||||
return m_items[i];
|
return m_items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr T const&operator[](std::size_t i) const noexcept {
|
constexpr T const&operator[](std::size_t i) const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||||
return m_items[i];
|
return m_items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Span operator+(size_t i) const noexcept {
|
constexpr Span operator+(size_t i) const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||||
return {m_items + i, m_size - i};
|
return {m_items + i, m_size - i};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr Span operator+=(size_t i) noexcept {
|
constexpr Span operator+=(size_t i) noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Span access overflow");
|
||||||
m_items += i;
|
m_items += i;
|
||||||
m_size -= i;
|
m_size -= i;
|
||||||
return *this;
|
return *this;
|
||||||
|
4
deps/ox/src/ox/std/vector.hpp
vendored
4
deps/ox/src/ox/std/vector.hpp
vendored
@ -427,13 +427,13 @@ constexpr Vector<T, SmallVectorSize, Allocator> &Vector<T, SmallVectorSize, Allo
|
|||||||
|
|
||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) noexcept {
|
constexpr T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Vector access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Vector access overflow");
|
||||||
return m_items[i];
|
return m_items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
template<typename T, std::size_t SmallVectorSize, typename Allocator>
|
||||||
constexpr const T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) const noexcept {
|
constexpr const T &Vector<T, SmallVectorSize, Allocator>::operator[](std::size_t i) const noexcept {
|
||||||
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Vector access overflow");
|
boundsCheck(__FILE__, __LINE__, i, size(), "Vector access overflow");
|
||||||
return m_items[i];
|
return m_items[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,27 @@ ox::Error PaletteEditorImGui::saveItem() noexcept {
|
|||||||
return m_sctx.project->writeObj(itemPath(), m_pal, ox::ClawFormat::Organic);
|
return m_sctx.project->writeObj(itemPath(), m_pal, ox::ClawFormat::Organic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaletteEditorImGui::navigateTo(ox::StringViewCR arg) noexcept {
|
||||||
|
auto const args = ox::split<2>(arg, ';');
|
||||||
|
if (args.size() < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto const &color = args[0];
|
||||||
|
auto const &page = args[1];
|
||||||
|
{
|
||||||
|
auto const [c, err] = atoi(color);
|
||||||
|
if (!err && static_cast<size_t>(c) < colorCnt(m_pal)) {
|
||||||
|
m_selectedColorRow = static_cast<size_t>(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto const [pg, err] = atoi(page);
|
||||||
|
if (!err && static_cast<size_t>(pg) < m_pal.pages.size()) {
|
||||||
|
m_page = static_cast<size_t>(pg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PaletteEditorImGui::drawColumnLeftAlign(ox::CStringView txt) noexcept {
|
void PaletteEditorImGui::drawColumnLeftAlign(ox::CStringView txt) noexcept {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%s", txt.c_str());
|
ImGui::Text("%s", txt.c_str());
|
||||||
|
@ -45,6 +45,8 @@ class PaletteEditorImGui: public studio::Editor {
|
|||||||
protected:
|
protected:
|
||||||
ox::Error saveItem() noexcept final;
|
ox::Error saveItem() noexcept final;
|
||||||
|
|
||||||
|
void navigateTo(ox::StringViewCR arg) noexcept override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void drawColumnLeftAlign(ox::CStringView txt) noexcept;
|
static void drawColumnLeftAlign(ox::CStringView txt) noexcept;
|
||||||
|
|
||||||
|
@ -565,9 +565,13 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
|
|||||||
label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
|
label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
|
||||||
m_view.setPalIdx(i);
|
m_view.setPalIdx(i);
|
||||||
}
|
}
|
||||||
|
if (ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)) {
|
||||||
|
auto const rqst = ox::sfmt<ox::BasicString<100>>("{};{}", i, m_model.palettePage());
|
||||||
|
oxLogError(studio::navigateTo(m_sctx, m_model.palPath(), rqst));
|
||||||
|
}
|
||||||
// Column: color RGB
|
// Column: color RGB
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
auto ic = ImGui::GetColorU32(ImVec4(redf(c), greenf(c), bluef(c), 1));
|
auto const ic = ImGui::GetColorU32({redf(c), greenf(c), bluef(c), 1});
|
||||||
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic);
|
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, ic);
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
auto const&name = i < pal.colorNames.size() ? pal.colorNames[i].c_str() : "";
|
auto const&name = i < pal.colorNames.size() ? pal.colorNames[i].c_str() : "";
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
|
|
||||||
namespace studio {
|
namespace studio {
|
||||||
|
|
||||||
|
ox::Error navigateTo(StudioContext &ctx, ox::StringViewCR filePath, ox::StringViewCR args) noexcept {
|
||||||
|
return ctx.ui.navigateTo(filePath, args);
|
||||||
|
}
|
||||||
|
|
||||||
namespace ig {
|
namespace ig {
|
||||||
extern bool s_mainWinHasFocus;
|
extern bool s_mainWinHasFocus;
|
||||||
}
|
}
|
||||||
@ -107,6 +111,12 @@ void StudioUI::handleKeyEvent(turbine::Key const key, bool const down) noexcept
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ox::Error StudioUI::navigateTo(ox::StringViewCR path, ox::StringViewCR navArgs) noexcept {
|
||||||
|
OX_RETURN_ERROR(openFile(path));
|
||||||
|
m_activeEditor->navigateTo(navArgs);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
void StudioUI::draw() noexcept {
|
void StudioUI::draw() noexcept {
|
||||||
glutils::clearScreen();
|
glutils::clearScreen();
|
||||||
drawMenu();
|
drawMenu();
|
||||||
|
@ -68,6 +68,8 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
|
|
||||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||||
|
|
||||||
|
ox::Error navigateTo(ox::StringViewCR path, ox::StringViewCR navArgs = {}) noexcept;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
constexpr Project *project() noexcept {
|
constexpr Project *project() noexcept {
|
||||||
return m_project.get();
|
return m_project.get();
|
||||||
|
@ -27,4 +27,6 @@ inline keel::Context &keelCtx(StudioContext &ctx) noexcept {
|
|||||||
return keelCtx(ctx.tctx);
|
return keelCtx(ctx.tctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ox::Error navigateTo(StudioContext &ctx, ox::StringViewCR filePath, ox::StringViewCR args) noexcept;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,8 @@ class BaseEditor: public Widget {
|
|||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
virtual UndoStack *undoStack() noexcept;
|
virtual UndoStack *undoStack() noexcept;
|
||||||
|
|
||||||
|
virtual void navigateTo(ox::StringViewCR arg) noexcept;
|
||||||
|
|
||||||
void setRequiresConstantRefresh(bool value) noexcept;
|
void setRequiresConstantRefresh(bool value) noexcept;
|
||||||
|
|
||||||
// signals
|
// signals
|
||||||
|
@ -106,6 +106,8 @@ UndoStack *BaseEditor::undoStack() noexcept {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseEditor::navigateTo(ox::StringViewCR) noexcept {}
|
||||||
|
|
||||||
|
|
||||||
Editor::Editor(StudioContext &ctx, ox::StringParam itemPath) noexcept:
|
Editor::Editor(StudioContext &ctx, ox::StringParam itemPath) noexcept:
|
||||||
m_itemPath(std::move(itemPath)),
|
m_itemPath(std::move(itemPath)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user