| 131 | } |
| 132 | |
| 133 | void SetupEmbeddedScriptPopup::onUpload() { |
| 134 | async::spawn( |
| 135 | geode::utils::file::pick( |
| 136 | file::PickMode::OpenFile, |
| 137 | file::FilePickOptions { |
| 138 | .filters = {{ |
| 139 | .description = "Lua Script Files (*.lua)", |
| 140 | .files = {"*.lua"} |
| 141 | }} |
| 142 | } |
| 143 | ), |
| 144 | |
| 145 | [this](auto result) { |
| 146 | if (!result) { |
| 147 | log::info("Failed to upload file: {}", result.unwrapErr()); |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | auto opt = std::move(result).unwrap(); |
| 152 | if (!opt) return; |
| 153 | |
| 154 | auto res = this->loadCodeFromPath(*opt); |
| 155 | |
| 156 | if (!res) { |
| 157 | globed::alertFormat("Error", "Failed to import the given file: {}", res.unwrapErr()); |
| 158 | } |
| 159 | } |
| 160 | ); |
| 161 | } |
| 162 | |
| 163 | void SetupEmbeddedScriptPopup::onPaste() { |
| 164 | this->loadCodeFromString(geode::utils::clipboard::read()); |
no test coverage detected