Changeset 8283 for code/branches/kicklib2/src/libraries
- Timestamp:
- Apr 21, 2011, 6:32:28 PM (14 years ago)
- Location:
- code/branches/kicklib2
- Files:
-
- 2 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib2
- Property svn:mergeinfo changed
/code/branches/kicklib merged: 7940-7948,7950-7951,7953,7956-7957,7959-7961,7964-7965,7967-7969,7971,7973-7974
- Property svn:mergeinfo changed
-
code/branches/kicklib2/src/libraries/core/CMakeLists.txt
r8079 r8283 58 58 command/ArgumentCompletionFunctions.cc 59 59 ConfigFileManager.cc 60 MemoryArchive.cc61 60 PathConfig.cc 62 61 COMPILATION_END … … 98 97 ${CEGUI_LIBRARY} 99 98 ${CEGUILUA_LIBRARY} 100 ${LUA_LIBRARIES} 99 ${CEGUI_TOLUA_LIBRARY} 100 ${CEGUI_OGRE_RENDERER_LIBRARY} 101 ${LUA5.1_LIBRARY} 101 102 cpptcl_orxonox 102 ogreceguirenderer_orxonox103 103 ois_orxonox 104 104 tinyxml_orxonox 105 tolua_orxonox106 105 util 107 106 SOURCE_FILES -
code/branches/kicklib2/src/libraries/core/CorePrereqs.h
r8079 r8283 38 38 #include "OrxonoxConfig.h" 39 39 #include <boost/version.hpp> 40 #include <CEGUIVersion.h> 40 41 41 42 //----------------------------------------------------------------------- … … 306 307 class LuaScriptModule; 307 308 309 #if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7 308 310 class OgreCEGUIRenderer; 309 311 class OgreCEGUIResourceProvider; 310 312 class OgreCEGUITexture; 313 #else 314 class OgreRenderer; 315 class OgreResourceProvider; 316 class OgreImageCodec; 317 #endif 311 318 } 312 319 -
code/branches/kicklib2/src/libraries/core/GUIManager.cc
r8079 r8283 30 30 #include "GUIManager.h" 31 31 32 #include <memory> 32 33 #include <boost/bind.hpp> 33 #include <memory> 34 #include <OgreRenderQueue.h> 35 #include <OgreRenderWindow.h> 34 36 35 37 #include <CEGUIDefaultLogger.h> … … 43 45 #include <elements/CEGUIListbox.h> 44 46 #include <elements/CEGUIListboxItem.h> 45 #include <ogreceguirenderer/OgreCEGUIRenderer.h> 46 47 #include "SpecialConfig.h" // Configures the macro below 48 #ifdef CEGUILUA_USE_INTERNAL_LIBRARY 49 # include <ceguilua/CEGUILua.h> 47 48 #ifdef ORXONOX_OLD_CEGUI 49 # include <CEGUILua.h> 50 # include <ogreceguirenderer/OgreCEGUIRenderer.h> 51 extern "C" { 52 # include <lauxlib.h> 53 } 50 54 #else 51 # include <CEGUILua.h> 55 # include <ScriptingModules/LuaScriptModule/CEGUILua.h> 56 # include <RendererModules/Ogre/CEGUIOgreImageCodec.h> 57 # include <RendererModules/Ogre/CEGUIOgreRenderer.h> 58 # include <RendererModules/Ogre/CEGUIOgreResourceProvider.h> 52 59 #endif 53 60 … … 89 96 case CEGUI::Informative: orxonoxLevel = 5; break; 90 97 case CEGUI::Insane: orxonoxLevel = 6; break; 91 default: OrxAssert(false, "CEGUI log level out of range, in pect immediately!");98 default: OrxAssert(false, "CEGUI log level out of range, inspect immediately!"); 92 99 } 93 100 OutputHandler::getOutStream(orxonoxLevel) … … 97 104 } 98 105 }; 106 107 #ifdef ORXONOX_OLD_CEGUI 108 /** Class with the same memory layout as CEGUI::LuaScriptModule. <br> 109 We need this to fix a problem with an uninitialised member variable 110 in CEGUI < 0.7 <br> 111 Notice that "public" modifier for the otherwise private variables. 112 */ 113 class CEGUILUA_API LuaScriptModuleWorkaround : public CEGUI::ScriptModule 114 { 115 public: 116 LuaScriptModuleWorkaround(); 117 ~LuaScriptModuleWorkaround(); 118 119 public: 120 bool d_ownsState; 121 lua_State* d_state; 122 CEGUI::String d_errFuncName; 123 int d_errFuncIndex; 124 CEGUI::String d_activeErrFuncName; 125 int d_activeErrFuncIndex; 126 }; 127 #endif 99 128 100 129 static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button); … … 118 147 */ 119 148 GUIManager::GUIManager(const std::pair<int, int>& mousePosition) 120 : resourceProvider_(NULL) 149 : destroyer_(*this, &GUIManager::cleanup) 150 , guiRenderer_(NULL) 151 , luaState_(NULL) 152 , scriptModule_(NULL) 153 , guiSystem_(NULL) 154 , resourceProvider_(NULL) 155 #ifndef ORXONOX_OLD_CEGUI 156 , imageCodec_(NULL) 157 #endif 121 158 , camera_(NULL) 122 159 { … … 129 166 130 167 // Note: No SceneManager specified yet 131 guiRenderer_.reset(new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000)); 168 #ifdef ORXONOX_OLD_CEGUI 169 guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000); 132 170 resourceProvider_ = guiRenderer_->createResourceProvider(); 171 #else 172 guiRenderer_ = &OgreRenderer::create(*GraphicsManager::getInstance().getRenderWindow()); 173 resourceProvider_ = &OgreRenderer::createOgreResourceProvider(); 174 imageCodec_ = &OgreRenderer::createOgreImageCodec(); 175 #endif 133 176 resourceProvider_->setDefaultResourceGroup("General"); 134 177 135 178 // Setup scripting 136 luaState_ .reset(new LuaState());179 luaState_ = new LuaState(); 137 180 rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua"); 138 181 // This is necessary to ensure that input events also use the right resource info when triggering lua functions 139 182 luaState_->setDefaultResourceInfo(this->rootFileInfo_); 140 scriptModule_.reset(new LuaScriptModule(luaState_->getInternalLuaState())); 183 #ifdef ORXONOX_OLD_CEGUI 184 scriptModule_ = new LuaScriptModule(luaState_->getInternalLuaState()); 185 // Ugly workaround: older CEGUILua versions don't initialise the member 186 // d_activeErrFuncIndex at all. That leads to "error in error handling" 187 // problems when a Lua error occurs. 188 // We fix this by setting the member manually. 189 reinterpret_cast<LuaScriptModuleWorkaround*>(scriptModule_)->d_activeErrFuncIndex = LUA_NOREF; 190 luaState_->doString("ORXONOX_OLD_CEGUI = true"); 191 #else 192 scriptModule_ = &LuaScriptModule::create(luaState_->getInternalLuaState()); 193 #endif 141 194 scriptModule_->setDefaultPCallErrorHandler(LuaState::ERROR_HANDLER_NAME); 142 195 … … 144 197 std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger()); 145 198 ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log"); 146 // set the log level according to ours (translate by subtracting 1)199 // Set the log level according to ours (translate by subtracting 1) 147 200 ceguiLogger->setLoggingLevel( 148 201 static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1)); … … 150 203 151 204 // Create the CEGUI system singleton 152 guiSystem_.reset(new System(guiRenderer_.get(), resourceProvider_, 0, scriptModule_.get())); 205 #ifdef ORXONOX_OLD_CEGUI 206 guiSystem_ = new System(guiRenderer_, resourceProvider_, 0, scriptModule_); 207 // Add functions that have been renamed in newer versions 208 luaState_->doString("CEGUI.SchemeManager.create = CEGUI.SchemeManager.loadScheme"); 209 luaState_->doString("CEGUI.Window.getUnclippedOuterRect = CEGUI.Window.getUnclippedPixelRect"); 210 #else 211 guiSystem_ = &System::create(*guiRenderer_, resourceProvider_, 0, imageCodec_, scriptModule_); 212 #endif 153 213 154 214 // Align CEGUI mouse with OIS mouse … … 175 235 } 176 236 177 /** 178 @brief 179 Basically shuts down CEGUI (member smart pointers) but first unloads our Tolua modules. 180 */ 181 GUIManager::~GUIManager() 182 { 237 void GUIManager::cleanup() 238 { 239 using namespace CEGUI; 240 241 #ifdef ORXONOX_OLD_CEGUI 242 delete guiSystem_; 243 delete guiRenderer_; 244 delete scriptModule_; 245 #else 246 System::destroy(); 247 OgreRenderer::destroyOgreResourceProvider(*resourceProvider_); 248 OgreRenderer::destroyOgreImageCodec(*imageCodec_); 249 OgreRenderer::destroy(*guiRenderer_); 250 LuaScriptModule::destroy(*scriptModule_); 251 #endif 252 delete luaState_; 183 253 } 184 254 … … 222 292 { 223 293 this->camera_ = camera; 294 #ifdef ORXONOX_OLD_CEGUI 224 295 if (camera == NULL) 225 296 this->guiRenderer_->setTargetSceneManager(0); 226 297 else 227 298 this->guiRenderer_->setTargetSceneManager(camera->getSceneManager()); 299 #endif 228 300 } 229 301 … … 522 594 The Listbox for which to enable (or disable) tooltips. 523 595 @param enabled 524 Whether to enable or disab elthe tooltips.596 Whether to enable or disable the tooltips. 525 597 */ 526 598 void GUIManager::setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled) … … 535 607 { 536 608 this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight)); 609 #else 610 this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight)); 611 #endif 537 612 } 538 613 -
code/branches/kicklib2/src/libraries/core/GUIManager.h
r8079 r8283 42 42 #include <string> 43 43 #include <CEGUIForwardRefs.h> 44 #include < boost/scoped_ptr.hpp>44 #include <CEGUIVersion.h> 45 45 #include <boost/shared_ptr.hpp> 46 #include <loki/ScopeGuard.h> 46 47 47 48 #include "util/OgreForwardRefs.h" … … 57 58 $cfile "../util/TriBool.h" // tolua_export 58 59 */ 60 61 #if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7 62 # define ORXONOX_OLD_CEGUI 63 #endif 59 64 60 65 namespace orxonox // tolua_export … … 78 83 public: 79 84 GUIManager(const std::pair<int, int>& mousePosition); 80 ~GUIManager(); 85 //! Leave empty and use cleanup() instead 86 ~GUIManager() {} 81 87 82 88 void setConfigValues(void); … … 104 110 const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export 105 111 LuaState* getLuaState(void) 106 { return this->luaState_ .get(); }112 { return this->luaState_; } 107 113 108 114 //! Returns the root window for all menu sheets … … 127 133 private: 128 134 GUIManager(const GUIManager& instance); //!< private and undefined copy c'tor (this is a singleton class) 135 136 /// Destructor that also executes when object fails to construct 137 void cleanup(); 138 129 139 void executeCode(const std::string& str); 130 140 … … 147 157 virtual void windowFocusChanged(bool bFocus); 148 158 149 scoped_ptr<CEGUI::OgreCEGUIRenderer> guiRenderer_; //!< CEGUI's interface to the Ogre Engine 150 scoped_ptr<LuaState> luaState_; //!< LuaState, access point to the Lua engine 151 scoped_ptr<CEGUI::LuaScriptModule> scriptModule_; //!< CEGUI's script module to use Lua 152 scoped_ptr<CEGUI::System> guiSystem_; //!< CEGUI's main system 159 /// Surrogate for the destructor 160 Loki::ObjScopeGuardImpl0<GUIManager, void (GUIManager::*)()> destroyer_; 161 162 #ifdef ORXONOX_OLD_CEGUI 163 CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 164 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider 165 #else 166 CEGUI::OgreRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine 167 CEGUI::OgreResourceProvider* resourceProvider_; //!< CEGUI's resource provider 168 CEGUI::OgreImageCodec* imageCodec_; 169 #endif 170 LuaState* luaState_; //!< LuaState, access point to the Lua engine 171 CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua 172 CEGUI::System* guiSystem_; //!< CEGUI's main system 153 173 shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script 154 CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider155 174 CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log 156 175 CEGUI::Window* rootWindow_; //!< Root node for all windows -
code/branches/kicklib2/src/libraries/core/GraphicsManager.cc
r8079 r8283 35 35 #include <boost/shared_array.hpp> 36 36 37 #include <OgreArchiveFactory.h>38 #include <OgreArchiveManager.h>39 37 #include <OgreFrameListener.h> 40 38 #include <OgreRoot.h> … … 60 58 #include "GUIManager.h" 61 59 #include "Loader.h" 62 #include "MemoryArchive.h"63 60 #include "PathConfig.h" 64 61 #include "ViewportEventListener.h" … … 102 99 GraphicsManager::GraphicsManager(bool bLoadRenderer) 103 100 : ogreWindowEventListener_(new OgreWindowEventListener()) 104 #if OGRE_VERSION < 0x010600105 , memoryArchiveFactory_(new MemoryArchiveFactory())106 #endif107 101 , renderWindow_(0) 108 102 , viewport_(0) … … 195 189 196 190 this->loadRenderer(); 197 198 #if OGRE_VERSION < 0x010600199 // WORKAROUND: There is an incompatibility for particle scripts when trying200 // to support both Ogre 1.4 and 1.6. The hacky solution is to create201 // scripts for the 1.6 version and then remove the inserted "particle_system"202 // keyword. But we need to supply these new scripts as well, which is why203 // there is an extra Ogre::Archive dealing with it in the memory.204 using namespace Ogre;205 ArchiveManager::getSingleton().addArchiveFactory(memoryArchiveFactory_.get());206 const StringVector& groups = ResourceGroupManager::getSingleton().getResourceGroups();207 // Travers all groups208 for (StringVector::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup)209 {210 FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo(*itGroup, "*.particle");211 for (FileInfoList::const_iterator itFile = files->begin(); itFile != files->end(); ++itFile)212 {213 // open file214 Ogre::DataStreamPtr input = ResourceGroupManager::getSingleton().openResource(itFile->filename, *itGroup, false);215 std::stringstream output;216 // Parse file and replace "particle_system" with nothing217 while (!input->eof())218 {219 std::string line = input->getLine();220 size_t pos = line.find("particle_system");221 if (pos != std::string::npos)222 {223 // 15 is the length of "particle_system"224 line.replace(pos, 15, "");225 }226 output << line << std::endl;227 }228 // Add file to the memory archive229 shared_array<char> data(new char[output.str().size()]);230 // Debug optimisations231 const std::string& outputStr = output.str();232 char* rawData = data.get();233 for (unsigned i = 0; i < outputStr.size(); ++i)234 rawData[i] = outputStr[i];235 MemoryArchive::addFile("particle_scripts_ogre_1.4_" + *itGroup, itFile->filename, data, output.str().size());236 }237 if (!files->empty())238 {239 // Declare the files, but using a new group240 ResourceGroupManager::getSingleton().addResourceLocation("particle_scripts_ogre_1.4_" + *itGroup,241 "Memory", "particle_scripts_ogre_1.4_" + *itGroup);242 }243 }244 #endif245 191 246 192 // Initialise all resources (do this AFTER the renderer has been loaded!) -
code/branches/kicklib2/src/libraries/core/GraphicsManager.h
r8079 r8283 114 114 115 115 scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h 116 #if OGRE_VERSION < 0x010600117 scoped_ptr<MemoryArchiveFactory> memoryArchiveFactory_; //!< Stores the modified particle scripts118 #endif119 116 scoped_ptr<Ogre::LogManager> ogreLogger_; 120 117 scoped_ptr<Ogre::Root> ogreRoot_; //!< Ogre's root -
code/branches/kicklib2/src/libraries/core/LuaState.cc
r7284 r8283 30 30 #include "LuaState.h" 31 31 32 #include <tolua /tolua++.h>32 #include <tolua++.h> 33 33 extern "C" { 34 34 #include <lua.h> … … 60 60 luaState_ = lua_open(); 61 61 Loki::ScopeGuard luaStateGuard = Loki::MakeGuard(&lua_close, luaState_); 62 #if LUA_VERSION_NUM == 50163 62 luaL_openlibs(luaState_); 64 #else65 luaopen_base(luaState_);66 luaopen_string(luaState_);67 luaopen_table(luaState_);68 luaopen_math(luaState_);69 luaopen_io(luaState_);70 luaopen_debug(luaState_);71 #endif72 63 73 64 // Open all available tolua interfaces … … 187 178 } 188 179 189 #if LUA_VERSION_NUM != 501190 LoadS ls;191 ls.s = code.c_str();192 ls.size = code.size();193 int error = lua_load(luaState_, &orxonox::LuaState::lua_Chunkreader, &ls, chunkname.c_str());194 #else195 180 int error = luaL_loadbuffer(luaState_, code.c_str(), code.size(), chunkname.c_str()); 196 #endif197 181 198 182 switch (error) … … 293 277 } 294 278 295 #if LUA_VERSION_NUM != 501296 const char * LuaState::lua_Chunkreader(lua_State *L, void *data, size_t *size)297 {298 LoadS* ls = static_cast<LoadS*>(data);299 if (ls->size == 0)300 return NULL;301 *size = ls->size;302 ls->size = 0;303 return ls->s;304 }305 #endif306 307 279 /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name) 308 280 { -
code/branches/kicklib2/src/libraries/core/LuaState.h
r7401 r8283 113 113 shared_ptr<ResourceInfo> getFileInfo(const std::string& filename); 114 114 115 #if LUA_VERSION_NUM != 501116 struct LoadS117 {118 const char* s;119 size_t size;120 };121 122 static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);123 #endif124 125 115 std::stringstream output_; 126 116 lua_State* luaState_; -
code/branches/kicklib2/src/libraries/core/input/KeyBinder.cc
r8079 r8283 396 396 397 397 // iterate over all modes 398 for ( size_t mode_index = 0; mode_index < 3; ++mode_index)398 for (int mode_index = 0; mode_index < 3; ++mode_index) 399 399 { 400 400 if (mode_index == (unsigned int)new_mode) // skip commands that are already in the desired mode -
code/branches/kicklib2/src/libraries/tools/Mesh.cc
r6417 r8283 69 69 this->entity_ = this->scenemanager_->createEntity("Mesh" + multi_cast<std::string>(Mesh::meshCounter_s++), meshsource); 70 70 this->entity_->setCastShadows(this->bCastShadows_); 71 72 #if OGRE_VERSION < 0x01060073 this->entity_->setNormaliseNormals(true);74 /*75 Excerpt from Ogre forum:76 "Note that the above is only for the fixed function pipeline.77 If/when you get into shaders, you'll need to manually normalize() the normal inside the vertex or pixel shader."78 79 I don't know exactly what this means, but I put this here if there will be problems with shaders.80 */81 #endif82 71 } 83 72 catch (...) -
code/branches/kicklib2/src/libraries/util/Exception.cc
r7401 r8283 95 95 throw; 96 96 } 97 catch (const CEGUI::Exception& ex) 98 { 99 return GeneralException(ex.getMessage().c_str(), ex.getLine(), 100 ex.getFileName().c_str(), ex.getName().c_str()).getDescription(); 101 } 97 102 catch (const std::exception& ex) 98 103 { 99 104 return ex.what(); 100 }101 catch (const CEGUI::Exception& ex)102 {103 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6104 return GeneralException(ex.getMessage().c_str()).getDescription();105 #else106 return GeneralException(ex.getMessage().c_str(), ex.getLine(),107 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();108 #endif109 105 } 110 106 catch (...)
Note: See TracChangeset
for help on using the changeset viewer.