private void LoadMaps() { var mapFile = MAPS_D2P_DIRECTORY + "maps0.d2p"; // put this in const field string eleFile = MAPS_D2P_DIRECTORY + "elements.ele"; if (!File.Exists(mapFile)) { return; } logger.White("Loading Maps from d2p..."); EleReader eleReader = new EleReader(eleFile); Elements elements = eleReader.ReadElements(); D2pFile d2p = new D2pFile(mapFile); var datas = d2p.ReadAllFiles(); UpdateLogger m_logger = new UpdateLogger(); int x = 0; foreach (var data in datas) { DlmReader mapReader = new DlmReader(new MemoryStream(data.Value)); mapReader.DecryptionKey = SqlSyncConfiguration.Instance.MapKey; ReadMap(mapReader, elements); //elements x++; m_logger.Update(x.Percentage(datas.Count) + "%"); } }
public Options(D2pFile file, string entryName, string containerName) { this.D2PFile = file; this.EntryName = entryName; this.ContainerName = containerName; this.InitializeComponent(); }
public D2PEditorModelView(D2PEditor editor, D2pFile file) { m_editor = editor; m_file = file; m_readOnylRows = new ReadOnlyObservableCollection <D2PGridRow>(m_rows); Open(null); }
public void Initialize(string path) { m_d2PFile = new D2pFile(path); m_icons = EnumerateIcons().ToDictionary(x => x.Id); ErrorIcon = new Icon(-1, m_d2PFile.ReadFile("error.png")); EmptyIcon = new Icon(0, m_d2PFile.ReadFile("empty.png")); }
public D2PSource(D2pFile reader) { if (reader == null) { throw new ArgumentNullException("reader"); } m_reader = reader; BindTypeWithExtension(typeof(DlmMap), ".dlm"); }
public static void Initialize() { if (m_gfxFile != null) { return; } m_gfxFile = new D2pFile(Settings.LoaderSettings.WorldGfxFile); m_eleReader = new EleReader(Settings.LoaderSettings.WorldEleFile); m_elements = m_eleReader.ReadElements(); }
private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); string path = openFileDialog1.FileName; if (path != string.Empty) { D2PFile = new D2pFile(path); foreach (var entry in D2PFile.Entries) { int soundId = 0; int.TryParse(Path.GetFileNameWithoutExtension(entry.FileName), out soundId); Values.Add(new D2PEntryDescription(entry.FullFileName, entry.Container.FilePath, D2OConstants.GetRelativeSubarea(soundId))); } BindDataSource(Values.ToArray()); } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { D2pFile d2p = new D2pFile(AppDomain.CurrentDomain.BaseDirectory + @"\data\d2p"); int step = 0; foreach (var file in d2p.ListD2pFileDlm) { label1.Invoke((MethodInvoker) delegate { label1.Text = "Chargement des élements : " + step + "/" + d2p.ListD2pFileDlm.Count; }); var elements = file.GetDictionnary(); bunifuCircleProgressbar1.Invoke((MethodInvoker) delegate { bunifuCircleProgressbar1.Value = 0; bunifuCircleProgressbar1.MaxValue = 100; }); int i = 0; foreach (var element in elements) { bunifuCircleProgressbar1.Invoke((MethodInvoker) delegate { bunifuCircleProgressbar1.Value = (i * 100) / (elements.Count); }); var name = element.Key.Split('/').Last(); if (!System.IO.File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\data\img\" + element.Key.Split('/').Last())) { var bit = file.ReadFile(element.Key); System.IO.File.WriteAllBytes(AppDomain.CurrentDomain.BaseDirectory + @"\data\img\" + element.Key.Split('/').Last(), bit); } i++; } step++; } System.IO.File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\data\init.conf", ""); Application.Run(new NewUI()); this.Invoke((MethodInvoker) delegate { this.Close(); }); }
private void button1_Click(object sender, EventArgs e) { string output = Environment.CurrentDirectory + @"\" + "Output"; if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } this.openFileDialog1.ShowDialog(); string path = this.openFileDialog1.FileName; D2pFile file = new D2pFile(path); var entry = file.GetEntry("music/20100.mp3"); var frostBottom = File.ReadAllBytes(Environment.CurrentDirectory + "/test.mp3"); entry.ModifyEntry(frostBottom); file.SaveAs(Environment.CurrentDirectory + "/test.d2p"); return; file.ExtractAllFiles(output, true, false); output = output + "/SWF/"; if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } foreach (var f in Directory.GetFiles(Environment.CurrentDirectory + @"\" + "Output")) { if (Path.GetExtension(f) == ".swl") { SwlFile swl = new SwlFile(f); swl.ExtractSwf(output); } } }
private void button2_Click(object sender, EventArgs e) { this.openFileDialog1.Filter = "Fichier MP3 | *.mp3"; this.openFileDialog1.ShowDialog(); string path = this.openFileDialog1.FileName; if (path != string.Empty) { try { D2pFile file = new D2pFile(Path.GetDirectoryName(this.D2PFile.FilePath) + "/" + this.ContainerName); var data = File.ReadAllBytes(path); file.GetEntry(this.EntryName).ModifyEntry(data); file.Save(); MessageBox.Show("Le fichier a bien été modifié."); this.Close(); } catch { MessageBox.Show("Impossible de modifier le fichier."); } } }
public ProgressionCounter Initialize(string d2pFile) { m_reader = new D2pFile(d2pFile); if (!File.Exists(MapsDataFile)) { return(BeginFileCreation()); } var stream = File.OpenRead(MapsDataFile); var reader = new BinaryReader(stream); if (new string(reader.ReadChars(4)) != "MAPS") { throw new Exception(string.Format("File {0} corrupted, delete it manually", MapsDataFile)); } m_fileVersion = reader.ReadUInt16(); if (m_fileVersion != CurrentMapsFileVersion) { logger.Info("{0} outdated (file version :{1}, expected version {2})", MapsDataFile, m_fileVersion, CurrentMapsFileVersion); reader.Dispose(); return(BeginFileCreation()); } m_tableOffset = reader.ReadUInt32(); m_length = reader.ReadUInt32(); reader.BaseStream.Seek(m_tableOffset, SeekOrigin.Begin); while (stream.Position < stream.Length) { m_offsetsTable.TryAdd(reader.ReadInt32(), reader.ReadInt32()); } reader.Dispose(); return(null); }
public D2PEditor(D2pFile file) { InitializeComponent(); ModelView = new D2PEditorModelView(this, file); DataContext = ModelView; }
public void Initialize(string path) { m_d2PFile = new D2pFile(path); }
public static void LoadSpawns() { // Since 2.36 version there is the same interactive on different maps because of the 16/9 mode, we have to find the correct one Console.WriteLine("Generating interactive spawns"); var worldDatabase = Program.ConnectToWorld(); if (worldDatabase == null) { return; } worldDatabase.Database.Execute("DELETE FROM interactives_spawns"); worldDatabase.Database.Execute("ALTER TABLE interactives_spawns AUTO_INCREMENT=1"); string eleFilePath = Path.Combine(Program.FindDofusPath(), "content", "maps", "elements.ele"); string mapsfilePath = Path.Combine(Program.FindDofusPath(), "content", "maps", "maps0.d2p"); var eleFile = new EleReader(eleFilePath); var eleInstance = eleFile.ReadElements(); var d2pFile = new D2pFile(mapsfilePath); var entries = d2pFile.ReadAllFiles(); var i = 0; var ids = new List <int>(); var failures = new List <int>(); var spawns = new Dictionary <int, InteractiveSpawn>(); var elementsGlobal = new Dictionary <int, DlmGraphicalElement>(); var identifiableElementsByMap = new Dictionary <int, List <IdentifiableElement> >(); int fails = 0; Console.WriteLine("Loading maps ... "); Program.InitializeCounter(); foreach (var mapBytes in entries.Values) { DlmReader mapFile; DlmMap map = null; try { mapFile = new DlmReader(mapBytes) { DecryptionKey = Program.MapDecryptionKey }; map = mapFile.ReadMap(); } catch (Exception) { fails++; continue; } var elements = (from layer in map.Layers from cell in layer.Cells from element in cell.Elements.OfType <DlmGraphicalElement>() where element.Identifier != 0 let point = new MapPoint(cell.Id) select new IdentifiableElement(element, map)).ToList(); identifiableElementsByMap.Add(map.Id, elements); Program.UpdateCounter(i++, entries.Count); } Program.EndCounter(); var identifiableElements = identifiableElementsByMap.Values.SelectMany(x => x). GroupBy(x => x.Element.Identifier).ToDictionary(x => x.Key, x => x.ToList()); Program.InitializeCounter(); i = 0; // every elements grouped by the same id foreach (var keyPair in identifiableElements) { var likelyElement = keyPair.Value.Where(x => !x.Ignore) .OrderByDescending(x => DistanceFromBorder(new MapPoint(x.Element.Cell.Id))) .ThenBy(x => Math.Abs(x.Element.PixelOffset.X) + Math.Abs(x.Element.PixelOffset.Y)).First(); var eleElement = eleInstance.GraphicalDatas[(int)likelyElement.Element.ElementId]; InteractiveSpawn spawn; spawn = new InteractiveSpawn { Id = (int)likelyElement.Element.Identifier, MapId = likelyElement.Map.Id, CellId = likelyElement.Element.Cell.Id, Animated = eleElement is AnimatedGraphicalElementData || eleElement is EntityGraphicalElementData, ElementId = (int)likelyElement.Element.ElementId }; if (ids.Contains(spawn.Id)) { Console.WriteLine($"Id {spawn.Id} already added"); failures.Add(spawn.Id); continue; } ids.Add(spawn.Id); worldDatabase.Database.Insert("interactives_spawns", "Id", false, spawn); spawns.Add(spawn.Id, spawn); elementsGlobal.Add(spawn.Id, likelyElement.Element); Program.UpdateCounter(i++, identifiableElements.Count); } Program.EndCounter(); if (fails > 0) { Console.WriteLine($"{fails} failes !"); } Program.ExecutePatch("./Patchs/interactives_spawns_patch.sql", worldDatabase.Database); }