예제 #1
0
 // Update RichTextBox
 public void updateStatus(string status, bool preBreak = true)
 {
     try
     {
         if (RTB_Status.InvokeRequired)
             RTB_Status.Invoke((MethodInvoker)delegate
             {
                 RTB_Status.AppendText(((preBreak) ? Environment.NewLine : "") + status);
                 RTB_Status.SelectionStart = RTB_Status.Text.Length;
                 RTB_Status.ScrollToCaret();
             });
         else
         {
             RTB_Status.AppendText(status + Environment.NewLine);
             RTB_Status.SelectionStart = RTB_Status.Text.Length;
             RTB_Status.ScrollToCaret();
         }
     }
     catch { }
 }
예제 #2
0
파일: Main.cs 프로젝트: SirBelga/pk3DS
        private void openQuick(string path)
        {
            FileInfo fi = new FileInfo(path);

            if (!Directory.Exists(path))
            {
                return;
            }

            if (threads > 0)
            {
                Util.Alert("Please wait for all operations to finish first."); return;
            }
            if (fi.Name.Contains("code.bin"))
            {
                if (fi.Length % 0x200 == 0 && (Util.Prompt(MessageBoxButtons.YesNo, "Detected Decompressed code.bin.", "Compress? File will be replaced.") == DialogResult.Yes))
                {
                    new Thread(() => { threads++; new BLZCoder(new[] { "-en", path }, pBar1); threads--; Util.Alert("Compressed!"); }).Start();
                }
                else if (Util.Prompt(MessageBoxButtons.YesNo, "Detected Compressed code.bin.", "Decompress? File will be replaced.") == DialogResult.Yes)
                {
                    new Thread(() => { threads++; new BLZCoder(new[] { "-d", path }, pBar1); threads--; Util.Alert("Decompressed!"); }).Start();
                }
            }
            else
            {
                // Check for ROMFS/EXEFS
                RomFS = ExeFS = null; // Reset
                string[] folders = Directory.GetDirectories(path);
                int      count   = folders.Length;
                if (count != 2 && count != 1)
                {
                    return;                           // Only want exefs & romfs (can have exheader there too, it's not a folder)
                }
                {
                    // First file should be 'exe'
                    if (new FileInfo(folders[0]).Name.ToLower().Contains("exe") && Directory.Exists(folders[0]))
                    {
                        checkIfExeFS(folders[0]);
                    }
                    if (new FileInfo(folders[count - 1]).Name.ToLower().Contains("rom") && Directory.Exists(folders[count - 1]))
                    {
                        checkIfRomFS(folders[count - 1]);
                    }

                    GB_RomFS.Enabled    = (RomFS != null);
                    GB_ExeFS.Enabled    = (RomFS != null && ExeFS != null);
                    B_MoveTutor.Enabled = oras; // Default false unless loaded
                    if (RomFS != null)
                    {
                        if (L_Game.Text == "Game Loaded: ORAS" || L_Game.Text == "Game Loaded: XY")
                        {
                            Directory.Delete("personal", true);
                        }                                       // Force reloading of personal data if the game is switched.
                        L_Game.Text = (oras) ? "Game Loaded: ORAS" : "Game Loaded: XY"; TB_Path.Text = path;
                    }
                    else if (ExeFS != null)
                    {
                        L_Game.Text = "ExeFS loaded - no RomFS"; TB_Path.Text = path;
                    }
                    else
                    {
                        L_Game.Text = "No Game Loaded"; TB_Path.Text = "";
                    }

                    if (RomFS != null)
                    {
                        // Trigger Data Loading
                        if (RTB_Status.Text.Length > 0)
                        {
                            RTB_Status.Clear();
                        }
                        updateStatus("Data found! Loading persistent data for subforms...", false);
                        changeLanguage(null, null);
                    }

                    // Method finished.
                    SystemSounds.Asterisk.Play();
                }
            }
        }