MCPcopy Create free account
hub / github.com/GlobedGD/globed2 / onUpload

Method onUpload

src/modules/scripting-ui/ui/SetupEmbeddedScriptPopup.cpp:133–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133void 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
163void SetupEmbeddedScriptPopup::onPaste() {
164 this->loadCodeFromString(geode::utils::clipboard::read());

Callers 1

initMethod · 0.95

Calls 2

loadCodeFromPathMethod · 0.95
alertFormatFunction · 0.85

Tested by

no test coverage detected