Exemplo n.º 1
0
        public SSSEditorForm(string gct, string pac)
        {
            InitializeComponent();
            foreach (Control c in tblColorCodeKeys.Controls)
            {
                c.DoubleClick += (o, e) => {
                    tblColorCodeKeys.Visible = false;
                };
            }
            try {
                Icon = Icon.ExtractAssociatedIcon(System.Reflection.Assembly.GetCallingAssembly().Location);
            } catch (Exception e) {
                Console.WriteLine(e.StackTrace);
            }

            tabControl1.SelectedIndexChanged += tabControl1_SelectedIndexChanged;

            sss = gct != null
                                ? new CustomSSSCodeset(gct)
                                : new CustomSSSCodeset();

            if (pac != null)
            {
                ReloadIfValidPac(pac);
            }
            else
            {
                md80 = new BRRESNode();
                ReloadData();
            }

            FormClosed += (o, e) => TempFiles.DeleteAll();
        }
Exemplo n.º 2
0
 private void pasteAnSSSCodeToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (Form f = new Form()
     {
         Text = "Custom SSS Code"
     }) {
         Button ok = new Button()
         {
             Text         = "OK",
             Dock         = DockStyle.Bottom,
             DialogResult = System.Windows.Forms.DialogResult.OK
         };
         f.Controls.Add(ok);
         TextBox t = new TextBox()
         {
             Multiline  = true,
             Dock       = DockStyle.Fill,
             ScrollBars = ScrollBars.Vertical,
             Font       = new System.Drawing.Font("Consolas", 12),
         };
         f.Controls.Add(t);
         if (f.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
         {
             sss = new CustomSSSCodeset(t.Lines);
             ReloadData();
         }
     }
 }
Exemplo n.º 3
0
 public void LoadCustomSSS(string file)
 {
     if (File.Exists(file))
     {
         ManualSSS = new CustomSSSCodeset(file);
         MessageBox.Show("You will need to quit and restart this program if you want to go back to loading the GCT codeset automatically.");
     }
 }
Exemplo n.º 4
0
 private void openCodesetgcttxtToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dialog = new OpenFileDialog()) {
         dialog.Filter      = "Ocarina codes (*.gct, *.txt)|*.gct;*.txt";
         dialog.Multiselect = false;
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             sss = new CustomSSSCodeset(dialog.FileName);
             ReloadData();
         }
     }
 }
Exemplo n.º 5
0
        private void openSDCardRootToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var dialog = new FolderBrowserDialog()) {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    CustomSSSCodeset candidateSSS = null;

                    string[] gctPaths = new string[] {
                        "codes/RSBE01.gct",
                        "data/gecko/codes/RSBE01.gct",
                        "LegacyTE/RSBE01.gct",
                        "LegacyXP/RSBE01.gct",
                        "RSBE01.gct"
                    };
                    foreach (string gctPath in gctPaths)
                    {
                        if (File.Exists(dialog.SelectedPath + "/" + gctPath))
                        {
                            candidateSSS = new CustomSSSCodeset(dialog.SelectedPath + "/" + gctPath);
                            break;
                        }
                    }
                    if (candidateSSS == null)
                    {
                        MessageBox.Show(this, "Could not find one of: " + string.Join(", ", gctPaths),
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    string root = null;
                    foreach (string folder in new string[] { "/private/wii/app/RSBE/pf", "/projectm/pf", "/minusery/pf", "/LegacyTE/pf", "/LegacyXP/pf" })
                    {
                        foreach (string file in new string[] { "/menu2/sc_selmap.pac", "/menu2/sc_selmap_en.pac", "system/common5.pac", "system/common5_en.pac" })
                        {
                            if (File.Exists(dialog.SelectedPath + folder + "/" + file))
                            {
                                root = dialog.SelectedPath + folder + "/" + file;
                                break;
                            }
                        }
                    }
                    if (root == null)
                    {
                        MessageBox.Show(this, "Could not find common5 or sc_selmap.",
                                        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    ReloadIfValidPac(root, candidateSSS);
                }
            }
        }
Exemplo n.º 6
0
        private void ReloadIfValidPac(string file, CustomSSSCodeset sssIfOtherFileValid = null)
        {
            ResourceNode node      = NodeFactory.FromFile(null, file);
            ResourceNode p1icon    = node.FindChild("MenSelmapCursorPly.1", true);
            BRRESNode    candidate = (p1icon != null) ? p1icon.Parent.Parent as BRRESNode : null;

            if (candidate == null)
            {
                MessageBox.Show(this, "No SSS icons were found in the selected file.",
                                "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (md80 != null)
                {
                    md80.Dispose();
                }
                md80 = candidate;
                sss  = sssIfOtherFileValid ?? sss;
                ReloadData();
            }
        }
Exemplo n.º 7
0
        public static List <string> PacFilesBySSSOrder(CustomSSSCodeset sss)
        {
            List <string> list = new List <string>();

            foreach (int stage_id in sss.StageIDsInOrder)
            {
                if (stage_id >= 0x40)
                {
                    list.Add("STGCUSTOM" + (stage_id - 0x3F).ToString("X2") + ".pac");
                }
                else
                {
                    IEnumerable <string[]> q = from s in Stages
                                               where s.ID == stage_id
                                               select s.PacNames;
                    foreach (string[] ss in q)
                    {
                        list.AddRange(ss);
                    }
                }
            }

            return(list);
        }
Exemplo n.º 8
0
 public static string[] ForPac(CustomSSSCodeset sss, string filename)
 {
     return(ForPac(sss.TracklistModifier, sss.CMM, filename));
 }
Exemplo n.º 9
0
        public static void Copy(ResourceNode scSelmap, ResourceNode muMenumain, CustomSSSCodeset sss)
        {
            ResourceNode                miscData0 = muMenumain.FindChild("Misc Data [0]", false);
            List <ResourceNode>         chrToKeep = miscData0.FindChild("AnmChr(NW4R)", false).Children;
            Dictionary <string, string> tempFiles = new Dictionary <string, string>(chrToKeep.Count);

            foreach (ResourceNode n in chrToKeep)
            {
                string file = TempFiles.Create(".chr0");
                tempFiles.Add(n.Name, file);
                n.Export(file);
            }

            ResourceNode miscData80 = scSelmap.FindChild("Misc Data [80]", false);

            miscData0.ReplaceRaw(miscData80.WorkingSource.Address, miscData80.WorkingSource.Length);
            miscData0.SignalPropertyChange();

            List <ResourceNode> chrToReplace = miscData0.FindChild("AnmChr(NW4R)", false).Children;

            foreach (ResourceNode n in chrToReplace)
            {
                string file = tempFiles[n.Name];
                n.Replace(file);
            }

            string       xx_png = TempFiles.Create(".png");
            ResourceNode xx     = miscData0.FindChild("Textures(NW4R)/MenSelmapIcon.XX", false);
            bool         found  = false;

            if (xx != null)
            {
                xx.Export(xx_png);
                found = true;
            }
            else
            {
                Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BrawlCrate.StageManager.XX.png");
                if (stream != null)
                {
                    Image.FromStream(stream).Save(xx_png);
                    found = true;
                }
            }

            if (found)
            {
                foreach (ResourceNode tex in miscData0.FindChild("Textures(NW4R)", false).Children)
                {
                    byte icon_id;
                    if (tex.Name.StartsWith("MenSelmapIcon.") && byte.TryParse(tex.Name.Substring(14, 2), out icon_id))
                    {
                        byte stage_id = sss.StageForIcon(icon_id);
                        if (icon_id != 100 && (stage_id == 0x25 || stage_id > 0x33))
                        {
                            tex.Replace(xx_png);
                        }
                    }
                }
            }

            File.Delete(xx_png);
        }
Exemplo n.º 10
0
        public void UpdateDirectory()
        {
            Console.WriteLine(System.Environment.CurrentDirectory);
            if (sc_selmap != null)
            {
                sc_selmap.Dispose();
            }
            if (common5 != null)
            {
                common5.Dispose();
            }
            _openFilePath       = null;
            fileSizeBar.Maximum = 1214283;
            if (File.Exists("../../menu2/sc_selmap.pac"))
            {
                common5       = null;
                sc_selmap     = TempFiles.MakeTempNode("../../menu2/sc_selmap.pac");
                _openFilePath = "../../menu2/sc_selmap.pac";
            }
            else if (File.Exists("../../menu2/sc_selmap_en.pac"))
            {
                common5       = null;
                sc_selmap     = TempFiles.MakeTempNode("../../menu2/sc_selmap_en.pac");
                _openFilePath = "../../menu2/sc_selmap_en.pac";
            }
            else if (File.Exists("../../system/common5.pac"))
            {
                common5       = TempFiles.MakeTempNode("../../system/common5.pac");
                sc_selmap     = common5.FindChild("sc_selmap_en", false);
                _openFilePath = "../../system/common5.pac";
            }
            else if (File.Exists("../../system/common5_en.pac"))
            {
                common5       = TempFiles.MakeTempNode("../../system/common5_en.pac");
                sc_selmap     = common5.FindChild("sc_selmap_en", false);
                _openFilePath = "../../system/common5_en.pac";
            }
            else
            {
                common5     = null;
                sc_selmap   = null;
                label1.Text = "Could not load sc_selmap(_en) or common5(_en).";
            }
            if (_openFilePath != null)
            {
                updateFileSize();
                TEX0Node tex0 = sc_selmap.FindChild("MiscData[80]/Textures(NW4R)/MenSelmapFrontBg", false) as TEX0Node;
                if (tex0 != null)
                {
                    scribble = tex0.GetImage(0);
                }
                FindMuMenumain();
            }
            else
            {
                fileSizeBar.Value  = 0;
                fileSizeLabel.Text = "";
            }

            // Find and load GCT, if it exists
            AutoSSS = null;
            DirectoryInfo directory = new DirectoryInfo(Environment.CurrentDirectory);

            while (directory != null)
            {
                Console.WriteLine(directory);
                if (File.Exists(directory.FullName + "/data/gecko/codes/RSBE01.gct"))
                {
                    AutoSSS = new CustomSSSCodeset(File.ReadAllBytes(directory.FullName + "/data/gecko/codes/RSBE01.gct"));
                    break;
                }
                else if (File.Exists(directory.FullName + "/codes/RSBE01.gct"))
                {
                    AutoSSS = new CustomSSSCodeset(File.ReadAllBytes(directory.FullName + "/codes/RSBE01.gct"));
                    break;
                }
                directory = directory.Parent;
            }
        }
Exemplo n.º 11
0
        public PortraitViewer()
        {
            InitializeComponent();

            #region default sss
            string s = @"Pretty generic custom SSS (based on CEP 5.5)
* 046B8F5C 7C802378
* 046B8F64 7C6300AE
* 040AF618 5460083C
* 040AF68C 38840002
* 040AF6AC 5463083C
* 040AF6C0 88030001
* 040AF6E8 3860FFFF
* 040AF59C 3860000C
* 060B91C8 00000018
* BFA10014 7CDF3378
* 7CBE2B78 7C7D1B78
* 2D05FFFF 418A0014
* 006B929C 00000027
* 066B99D8 00000027
* 00010203 04050709
* 080A0B0C 0D0E0F10
* 11141516 1A191217
* 0618131D 1E1B1C1F
* 20212223 24252600
* 006B92A4 00000027
* 066B9A58 00000027
* 27282A2B 2C2D2E2F
* 30313233 34353637
* 38393A3B 3C3D3E3F
* 40414243 44454647
* 48494A4B 4C4D4E00
* 06407AAC 0000009E
* 01010202 03030404
* 05050606 07070808
* 0909330A 0B0B0C0C
* 0D0D0E0E 130F1410
* 15111612 17131814
* 19151C16 1D171E18
* 1F19201A 211B221C
* 231D241E 251F2932
* 2A332B34 2C352D36
* 2F373038 3139323A
* 2E3BFFFF 40204121
* 42224323 44244525
* 46264727 48284929
* 4A2A4B2B 4C2C4D2D
* 4E2E4F2F 50305131
* 523D533E 543F5540
* 56415742 58435944
* 5A455B46 5C475D48
* 5E495F4A 604B614C
* 624D634E 644F0000";
            DefaultSSS = new CustomSSSCodeset(s.Split('\n'));
            #endregion

            _iconNum          = -1;
            fileSizeBar.Style = ProgressBarStyle.Continuous;

            foreach (Control child in flowLayoutPanel1.Controls)
            {
                if (child is ImagePreviewPanel)
                {
                    (child as ImagePreviewPanel).DragEnter += panel1_DragEnter;
                    (child as ImagePreviewPanel).DragDrop  += panel1_DragDrop;
                }
            }

            //UpdateDirectory();
        }