public Stream OpenFile(GameFile file) { var name = Path.ChangeExtension(file.ToString(), ".sbc"); var path = Path.Combine(dataRootPath, name); if (!File.Exists(path)) throw new FileNotFoundException(String.Format("The game data file '{0}' was not found in the current data directory at '{1}'", name, dataRootPath)); return File.OpenRead(path); }
/// <summary> /// Create the folder tree. /// </summary> /// <param name="files">Files in the tree.</param> /// <returns>Root folder</returns> public GameFolder CreateTree(GameFile[] files) { GameFolder root = new GameFolder("ROM"); root.Tags["Id"] = (ushort)this.tables.Length; this.CreateTree(root, files); return root; }
private static void TestNdsRomWrite(string romPath) { DataStream outStream = new DataStream(new MemoryStream(), 0, 0); DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read); Format romFormat = FileManager.GetFormat("Rom"); GameFile rom = new GameFile(Path.GetFileName(romPath), romStream, romFormat); romFormat.Initialize(rom); DateTime t1 = DateTime.Now; romFormat.Read(); DateTime t2 = DateTime.Now; romFormat.Write(outStream); DateTime t3 = DateTime.Now; outStream.WriteTo("/lab/nds/test.nds"); DateTime t4 = DateTime.Now; outStream.Dispose(); romStream.Dispose(); // Display time result Console.WriteLine("Time results:"); Console.WriteLine("\tRead -> {0}", t2 - t1); Console.WriteLine("\tWrite into MemoryStream -> {0}", t3 - t2); Console.WriteLine("\tWrite into FileStream -> {0}", t4 - t3); }
public override void Initialize(GameFile file, params object[] parameters) { base.Initialize(file, parameters); if (parameters.Length == 2) { this.CreateTables((GameFolder)parameters[0], (int)parameters[1]); } }
public override void Initialize(GameFile file, params object[] parameters) { base.Initialize(file, parameters); hasNumBlock = (bool)parameters[0]; isEncoded = (bool)parameters[1]; wOriginal = (bool)parameters[2]; nullTermina = (bool)parameters[3]; textSize = (int)parameters[4]; dataSize = (int)parameters[5]; longTxtSize = (int)parameters[6]; fileName = (string)parameters[7]; }
Dictionary <string, Campaign> FreshCampaigns() { Dictionary <string, Campaign> campaigns = new Dictionary <string, Campaign>(); XmlDocument doc = new XmlDocument(); using (StringReader s = new StringReader(database.text)) { doc.Load(s); } XmlNodeList struList = doc.GetElementsByTagName("Campaign"); foreach (XmlNode stru in struList) { //make new campaign and read children nodes Campaign c = new Campaign(); XmlNodeList children = stru.ChildNodes; foreach (XmlNode thing in children) { //read name of campaign if (thing.Name == "Name") { c.name = thing.InnerText; } //check if all levels are unlocked or not else if (thing.Name == "AllUnlocked") { c.allUnlocked = bool.Parse(thing.InnerText); } //read scenarios else if (thing.Name == "Levels") { XmlNodeList levels = thing.ChildNodes; foreach (XmlNode scnr in levels) { GameFile gf = new GameFile(Mode.Construct, levelFilesLocation, scnr.InnerText); c.levels.Add(gf); } } } c.StartCampaign(); campaigns[c.name] = c; } return(campaigns); }
private IEnumerable <GameFilePart> ResolveGameFilePart(GameFile file, string path) { if (File.Exists(path)) { yield return(new GameFilePart(file, path)); } if (Directory.Exists(path)) { foreach (var child in Directory.EnumerateFileSystemEntries(path).SelectMany(p => ResolveGameFilePart(file, p))) { yield return(child); } } }
void dgvMain_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { if (m_datasource != null && m_datasource.Count > e.RowIndex) { GameFile gameFile = m_datasource[e.RowIndex].Object; if (!m_properties.ContainsKey(e.ColumnIndex)) { m_properties.Add(e.ColumnIndex, gameFile.GetType().GetProperty(dgvMain.Columns[e.ColumnIndex].DataPropertyName)); } e.Value = m_properties[e.ColumnIndex].GetValue(gameFile); } }
private void PopWildEdit(GameFile type) { var file = ROM.GetFile(type); var data = file[0]; var obj = FlatBufferConverter.DeserializeFrom <EncounterArchive7b>(data); using var form = new GGWE(ROM, obj); if (form.ShowDialog() != DialogResult.OK) { return; } data = FlatBufferConverter.SerializeFrom(obj); file[0] = data; }
public void Start() { loadedFiles = GenerateFile.loadFiles(); string formattedSize = ""; for (int i = 0; i < loadedFiles.Length; i++) { GameFile fileToPrint = JsonUtility.FromJson <GameFile>(loadedFiles[i]); GameObject filePanel = Instantiate(fileSelectTemplate) as GameObject; filePanel.SetActive(true); formattedSize = formatSize(fileToPrint.getGameFileSize()); filePanel.GetComponent <FileSelectElement>().setTMP(fileToPrint.getGameFileName() + fileToPrint.getGameFileExtension(), formattedSize, fileToPrint.getGameFileID().ToString()); filePanel.transform.SetParent(fileSelectTemplate.transform.parent, false); } }
public static void Main(string[] args) { if (args.Length != 2) return; var stream = new DataStream(args[0], FileMode.Open, FileAccess.Read); var file = new GameFile(Path.GetFileName(args[0]), stream); file.SetFormat(typeof(Sadl)); file.Format.Read(); ((Sadl)file.Format).Decoder.ProgressNotifier = new ConsoleProgressNotifier(""); PrintInfo((Sadl)file.Format); file.Format.Export(args[1]); }
public void CreateNewGame() { if (!string.IsNullOrEmpty(NewGameName.text)) { string name = NewGameName.text; GameMetaFile gameMetaFile = new GameMetaFile(name); GameMetaData.GameSaves.Add(name, gameMetaFile); GameFileManager.Save(GameMetaData, "Meta"); GameFile gameFile = new GameFile(name); GameFileManager.GameFile = gameFile; GameFileManager.Save(); SceneManager.LoadScene(NextSceneName); } }
private void OnCreateGxtClick(object sender, EventArgs e) { SaveFileDialog dialog = new SaveFileDialog(); dialog.FileName = ""; dialog.Filter = "GXT file (*.gxt)|*.gxt|FXT file (*.fxt)|*.fxt"; dialog.FilterIndex = 2; dialog.Title = "Save as..."; DialogResult result = dialog.ShowDialog(); switch (result) { case DialogResult.OK: GameFile file = new GameFile(dialog.FileName); switch (file.Extension) { case ".fxt": FXTFile fxtFile = new FXTFile(file.FullPath); FXTEditorWindow fxtEditorWindow = new FXTEditorWindow(); try { fxtFile.SaveFile(); } catch (Exception ex) { MessageBox.Show(ex.Message); } fxtEditorWindow.OpenFile(fxtFile); fxtEditorWindow.Show(); break; case ".gxt": break; default: MessageBox.Show("Unknown file extention!"); break; } break; default: break; } }
private ObservableCollection <ContextAction <GameFile> > BuildActionList(GameFile file) { var collection = new ObservableCollection <ContextAction <GameFile> >(); if (file.IsBundle) { collection.Add(new GameFileContextAction { Name = "Load", Command = LoadFileCommand, File = file }); } return(collection); }
public override void Read(DataStream strIn) { uint header = new DataReader(strIn).ReadUInt32(); uint encoder = header & 0x3; uint size = header >> 3; if (encoder == 0) { File.AddFile(new GameFile(File.Name + ".dec", new DataStream(strIn, 4, strIn.Length))); return; } // Export file to decode string tempFile = Path.Combine(ExecutablePath, File.Name); var tempStream = new DataStream(new MemoryStream(), 0, 0); strIn.WriteTo(tempStream); tempStream.Seek(0, SeekMode.Origin); // Set header uint stdHeader = (Encoders[encoder].Item1) | (size << 8); tempStream.Write(BitConverter.GetBytes(stdHeader), 0, 4); // Export tempStream.WriteTo(tempFile); tempStream.Dispose(); // Decode ExecuteProgram(Encoders[encoder].Item2, "-d \"" + tempFile + "\""); // Read data var memStream = new MemoryStream(); using (var fs = new FileStream(tempFile, FileMode.Open)) fs.CopyTo(memStream); // Remove file System.IO.File.Delete(tempFile); // Create subfile var subStream = new DataStream(memStream, 0, memStream.Length); var subFile = new GameFile(File.Name + ".dec", subStream); File.AddFile(subFile); }
static void ExportText(GameFile objectFile, string value, string openedFileDir, Parameters parameters) { if (objectFile.GameData is PTP ptp) { string path = value == "" ? Path.Combine(openedFileDir, Path.GetFileNameWithoutExtension(objectFile.Name) + ".TXT") : value; var exp = ptp.ExportTXT(parameters.RemoveSplit, Static.OldEncoding()).Select(x => $"{objectFile.Name}\t{x}"); File.AppendAllLines(path, exp); } else if (objectFile.GameData is StringList strlst) { string path = value == "" ? Path.Combine(openedFileDir, Path.GetFileNameWithoutExtension(objectFile.Name) + ".TXT") : value; string[] exp = strlst.ExportText(); File.AppendAllLines(path, exp); } }
static void ImportAll(GameFile objectFile, string openedFileDir) { foreach (var item in objectFile.GameData.SubFiles) { string newpath = Path.Combine(openedFileDir, item.Name.Replace('/', '+')); FormatEnum fileType = item.GameData.Type; if (File.Exists(newpath)) { var file = GameFormatHelper.OpenFile(objectFile.Name, File.ReadAllBytes(newpath), fileType); if (file != null) { item.GameData = file.GameData; } } } }
public bool Export() { XElement files = edit.Root.Element("Files"); ConsoleCount count = new ConsoleCount( "Exporting file {0:0000} of {1:0000}", files.Elements("File").Count() ); foreach (XElement fileEdit in files.Elements("File")) { count.Show(); string path = fileEdit.Element("Path").Value; IList <string> exportPaths = fileEdit.Elements("Import") .Select(f => this.config.ResolvePath(f.Value)) .ToList(); foreach (string p in exportPaths.Select(f => System.IO.Path.GetDirectoryName(f))) { if (!System.IO.Directory.Exists(p)) { System.IO.Directory.CreateDirectory(p); } } if (exportPaths.Any()) { GameFile file = fileManager.RescueFile(path); file.Format.Read(); try { file.Format.Export(exportPaths.ToArray()); } catch (Exception ex) { //Console.WriteLine("Can not export {0}", path); //Console.WriteLine(ex.Message); if (!(ex is NotImplementedException) && !(ex is NotSupportedException)) { return(false); } } } count.UpdateCoordinates(); } return(true); }
public static FormatValidation AssignBestFormat(GameFile file) { if (file.Format != null) return null; InitializeAddins(); FormatValidation validation = AddinManager.GetExtensionObjects<FormatValidation>(false) .OrderByDescending((validat) => {validat.RunTests(file); return validat.Result;}) .FirstOrDefault(); if (validation != null) { validation.AutosetFormat = true; validation.RunTests(file); } return validation; }
public void startHash() { int selectedFileId = Int32.Parse(PlayerPrefs.GetString("chosenFileId")); loadedFiles = GenerateFile.loadFiles(); for (int i = 0; i < loadedFiles.Length; i++) { GameFile fileToPrint = JsonUtility.FromJson <GameFile>(loadedFiles[i]); if (fileToPrint.getGameFileID().ToString() == selectedFileId.ToString()) { selectedFile = fileToPrint; } } if (md5Toggle.isOn) { md5OutputField.GetComponent <TMP_InputField>().text = md5Hash(selectedFile.ToString()); } else { md5OutputField.GetComponent <TMP_InputField>().text = ""; } if (sha1Toggle.isOn) { sha1OutputField.GetComponent <TMP_InputField>().text = sha1Hash(selectedFile.ToString()); } else { sha1OutputField.GetComponent <TMP_InputField>().text = ""; } if (sha256Toggle.isOn) { sha256OutputField.GetComponent <TMP_InputField>().text = sha256Hash(selectedFile.ToString()); } else { sha256OutputField.GetComponent <TMP_InputField>().text = ""; } if (sha512Toggle.isOn) { sha512OutputField.GetComponent <TMP_InputField>().text = sha512Hash(selectedFile.ToString()); } else { sha512OutputField.GetComponent <TMP_InputField>().text = ""; } }
private void UpdateList() { Player player = new Player(null, null); try { for (int i = 0; i < MaxList; i++) { string fn = NWGameSpace.GetSaveFile(NWGameSpace.SAVEFILE_PLAYER, i); fFiles[i] = new GameFile(); fFiles[i].Exist = File.Exists(fn); if (fFiles[i].Exist) { fFiles[i].SaveTime = File.GetLastWriteTime(fn); try { NWGameSpace.LoadPlayer(i, player); fFiles[i].PlayerName = player.Name; int fx = player.Field.X; int fy = player.Field.Y; LayerEntry layer = (LayerEntry)GlobalVars.nwrDB.GetEntry(player.LayerID); string landSign = layer.GetFieldEntry(fx, fy).LandSign; LandEntry land = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(landSign); fFiles[i].LandName = land.Name; } catch (Exception ex) { Logger.Write("FilesWindow.refreshList.PlayerLoad(" + fn + "): " + ex.Message); fFiles[i].PlayerName = "<error>"; fFiles[i].LandName = "<error>"; } } else { fFiles[i].PlayerName = BaseLocale.GetStr(RS.rs_PlayerUnknown); fFiles[i].LandName = "-"; fFiles[i].SaveTime = new DateTime(); } } } finally { player.Dispose(); } }
/// <summary> /// Load a game directory and build the directory tree. /// </summary> /// <param name="message"></param> private void LoadGame(LoadGameMessage message) { // Reset data _resourceService.PurgeResources(); Groups.Clear(); if (!Directory.Exists(message.Directory)) { throw new FileNotFoundException($"Invalid directory: {message.Directory}"); } foreach (var directory in Directory.EnumerateDirectories(message.Directory)) { Groups.Add(CreateTreeGroup(directory, message.Directory)); } foreach (var file in Directory.EnumerateFiles(message.Directory).OrderBy(k => k)) { var gameFile = new GameFile { Name = file.Replace($"{message.Directory}\\", ""), Extension = Path.GetExtension(file).Replace(".", ""), Resources = new ObservableCollection <GameResource>(), SubGroups = new ObservableCollection <ResourceGroup>(), FullPath = file }; gameFile.Actions = BuildActionList(gameFile); Groups.Add(gameFile); } _currentGame = message.Game; Messenger.Default.Send(new WindowTitleMessage { Title = $"OpenNFS | {message.Directory}" }); Messenger.Default.Send(new ConsoleLogMessage { Level = MessageLevel.Info, Message = $"Loaded game. Detected: {message.Game}" }); }
public void Load(string team) { var file = new GameFile($"Depth\\{team}.txt"); for (int i = 0; i < NUM_DEPTH_TYPES; i++) { // Read the number of slots filled this.NumSlotsFilled[i] = int.Parse(file.ReadLine()); for (int ii = 0; ii < this.NumSlotsFilled[i]; ii++) { // Read type roster pos this.RosterPos[i, ii] = int.Parse(file.ReadLine()); } } }
public void Load(string name) { var file = new GameFile($"Rosters\\{name}.txt"); // Read the number of players this.NumPlayers = int.Parse(file.ReadLine()); // Load each player for (int i = 0; i < this.NumPlayers; i++) { var playerName = file.ReadLine(); this.PlayerInfo[i].Load(playerName); } }
public static void printFile() { string fileInfo = PlayerPrefs.GetString("chosenFileId"); int selectedFileId = Int32.Parse(PlayerPrefs.GetString("chosenFileId")); string[] newLoadedFiles = GenerateFile.loadFiles(); for (int i = 0; i < newLoadedFiles.Length; i++) { GameFile fileToPrint = JsonUtility.FromJson <GameFile>(newLoadedFiles[i]); if (fileToPrint.getGameFileID().ToString() == selectedFileId.ToString()) { selectedFile = fileToPrint; } } filePrint.text = selectedFile.getGameFileName() + selectedFile.getGameFileExtension(); filePrint.color = new Color32(0, 0, 0, 255); filePrint.fontStyle = FontStyles.Normal; }
public static void Main(string[] args) { if (args.Length != 2) { return; } var stream = new DataStream(args[0], FileMode.Open, FileAccess.Read); var file = new GameFile(Path.GetFileName(args[0]), stream); file.SetFormat(typeof(Sadl)); file.Format.Read(); ((Sadl)file.Format).Decoder.ProgressNotifier = new ConsoleProgressNotifier(""); PrintInfo((Sadl)file.Format); file.Format.Export(args[1]); }
public static Packer GetInstance(GameFile file) { // Another way I thought it would be faster than using reflection // but testing I got 3 seconds of difference, so... file.BaseStream.Position = file.Position; if (Zarc.IsValid(file.BaseStream)) { return(new Zarc(file)); } file.BaseStream.Position = file.Position; if (Psar.IsValid(file.BaseStream)) { return(new Psar(file)); } return(null); }
/// <summary> /// Create a folder with all the overlays of the same ARM. /// </summary> /// <param name="str">Stream to read the overlay table.</param> /// <param name="header">Header of the current ROM.</param> /// <param name="isArm9">If must read overlays from the ARM9 or ARM7.</param> /// <param name="listFiles">List with all the files in the ROM.</param> /// <returns>Folder with overlays.</returns> public static OverlayFolder FromTable(DataStream str, RomHeader header, bool isArm9, GameFile[] listFiles) { OverlayFolder overlays = new OverlayFolder(isArm9); int numOverlays; if (isArm9) { str.Seek(header.Ov9TableOffset, SeekMode.Origin); numOverlays = (int)(header.Ov9TableSize / OverlayFile.TableEntrySize); } else { str.Seek(header.Ov7TableOffset, SeekMode.Origin); numOverlays = (int)(header.Ov7TableSize / OverlayFile.TableEntrySize); } for (int i = 0; i < numOverlays; i++) overlays.AddFile(OverlayFile.FromTable(str, isArm9, listFiles)); return overlays; }
private void LoadFile(string fileName) { var gameFile = GameFile.Load(fileName); ChessGame.Load(gameFile); var moves = new List <Move>(); moves.AddRange(ChessGame.WhitePlayer.Moves); moves.AddRange(ChessGame.BlackPlayer.Moves); moves = moves.OrderBy(x => x.NumberInGame).ThenBy(x => x.Piece.Color).ToList(); foreach (var move in moves) { MoveToList(new Evaluation { Move = move }); } }
/// <summary> /// Opens the <paramref name="file"/> in it's associated editor /// </summary> /// <summary xml:lang="ru"> /// ŠŃŠŗŃŃŠ²Š°ŠµŃ ŃŠ°Š¹Š» <paramref name="file"/> Š² Š°ŃŃŠ¾ŃŠøŠøŃŠ¾Š²Š°Š½Š½ŃŠ¼ Ń ŠµŠ³Š¾ ŃŠøŠæŠ¾Š¼ ŃŠµŠ“Š°ŠŗŃŠ¾ŃŠµ /// </summary> /// <param name="file">File to be opened</param> /// <param name="file" xml:lang="ru">Š¤Š°Š¹Š» ŠŗŠ¾ŃŠ¾ŃŃŠ¹ Š½ŠµŠ¾Š±Ń Š¾Š“ŠøŠ¼Š¾ Š¾ŃŠŗŃŃŃŃ</param> public static void OpenFile(GameFile file) { // TODO: ŃŠ¾Š·Š“Š°ŃŃ Š¾Š±ŃŠµŠŗŃ Ń ŃŠ°ŃŃŠøŃŠµŠ½ŠøŃŠ¼Šø ŃŠ°Š¹Š»Š¾Š² switch (file.Extension.ToLower()) { case ".gxt": GXTEditorWindow gxtEditorWindow = new GXTEditorWindow(); gxtEditorWindow.OpenFile(new GXTFile(file.FullPath)); gxtEditorWindow.Show(); break; case ".fxt": FXTEditorWindow fxtEditorWindow = new FXTEditorWindow(); fxtEditorWindow.OpenFile(new FXTFile(file.FullPath)); fxtEditorWindow.Show(); break; case ".ide": TestWindow testWindow = new TestWindow(); testWindow.OpenFile(new IDEFile(file.FullPath)); testWindow.Show(); break; case ".ipl": case ".dat": case ".txt": case ".log": case ".cfg": case ".ini": case ".zon": DataEditorWindow dataEditorWindow = new DataEditorWindow(); dataEditorWindow.OpenFile(new TextFile(file.FullPath)); dataEditorWindow.Show(); break; case ".img": FileBrowserWindow.GetInstance().OpenArchive((ArchiveFile)file); break; default: MessageBox.Show("Unsupported file type.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } }
public BMDEditorVM(GameFile objbmd) { FromCommand = new RelayCommand(Replace); TestCommand = new RelayCommand(Test); if (objbmd.GameData is BMD bmd) { EncodingEW = new EventWrapperINPC(Static.EncodingManager, this); int sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(ApplicationSettings.AppSetting.Default.BMDFontDefault); if (sourceInd >= 0) { sourceFont = sourceInd; } else { sourceFont = 0; } sourceInd = Static.EncodingManager.GetPersonaEncodingIndex(ApplicationSettings.AppSetting.Default.BMDFontDestDefault); if (sourceInd >= 0) { destFont = sourceInd; } else { destFont = 0; } foreach (var a in bmd.Name) { NameList.Add(new BMDNameVM(a, sourceFont)); } foreach (var a in bmd.Msg) { MsgList.Add(new BMDMsgVM(a, sourceFont)); } Name = objbmd.Name; } }
public SPDTextureVM(GameFile dds, IList <SPDKey> keylist, int index) { if (dds == null) { throw new ArgumentNullException(nameof(dds)); } if (keylist == null) { throw new ArgumentNullException(nameof(keylist)); } texture = dds; TextureImage = (dds.GameData as IImage).GetBitmap().GetBitmapSource(); foreach (var a in keylist.Where(x => x.TextureIndex == index)) { KeyList.Add(new SPDKeyVM(a)); } }
private static void SearchGame(string romPath) { // Create file of the ROM DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read); GameFile rom = new GameFile("Game.nds", romStream); Format romFormat = new Rom(); romFormat.Initialize(rom); // Read the ROM Console.WriteLine("Reading: {0}", romPath); rom.Format.Read(); // For each ARM and Overlay, search the string. foreach (GameFile systemFile in rom.Folders[1].GetFilesRecursive(false)) { SearchAndShow(systemFile); } }
public SPRTextureVM(GameFile tmx, IList <SPRKey> keylist, int textureindex) { if (tmx == null) { throw new ArgumentNullException(nameof(tmx)); } if (keylist == null) { throw new ArgumentNullException(nameof(keylist)); } texture = tmx; TextureImage = (tmx.GameData as IImage).GetBitmap().GetBitmapSource(); foreach (var a in keylist.Where(x => x.mTextureIndex == textureindex)) { KeyList.Add(new SPRKeyVM(a)); } }
private void ExtractAsync(GameFile entry, string destination) { CancellationTokenSource tokenSource = new CancellationTokenSource(); ProgressBarWindow window = new ProgressBarWindow(); window.StartDialogWithAction(() => entry.ExtractAsync(destination, tokenSource.Token, (progress, description) => { window.InvokeOnThread(new Action(() => { window.SetProgress(progress); window.SetOperationText(description); if (progress == 100) { window.Close(); } })); }), tokenSource); }
static void ImportImage(GameFile objectFile, string value, string openedFileDir, Parameters parameters) { if (objectFile.GameData is IImage image) { if (parameters.Size >= 0) { if (objectFile.GameData is FNT fnt) { fnt.Resize(parameters.Size); } } string path = value == "" ? Path.Combine(openedFileDir, Path.GetFileNameWithoutExtension(objectFile.Name) + ".PNG") : value; if (File.Exists(path)) { image.SetBitmap(AuxiliaryLibraries.WPF.Tools.ImageTools.OpenPNG(path).GetBitmap()); } } }
//Functions to populate the InspectorView public void elaborate(GameObject currentTemplate) { int ins = int.Parse(currentTemplate.GetComponent <fileAnalyzeElement>().fileID.text); temp = JsonUtility.FromJson <GameFile>(loadedFiles[ins]); void resetHighlight() { GameObject parentGameObject = GameObject.Find("DirectoryContent"); List <GameObject> childGameObjects = new List <GameObject>(); int numOfFiles = 24; for (int i = 0; i <= numOfFiles; i++) { parentGameObject.transform.GetChild(i).gameObject.GetComponent <fileAnalyzeElement>().fileName.color = new Color32(230, 230, 230, 255); parentGameObject.transform.GetChild(i).gameObject.GetComponent <fileAnalyzeElement>().filePath.color = new Color32(230, 230, 230, 255); parentGameObject.transform.GetChild(i).gameObject.GetComponent <fileAnalyzeElement>().fileDate.color = new Color32(230, 230, 230, 255); parentGameObject.transform.GetChild(i).gameObject.GetComponent <fileAnalyzeElement>().fileType.color = new Color32(230, 230, 230, 255); parentGameObject.transform.GetChild(i).gameObject.GetComponent <fileAnalyzeElement>().fileSize.color = new Color32(230, 230, 230, 255); } } resetHighlight(); currentTemplate.GetComponent <fileAnalyzeElement>().fileName.color = new Color32(222, 162, 73, 255); currentTemplate.GetComponent <fileAnalyzeElement>().filePath.color = new Color32(222, 162, 73, 255); currentTemplate.GetComponent <fileAnalyzeElement>().fileDate.color = new Color32(222, 162, 73, 255); currentTemplate.GetComponent <fileAnalyzeElement>().fileType.color = new Color32(222, 162, 73, 255); currentTemplate.GetComponent <fileAnalyzeElement>().fileSize.color = new Color32(222, 162, 73, 255); if (firstBtn == 0) { chosenElaborate(1); hexBtn.GetComponent <Button>().interactable = true; stringsBtn.GetComponent <Button>().interactable = true; metaBtn.GetComponent <Button>().interactable = true; firstBtn = 1; } else { chosenElaborate(chosenBtn); } }
public IActionResult Play(string name) { GameFile file = null; GameFiles.Singleton.ForEach((n) => { if (n.Name.Equals(name)) { file = n; } }); if (file != null && SessionInformation.Singleton.IsSignedIn) { return(View(file)); } else if (!SessionInformation.Singleton.IsSignedIn) { return(Redirect("/Identity/Account/Login")); } return(RedirectToAction("Index", 0)); }
private static void TestNdsRomRead(string romPath, string filePath, string outPath) { DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read); Format romFormat = FileManager.GetFormat("Rom"); GameFolder main = new GameFolder("main"); GameFile rom = new GameFile(Path.GetFileName(romPath), romStream, romFormat); main.AddFile(rom); romFormat.Initialize(rom); XDocument xmlGame = new XDocument(); // TODO: Replace with ExampleGame.xml xmlGame.Add(new XElement("GameInfo", new XElement("Files"))); FileManager.Initialize(main, FileInfoCollection.FromXml(xmlGame)); GameFile file = FileManager.GetInstance().RescueFile(filePath); if (file != null) file.Stream.WriteTo(outPath); romStream.Dispose(); }
/// <summary> /// Serialize function /// åŗååę¹ę³ /// </summary> /// <param name="info">info of Publish(Publishäæ”ęÆ)</param> /// <param name="projFile">Project file(锹ē®ę件)</param> /// <returns>error info(éčÆÆäæ”ęÆ)</returns> public string Serialize(PublishInfo info, GameFile projFile) { //csd fullpath //csd č·Æå¾ string src = info.SourceFilePath; //des fullpath //csdč½¬ę¢åēč·Æå¾ FilePath desFilePath = info.DestinationFilePath; //resources fullpath //å½å锹ē®čµęŗč·Æå¾ string res = Services.ProjectOperations.CurrentSelectedSolution.ItemDirectory; //serialize code //åŗåå代ē ååØäøé¢ return ""; }
public override void Initialize(GameFile file, params object[] parameters) { base.Initialize(file, parameters); if (parameters.Length == 1) this.header = (RomHeader)parameters[0]; }
private void UpdateQueue(GameFile file) { foreach (GameFile dependency in file.Dependencies) this.UpdateQueue(dependency); // Checks if it's in the queue if (this.updateQueue.Contains(file.Path)) return; // Get the higher position in the queue of it's dependencies int depTopPosition = this.updateQueue.Count; foreach (GameFile dependency in file.Dependencies) { int depPosition = this.updateQueue.IndexOf(dependency.Path); if (depPosition < depTopPosition) depTopPosition = depPosition; } // Insert the file just above the top dependency this.updateQueue.Insert(depTopPosition, file.Path); }
protected abstract string[] GuessDependencies(GameFile file);
/// <summary> /// Read the internal info of a ROM file. /// </summary> /// <param name="str">Stream to read from.</param> public override void Read(DataStream str) { // Read header str.Seek(0, SeekMode.Origin); this.header = new RomHeader(); this.header.Read(str); // Read banner var bannerStream = new DataStream(str, this.header.BannerOffset, Banner.Size); var bannerFile = new GameFile("Banner", bannerStream); this.banner = new Banner(); this.banner.Initialize(bannerFile); this.banner.Read(); // Read file system: FAT and FNT this.fileSys = new FileSystem(); this.fileSys.Initialize(null, this.header); this.fileSys.Read(str); // Assign common tags (they will be assigned recursively) this.File.Tags["_Device_"] = "NDS"; this.File.Tags["_MakerCode_"] = this.header.MakerCode; this.File.Tags["_GameCode_"] = this.header.GameCode; // Get the ROM folders with files and system files. this.fileSys.SystemFolder.AddFile(bannerFile); this.File.AddFolder(this.fileSys.Root); this.File.AddFolder(this.fileSys.SystemFolder); }
private void CreateTree(GameFolder currentFolder, GameFile[] listFile) { int folderId = ((ushort)currentFolder.Tags["Id"] > 0x0FFF) ? (ushort)currentFolder.Tags["Id"] & 0x0FFF : 0; // Add files foreach (ElementInfo fileInfo in this.tables[folderId].Files) { listFile[fileInfo.Id].Name = fileInfo.Name; currentFolder.AddFile(listFile[fileInfo.Id]); } // Add subfolders foreach (ElementInfo folderInfo in this.tables[folderId].Folders) { GameFolder subFolder = new GameFolder(folderInfo.Name); subFolder.Tags["Id"] = folderInfo.Id; this.CreateTree(subFolder, listFile); currentFolder.AddFolder(subFolder); } }
/// <summary> /// Creates the terrain that is immediately around the player's spawn point. /// If loading from a file, loads the existing terrain from a file. /// </summary> public void GenerateInitialChunks() { gameFile = null; bool fileExists = !string.IsNullOrEmpty(ExistingFile); // If we already have a file, we need to load all the chunks from it. // This is preliminary stuff that just makes sure the file exists and can be loaded. if (fileExists) { LoadingMessage = "Loading " + ExistingFile; gameFile = new GameFile(ExistingFile, true); Sky.TimeOfDay = gameFile.Data.Metadata.TimeOfDay; WorldOrigin = gameFile.Data.Metadata.WorldOrigin; WorldScale = gameFile.Data.Metadata.WorldScale; ChunkWidth = gameFile.Data.Metadata.ChunkWidth; ChunkHeight = gameFile.Data.Metadata.ChunkHeight; if (gameFile.Data.Metadata.OverworldFile != null && gameFile.Data.Metadata.OverworldFile != "flat") { LoadingMessage = "Loading world " + gameFile.Data.Metadata.OverworldFile; Overworld.Name = gameFile.Data.Metadata.OverworldFile; DirectoryInfo worldDirectory = Directory.CreateDirectory(DwarfGame.GetGameDirectory() + ProgramData.DirChar + "Worlds" + ProgramData.DirChar + Overworld.Name); OverworldFile overWorldFile = new OverworldFile( worldDirectory.FullName + ProgramData.DirChar + "world." + OverworldFile.CompressedExtension, true); Overworld.Map = overWorldFile.Data.CreateMap(); Overworld.Name = overWorldFile.Data.Name; WorldWidth = Overworld.Map.GetLength(1); WorldHeight = Overworld.Map.GetLength(0); } else { LoadingMessage = "Generating flat world.."; Overworld.CreateUniformLand(Game.GraphicsDevice); } GameID = gameFile.Data.GameID; } else { GameID = Random.Next(0, 1024); } ChunkGenerator = new ChunkGenerator(VoxelLibrary, Seed, 0.02f, ChunkHeight/2.0f) { SeaLevel = SeaLevel }; Vector3 globalOffset = new Vector3(WorldOrigin.X, 0, WorldOrigin.Y) * WorldScale; if(fileExists) { globalOffset /= WorldScale; } // If the file exists, we get the camera's pose from the file. // Otherwise, we set it to a pose above the center of the world (0, 0, 0) // facing down slightly. Camera = fileExists ? gameFile.Data.Camera : new OrbitCamera(0, 0, 10f, new Vector3(ChunkWidth, ChunkHeight - 1.0f, ChunkWidth) + globalOffset, new Vector3(0, 50, 0) + globalOffset, MathHelper.PiOver4, AspectRatio, 0.1f, GameSettings.Default.VertexCullDistance); Drawer3D.Camera = Camera; // Creates the terrain management system. ChunkManager = new ChunkManager(Content, (uint) ChunkWidth, (uint) ChunkHeight, (uint) ChunkWidth, Camera, GraphicsDevice, Tilesheet, TextureManager.GetTexture(ContentPaths.Terrain.terrain_illumination), TextureManager.GetTexture(ContentPaths.Gradients.sungradient), TextureManager.GetTexture(ContentPaths.Gradients.ambientgradient), TextureManager.GetTexture(ContentPaths.Gradients.torchgradient), ChunkGenerator, WorldSize.X, WorldSize.Y, WorldSize.Z); // Trying to determine the global offset from overworld coordinates (pixels in the overworld) to // voxel coordinates. globalOffset = ChunkManager.ChunkData.RoundToChunkCoords(globalOffset); globalOffset.X *= ChunkWidth; globalOffset.Y *= ChunkHeight; globalOffset.Z *= ChunkWidth; // If there's no file, we have to offset the camera relative to the global offset. if(!fileExists) { WorldOrigin = new Vector2(globalOffset.X, globalOffset.Z); Camera.Position = new Vector3(0, 10, 0) + globalOffset; Camera.Target = new Vector3(0, 10, 1) + globalOffset; Camera.Radius = 0.01f; Camera.Phi = -1.57f; } // If there's no file, we have to initialize the first chunk coordinate if(gameFile == null) { ChunkManager.GenerateInitialChunks(Camera, ChunkManager.ChunkData.GetChunkID(new Vector3(0, 0, 0) + globalOffset), ref LoadingMessage); } // Otherwise, we just load all the chunks from the file. else { LoadingMessage = "Loading Chunks from Game File"; ChunkManager.ChunkData.LoadFromFile(gameFile, ref LoadingMessage); } // If there's no file, for some reason we modify the camera position... // TODO: Figure out why the camera keeps needing to be reset. if(!fileExists) { Camera.Radius = 0.01f; Camera.Phi = -1.57f / 4.0f; Camera.Theta = 0.0f; } // Finally, the chunk manager's threads are started to allow it to // dynamically rebuild terrain ChunkManager.RebuildList = new ConcurrentQueue<VoxelChunk>(); ChunkManager.StartThreads(); }
private static void TestNinokuniExportImport(string romPath, string filePath) { DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read); Format romFormat = FileManager.GetFormat("Rom"); Format subtitleFormat = FileManager.GetFormat("Subtitle"); GameFile rom = new GameFile(Path.GetFileName(romPath), romStream, romFormat); romFormat.Initialize(rom); XDocument xmlGame = XDocument.Load(Path.Combine(AppPath, "ExampleGame.xml")); XDocument xmlEdit = XDocument.Load(Path.Combine(AppPath, "ExampleEdition.xml")); FileManager.Initialize(rom, FileInfoCollection.FromXml(xmlGame)); Configuration.Initialize(xmlEdit); GameFile file = FileManager.GetInstance().RescueFile(filePath); subtitleFormat.Initialize(file); file.Format.Read(); file.Format.Import("/home/benito/Dropbox/Ninokuni espaƱol/Texto/Subs peli/s01.xml"); file.Format.Write(); romFormat.Write(); rom.Stream.WriteTo("/lab/nds/projects/generic/test.nds"); romStream.Dispose(); }
public void RunTests(GameFile file) { if (file.Format != null) throw new Exception("The file already has a format."); this.dependencies.Clear(); this.Result = 0; this.Result += ((int)this.TestByTags(file.Tags) * 0.75); this.Result += ((int)this.TestByData(file.Stream) * 0.50); this.Result += ((int)this.TestByRegexp(file.Path, file.Name) * 0.25); file.Stream.Seek(0, SeekMode.Origin); this.IsValid = (this.Result >= 50) ? true : false; if (this.IsValid) { string[] depend = this.GuessDependencies(file); if (depend != null) this.dependencies.AddRange(depend); if (this.AutosetFormat) { file.SetFormat(this.FormatType, this.GuessParameters(file)); file.Format.IsGuessed = true; } } }
protected override string[] GuessDependencies(GameFile file) { // No extra dependency return null; }
public override void Initialize(GameFile file, params object[] parameters) { base.Initialize(file, parameters); binaryConverter = new SadlBinaryConverter(); wavConverter = new SadlWavConverter(); }
public virtual void Initialize(GameFile file, params Object[] parameters) { this.File = file; if (file != null) this.File.Format = this; this.isInitialized = true; this.parameters = parameters; }
public static void Main(string[] args) { Console.CursorVisible = false; Console.WriteLine("/*"); Console.WriteLine("****************************"); Console.WriteLine("** ModiMe **"); Console.WriteLine("** The new way to modify **"); Console.WriteLine("** your games **"); Console.WriteLine("****************************"); Console.WriteLine("~~~~~~~~ by pleoNeX ~~~~~~~~"); Console.WriteLine("| Version: {0,-16}|", Assembly.GetExecutingAssembly().GetName().Version); Console.WriteLine("~~~~~ Good RomHacking! ~~~~~"); Console.WriteLine("*/"); Console.WriteLine(); Stopwatch watch = new Stopwatch(); watch.Start(); int argIdx = 0; // Get global settings string[] inputNames = new string[0]; for (; argIdx < args.Length; argIdx++) { if (args[argIdx].StartsWith("--set-input-names=")) { inputNames = args[argIdx++].Substring(18). Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); break; } } // Import. Single file as input if (args.Length >= 5 && (args[argIdx] == "-i" || args[argIdx] == "-inew" || args[argIdx] == "-e")) { string xmlGame = args[argIdx + 1]; string xmlEdit = args[argIdx + 2]; string outputFile = (args[argIdx] == "-e") ? null : args[argIdx + 4]; string inputFile = args[argIdx + 3]; string filename = (inputNames.Length > 0) ? inputNames[0] : Path.GetFileName(inputFile); Console.WriteLine("Time to import!"); Console.WriteLine("From {0}", inputFile); Console.WriteLine("To {0}", outputFile); Console.WriteLine("Game specs: {0}", xmlGame); Console.WriteLine("Modify specs: {0}", xmlEdit); Console.WriteLine("Now... Let's start!"); Console.WriteLine(); DataStream stream = new DataStream(inputFile, FileMode.Open, FileAccess.Read); GameFile mainFile = new GameFile(filename, stream); Worker worker = new Worker(xmlGame, xmlEdit, mainFile); bool result = false; if (args[argIdx] == "-i") result = worker.Import(); else if (args[argIdx] == "-inew") result = worker.Import(File.GetLastWriteTime(inputFile)); else if (args[argIdx] == "-e") result = worker.Export(); // On error if (!result) { Console.WriteLine("Press a key to quit. . ."); Console.ReadKey(true); return; } if (args[argIdx] == "-i" || args[argIdx] == "-inew") worker.Write(outputFile); } else { ShowHelp(); } watch.Stop(); Console.WriteLine(); Console.WriteLine("Done! It took: {0}", watch.Elapsed); Console.CursorVisible = true; #if !DEBUG Console.WriteLine("Press any key to quit . . ."); Console.ReadKey(true); #endif }
public override void Initialize(GameFile file, params object[] parameters) { this.scriptName = ((XElement)parameters[0]).Value; base.Initialize(file, parameters); }
private OverlayFile(GameFile baseFile, bool isArm9) : base(string.Empty, baseFile.Stream) { this.Tags["Id"] = baseFile.Tags["Id"]; this.Name = "Overlay" + (isArm9 ? "9" : "7") + "_" + this.Tags["Id"].ToString() + ".bin"; }
protected abstract object[] GuessParameters(GameFile file);
/// <summary> /// Create a new overlay file from the info in the overlay table. /// </summary> /// <param name="str">Stream to read the table.</param> /// <param name="listFiles">List of files where the overlay must be.</param> /// <returns>Overlay file.</returns> public static OverlayFile FromTable(DataStream str, bool isArm9, GameFile[] listFiles) { DataReader dr = new DataReader(str); str.Seek(0x18, SeekMode.Current); uint fileId = dr.ReadUInt32(); str.Seek(-0x1C, SeekMode.Current); OverlayFile overlay = new OverlayFile(listFiles[fileId], isArm9); overlay.OverlayId = dr.ReadUInt32(); overlay.RamAddress = dr.ReadUInt32(); overlay.RamSize = dr.ReadUInt32(); overlay.BssSize = dr.ReadUInt32(); overlay.StaticInitStart = dr.ReadUInt32(); overlay.StaticInitEnd = dr.ReadUInt32(); dr.ReadUInt32(); // File ID again uint encodingInfo = dr.ReadUInt32(); overlay.EncodedSize = encodingInfo & 0x00FFFFFF; overlay.IsEncoded = ((encodingInfo >> 24) & 0x01) == 1; overlay.IsSigned = ((encodingInfo >> 24) & 0x02) == 2; return overlay; }
public override void Initialize(GameFile file, params object[] parameters) { base.Initialize(file, parameters); if (parameters.Length >= 1) { // Get a list with all files... GameFolder root = parameters[0] as GameFolder; List<GameFile> fileList = new List<GameFile>(); foreach (FileContainer f in root.GetFilesRecursive(false)) fileList.Add(f as GameFile); // ... and sort them by Id fileList.OrderBy(f => (ushort)f.Tags["Id"]); this.files = fileList.ToArray(); } if (parameters.Length == 2) this.firstOffset = (uint)parameters[1]; }
protected override object[] GuessParameters(GameFile file) { return SupportedFiles[(ushort)file.Tags["Id"]]; }
void SaveThread(string filename) { DirectoryInfo worldDirectory = Directory.CreateDirectory(DwarfGame.GetGameDirectory() + Path.DirectorySeparatorChar + "Worlds" + Path.DirectorySeparatorChar + Overworld.Name); OverworldFile file = new OverworldFile(Overworld.Map, Overworld.Name); file.WriteFile(worldDirectory.FullName + Path.DirectorySeparatorChar + "world." + OverworldFile.CompressedExtension, true); file.SaveScreenshot(worldDirectory.FullName + Path.DirectorySeparatorChar + "screenshot.png"); gameFile = new GameFile(Overworld.Name, GameID); gameFile.WriteFile(DwarfGame.GetGameDirectory() + Path.DirectorySeparatorChar + "Saves" + Path.DirectorySeparatorChar + filename, true); lock (ScreenshotLock) { Screenshots.Add(new Screenshot() { FileName = DwarfGame.GetGameDirectory() + Path.DirectorySeparatorChar + "Saves" + Path.DirectorySeparatorChar + filename + Path.DirectorySeparatorChar + "screenshot.png", Resolution = new Point(GraphicsDevice.Viewport.Width/4, GraphicsDevice.Viewport.Height/4) }); } }
private static void TestXmlImporting(string romPath) { DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read); GameFile rom = new GameFile(Path.GetFileName(romPath), romStream); XDocument xmlGame = XDocument.Load(Path.Combine(AppPath, "ExampleGame.xml")); XDocument xmlEdit = XDocument.Load(Path.Combine(AppPath, "ExampleEdition.xml")); Worker worker = new Worker(xmlGame, xmlEdit, rom); worker.Import(); worker.Write("/lab/nds/projects/generic/test.nds"); }