[nostalgia,studio] Add ability to navigate from tile sheet to palette color
All checks were successful
Build / build (push) Successful in 1m52s
All checks were successful
Build / build (push) Successful in 1m52s
This commit is contained in:
parent
a2e41e6527
commit
03d4a5736e
@ -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());
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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() : "";
|
||||
|
@ -18,6 +18,10 @@
|
||||
|
||||
namespace studio {
|
||||
|
||||
ox::Error navigateTo(StudioContext &ctx, ox::StringViewCR filePath, ox::StringViewCR args) noexcept {
|
||||
return ctx.ui.navigateTo(filePath, args);
|
||||
}
|
||||
|
||||
namespace ig {
|
||||
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 {
|
||||
glutils::clearScreen();
|
||||
drawMenu();
|
||||
|
@ -68,6 +68,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
void handleKeyEvent(turbine::Key, bool down) noexcept;
|
||||
|
||||
ox::Error navigateTo(ox::StringViewCR path, ox::StringViewCR navArgs = {}) noexcept;
|
||||
|
||||
[[nodiscard]]
|
||||
constexpr Project *project() noexcept {
|
||||
return m_project.get();
|
||||
|
@ -27,4 +27,6 @@ inline keel::Context &keelCtx(StudioContext &ctx) noexcept {
|
||||
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]]
|
||||
virtual UndoStack *undoStack() noexcept;
|
||||
|
||||
virtual void navigateTo(ox::StringViewCR arg) noexcept;
|
||||
|
||||
void setRequiresConstantRefresh(bool value) noexcept;
|
||||
|
||||
// signals
|
||||
|
@ -106,6 +106,8 @@ UndoStack *BaseEditor::undoStack() noexcept {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BaseEditor::navigateTo(ox::StringViewCR) noexcept {}
|
||||
|
||||
|
||||
Editor::Editor(StudioContext &ctx, ox::StringParam itemPath) noexcept:
|
||||
m_itemPath(std::move(itemPath)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user