Пример #1
0
    // Save text to file
    private void ExportText(Unity_Studio.AssetPreloadData asset)
    {
        Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
        Directory.CreateDirectory(ContentData.ContentPath());
        Directory.CreateDirectory(ContentData.ContentPath() + gameType);
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg");
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg/text");
        string fileCandidate = ContentData.ContentPath() + gameType + "/ffg/text/" + asset.Text;
        string fileName      = fileCandidate + asset.extension;

        m_TextAsset = new Unity_Studio.TextAsset(asset, true);
        // This should apend a postfix to the name to avoid collisions, but as we import multiple times
        // This is broken
        while (File.Exists(fileName))
        {
            return;// Fixme;
        }

        // Write to disk
        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            // Pass the Deobfuscate key to decrypt
            writer.Write(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            writer.Close();
        }

        // Run monster data extration tool if in dev
        if (Application.isEditor && asset.Text.Equals("Localization"))
        {
            if (finder is MoMFinder)
            {
                ExtractDataTool.MoM(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            }
        }
    }
Пример #2
0
    private void ExportText(Unity_Studio.AssetPreloadData asset)
    {
        Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
        Directory.CreateDirectory(ContentData.ContentPath());
        Directory.CreateDirectory(ContentData.ContentPath() + gameType);
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg");
        Directory.CreateDirectory(ContentData.ContentPath() + gameType + "/ffg/text");
        string fileCandidate = ContentData.ContentPath() + gameType + "/ffg/text/" + asset.Text;
        string fileName      = fileCandidate + asset.extension;

        m_TextAsset = new Unity_Studio.TextAsset(asset, true);
        while (File.Exists(fileName))
        {
            return;// Fixme;
        }

        using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
        {
            writer.Write(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            writer.Close();
        }

        // Run monster data extration tool if in dev
        if (Application.isEditor && asset.Text.Equals("Localization"))
        {
            if (finder is MoMFinder)
            {
                ExtractDataTool.MoM(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
            }
        }
    }
Пример #3
0
        // Save text to file
        private void ExportText(Unity_Studio.AssetPreloadData asset)
        {
            Unity_Studio.TextAsset m_TextAsset = new Unity_Studio.TextAsset(asset, false);
            Directory.CreateDirectory(contentPath);
            Directory.CreateDirectory(contentPath + "/text");
            string fileCandidate = contentPath + "/text/" + asset.Text;
            string fileName      = fileCandidate + asset.extension;

            m_TextAsset = new Unity_Studio.TextAsset(asset, true);
            // This should apend a postfix to the name to avoid collisions, but as we import multiple times
            // This is broken
            while (File.Exists(fileName))
            {
                return;// Fixme;
            }

            // Write to disk
            using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create)))
            {
                // Pass the Deobfuscate key to decrypt
                writer.Write(m_TextAsset.Deobfuscate(finder.ObfuscateKey()));
                writer.Close();
            }

            // Need to trim new lines from old D2E format
            if (asset.Text.Equals("Localization"))
            {
                string[]      locFix      = File.ReadAllLines(fileName);
                List <string> locOut      = new List <string>();
                string        currentLine = "";
                for (int i = 0; i < locFix.Length; i++)
                {
                    if (locFix[i].Split('\"').Length % 2 == 0)
                    {
                        if (currentLine.Length == 0)
                        {
                            currentLine = locFix[i];
                        }
                        else
                        {
                            locOut.Add(currentLine + "\\n" + locFix[i]);
                            currentLine = "";
                        }
                    }
                    else
                    {
                        if (currentLine.Length == 0)
                        {
                            locOut.Add(locFix[i]);
                        }
                        else
                        {
                            currentLine += "\\n" + locFix[i];
                        }
                    }
                }
                File.WriteAllLines(fileName, locOut.ToArray());
            }
        }
Пример #4
0
        // Save text to file
        private void ExportText(Unity_Studio.AssetPreloadData asset)
        {
            if (asset == null)
            {
                throw new ArgumentNullException("asset");
            }
            var    textAsset = new Unity_Studio.TextAsset(asset, false);
            string textPath  = Path.Combine(contentPath, "text");

            Directory.CreateDirectory(textPath);
            string fileCandidate = Path.Combine(textPath, asset.Text);

            textAsset = new Unity_Studio.TextAsset(asset, true);

            // This should apends a postfix to the name to avoid collisions
            string fileName = GetAvailableFileName(fileCandidate, asset.extension);

            // Write to disk, pass the Deobfuscate key to decrypt
            File.WriteAllBytes(fileName, textAsset.Deobfuscate(finder.ObfuscateKey()));

            // Need to trim new lines from old D2E format
            if (asset.Text.Equals("Localization"))
            {
                string[] locFix      = File.ReadAllLines(fileName);
                var      locOut      = new List <string>();
                string   currentLine = "";
                for (int i = 0; i < locFix.Length; i++)
                {
                    if (locFix[i].Split('\"').Length % 2 == 0)
                    {
                        if (currentLine.Length == 0)
                        {
                            currentLine = locFix[i];
                        }
                        else
                        {
                            locOut.Add(currentLine + "\\n" + locFix[i]);
                            currentLine = "";
                        }
                    }
                    else
                    {
                        if (currentLine.Length == 0)
                        {
                            locOut.Add(locFix[i]);
                        }
                        else
                        {
                            currentLine += "\\n" + locFix[i];
                        }
                    }
                }
                File.WriteAllLines(fileName, locOut.ToArray());
            }
        }