MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / open_world_file

Method open_world_file

src/Toolbar.cpp:1265–1299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1263}
1264
1265void Toolbar::open_world_file(bool isClient, const std::string& netSource, const std::string& serverLocalID2) {
1266#ifdef __EMSCRIPTEN__
1267 static struct UploadData {
1268 bool iC;
1269 std::string nS;
1270 std::string sLID;
1271 MainProgram* main;
1272 } uploadData;
1273 uploadData.iC = isClient;
1274 uploadData.nS = netSource;
1275 uploadData.sLID = serverLocalID2;
1276 uploadData.main = &main;
1277 emscripten_browser_file::upload("." + World::FILE_EXTENSION, [](std::string const& fileName, std::string const& mimeType, std::string_view buffer, void* callbackData) {
1278 if(!buffer.empty()) {
1279 UploadData* uD = (UploadData*)callbackData;
1280 CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
1281 .isClient = uD->iC,
1282 .filePathSource = std::filesystem::path(fileName),
1283 .netSource = uD->nS,
1284 .serverLocalID = uD->sLID,
1285 .fileDataBuffer = std::string(buffer)
1286 });
1287 }
1288 }, &uploadData);
1289#else
1290 open_file_selector("Open", {{"InfiniPaint Canvas", World::FILE_EXTENSION}, {"Any File", "*"}}, [&, isClient = isClient, netSource = netSource, serverLocalID2 = serverLocalID2](const std::filesystem::path& p, const auto& e) {
1291 CustomEvents::emit_event<CustomEvents::OpenInfiniPaintFileEvent>({
1292 .isClient = isClient,
1293 .filePathSource = p,
1294 .netSource = netSource,
1295 .serverLocalID = serverLocalID2
1296 });
1297 });
1298#endif
1299}
1300
1301void Toolbar::center_obstructing_window_gui(const char* id, Clay_SizingAxis x, Clay_SizingAxis y, const std::function<void()>& innerContent) {
1302 auto& gui = main.g.gui;

Callers

nothing calls this directly

Calls 2

uploadFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected