Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2011, 6:32:28 PM (14 years ago)
Author:
rgrieder
Message:

Merged revisions 7940-7974 from kicklib to kicklib2.

Location:
code/branches/kicklib2
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib2

  • code/branches/kicklib2/src/libraries/core/CMakeLists.txt

    r8079 r8283  
    5858  command/ArgumentCompletionFunctions.cc
    5959  ConfigFileManager.cc
    60   MemoryArchive.cc
    6160  PathConfig.cc
    6261COMPILATION_END
     
    9897    ${CEGUI_LIBRARY}
    9998    ${CEGUILUA_LIBRARY}
    100     ${LUA_LIBRARIES}
     99    ${CEGUI_TOLUA_LIBRARY}
     100    ${CEGUI_OGRE_RENDERER_LIBRARY}
     101    ${LUA5.1_LIBRARY}
    101102    cpptcl_orxonox
    102     ogreceguirenderer_orxonox
    103103    ois_orxonox
    104104    tinyxml_orxonox
    105     tolua_orxonox
    106105    util
    107106  SOURCE_FILES
  • code/branches/kicklib2/src/libraries/core/CorePrereqs.h

    r8079 r8283  
    3838#include "OrxonoxConfig.h"
    3939#include <boost/version.hpp>
     40#include <CEGUIVersion.h>
    4041
    4142//-----------------------------------------------------------------------
     
    306307    class LuaScriptModule;
    307308
     309#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
    308310    class OgreCEGUIRenderer;
    309311    class OgreCEGUIResourceProvider;
    310312    class OgreCEGUITexture;
     313#else
     314    class OgreRenderer;
     315    class OgreResourceProvider;
     316    class OgreImageCodec;
     317#endif
    311318}
    312319
  • code/branches/kicklib2/src/libraries/core/GUIManager.cc

    r8079 r8283  
    3030#include "GUIManager.h"
    3131
     32#include <memory>
    3233#include <boost/bind.hpp>
    33 #include <memory>
     34#include <OgreRenderQueue.h>
     35#include <OgreRenderWindow.h>
    3436
    3537#include <CEGUIDefaultLogger.h>
     
    4345#include <elements/CEGUIListbox.h>
    4446#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>
     51extern "C" {
     52#  include <lauxlib.h>
     53}
    5054#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>
    5259#endif
    5360
     
    8996                case CEGUI::Informative: orxonoxLevel = 5; break;
    9097                case CEGUI::Insane:      orxonoxLevel = 6; break;
    91                 default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!");
     98                default: OrxAssert(false, "CEGUI log level out of range, inspect immediately!");
    9299            }
    93100            OutputHandler::getOutStream(orxonoxLevel)
     
    97104        }
    98105    };
     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
    99128
    100129    static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
     
    118147    */
    119148    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
    121158        , camera_(NULL)
    122159    {
     
    129166
    130167        // 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);
    132170        resourceProvider_ = guiRenderer_->createResourceProvider();
     171#else
     172        guiRenderer_ = &OgreRenderer::create(*GraphicsManager::getInstance().getRenderWindow());
     173        resourceProvider_ = &OgreRenderer::createOgreResourceProvider();
     174        imageCodec_ = &OgreRenderer::createOgreImageCodec();
     175#endif
    133176        resourceProvider_->setDefaultResourceGroup("General");
    134177
    135178        // Setup scripting
    136         luaState_.reset(new LuaState());
     179        luaState_ = new LuaState();
    137180        rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua");
    138181        // This is necessary to ensure that input events also use the right resource info when triggering lua functions
    139182        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
    141194        scriptModule_->setDefaultPCallErrorHandler(LuaState::ERROR_HANDLER_NAME);
    142195
     
    144197        std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
    145198        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)
    147200        ceguiLogger->setLoggingLevel(
    148201            static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1));
     
    150203
    151204        // 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
    153213
    154214        // Align CEGUI mouse with OIS mouse
     
    175235    }
    176236
    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_;
    183253    }
    184254
     
    222292    {
    223293        this->camera_ = camera;
     294#ifdef ORXONOX_OLD_CEGUI
    224295        if (camera == NULL)
    225296            this->guiRenderer_->setTargetSceneManager(0);
    226297        else
    227298            this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
     299#endif
    228300    }
    229301
     
    522594        The Listbox for which to enable (or disable) tooltips.
    523595    @param enabled
    524         Whether to enable or disabel the tooltips.
     596        Whether to enable or disable the tooltips.
    525597    */
    526598    void GUIManager::setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled)
     
    535607    {
    536608        this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
     609#else
     610        this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
     611#endif
    537612    }
    538613
  • code/branches/kicklib2/src/libraries/core/GUIManager.h

    r8079 r8283  
    4242#include <string>
    4343#include <CEGUIForwardRefs.h>
    44 #include <boost/scoped_ptr.hpp>
     44#include <CEGUIVersion.h>
    4545#include <boost/shared_ptr.hpp>
     46#include <loki/ScopeGuard.h>
    4647
    4748#include "util/OgreForwardRefs.h"
     
    5758$cfile "../util/TriBool.h" // tolua_export
    5859*/
     60
     61#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
     62#  define ORXONOX_OLD_CEGUI
     63#endif
    5964
    6065namespace orxonox // tolua_export
     
    7883    public:
    7984        GUIManager(const std::pair<int, int>& mousePosition);
    80         ~GUIManager();
     85        //! Leave empty and use cleanup() instead
     86        ~GUIManager() {}
    8187
    8288        void setConfigValues(void);
     
    104110        const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
    105111        LuaState* getLuaState(void)
    106             { return this->luaState_.get(); }
     112            { return this->luaState_; }
    107113
    108114        //! Returns the root window for all menu sheets
     
    127133    private:
    128134        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
    129139        void executeCode(const std::string& str);
    130140
     
    147157        virtual void windowFocusChanged(bool bFocus);
    148158
    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
    153173        shared_ptr<ResourceInfo>             rootFileInfo_;     //!< Resource information about the root script
    154         CEGUI::ResourceProvider*             resourceProvider_; //!< CEGUI's resource provider
    155174        CEGUI::Logger*                       ceguiLogger_;      //!< CEGUI's logger to be able to log CEGUI errors in our log
    156175        CEGUI::Window*                       rootWindow_;       //!< Root node for all windows
  • code/branches/kicklib2/src/libraries/core/GraphicsManager.cc

    r8079 r8283  
    3535#include <boost/shared_array.hpp>
    3636
    37 #include <OgreArchiveFactory.h>
    38 #include <OgreArchiveManager.h>
    3937#include <OgreFrameListener.h>
    4038#include <OgreRoot.h>
     
    6058#include "GUIManager.h"
    6159#include "Loader.h"
    62 #include "MemoryArchive.h"
    6360#include "PathConfig.h"
    6461#include "ViewportEventListener.h"
     
    10299    GraphicsManager::GraphicsManager(bool bLoadRenderer)
    103100        : ogreWindowEventListener_(new OgreWindowEventListener())
    104 #if OGRE_VERSION < 0x010600
    105         , memoryArchiveFactory_(new MemoryArchiveFactory())
    106 #endif
    107101        , renderWindow_(0)
    108102        , viewport_(0)
     
    195189
    196190        this->loadRenderer();
    197 
    198 #if OGRE_VERSION < 0x010600
    199         // WORKAROUND: There is an incompatibility for particle scripts when trying
    200         // to support both Ogre 1.4 and 1.6. The hacky solution is to create
    201         // 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 why
    203         // 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 groups
    208         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 file
    214                 Ogre::DataStreamPtr input = ResourceGroupManager::getSingleton().openResource(itFile->filename, *itGroup, false);
    215                 std::stringstream output;
    216                 // Parse file and replace "particle_system" with nothing
    217                 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 archive
    229                 shared_array<char> data(new char[output.str().size()]);
    230                 // Debug optimisations
    231                 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 group
    240                 ResourceGroupManager::getSingleton().addResourceLocation("particle_scripts_ogre_1.4_" + *itGroup,
    241                     "Memory", "particle_scripts_ogre_1.4_" + *itGroup);
    242             }
    243         }
    244 #endif
    245191
    246192        // Initialise all resources (do this AFTER the renderer has been loaded!)
  • code/branches/kicklib2/src/libraries/core/GraphicsManager.h

    r8079 r8283  
    114114
    115115        scoped_ptr<OgreWindowEventListener> ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
    116 #if OGRE_VERSION < 0x010600
    117         scoped_ptr<MemoryArchiveFactory>    memoryArchiveFactory_;    //!< Stores the modified particle scripts
    118 #endif
    119116        scoped_ptr<Ogre::LogManager>        ogreLogger_;
    120117        scoped_ptr<Ogre::Root>              ogreRoot_;                //!< Ogre's root
  • code/branches/kicklib2/src/libraries/core/LuaState.cc

    r7284 r8283  
    3030#include "LuaState.h"
    3131
    32 #include <tolua/tolua++.h>
     32#include <tolua++.h>
    3333extern "C" {
    3434#include <lua.h>
     
    6060        luaState_ = lua_open();
    6161        Loki::ScopeGuard luaStateGuard = Loki::MakeGuard(&lua_close, luaState_);
    62 #if LUA_VERSION_NUM == 501
    6362        luaL_openlibs(luaState_);
    64 #else
    65         luaopen_base(luaState_);
    66         luaopen_string(luaState_);
    67         luaopen_table(luaState_);
    68         luaopen_math(luaState_);
    69         luaopen_io(luaState_);
    70         luaopen_debug(luaState_);
    71 #endif
    7263
    7364        // Open all available tolua interfaces
     
    187178        }
    188179
    189 #if LUA_VERSION_NUM != 501
    190         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 #else
    195180        int error = luaL_loadbuffer(luaState_, code.c_str(), code.size(), chunkname.c_str());
    196 #endif
    197181
    198182        switch (error)
     
    293277    }
    294278
    295 #if LUA_VERSION_NUM != 501
    296     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 #endif
    306 
    307279    /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name)
    308280    {
  • code/branches/kicklib2/src/libraries/core/LuaState.h

    r7401 r8283  
    113113        shared_ptr<ResourceInfo> getFileInfo(const std::string& filename);
    114114
    115 #if LUA_VERSION_NUM != 501
    116         struct LoadS
    117         {
    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 #endif
    124 
    125115        std::stringstream output_;
    126116        lua_State* luaState_;
  • code/branches/kicklib2/src/libraries/core/input/KeyBinder.cc

    r8079 r8283  
    396396
    397397            // 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)
    399399            {
    400400                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  
    6969                this->entity_ = this->scenemanager_->createEntity("Mesh" + multi_cast<std::string>(Mesh::meshCounter_s++), meshsource);
    7070                this->entity_->setCastShadows(this->bCastShadows_);
    71 
    72 #if OGRE_VERSION < 0x010600
    73                 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 #endif
    8271            }
    8372            catch (...)
  • code/branches/kicklib2/src/libraries/util/Exception.cc

    r7401 r8283  
    9595            throw;
    9696        }
     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        }
    97102        catch (const std::exception& ex)
    98103        {
    99104            return ex.what();
    100         }
    101         catch (const CEGUI::Exception& ex)
    102         {
    103 #if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6
    104             return GeneralException(ex.getMessage().c_str()).getDescription();
    105 #else
    106             return GeneralException(ex.getMessage().c_str(), ex.getLine(),
    107                 ex.getFileName().c_str(), ex.getName().c_str()).getDescription();
    108 #endif
    109105        }
    110106        catch (...)
Note: See TracChangeset for help on using the changeset viewer.