2 * LiveML - LiveML is screen(graphic) controling library using XML.
5 * Copyright (C) 2010 Nothan
6 * http://github.com/nothan/liveml/
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the Free
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 * private@nothan.xrea.jp
27 * http://tsuioku-denrai.xrea.jp/
30 #ifndef __LIVEMLRUNNER_H__
31 #define __LIVEMLRUNNER_H__
33 #include "livemlparser.h"
35 #include "bool_list.hpp"
41 list<ActionParser*> currentActionList;
42 list<Tag*> currentTagList;
43 unsigned int waitCounter;
44 list<unsigned int> repeatCounter;
52 bool setAction(ActionParser *action)
54 *currentActionList.push_back() = action;
55 if (action == NULL) return false;
56 *currentTagList.push_back() = action->tag;
60 bool setAction(action_type type)
62 ActionParser *action = parser->actionContainer.getAction(type);
63 if (action == NULL) return false;
68 bool setActionByName(const char *name)
70 action_type type = parser->actionContainer.getActionType(name);
71 printf("find %s => %d\n", name, type);
72 return setAction(type);
76 struct LMLSceneObject : public LMLObject
80 struct LMLActorObject : public LMLObject
88 bool (*func)(Parameter&, LMLObject&, LiveMLRunner&);
89 bool (*closeFunc)(Parameter&, LMLObject&, LiveMLRunner&);
92 LMLSceneObject _scene;
93 list<LMLActorObject> _actorList;
94 LMLActorObject *_currentActor;
95 LMLObject *_focusObject;
96 vector<FuncPtr> _commandFuncs;
98 list_allocator<ActionParser*> _actionAllocator;
99 list_allocator<Tag*> _tagAllocator;
100 list_allocator<unsigned int> _repeatAllocator;
103 LiveMLParser *parser;
104 bool registerCommand(
106 bool (*)(Parameter&, LMLObject&, LiveMLRunner&),
107 bool (*)(Parameter&, LMLObject&, LiveMLRunner&) = NULL
110 LiveMLRunner(LiveMLParser*);
112 void setMaxActors(size_t);
113 LMLSceneObject* setScene(const char*);
114 LMLActorObject* addActor(const char*);
116 LMLActorObject* setCurrentActor(LMLActorObject *obj) { _currentActor = obj; }
117 LMLActorObject* getCurrentActor(void) { return _currentActor; }
119 void setFocusObject(LMLObject* obj) { _focusObject = obj; }
120 LMLObject* getFocusObject(void) { return _focusObject; }
122 void onEvent(size_t index) { _eventFlag.on(index); }
123 void offEvent(size_t index) { _eventFlag.off(index); }
124 bool stateEvent(size_t index) { return _eventFlag[index]; }
125 bool_list getbool_lists(void) { return _eventFlag; }
126 void setbool_lists(bool_list &f) { _eventFlag = f; }
128 bool runCommand(LMLObject&, Tag*);
129 bool runObjectEvent(LMLObject&);
130 bool runObjectAction(LMLObject&);
131 bool runObject(LMLObject&);
135 #endif // __LIVEMLRUNNER_H__