AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzActions.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CZ_ACTIONS_H_)
00015 #define _CZ_ACTIONS_H_
00016 
00017 #include "CzUtil.h"
00018 #include "CzXoml.h"
00019 #include "CzXomlVariables.h"
00020 
00021 class CzActions;
00022 
00023 /**
00024  @addtogroup XOML
00025  @{
00026  */
00027  
00028 /**
00029  @struct    CzAction
00030 
00031  @brief An action is a command that can be executed from XOML.
00032 
00033  <h1>Introduction</h1>
00034 
00035  An action consists of a method and a number of parameters (eiter variabls or values) that can be passed to that method. Note that actions will cache any variables that are passed 
00036  as parameters osthey do not have to be constantly searched for in the resuorce manager.
00037 
00038  An action also carries a conditions variable which defines a conditions variable that can be used to conditionally execute the action.
00039 
00040  A game or app would be pretty useless if it did nothing other than just sit and look pretty. Users generally expect lots of interaction with their apps. XOML uses the events and 
00041  actions system to provide such interaction.
00042 
00043  From a XOML point of view an event is something that has happened in the app that some scene or actor needs to know about. For example, when the user taps a button to see help he 
00044  raises the tapped help button event. An action from XOML's point of view is something that is done in response to an event. Continuing on with the same example, an action that could 
00045  be carried out in response to the user pressing the help button is to load and show a help scene.
00046 
00047  Scenes and different types of actors all handle a variety of different events (more on this later). Likewise scenes and different actors can carry our different actions. If we 
00048  look back at our scene and actor property definitions we see many properties with names such as OnCreate, OnDestroy, OnTapped etc.. These properties represent event handlers. 
00049  When we define one of these properties for an object we tell the system that we want to respond to that event occurring by calling an actions list. 
00050 
00051  An actions list is a list of actions that should be carried out in response to an event occurring. Actions lists can be declared globally, local to a scene or even local to an actor.
00052 
00053  The BasicActions example shows an example how to use events with actions. Lets take a look at the XOML for this example to see how it works:
00054 
00055  @code
00056 <!-- Create rotation animation (we will use this to animate angle of the label) -->
00057 <Animation Name="AngleAnim" Duration="4" Type="float">
00058     <Frame Time="0" Value="0" />
00059     <Frame Time="4" Value="360" />
00060 </Animation>
00061     
00062 <!-- Create a timeline that can be used to animate an actor -->
00063 <Timeline Name="Anim1" AutoPlay="false">
00064     <Animation Anim="AngleAnim" Target="Angle" />
00065 </Timeline>
00066 
00067 <!-- Create a scene -->
00068 <Scene Name="Scene1" Current="true" >
00069 
00070     <!-- Create a label with an animation -->
00071     <Label Font="serif" Background="Button1Brush" BackgroundColour="80, 80, 255, 255" Size="100, 100" Text="Animation" OnBeginTouch="Spin" NotifyEnd(Touch="StopSpin" Timeline="Anim1">
00072         <Actions Name="Spin">
00073             <Action Method="PlayTimeline" />
00074         </Actions>
00075         <Actions Name="StopSpin">
00076             <Action Method="PauseTimeline" />
00077         </Actions>
00078     </Label>
00079 
00080 </Scene>
00081  @endcode
00082 
00083  Firstly we create an animation and a timeline that will be used to spin our label. Next we create a label within a scene and assign action lists to the OnBeginTouch and NotifyEnd(Touch 
00084  events. Next, we define two actions list, one called Spin and another called StopSpin. The first action list calls an action called PlayTimeline which tells the actor to start playing 
00085  its current timeline. The second actions list calls an action called PauseTimeline which tells the actor to pause playback of its timeline. The OnBeginTouch event is raised when the 
00086  user starts to press the actor, the NotifyEnd(Touch event is raised when the user stops touching the actor.
00087 
00088  You use the Actions tag to declare a list of actions. Actions can be declared globally so that any scene or actor can call them, local to a scene so that the scene and any actors 
00089  contained with the scene can call them or local to an actor in which case only that actor can call them. Lets take a look at the properties that are supported by an Actions list:
00090  - Name (string) - Name of actions group
00091  - Local (boolean) - When set to false, this actions group will be added to the scenes actions manager instead of the actors actions manager
00092  - Condition (variable) - A condition variable that must evaluate to true for this action list to be executed (this is an optional feature and can be used to conditionally execute 
00093  actions lists based on the state of the app, such as the value of certain variables)
00094  - Tag (string) - Resource tag (used to group resources together)
00095 
00096  An actions list contains a list of action tags. An action tag has the following properties:
00097  - Method (method name) - A method is the actual action that takes places such as PlayTimeline, SetProperty etc..
00098  - Param1 to Param5 - Five parameters that can be passed to the action. with exception to parameters that are passed as optional container scenes. Note that the shorter P1 to P5 
00099  attributes can be substituted for Param1 to Param5. Variables can be passed to any parameter that is not expecting a variable name or optional container scene
00100  - Condition (variable) - A condition variable that must evaluate to true for this action to executed (this is an optional feature and can be used to conditionally execute actions based 
00101  on the state of the app, such as the value of certain variables)
00102 
00103  Method is a required property. In some cases Param1 to Param5 may also be required properties (see individual actions)
00104 
00105  Note that when passing a variable to an actions parameter the variable will be searched for in the container scene (or in many cases the optional container scene that was passed). 
00106  If it is not found there then the global variables space will be searched. If the variable is found then the variables value will be substituted as the parameter. If the variable 
00107  does not exist then XOML assumes that the variable is a value. 
00108 
00109  For clarity the container scene is the scene that contains the actor that called the action, if the action is called from an actor. If the action was called from a scene then that 
00110  scene will be the container scene. 
00111 
00112  XOML has an ever growing list of supported actions that can be called to carry out certain functions. Actions are grouped by purpose into the following groups:
00113  - CzXomlActions_Actor - Actor specific actions
00114  - CzXomlActions_Animation - Animation specific actions
00115  - CzXomlActions_Comms - Communications specific actions
00116  - CzXomlActions_Market - Market specific actions
00117  - CzXomlActions_Media - Media specific actions
00118  - CzXomlActions_Program - XOML Program Removal actions
00119  - CzXomlActions_Resource - Resource specific actions
00120  - CzXomlActions_Scene - Scene specific actions
00121  - CzXomlActions_Script - Script specific actions
00122  - CzXomlActions_Shared - Scene / actor shared actions
00123  - CzXomlActions_Sys - System specific actions
00124  - CzXomlActions_Variable - Variable specific actions
00125 
00126  <h1>Actions Scope<h1>
00127  The scope of an actions list depends on where it was declared. You can declare actions in the following places:
00128  - Inside actor tags - The actions list will be assigned to the actors actions manager and will be local to the actor and timelines that are local to the actor
00129  - Inside scene tags - The actions list will be assigned to the scenes actions manager and will be local to the scene and any actors / timelines within that scene
00130  - Inside timeline tags  - The actions list will be assigned to the actors actions manager if it was declared inside an actor or to the scenes if it was declared inside a scene. if 
00131  declared globally then the actions list will be assigned to the global actions manager and will be available to all scenes and their actors
00132  - Declared globally (outside a scene) - The actions list will be assigned to the global actions manager and will be available to all scenes and actors
00133 
00134  <h1>Creating Actions</h1>
00135 
00136  Below we show 3 different ways of creating actions and assigning them to an actor:
00137 
00138  @par XOML Example:
00139  @code
00140 <!-- Create a label object -->
00141 <Label Font="serif" Background="Button1Brush" BackgroundColour="255, 80, 80, 255" Text="Clipping" WrapPosition="true" OnTick="Update">
00142     <Actions Name="Update">
00143         <Action Method="AddProperty" Param1="Position" Param2="2, 2" />
00144     </Actions>
00145 </Label>
00146  @endcode
00147 
00148  @par Code Example:
00149  @code
00150     // Create label
00151     CzFont* font = (CzFont*)CZ_GLOBAL_RESOURCE_MANAGER->findResource("serif", CzHashes::Font_Hash);
00152     IzBrush* background_brush = (IzBrush*)CZ_GLOBAL_RESOURCE_MANAGER->findResource("Button1Brush", CzHashes::Brush_Hash);
00153     CzIVec2 size(200, 70);
00154     CZ_NEW_LABEL(scene, label, "label1", CzString("Clipping"), background_brush, font, size, false);
00155     label->setBackgroundColour(CzColour(255, 80, 80, 255));
00156     label->setWrapPosition(true);
00157 
00158     // Create an actions list that modifies the Position property of the label
00159     CzActions* actions = new CzActions();
00160     actions->setName("Update");
00161     CzAction* action = new CzAction();
00162     action->setMethodName("AddProperty");
00163     actions->addAction(action);
00164     action->setParameter1("Position");
00165     action->setParameter2("2, 2");
00166 
00167     // Add actions list to the label actors actions manager
00168     label->getActionsManager()->addActions(actions);
00169 
00170     // Tie label OnTick event to Update actions list
00171     label->getEventsManager()->addEvent("OnTick", "Update", true);
00172     label->setTickEnabled(true);    // When OnTick is specified we need to inform actor that it has been added to list (optimisation)
00173  @endcode
00174 
00175  @par Code Example (using macros):
00176  @code
00177     // Create label
00178     CzFont* font = (CzFont*)CZ_GLOBAL_RESOURCE_MANAGER->findResource("serif", CzHashes::Font_Hash);
00179     IzBrush* background_brush = (IzBrush*)CZ_GLOBAL_RESOURCE_MANAGER->findResource("Button1Brush", CzHashes::Brush_Hash);
00180     CzIVec2 size(200, 70);
00181     CZ_NEW_LABEL(scene, label, "label1", CzString("Clipping"), background_brush, font, size, false);
00182     label->setBackgroundColour(CzColour(255, 80, 80, 255));
00183     label->setWrapPosition(true);
00184 
00185     // Create an actions list that modifies the Position property of the label
00186     CZ_NEW_SINGLE_ACTION_P2(actions, a, "Update", "AddProperty", "Position", "2, 2");
00187     label->getActionsManager()->addActions(actions);
00188 
00189     // Tie label OnTick event to Update actions list
00190     label->getEventsManager()->addEvent("OnTick", "Update", true);
00191     label->setTickEnabled(true);    // When OnTick is specified we need to inform actor that it has been added to list (optimisation)
00192  @endcode
00193 
00194  As you can see, by far the easiest way to work with actions, actions lists and events is to use XOML.
00195 
00196  <h1>Creating Custom Actions</h1>
00197 
00198  Actions are a great way of passiong information between XOML and code, but the actions system wouldn't be as useful if it was limited to just the standard set of actions. Lets take 
00199  a look at how to create our own custom actions that can be called from XOML. 
00200 
00201  To create our own action we follow the following process:
00202  - Derive a new actions class from IzXomlAction
00203  - Set the action name in the constructor using setActionName() - This will be the name as it will be used in XOML.
00204  - Implement the Execute() method of IzXomlAction
00205  - Add an instance of the action to the actions manager
00206 
00207  Lets take a look at the first 3 stages:
00208 
00209  @code
00210 class CzXomlActions_MyAction : public IzXomlAction
00211 {
00212     CzXomlActions_MyAction()
00213     {
00214         // Set the action name (case insensitive )
00215         setActionName("myaction");
00216     }
00217 public:
00218     void Execute(IzXomlResource* source, CzAction* action)
00219     {
00220         CzApp* app = NULL;
00221         CzScene* scene = NULL;
00222         CzActor* actor = NULL;
00223 
00224         // Determine the scene, app and possibly actor that called the action
00225         if (source->getClassTypeHash() == CzHashes::Scene_Hash)
00226         {
00227             scene = (CzScene*)source;
00228             app = scene->getParent();
00229         }
00230         else
00231         if (source->getClassTypeHash() == CzHashes::Actor_Hash)
00232         {
00233             actor = (CzActor*)source;
00234             scene = actor->getScene();
00235             app = scene->getParent();
00236         }
00237 
00238         // Get the container / parent that contains the action
00239         IzXomlResource* cont = (actor != NULL) ? (IzXomlResource*)actor : (IzXomlResource*)scene;
00240 
00241         // Do something with the action
00242         CzString& param1 = action->getParameter1(cont);
00243         CzString& param2 = action->getParameter2(cont);
00244         DoSomething(param1, param2);
00245     }
00246 };
00247  @endcode
00248  
00249  Note that you do not need to determine the app, scene and actor of the caller if you do not need them all. We have provided them all as an example.
00250  
00251  Also note that in this example we call the actions parameter extraction methods CzAction::getParameter1() and CzAction::getParameter2() which will evaluate the parameters that were passed 
00252  to the action. The evaluation process will check the parameters for variables and if any are found then these variables values will be returned. You do not need to add this step if you 
00253  do not rely on XOML variables being passed as parameters to your actions. Below is an example of a much simplified action handler:
00254 
00255  @code
00256 class CzXomlActions_MyAction : public IzXomlAction
00257 {
00258     CzXomlActions_MyAction()
00259     {
00260         // Set the action name (case insensitive )
00261         setActionName("myaction");
00262     }
00263 public:
00264     void Execute(IzXomlResource* source, CzAction* action)
00265     {
00266         // Do something with the action
00267         DoSomething(action->Params[0], action->Params[1]);
00268     }
00269 };
00270  @endcode
00271 
00272  The last stage of adding your own custom action is to notify the XOML system that your action is available. To do this we call CZ_XOML->addAction():
00273 
00274  CZ_XOML->addAction(new CzXomlActions_MyAction());
00275 
00276  Note that CZ_XOML is a macro that accesses the global XOML singleton.
00277 
00278  We would place this call somewhere in our apps main boot up sequence so it gets called before any XOML parsing that contains this action begins. 
00279 
00280  Now lets take a look at a small XOML example that shows the use of our new action:
00281 
00282  @code
00283 <Actions Name="AnActionsList">
00284     <Action Method="MyAction" Param1="Hello World!" Param2="Im an action!" />
00285 </Actions>
00286  @endcode
00287 
00288  <h1>Conditional Actions</h1>
00289 
00290  A conditional action is an action that will be executed only if certain conditions are met. Lets take a look at a short example:
00291  
00292  @code
00293 <Actions Name="UpdatePLayerScore">
00294     <Action Method="AddVar" Param1="PlayerScore" Param2="1" Condition="!PlayerScoreTooHigh" />
00295     <Action Method="SetVar" Param1="PlayerScore" Param2="0" Condition="PlayerScoreTooHigh" />
00296 </Actions>
00297  @endcode
00298 
00299  In the above example the Condition attribute contains the PlayerScoreTooHigh variable. This variable is evaluated when the action is ran. if it returns true then the action will be executed. 
00300  Note that if the condition variable is prefixed with an exlamation mark then the result of the condition will be inverted. In this case the action will only be executed if the result of evaluating 
00301  the action is false. Conditions can also be applied to the actions list itself. Conditional actions offer a quick and easy way of applying simple logic to your apps directly in XOML without having 
00302  to resort to code.
00303 
00304  <h1>Some Examples</h1>
00305  
00306  Lets take a look at some useful example actions:
00307 
00308  @code
00309 <Action Method="ShowActor" P1="RefundedMessage"/>       - Show an actor
00310 <Action Method="HideActor" P1="RefundedMessage"/>       - Hide an actor
00311  @endcode
00312 
00313  @code
00314 <Action Method="CallScript" Param1="Guess" />   - Calls a script method
00315  @endcode
00316 
00317  @code
00318 <Action Method="Inline" Param1="
00319         local scene = scene.find('Scene1');
00320         local sound = resource.find('explosion', 'sound', scene);
00321         media.playSound(sound, true);            - Executes Lua script inline
00322         " />
00323  @endcode
00324 
00325  @code
00326 <Action Method="PlaySound" Param1="explosion" Param2="true" />  - Play a sound effect
00327  @endcode
00328 
00329  @code
00330 <Action Method="Purchase" P1="coins1" />    - Purchase a product using in-app purchasing
00331  @endcode
00332 
00333  @code
00334 <Action Method="SetProperty" P1="BackgroundColour" P2="128, 128, 255, 255" P3="Menu" /> - change the background colour of a menu
00335  @endcode
00336 
00337  @code
00338 <Action Method="LoadFile" Param1="RoundFile" Param2="true" Param3="Round1.txt" Condition="IsRound0" /> - Load a file
00339  @endcode
00340 
00341  @code
00342 <Action Method="SetVar" Param1="CardIndex" Param2="0" /> - Set the value of a variable
00343  @endcode
00344 
00345  @code
00346 <Action Method="CallActions" Param1="NextRound" /> - Call anoter actions list
00347 @endcode
00348 
00349  */
00350 
00351 struct CzAction
00352 {
00353     unsigned int            MethodName;     ///< Action method type
00354     CzString                Params[5];      ///< Action parameters
00355     CzXomlVariable*         Variables[5];   ///< Cached variable parameters (prevents continually searching for variables)
00356     unsigned int            Conditions;     ///< Name of conditions variable that defines a set of conditions that must be met for this action to be executed
00357     bool                    Not;            ///< if true then result of condition will be inversed
00358     CzActions*              Parent;         ///< Parent actions container
00359 #if defined(_DEBUG)
00360     CzString                _MethodName;
00361 #endif  //_DEBUG
00362     CzString                _Conditions;
00363     CzAction() : MethodName(0), Conditions(0), Not(false), Parent(NULL) {}
00364     void                    setMethodName(const char* name)
00365     {
00366 #if defined(_DEBUG)
00367         _MethodName = name;
00368 #endif  //_DEBUG
00369         MethodName = CZ_HASH(name);
00370     }
00371     unsigned int            getMethodName() const                   { return MethodName; }
00372     void                    setParameter1(CzString& p)              { Params[0] = p; }
00373     void                    setParameter1(const char* p)            { Params[0] = p; }
00374     CzString&               getParameter1(IzXomlResource* parent = NULL);
00375     void                    setParameter2(CzString& p)              { Params[1] = p; }
00376     void                    setParameter2(const char* p)            { Params[1] = p; }
00377     CzString&               getParameter2(IzXomlResource* parent = NULL);
00378     void                    setParameter3(CzString& p)              { Params[2] = p; }
00379     void                    setParameter3(const char* p)            { Params[2] = p; }
00380     CzString&               getParameter3(IzXomlResource* parent = NULL);
00381     void                    setParameter4(CzString& p)              { Params[3] = p; }
00382     void                    setParameter4(const char* p)            { Params[3] = p; }
00383     CzString&               getParameter4(IzXomlResource* parent = NULL);
00384     void                    setParameter5(CzString& p)              { Params[4] = p; }
00385     void                    setParameter5(const char* p)            { Params[4] = p; }
00386     CzString&               getParameter5(IzXomlResource* parent = NULL);
00387     void                    setConditions(const char* cond)
00388     {
00389         _Conditions = cond;
00390         Conditions = CZ_HASH(cond);
00391     }
00392     unsigned int            getConditions() const   { return Conditions; }
00393 
00394 
00395 };
00396 
00397 /**
00398  @class CzActions
00399 
00400  @brief A collection of actions (called an actions list in XOML).
00401 
00402  XOML allows you to collect together a collection of actions that are executed one after the other. Below is an example that shows how to create an actions list in XOML:
00403 
00404 @code
00405 <!-- Action that is called when a correct answer is given -->
00406 <Actions Name="CorrectAnswer">
00407     <Action Method="AddVar" Param1="RoundScore" Param2="1" />
00408     <Action Method="HideActor" Param1="SelectedCardNames:0" />
00409     <Action Method="HideActor" Param1="SelectedCardNames:1" />
00410     <Action Method="HideActor" Param1="SelectedCardNames:2" />
00411     <Action Method="AddVar" Param1="CardsFoundCount" Param2="3" />
00412     <Action Method="SetProperty" Param1="Text" Param2="Correct, well done" Param3="AnswerNotification" />
00413     <Action Method="SetTimeline" Param1="AnswerNotificationAnim" Param2="AnswerNotification" />
00414 </Actions>
00415 @endcode
00416 
00417  In code to create an actions list is a simple case of instantiating a CzActions class then calliong addAction() to add actions to the actions list. When the actions list is built 
00418  you can then add it to either the global resources actions manager, a scenes actions manager or an actors actions manager depending on what scope you would like the actions list to have. 
00419  Its possible for example to add the actions list to a scene then apply it to multiple actors.
00420 
00421  */
00422 
00423 class CzActions : public IzXomlResource
00424 {
00425 public:
00426     // Public access to actions iteration
00427     typedef CzList<CzAction*>::iterator _Iterator;
00428     _Iterator                   begin() { return Actions.begin(); }
00429     _Iterator                   end() { return Actions.end(); }
00430     // Properties
00431 protected:
00432     CzList<CzAction*>           Actions;            // List of actions
00433     unsigned int                Conditions;         // Name as a string hash of the conditions variable that defines a set of conditions that must be met for this set of actions to be executed
00434     CzString                    _Conditions;        // Name of the conditions variable that defines a set of conditions that must be met for this set of actions to be executed
00435     bool                        Not;                // if true then result of condition will be inversed
00436 public:
00437     void                        addAction(CzAction* action);
00438     void                        removeAction(CzAction* action, bool auto_delete = true);
00439     void                        setConditions(const CzString& conditions)
00440     {
00441         Conditions = conditions.getHash();
00442         _Conditions = conditions;
00443     }
00444     unsigned int                getConditions() const                           { return Conditions; }
00445     void                        setNot(bool _not)                               { Not = _not; }
00446     bool                        isNot() const                                   { return Not; }
00447     // Properties end
00448 
00449     CzActions() : IzXomlResource(), Conditions(0), Not(false) { setClassType("actions");    }
00450     virtual ~CzActions()
00451     {
00452         for (_Iterator it = begin(); it != end(); ++it)
00453             delete *it;
00454         Actions.clear();
00455     }
00456 
00457     void            Execute(IzXomlResource* source);
00458 
00459     // Implementation of IzXomlResource interface
00460     int             LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00461 };
00462 
00463 /**
00464  @class CzActionsCreator
00465 
00466  @brief CzActionsreator - Creates an instance of an actions object.
00467 
00468  CzActionsCreator enables actions lists to be instantiated from XOML.
00469 
00470  */
00471 
00472 class CzActionsCreator : public IzXomlClassCreator
00473 {
00474 public:
00475     CzActionsCreator()
00476     {
00477         setClassName("actions");
00478     }
00479     IzXomlResource* CreateInstance(IzXomlResource* parent) { return new CzActions(); }
00480 };
00481 
00482 /**
00483  @class CzActionsManager
00484 
00485  @brief Manages a collection of actions lists.
00486 
00487  CzActionsManager manages a collection of actions lists and each actor and scene that is created is assigned its own actions manager. You can retrieve an actors actions manager by calling 
00488  CzActor::getActionsManager() and a scenes by calling CzScene::getActionsManager(). The global resource manager also has an actions manager of its own which is used to store global actions lists. 
00489  You can access this via CzGlobalResources::getActionsManager() by using the macro CZ_GLOBAL_ACTIONS_MANAGER.
00490 
00491  */
00492 
00493 class CzActionsManager
00494 {
00495 public:
00496     // Public access to iteration
00497     typedef CzList<CzActions*>::iterator _Iterator;
00498     _Iterator               begin()     { return Actions.begin(); }
00499     _Iterator               end()       { return Actions.end(); }
00500 
00501 protected:
00502     // Properties
00503     CzList<CzActions*>      Actions;            // A collection of actions
00504     IzXomlResource*         Parent;             // Parent container
00505 public:
00506     void                    addActions(CzActions* actions);
00507     void                    removeActions(CzActions* Actions);
00508     void                    removeActions(unsigned int name_hash);
00509     CzActions*              findActions(unsigned int name_hash);
00510     CzActions*              findActions(const char* name);
00511     void                    clearActionss();
00512     void                    setParent(IzXomlResource* scene)
00513     {
00514         Parent = scene;
00515     }
00516     IzXomlResource*         getParent()                             { return Parent; }
00517     // Properties end
00518 
00519 public:
00520     CzActionsManager() : Parent(NULL) {}
00521     virtual ~CzActionsManager() { clearActionss(); }
00522 
00523     // Utility
00524     static CzActions*   FindActions(const char* name, IzXomlResource* container);
00525     static CzActions*   FindActions(unsigned int name_hash, IzXomlResource* container);
00526     static CzActions*   FindActions(unsigned int name_hash, CzScene* container, unsigned int actor_hash);
00527     static CzActions*   FindActions(const char* name, CzScene* container, const char* actor_name);
00528 };
00529 
00530 //
00531 //
00532 //
00533 //
00534 //  Helper macros
00535 //
00536 //
00537 //
00538 //
00539 
00540 /**
00541  @def   CZ_NEW_SINGLE_ACTION(actions, action, name, method)
00542 
00543  @brief A macro that creates an actions list containing a single action with no parameters.
00544 
00545  @param actions The actions list variable.
00546  @param action  The action variable.
00547  @param name    The actions list name.
00548  @param method  The method name.
00549  */
00550 
00551 #define CZ_NEW_SINGLE_ACTION(actions, action, name, method)     \
00552     CzActions* actions = new CzActions();                       \
00553     actions->setName(name);                                     \
00554     CzAction* action = new CzAction();                          \
00555     action->setMethodName(method);                              \
00556     actions->addAction(action);
00557 
00558 /**
00559  @def   CZ_NEW_SINGLE_ACTION_P1(actions, action, name, method, p1)
00560 
00561  @brief A macro that creates an actions list containing a single action with one parameter.
00562 
00563  @param actions The actions list variable.
00564  @param action  The action variable.
00565  @param name    The actions list name.
00566  @param method  The method name.
00567  @param p1      The first parameter.
00568  */
00569 
00570 #define CZ_NEW_SINGLE_ACTION_P1(actions, action, name, method, p1)  \
00571     CZ_NEW_SINGLE_ACTION(actions, action, name, method)             \
00572     action->setParameter1(p1);
00573 
00574 /**
00575  @def   CZ_NEW_SINGLE_ACTION_P2(actions, action, name, method, p1, p2)
00576 
00577  @brief A macro that creates an actions list containing a single action with two parameters.
00578 
00579  @param actions The actions list variable.
00580  @param action  The action variable.
00581  @param name    The actions list name.
00582  @param method  The method name.
00583  @param p1      The first parameter.
00584  @param p2      The second parameter.
00585  */
00586 
00587 #define CZ_NEW_SINGLE_ACTION_P2(actions, action, name, method, p1, p2)  \
00588     CZ_NEW_SINGLE_ACTION(actions, action, name, method)                 \
00589     action->setParameter1(p1);                                          \
00590     action->setParameter2(p2);
00591 
00592 /**
00593  @def   CZ_NEW_SINGLE_ACTION_P3(actions, action, name, method, p1, p2, p3)
00594  
00595  @brief A macro that creates an actions list containing a single action with three parameters.
00596 
00597  @param actions The actions list variable.
00598  @param action  The action variable.
00599  @param name    The actions list name.
00600  @param method  The method name.
00601  @param p1      The first parameter.
00602  @param p2      The second parameter.
00603  @param p3      The third parameter.
00604  */
00605 
00606 #define CZ_NEW_SINGLE_ACTION_P3(actions, action, name, method, p1, p2, p3)  \
00607     CZ_NEW_SINGLE_ACTION(actions, action, name, method)                     \
00608     action->setParameter1(p1);                                              \
00609     action->setParameter2(p2);                                              \
00610     action->setParameter3(p3);
00611 
00612 /**
00613  @def   CZ_NEW_SINGLE_ACTION_P4(actions, action, name, method, p1, p2, p3, p4)
00614  @brief A macro that creates an actions list containing a single action with four parameters.
00615 
00616  @param actions The actions list variable.
00617  @param action  The action variable.
00618  @param name    The actions list name.
00619  @param method  The method name.
00620  @param p1      The first parameter.
00621  @param p2      The second parameter.
00622  @param p3      The third parameter.
00623  @param p4      The fourth parameter.
00624  */
00625 
00626 #define CZ_NEW_SINGLE_ACTION_P4(actions, action, name, method, p1, p2, p3, p4)  \
00627     CZ_NEW_SINGLE_ACTION(actions, action, name, method)                         \
00628     action->setParameter1(p1);                                                  \
00629     action->setParameter2(p2);                                                  \
00630     action->setParameter3(p3);                                                  \
00631     action->setParameter4(p4);
00632 
00633 /**
00634  @def   CZ_NEW_SINGLE_ACTION_P5(actions, action, name, method, p1, p2, p3, p4, p5)
00635 
00636  @brief A macro that creates an actions list containing a single action with five parameters.
00637 
00638  @param actions The actions list variable.
00639  @param action  The action variable.
00640  @param name    The actions list name.
00641  @param method  The method name.
00642  @param p1      The first parameter.
00643  @param p2      The second parameter.
00644  @param p3      The third parameter.
00645  @param p4      The fourth parameter.
00646  @param p5      The fifth parameter.
00647  */
00648 
00649 #define CZ_NEW_SINGLE_ACTION_P5(actions, action, name, method, p1, p2, p3, p4, p5)  \
00650     CZ_NEW_SINGLE_ACTION(actions, action, name, method)                             \
00651     action->setParameter1(p1);                                                      \
00652     action->setParameter2(p2);                                                      \
00653     action->setParameter3(p3);                                                      \
00654     action->setParameter4(p4);                                                      \
00655     action->setParameter5(p5);
00656 
00657 /// @}
00658 
00659 #endif // _CZ_ACTIONS_H_