00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Planner.h"
00010
00011 #include "ScriptState.h"
00012 #include "CommandQueue.h"
00013 #include "DialogStack.h"
00014
00015 #include "SubTitleAgent.h"
00016 #include "ScriptCmd.h"
00017 #include "dialog-script.h"
00018 #include "options-script.h"
00019
00020
00021 Planner::Planner()
00022 {
00023 m_plan = new CommandQueue();
00024 m_dialogs = new DialogStack();
00025 registerScriptFuncs();
00026 }
00027
00028 void
00029 Planner::registerScriptFuncs()
00030 {
00031 m_script->registerFunc("game_planAction", script_game_planAction);
00032 m_script->registerFunc("game_isPlanning", script_game_isPlanning);
00033 m_script->registerFunc("game_killPlan", script_game_killPlan);
00034
00035 m_script->registerFunc("dialog_isDialog", script_dialog_isDialog);
00036 m_script->registerFunc("dialog_addFont", script_dialog_addFont);
00037 m_script->registerFunc("dialog_addDialog", script_dialog_addDialog);
00038 m_script->registerFunc("model_isTalking", script_model_isTalking);
00039 m_script->registerFunc("model_talk", script_model_talk);
00040 m_script->registerFunc("model_killSound", script_model_killSound);
00041
00042 m_script->registerFunc("sound_playMusic", script_sound_playMusic);
00043 m_script->registerFunc("sound_stopMusic", script_sound_stopMusic);
00044
00045 m_script->registerFunc("options_getParam", script_options_getParam);
00046 }
00047
00048 Planner::~Planner()
00049 {
00050
00051 delete m_plan;
00052 delete m_dialogs;
00053 }
00054
00055
00056
00057
00058
00059 bool
00060 Planner::satisfyPlan()
00061 {
00062 m_dialogs->updateStack();
00063 m_plan->executeFirst();
00064 return m_plan->empty();
00065 }
00066
00067 void
00068 Planner::killPlan()
00069 {
00070 m_dialogs->killTalks();
00071 SubTitleAgent::agent()->killTalks();
00072 interruptPlan();
00073 }
00074
00075 void
00076 Planner::interruptPlan()
00077 {
00078 m_plan->removeAll();
00079 }
00080
00081 void
00082 Planner::planAction(int funcRef)
00083 {
00084 m_plan->planCommand(new ScriptCmd(m_script, funcRef));
00085 }
00086
00087
00088
00089
00090 bool
00091 Planner::isPlanning() const
00092 {
00093 return !m_plan->empty();
00094 }
00095