diff --git a/src/Screens/FileSelectScreen.cpp b/src/Screens/FileSelectScreen.cpp index fc180ff..6938054 100644 --- a/src/Screens/FileSelectScreen.cpp +++ b/src/Screens/FileSelectScreen.cpp @@ -9,6 +9,7 @@ #include "../GUIStuff/Elements/LayoutElement.hpp" #include "../World.hpp" #include "Helpers/StringHelpers.hpp" +#include "DrawingProgramScreen.hpp" #include #define MAIN_MENU_SIZE 300 @@ -139,8 +140,13 @@ void FileSelectScreen::file_view() { .entryHeight = 200.0f, .entryCount = fileList.size(), .elementContent = [&](size_t i) { + std::filesystem::path filePath = main.conf.configPath / folder / (fileList[i].fileName + ".infpnt"); gui.element("file button", SelectableButton::Data{ - .onClick = [&] { + .onClick = [&, filePath] { + CustomEvents::emit_event({ + .isClient = false, + .filePathSource = filePath + }); }, .innerContent = [&](const SelectableButton::InnerContentCallbackParameters& c){ CLAY_AUTO_ID({ @@ -234,6 +240,11 @@ const std::vector& FileSelectScreen::get_file_list(c return fileListOptional.value(); } +void FileSelectScreen::input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) { + main.create_new_tab(openFile); + main.screen = std::make_unique(main); +} + void FileSelectScreen::draw(SkCanvas* canvas) { canvas->clear(main.g.gui.io.theme->backColor1); } diff --git a/src/Screens/FileSelectScreen.hpp b/src/Screens/FileSelectScreen.hpp index 5fbb029..0dfd56c 100644 --- a/src/Screens/FileSelectScreen.hpp +++ b/src/Screens/FileSelectScreen.hpp @@ -6,6 +6,7 @@ class FileSelectScreen : public Screen { FileSelectScreen(MainProgram& m); virtual void gui_layout_run() override; virtual void draw(SkCanvas* canvas) override; + virtual void input_open_infinipaint_file_callback(const CustomEvents::OpenInfiniPaintFileEvent& openFile) override; private: struct FileInfo { std::string fileName;