Changeset 1154 for code/branches/input/src/core
- Timestamp:
- Apr 24, 2008, 11:04:01 AM (17 years ago)
- Location:
- code/branches/input/src/core
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/core/CMakeLists.txt
r1084 r1154 1 #get the created files 2 AUX_SOURCE_DIRECTORY(tolua TOLUA_BIND_FILES) 3 4 SET( CORE_SRC_FILES 1 SET(CORE_SRC_FILES 5 2 OrxonoxClass.cc 6 3 BaseObject.cc … … 29 26 Tickable.cc 30 27 Script.cc 31 ${TOLUA_BIND_FILES} 28 tolua/tolua_bind.cc 29 #tolua/tolua_bind.h 32 30 ) 33 31 34 ADD_LIBRARY( core SHARED ${CORE_SRC_FILES}) 32 #SET_SOURCE_FILES_PROPERTIES(tolua/tolua_bind.h 33 # PROPERTIES 34 # OBJECT_DEPENDS tolua/tolua_bind.h 35 # OBJECT_DEPENDS tolua/tolua_bind.cc 36 # GENERATED true 37 # HEADER_FILE_ONLY true 38 #) 35 39 36 TARGET_LINK_LIBRARIES( core 40 GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION) 41 ADD_CUSTOM_COMMAND( 42 OUTPUT tolua/tolua_bind.cc tolua/tolua_bind.h 43 COMMAND ${TOLUA_EXE} -n core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg 44 DEPENDS tolua 45 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib 46 ) 47 48 ADD_LIBRARY(core SHARED ${CORE_SRC_FILES}) 49 50 TARGET_LINK_LIBRARIES(core 51 ${Lua_LIBRARIES} 52 ${OIS_LIBRARIES} 53 ${OGRE_LIBRARIES} 37 54 util 38 ${Lua_LIBRARIES}39 ${Lua_LIBRARY}40 ${OIS_LIBRARIES}41 55 ) -
code/branches/input/src/core/ConfigFileManager.h
r1064 r1154 63 63 { 64 64 public: 65 virtual ~ConfigFileEntry() {}; 65 66 virtual void setValue(const std::string& value) = 0; 66 67 virtual std::string getValue() const = 0; -
code/branches/input/src/core/InputManager.cc
r1118 r1154 125 125 // create the handlers 126 126 this->handlerGUI_ = new InputHandlerGUI(); 127 this->handlerGUI_->initialise(); 127 128 this->handlerGame_ = new InputHandlerGame(); 128 //this->handlerBuffer_ = new InputBuffer(); 129 this->handlerGame_->loadBindings(); 130 131 /*COUT(ORX_DEBUG) << "*** InputManager: Loading key bindings..." << std::endl; 132 // load the key bindings 133 InputEvent empty = {0, false, 0, 0, 0}; 134 for (int i = 0; i < this->numberOfKeys_; i++) 135 this->bindingsKeyPressed_[i] = empty; 136 137 //assign 'abort' to the escape key 138 this->bindingsKeyPressed_[(int)OIS::KC_ESCAPE].id = 1; 129 this->handlerGame_->initialise(); 130 139 131 COUT(ORX_DEBUG) << "*** InputManager: Loading done." << std::endl;*/ 140 132 … … 159 151 this->inputSystem_ = 0; 160 152 161 if (this->handlerBuffer_)162 delete this->handlerBuffer_;163 153 if (this->handlerGame_) 164 154 delete this->handlerGame_; … … 166 156 delete this->handlerGUI_; 167 157 168 this->handlerBuffer_ = 0;169 158 this->handlerGame_ = 0; 170 159 this->handlerGUI_ = 0; … … 192 181 this->keyboard_->setEventCallback(this->handlerGame_); 193 182 break; 194 case IM_KEYBOARD:195 this->mouse_->setEventCallback(this->handlerGame_);196 this->keyboard_->setEventCallback(this->handlerBuffer_);197 break;198 183 case IM_UNINIT: 199 184 this->mouse_->setEventCallback(0); … … 211 196 212 197 // Give the listeners the chance to do additional calculations 198 this->currentHandler_->tick(dt); 213 199 } 214 200 -
code/branches/input/src/core/InputManager.h
r1084 r1154 51 51 IM_INGAME: Normal game mode. Key bindings and mouse are active. 52 52 */ 53 enum InputMode54 {55 IM_GUI = 0,56 IM_KEYBOARD = 1,57 IM_INGAME = 2,58 IM_UNINIT = 3,59 };60 53 61 54 /** … … 83 76 static InputManager& getSingleton(); 84 77 static InputManager* getSingletonPtr() { return &getSingleton(); } 85 static void setInputMode(int mode); 78 79 static void setInputHandler(std::string& name); 86 80 87 81 private: … … 95 89 OIS::Mouse *mouse_; //!< OIS keyboard 96 90 97 InputMode currentMode_; //!< Input mode currently used 98 InputMode setMode_; //!< Input mode that has been set lately 99 InputHandlerGUI *handlerGUI_; //!< Handles the input if in GUI mode 100 // FIXME: insert the InputBuffer once merged with core2 101 InputBuffer *handlerBuffer_; //!< Handles the input if in Buffer mode 102 InputHandlerGame *handlerGame_; //!< Handles the input if in Game mode 91 BaseInputHandler* currentHandler_; 92 BaseInputHandler* switchToHandler_; 93 //! Maps the names of the input handlers to their instance 94 std::map<std::string, BaseInputHandler*> handlers_; 103 95 104 //! Pointer to the instance of the singleton105 //static InputManager *singletonRef_s;106 96 }; 107 97 } -
code/branches/input/src/core/Loader.cc
r1085 r1154 115 115 Script::init(Script::getLuaState()); 116 116 Script::run();*/ 117 //Script* lua = Script::getInstance();118 //lua->loadFile(level->getFile(), true);119 //lua->run();117 Script* lua = Script::getInstance(); 118 lua->loadFile(level->getFile(), true); 119 lua->run(); 120 120 121 121 try … … 124 124 COUT(3) << "Mask: " << Loader::currentMask_s << std::endl; 125 125 126 ticpp::Document xmlfile(level->getFile());127 xmlfile.LoadFile();126 //ticpp::Document xmlfile(level->getFile()); 127 //xmlfile.LoadFile(); 128 128 //ticpp::Element myelement(*Script::getFileString()); 129 //ticpp::Document xmlfile;130 xmlfile.ToDocument();131 //xmlfile.Parse(lua->getLuaOutput(), true);129 ticpp::Document xmlfile; 130 //xmlfile.ToDocument(); 131 xmlfile.Parse(lua->getLuaOutput(), true); 132 132 133 133 ticpp::Element rootElement; -
code/branches/input/src/core/Script.cc
r1076 r1154 60 60 luaopen_debug(luaState_); 61 61 #endif 62 tolua_ orxonox_open(luaState_);62 tolua_core_open(luaState_); 63 63 output_ = ""; 64 64 } … … 102 102 } 103 103 104 #if LUA_VERSION_NUM != 501 105 const char * Script::lua_Chunkreader(lua_State *L, void *data, size_t *size) 106 { 107 LoadS* ls = ((LoadS*)data); 108 if (ls->size == 0) return NULL; 109 *size = ls->size; 110 ls->size = 0; 111 return ls->s; 112 } 113 #endif 104 114 void Script::run() 105 115 { … … 110 120 error = luaL_loadstring(luaState_, init.c_str()); 111 121 #else 112 error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, (void*)init.c_str(), "init"); 122 LoadS ls; 123 ls.s = init.c_str(); 124 ls.size = init.size(); 125 error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, &ls, init.c_str()); 113 126 #endif 114 127 if (error == 0) -
code/branches/input/src/core/Script.h
r1056 r1154 50 50 class _CoreExport Script // tolua_export 51 51 { // tolua_export 52 struct LoadS { 53 const char *s; 54 size_t size; 55 }; 56 52 57 public: 53 58 inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export … … 61 66 62 67 #if LUA_VERSION_NUM != 501 63 inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};68 static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size); 64 69 #endif 65 70
Note: See TracChangeset
for help on using the changeset viewer.