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

Merge pull request #108 from paulsapps/installer

Fixes gateway script generation
paulsapps 11 лет назад
Родитель
Сommit
4c3d70319c
2 измененных файлов с 42 добавлено и 4 удалено
  1. 1 1
      dependencies/SUDM
  2. 41 3
      utilities/q-gears-launcher/src/ff7DataInstaller.cpp

+ 1 - 1
dependencies/SUDM

@@ -1 +1 @@
-Subproject commit fbc361f0e436b34e17541a48ff632e5cb08f4050
+Subproject commit c09b9cde3dfd544009593bbe5cfdb654bc1f65e9

+ 41 - 3
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -169,6 +169,31 @@ public:
 
 
 };
 };
 
 
+static std::string CreateGateWayScript(const std::string& gatewayEntityName, const std::string& targetMapName, const std::string& sourceSpawnPointName)
+{
+    return "\nEntityContainer[ \"" + gatewayEntityName + "\" ] = {\n"
+        "on_start = function(self)\n"
+        "   return 0\n"
+        "end,\n"
+        "on_enter_line = function(self, entity)\n"
+        "    return 0\n"
+        "end,\n\n"
+        "on_move_to_line = function(self, entity)\n"
+        "   return 0\n"
+        "end,\n\n"
+        "on_cross_line = function(self, entity)\n"
+        "   if entity == \"Cloud\" then\n"
+        "       load_field_map_request(\"" + targetMapName + "\", \"" + sourceSpawnPointName + "\")\n"
+        "   end\n\n"
+        "   return 0\n"
+        "end,\n\n"
+        "on_leave_line = function(self, entity)\n"
+        "   return 0\n"
+        "end,\n"
+        "}\n\n";
+
+}
+
 const int kInactiveGateWayId = 32767;
 const int kInactiveGateWayId = 32767;
 
 
 class SpawnPointDb
 class SpawnPointDb
@@ -205,6 +230,21 @@ static void FF7PcFieldToQGearsField(QGears::FLevelFilePtr& field, const std::str
 
 
     // TODO: Insert triggers into LUA script
     // TODO: Insert triggers into LUA script
   
   
+    std::string gatewayScriptData;
+    const QGears::TriggersFilePtr& triggers = field->getTriggers();
+    const auto& gateways = triggers->GetGateways();
+
+    for (size_t i = 0; i < gateways.size(); i++)
+    {
+        const QGears::TriggersFile::Gateway& gateway = gateways[i];
+        if (gateway.destinationFieldId != kInactiveGateWayId)
+        {
+            const std::string gatewayEntityName = "Gateway" + std::to_string(i);
+
+            // TODO: Obtain correct params
+            gatewayScriptData += CreateGateWayScript(gatewayEntityName, "ffvii_" + fieldIdToNameLookup.at(gateway.destinationFieldId), "Spawn_" + field->getName() + "_" + std::to_string(i));
+        }
+    }
 
 
     SUDM::FF7::Field::DecompiledScript decompiled;
     SUDM::FF7::Field::DecompiledScript decompiled;
     try
     try
@@ -214,7 +254,7 @@ static void FF7PcFieldToQGearsField(QGears::FLevelFilePtr& field, const std::str
 
 
         // Decompile to LUA
         // Decompile to LUA
         FF7FieldScriptFormatter formatter;
         FF7FieldScriptFormatter formatter;
-        decompiled = SUDM::FF7::Field::Decompile(field->getName(), rawFieldData, formatter);
+        decompiled = SUDM::FF7::Field::Decompile(field->getName(), rawFieldData, formatter, gatewayScriptData, "EntityContainer = {}\n\n");
         std::ofstream scriptFile(outDir + "/" + field->getName() + ".lua");
         std::ofstream scriptFile(outDir + "/" + field->getName() + ".lua");
         if (scriptFile.is_open())
         if (scriptFile.is_open())
         {
         {
@@ -231,8 +271,6 @@ static void FF7PcFieldToQGearsField(QGears::FLevelFilePtr& field, const std::str
     }
     }
 
 
 
 
-    const QGears::TriggersFilePtr& triggers = field->getTriggers();
-
     // Write out the map file which links all the other files together for a given field
     // Write out the map file which links all the other files together for a given field
     {
     {
         TiXmlDocument doc;
         TiXmlDocument doc;