Lying

Editeur D2i 2.22+

Recommended Posts

Il vient de moi joli le changement d'ui :3 voici l'original

Cadeau >

using System;
using System.Collections.Generic;
using System.IO;
using Entropy.Utils;

namespace Entropy.DofusTool.D2I
{
    public class D2IFile : IDisposable
    {
        public string FilePath;
        public void Dispose()
        {
             m_Writer.Dispose();
        }
        public void Save()
        {
            m_Writer.Dispose();
            FileStream stream = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write);
            m_Writer = new BigEndianWriter(stream);
        }
        public Dictionary<int, string> m_Content;
        public Dictionary<string,int> m_Content_UI { get { return m_TextIndexes; } }
        private BigEndianReader m_Stream;
        private BigEndianWriter m_Writer;
        private Dictionary<int, int> m_Indexes;
        private Dictionary<int, int> m_UnDiacriticalIndex;
        private Dictionary<string, int> m_TextIndexes;
        private Dictionary<string, string> m_TextIndexesOverride;
        private Dictionary<int, int> m_TextSortIndex;
        public void Open(string filePath)
        {
            FileInfo fileInfo = new FileInfo(filePath);
            this.FilePath = filePath;
            if (m_Indexes == null)
                m_Indexes = new Dictionary<int, int>();

            if (m_UnDiacriticalIndex == null)
                m_UnDiacriticalIndex = new Dictionary<int, int>();

            if (m_TextIndexes == null)
                m_TextIndexes = new Dictionary<string, int>();

            if (m_TextIndexesOverride == null)
                m_TextIndexesOverride = new Dictionary<string, string>();

            if (m_TextSortIndex == null)
                m_TextSortIndex = new Dictionary<int, int>();

            byte[] fileContent = new byte[fileInfo.Length];
            FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
            fileStream.Read(fileContent, 0, fileContent.Length);
            fileStream.Dispose();
            FileStream writeStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write);
            m_Stream = new BigEndianReader(fileContent);
            m_Writer = new BigEndianWriter(writeStream);
            int position = m_Stream.ReadInt();
            m_Stream.Seek(position,SeekOrigin.Begin);

            int indexCount = m_Stream.ReadInt();

            for (int index = 0; index < indexCount; index += 9)
            {
                int key = m_Stream.ReadInt();
                bool diacriticalText = m_Stream.ReadBoolean();
                int pointeur = m_Stream.ReadInt();
                m_Indexes.Add(key, pointeur);

                if (diacriticalText)
                {
                    index += 4;
                    m_UnDiacriticalIndex.Add(key, m_Stream.ReadInt());
                }
                else
                    m_UnDiacriticalIndex.Add(key, pointeur);
            }

            int textIndexesCount = m_Stream.ReadInt();

            while (textIndexesCount > 0)
            {
                position = (int)m_Stream.Position;
                m_TextIndexes.Add(m_Stream.ReadUTF(), m_Stream.ReadInt());
                textIndexesCount -= (int)(m_Stream.Position - position);
            }

            textIndexesCount = m_Stream.ReadInt();

            int i = 0;

            while (textIndexesCount > 0)
            {
                position = (int)m_Stream.Position;
                m_TextSortIndex.Add(m_Stream.ReadInt(), ++i);
                textIndexesCount -= (int)(m_Stream.Position - position);
            }
            Initialize();
        }

        public string GetText(int id)
        {
            if ((m_Indexes == null) || (!m_Indexes.ContainsKey(id)))
                return null;

            m_Stream.Seek(m_Indexes[id],SeekOrigin.Begin);
            return m_Stream.ReadUTF();
        }
        public void Initialize()
        {
            m_Content = new Dictionary<int, string>();
            foreach (var key in m_Indexes.Keys)
            {
                m_Stream.Seek(m_Indexes[key], SeekOrigin.Begin);
                m_Content.Add(key, m_Stream.ReadUTF());
            }
        }
        public void SetText(int key,string newValue)
        {
            m_Writer.Seek(m_Indexes[key], SeekOrigin.Begin);
            m_Writer.WriteUTF(newValue);
        }
    }
}

f8d0d02734.png

Modifié (le) par Skinz ๖

Partager ce message


Lien à poster
Partager sur d’autres sites

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant