Beispiel #1
0
 private static void Execute(string path, Tasks task)
 {
     Utils.LogInfo("{0} {1}...", true, false, task == Tasks.Unpack ? "Unpacking" : "Repacking",
                   Path.GetFileName(path));
     Utils.Command($"UnityEX.exe {(task == Tasks.Unpack ? "export" : "import")} \"{path}\"",
                   PathMgr.Thirdparty("unityex"));
     Utils.Write(" <done>", false, true);
 }
Beispiel #2
0
        internal static void Command(string argument)
        {
            using (var process = new Process())
            {
                process.StartInfo.FileName         = "cmd";
                process.StartInfo.Arguments        = $"/c {argument}";
                process.StartInfo.WorkingDirectory = PathMgr.Thirdparty();
                process.StartInfo.UseShellExecute  = false;
                process.StartInfo.CreateNoWindow   = true;

                process.Start();
                process.WaitForExit();
            }
        }
Beispiel #3
0
        private static void Execute(string lua, Tasks task)
        {
            var luaPath = lua;

            if (Program.IsDevMode == false)
            {
                lua = Path.Combine(PathMgr.Local(task == Tasks.Decompile ? "decrypted_lua" : "encrypted_lua"),
                                   Path.GetFileName(lua));
                luaPath = Path.Combine(PathMgr.Local(task == Tasks.Decompile ? "decompiled_lua" : "recompiled_lua"),
                                       Path.GetFileName(lua));

                if (File.Exists(luaPath))
                {
                    File.Delete(luaPath);
                }
            }

            Utils.LogInfo("{0} {1}...", true, false, task == Tasks.Decompile ? "Decompiling" : "Recompiling",
                          Path.GetFileName(lua).Replace(".txt", string.Empty));
            try
            {
                Utils.Command(
                    task == Tasks.Decompile
                        ? $"python main.py -f \"{lua}\" -o \"{luaPath}\""
                        : $"luajit.exe -b \"{lua}\" \"{luaPath}\"",
                    PathMgr.Thirdparty(task == Tasks.Decompile ? "ljd" : "luajit"));
            }
            catch (Exception e)
            {
                Utils.LogException(
                    $"Exception detected (Executor.2) during {(task == Tasks.Decompile ? "decompiling" : "recompiling")} {Path.GetFileName(lua).Replace(".txt", string.Empty)}",
                    e);
            }
            finally
            {
                if (File.Exists(luaPath))
                {
                    SuccessCount++;
                    Utils.Write(" <done>", false, true);
                }
                else
                {
                    FailedCount++;
                    Utils.Write(" <failed>", false, true);
                }
            }
        }
Beispiel #4
0
        private static void CheckDependencies()
        {
            var missingCount  = 0;
            var pythonVersion = 0.0;

            try
            {
                using (var process = new Process())
                {
                    process.StartInfo.FileName  = "python";
                    process.StartInfo.Arguments = "--version";
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.CreateNoWindow         = true;
                    process.StartInfo.UseShellExecute        = false;

                    process.Start();
                    var result = process.StandardOutput.ReadToEnd();
                    process.WaitForExit();

                    if (result.Contains("Python"))
                    {
                        pythonVersion = Convert.ToDouble(result.Split(' ')[1].Remove(3));
                    }
                    else
                    {
                        pythonVersion = -0.0;
                    }
                }
            }
            catch
            {
                // Empty
            }

            if (pythonVersion.Equals(0.0) || pythonVersion.Equals(-0.0))
            {
                Utils.LogDebug("No python detected", true, true);
                Utils.LogInfo(Properties.Resources.SolutionPythonMessage, true, true);
                missingCount++;
            }
            else if (pythonVersion < 3.7)
            {
                Utils.LogDebug("Detected Python version {0}.x - expected 3.7.x or newer", true, true, pythonVersion);
                Utils.LogInfo(Properties.Resources.SolutionPythonMessage, true, true);
                missingCount++;
            }

            if (!Directory.Exists(PathMgr.Thirdparty("ljd")))
            {
                Utils.LogDebug(Properties.Resources.LuajitNotFoundMessage, true, true);
                Utils.LogInfo(Properties.Resources.SolutionReferMessage, true, true);
                missingCount++;
            }

            if (!Directory.Exists(PathMgr.Thirdparty("luajit")))
            {
                Utils.LogDebug(Properties.Resources.LjdNotFoundMessage, true, true);
                Utils.LogInfo(Properties.Resources.SolutionReferMessage, true, true);
                missingCount++;
            }

            if (!Directory.Exists(PathMgr.Thirdparty("unityex")))
            {
                Utils.LogDebug(Properties.Resources.UnityExNotFoundMessage, true, true);
                Utils.LogInfo(Properties.Resources.SolutionReferMessage, true, true);
                missingCount++;
            }

            if (missingCount > 0)
            {
                Abort = true;
            }
        }