libscratchcpp
A library for C++ based Scratch project players
Loading...
Searching...
No Matches
libscratchcpp::Project Class Reference

The Project class provides API for reading and running Scratch projects. More...

#include <scratchcpp/project.h>

Public Member Functions

 Project ()
 
 Project (const std::string &fileName)
 
 Project (const Project &)=delete
 
bool load ()
 
void stopLoading ()
 
void start ()
 
void run ()
 
void runEventLoop ()
 
const std::string & fileName () const
 
void setFileName (const std::string &newFileName)
 
std::shared_ptr< IEngineengine () const
 
sigslot::signal< unsigned int, unsigned int > & downloadProgressChanged ()
 

Detailed Description

The Project class provides API for reading and running Scratch projects.

Note
Loading online projects is supported if the LIBSCRATCHCPP_NETWORK_SUPPORT option is set, just use setFileName("some URL")

Constructor & Destructor Documentation

◆ Project() [1/3]

Project::Project ( )

Constructs Project without a file name. Use setFileName() to set a file name.

◆ Project() [2/3]

Project::Project ( const std::string & fileName)

Constructs ScratchProject with the given file name.

◆ Project() [3/3]

libscratchcpp::Project::Project ( const Project & )
delete

Member Function Documentation

◆ downloadProgressChanged()

sigslot::signal< unsigned int, unsigned int > & Project::downloadProgressChanged ( )

Emits when the asset download progress changes.

Note
The first parameter is the number of downloaded assets and the latter is the number of all assets to download.

◆ engine()

std::shared_ptr< IEngine > Project::engine ( ) const

Returns the engine of the loaded project.

See also
IEngine

◆ fileName()

const std::string & Project::fileName ( ) const

Returns the project file name or URL.

◆ load()

bool Project::load ( )

Loads the project. Returns true if successful.

◆ run()

void Project::run ( )

Calls and runs "when green flag clicked" blocks.

Note
This function returns when all scripts finish.
If you need an event loop that runs even after the project stops, use runEventLoop().

◆ runEventLoop()

void Project::runEventLoop ( )

Runs the event loop. Call start() (from another thread) to start the project.

Note
This should be called from another thread in GUI project players to keep the UI responsive.

◆ setFileName()

void Project::setFileName ( const std::string & newFileName)

Sets the project file name or URL.

◆ start()

void Project::start ( )

Calls all "when green flag clicked" blocks.

Note
Nothing will happen until run() or frame() is called.

◆ stopLoading()

void Project::stopLoading ( )

Cancels project loading if loading in another thread.


The documentation for this class was generated from the following files: