|
libscratchcpp
A library for C++ based Scratch project players
|
The IEngine interface provides an API for running Scratch projects. More...
#include <scratchcpp/iengine.h>
Public Member Functions | |
| virtual | ~IEngine () |
| virtual void | clear ()=0 |
| virtual void | compile ()=0 |
| virtual void | start ()=0 |
| virtual void | stop ()=0 |
| virtual Thread * | startScript (Block *topLevelBlock, Target *)=0 |
| virtual void | broadcast (int index, Thread *sender, bool wait)=0 |
| virtual void | broadcastByPtr (Broadcast *broadcast, Thread *sender, bool wait)=0 |
| virtual void | startBackdropScripts (Broadcast *broadcast, Thread *sender, bool wait)=0 |
| virtual void | stopScript (Thread *vm)=0 |
| virtual void | stopTarget (Target *target, Thread *exceptScript)=0 |
| virtual void | initClone (std::shared_ptr< Sprite > clone)=0 |
| virtual void | deinitClone (std::shared_ptr< Sprite > clone)=0 |
| virtual void | stopSounds ()=0 |
| virtual double | globalVolume () const =0 |
| virtual void | setGlobalVolume (double volume)=0 |
| virtual void | updateMonitors ()=0 |
| virtual void | step ()=0 |
| virtual void | run ()=0 |
| virtual void | runEventLoop ()=0 |
| virtual void | stopEventLoop ()=0 |
| virtual sigslot::signal & | aboutToRender ()=0 |
| virtual sigslot::signal< Thread * > & | threadAboutToStop ()=0 |
| virtual sigslot::signal & | stopped ()=0 |
| virtual bool | isRunning () const =0 |
| virtual double | fps () const =0 |
| virtual void | setFps (double fps)=0 |
| virtual bool | turboModeEnabled () const =0 |
| virtual void | setTurboModeEnabled (bool turboMode)=0 |
| virtual bool | keyPressed (const std::string &name) const =0 |
| virtual void | setKeyState (const std::string &name, bool pressed)=0 |
| virtual void | setKeyState (const KeyEvent &event, bool pressed)=0 |
| virtual void | setAnyKeyPressed (bool pressed)=0 |
| virtual void | mouseWheelUp ()=0 |
| virtual void | mouseWheelDown ()=0 |
| virtual double | mouseX () const =0 |
| virtual void | setMouseX (double x)=0 |
| virtual double | mouseY () const =0 |
| virtual void | setMouseY (double y)=0 |
| virtual bool | mousePressed () const =0 |
| virtual void | setMousePressed (bool pressed)=0 |
| virtual void | clickTarget (Target *target)=0 |
| virtual const StringPtr * | answer () const =0 |
| virtual unsigned int | stageWidth () const =0 |
| virtual void | setStageWidth (unsigned int width)=0 |
| virtual unsigned int | stageHeight () const =0 |
| virtual void | setStageHeight (unsigned int height)=0 |
| virtual int | cloneLimit () const =0 |
| virtual void | setCloneLimit (int limit)=0 |
| virtual int | cloneCount () const =0 |
| virtual bool | spriteFencingEnabled () const =0 |
| virtual void | setSpriteFencingEnabled (bool enable)=0 |
| virtual void | requestRedraw ()=0 |
| virtual ITimer * | timer () const =0 |
| virtual void | addCompileFunction (IExtension *extension, const std::string &opcode, BlockComp f)=0 |
| virtual void | addHatPredicateCompileFunction (IExtension *extension, const std::string &opcode, HatPredicateCompileFunc f)=0 |
| virtual void | addMonitorNameFunction (IExtension *extension, const std::string &opcode, MonitorNameFunc f)=0 |
| virtual void | addMonitorChangeFunction (IExtension *extension, const std::string &opcode, MonitorChangeFunc f)=0 |
| virtual void | addHatBlock (IExtension *extension, const std::string &opcode)=0 |
| virtual const std::vector< std::shared_ptr< Broadcast > > & | broadcasts () const =0 |
| virtual void | setBroadcasts (const std::vector< std::shared_ptr< Broadcast > > &broadcasts)=0 |
| virtual std::shared_ptr< Broadcast > | broadcastAt (int index) const =0 |
| virtual std::vector< int > | findBroadcasts (const std::string &broadcastName) const =0 |
| virtual int | findBroadcastById (const std::string &broadcastId) const =0 |
| virtual void | addWhenTouchingObjectScript (Block *hatBlock)=0 |
| virtual void | addGreenFlagScript (Block *hatBlock)=0 |
| virtual void | addBroadcastScript (Block *whenReceivedBlock, Field *field, Broadcast *broadcast)=0 |
| virtual void | addBackdropChangeScript (Block *hatBlock, Field *field)=0 |
| virtual void | addCloneInitScript (Block *hatBlock)=0 |
| virtual void | addKeyPressScript (Block *hatBlock, Field *field)=0 |
| virtual void | addTargetClickScript (Block *hatBlock)=0 |
| virtual void | addWhenGreaterThanScript (Block *hatBlock)=0 |
| virtual const std::vector< std::shared_ptr< Target > > & | targets () const =0 |
| virtual void | setTargets (const std::vector< std::shared_ptr< Target > > &newTargets)=0 |
| virtual Target * | targetAt (int index) const =0 |
| virtual void | getVisibleTargets (std::vector< Target * > &dst) const =0 |
| virtual int | findTarget (const std::string &targetName) const =0 |
| virtual void | moveDrawableToFront (Drawable *drawable)=0 |
| virtual void | moveDrawableToBack (Drawable *drawable)=0 |
| virtual void | moveDrawableForwardLayers (Drawable *drawable, int layers)=0 |
| virtual void | moveDrawableBackwardLayers (Drawable *drawable, int layers)=0 |
| virtual void | moveDrawableBehindOther (Drawable *drawable, Drawable *other)=0 |
| virtual Stage * | stage () const =0 |
| virtual const std::vector< std::shared_ptr< Monitor > > & | monitors () const =0 |
| virtual void | setMonitors (const std::vector< std::shared_ptr< Monitor > > &newMonitors)=0 |
| virtual Monitor * | createVariableMonitor (std::shared_ptr< Variable > var, const std::string &opcode, const std::string &varFieldName)=0 |
| virtual Monitor * | createListMonitor (std::shared_ptr< List > list, const std::string &opcode, const std::string &listFieldName)=0 |
| virtual sigslot::signal< Monitor * > & | monitorAdded ()=0 |
| virtual sigslot::signal< Monitor *, IMonitorHandler * > & | monitorRemoved ()=0 |
| virtual sigslot::signal< const std::string & > & | questionAsked ()=0 |
| virtual sigslot::signal & | questionAborted ()=0 |
| virtual sigslot::signal< const std::string & > & | questionAnswered ()=0 |
| virtual const std::vector< std::string > & | extensions () const =0 |
| virtual void | setExtensions (const std::vector< std::string > &newExtensions)=0 |
| virtual const std::unordered_map< Block *, std::shared_ptr< Script > > & | scripts () const =0 |
| virtual const std::string & | userAgent () const =0 |
| virtual void | setUserAgent (const std::string &agent)=0 |
| virtual const std::unordered_set< std::string > & | unsupportedBlocks () const =0 |
The IEngine interface provides an API for running Scratch projects.
This interface can be used to manipulate loaded Scratch projects.
To load a Scratch project, use the Project class.
|
inlinevirtual |
|
pure virtual |
Emits when rendering should occur.
|
pure virtual |
Registers the backdrop change script.
|
pure virtual |
Registers the broadcast script.
|
pure virtual |
|
pure virtual |
Call this from IExtension::registerBlocks() to add a compile function to a block section.
|
pure virtual |
Registers the "green flag" script.
|
pure virtual |
Call this from IExtension::registerBlocks() to add a hat block to a block section.
|
pure virtual |
Call this from IExtension::registerBlocks() to add a hat block predicate compile function to a block section.
|
pure virtual |
|
pure virtual |
Call this from IExtension::registerBlocks() to add a monitor value change function to a block section.
|
pure virtual |
Call this from IExtension::registerBlocks() to add a monitor name function to a block section.
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
Returns the answer received from the user.
|
pure virtual |
Starts the scripts of the broadcast with the given index.
|
pure virtual |
Returns the broadcast at index.
|
pure virtual |
Starts the scripts of the given broadcast.
|
pure virtual |
Returns the list of broadcasts.
|
pure virtual |
Clears the engine so that it can be used with another project.
|
pure virtual |
Call this when a target is clicked.
|
pure virtual |
Returns the current number of clones.
|
pure virtual |
Returns the maximum number of clones (or -1 if the limit is disabled).
|
pure virtual |
Compiles all scripts to bytecode.
|
pure virtual |
Creates a monitor for the given list if it's missing and returns it.
|
pure virtual |
Creates a monitor for the given variable if it's missing and returns it.
|
pure virtual |
Automatically called from clones that are being deleted.
|
pure virtual |
Returns the list of extension names.
|
pure virtual |
Returns the index of the broadcast with the given ID.
|
pure virtual |
Returns the list of indexes of the broadcasts with the given name (case insensitive).
|
pure virtual |
Returns the index of the target with the given name.
|
pure virtual |
Returns the framerate of the project.
|
pure virtual |
Gets visible targets sorted by layer order and stores them in the given vector.
|
pure virtual |
Returns the global volume of all sounds (in %).
|
pure virtual |
Calls the "when I start as a clone" blocks of the given sprite.
|
pure virtual |
Returns true if the project is currently running.
|
pure virtual |
Returns true if the given key is pressed.
|
pure virtual |
Emits when a monitor is added.
|
pure virtual |
Emits when a monitor is removed.
|
pure virtual |
Returns the list of monitors.
|
pure virtual |
Returns true if mouse is pressed.
|
pure virtual |
Starts "when down arrow key pressed" hats.
|
pure virtual |
Starts "when up arrow key pressed" hats.
|
pure virtual |
Returns the X coordinate of the mouse pointer.
|
pure virtual |
Returns the Y coordinate of the mouse pointer.
|
pure virtual |
Moves the given sprite backward a number of layers.
|
pure virtual |
Moves the given sprite behind some other sprite.
|
pure virtual |
Moves the given sprite forward a number of layers.
|
pure virtual |
Moves the given sprite to the back layer.
|
pure virtual |
Moves the given sprite to the front layer.
|
pure virtual |
Emits when the current question is aborted.
|
pure virtual |
Emits when a question is answered.
|
pure virtual |
Emits when a question is asked, for example using the 'ask and wait' block.
|
pure virtual |
Call this from a block implementation to force a redraw (screen refresh).
|
pure virtual |
Calls and runs "when green flag clicked" blocks.
|
pure virtual |
Runs the event loop. Call start() (from another thread) to start the project.
|
pure virtual |
Returns the map of scripts (each top level block has a Script object).
|
pure virtual |
Sets whether any key is pressed (use this for any key, even for unsupported keys).
|
pure virtual |
Sets the list of broadcasts.
|
pure virtual |
Sets the maximum number of clones (use -1 or any negative number to disable the limit).
|
pure virtual |
Sets the list of extension names.
|
pure virtual |
Sets the framerate of the project.
|
pure virtual |
Sets the global volume of all sounds (in %).
|
pure virtual |
Sets the state of the given key.
|
pure virtual |
Sets the state of the key with the given name.
|
pure virtual |
Sets the list of monitors.
|
pure virtual |
Sets the pressed state of mouse.
|
pure virtual |
Sets the X coordinate of the mouse pointer.
|
pure virtual |
Sets the Y coordinate of the mouse pointer.
|
pure virtual |
Toggles sprite fencing.
|
pure virtual |
Sets the stage height.
|
pure virtual |
Sets the stage width.
|
pure virtual |
Sets the list of targets.
|
pure virtual |
Sets whether turbo mode is enabled.
|
pure virtual |
Sets the user agent of the last person to edit the project.
|
pure virtual |
Returns true if sprite fencing is enabled.
|
pure virtual |
Returns the stage height.
|
pure virtual |
Returns the stage width.
|
pure virtual |
Calls all "when green flag clicked" blocks.
|
pure virtual |
Starts the "when backdrop switches to" scripts for the given backdrop broadcast.
|
pure virtual |
Starts a script with the given top level block as the given Target (a sprite or the stage).
|
pure virtual |
Steps all currently running threads. Use this to implement a custom event loop.
|
pure virtual |
Stops all scripts.
|
pure virtual |
Stops the event loop which is running in another thread.
|
pure virtual |
Emits when the project is stopped by calling stop().
|
pure virtual |
Stops the given script.
|
pure virtual |
Stops all currently playing sounds.
|
pure virtual |
Stops all scripts in the given target.
| [in] | target | The Target to stop. |
| [in] | exceptScript | Sets this parameter to stop all scripts except the given script. |
|
pure virtual |
Returns the target at index.
|
pure virtual |
Returns the list of targets.
|
pure virtual |
Emits when a script is about to stop.
|
pure virtual |
Returns the timer of the project.
|
pure virtual |
Returns true if turbo mode is enabled.
|
pure virtual |
Returns the unsupported block opcodes which were found when compiling.
|
pure virtual |
Updates the values of stage monitors.
|
pure virtual |
Returns the user agent of the last person to edit the project.