mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2026-08-15 23:35:45 +00:00
Initial commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
require_once("./BuildScript/Mission.php");
|
||||
require_once("./BuildScript/Script.php");
|
||||
require_once("./BuildScript/Warehouses.php");
|
||||
|
||||
if (!is_dir("./_DebugOutput"))
|
||||
{
|
||||
mkdir("./_DebugOutput");
|
||||
}
|
||||
|
||||
function packMiz($theaterJson, $debugMode)
|
||||
{
|
||||
echo " Writing ZIP file...\n";
|
||||
$zip = new ZipArchive();
|
||||
|
||||
$suffix = "";
|
||||
if ($debugMode)
|
||||
$suffix = " [DEBUG]";
|
||||
|
||||
$filename = "./The Universal Mission - ".$theaterJson["displayName"]."$suffix.miz";
|
||||
|
||||
if ($zip->open($filename, ZipArchive::CREATE) !== true)
|
||||
return false;
|
||||
|
||||
$zip->addFromString("mission", createMissionTable($theaterJson));
|
||||
$zip->addFile("./Miz/Options.lua", "options");
|
||||
$zip->addFromString("theatre", $theaterJson["dcsID"]);
|
||||
$zip->addFromString("warehouses", createWarehousesTable($theaterJson));
|
||||
$zip->addFromString("l10n/DEFAULT/dictionary", "dictionary = { }\n");
|
||||
$zip->addFromString("l10n/DEFAULT/Script.lua", createScript($theaterJson, $debugMode));
|
||||
|
||||
$resourceTable = "mapResource =\n{\n\t[\"Script.lua\"] = \"Script.lua\",\n";
|
||||
$mediaFiles = scandir("./Media");
|
||||
foreach ($mediaFiles as $mediaFile) {
|
||||
if (!is_file("./Media/$mediaFile")) continue;
|
||||
$zip->addFile("./Media/$mediaFile", "l10n/DEFAULT/$mediaFile");
|
||||
$resourceTable .= "\t[\"$mediaFile\"] = \"$mediaFile\",\n";
|
||||
}
|
||||
$resourceTable .= "}\n";
|
||||
$zip->addFromString("l10n/DEFAULT/mapResource", $resourceTable);
|
||||
|
||||
$zip->close();
|
||||
echo " Done!\n\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
$theaterFiles = scandir("./Theaters");
|
||||
foreach ($theaterFiles as $theaterFile)
|
||||
{
|
||||
if (($theaterFile === ".") || ($theaterFile === "..")) continue;
|
||||
if (!str_ends_with(strtolower($theaterFile), ".json")) continue;
|
||||
|
||||
$theaterJson = json_decode(file_get_contents("./Theaters/$theaterFile"), true);
|
||||
if ($theaterJson == null)
|
||||
{
|
||||
echo "WARNING: Failed to open scenario \"".$theaterFile."\"...\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
echo "Building scenario \"".$theaterFile."\"...\n";
|
||||
for ($i = 0; $i <= 1; $i++)
|
||||
{
|
||||
packMiz($theaterJson, $i == 1);
|
||||
}
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user