Ejemplo n.º 1
0
        private void AddEntry(iniEntry.EntryType entryType)
        {
            int newIndex = GetLastEntryNum(entryType) + 1;

            string type = "[cont";

            if (entryType == iniEntry.EntryType.CustomImage)
            {
                type = "[cimg";
            }
            else if (entryType == iniEntry.EntryType.StaticImage)
            {
                type = "[simg";
            }
            else if (entryType == iniEntry.EntryType.CustomData)
            {
                type = "[cdta";
            }
            else if (entryType == iniEntry.EntryType.StaticData)
            {
                type = "[sdta";
            }

            iniEntry newEntry = new iniEntry();

            newEntry.entryType = entryType;
            newEntry.entry     = type + newIndex.ToString() + "]";
            newEntry.format    = iniEntry.TplFormat.RGB5A3;

            ini.EntryList.Add(newEntry);
            lbxIniEntries.Items.Add(newEntry.entry);
            lbxIniEntries.SelectedIndex = lbxIniEntries.Items.Count - 1;
        }
Ejemplo n.º 2
0
 public void EditEntry(iniEntry editedEntry)
 {
     for (int i = 0; i < entries.Count; i++)
     {
         if (entries[i].entry == editedEntry.entry)
         {
             entries[i] = editedEntry;
         }
     }
 }
Ejemplo n.º 3
0
        private void DeASH(iniEntry mymC, string appOut)
        {
            ProcessStartInfo pInfo = new ProcessStartInfo(Application.StartupPath + "\\ASH.exe", string.Format("\"{0}\"", appOut + mymC.file));

            pInfo.UseShellExecute = false;
            //pInfo.RedirectStandardOutput = true;
            pInfo.CreateNoWindow = true;

            Process p = Process.Start(pInfo);

            p.WaitForExit();

            //ErrorBox(p.StandardOutput.ReadToEnd() + "\n\n" + mymC.file);
        }
Ejemplo n.º 4
0
 private void msRemoveMissingStatics_Click(object sender, EventArgs e)
 {
     for (int i = lbxIniEntries.Items.Count - 1; i > -1; i--)
     {
         if (lbxIniEntries.Items[i].ToString().StartsWith("[s"))
         {
             iniEntry tempEntry = ini.GetEntry(lbxIniEntries.Items[i].ToString());
             if (!File.Exists(tempEntry.filepath))
             {
                 RemoveEntry(i);
             }
         }
     }
 }
Ejemplo n.º 5
0
        private bool EntryExists(iniEntry entry, List <string[]> list)
        {
            foreach (string[] array in list)
            {
                if (array[0] == entry.source)
                {
                    FileInfo fi = new FileInfo(entry.filepath);
                    if (fi.Length != int.Parse(array[1]))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 6
0
        private void msImageSizeFromPng_Click(object sender, EventArgs e)
        {
            if (!msImageSizeFromPng.Checked)
            {
                settings.autoImageSize = false;

                if (panStaticImage.Visible)
                {
                    iniEntry tempEntry = ini.GetEntry(lbxIniEntries.SelectedItem.ToString());
                    tbStaticImageWidth.Text  = tempEntry.width.ToString();
                    tbStaticImageHeight.Text = tempEntry.height.ToString();
                }
                else if (panCustomImage.Visible)
                {
                    iniEntry tempEntry = ini.GetEntry(lbxIniEntries.SelectedItem.ToString());
                    tbCustomImageWidth.Text  = tempEntry.width.ToString();
                    tbCustomImageHeight.Text = tempEntry.height.ToString();
                }

                tbStaticImageWidth.Enabled  = true;
                tbStaticImageHeight.Enabled = true;
                tbCustomImageWidth.Enabled  = true;
                tbCustomImageHeight.Enabled = true;
            }
            else
            {
                settings.autoImageSize      = true;
                tbStaticImageWidth.Text     = string.Empty;
                tbStaticImageHeight.Text    = string.Empty;
                tbCustomImageWidth.Text     = string.Empty;
                tbCustomImageHeight.Text    = string.Empty;
                tbStaticImageWidth.Enabled  = false;
                tbStaticImageHeight.Enabled = false;
                tbCustomImageWidth.Enabled  = false;
                tbCustomImageHeight.Enabled = false;

                if (msImageSizeFromTpl.Checked)
                {
                    msImageSizeFromTpl.Checked = false;
                    settings.imageSizeFromTpl  = false;
                }

                MessageBox.Show("Be sure that your PNG images have the same size as the original TPLs they will replace," +
                                " else you might get a brick!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void AddEntry(iniEntry.EntryType entryType)
        {
            int newIndex = GetLastEntryNum(entryType) + 1;

            string type = "[cont";
            if (entryType == iniEntry.EntryType.CustomImage) type = "[cimg";
            else if (entryType == iniEntry.EntryType.StaticImage) type = "[simg";
            else if (entryType == iniEntry.EntryType.CustomData) type = "[cdta";
            else if (entryType == iniEntry.EntryType.StaticData) type = "[sdta";

            iniEntry newEntry = new iniEntry();
            newEntry.entryType = entryType;
            newEntry.entry = type + newIndex.ToString() + "]";
            newEntry.format = iniEntry.TplFormat.RGB5A3;

            ini.EntryList.Add(newEntry);
            lbxIniEntries.Items.Add(newEntry.entry);
            lbxIniEntries.SelectedIndex = lbxIniEntries.Items.Count - 1;
        }
Ejemplo n.º 8
0
        private void _saveMym(object _creationInfo)
        {
            SetControls(false);
            CreationInfo cInfo = (CreationInfo)_creationInfo;
            string outDir = tempDir + "newMym\\";
            if (Directory.Exists(outDir)) Directory.Delete(outDir, true);
            Directory.CreateDirectory(outDir);

            int counter = 0;
            int[] counters = new int[5];

            //Build new ini
            List<iniEntry> tempEntries = new List<iniEntry>();
            List<string[]> dataSources = new List<string[]>();
            List<string[]> imageSources = new List<string[]>();

            foreach (object tempObject in cInfo.lbEntries)
            {
                ReportProgress(++counter * 100 / cInfo.lbEntries.Length, "Building mym.ini...");

                try
                {
                    iniEntry tempEntry = ini.GetEntry(tempObject.ToString());
                    if (!CheckEntry(tempEntry))
                    {
                        if (!settings.ignoreMissing) { ReportProgress(100, " "); SetControls(true); return; }
                        else continue;
                    }

                    if (settings.sourceManage)
                    {
                        //Manage source
                        if (tempEntry.entryType == iniEntry.EntryType.StaticData)
                        {
                            if (Path.HasExtension(tempEntry.filepath))
                            {
                                tempEntry.source = "\\" + Path.GetExtension(tempEntry.filepath).Remove(0, 1) + "\\" + Path.GetFileName(tempEntry.filepath);

                                string tempSource = "\\" + Path.GetExtension(tempEntry.filepath).Remove(0, 1) + "\\" + Path.GetFileName(tempEntry.filepath);
                                int i = 1;

                                while (EntryExists(tempEntry, dataSources))
                                {
                                    tempEntry.source = tempSource.Insert(tempSource.LastIndexOf('.'), (++i).ToString());
                                }

                                FileInfo fi = new FileInfo(tempEntry.filepath);
                                dataSources.Add(new string[] { tempEntry.source, fi.Length.ToString() });
                            }
                            else
                            {
                                tempEntry.source = "\\" + Path.GetFileName(tempEntry.filepath);

                                string tempSource = "\\" + "\\" + Path.GetFileName(tempEntry.filepath);
                                int i = 1;

                                while (EntryExists(tempEntry, dataSources))
                                {
                                    tempEntry.source = tempSource.Insert(tempSource.LastIndexOf('.'), (++i).ToString());
                                }

                                FileInfo fi = new FileInfo(tempEntry.filepath);
                                dataSources.Add(new string[] { tempEntry.source, fi.Length.ToString() });
                            }
                        }
                        else if (tempEntry.entryType == iniEntry.EntryType.StaticImage)
                        {
                            tempEntry.source = "\\images\\" + Path.GetFileName(tempEntry.filepath);

                            string tempSource = "\\images\\" + Path.GetFileName(tempEntry.filepath);
                            int i = 1;

                            while (EntryExists(tempEntry, imageSources))
                            {
                                tempEntry.source = tempSource.Insert(tempSource.LastIndexOf('.'), (++i).ToString());
                            }

                            FileInfo fi = new FileInfo(tempEntry.filepath);
                            imageSources.Add(new string[] { tempEntry.source, fi.Length.ToString() });
                        }
                    }
                    if (settings.autoImageSize)
                    {
                        if (tempEntry.entryType == iniEntry.EntryType.CustomImage ||
                            tempEntry.entryType == iniEntry.EntryType.StaticImage)
                        {
                            //Get png width and height
                            Image img = Image.FromFile(tempEntry.filepath);
                            tempEntry.width = img.Width;
                            tempEntry.height = img.Height;
                        }
                    }

                    tempEntries.Add(tempEntry);
                }
                catch { }
            }

            if (tempEntries.Count < 1)
            {
                ErrorBox("No entries left...");
                SetControls(true);
                return;
            }

            //Manage Containers
            if (settings.containerManage)
            {
                List<string> containersToManage = new List<string>();
                List<string> managedContainers = new List<string>();

                foreach (iniEntry tempEntry in tempEntries)
                {
                    if (tempEntry.entryType == iniEntry.EntryType.Container)
                        managedContainers.Add(tempEntry.file);
                    else
                    {
                        if (tempEntry.file.Contains("_out"))
                        {
                            string tmpString = tempEntry.file.Remove(tempEntry.file.IndexOf("_out"));
                            tmpString = tmpString.Substring(0, tmpString.Length - 5) + tmpString.Substring(tmpString.Length - 5).Replace("_", ".");

                            if (!StringExistsInStringArray(tmpString, containersToManage.ToArray()))
                                containersToManage.Add(tmpString);
                        }
                    }
                }

                List<string> leftContainers = new List<string>();

                foreach (string thisContainer in containersToManage)
                {
                    if (!StringExistsInStringArray(thisContainer, managedContainers.ToArray()))
                        leftContainers.Add(thisContainer);
                }

                if (leftContainers.Count > 0)
                {
                    List<iniEntry> newList = new List<iniEntry>();

                    foreach (string thisContainer in leftContainers)
                    {
                        iniEntry tempEntry = new iniEntry();
                        tempEntry.entryType = iniEntry.EntryType.Container;
                        tempEntry.file = thisContainer;
                        tempEntry.type = iniEntry.ContainerType.ASH;

                        newList.Add(tempEntry);
                    }

                    newList.AddRange(tempEntries);
                    tempEntries = newList;
                }
            }

            ini = new mymini();
            ini.EntryList = tempEntries;
            ini.Save(outDir + "mym.ini");
            counter = 0;

            //Copy files
            foreach (iniEntry tempEntry in ini.EntryList)
            {
                ReportProgress(++counter * 100 / ini.EntryList.Count, "Copying files...");

                if (tempEntry.entryType == iniEntry.EntryType.StaticImage ||
                    tempEntry.entryType == iniEntry.EntryType.StaticData)
                {
                    string sourceFile = tempEntry.filepath;
                    string destFile = outDir + tempEntry.source;

                    if (!Directory.Exists(Path.GetDirectoryName(destFile))) Directory.CreateDirectory(Path.GetDirectoryName(destFile));
                    File.Copy(sourceFile, destFile, true);
                }
            }

            //Zip file
            ReportProgress(0, "Packing mym...");
            ReportProgress(80, ""); // Fake, hm?!
            FastZip fZip = new FastZip();
            fZip.CreateZip((cInfo.createCsm) ? tempDir + "temp.mym" : cInfo.savePath, outDir, true, "");
            ReportProgress(100, " ");

            if (cInfo.closeAfter) { MethodInvoker m = new MethodInvoker(this.ExitApplication); this.Invoke(m); return; }
            if (!cInfo.createCsm) { InfoBox("Saved mym to:\n" + cInfo.savePath); SetControls(true); return; }

            _createCsm(cInfo.savePath, cInfo.appFile, tempDir + "temp.mym");
        }
Ejemplo n.º 9
0
        private void _convertCsm()
        {
            string appDir = tempDir + "\\appOut\\";
            string csmDir = tempDir + "\\csmOut\\";
            string mymDir = tempDir + "\\mymOut\\";

            if (Directory.Exists(appDir))
            {
                Directory.Delete(appDir, true);
            }
            if (Directory.Exists(csmDir))
            {
                Directory.Delete(csmDir, true);
            }
            if (Directory.Exists(mymDir))
            {
                Directory.Delete(mymDir, true);
            }

            List <iniEntry> entryList = new List <iniEntry>();

            Wii.U8.UnpackU8(tbCsm.Text, csmDir);
            Wii.U8.UnpackU8(tbApp.Text, appDir);

            string[] csmFiles = Directory.GetFiles(csmDir, "*", SearchOption.AllDirectories);

            if (intensiveAlgorithm)
            {
                for (int i = 0; i < csmFiles.Length; i++)
                {
                    ReportProgress((i * 100 / csmFiles.Length) / 2);

                    byte[] temp = Wii.Tools.LoadFileToByteArray(csmFiles[i], 0, 4);
                    if (temp[0] == 'Y' && temp[1] == 'a' && temp[2] == 'z' && temp[3] == '0')
                    {
                        continue;
                    }

                    bool extracted = false;

                    while (!extracted)
                    {
                        byte[] fourBytes = Wii.Tools.LoadFileToByteArray(csmFiles[i].Replace(csmDir, appDir), 0, 4);

                        if (fourBytes[0] == 'A' && fourBytes[1] == 'S' &&
                            fourBytes[2] == 'H' && fourBytes[3] == '0')     //ASH0
                        {
                            try
                            {
                                DeASH(csmFiles[i].Replace(csmDir, appDir));

                                File.Delete(csmFiles[i].Replace(csmDir, appDir));
                                FileInfo fi = new FileInfo(csmFiles[i].Replace(csmDir, appDir) + ".arc");
                                fi.MoveTo(csmFiles[i].Replace(csmDir, appDir));
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'L' && fourBytes[1] == 'Z' &&
                                 fourBytes[2] == '7' && fourBytes[3] == '7') //Lz77
                        {
                            try
                            {
                                byte[] decompressedFile = Wii.Lz77.Decompress(File.ReadAllBytes(csmFiles[i].Replace(csmDir, appDir)), 0);

                                File.Delete(csmFiles[i].Replace(csmDir, appDir));
                                File.WriteAllBytes(csmFiles[i].Replace(csmDir, appDir), decompressedFile);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'Y' && fourBytes[1] == 'a' &&
                                 fourBytes[2] == 'z' && fourBytes[3] == '0') //Yaz0
                        {
                            //Nothing to do about yet...
                            break;
                        }
                        else if (fourBytes[0] == 0x55 && fourBytes[1] == 0xaa &&
                                 fourBytes[2] == 0x38 && fourBytes[3] == 0x2d) //U8
                        {
                            try
                            {
                                Wii.U8.UnpackU8(csmFiles[i].Replace(csmDir, appDir), csmFiles[i].Replace(csmDir, appDir).Replace(".", "_") + "_out");
                                File.Delete(csmFiles[i].Replace(csmDir, appDir));
                                extracted = true;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    extracted = false;

                    while (!extracted)
                    {
                        byte[] fourBytes = Wii.Tools.LoadFileToByteArray(csmFiles[i], 0, 4);

                        if (fourBytes[0] == 'A' && fourBytes[1] == 'S' &&
                            fourBytes[2] == 'H' && fourBytes[3] == '0')     //ASH0
                        {
                            try
                            {
                                DeASH(csmFiles[i]);

                                File.Delete(csmFiles[i]);
                                FileInfo fi = new FileInfo(csmFiles[i] + ".arc");
                                fi.MoveTo(csmFiles[i]);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'L' && fourBytes[1] == 'Z' &&
                                 fourBytes[2] == '7' && fourBytes[3] == '7') //Lz77
                        {
                            try
                            {
                                byte[] decompressedFile = Wii.Lz77.Decompress(File.ReadAllBytes(csmFiles[i]), 0);

                                File.Delete(csmFiles[i]);
                                File.WriteAllBytes(csmFiles[i], decompressedFile);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'Y' && fourBytes[1] == 'a' &&
                                 fourBytes[2] == 'z' && fourBytes[3] == '0') //Yaz0
                        {
                            //Nothing to do about yet...
                            break;
                        }
                        else if (fourBytes[0] == 0x55 && fourBytes[1] == 0xaa &&
                                 fourBytes[2] == 0x38 && fourBytes[3] == 0x2d) //U8
                        {
                            try
                            {
                                Wii.U8.UnpackU8(csmFiles[i], csmFiles[i].Replace(".", "_") + "_out");
                                File.Delete(csmFiles[i]);
                                extracted = true;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }

                csmFiles = Directory.GetFiles(csmDir, "*", SearchOption.AllDirectories);
            }

            for (int i = 0; i < csmFiles.Length; i++)
            {
                ReportProgress(((i * 100 / csmFiles.Length) / (intensiveAlgorithm ? 2 : 1)) + (intensiveAlgorithm ? 50 : 0));

                if (File.Exists(csmFiles[i].Replace(csmDir, appDir)))
                {
                    //File exists in original app
                    FileInfo fi  = new FileInfo(csmFiles[i]);
                    FileInfo fi2 = new FileInfo(csmFiles[i].Replace(csmDir, appDir));

                    if (fi.Length == fi2.Length) //Same file
                    {
                        continue;
                    }
                }

                iniEntry tempEntry = new iniEntry();
                tempEntry.entryType = iniEntry.EntryType.StaticData;
                tempEntry.file      = csmFiles[i].Replace(csmDir, string.Empty);
                if (!tempEntry.file.StartsWith("\\"))
                {
                    tempEntry.file = tempEntry.file.Insert(0, "\\");
                }

                if (!Directory.Exists(Path.GetDirectoryName(mymDir + Path.GetExtension(csmFiles[i]).Remove(0, 1) + "\\" + Path.GetFileName(csmFiles[i]))))
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(mymDir + Path.GetExtension(csmFiles[i]).Remove(0, 1) + "\\" + Path.GetFileName(csmFiles[i])));
                }

                string destFile = mymDir + Path.GetExtension(csmFiles[i]).Remove(0, 1) + "\\" + Path.GetFileName(csmFiles[i]);

                int      counter  = 0;
                FileInfo fi1      = new FileInfo(csmFiles[i]);
                string   tempFile = destFile;

                while (File.Exists(destFile))
                {
                    FileInfo fi2 = new FileInfo(destFile);
                    if (fi1.Length == fi2.Length)
                    {
                        break;
                    }

                    destFile = tempFile.Replace(Path.GetExtension(tempFile), (++counter).ToString() + Path.GetExtension(tempFile));
                }

                File.Copy(csmFiles[i], destFile, true);
                tempEntry.source = "\\" + Path.GetExtension(destFile).Remove(0, 1) + "\\" + Path.GetFileName(destFile);
                entryList.Add(tempEntry);
            }

            //---

            List <string> containersToManage = new List <string>();
            List <string> managedContainers  = new List <string>();

            foreach (iniEntry tempEntry in entryList)
            {
                if (tempEntry.entryType == iniEntry.EntryType.Container)
                {
                    managedContainers.Add(tempEntry.file);
                }
                else
                {
                    if (tempEntry.file.Contains("_out"))
                    {
                        string tmpString = tempEntry.file.Remove(tempEntry.file.IndexOf("_out"));
                        tmpString = tmpString.Substring(0, tmpString.Length - 5) + tmpString.Substring(tmpString.Length - 5).Replace("_", ".");

                        if (!StringExistsInStringArray(tmpString, containersToManage.ToArray()))
                        {
                            containersToManage.Add(tmpString);
                        }
                    }
                }
            }

            List <string> leftContainers = new List <string>();

            foreach (string thisContainer in containersToManage)
            {
                if (!StringExistsInStringArray(thisContainer, managedContainers.ToArray()))
                {
                    leftContainers.Add(thisContainer);
                }
            }

            if (leftContainers.Count > 0)
            {
                List <iniEntry> newList = new List <iniEntry>();

                foreach (string thisContainer in leftContainers)
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.Container;
                    tempEntry.file      = thisContainer;
                    tempEntry.type      = iniEntry.ContainerType.ASH;

                    newList.Add(tempEntry);
                }

                newList.AddRange(entryList);
                entryList = newList;
            }

            //---

            mymini ini = mymini.CreateIni(entryList.ToArray());

            ini.Save(mymDir + "mym.ini");

            FastZip fZip = new FastZip();

            fZip.CreateZip(saveFile, mymDir, true, "");

            if (Directory.Exists(appDir))
            {
                Directory.Delete(appDir, true);
            }
            if (Directory.Exists(csmDir))
            {
                Directory.Delete(csmDir, true);
            }
            if (Directory.Exists(mymDir))
            {
                Directory.Delete(mymDir, true);
            }

            ReportProgress(100);
            MessageBox.Show("Saved mym to:\n" + saveFile, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private bool CheckEntry(iniEntry entry)
        {
            if (entry.entryType == iniEntry.EntryType.Container)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry)); return false; }
            }
            else if (entry.entryType == iniEntry.EntryType.CustomImage)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry)); return false; }
                if (string.IsNullOrEmpty(entry.name))
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"name\"...", entry.entry)); return false; }
            }
            else if (entry.entryType == iniEntry.EntryType.StaticImage)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry)); return false; }
                if (!settings.sourceManage)
                {
                    if (string.IsNullOrEmpty(entry.source))
                    { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"source\"...", entry.entry)); return false; }
                }

                if (!File.Exists(entry.filepath))
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nFile not found...\n\n{1}", entry.entry, entry.filepath)); return false; }
            }
            else if (entry.entryType == iniEntry.EntryType.CustomData)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry)); return false; }
                if (string.IsNullOrEmpty(entry.name))
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"name\"...", entry.entry)); return false; }
            }
            else if (entry.entryType == iniEntry.EntryType.StaticData)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry)); return false; }
                if (!settings.sourceManage)
                {
                    if (string.IsNullOrEmpty(entry.source))
                    { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nInvalid argument \"source\"...", entry.entry)); return false; }
                }

                if (!File.Exists(entry.filepath))
                { if (!settings.ignoreMissing) ErrorBox(string.Format("Entry: {0}\nFile not found...\n\n{1}", entry.entry, entry.filepath)); return false; }
            }

            return true;
        }
        private int GetLastEntryNum(iniEntry.EntryType entryType)
        {
            int highestIndex = 0;

            string type = "[cont";
            if (entryType == iniEntry.EntryType.CustomImage) type = "[cimg";
            else if (entryType == iniEntry.EntryType.StaticImage) type = "[simg";
            else if (entryType == iniEntry.EntryType.CustomData) type = "[cdta";
            else if (entryType == iniEntry.EntryType.StaticData) type = "[sdta";

            foreach (iniEntry entry in ini.EntryList)
            {
                if (entry.entryType == entryType)
                {
                    int newIndex = int.Parse(entry.entry.Replace(type, "").Replace("]", ""));
                    if (newIndex > highestIndex) highestIndex = newIndex;
                }
            }

            return highestIndex;
        }
Ejemplo n.º 12
0
        private void ParseIni()
        {
            string[]        iniLines    = File.ReadAllLines(iniFile);
            List <iniEntry> tempEntries = new List <iniEntry>();

            iniLines = CutComments(iniLines);

            for (int i = 0; i < iniLines.Length; i++)
            {
                ReportProgress((i + 1) * 100 / iniLines.Length, "Pasring mym.ini...");

                if (iniLines[i].ToLower().StartsWith("[cont")) //Container
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.Container;
                    tempEntry.entry     = iniLines[i];
                    bool[] trues = new bool[] { false, false };
                    int    j     = i + 1;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0]       = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("type="))
                        {
                            if (iniLines[j].ToUpper().Contains("ASH"))
                            {
                                tempEntry.type = iniEntry.ContainerType.ASH;
                            }
                            else
                            {
                                tempEntry.type = iniEntry.ContainerType.U8;
                            }

                            trues[1] = true;
                        }

                        j++;
                        if (j == iniLines.Length)
                        {
                            break;
                        }
                    }

                    if (trues[0] && trues[1])
                    {
                        tempEntries.Add(tempEntry);
                    }
                }
                else if (iniLines[i].ToLower().StartsWith("[cimg")) //Custom Image
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.CustomImage;
                    tempEntry.entry     = iniLines[i];
                    bool[] trues = new bool[] { false, false, false, false };
                    int    j     = i + 1;

                    tempEntry.format = iniEntry.TplFormat.RGB5A3;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0]       = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("name="))
                        {
                            tempEntry.name = iniLines[j].Substring(5);
                            trues[1]       = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("width="))
                        {
                            try
                            {
                                tempEntry.width = int.Parse(iniLines[j].Substring(6));
                                trues[2]        = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("height="))
                        {
                            try
                            {
                                tempEntry.height = int.Parse(iniLines[j].Substring(7));
                                trues[3]         = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("format="))
                        {
                            if (iniLines[j].Substring(7).ToUpper().StartsWith("RGBA8"))
                            {
                                tempEntry.format = iniEntry.TplFormat.RGBA8;
                            }
                            else if (iniLines[j].Substring(7).ToUpper().StartsWith("RGB565"))
                            {
                                tempEntry.format = iniEntry.TplFormat.RGB565;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "I4")
                            {
                                tempEntry.format = iniEntry.TplFormat.I4;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "I8")
                            {
                                tempEntry.format = iniEntry.TplFormat.I8;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "IA4")
                            {
                                tempEntry.format = iniEntry.TplFormat.IA4;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "IA8")
                            {
                                tempEntry.format = iniEntry.TplFormat.IA8;
                            }
                        }

                        j++;
                        if (j == iniLines.Length)
                        {
                            break;
                        }
                    }

                    if (trues[0] && trues[1] && trues[2] && trues[3])
                    {
                        tempEntries.Add(tempEntry);
                    }
                }
                else if (iniLines[i].ToLower().StartsWith("[simg")) //Static Image
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.StaticImage;
                    tempEntry.entry     = iniLines[i];
                    bool[] trues = new bool[] { false, false, false, false };
                    int    j     = i + 1;

                    tempEntry.format = iniEntry.TplFormat.RGB5A3;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0]       = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("source="))
                        {
                            tempEntry.source = iniLines[j].Substring(7);
                            trues[1]         = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("width="))
                        {
                            try
                            {
                                tempEntry.width = int.Parse(iniLines[j].Substring(6));
                                trues[2]        = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("height="))
                        {
                            try
                            {
                                tempEntry.height = int.Parse(iniLines[j].Substring(7));
                                trues[3]         = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("format="))
                        {
                            if (iniLines[j].Substring(7).ToUpper() == "RGBA8")
                            {
                                tempEntry.format = iniEntry.TplFormat.RGBA8;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "RGB565")
                            {
                                tempEntry.format = iniEntry.TplFormat.RGB565;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "I4")
                            {
                                tempEntry.format = iniEntry.TplFormat.I4;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "I8")
                            {
                                tempEntry.format = iniEntry.TplFormat.I8;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "IA4")
                            {
                                tempEntry.format = iniEntry.TplFormat.IA4;
                            }
                            else if (iniLines[j].Substring(7).ToUpper() == "IA8")
                            {
                                tempEntry.format = iniEntry.TplFormat.IA8;
                            }
                        }

                        tempEntry.filepath = Path.GetDirectoryName(iniFile) + tempEntry.source;

                        j++;
                        if (j == iniLines.Length)
                        {
                            break;
                        }
                    }

                    if (trues[0] && trues[1] && trues[2] && trues[3])
                    {
                        tempEntries.Add(tempEntry);
                    }
                }
                else if (iniLines[i].ToLower().StartsWith("[cdta")) //Custom Data
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.CustomData;
                    tempEntry.entry     = iniLines[i];
                    bool[] trues = new bool[] { false, false };
                    int    j     = i + 1;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0]       = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("name="))
                        {
                            tempEntry.name = iniLines[j].Substring(5);
                            trues[1]       = true;
                        }

                        j++;
                        if (j == iniLines.Length)
                        {
                            break;
                        }
                    }

                    if (trues[0] && trues[1])
                    {
                        tempEntries.Add(tempEntry);
                    }
                }
                else if (iniLines[i].ToLower().StartsWith("[sdta")) //Static Data
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.StaticData;
                    tempEntry.entry     = iniLines[i];
                    bool[] trues = new bool[] { false, false };
                    int    j     = i + 1;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0]       = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("source="))
                        {
                            tempEntry.source = iniLines[j].Substring(7);
                            trues[1]         = true;
                        }

                        j++;
                        if (j == iniLines.Length)
                        {
                            break;
                        }
                    }

                    tempEntry.filepath = Path.GetDirectoryName(iniFile) + tempEntry.source;

                    if (trues[0] && trues[1])
                    {
                        tempEntries.Add(tempEntry);
                    }
                }
            }

            entries = tempEntries;
        }
Ejemplo n.º 13
0
        private bool CheckEntry(iniEntry entry)
        {
            if (entry.entryType == iniEntry.EntryType.Container)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry));
                    }
                    return(false);
                }
            }
            else if (entry.entryType == iniEntry.EntryType.CustomImage)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry));
                    }
                    return(false);
                }
                if (string.IsNullOrEmpty(entry.name))
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"name\"...", entry.entry));
                    }
                    return(false);
                }
            }
            else if (entry.entryType == iniEntry.EntryType.StaticImage)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry));
                    }
                    return(false);
                }
                if (!settings.sourceManage)
                {
                    if (string.IsNullOrEmpty(entry.source))
                    {
                        if (!settings.ignoreMissing)
                        {
                            ErrorBox(string.Format("Entry: {0}\nInvalid argument \"source\"...", entry.entry));
                        }
                        return(false);
                    }
                }

                if (!File.Exists(entry.filepath))
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nFile not found...\n\n{1}", entry.entry, entry.filepath));
                    }
                    return(false);
                }
            }
            else if (entry.entryType == iniEntry.EntryType.CustomData)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry));
                    }
                    return(false);
                }
                if (string.IsNullOrEmpty(entry.name))
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"name\"...", entry.entry));
                    }
                    return(false);
                }
            }
            else if (entry.entryType == iniEntry.EntryType.StaticData)
            {
                if (string.IsNullOrEmpty(entry.file) || entry.file.Length < 2)
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nInvalid argument \"file\"...", entry.entry));
                    }
                    return(false);
                }
                if (!settings.sourceManage)
                {
                    if (string.IsNullOrEmpty(entry.source))
                    {
                        if (!settings.ignoreMissing)
                        {
                            ErrorBox(string.Format("Entry: {0}\nInvalid argument \"source\"...", entry.entry));
                        }
                        return(false);
                    }
                }

                if (!File.Exists(entry.filepath))
                {
                    if (!settings.ignoreMissing)
                    {
                        ErrorBox(string.Format("Entry: {0}\nFile not found...\n\n{1}", entry.entry, entry.filepath));
                    }
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 14
0
        private void _convertCsm()
        {
            string appDir = tempDir + "\\appOut\\";
            string csmDir = tempDir + "\\csmOut\\";
            string mymDir = tempDir + "\\mymOut\\";

            if (Directory.Exists(appDir)) Directory.Delete(appDir, true);
            if (Directory.Exists(csmDir)) Directory.Delete(csmDir, true);
            if (Directory.Exists(mymDir)) Directory.Delete(mymDir, true);

            List<iniEntry> entryList = new List<iniEntry>();

            Wii.U8.UnpackU8(tbCsm.Text, csmDir);
            Wii.U8.UnpackU8(tbApp.Text, appDir);

            string[] csmFiles = Directory.GetFiles(csmDir, "*", SearchOption.AllDirectories);

            if (intensiveAlgorithm)
            {
                for (int i = 0; i < csmFiles.Length; i++)
                {
                    ReportProgress((i * 100 / csmFiles.Length) / 2);

                    byte[] temp = Wii.Tools.LoadFileToByteArray(csmFiles[i], 0, 4);
                    if (temp[0] == 'Y' && temp[1] == 'a' && temp[2] == 'z' && temp[3] == '0') continue;

                    bool extracted = false;

                    while (!extracted)
                    {
                        byte[] fourBytes = Wii.Tools.LoadFileToByteArray(csmFiles[i].Replace(csmDir, appDir), 0, 4);

                        if (fourBytes[0] == 'A' && fourBytes[1] == 'S' &&
                                fourBytes[2] == 'H' && fourBytes[3] == '0') //ASH0
                        {
                            try
                            {
                                DeASH(csmFiles[i].Replace(csmDir, appDir));

                                File.Delete(csmFiles[i].Replace(csmDir, appDir));
                                FileInfo fi = new FileInfo(csmFiles[i].Replace(csmDir, appDir) + ".arc");
                                fi.MoveTo(csmFiles[i].Replace(csmDir, appDir));
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'L' && fourBytes[1] == 'Z' &&
                                fourBytes[2] == '7' && fourBytes[3] == '7') //Lz77
                        {
                            try
                            {
                                byte[] decompressedFile = Wii.Lz77.Decompress(File.ReadAllBytes(csmFiles[i].Replace(csmDir, appDir)), 0);

                                File.Delete(csmFiles[i].Replace(csmDir, appDir));
                                File.WriteAllBytes(csmFiles[i].Replace(csmDir, appDir), decompressedFile);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'Y' && fourBytes[1] == 'a' &&
                                fourBytes[2] == 'z' && fourBytes[3] == '0') //Yaz0
                        {
                            //Nothing to do about yet...
                            break;
                        }
                        else if (fourBytes[0] == 0x55 && fourBytes[1] == 0xaa &&
                                fourBytes[2] == 0x38 && fourBytes[3] == 0x2d) //U8
                        {
                            try
                            {
                                Wii.U8.UnpackU8(csmFiles[i].Replace(csmDir, appDir), csmFiles[i].Replace(csmDir, appDir).Replace(".", "_") + "_out");
                                File.Delete(csmFiles[i].Replace(csmDir, appDir));
                                extracted = true;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else break;
                    }

                    extracted = false;

                    while (!extracted)
                    {
                        byte[] fourBytes = Wii.Tools.LoadFileToByteArray(csmFiles[i], 0, 4);

                        if (fourBytes[0] == 'A' && fourBytes[1] == 'S' &&
                                fourBytes[2] == 'H' && fourBytes[3] == '0') //ASH0
                        {
                            try
                            {
                                DeASH(csmFiles[i]);

                                File.Delete(csmFiles[i]);
                                FileInfo fi = new FileInfo(csmFiles[i] + ".arc");
                                fi.MoveTo(csmFiles[i]);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'L' && fourBytes[1] == 'Z' &&
                                fourBytes[2] == '7' && fourBytes[3] == '7') //Lz77
                        {
                            try
                            {
                                byte[] decompressedFile = Wii.Lz77.Decompress(File.ReadAllBytes(csmFiles[i]), 0);

                                File.Delete(csmFiles[i]);
                                File.WriteAllBytes(csmFiles[i], decompressedFile);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else if (fourBytes[0] == 'Y' && fourBytes[1] == 'a' &&
                                fourBytes[2] == 'z' && fourBytes[3] == '0') //Yaz0
                        {
                            //Nothing to do about yet...
                            break;
                        }
                        else if (fourBytes[0] == 0x55 && fourBytes[1] == 0xaa &&
                                fourBytes[2] == 0x38 && fourBytes[3] == 0x2d) //U8
                        {
                            try
                            {
                                Wii.U8.UnpackU8(csmFiles[i], csmFiles[i].Replace(".", "_") + "_out");
                                File.Delete(csmFiles[i]);
                                extracted = true;
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                        else break;
                    }
                }

                csmFiles = Directory.GetFiles(csmDir, "*", SearchOption.AllDirectories);
            }

            for (int i = 0; i < csmFiles.Length; i++)
            {
                ReportProgress(((i * 100 / csmFiles.Length) / (intensiveAlgorithm ? 2 : 1)) + (intensiveAlgorithm ? 50 : 0));

                if (File.Exists(csmFiles[i].Replace(csmDir, appDir)))
                {
                    //File exists in original app
                    FileInfo fi = new FileInfo(csmFiles[i]);
                    FileInfo fi2 = new FileInfo(csmFiles[i].Replace(csmDir, appDir));

                    if (fi.Length == fi2.Length) //Same file
                        continue;
                }

                iniEntry tempEntry = new iniEntry();
                tempEntry.entryType = iniEntry.EntryType.StaticData;
                tempEntry.file = csmFiles[i].Replace(csmDir, string.Empty);
                if (!tempEntry.file.StartsWith("\\")) tempEntry.file = tempEntry.file.Insert(0, "\\");

                if (!Directory.Exists(Path.GetDirectoryName(mymDir + Path.GetExtension(csmFiles[i]).Remove(0, 1) + "\\" + Path.GetFileName(csmFiles[i]))))
                    Directory.CreateDirectory(Path.GetDirectoryName(mymDir + Path.GetExtension(csmFiles[i]).Remove(0, 1) + "\\" + Path.GetFileName(csmFiles[i])));

                string destFile = mymDir + Path.GetExtension(csmFiles[i]).Remove(0, 1) + "\\" + Path.GetFileName(csmFiles[i]);

                int counter = 0;
                FileInfo fi1 = new FileInfo(csmFiles[i]);
                string tempFile = destFile;

                while (File.Exists(destFile))
                {
                    FileInfo fi2 = new FileInfo(destFile);
                    if (fi1.Length == fi2.Length) break;

                    destFile = tempFile.Replace(Path.GetExtension(tempFile), (++counter).ToString() + Path.GetExtension(tempFile));
                }

                File.Copy(csmFiles[i], destFile, true);
                tempEntry.source = "\\" + Path.GetExtension(destFile).Remove(0, 1) + "\\" + Path.GetFileName(destFile);
                entryList.Add(tempEntry);
            }

            //---

            List<string> containersToManage = new List<string>();
            List<string> managedContainers = new List<string>();

            foreach (iniEntry tempEntry in entryList)
            {
                if (tempEntry.entryType == iniEntry.EntryType.Container)
                    managedContainers.Add(tempEntry.file);
                else
                {
                    if (tempEntry.file.Contains("_out"))
                    {
                        string tmpString = tempEntry.file.Remove(tempEntry.file.IndexOf("_out"));
                        tmpString = tmpString.Substring(0, tmpString.Length - 5) + tmpString.Substring(tmpString.Length - 5).Replace("_", ".");

                        if (!StringExistsInStringArray(tmpString, containersToManage.ToArray()))
                            containersToManage.Add(tmpString);
                    }
                }
            }

            List<string> leftContainers = new List<string>();

            foreach (string thisContainer in containersToManage)
            {
                if (!StringExistsInStringArray(thisContainer, managedContainers.ToArray()))
                    leftContainers.Add(thisContainer);
            }

            if (leftContainers.Count > 0)
            {
                List<iniEntry> newList = new List<iniEntry>();

                foreach (string thisContainer in leftContainers)
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.Container;
                    tempEntry.file = thisContainer;
                    tempEntry.type = iniEntry.ContainerType.ASH;

                    newList.Add(tempEntry);
                }

                newList.AddRange(entryList);
                entryList = newList;
            }

            //---

            mymini ini = mymini.CreateIni(entryList.ToArray());
            ini.Save(mymDir + "mym.ini");

            FastZip fZip = new FastZip();
            fZip.CreateZip(saveFile, mymDir, true, "");

            if (Directory.Exists(appDir)) Directory.Delete(appDir, true);
            if (Directory.Exists(csmDir)) Directory.Delete(csmDir, true);
            if (Directory.Exists(mymDir)) Directory.Delete(mymDir, true);

            ReportProgress(100);
            MessageBox.Show("Saved mym to:\n" + saveFile, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 15
0
        private void _saveMym(object _creationInfo)
        {
            SetControls(false);
            CreationInfo cInfo  = (CreationInfo)_creationInfo;
            string       outDir = tempDir + "newMym\\";

            if (Directory.Exists(outDir))
            {
                Directory.Delete(outDir, true);
            }
            Directory.CreateDirectory(outDir);

            int counter = 0;

            int[] counters = new int[5];

            //Build new ini
            List <iniEntry> tempEntries  = new List <iniEntry>();
            List <string[]> dataSources  = new List <string[]>();
            List <string[]> imageSources = new List <string[]>();

            foreach (object tempObject in cInfo.lbEntries)
            {
                ReportProgress(++counter * 100 / cInfo.lbEntries.Length, "Building mym.ini...");

                try
                {
                    iniEntry tempEntry = ini.GetEntry(tempObject.ToString());
                    if (!CheckEntry(tempEntry))
                    {
                        if (!settings.ignoreMissing)
                        {
                            ReportProgress(100, " "); SetControls(true); return;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (settings.sourceManage)
                    {
                        //Manage source
                        if (tempEntry.entryType == iniEntry.EntryType.StaticData)
                        {
                            if (Path.HasExtension(tempEntry.filepath))
                            {
                                tempEntry.source = "\\" + Path.GetExtension(tempEntry.filepath).Remove(0, 1) + "\\" + Path.GetFileName(tempEntry.filepath);

                                string tempSource = "\\" + Path.GetExtension(tempEntry.filepath).Remove(0, 1) + "\\" + Path.GetFileName(tempEntry.filepath);
                                int    i          = 1;

                                while (EntryExists(tempEntry, dataSources))
                                {
                                    tempEntry.source = tempSource.Insert(tempSource.LastIndexOf('.'), (++i).ToString());
                                }

                                FileInfo fi = new FileInfo(tempEntry.filepath);
                                dataSources.Add(new string[] { tempEntry.source, fi.Length.ToString() });
                            }
                            else
                            {
                                tempEntry.source = "\\" + Path.GetFileName(tempEntry.filepath);

                                string tempSource = "\\" + "\\" + Path.GetFileName(tempEntry.filepath);
                                int    i          = 1;

                                while (EntryExists(tempEntry, dataSources))
                                {
                                    tempEntry.source = tempSource.Insert(tempSource.LastIndexOf('.'), (++i).ToString());
                                }

                                FileInfo fi = new FileInfo(tempEntry.filepath);
                                dataSources.Add(new string[] { tempEntry.source, fi.Length.ToString() });
                            }
                        }
                        else if (tempEntry.entryType == iniEntry.EntryType.StaticImage)
                        {
                            tempEntry.source = "\\images\\" + Path.GetFileName(tempEntry.filepath);

                            string tempSource = "\\images\\" + Path.GetFileName(tempEntry.filepath);
                            int    i          = 1;

                            while (EntryExists(tempEntry, imageSources))
                            {
                                tempEntry.source = tempSource.Insert(tempSource.LastIndexOf('.'), (++i).ToString());
                            }

                            FileInfo fi = new FileInfo(tempEntry.filepath);
                            imageSources.Add(new string[] { tempEntry.source, fi.Length.ToString() });
                        }
                    }
                    if (settings.autoImageSize)
                    {
                        if (tempEntry.entryType == iniEntry.EntryType.CustomImage ||
                            tempEntry.entryType == iniEntry.EntryType.StaticImage)
                        {
                            //Get png width and height
                            Image img = Image.FromFile(tempEntry.filepath);
                            tempEntry.width  = img.Width;
                            tempEntry.height = img.Height;
                        }
                    }

                    tempEntries.Add(tempEntry);
                }
                catch { }
            }

            if (tempEntries.Count < 1)
            {
                ErrorBox("No entries left...");
                SetControls(true);
                return;
            }

            //Manage Containers
            if (settings.containerManage)
            {
                List <string> containersToManage = new List <string>();
                List <string> managedContainers  = new List <string>();

                foreach (iniEntry tempEntry in tempEntries)
                {
                    if (tempEntry.entryType == iniEntry.EntryType.Container)
                    {
                        managedContainers.Add(tempEntry.file);
                    }
                    else
                    {
                        if (tempEntry.file.Contains("_out"))
                        {
                            string tmpString = tempEntry.file.Remove(tempEntry.file.IndexOf("_out"));
                            tmpString = tmpString.Substring(0, tmpString.Length - 5) + tmpString.Substring(tmpString.Length - 5).Replace("_", ".");

                            if (!StringExistsInStringArray(tmpString, containersToManage.ToArray()))
                            {
                                containersToManage.Add(tmpString);
                            }
                        }
                    }
                }

                List <string> leftContainers = new List <string>();

                foreach (string thisContainer in containersToManage)
                {
                    if (!StringExistsInStringArray(thisContainer, managedContainers.ToArray()))
                    {
                        leftContainers.Add(thisContainer);
                    }
                }

                if (leftContainers.Count > 0)
                {
                    List <iniEntry> newList = new List <iniEntry>();

                    foreach (string thisContainer in leftContainers)
                    {
                        iniEntry tempEntry = new iniEntry();
                        tempEntry.entryType = iniEntry.EntryType.Container;
                        tempEntry.file      = thisContainer;
                        tempEntry.type      = iniEntry.ContainerType.ASH;

                        newList.Add(tempEntry);
                    }

                    newList.AddRange(tempEntries);
                    tempEntries = newList;
                }
            }

            ini           = new mymini();
            ini.EntryList = tempEntries;
            ini.Save(outDir + "mym.ini");
            counter = 0;

            //Copy files
            foreach (iniEntry tempEntry in ini.EntryList)
            {
                ReportProgress(++counter * 100 / ini.EntryList.Count, "Copying files...");

                if (tempEntry.entryType == iniEntry.EntryType.StaticImage ||
                    tempEntry.entryType == iniEntry.EntryType.StaticData)
                {
                    string sourceFile = tempEntry.filepath;
                    string destFile   = outDir + tempEntry.source;

                    if (!Directory.Exists(Path.GetDirectoryName(destFile)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(destFile));
                    }
                    File.Copy(sourceFile, destFile, true);
                }
            }

            //Zip file
            ReportProgress(0, "Packing mym...");
            ReportProgress(80, ""); // Fake, hm?!
            FastZip fZip = new FastZip();

            fZip.CreateZip((cInfo.createCsm) ? tempDir + "temp.mym" : cInfo.savePath, outDir, true, "");
            ReportProgress(100, " ");

            if (cInfo.closeAfter)
            {
                MethodInvoker m = new MethodInvoker(this.ExitApplication); this.Invoke(m); return;
            }
            if (!cInfo.createCsm)
            {
                InfoBox("Saved mym to:\n" + cInfo.savePath); SetControls(true); return;
            }

            _createCsm(cInfo.savePath, cInfo.appFile, tempDir + "temp.mym");
        }
Ejemplo n.º 16
0
        private void lbxIniEntrys_SelectedIndexChanged(object sender, EventArgs e)
        {
            SaveLastSelected();

            if (lbxIniEntries.SelectedIndex > -1)
            {
                lastSelected      = lbxIniEntries.SelectedIndex;
                lastSelectedEntry = lbxIniEntries.Items[lbxIniEntries.SelectedIndex].ToString();
                iniEntry tempEntry = ini.GetEntry(lbxIniEntries.SelectedItem.ToString());

                if (tempEntry.entryType == iniEntry.EntryType.Container)
                {
                    lbCont.Text                      = tempEntry.entry;
                    tbContainerFile.Text             = tempEntry.file;
                    cmbContainerFormat.SelectedIndex = (tempEntry.type == iniEntry.ContainerType.ASH) ? 0 : 1;

                    if (!panContainer.Visible)
                    {
                        HidePanels();
                        panContainer.Visible = true;
                    }
                }
                else if (tempEntry.entryType == iniEntry.EntryType.CustomImage)
                {
                    lbCimg.Text            = tempEntry.entry;
                    tbCustomImageFile.Text = tempEntry.file;
                    tbCustomImageName.Text = tempEntry.name;
                    if (!settings.autoImageSize)
                    {
                        tbCustomImageWidth.Text = tempEntry.width.ToString();
                    }
                    if (!settings.autoImageSize)
                    {
                        tbCustomImageHeight.Text = tempEntry.height.ToString();
                    }

                    if (tempEntry.format == iniEntry.TplFormat.RGB5A3)
                    {
                        cmbCustomImageFormat.SelectedIndex = 0;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.RGBA8)
                    {
                        cmbCustomImageFormat.SelectedIndex = 1;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.RGB565)
                    {
                        cmbCustomImageFormat.SelectedIndex = 2;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.I4)
                    {
                        cmbCustomImageFormat.SelectedIndex = 3;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.I8)
                    {
                        cmbCustomImageFormat.SelectedIndex = 4;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.IA4)
                    {
                        cmbCustomImageFormat.SelectedIndex = 5;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.IA8)
                    {
                        cmbCustomImageFormat.SelectedIndex = 6;
                    }

                    if (!panCustomImage.Visible)
                    {
                        HidePanels();
                        panCustomImage.Visible = true;
                    }
                }
                else if (tempEntry.entryType == iniEntry.EntryType.StaticImage)
                {
                    lbSimg.Text            = tempEntry.entry;
                    tbStaticImageFile.Text = tempEntry.file;
                    if (!settings.sourceManage)
                    {
                        tbStaticImageSource.Text = tempEntry.source;
                    }
                    if (!settings.autoImageSize)
                    {
                        tbStaticImageWidth.Text = tempEntry.width.ToString();
                    }
                    if (!settings.autoImageSize)
                    {
                        tbStaticImageHeight.Text = tempEntry.height.ToString();
                    }

                    if (tempEntry.format == iniEntry.TplFormat.RGB5A3)
                    {
                        cmbStaticImageFormat.SelectedIndex = 0;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.RGBA8)
                    {
                        cmbStaticImageFormat.SelectedIndex = 1;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.RGB565)
                    {
                        cmbStaticImageFormat.SelectedIndex = 2;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.I4)
                    {
                        cmbStaticImageFormat.SelectedIndex = 3;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.I8)
                    {
                        cmbStaticImageFormat.SelectedIndex = 4;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.IA4)
                    {
                        cmbStaticImageFormat.SelectedIndex = 5;
                    }
                    else if (tempEntry.format == iniEntry.TplFormat.IA8)
                    {
                        cmbStaticImageFormat.SelectedIndex = 6;
                    }
                    tbStaticImageFilepath.Text = tempEntry.filepath;

                    if (!panStaticImage.Visible)
                    {
                        HidePanels();
                        panStaticImage.Visible = true;
                    }
                }
                else if (tempEntry.entryType == iniEntry.EntryType.CustomData)
                {
                    lbCdta.Text           = tempEntry.entry;
                    tbCustomDataFile.Text = tempEntry.file;
                    tbCustomDataName.Text = tempEntry.name;

                    if (!panCustomData.Visible)
                    {
                        HidePanels();
                        panCustomData.Visible = true;
                    }
                }
                else if (tempEntry.entryType == iniEntry.EntryType.StaticData)
                {
                    lbSdta.Text           = tempEntry.entry;
                    tbStaticDataFile.Text = tempEntry.file;
                    if (!settings.sourceManage)
                    {
                        tbStaticDataSource.Text = tempEntry.source;
                    }

                    tbStaticDataFilepath.Text = tempEntry.filepath;

                    if (!panStaticData.Visible)
                    {
                        HidePanels();
                        panStaticData.Visible = true;
                    }
                }
            }
            else
            {
                HidePanels();
            }
        }
Ejemplo n.º 17
0
        private void SaveLastSelected()
        {
            if (lastSelected > -1 && lastSelected < lbxIniEntries.Items.Count && lbxIniEntries.Items[lastSelected].ToString() == lastSelectedEntry)
            {
                iniEntry tempEntry = ini.GetEntry(lbxIniEntries.Items[lastSelected].ToString());

                if (tempEntry.entryType == iniEntry.EntryType.Container)
                {
                    tempEntry.file = (tbContainerFile.Text.StartsWith("\\")) ? tbContainerFile.Text : tbContainerFile.Text.Insert(0, "\\");
                    tempEntry.type = (cmbContainerFormat.SelectedIndex == 0) ? iniEntry.ContainerType.ASH : iniEntry.ContainerType.U8;
                }
                else if (tempEntry.entryType == iniEntry.EntryType.CustomImage)
                {
                    tempEntry.file = (tbCustomImageFile.Text.StartsWith("\\")) ? tbCustomImageFile.Text : tbCustomImageFile.Text.Insert(0, "\\");
                    tempEntry.name = tbCustomImageName.Text;
                    if (!settings.autoImageSize)
                    {
                        tempEntry.width = int.Parse(tbCustomImageWidth.Text);
                    }
                    if (!settings.autoImageSize)
                    {
                        tempEntry.height = int.Parse(tbCustomImageHeight.Text);
                    }

                    if (cmbCustomImageFormat.SelectedIndex == 0)
                    {
                        tempEntry.format = iniEntry.TplFormat.RGB5A3;
                    }
                    else if (cmbCustomImageFormat.SelectedIndex == 1)
                    {
                        tempEntry.format = iniEntry.TplFormat.RGBA8;
                    }
                    else if (cmbCustomImageFormat.SelectedIndex == 2)
                    {
                        tempEntry.format = iniEntry.TplFormat.RGB565;
                    }
                    else if (cmbCustomImageFormat.SelectedIndex == 3)
                    {
                        tempEntry.format = iniEntry.TplFormat.I4;
                    }
                    else if (cmbCustomImageFormat.SelectedIndex == 4)
                    {
                        tempEntry.format = iniEntry.TplFormat.I8;
                    }
                    else if (cmbCustomImageFormat.SelectedIndex == 5)
                    {
                        tempEntry.format = iniEntry.TplFormat.IA4;
                    }
                    else if (cmbCustomImageFormat.SelectedIndex == 6)
                    {
                        tempEntry.format = iniEntry.TplFormat.IA8;
                    }
                }
                else if (tempEntry.entryType == iniEntry.EntryType.StaticImage)
                {
                    tempEntry.file = (tbStaticImageFile.Text.StartsWith("\\")) ? tbStaticImageFile.Text : tbStaticImageFile.Text.Insert(0, "\\");
                    if (!settings.sourceManage)
                    {
                        tempEntry.source = (tbStaticImageSource.Text.StartsWith("\\")) ? tbStaticImageSource.Text : tbStaticImageSource.Text.Insert(0, "\\");
                    }
                    if (!settings.autoImageSize)
                    {
                        tempEntry.width = int.Parse(tbStaticImageWidth.Text);
                    }
                    if (!settings.autoImageSize)
                    {
                        tempEntry.height = int.Parse(tbStaticImageHeight.Text);
                    }

                    if (cmbStaticImageFormat.SelectedIndex == 0)
                    {
                        tempEntry.format = iniEntry.TplFormat.RGB5A3;
                    }
                    else if (cmbStaticImageFormat.SelectedIndex == 1)
                    {
                        tempEntry.format = iniEntry.TplFormat.RGBA8;
                    }
                    else if (cmbStaticImageFormat.SelectedIndex == 2)
                    {
                        tempEntry.format = iniEntry.TplFormat.RGB565;
                    }
                    else if (cmbStaticImageFormat.SelectedIndex == 3)
                    {
                        tempEntry.format = iniEntry.TplFormat.I4;
                    }
                    else if (cmbStaticImageFormat.SelectedIndex == 4)
                    {
                        tempEntry.format = iniEntry.TplFormat.I8;
                    }
                    else if (cmbStaticImageFormat.SelectedIndex == 5)
                    {
                        tempEntry.format = iniEntry.TplFormat.IA4;
                    }
                    else if (cmbStaticImageFormat.SelectedIndex == 6)
                    {
                        tempEntry.format = iniEntry.TplFormat.IA8;
                    }

                    tempEntry.filepath = tbStaticImageFilepath.Text;
                }
                else if (tempEntry.entryType == iniEntry.EntryType.CustomData)
                {
                    tempEntry.file = (tbCustomDataFile.Text.StartsWith("\\")) ? tbCustomDataFile.Text : tbCustomDataFile.Text.Insert(0, "\\");
                    tempEntry.name = tbCustomDataName.Text;
                }
                else if (tempEntry.entryType == iniEntry.EntryType.StaticData)
                {
                    tempEntry.file = (tbStaticDataFile.Text.StartsWith("\\")) ? tbStaticDataFile.Text : tbStaticDataFile.Text.Insert(0, "\\");
                    if (!settings.sourceManage)
                    {
                        tempEntry.source = (tbStaticDataSource.Text.StartsWith("\\")) ? tbStaticDataSource.Text : tbStaticDataSource.Text.Insert(0, "\\");
                    }

                    tempEntry.filepath = tbStaticDataFilepath.Text;
                }

                ini.EditEntry(tempEntry);
            }
        }
Ejemplo n.º 18
0
 public void EditEntry(iniEntry editedEntry)
 {
     for (int i = 0; i < entries.Count; i++)
         if (entries[i].entry == editedEntry.entry) entries[i] = editedEntry;
 }
        private void DeASH(iniEntry mymC, string appOut)
        {
            ProcessStartInfo pInfo = new ProcessStartInfo(Application.StartupPath + "\\ASH.exe", string.Format("\"{0}\"", appOut + mymC.file));
            pInfo.UseShellExecute = false;
            //pInfo.RedirectStandardOutput = true;
            pInfo.CreateNoWindow = true;

            Process p = Process.Start(pInfo);
            p.WaitForExit();

            //ErrorBox(p.StandardOutput.ReadToEnd() + "\n\n" + mymC.file);
        }
Ejemplo n.º 20
0
        private void ParseIni()
        {
            string[] iniLines = File.ReadAllLines(iniFile);
            List<iniEntry> tempEntries = new List<iniEntry>();

            iniLines = CutComments(iniLines);

            for (int i = 0; i < iniLines.Length; i++)
            {
                ReportProgress((i + 1) * 100 / iniLines.Length, "Pasring mym.ini...");

                if (iniLines[i].ToLower().StartsWith("[cont")) //Container
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.Container;
                    tempEntry.entry = iniLines[i];
                    bool[] trues = new bool[] { false, false };
                    int j = i + 1;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("type="))
                        {
                            if (iniLines[j].ToUpper().Contains("ASH"))
                                tempEntry.type = iniEntry.ContainerType.ASH;
                            else
                                tempEntry.type = iniEntry.ContainerType.U8;

                            trues[1] = true;
                        }

                        j++;
                        if (j == iniLines.Length) break;
                    }

                    if (trues[0] && trues[1]) tempEntries.Add(tempEntry);
                }
                else if (iniLines[i].ToLower().StartsWith("[cimg")) //Custom Image
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.CustomImage;
                    tempEntry.entry = iniLines[i];
                    bool[] trues = new bool[] { false, false, false, false };
                    int j = i + 1;

                    tempEntry.format = iniEntry.TplFormat.RGB5A3;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("name="))
                        {
                            tempEntry.name = iniLines[j].Substring(5);
                            trues[1] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("width="))
                        {
                            try
                            {
                                tempEntry.width = int.Parse(iniLines[j].Substring(6));
                                trues[2] = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("height="))
                        {
                            try
                            {
                                tempEntry.height = int.Parse(iniLines[j].Substring(7));
                                trues[3] = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("format="))
                        {
                            if (iniLines[j].Substring(7).ToUpper().StartsWith("RGBA8"))
                                tempEntry.format = iniEntry.TplFormat.RGBA8;
                            else if (iniLines[j].Substring(7).ToUpper().StartsWith("RGB565"))
                                tempEntry.format = iniEntry.TplFormat.RGB565;
                            else if (iniLines[j].Substring(7).ToUpper() == "I4")
                                tempEntry.format = iniEntry.TplFormat.I4;
                            else if (iniLines[j].Substring(7).ToUpper() == "I8")
                                tempEntry.format = iniEntry.TplFormat.I8;
                            else if (iniLines[j].Substring(7).ToUpper() == "IA4")
                                tempEntry.format = iniEntry.TplFormat.IA4;
                            else if (iniLines[j].Substring(7).ToUpper() == "IA8")
                                tempEntry.format = iniEntry.TplFormat.IA8;
                        }

                        j++;
                        if (j == iniLines.Length) break;
                    }

                    if (trues[0] && trues[1] && trues[2] && trues[3]) tempEntries.Add(tempEntry);
                }
                else if (iniLines[i].ToLower().StartsWith("[simg")) //Static Image
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.StaticImage;
                    tempEntry.entry = iniLines[i];
                    bool[] trues = new bool[] { false, false, false, false };
                    int j = i + 1;

                    tempEntry.format = iniEntry.TplFormat.RGB5A3;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("source="))
                        {
                            tempEntry.source = iniLines[j].Substring(7);
                            trues[1] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("width="))
                        {
                            try
                            {
                                tempEntry.width = int.Parse(iniLines[j].Substring(6));
                                trues[2] = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("height="))
                        {
                            try
                            {
                                tempEntry.height = int.Parse(iniLines[j].Substring(7));
                                trues[3] = true;
                            }
                            catch { }
                        }
                        else if (iniLines[j].ToLower().StartsWith("format="))
                        {
                            if (iniLines[j].Substring(7).ToUpper() == "RGBA8")
                                tempEntry.format = iniEntry.TplFormat.RGBA8;
                            else if (iniLines[j].Substring(7).ToUpper() == "RGB565")
                                tempEntry.format = iniEntry.TplFormat.RGB565;
                            else if (iniLines[j].Substring(7).ToUpper() == "I4")
                                tempEntry.format = iniEntry.TplFormat.I4;
                            else if (iniLines[j].Substring(7).ToUpper() == "I8")
                                tempEntry.format = iniEntry.TplFormat.I8;
                            else if (iniLines[j].Substring(7).ToUpper() == "IA4")
                                tempEntry.format = iniEntry.TplFormat.IA4;
                            else if (iniLines[j].Substring(7).ToUpper() == "IA8")
                                tempEntry.format = iniEntry.TplFormat.IA8;
                        }

                        tempEntry.filepath = Path.GetDirectoryName(iniFile) + tempEntry.source;

                        j++;
                        if (j == iniLines.Length) break;
                    }

                    if (trues[0] && trues[1] && trues[2] && trues[3]) tempEntries.Add(tempEntry);
                }
                else if (iniLines[i].ToLower().StartsWith("[cdta")) //Custom Data
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.CustomData;
                    tempEntry.entry = iniLines[i];
                    bool[] trues = new bool[] { false, false };
                    int j = i + 1;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("name="))
                        {
                            tempEntry.name = iniLines[j].Substring(5);
                            trues[1] = true;
                        }

                        j++;
                        if (j == iniLines.Length) break;
                    }

                    if (trues[0] && trues[1]) tempEntries.Add(tempEntry);
                }
                else if (iniLines[i].ToLower().StartsWith("[sdta")) //Static Data
                {
                    iniEntry tempEntry = new iniEntry();
                    tempEntry.entryType = iniEntry.EntryType.StaticData;
                    tempEntry.entry = iniLines[i];
                    bool[] trues = new bool[] { false, false };
                    int j = i + 1;

                    while (!iniLines[j].StartsWith("["))
                    {
                        if (iniLines[j].ToLower().StartsWith("file="))
                        {
                            tempEntry.file = iniLines[j].Substring(5);
                            trues[0] = true;
                        }
                        else if (iniLines[j].ToLower().StartsWith("source="))
                        {
                            tempEntry.source = iniLines[j].Substring(7);
                            trues[1] = true;
                        }

                        j++;
                        if (j == iniLines.Length) break;
                    }

                    tempEntry.filepath = Path.GetDirectoryName(iniFile) + tempEntry.source;

                    if (trues[0] && trues[1]) tempEntries.Add(tempEntry);
                }
            }

            entries = tempEntries;
        }
        private bool EntryExists(iniEntry entry, List<string[]> list)
        {
            foreach (string[] array in list)
            {
                if (array[0] == entry.source)
                {
                    FileInfo fi = new FileInfo(entry.filepath);
                    if (fi.Length != int.Parse(array[1]))
                        return true;
                }
            }

            return false;
        }
Ejemplo n.º 22
0
 public static mymini CreateIni(iniEntry[] iniEntries)
 {
     mymini m = new mymini();
     m.entries = new List<iniEntry>(iniEntries);
     return m;
 }