| 51 | inject<ScriptObject> m_command{"command"}; |
| 52 | |
| 53 | AppScriptObject() { |
| 54 | addProperty("activeFrameNumber", [this]{return updateSite() ? m_site.frame() : 0;}) |
| 55 | .doc("read-only. Returns the number of the currently active animation frame."); |
| 56 | |
| 57 | addProperty("activeLayerNumber", [this]{return updateSite() ? m_site.layerIndex() : 0;}) |
| 58 | .doc("read-only. Returns the number of the current layer."); |
| 59 | |
| 60 | addProperty("activeImage", [this]{ |
| 61 | return getEngine()->getScriptObject(app::current_editor ? app::current_editor->getSite().image() : nullptr); |
| 62 | }).doc("read-only, can be null. Returns the current layer/frame's image."); |
| 63 | |
| 64 | addProperty("activeSprite", [this]{ |
| 65 | return getEngine()->getScriptObject(app::current_editor ? app::current_editor->getSite().sprite() : nullptr); |
| 66 | }).doc("read-only. Returns the currently active Sprite."); |
| 67 | |
| 68 | addProperty("activeDocument", [this]{ |
| 69 | return getEngine()->getScriptObject(app::current_editor ? app::current_editor->getSite().document() : nullptr); |
| 70 | }).doc("read-only. Returns the currently active Document."); |
| 71 | |
| 72 | addProperty("pixelColor", [this]{return m_pixelColor.get();}) |
| 73 | .doc("read-only. Returns an object with functions for color conversion."); |
| 74 | |
| 75 | addProperty("command", [this]{return m_command.get();}) |
| 76 | .doc("read-only. Returns an object with functions for running commands."); |
| 77 | |
| 78 | addProperty("version", []{return script::Value{VERSION};}) |
| 79 | .doc("read-only. Returns LibreSprite's current version as a string."); |
| 80 | |
| 81 | addProperty("platform", []() -> std::string { |
| 82 | #ifdef EMSCRIPTEN |
| 83 | return "emscripten"; |
| 84 | #elif _WIN32 |
| 85 | return "windows"; |
| 86 | #elif __APPLE__ |
| 87 | return "macos"; |
| 88 | #elif ANDROID |
| 89 | return "android"; |
| 90 | #else |
| 91 | return "linux"; |
| 92 | #endif |
| 93 | }).doc("read-only. Returns one of: emscripten, windows, macos, android, linux."); |
| 94 | |
| 95 | addMethod("documentation", &AppScriptObject::documentation) |
| 96 | .doc("Prints this text."); |
| 97 | |
| 98 | addMethod("createDialog", &AppScriptObject::createDialog) |
| 99 | .doc("Creates a dialog window"); |
| 100 | |
| 101 | addMethod("yield", &AppScriptObject::yield) |
| 102 | .doc("Schedules a yield event on the next frame") |
| 103 | .docArg("event", "Name of the event to be raised. The default is yield."); |
| 104 | |
| 105 | addMethod("open", &AppScriptObject::open) |
| 106 | .doc("Opens a document for editing"); |
| 107 | |
| 108 | addMethod("launch", &AppScriptObject::launch); |
| 109 | |
| 110 | addMethod("redraw", &AppScriptObject::redraw); |
nothing calls this directly
no test coverage detected