dm 7 rokov pred
rodič
commit
572b3c60f1

+ 2 - 2
oxygine/src/oxygine/Clock.cpp

@@ -48,7 +48,7 @@ namespace oxygine
 
     float   Clock::getLastDTF() const
     {
-        return (float)(_lastDT/1000.0f);
+        return (float)(_lastDT / 1000.0f);
     }
 
     int Clock::getLastDT() const
@@ -114,7 +114,7 @@ namespace oxygine
             dt = 100;
         if (dt < 0)
             dt = 1;
-         
+
         if (_counter > 0)
             dt = 0;//todo destTime == srcTime ??
 

+ 5 - 5
oxygine/src/oxygine/Clock.h

@@ -11,7 +11,7 @@ namespace oxygine
         Clock();
         ~Clock();
 
-        timeMS  getTime() const;//deprecated, use F 
+        timeMS  getTime() const;//deprecated, use F
         int     getFixedStep() const;//deprecated, use F
         void    setFixedStep(float stepMS);//deprecated, use F
         timeMS  doTick();//deprecated, use F
@@ -22,14 +22,14 @@ namespace oxygine
         float   getTimeF() const;
         int     getPauseCounter() const;
         bool    isPaused() const;
-        
+
         float   getFixedStepF() const;
         float   getLastDTF() const;
-        
+
         float   getLastUpdateTimeF() const;
         float   getMultiplier() const;
 
-        
+
         /**set fixed actor update in seconds*/
         void    setFixedStepF(float step);
         void    setMultiplier(float m);
@@ -39,7 +39,7 @@ namespace oxygine
         void    resetPause();
 
         void    update(timeMS globalTime = -1);
-        
+
         float   doTickF();
 
         std::string dump() const;

+ 1 - 1
oxygine/src/oxygine/Event.h

@@ -29,7 +29,7 @@ namespace oxygine
             bool   userDataBool;
             void*  userData;
         };
-        
+
         eventType type;
         Phase phase;
         bool bubbles;

+ 1 - 1
oxygine/src/oxygine/Material.h

@@ -107,5 +107,5 @@ namespace oxygine
 
         spSTDMaterial cloneDefaultShader() const;
     };
-    
+
 }

+ 1 - 1
oxygine/src/oxygine/Serialize.h

@@ -16,7 +16,7 @@ namespace oxygine
         virtual const ResAnim*    getResAnim(const char* id) const {return safeCast<const ResAnim*>(getResource(id));}
         virtual AnimationFrame getFrame(const char* id, int col, int row) const { const ResAnim* rs = getResAnim(id);  if (rs) return rs->getFrame(col, row); return AnimationFrame();}
         virtual const ResFont*    getResFont(const char* id) const {return safeCast<const ResFont*>(getResource(id));}
-        virtual bool              getString(const char* id, std::string &result) const { return false; }
+        virtual bool              getString(const char* id, std::string& result) const { return false; }
     };
 
     struct serializedata

+ 1 - 1
oxygine/src/oxygine/UpdateState.h

@@ -6,7 +6,7 @@ namespace oxygine
     class UpdateState
     {
     public:
-        UpdateState(): time(0), dt(0), iteration(0), dtf(0){}
+        UpdateState(): time(0), dt(0), iteration(0), dtf(0) {}
 
         /**local time in  milliseconds*/
         timeMS time;

+ 2 - 2
oxygine/src/oxygine/actor/Box9Sprite.cpp

@@ -53,14 +53,14 @@ namespace oxygine
 
         RectF rect;
         rect.pos = Vector2(_guideX[0], _guideY[0]);
-        
+
         Vector2 rb;
         rb.x = getWidth() - (_frame.getWidth() - _guideX[1]);
         rb.y = getHeight() - (_frame.getHeight() - _guideY[1]);
 
         rect.setSize(rb - rect.pos);
 
-        return rect;                             
+        return rect;
     }
 
     void Box9Sprite::setVerticalMode(StretchMode m)

+ 2 - 2
oxygine/src/oxygine/actor/TextField.cpp

@@ -474,11 +474,11 @@ namespace oxygine
         needRebuild();
 
         std::string txt;
-        const char *str = node.attribute("text").as_string();
+        const char* str = node.attribute("text").as_string();
         if (data->factory->getString(str, txt))
         {
             setHtmlText(txt);
-        }        
+        }
         else
         {
             setText(str);

+ 1 - 1
oxygine/src/oxygine/core/Object.cpp

@@ -254,7 +254,7 @@ namespace oxygine
         int cbs = 0;
         if (o && o->_ref_counter)
         {
-            const EventDispatcher *ed = dynamic_cast<const EventDispatcher*>(o);
+            const EventDispatcher* ed = dynamic_cast<const EventDispatcher*>(o);
             if (ed)
                 cbs = ed->getListenersCount();
         }

+ 2 - 2
oxygine/src/oxygine/core/ZipFileSystem.cpp

@@ -11,8 +11,8 @@ namespace oxygine
 {
     namespace file
     {
-       
-        ZipFileSystem::ZipFileSystem() : FileSystem(true) 
+
+        ZipFileSystem::ZipFileSystem() : FileSystem(true)
         {
             _zips = new Zips();
         }

+ 216 - 215
oxygine/src/oxygine/core/Zips.cpp

@@ -10,287 +10,288 @@ namespace oxygine
 {
     namespace file
     {
-    bool sortFiles(const file_entry& ob1, const file_entry& ob2)
-    {
-        return strcmp_cns(ob1.name, ob2.name) < 0;
-    }
+        bool sortFiles(const file_entry& ob1, const file_entry& ob2)
+        {
+            return strcmp_cns(ob1.name, ob2.name) < 0;
+        }
 
-    bool readEntry(const file_entry* entry, file::buffer& bf)
-    {
-        bf.data.clear();
-        int r = unzGoToFilePos(entry->zp, const_cast<unz_file_pos*>(&entry->pos));
-        OX_ASSERT(r == UNZ_OK);
+        bool readEntry(const file_entry* entry, file::buffer& bf)
+        {
+            bf.data.clear();
+            int r = unzGoToFilePos(entry->zp, const_cast<unz_file_pos*>(&entry->pos));
+            OX_ASSERT(r == UNZ_OK);
 
-        unz_file_info file_info;
-        r = unzGetCurrentFileInfo(entry->zp, &file_info, 0, 0, 0, 0, 0, 0);
-        OX_ASSERT(r == UNZ_OK);
+            unz_file_info file_info;
+            r = unzGetCurrentFileInfo(entry->zp, &file_info, 0, 0, 0, 0, 0, 0);
+            OX_ASSERT(r == UNZ_OK);
 
-        unzOpenCurrentFile(entry->zp);
+            unzOpenCurrentFile(entry->zp);
 
-        bf.data.resize(file_info.uncompressed_size);
-        r = unzReadCurrentFile(entry->zp, &bf.data.front(), (int)bf.data.size());
-        OX_ASSERT(r == (int)file_info.uncompressed_size);
+            bf.data.resize(file_info.uncompressed_size);
+            r = unzReadCurrentFile(entry->zp, &bf.data.front(), (int)bf.data.size());
+            OX_ASSERT(r == (int)file_info.uncompressed_size);
 
-        unzCloseCurrentFile(entry->zp);
-        return true;
-    }
-
-    Zips::Zips() : _lock(true)
-    {
+            unzCloseCurrentFile(entry->zp);
+            return true;
+        }
 
-    }
+        Zips::Zips() : _lock(true)
+        {
 
-    Zips::~Zips()
-    {
-        reset();
-    }
+        }
 
-    void Zips::read(unzFile zp)
-    {
-        //MutexAutoLock al(_lock);
+        Zips::~Zips()
+        {
+            reset();
+        }
 
-        do
+        void Zips::read(unzFile zp)
         {
-            unz_file_pos pos;
-            unzGetFilePos(zp, &pos);
+            //MutexAutoLock al(_lock);
 
-            file_entry entry;
-            unzGetCurrentFileInfo(zp, 0, entry.name, sizeof(entry.name) - 1, 0, 0, 0, 0);
-            entry.refs = 0;
-            entry.pos = pos;
-            entry.zp = zp;
+            do
+            {
+                unz_file_pos pos;
+                unzGetFilePos(zp, &pos);
 
-            char* str = entry.name;
-            for (int i = 0; str[i]; i++)
-                str[i] = tolower(str[i]);
+                file_entry entry;
+                unzGetCurrentFileInfo(zp, 0, entry.name, sizeof(entry.name) - 1, 0, 0, 0, 0);
+                entry.refs = 0;
+                entry.pos = pos;
+                entry.zp = zp;
 
+                char* str = entry.name;
+                for (int i = 0; str[i]; i++)
+                    str[i] = tolower(str[i]);
 
-            OX_ASSERT(_files.find(entry.name) == _files.end());
 
-            _files[entry.name] = entry;
+                OX_ASSERT(_files.find(entry.name) == _files.end());
 
-        } while (unzGoToNextFile(zp) != UNZ_END_OF_LIST_OF_FILE);
+                _files[entry.name] = entry;
 
-    }
+            }
+            while (unzGoToNextFile(zp) != UNZ_END_OF_LIST_OF_FILE);
 
-    void Zips::add(const unsigned char* data, unsigned int size)
-    {
-        MutexAutoLock al(_lock);
+        }
 
-        zlib_filefunc_def ff;
-        fill_memory_filefunc(&ff);
+        void Zips::add(const unsigned char* data, unsigned int size)
+        {
+            MutexAutoLock al(_lock);
 
-        zmemdata dta;
-        dta.data = (char*)data;
-        dta.size = size;
+            zlib_filefunc_def ff;
+            fill_memory_filefunc(&ff);
 
-        unzFile zp = unzOpen2((const char*)&dta, &ff);
-        OX_ASSERT(zp);
-        if (!zp)
-            return;
+            zmemdata dta;
+            dta.data = (char*)data;
+            dta.size = size;
 
+            unzFile zp = unzOpen2((const char*)&dta, &ff);
+            OX_ASSERT(zp);
+            if (!zp)
+                return;
 
-        zpitem item;
-        item.handle = zp;
-        _zps.push_back(item);
 
-        read(zp);
-    }
+            zpitem item;
+            item.handle = zp;
+            _zps.push_back(item);
 
-    void Zips::add(std::vector<char>& data)
-    {
-        MutexAutoLock al(_lock);
+            read(zp);
+        }
 
-        zlib_filefunc_def ff;
-        fill_memory_filefunc(&ff);
+        void Zips::add(std::vector<char>& data)
+        {
+            MutexAutoLock al(_lock);
 
-        zmemdata dta;
-        dta.data = (char*)&data.front();
-        dta.size = data.size();
+            zlib_filefunc_def ff;
+            fill_memory_filefunc(&ff);
 
-        unzFile zp = unzOpen2((const char*)&dta, &ff);
-        OX_ASSERT(zp);
-        if (!zp)
-            return;
+            zmemdata dta;
+            dta.data = (char*)&data.front();
+            dta.size = data.size();
 
-        _zps.push_back(zpitem());
-        zpitem& item = _zps.back();
-        item.handle = zp;
-        std::swap(item.data, data);
+            unzFile zp = unzOpen2((const char*)&dta, &ff);
+            OX_ASSERT(zp);
+            if (!zp)
+                return;
 
-        read(zp);
-    }
+            _zps.push_back(zpitem());
+            zpitem& item = _zps.back();
+            item.handle = zp;
+            std::swap(item.data, data);
 
-    voidpf ZCALLBACK ox_fopen(voidpf opaque, const char* filename, int mode)
-    {
-        return file::open(filename, "rb");
-    }
+            read(zp);
+        }
 
-    uLong ZCALLBACK ox_fread(voidpf opaque, voidpf stream, void* buf, uLong size)
-    {
-        return file::read((handle)stream, buf, (unsigned int)size);
-    }
+        voidpf ZCALLBACK ox_fopen(voidpf opaque, const char* filename, int mode)
+        {
+            return file::open(filename, "rb");
+        }
 
-    /*
-    uLong ZCALLBACK ox_fwriteOF(voidpf opaque, voidpf stream, const void* buf, uLong size)
-    {
+        uLong ZCALLBACK ox_fread(voidpf opaque, voidpf stream, void* buf, uLong size)
+        {
+            return file::read((handle)stream, buf, (unsigned int)size);
+        }
 
-    }
-    */
+        /*
+        uLong ZCALLBACK ox_fwriteOF(voidpf opaque, voidpf stream, const void* buf, uLong size)
+        {
 
-    long ZCALLBACK ox_ftell(voidpf opaque, voidpf stream)
-    {
-        return file::tell((handle)stream);
-    }
+        }
+        */
 
-    long ZCALLBACK ox_fseek(voidpf opaque, voidpf stream, uLong offset, int origin)
-    {
-        file::seek((handle)stream, (unsigned int)offset, origin);
-        return 0;
-    }
+        long ZCALLBACK ox_ftell(voidpf opaque, voidpf stream)
+        {
+            return file::tell((handle)stream);
+        }
 
-    int ZCALLBACK ox_fclose(voidpf opaque, voidpf stream)
-    {
-        file::close((handle)stream);
-        return 0;
-    }
+        long ZCALLBACK ox_fseek(voidpf opaque, voidpf stream, uLong offset, int origin)
+        {
+            file::seek((handle)stream, (unsigned int)offset, origin);
+            return 0;
+        }
 
-    int ZCALLBACK ox_ferror(voidpf opaque, voidpf stream)
-    {
-        return 0;
-    }
+        int ZCALLBACK ox_fclose(voidpf opaque, voidpf stream)
+        {
+            file::close((handle)stream);
+            return 0;
+        }
 
-    void Zips::remove(const char* name)
-    {
-        MutexAutoLock al(_lock);
+        int ZCALLBACK ox_ferror(voidpf opaque, voidpf stream)
+        {
+            return 0;
+        }
 
-        for (size_t i = 0; i < _zps.size(); ++i)
+        void Zips::remove(const char* name)
         {
-            zpitem& item = _zps[i];
-            if (!strcmp(item.name, name))
+            MutexAutoLock al(_lock);
+
+            for (size_t i = 0; i < _zps.size(); ++i)
             {
-                for (files::iterator it = _files.begin(); it != _files.end();)
+                zpitem& item = _zps[i];
+                if (!strcmp(item.name, name))
                 {
-                    file_entry& entry = it->second;
-                    if (entry.zp == item.handle)
+                    for (files::iterator it = _files.begin(); it != _files.end();)
                     {
-                        OX_ASSERT(entry.refs == 0);
-                        it = _files.erase(it);
+                        file_entry& entry = it->second;
+                        if (entry.zp == item.handle)
+                        {
+                            OX_ASSERT(entry.refs == 0);
+                            it = _files.erase(it);
+                        }
+                        else
+                            ++it;
                     }
-                    else
-                        ++it;
-                }
 
-                unzClose(item.handle);
+                    unzClose(item.handle);
 
-                _zps.erase(_zps.begin() + i);
-                break;
+                    _zps.erase(_zps.begin() + i);
+                    break;
+                }
             }
         }
-    }
-
-    void Zips::add(const char* name)
-    {
-        MutexAutoLock al(_lock);
-
-        zlib_filefunc_def zpfs;
-        memset(&zpfs, 0, sizeof(zpfs));
-
-        zpfs.zopen_file = ox_fopen;
-        zpfs.zread_file = ox_fread;
-        zpfs.zwrite_file = 0;
-        zpfs.ztell_file = ox_ftell;
-        zpfs.zseek_file = ox_fseek;
-        zpfs.zclose_file = ox_fclose;
-        zpfs.zerror_file = ox_ferror;
-        zpfs.opaque = (void*)_zps.size();
-        //zpfs.opaque = name;
-
-        unzFile zp = unzOpen2(name, &zpfs);//todo, optimize search in zip
-        OX_ASSERT(zp);
-        if (!zp)
-            return;
-
-        zpitem item;
-        item.handle = zp;
-        strcpy(item.name, name);
-        _zps.push_back(item);
-
-        read(zp);
-    }
 
-    bool Zips::isExists(const char* name)
-    {
-        MutexAutoLock al(_lock);
-        return getEntryByName(name) != 0;
-    }
+        void Zips::add(const char* name)
+        {
+            MutexAutoLock al(_lock);
+
+            zlib_filefunc_def zpfs;
+            memset(&zpfs, 0, sizeof(zpfs));
+
+            zpfs.zopen_file = ox_fopen;
+            zpfs.zread_file = ox_fread;
+            zpfs.zwrite_file = 0;
+            zpfs.ztell_file = ox_ftell;
+            zpfs.zseek_file = ox_fseek;
+            zpfs.zclose_file = ox_fclose;
+            zpfs.zerror_file = ox_ferror;
+            zpfs.opaque = (void*)_zps.size();
+            //zpfs.opaque = name;
+
+            unzFile zp = unzOpen2(name, &zpfs);//todo, optimize search in zip
+            OX_ASSERT(zp);
+            if (!zp)
+                return;
+
+            zpitem item;
+            item.handle = zp;
+            strcpy(item.name, name);
+            _zps.push_back(item);
+
+            read(zp);
+        }
 
-    bool Zips::read(const char* name, file::buffer& bf)
-    {
-        MutexAutoLock al(_lock);
+        bool Zips::isExists(const char* name)
+        {
+            MutexAutoLock al(_lock);
+            return getEntryByName(name) != 0;
+        }
 
-        const file_entry* entry = getEntryByName(name);
-        if (!entry)
-            return false;
-        return readEntry(entry, bf);
-    }
+        bool Zips::read(const char* name, file::buffer& bf)
+        {
+            MutexAutoLock al(_lock);
 
-    bool Zips::read(const file_entry* entry, file::buffer& bf)
-    {
-        MutexAutoLock al(_lock);
-        return readEntry(entry, bf);
-    }
+            const file_entry* entry = getEntryByName(name);
+            if (!entry)
+                return false;
+            return readEntry(entry, bf);
+        }
 
-    void Zips::reset()
-    {
-        MutexAutoLock al(_lock);
-        for (zips::iterator i = _zps.begin(); i != _zps.end(); ++i)
+        bool Zips::read(const file_entry* entry, file::buffer& bf)
         {
-            zpitem& f = *i;
-            unzClose(f.handle);
+            MutexAutoLock al(_lock);
+            return readEntry(entry, bf);
         }
 
+        void Zips::reset()
+        {
+            MutexAutoLock al(_lock);
+            for (zips::iterator i = _zps.begin(); i != _zps.end(); ++i)
+            {
+                zpitem& f = *i;
+                unzClose(f.handle);
+            }
+
 
 #ifdef OX_DEBUG
-        for (files::iterator i = _files.begin(); i != _files.end(); ++i)
-        {
-            OX_ASSERT(i->second.refs == 0);
-        }
+            for (files::iterator i = _files.begin(); i != _files.end(); ++i)
+            {
+                OX_ASSERT(i->second.refs == 0);
+            }
 
 #endif
-        _zps.clear();
-        _files.clear();
-    }
+            _zps.clear();
+            _files.clear();
+        }
 
-    file_entry* Zips::getEntryByName(const char* name)
-    {
-        char str[255];
-        char* p = str;
-        while (*name)
+        file_entry* Zips::getEntryByName(const char* name)
         {
-            *p = tolower(*name);
-            name++;
-            ++p;
-        }
-        *p = 0;
+            char str[255];
+            char* p = str;
+            while (*name)
+            {
+                *p = tolower(*name);
+                name++;
+                ++p;
+            }
+            *p = 0;
 
-        files::iterator it = _files.find(str);
-        if (it != _files.end())
-            return &it->second;
+            files::iterator it = _files.find(str);
+            if (it != _files.end())
+                return &it->second;
 
-        return 0;
-    }
+            return 0;
+        }
 
-    /*
-    const file_entry* Zips::getEntry(int index)
-    {
-    return &_files[index];
-    }
+        /*
+        const file_entry* Zips::getEntry(int index)
+        {
+        return &_files[index];
+        }
 
-    size_t Zips::getNumEntries() const
-    {
-    return _files.size();
+        size_t Zips::getNumEntries() const
+        {
+        return _files.size();
+        }
+        */
     }
-    */
-     }
 }

+ 40 - 40
oxygine/src/oxygine/core/Zips.h

@@ -12,56 +12,56 @@ namespace oxygine
 {
     namespace file
     {
-    struct file_entry
-    {
-        unzFile zp;
-        char name[128];
-        unz_file_pos pos;
-        int refs;
-    };
+        struct file_entry
+        {
+            unzFile zp;
+            char name[128];
+            unz_file_pos pos;
+            int refs;
+        };
 
-    class Zips
-    {
-    public:
-        Zips();
-        ~Zips();
+        class Zips
+        {
+        public:
+            Zips();
+            ~Zips();
 
-        void reset();
+            void reset();
 
-        void add(const char* name);
-        void add(const unsigned char* data, unsigned int size);
-        void add(std::vector<char>& data);
-        void remove(const char* name);
+            void add(const char* name);
+            void add(const unsigned char* data, unsigned int size);
+            void add(std::vector<char>& data);
+            void remove(const char* name);
 
-        bool read(const char* name, file::buffer& bf);
-        bool read(const file_entry* entry, file::buffer& bf);
-        bool isExists(const char* name);
+            bool read(const char* name, file::buffer& bf);
+            bool read(const file_entry* entry, file::buffer& bf);
+            bool isExists(const char* name);
 
-        file_entry*         getEntryByName(const char* name);
-        const char*         getZipFileName(int i) const { return _zps[i].name; }
-        Mutex&              getMutex() { return _lock; }
+            file_entry*         getEntryByName(const char* name);
+            const char*         getZipFileName(int i) const { return _zps[i].name; }
+            Mutex&              getMutex() { return _lock; }
 
-    private:
-        friend class ZipFileSystem;
-        void read(unzFile zp);
+        private:
+            friend class ZipFileSystem;
+            void read(unzFile zp);
 
-        typedef std::unordered_map<std::string, file_entry> files;
-        files _files;
+            typedef std::unordered_map<std::string, file_entry> files;
+            files _files;
 
-        struct zpitem
-        {
-            unzFile handle;
-            std::vector<char> data;
-            char name[255];
+            struct zpitem
+            {
+                unzFile handle;
+                std::vector<char> data;
+                char name[255];
 
-            zpitem() : handle(0) { name[0] = 0; }
-        };
-        typedef std::vector<zpitem> zips;
-        zips _zps;
+                zpitem() : handle(0) { name[0] = 0; }
+            };
+            typedef std::vector<zpitem> zips;
+            zips _zps;
 
-        Mutex _lock;
-    };
+            Mutex _lock;
+        };
 
-    bool read(file_entry* entry, file::buffer& bf);
+        bool read(file_entry* entry, file::buffer& bf);
     }
 }

+ 2 - 2
oxygine/src/oxygine/core/oxygine.cpp

@@ -752,7 +752,7 @@ namespace oxygine
 #ifndef OXYGINE_EDITOR
             key::update();
 #endif
-            
+
             Point ds = getDisplaySize();
             //logs::messageln("SDL_GL_GetDrawableSize: %d %d", ds.x, ds.y);
 
@@ -914,7 +914,7 @@ namespace oxygine
         {
             case ep_show_error:
                 logs::error_va(format, args);
-                 OX_ASSERT_NL(!"handleErrorPolicy error.");
+                OX_ASSERT_NL(!"handleErrorPolicy error.");
                 break;
             case ep_show_warning:
                 logs::warning_va(format, args);

+ 1 - 1
oxygine/src/oxygine/tween/Tween.h

@@ -179,7 +179,7 @@ namespace oxygine
         timeMS _duration;
         timeMS _delay;
 
-        float _durationF;        
+        float _durationF;
         float _delayF;