TimelineScript.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include "TimelineScript.hpp"
00023 #include "ScriptComponent.hpp"
00024 #include "../sim.hpp"
00025 #include "../SimEngine.hpp"
00026 #include "../action/Action.hpp"
00027 #include "../action/Idle.hpp"
00028 #include "../schema/SimSchema.hpp"
00029 #include "../../util/type/String.hpp"
00030 #include "../../util/error/Log.hpp"
00031 
00032 
00033 namespace se_core {
00034 
00035 
00036     TimelineScript
00037     ::TimelineScript(const char* name, int trackerPosCount) : Script(name), trackerPosCount_(trackerPosCount), isInZeroMode_(trackerPosCount == 1) {
00038         actions_ = new const Action*[ trackerPosCount_ ];
00039         scriptSingleValueParameters_ = new int[ trackerPosCount_ ];
00040         scriptAttributeParameters_ = new String*[ trackerPosCount_ ];
00041         for(int j = 0; j < trackerPosCount_; ++j) {
00042             actions_[j] = 0;
00043             scriptSingleValueParameters_[j] = 0;
00044             scriptAttributeParameters_[j] = 0;
00045         }
00046     }
00047 
00048 
00049     TimelineScript
00050     ::~TimelineScript() {
00051         delete actions_;
00052     }
00053 
00054 
00055     void TimelineScript
00056     ::addAction(int trackerPos, const Action* action) {
00057         Assert(trackerPos < trackerPosCount_);
00058         actions_[ trackerPosCount_ + trackerPos ] = action;
00059     }
00060 
00061 
00062     void TimelineScript
00063     ::addAction(int trackerPos, const char* name) {
00064         Assert(trackerPos < trackerPosCount_);
00065         addAction(trackerPos, Action::lookup(name));
00066     }
00067 
00068 
00069     const Action* TimelineScript
00070     ::nextAction(const ScriptComponent& performer, int channel, ScriptData* sd, Parameter& out) const {
00071         if(channel != 0)
00072             return 0;
00073         if(isInZeroMode_) {
00074             const Action* a = actions_[ trackerPosCount_ + 0];
00075             if(!a) { return &actionIdle; }
00076             //performer.param(channel).setNumber(scriptSingleValueParameters_[0]);
00077             if(scriptAttributeParameters_[0]) {
00078                 //performer.param(channel).setString(scriptAttributeParameters_[0]->get());
00079             }
00080             return a;
00081         }
00082 
00083         //LogDetail((sprintf(log_msg(), "Tracker: %d - %d - %d - %s", SimSchema::scriptTracker, SimSchema::simEngine.when(), channel, performer.name()), log_msg()));
00084         Assert(SimSchema::scriptTracker < trackerPosCount_);
00085         const Action* a = actions_[ trackerPosCount_ + SimSchema::scriptTracker];
00086         if(!a) { return &actionIdle; }
00087         SimSchema::didTrack = true;
00088         //performer.param(channel).setNumber(scriptSingleValueParameters_[SimSchema::scriptTracker]);
00089         if(scriptAttributeParameters_[SimSchema::scriptTracker]) {
00090             //performer.param(channel).setString(scriptAttributeParameters_[SimSchema::scriptTracker]->get());
00091             //LogDetail(performer.param(channel).string());
00092         }
00093         return a;
00094     }
00095 
00096 }

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:12 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo