Squashed 'deps/nostalgia/' changes from 26fc5565..d0a32e24

d0a32e24 [ox/std] Add Vector::remove
03d4a573 [nostalgia,studio] Add ability to navigate from tile sheet to palette color
a2e41e65 Merge commit '4e94c925686cdda4b1ac777045dd7a17c7dc0329'
40a7caff [ox/std] Make bounds checking its own option enable-able in release builds

git-subtree-dir: deps/nostalgia
git-subtree-split: d0a32e247eb9f5f3847c5d03708b455ee698ea96
This commit is contained in:
2025-02-20 23:38:27 -06:00
parent 4e94c92568
commit 611df32bdb
14 changed files with 89 additions and 12 deletions

View File

@@ -94,6 +94,27 @@ ox::Error PaletteEditorImGui::saveItem() noexcept {
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 {
ImGui::TableNextColumn();
ImGui::Text("%s", txt.c_str());

View File

@@ -45,6 +45,8 @@ class PaletteEditorImGui: public studio::Editor {
protected:
ox::Error saveItem() noexcept final;
void navigateTo(ox::StringViewCR arg) noexcept override;
private:
static void drawColumnLeftAlign(ox::CStringView txt) noexcept;

View File

@@ -565,9 +565,13 @@ void TileSheetEditorImGui::drawPaletteMenu() noexcept {
label.c_str(), rowSelected, ImGuiSelectableFlags_SpanAllColumns)) {
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
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::TableNextColumn();
auto const&name = i < pal.colorNames.size() ? pal.colorNames[i].c_str() : "";