Ver Fonte

Merge pull request #61 from paulsapps/master

small improvement to data installer, still crashes due to a hrc conversion bug
paulsapps há 11 anos atrás
pai
commit
a4f5029da1

+ 2 - 0
QGearsMain/include/common/QGearsApplication.h

@@ -38,6 +38,7 @@ namespace QGears
         Ogre::Root*         getRoot( void );
         Ogre::RenderWindow* getRenderWindow( void );
         const String&       getResourcesFilename( void );
+        Ogre::ResourceGroupManager* ResMgr() { return mResMgr; }
     protected:
         String  getWindowTitle( void ) const;
         bool    processCommandLine( int argc, char *argv[] );
@@ -76,6 +77,7 @@ namespace QGears
         std::unique_ptr<Ogre::OverlaySystem> m_overlay_system;
         Ogre::RenderWindow* m_render_window = nullptr; // Not owned
         ResourceManagerVector m_resource_managers;
+        Ogre::ResourceGroupManager* mResMgr = nullptr; // Not owned
     };
 }
 

+ 2 - 2
QGearsMain/src/common/QGearsApplication.cpp

@@ -138,7 +138,7 @@ namespace QGears
         Ogre::ConfigFile::SectionIterator section( config_file.getSectionIterator() );
 
         Ogre::String section_name, archive_type, archive_name;
-        Ogre::ResourceGroupManager &res_gm( Ogre::ResourceGroupManager::getSingleton() );
+        mResMgr = (&Ogre::ResourceGroupManager::getSingleton());
         while( section.hasMoreElements() )
         {
             section_name = section.peekNextKey();
@@ -149,7 +149,7 @@ namespace QGears
             {
                 archive_type = it->first;
                 archive_name = it->second;
-                res_gm.addResourceLocation( archive_name, archive_type, section_name, true );
+                mResMgr->addResourceLocation(archive_name, archive_type, section_name, true);
                 ++it;
             }
         }

+ 0 - 4
utilities/q-gears-launcher/.directory

@@ -1,4 +0,0 @@
-[Dolphin]
-Timestamp=2015,2,9,9,44,15
-Version=3
-ViewMode=1

+ 1 - 1
utilities/q-gears-launcher/CMakeLists.txt

@@ -1,7 +1,7 @@
 project( q-gears-launcher )
 cmake_minimum_required( VERSION 2.6 )
 set ( CMAKE_BUILD_TYPE Release )
-add_definitions ( -Wall )
+
 find_package ( Qt4 REQUIRED )
 include ( ${QT_USE_FILE} )
 include_directories (

+ 30 - 23
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -54,6 +54,12 @@ void FF7DataInstaller::Convert(std::string inputDir, std::string outputDir, cons
             mApp.getRoot()->addResourceLocation(fullPath, "LGP", "FFVII");
             ConvertFieldModels(fullPath, outputDir);
         }
+        else if (file == "field\\flevel.lgp")
+        {
+            auto fullPath = inputDir + file;
+            mApp.getRoot()->addResourceLocation(fullPath, "LGP", "FFVII");
+            ConvertFields(fullPath, outputDir);
+        }
     }
 }
 
@@ -88,35 +94,32 @@ static void exportMesh(std::string outdir, const Ogre::MeshPtr &mesh)
 
 void FF7DataInstaller::ConvertFieldModels(std::string archive, std::string outDir)
 {
-    // TODO: Find a way to query the file list from the added resource else we're having
-    // to parse/load the LGP archive twice
-    QGears::LGPArchive lgp(archive, "LGP");
-    lgp.open(archive);
-    lgp.load();
-    auto files = lgp.find("*.hrc");
-    for (const auto& file : *files)
+    Ogre::StringVectorPtr resources = mApp.ResMgr()->listResourceNames("FFVII", "*.hrc");
+    for (auto& resourceName : *resources)
     {
-        try
+        if (QGears::StringUtil::endsWith(resourceName, ".hrc"))
         {
-            Ogre::ResourcePtr hrc = QGears::HRCFileManager::getSingleton().load(file, "FFVII");
-
-            Ogre::String baseName;
-            QGears::StringUtil::splitBase(file, baseName);
-
-            auto meshName = QGears::FF7::NameLookup::model(baseName) + ".mesh";
-
-            Ogre::MeshPtr mesh(Ogre::MeshManager::getSingleton().load(meshName, "FFVII"));
-            Ogre::SkeletonPtr skeleton(mesh->getSkeleton());
-            exportMesh(outDir, mesh);
-        }
-        catch (const Ogre::Exception& ex)
-        {
-            std::cout << "ERROR converting: " << file << " Exception: " << ex.what() << std::endl;
+            //try
+            {
+                Ogre::ResourcePtr hrc = QGears::HRCFileManager::getSingleton().load(resourceName, "FFVII");
+
+                Ogre::String baseName;
+                QGears::StringUtil::splitBase(resourceName, baseName);
+
+                auto meshName = QGears::FF7::NameLookup::model(baseName) + ".mesh";
+
+                Ogre::MeshPtr mesh(Ogre::MeshManager::getSingleton().load(meshName, "FFVII"));
+                Ogre::SkeletonPtr skeleton(mesh->getSkeleton());
+                exportMesh(outDir, mesh);
+            }
+           // catch (const Ogre::Exception& ex)
+            {
+               // std::cout << "ERROR converting: " << resourceName << " Exception: " << ex.what() << std::endl;
+            }
         }
     }
 
 
-
     /*
     TODO:
     To figure out what .a files relate to which .hrc files, we need to enumerate every field
@@ -126,3 +129,7 @@ void FF7DataInstaller::ConvertFieldModels(std::string archive, std::string outDi
     */
 }
 
+void FF7DataInstaller::ConvertFields(std::string archive, std::string outDir)
+{
+
+}

+ 1 - 0
utilities/q-gears-launcher/src/ff7DataInstaller.h

@@ -14,6 +14,7 @@ public:
 
 private:
     void ConvertFieldModels(std::string archive, std::string outDir);
+    void ConvertFields(std::string archive, std::string outDir);
 
     QGears::Application mApp;
 };