public static void Initialize() { // Get the RomConfig RomConfig romConfig = ((JelonzoBotConfiguration)Configuration.LoadedConfiguration).RomConfig; // Load the base and update NCAs NcaWrapper = new NcaWrapper(KeysetManager.GetKeyset(), romConfig.BaseNcaPath, romConfig.UpdateNcaPath); // Create a new pack files dictionary PackFiles = new Dictionary <string, byte[]>(); // Load the pack directory IDirectory packDirectory = NcaWrapper.Romfs.OpenDirectory("/Pack", OpenDirectoryMode.Files); // Read every directory entries foreach (DirectoryEntry directoryEntry in packDirectory.Read()) { // Load the SARC Sarc sarc = new Sarc(GetRomFileFromRomfs(directoryEntry.FullPath)); // Loop over every file foreach (KeyValuePair <string, byte[]> pair in sarc) { // Add this file to the pack files dictionary PackFiles.Add("/" + pair.Key, pair.Value); } } }
private void ReadMainScript(Block romData, StringCodec codec) { var stream = romData.ToBinaryStream(RomConfig.GetOffset("Text.MainScript", romData)); MainScript = new List <List <string> >(); var offsetTableReader = new WideOffsetTableReader(stream); while (!offsetTableReader.EndOfTable) { MainScript.Add(offsetTableReader.ReadStringOffsetTable(codec, true, false)); } }
private void ReadTextBank(Block romData, StringCodec codec) { var stream = romData.ToBinaryStream(RomConfig.GetOffset("Text.Bank", romData)); var offsetTableReader = new WideOffsetTableReader(stream); RoomDescriptions = offsetTableReader.ReadStringOffsetTable(codec, false, false); ItemNames = offsetTableReader.ReadStringTable(codec); ItemDescriptions = offsetTableReader.ReadStringOffsetTable(codec, false, false); CharNames = offsetTableReader.ReadStringTable(codec); PartyCharNames = offsetTableReader.ReadStringTable(codec); EnemyNames = offsetTableReader.ReadStringTable(codec); PsiNames = offsetTableReader.ReadStringTable(codec); PsiDescriptions = offsetTableReader.ReadStringOffsetTable(codec, false, false); Statuses = offsetTableReader.ReadStringTable(codec); DefaultCharNames = offsetTableReader.ReadStringTable(codec); Skills = offsetTableReader.ReadStringTable(codec); SkillDescriptions = offsetTableReader.ReadStringOffsetTable(codec, false, false); }
protected override async Task RunAppSpecificBootTasks() { // Initialize the FileCache if first run is complete if (Configuration.LoadedConfiguration.FirstRunCompleted) { FileCache.Initialize(); } // Initialize the RomResourceLoader RomResourceLoader.Initialize(); // Initialize the BlitzLocalizer BlitzLocalizer.Initialize(); // Load GameConfigSetting XDocument gameConfig = XDocument.Load(RomResourceLoader.GetRomFile("/System/GameConfigSetting.xml")); // Get the application version int appVersion = int.Parse(gameConfig.Root .Elements("category").Where(e => e.Attribute("name").Value == "Root").First() .Elements("category").Where(e => e.Attribute("name").Value == "Project").First() .Elements("category").Where(e => e.Attribute("name").Value == "Version").First() .Elements("parameter").Where(e => e.Attribute("name").Value == "AppVersion").First() .Attribute("defaultValue").Value); // Output the ROM version await DiscordBot.LoggingChannel.SendMessageAsync($"**[JelonzoBotBootHousekepingJob]** ROM version {appVersion} was loaded by RomResourceLoader"); // Get the ROM config RomConfig romConfig = (Configuration.LoadedConfiguration as JelonzoBotConfiguration).RomConfig; // Check if this version is new compared to the last boot if (romConfig.LastRomVersion < appVersion) { // Create a JobDataMap to hold the version JobDataMap dataMap = new JobDataMap(); dataMap.Add("version", appVersion); // Upload necessary ROM data after everything is initalized await QuartzScheduler.ScheduleJob <RomDataUploadJob>("Normal", DateTime.Now.AddSeconds(5), dataMap); } }