public ShaderData(string pixelShaderPath, Texture dataSurface, TextureTransparency transparency) { if (ShaderData.IsSupported) { ArchivedFile archivedFile = Engine.FileManager.GetArchivedFile("play/shaders/" + pixelShaderPath); if (archivedFile != null) { using (Stream stream = archivedFile.Download()) { try { byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); using (ShaderBytecode shaderBytecode = new ShaderBytecode(buffer)) this._pixelShader = new PixelShader(Engine.m_Device, shaderBytecode); } catch (Exception ex) { Debug.Error(ex); } } } this._dataSurface = dataSurface; } this._transparency = transparency; }
public SpellList(string name) { bool flag = true; ArchivedFile archivedFile = Engine.FileManager.GetArchivedFile(string.Format("play/config/spells/{0}.xml", (object)name)); if (archivedFile != null) { using (Stream input = archivedFile.Download()) { XmlTextReader xml = new XmlTextReader(input); xml.WhitespaceHandling = WhitespaceHandling.None; flag = !this.Parse(xml); xml.Close(); } } if (!flag) { return; } this.m_Circles = 0; this.m_DisplayCircles = false; this.m_DisplayIndex = false; this.m_Spells = new Spell[0]; this.m_SpellID = 0; }
public MountTable() { ArchivedFile archivedFile = Engine.FileManager.GetArchivedFile("play/config/mounts.cfg"); if (archivedFile != null) { using (StreamReader ip = new StreamReader(archivedFile.Download())) this.Load(ip); } else { this.Default(); } }
private void archivedFilesListBox_SelectedIndexChanged(object sender, EventArgs e) { extractFileButton.Enabled = false; if (currentArchive == null || !currentArchive.ArchivedFiles.Any() || archivedFilesListBox.SelectedIndex == -1) { return; } ArchivedFile archivedFile = currentArchive.ArchivedFiles[archivedFilesListBox.SelectedIndex]; fileNameTextBox.Text = archivedFile.Name; sizeTextBox.Text = archivedFile.Size.ToString(); extractFileButton.Enabled = true; }
static Config() { if (!File.Exists(Engine.FileManager.ResolveMUL(Files.Verdata))) { string path = Engine.FileManager.BasePath("data/ultima/empty-verdata.mul"); Config.m_FileNames[24] = path; if (!File.Exists(path)) { using (Stream stream = (Stream)File.Create(path, 4)) { stream.Write(new byte[4], 0, 4); stream.Flush(); } } } Config.m_PaperdollCFG = new ArrayList(); ArchivedFile archivedFile = Engine.FileManager.GetArchivedFile("play/config/paperdoll.cfg"); if (archivedFile == null) { return; } using (StreamReader streamReader = new StreamReader(archivedFile.Download())) { string str; while ((str = streamReader.ReadLine()) != null) { string[] strArray = str.Split('\t'); if (strArray.Length >= 2) { try { Config.m_PaperdollCFG.Add((object)new PaperdollEntry(Convert.ToInt32(strArray[0], 16), Convert.ToInt32(strArray[1], 16))); } catch { } } } } }
private static MacroConfig LoadConfig() { MacroConfig macroConfig = new MacroConfig(); string configurationPath = Macros.GetConfigurationPath(); if (!File.Exists(configurationPath)) { string str = Engine.FileManager.BasePath("data/ultima/macros/macros.xml"); if (File.Exists(str)) { try { File.Move(str, configurationPath); } catch { File.Copy(str, configurationPath, false); } } else { ArchivedFile archivedFile = Engine.FileManager.GetArchivedFile("play/macros/macros.xml"); if (archivedFile != null) { using (FileStream fileStream = new FileStream(configurationPath, FileMode.Create, FileAccess.Write, FileShare.None)) archivedFile.Download((Stream)fileStream); } } } if (File.Exists(configurationPath)) { using (FileStream fileStream = new FileStream(configurationPath, FileMode.Open, FileAccess.Read, FileShare.Read)) { XmlPersistanceReader persistanceReader = new XmlPersistanceReader((Stream)fileStream); ((PersistanceReader)persistanceReader).ReadDocument((PersistableObject)macroConfig); ((PersistanceReader)persistanceReader).Close(); } } return(macroConfig); }
private void extractFileButton_Click(object sender, EventArgs e) { if (currentArchive == null || !currentArchive.ArchivedFiles.Any() || archivedFilesListBox.SelectedIndex == -1) { return; } ArchivedFile archivedFile = currentArchive.ArchivedFiles[archivedFilesListBox.SelectedIndex]; string fileName = archivedFile.Name.Split('\\').Last(); string extension = fileName.Split('.').Last(); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.FileName = fileName; saveFileDialog.Filter = $"Data file (.{extension})|*.{extension}"; var result = saveFileDialog.ShowDialog(); if (result == DialogResult.Abort || result == DialogResult.Cancel) { return; } FileInfo fileInfo = new FileInfo(saveFileDialog.FileName); try { currentArchive.ExtractFile(archivedFile, fileInfo.DirectoryName, true, false); } catch (Exception) { Console.WriteLine("Something went wrong with extraction. Archive is likely invalid or corrupted."); return; } statusLabel.Text = $"Extracted {fileName} succesfully."; }
public static void FindAndExtractFile(bool ignoreComplete = false) { string path = Program.ProjectPath; string where = Functions.FileDialog._SaveDialog.DirectoryPath.ToString(); string file = StaticWindows.ExportOneFile.GetFile(); //WaitDialog.Width = 15; //WaitDialog.Height = 3; Functions.Misc.UpdateStatus("Extracting file: " + file); RPGMakerVersion _version = RGSSAD.GetVersion(path); switch (_version) { case RPGMakerVersion.Xp: case RPGMakerVersion.Vx: { RGSSADv1 encrypted = new RGSSADv1(path); try { ArchivedFile _result = encrypted.ArchivedFiles.FirstOrDefault(x => x.Name.Contains(file)); if ((_result.Name ?? "TheresNoFileHere") != "TheresNoFileHere") { encrypted.ExtractFile(_result, where, StaticWindows.Settings.OverwriteFiles); } if (!ignoreComplete) { Functions.Misc.UpdateStatus("Extracted file: " + file); Application.Run(Operation.Complete); } } catch (IOException fileErr) { Operation.ShowError(fileErr.Message + "\n\n" + fileErr.Source); } encrypted.Dispose(); break; } case RPGMakerVersion.VxAce: { RGSSADv3 encrypted = new RGSSADv3(path); try { ArchivedFile _result = encrypted.ArchivedFiles.FirstOrDefault(x => x.Name.Contains(file)); if ((_result.Name ?? "TheresNoFileHere") != "TheresNoFileHere") { encrypted.ExtractFile(_result, where, StaticWindows.Settings.OverwriteFiles); } if (!ignoreComplete) { Functions.Misc.UpdateStatus("Extracted file: " + file); Application.Run(Operation.Complete); } } catch (IOException fileErr) { Operation.ShowError(fileErr.Message + "\n\n" + fileErr.Source); } encrypted.Dispose(); break; } default: break; } }
public ArchivedFile GetSelectedFile() { ArchivedFile file = SelectedArchiveEntry as ArchivedFile; return(file); }