Exemple #1
0
 private void xytext_FormClosing(object sender, FormClosingEventArgs e)
 {
     // Save All the old text
     if (entry > -1)
     {
         File.WriteAllBytes(files[entry], TextFile.getBytes(getCurrentDGLines()));
     }
 }
Exemple #2
0
        private bool importTextFile(string fileName)
        {
            string[]   fileText          = File.ReadAllLines(fileName, Encoding.Unicode);
            string[][] textLines         = new string[files.Length][];
            int        ctr               = 0;
            bool       newlineFormatting = false;

            // Loop through all files
            for (int i = 0; i < fileText.Length; i++)
            {
                string line = fileText[i];
                if (line != "~~~~~~~~~~~~~~~")
                {
                    continue;
                }
                string[] brokenLine = fileText[i++ + 1].Split(new[] { " : " }, StringSplitOptions.None);
                if (brokenLine.Length != 2)
                {
                    Util.Error($"Invalid Line @ {i}, expected Text File : {ctr}"); return(false);
                }
                int file = Util.ToInt32(brokenLine[1]);
                if (file != ctr)
                {
                    Util.Error($"Invalid Line @ {i}, expected Text File : {ctr}"); return(false);
                }
                i += 2; // Skip over the other header line
                List <string> Lines = new List <string>();
                while (i < fileText.Length && fileText[i] != "~~~~~~~~~~~~~~~")
                {
                    Lines.Add(fileText[i]);
                    newlineFormatting |= fileText[i].Contains("\\n"); // Check if any line wasn't stripped of ingame formatting codes for human readability.
                    i++;
                }
                i--;
                textLines[ctr++] = Lines.ToArray();
            }

            // Error Check
            if (ctr != files.Length)
            {
                Util.Error("The amount of Text Files in the input file does not match the required for the text file.",
                           $"Received: {ctr}, Expected: {files.Length}"); return(false);
            }
            if (!newlineFormatting)
            {
                Util.Error("The input Text Files do not have the ingame newline formatting codes (\\n,\\r,\\c).",
                           "When exporting text, do not remove newline formatting."); return(false);
            }

            // All Text Lines received. Store all back.
            for (int i = 0; i < files.Length; i++)
            {
                try { File.WriteAllBytes(files[i], TextFile.getBytes(textLines[i])); }
                catch (Exception e) { Util.Error($"The input Text File (# {i}) failed to convert:", e.ToString()); return(false); }
            }
            return(true);
        }
Exemple #3
0
        // Mirror Changes
        private void updateStarterText()
        {
            var gr   = Main.Config.getGARCReference("storytext");
            int file = Main.Config.USUM ? 39 : 41;

            for (int i = 0; i < 10; i++)
            {
                // get Story Text
                var      sr            = gr.getRelativeGARC(i, gr.Name);
                var      s             = Main.Config.getGARCByReference(sr);
                byte[][] storytextdata = s.Files;

                string[] storyText = TextFile.getStrings(Main.Config, storytextdata[file]);

                for (int j = 0; j < 3; j++)
                {
                    int oldSpecies = oldStarters[j];
                    int species    = Gifts[j].Species;
                    // Replace Story Text
                    string line = storyText[1 + j];
                    // Replace Species
                    line = line.Replace(specieslist[oldSpecies], specieslist[species]);

                    if (Main.Config.SM) // replace type text
                    {
                        int oldIndex = Main.Config.Personal.getFormeIndex(oldSpecies, Gifts[j].Form);
                        int oldtype0 = Main.Config.Personal[oldIndex].Types[0];
                        int newIndex = Main.Config.Personal.getFormeIndex(species, Gifts[j].Form);
                        int newtype0 = Main.Config.Personal[newIndex].Types[0];
                        line = line.Replace(types[oldtype0], types[newtype0]);
                    }
                    else if (Main.Config.USUM)
                    {
                        storyText[14 + j] = specieslist[species];
                    }

                    storyText[1 + j] = line;
                }
                storytextdata[file] = TextFile.getBytes(Main.Config, storyText);
                s.Files             = storytextdata;
                s.Save();
            }
        }
Exemple #4
0
        private void changeEntry(object sender, EventArgs e)
        {
            // Save All the old text
            if (entry > -1 && sender != null)
            {
                try
                {
                    byte[] bin = TextFile.getBytes(getCurrentDGLines());
                    File.WriteAllBytes(files[entry], bin);
                }
                catch (Exception ex) { Util.Error(ex.ToString()); }
            }

            // Reset
            entry = CB_Entry.SelectedIndex;
            string file = files[entry];

            string[] data = TextFile.getStrings(file);
            setStringsDataGridView(data);
        }