ScummVM API documentation
Stark::Resources::Script Class Reference

#include <script.h>

Inheritance diagram for Stark::Resources::Script:
Stark::Resources::Object

Public Types

enum  SubType { kSubTypeGameEvent = 4, kSubTypePlayerAction = 5, kSubTypeDialog = 6 }
 
enum  ScriptType {
  kScriptTypeOnGameEvent = 0, kScriptTypePassiveDialog = 1, kScriptTypeOnPlayerAction = 2, kScriptType3 = 3,
  kScriptType4 = 4
}
 
enum  GameEvent { kGameEventOnGameLoop = 0, kGameEventOnEnterLocation = 1, kGameEventOnExitLocation = 2 }
 
enum  CallMode {
  kCallModeGameLoop = 1, kCallModeExitLocation = 2, kCallModeEnterLocation = 3, kCallModePlayerAction = 4,
  kCallModeDialogCreateSelections = 5, kCallModeDialogAnswer = 6
}
 
enum  ResumeStatus { kResumeComplete, kResumeAbort, kResumeSuspend }
 

Public Member Functions

 Script (Object *parent, byte subType, uint16 index, const Common::String &name)
 
void readData (Formats::XRCReadStream *stream) override
 
void saveLoad (ResourceSerializer *serializer) override
 
void saveLoadCurrent (ResourceSerializer *serializer) override
 
void onAllLoaded () override
 
void onGameLoop () override
 
void reset ()
 
bool isEnabled ()
 
void enable (bool value)
 
void stop ()
 
bool isOnBegin ()
 
bool isOnEnd ()
 
CommandgetBeginCommand ()
 
void execute (uint32 callMode)
 
void pause (int32 msecs)
 
void suspend (Object *cause)
 
bool isSuspended ()
 
ObjectgetSuspendingResource () const
 
bool shouldExecute (uint32 callMode)
 
void goToNextCommand ()
 
void addReturnObject (Object *object)
 
void setResumeStatus (ResumeStatus status)
 
- Public Member Functions inherited from Stark::Resources::Object
Type getType () const
 
byte getSubType () const
 
uint16 getIndex () const
 
Common::String getIndexAsString () const
 
Common::String getName () const
 
virtual void onPostRead ()
 
virtual void onEnterLocation ()
 
virtual void onEnginePause (bool pause)
 
virtual void onExitLocation ()
 
virtual void onPreDestroy ()
 
template<class T >
T * findParent ()
 
ObjectfindChildWithIndex (Type type, uint16 index, int subType=-1) const
 
ObjectfindChildWithOrder (Type type, uint16 order, int subType=-1) const
 
ObjectfindChildWithName (Type type, const Common::String &name, int subType=-1) const
 
template<class T >
T * findChild (bool mustBeUnique=true) const
 
template<class T >
T * findChildWithSubtype (int subType, bool mustBeUnique=true) const
 
template<class T >
T * findChildWithIndex (uint16 index, int subType=-1) const
 
template<class T >
T * findChildWithOrder (uint16 order, int subType=-1) const
 
template<class T >
T * findChildWithName (const Common::String &name, int subType=-1) const
 
template<class T >
Common::Array< T * > listChildren (int subType=-1) const
 
template<class T >
Common::Array< T * > listChildrenRecursive (int subType=-1)
 
void addChild (Object *child)
 
template<>
Objectcast (Object *resource)
 
template<>
ObjectfindParent ()
 
template<>
Common::Array< Object * > listChildren (int subType) const
 

Static Public Attributes

static const Type::ResourceType TYPE = Type::kScript
 

Protected Member Functions

void print (uint depth) override
 
void printData () override
 
void updateSuspended ()
 
void resumeCallerExecution (Object *callerObject)
 
- Protected Member Functions inherited from Stark::Resources::Object
 Object (Object *parent, byte subType, uint16 index, const Common::String &name)
 
void printWithDepth (uint depth, const Common::String &string) const
 
void printDescription (uint depth) const
 

Protected Attributes

uint32 _scriptType
 
uint32 _runEvent
 
uint32 _minChapter
 
uint32 _maxChapter
 
bool _shouldResetGameSpeed
 
bool _enabled
 
Command_nextCommand
 
int32 _pauseTimeLeft
 
Object_suspendingResource
 
ResumeStatus _resumeStatus
 
Common::Array< Object * > _returnObjects
 
- Protected Attributes inherited from Stark::Resources::Object
Type _type
 
byte _subType
 
uint16 _index
 
Common::String _name
 
Object_parent
 
Common::Array< Object * > _children
 

Additional Inherited Members

- Static Public Member Functions inherited from Stark::Resources::Object
template<class T >
static T * cast (Object *resource)
 

Detailed Description

A script resource

Scripts are made of a collection of Command resources. Commands return the next command to be executed, allowing for branches.

Member Enumeration Documentation

◆ CallMode

Script call modes.

Most script types are only meaningful for a call mode. The shouldExecute method checks the consistency between the script type and the call mode.

Member Function Documentation

◆ readData()

void Stark::Resources::Script::readData ( Formats::XRCReadStream stream)
overridevirtual

Deserialize the resource static data and initial state.

Reimplemented from Stark::Resources::Object.

◆ saveLoad()

void Stark::Resources::Script::saveLoad ( ResourceSerializer serializer)
overridevirtual

Persist / restore the resource state

Reimplemented from Stark::Resources::Object.

◆ saveLoadCurrent()

void Stark::Resources::Script::saveLoadCurrent ( ResourceSerializer serializer)
overridevirtual

Persist / restore the resource state

Called only for active locations

Reimplemented from Stark::Resources::Object.

◆ onAllLoaded()

void Stark::Resources::Script::onAllLoaded ( )
overridevirtual

Called when the resource sub-tree is entirely loaded.

Allows to load data from other nodes.

Reimplemented from Stark::Resources::Object.

◆ onGameLoop()

void Stark::Resources::Script::onGameLoop ( )
overridevirtual

Called once per game loop

Reimplemented from Stark::Resources::Object.

◆ reset()

void Stark::Resources::Script::reset ( )

Reset the script so that it can be executed again from the beginning

◆ isEnabled()

bool Stark::Resources::Script::isEnabled ( )

Is the script enabled?

◆ enable()

void Stark::Resources::Script::enable ( bool  value)

Enable the script

◆ stop()

void Stark::Resources::Script::stop ( )

Disable and reset the script

◆ isOnBegin()

bool Stark::Resources::Script::isOnBegin ( )

Is the script on its Begin command?

◆ isOnEnd()

bool Stark::Resources::Script::isOnEnd ( )

Has the script ended?

◆ getBeginCommand()

Command* Stark::Resources::Script::getBeginCommand ( )

Get the script's startup command

◆ execute()

void Stark::Resources::Script::execute ( uint32  callMode)

Attempt to run the script using the specified call mode

◆ pause()

void Stark::Resources::Script::pause ( int32  msecs)

Pause the script for the specified time

◆ suspend()

void Stark::Resources::Script::suspend ( Object cause)

Suspend the script while the specified resource is running

◆ isSuspended()

bool Stark::Resources::Script::isSuspended ( )

Is the script paused, or waiting for a resource to complete?

◆ getSuspendingResource()

Object* Stark::Resources::Script::getSuspendingResource ( ) const

Get the resource the script is waiting to complete, if any

◆ shouldExecute()

bool Stark::Resources::Script::shouldExecute ( uint32  callMode)

Returns true if the script is enabled and valid for this call mode

◆ goToNextCommand()

void Stark::Resources::Script::goToNextCommand ( )

Step the script to the next command, overriding all checks

◆ addReturnObject()

void Stark::Resources::Script::addReturnObject ( Object object)

Add an object to the return list.

The script will resume execution of this object once it reaches an End opcode

◆ setResumeStatus()

void Stark::Resources::Script::setResumeStatus ( ResumeStatus  status)

Set the outcome of a suspension (completion or abortion)

◆ print()

void Stark::Resources::Script::print ( uint  depth)
overrideprotectedvirtual

Print debug information for the resource

Reimplemented from Stark::Resources::Object.


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