Exemple #1
0
        public static void OutputJSONForWeb(string outputDir)
        {
            foreach (var mode in EnumHelpers.GetValues <GameModeSelection>().Where(x => Settings.GameDirectories.ContainsKey(x) && Directory.Exists(Settings.GameDirectories[x])))
            {
                var s = new GameSettings(mode, Settings.GameDirectories[mode], 0, 0);
                var m = (IGameManager)Activator.CreateInstance(mode.GetAttribute <GameModeAttribute>().ManagerType);

                foreach (var vol in m.GetLevels(s))
                {
                    s.EduVolume = vol.Name;
                    OutputJSONForWeb(Path.Combine(outputDir, $"{mode}{vol.Name}.json"), s);
                }
            }
        }
Exemple #2
0
        private static void SerializeSettings(ISerializer s, bool cmdLine = false)
        {
            if (!cmdLine)
            {
                GameModeSelection[] modes = EnumHelpers.GetValues <GameModeSelection>();
                foreach (GameModeSelection mode in modes)
                {
                    string dir = GameDirectories.ContainsKey(mode) ? GameDirectories[mode] : "";
                    GameDirectories[mode] = s.SerializeString("Directory" + mode.ToString(), dir);
                }
                if (Application.isEditor)
                {
                    foreach (GameModeSelection mode in modes)
                    {
                        string dir = GameDirectoriesWeb.ContainsKey(mode) ? GameDirectoriesWeb[mode] : "";
                        GameDirectoriesWeb[mode] = s.SerializeString("WebDirectory" + mode.ToString(), dir);
                    }
                }
            }
            string modeString = s.SerializeString("GameMode", SelectedGameMode.ToString(), "mode", "m");

            SelectedGameMode = Enum.TryParse <GameModeSelection>(modeString, out GameModeSelection gameMode) ? gameMode : SelectedGameMode;
            if (cmdLine)
            {
                if (FileSystem.mode == FileSystem.Mode.Web)
                {
                    string dir = GameDirectoriesWeb.ContainsKey(SelectedGameMode) ? GameDirectoriesWeb[SelectedGameMode] : "";
                    GameDirectoriesWeb[SelectedGameMode] = s.SerializeString("Directory", dir, "dir", "directory", "folder", "f", "d");
                }
                else
                {
                    string dir = GameDirectories.ContainsKey(SelectedGameMode) ? GameDirectories[SelectedGameMode] : "";
                    GameDirectories[SelectedGameMode] = s.SerializeString("Directory", dir, "dir", "directory", "folder", "f", "d");
                }
            }

            World                    = s.SerializeInt("WorldIndex", World, "wld", "w");
            EduVolume                = s.SerializeString("EduVolume", EduVolume, "volume", "vol");
            Level                    = s.SerializeInt("SelectedLevelFile", Level, "level", "lvl", "map");
            LoadFromMemory           = s.SerializeBool("LoadFromMemory", LoadFromMemory);
            ProcessName              = s.SerializeString("ProcessName", ProcessName);
            ModuleName               = s.SerializeString("ModuleName", ModuleName);
            GameBasePointer          = s.SerializeInt("GameBasePointer", GameBasePointer);
            IsGameBaseAPointer       = s.SerializeBool("IsPointer", IsGameBaseAPointer);
            FindPointerAutomatically = s.SerializeBool("FindPointerAutomatically", FindPointerAutomatically);
            UseHDCollisionSheet      = s.SerializeBool("UseHDCollisionSheet", UseHDCollisionSheet);

            ShowObjects      = s.SerializeBool("ShowObjects", ShowObjects);
            ShowTiles        = s.SerializeBool("ShowTiles", ShowTiles);
            ShowCollision    = s.SerializeBool("ShowCollision", ShowCollision);
            ShowLinks        = s.SerializeBool("ShowLinks", ShowLinks);
            ShowObjCollision = s.SerializeBool("ShowObjCollision", ShowObjCollision);

            AnimateSprites    = s.SerializeBool("AnimateSprites", AnimateSprites);
            AnimateTiles      = s.SerializeBool("AnimateTiles", AnimateTiles);
            ShowAlwaysObjects = s.SerializeBool("ShowAlwaysObjects", ShowAlwaysObjects);

            string stateModeString = s.SerializeString("StateSwitchingMode", StateSwitchingMode.ToString());

            StateSwitchingMode = Enum.TryParse(stateModeString, out StateSwitchingMode stateMode) ? stateMode : StateSwitchingMode;

            ShowEditorObjects     = s.SerializeBool("ShowEditorObjects", ShowEditorObjects);
            ScreenshotEnumeration = s.SerializeBool("ScreenshotEnumeration", ScreenshotEnumeration);
            BackupFiles           = s.SerializeBool("BackupFiles", BackupFiles);
            ShowDebugInfo         = s.SerializeBool("ShowDebugInfo", ShowDebugInfo, "debug");

            string screenshot_FileNameString = s.SerializeString("Screenshot_FileName", Screenshot_FileName.ToString());

            Screenshot_FileName       = Enum.TryParse(screenshot_FileNameString, out ScreenshotName screenshotFileName) ? screenshotFileName : Screenshot_FileName;
            Screenshot_ShowDefaultObj = s.SerializeBool("Screenshot_ShowDefaultObj", Screenshot_ShowDefaultObj);
            HideUnusedLinks           = s.SerializeBool("HideUnusedLinks", HideUnusedLinks);
            LoadIsometricMapLayer     = s.SerializeBool("LoadIsometricMapLayer", LoadIsometricMapLayer);
            GBAVV_Crash_TimeTrialMode = s.SerializeBool("GBAVV_Crash_TimeTrialMode", GBAVV_Crash_TimeTrialMode);
            Screenshot_RayWikiMode    = s.SerializeBool("Screenshot_RayWikiMode", Screenshot_RayWikiMode);
            ShowGridMap = s.SerializeBool("ShowGridMap", ShowGridMap);

            ShowDefaultObjIcons      = s.SerializeBool("ShowDefaultObjIcons", ShowDefaultObjIcons);
            ShowObjOffsets           = s.SerializeBool("ShowObjOffsets", ShowObjOffsets);
            ShowRayman               = s.SerializeBool("ShowRayman", ShowRayman);
            FollowRaymanInMemoryMode = s.SerializeBool("FollowRaymanInMemoryMode", FollowRaymanInMemoryMode);
            Tool_mkpsxiso_filePath   = s.SerializeString("Tool_mkpsxiso_filePath", Tool_mkpsxiso_filePath, "mkpsxiso");
            HideDirSettings          = s.SerializeBool("HideDirSettings", HideDirSettings);

            RandomizerSeed  = s.SerializeString("RandomizerSeed", RandomizerSeed, "RandomizerSeed");
            RandomizerFlags = (RandomizerFlags)s.SerializeInt("RandomizerFlags", (int)RandomizerFlags, "RandomizerFlags");
            RandomizeBatch  = s.SerializeBool("RandomizeBatch", RandomizeBatch, "RandomizeBatch");

            Log     = s.SerializeBool("Log", Log);
            LogFile = s.SerializeString("LogFile", LogFile);
        }
Exemple #3
0
        public async UniTask ImportDESETA(GameSettings settings, bool edu)
        {
            // TODO: Not hard-code these?
            const int desAllfixCount      = 9;
            const int etaAllfixCount      = 5;
            int       otherDesAllfixCount = edu ? 8 : 7;
            int       otherEtaAllfixCount = edu ? 5 : 4;

            // Load in the JSON files to get our mappings
            await LevelEditorData.InitAsync(settings, true);

            using (var context = new Context(settings))
            {
                GameSettings otherSettings;

                if (!edu)
                {
                    // Find the first Rayman 1 version that the user has actually set up.
                    var mode = EnumHelpers.GetValues <GameModeSelection>().Where(x => x.GetAttribute <GameModeAttribute>().EngineVersion == EngineVersion.R1_PC).First(x => Settings.GameDirectories.ContainsKey(x) && Directory.Exists(Settings.GameDirectories[x]));

                    otherSettings = new GameSettings(mode, Settings.GameDirectories[mode], settings.World, settings.Level);
                }
                else
                {
                    otherSettings = new GameSettings(GameModeSelection.RaymanEducationalPC, Settings.GameDirectories[GameModeSelection.RaymanEducationalPC], settings.World, settings.Level);
                }

                using (var otherContext = new Context(otherSettings)) {
                    // Create manager for the other game, and load its files.
                    R1_PCBaseManager otherGame = (R1_PCBaseManager)otherSettings.GetGameManager;

                    if (edu)
                    {
                        otherContext.Settings.EduVolume = otherGame.GetLevels(otherContext.Settings).First().Name;
                    }

                    // Loop through the worlds.
                    for (int w = 1; w < 7; w++)
                    {
                        context.Settings.World = otherContext.Settings.World = w;
                        var wldPath = GetWorldFilePath(context.Settings);

                        await LoadFilesAsync(context);

                        await otherGame.LoadFilesAsync(otherContext);

                        // Load our WLD file and the other game's.
                        var wld      = FileFactory.Read <R1_PC_WorldFile>(wldPath, context);
                        var otherWld = FileFactory.Read <R1_PC_WorldFile>(otherGame.GetWorldFilePath(otherContext.Settings), otherContext);

                        // Get the list of existing ETA and DES files so we know what's missing.
                        var desNames = wld.DESFileNames.ToArray();
                        var etaNames = wld.ETAFileNames.ToArray();

                        // Use the tables to get mappings from the other game onto this one.
                        var desMappings = new Dictionary <int, string>();
                        var etaMappings = new Dictionary <int, string>();
                        var r1wld       = otherContext.Settings.R1_World;

                        var desNameTable = otherGame.GetDESNameTable(otherContext);
                        var etaNameTable = otherGame.GetETANameTable(otherContext);

                        // Go through the other game's DES and ETA name tables, and see if any one
                        // is missing from Designer.
                        for (int iDes = 0; iDes < desNameTable.Length; iDes++)
                        {
                            var desName = desNameTable[iDes];
                            if ((desName == null) || (desName == "N/A"))
                            {
                                continue;
                            }
                            if (!desNames.Contains($"{desName}.DES"))
                            {
                                // The DES is specified in the JSON file, but doesn't exist in the WLD file.
                                // Add it to the copy list.
                                desMappings[iDes] = $"{desName}.DES";

                                Debug.Log($"Mapping DES {iDes} to {desName}");
                            }
                        }
                        for (int iEta = 0; iEta < etaNameTable.Length; iEta++)
                        {
                            var etaName = etaNameTable[iEta];
                            if ((etaName == null) || (etaName == "N/A"))
                            {
                                continue;
                            }
                            if (!etaNames.Contains($"{etaName}.ETA"))
                            {
                                // The ETA is specified in the JSON file, but doesn't exist in the WLD file.
                                // Add it to the copy list.
                                etaMappings[iEta] = $"{etaName}.ETA";

                                Debug.Log($"Mapping ETA {iEta} to {etaName}");
                            }
                        }

                        // Now that we've set up the mappings, carry out the copies!
                        var newDesItems = wld.DesItems.ToList();
                        foreach (var mapping in desMappings)
                        {
                            Debug.Log($"Attempting to port DES {mapping.Key} -> {mapping.Value}");
                            newDesItems.Add(otherWld.DesItems[mapping.Key - otherDesAllfixCount - 1]);
                            wld.DesItemCount = (ushort)newDesItems.Count;
                            wld.DESFileNames[wld.DesItemCount + desAllfixCount - 1] = mapping.Value;
                        }
                        wld.DesItems = newDesItems.ToArray();

                        var newEtaItems = wld.Eta.ToList();
                        foreach (var mapping in etaMappings)
                        {
                            Debug.Log($"Attempting to port ETA {mapping.Key} -> {mapping.Value}");
                            newEtaItems.Add(otherWld.Eta[mapping.Key - otherEtaAllfixCount]);
                            wld.ETAFileNames[newEtaItems.Count + etaAllfixCount - 1] = mapping.Value;
                        }
                        wld.Eta = newEtaItems.ToArray();

                        // Save the WLD
                        FileFactory.Write <R1_PC_WorldFile>(wldPath, context);
                    }
                }
            }

            // Beef up the memory allocation if necessary.
            await IncreaseMemAlloc(settings);
        }