Skip to content

Commit

Permalink
Allow opening pad folders from project system
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaMKW committed Oct 2, 2024
1 parent 3730cc2 commit 059915c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/gui/project/window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace Toolbox::UI {
bool is_selected);

bool actionOpenScene(const ModelIndex &index);
bool actionOpenPad(const ModelIndex &index);

bool isPathForScene(const ModelIndex &index) const;

Expand Down
32 changes: 32 additions & 0 deletions src/gui/project/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,10 @@ namespace Toolbox::UI {

void ProjectViewWindow::actionOpenIndexes(const std::vector<ModelIndex> &indices) {
for (auto &item_index : indices) {
if (actionOpenPad(item_index)) {
continue;
}

if (actionOpenScene(item_index)) {
continue;
}
Expand Down Expand Up @@ -536,6 +540,34 @@ namespace Toolbox::UI {
}
}

bool ProjectViewWindow::actionOpenPad(const ModelIndex &index) {
if (!m_file_system_model->isDirectory(index)) {
return false;
}

GUIApplication &app = GUIApplication::instance();

// ./scene/map/map/pad/
fs_path pad_path = m_file_system_model->getPath(index);
if (pad_path.filename().string() != "pad") {
return false;
}

RefPtr<ImWindow> existing_editor = app.findWindow("Pad Recorder", pad_path.string());
if (existing_editor) {
existing_editor->focus();
return true;
}

RefPtr<SceneWindow> window = app.createWindow<SceneWindow>("Pad Recorder");
if (!window->onLoadData(pad_path)) {
app.removeWindow(window);
return false;
}

return true;
}

bool ProjectViewWindow::isPathForScene(const ModelIndex &index) const {
if (!m_file_system_model->validateIndex(index)) {
return false;
Expand Down

0 comments on commit 059915c

Please sign in to comment.