Просмотр исходного кода

Merge pull request #116 from paulsapps/installer

Installer more fixes to try to get it working, progress blocked by issue #115
paulsapps 11 лет назад
Родитель
Сommit
a446340575

+ 5 - 1
QGearsMain/src/core/EntityModel.cpp

@@ -75,7 +75,11 @@ EntityModel::PlayAnimation(const Ogre::String& animation, Entity::AnimationState
     }
     else
     {
-        LOG_ERROR("Animation '" + animation + "' doesn't exist in model '" + m_Model->getName() + "'.");
+        // Idle is hard coded to the default animation, so don't spam crazy amounts of errors if its not found.
+        if (animation != "Idle")
+        {
+            LOG_ERROR("Animation '" + animation + "' doesn't exist in model '" + m_Model->getName() + "'.");
+        }
     }
 }
 

+ 16 - 1
QGearsMain/src/core/ScriptManager.cpp

@@ -338,12 +338,27 @@ ScriptManager::AddEntity(const ScriptManager::Type type, const Ogre::String& ent
             table["entity"] = boost::ref(*entity);
         }
 
+        // check "on_init" script
+        if (luabind::type(table["on_init"]) == LUA_TFUNCTION)
+        {
+            QueueScript script;
+            script.function = "on_init";
+            script.priority = 0;
+            script.state = lua_newthread(m_LuaState);
+            // we dont want thread to be garbage collected so we store it
+            script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
+            script.seconds_to_wait = 0;
+            script.wait = false;
+            script.yield = false;
+            script_entity.queue.push_back(script);
+        }
+
         // check "on_start" script
         if(luabind::type(table["on_start"]) == LUA_TFUNCTION)
         {
             QueueScript script;
             script.function = "on_start";
-            script.priority = 0;
+            script.priority = 1;
             script.state = lua_newthread(m_LuaState);
             // we dont want thread to be garbage collected so we store it
             script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);

+ 17 - 1
output/field_models_and_animation_metadata.xml

@@ -140,8 +140,15 @@
 
 	<!-- Renames for models to something more readable -->
 	<models>
-		<model name="aaaa" target="n_cloud"></model>
+		<model name="aaaa" target="cloud"></model>
+		<model name="acgd" target="barret"></model>
+		<model name="bxbe" target="wedge"></model>
+		<model name="bwfd" target="biggs"></model>
+		<model name="axdc" target="jessie"></model>
+		<model name="bwab" target="soldier"></model>
+		<model name="azhe" target="guard"></model>
 		<model name="adda" target="sd_red"></model>
+		
 	</models>
 
 	<!-- Renames for animations to something more readable -->
@@ -150,6 +157,15 @@
 		<animation name="aaff" target="Walk"></animation>
 		<animation name="aaga" target="Run"></animation>
 		<animation name="bvjf" target="JumpFromTrain"></animation>
+		<animation name="bxbb" target="JumpFromTrain"></animation>
+		<animation name="bxbc" target="Throw"></animation>
+		<animation name="bxbd" target="Kick"></animation>
+		<animation name="bxhc" target="Dead1"></animation>
+		<animation name="bxhd" target="LookBack"></animation>
+		<animation name="bxhe" target="Kicked"></animation>
+		<animation name="bxhf" target="Dead2"></animation>
+		<animation name="bxia" target="Throwed"></animation>
+	
 		
 		<animation name="adcb" target="Idle"></animation>
 		<animation name="adcc" target="Walk"></animation>

+ 19 - 14
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -79,6 +79,7 @@ static void exportMesh(std::string outdir, const Ogre::MeshPtr &mesh)
     sk_ser.exportSkeleton(skeleton.getPointer(), outdir +  skeleton->getName());
 
     mesh->setSkeletonName(FieldModelDir() + "/" + mesh->getSkeletonName());
+
     mesh_ser.exportMesh(mesh.getPointer(), outdir + mesh->getName());
 
 
@@ -162,7 +163,6 @@ static std::string FieldMapDir()
     return "maps/ffvii/field";
 }
 
-
 class FF7FieldScriptFormatter : public SUDM::IScriptFormatter
 {
 public:
@@ -188,7 +188,15 @@ public:
     virtual std::string AnimationName(int charId, int id) override
     {
         // Get the animation file name, then look up the friendly name of the "raw" animation
-        return QGears::FF7::NameLookup::animation(mModelLoader->getModels().at(charId).animations.at(id).name);
+        const auto& modelInfo = mModelLoader->getModels().at(charId);
+        const auto rawName = modelInfo.animations.at(id).name;
+
+        // Trim off ".yos" or whatever other crazy extension the model loader adds in
+        Ogre::String baseName;
+        QGears::StringUtil::splitBase(rawName, baseName);
+
+        QGears::StringUtil::toLowerCase(baseName);
+        return QGears::FF7::NameLookup::animation(baseName);
     }
 
     // Get name of char from its id, can't return empty
@@ -281,19 +289,10 @@ public:
 
     std::string ModelMetaDataName(const std::string& modelName)
     {
-        // TODO: Convert to name thats in the meta data
-
         // If not in meta data then just replace .hrc with .mesh
         Ogre::String baseName;
         QGears::StringUtil::splitBase(modelName, baseName);
-
-        return baseName + ".mesh";
-    }
-
-    std::string AnimationMetaDataName(const std::string& /*modelName*/, const std::string& animationName)
-    {
-        // TODO: Same as above
-        return animationName;
+        return QGears::FF7::NameLookup::model(baseName) + ".mesh";
     }
 
 //private:
@@ -406,7 +405,9 @@ static void FF7PcFieldToQGearsField(
                 xmlEntityScript->SetAttribute("name", it.first);
 
                 // TODO: Add to list of HRC's to convert, obtain name of target converted .mesh file
-                xmlEntityScript->SetAttribute("file_name", FieldModelDir() + "/" + modelAnimationDb.ModelMetaDataName(desc.hrc_name));
+                auto lowerCaseHrcName = desc.hrc_name;
+                QGears::StringUtil::toLowerCase(lowerCaseHrcName);
+                xmlEntityScript->SetAttribute("file_name", FieldModelDir() + "/" + modelAnimationDb.ModelMetaDataName(lowerCaseHrcName));
 
                 // TODO: entity_model - name, file_name,  position, direction
                 // We set char 1 position to be position of first entity_point so player is spawned in sane
@@ -762,7 +763,11 @@ void FF7DataInstaller::ConvertFields(std::string archive, std::string inputDir,
         {
             QGears::AFileManager       &afl_mgr(QGears::AFileManager::getSingleton());
             QGears::AFilePtr  a = afl_mgr.load(anim, "FFVII").staticCast<QGears::AFile>();
-            a->addTo(skeleton, anim); // TODO: Set "friendly" name, also update this name in the scripts
+
+            // Convert the FF7 name to a more readble name set in the meta data
+            Ogre::String baseName;
+            QGears::StringUtil::splitBase(anim, baseName);
+            a->addTo(skeleton, QGears::FF7::NameLookup::animation(baseName));
         }
 
         exportMesh(outDir + "/" + FieldModelDir() + "/", mesh);