Пример #1
0
        private WFR _WCC_GenerateNavData(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- WCC_LITE: GENERATE NAVDATA pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            try
            {
                WCC_Command cmd = new pathlib()
                {
                    RootSearchDir = settings.DIR_WCC_DEPOT_WORLDS(),
                    FilePattern   = "*.w2w"
                };

                settings.LOGGER.LogString("done.");
                return(WCC_Task.RunCommandSync(cmd));
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }
Пример #2
0
        private WFR _WCC_GenerateTextureCache(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- WCC_LITE: GENERATE TEXTURE CACHE pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            if (!Directory.Exists(Path.Combine(settings.DIR_UNCOOKED_TEXTURES(), settings.DIR_DLC_GAMEPATH())))
            {
                settings.LOGGER.LogString($"WARNING: no textures found in {Path.Combine(settings.DIR_UNCOOKED_TEXTURES(), settings.DIR_DLC_GAMEPATH())}");
                return(WFR.WFR_Error);
            }

            try
            {
                WFR result_cook  = WFR.WFR_Error;
                WFR result_cache = WFR.WFR_Error;

                if (Directory.Exists(settings.DIR_COOKED_TEXTURES_DB()))
                {
                    Directory.Delete(settings.DIR_COOKED_TEXTURES_DB());
                }

                // cook textures

                WCC_Command cook = new cook()
                {
                    Platform = platform.pc,
                    mod      = settings.DIR_UNCOOKED_TEXTURES(),
                    basedir  = settings.DIR_UNCOOKED_TEXTURES(),
                    outdir   = settings.DIR_COOKED_DLC()
                };
                result_cook = WCC_Task.RunCommandSync(cook);
                if (result_cook == WFR.WFR_Error)
                {
                    return(WFR.WFR_Error);
                }

                // move so it is separated from "normal" files cook.db
                if (File.Exists(Path.Combine(settings.DIR_COOKED_DLC(), "cook.db")))
                {
                    File.Delete(Path.Combine(settings.DIR_COOKED_DLC(), "cook.db"));
                }

                // build texture cache
                WCC_Command buildcache = new buildcache()
                {
                    builder  = cachebuilder.textures,
                    DataBase = settings.DIR_COOKED_TEXTURES_DB(),
                    basedir  = settings.DIR_UNCOOKED_TEXTURES(),
                    Out      = Path.Combine(settings.DIR_DLC_CONTENT(), "texture.cache"),
                    Platform = platform.pc
                };
                result_cache = WCC_Task.RunCommandSync(buildcache);
                if (result_cache == WFR.WFR_Error)
                {
                    return(WFR.WFR_Error);
                }

                settings.LOGGER.LogString("done.");
                return(WFR.WFR_Finished);
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }
Пример #3
0
        private WFR _WCC_analyze(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- WCC_LITE: ANALYZE FILES pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            try
            {
                if (!Directory.Exists(settings.DIR_TMP()))
                {
                    Directory.CreateDirectory(settings.DIR_TMP());
                }

                // process all worlds IF any world was generated
                if (settings.ENCODE_WORLD || settings.WCC_ANALYZE_WORLD)
                {
                    //get all folders inside the levels directory
                    string levelDir = Path.Combine(settings.DIR_UNCOOKED(), settings.DIR_DLC_GAMEPATH(), "levels");
                    var    levels   = Directory.GetDirectories(levelDir);

                    for (int i = 0; i < levels.Length; i++)
                    {
                        string level     = levels[i]; //path
                        string worldname = Path.GetDirectoryName(level);
                        settings.LOGGER.LogString($"analyze world for: {worldname}...");

                        //check i w2w file in subfolder?
                        string worldfile = Path.Combine(levelDir, worldname, $"{worldname}.w2w");
                        if (File.Exists(worldfile))
                        {
                            //LOG WCC_LITE: ANALYZE WORLD FOR !WORLDNAME!

                            //call wcc_lite

                            WCC_Command cmd = new analyze()
                            {
                                Analyzer = analyzers.world,
                                Object   = Path.Combine(settings.DIR_DLC_GAMEPATH(), "levels", worldname, $"{worldname}.w2w"),
                                Out      = Path.Combine(settings.DIR_TMP(), $"{settings.SEEDFILE_PREFIX}world.{worldname}.files")
                            };
                            WFR result = WCC_Task.RunCommandSync(cmd);

                            //if any wcc operation fails return
                            if (result == WFR.WFR_Error)
                            {
                                return(WFR.WFR_Error);
                            }
                        }
                    }
                }
                else //process dlc IF something changed
                {
                    if (settings.ENCODE_QUEST || settings.WCC_IMPORT_MODELS)
                    {
                        //LOG WCC_LITE: ANALYZE DLC
                        //call wcc_lite

                        WCC_Command cmd = new analyze()
                        {
                            Analyzer = analyzers.r4dlc,
                            reddlc   = Path.Combine(settings.DIR_DLC_GAMEPATH(), $"dlc{settings.MODNAME}.reddlc"),
                            Out      = Path.Combine(settings.DIR_TMP(), $"{settings.SEEDFILE_PREFIX}dlc{settings.MODNAME}.files")
                        };
                        return(WCC_Task.RunCommandSync(cmd));
                    }
                }

                settings.LOGGER.LogString("done.");
                return(WFR.WFR_Finished);
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }
Пример #4
0
        private WFR _Encode_speech(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- ENCODING SPEECH pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            try
            {
                // GENERATING LIPSYNC ANIMATIONS
                if (Directory.Exists(settings.DIR_PHONEMES()))
                {
                    settings.LOGGER.LogString($"GENERATING LIPSYNC ANIMATIONS");

                    string file = Directory.GetFiles(settings.DIR_PHONEMES(), "*.phonemes", SearchOption.AllDirectories).First();

                    //call encoder

                    var encoder = new w3speech_lipsync_creator()
                    {
                        CreateLipsync   = file,
                        OutputDirectory = settings.DIR_AUDIO_WEM(),
                        RepoDirectory   = settings.dir_repo_lipsync(),
                        LogLevel        = settings.LOG_LEVEL
                    };
                    if (RAD_Task.RunCommandSync(encoder) == WFR.WFR_Error)
                    {
                        return(WFR.WFR_Error);
                    }
                }

                // ENCODING LIPSYNC ANIMATIONS TO CR2W
                if (Directory.Exists(settings.DIR_AUDIO_WEM()))
                {
                    settings.LOGGER.LogString($"ENCODING LIPSYNC ANIMATIONS TO CR2W");

                    //call encoder

                    var encoder = new w3speech()
                    {
                        Encode   = settings.DIR_AUDIO_WEM(),
                        LogLevel = settings.LOG_LEVEL
                    };
                    if (RAD_Task.RunCommandSync(encoder) == WFR.WFR_Error)
                    {
                        return(WFR.WFR_Error);
                    }
                }

                // CREATING W3SPEECH FILE
                if (Directory.Exists(settings.DIR_AUDIO_WEM()))
                {
                    settings.LOGGER.LogString($"CREATING W3SPEECH FILE");

                    //call encoder FIXME

                    var pack = new w3speech()
                    {
                        Pack            = settings.DIR_AUDIO_WEM(),
                        OutputDirectory = settings.DIR_DLC_CONTENT(),
                        Language        = settings.language,
                        LogLevel        = settings.LOG_LEVEL
                    };
                    if (RAD_Task.RunCommandSync(pack) == WFR.WFR_Error)
                    {
                        return(WFR.WFR_Error);
                    }
                }

                // UPDATING DLC W3SPEECH FILE
                settings.LOGGER.LogString($"UPDATING DLC W3SPEECH FILE");


                string speech_packed_file = Path.Combine(settings.DIR_DLC_CONTENT(), $"speech.{settings.language}.w3speech.packed");
                string speech_final_file  = Path.Combine(settings.DIR_DLC_CONTENT(), $"{settings.language}pc.w3speech");

                if (File.Exists(speech_final_file))
                {
                    File.Delete(speech_final_file);
                }
                File.Move(speech_packed_file, speech_final_file);

                settings.LOGGER.LogString("done.");
                return(WFR.WFR_Finished);
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }
Пример #5
0
        private WFR _Encode_world(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- ENCODING WORLD pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            try
            {
                if (!Directory.Exists(settings.DIR_OUTPUT_WORLD()))
                {
                    Directory.CreateDirectory(settings.DIR_OUTPUT_WORLD());
                }
                if (!Directory.Exists(settings.DIR_TMP()))
                {
                    Directory.CreateDirectory(settings.DIR_TMP());
                }

                string sp    = $"{settings.WORLD_DEF_PREFIX}*.yml";
                var    files = Directory.GetFiles(settings.DIR_DEF_WORLD(), sp, SearchOption.AllDirectories);

                for (int i = 0; i < files.Length; i++)
                {
                    string filename = files[i];
                    settings.LOGGER.LogString($"encoding: {filename}...");

                    //call encoder //FIXME
                    var encoder = new w3world()
                    {
                        RepoDirectory         = settings.dir_repo_worlds(),
                        OutputDirectory       = settings.DIR_OUTPUT_WORLD(),
                        FoliageDirectory      = settings.DIR_DEF_WORLD(),
                        SkipFoliageGeneration = SKIP_FOLIAGE_GENERATION,
                        SkipWorldGeneration   = SKIP_WORLD_GENERATION,
                        Encode   = filename,
                        LogLevel = settings.LOG_LEVEL
                    };
                    WFR result = RAD_Task.RunCommandSync(encoder);
                    if (result == WFR.WFR_Error)
                    {
                        return(WFR.WFR_Error);
                    }
                }

                //set dependencies
                if (!settings.PATCH_MODE)
                {
                    settings.WCC_ANALYZE        = true;
                    settings.WCC_ANALYZE_WORLD  = true;
                    settings.WCC_COOK           = true;
                    settings.WCC_NAVDATA        = true;
                    settings.WCC_OCCLUSIONDATA  = true;
                    settings.WCC_TEXTURECACHE   = true;
                    settings.WCC_COLLISIONCACHE = true;
                    settings.WCC_REPACK_DLC     = true;
                }

                settings.LOGGER.LogString("done.");
                return(WFR.WFR_Finished);
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }
Пример #6
0
        private WFR _Encode_strings(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- ENCODING STRINGS pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            try
            {
                //if (!Directory.Exists(settings.DIR_OUTPUT_STRINGS()))
                //    Directory.CreateDirectory(settings.DIR_OUTPUT_STRINGS());
                if (!Directory.Exists(settings.DIR_DLC_CONTENT()))
                {
                    Directory.CreateDirectory(settings.DIR_DLC_CONTENT());
                }

                // collect snippets into one csv file
                settings.LOGGER.LogString($"merging strings.csv parts...");
                string STRINGS_FILE_COMBINED = Path.Combine(settings.DIR_STRINGS(), "all.en.strings.csv");
                string W3_STRINGS_FILE       = $"{STRINGS_FILE_COMBINED}.w3strings";

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

                string sp    = $"{settings.STRINGS_PART_PREFIX}*.csv";
                var    files = Directory.GetFiles(settings.DIR_STRINGS(), sp, SearchOption.AllDirectories);

                using (Stream destStream = File.OpenWrite(STRINGS_FILE_COMBINED))
                {
                    for (int i = 0; i < files.Length; i++)
                    {
                        string filename = files[i];
                        settings.LOGGER.LogString($"merging: {filename}");

                        using (Stream srcStream = File.OpenRead(filename))
                        {
                            srcStream.CopyTo(destStream);
                        }
                    }
                }

                // --- encode csv to w3strings
                if (File.Exists(STRINGS_FILE_COMBINED))
                {
                    settings.LOGGER.LogString($"encoding to w3strings...");

                    //call encoder
                    var encoder = new w3strings()
                    {
                        Encode  = STRINGS_FILE_COMBINED,
                        IdSpace = settings.idspace,
                        AutoGenerateMissingIds = true,
                        LogLevel = settings.LOG_LEVEL
                    };
                    if (RAD_Task.RunCommandSync(encoder) == WFR.WFR_Error)
                    {
                        return(WFR.WFR_Error);
                    }
                }
                // COPYING W3STRINGS INTO DLC FOLDER
                settings.LOGGER.LogString($"COPYING W3STRINGS INTO DLC FOLDER");
                if (File.Exists(W3_STRINGS_FILE))
                {
                    File.Copy(W3_STRINGS_FILE, Path.Combine(settings.DIR_DLC_CONTENT(), "en.w3strings"));
                }

                // cleanup
                if (File.Exists(W3_STRINGS_FILE))
                {
                    File.Delete(W3_STRINGS_FILE);
                }
                if (File.Exists($"{W3_STRINGS_FILE}.ws"))
                {
                    File.Delete($"{W3_STRINGS_FILE}.ws");
                }

                settings.LOGGER.LogString("done.");
                return(WFR.WFR_Finished);
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }
Пример #7
0
        private WFR _Encode_scene(WF_Settings settings)
        {
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");
            settings.LOGGER.LogString($"-- ENCODING SCENES pm: {settings.PATCH_MODE}");
            settings.LOGGER.LogString($"--------------------------------------------------------------------------");

            try
            {
                if (!Directory.Exists(settings.DIR_OUTPUT_SCENES()))
                {
                    Directory.CreateDirectory(settings.DIR_OUTPUT_SCENES());
                }

                string WILDCARD = $"{settings.SCENE_DEF_PREFIX}*.yml";
                if (!String.IsNullOrEmpty(SCENEID))
                {
                    WILDCARD = $"{settings.SCENE_DEF_PREFIX}{SCENEID}.yml";
                }
                var files = Directory.GetFiles(settings.DIR_DEF_SCENES(), WILDCARD, SearchOption.AllDirectories);

                for (int i = 0; i < files.Length; i++)
                {
                    string file      = files[i];
                    string SCENENAME = Path.GetFileNameWithoutExtension(file);
                    string SCENEID   = SCENENAME.Split(new string[] { settings.SCENE_DEF_PREFIX }, StringSplitOptions.None).Last();
                    settings.LOGGER.LogString($"encoding scene: {SCENEID}...");

                    //FIXME paths
                    //call encoder
                    RAD_Task th      = new RAD_Task();
                    var      encoder = new w2scene()
                    {
                        RepoDirectory   = settings.dir_repo_scenes(),
                        OutputDirectory = settings.DIR_OUTPUT_SCENES(),
                        Encode          = SCENENAME,
                        LogLevel        = settings.LOG_LEVEL
                    };
                    if (RAD_Task.RunCommandSync(encoder) == WFR.WFR_Error)
                    {
                        return(WFR.WFR_Error);
                    }

                    //rename scene.<sceneid>.w2scene to <sceneid>.w2scene
                    settings.LOGGER.LogString($"renaming scene to {SCENEID}.w2scene.");
                    string GENERATED_SCENE_FILE = Path.Combine(settings.DIR_OUTPUT_SCENES(), $"{SCENENAME}.w2scene");
                    File.Move(GENERATED_SCENE_FILE, Path.Combine(settings.DIR_OUTPUT_SCENES(), $"{SCENEID}.w2scene"));

                    //put generated strings into strings dir for later concatenation
                    string GENERATED_STRINGS_CSV = Path.Combine(settings.DIR_OUTPUT_SCENES(), $"{SCENENAME}.w3strings-csv");
                    string STRINGS_PART_CSV      = Path.Combine(settings.DIR_STRINGS(), $"{settings.STRINGS_PART_PREFIX}scene-{SCENEID}.csv");
                    if (File.Exists(GENERATED_STRINGS_CSV))
                    {
                        File.Move(GENERATED_STRINGS_CSV, STRINGS_PART_CSV);
                    }
                }

                //set dependencies
                if (!settings.PATCH_MODE)
                {
                    settings.ENCODE_STRINGS = true;
                    settings.WCC_COOK       = true;
                    settings.WCC_REPACK_DLC = true;
                }

                settings.LOGGER.LogString("done.");
                return(WFR.WFR_Finished);
            }
            catch (Exception ex)
            {
                settings.LOGGER.LogString(ex.ToString());
                throw ex;
            }
        }