public void Trim()
        {
            while (courseDescription.Count() != 0)
            {
                LineDescriptionEx lde = courseDescription.Last();

                if (lde == null || lde.IsEmpty())
                {
                    courseDescription.RemoveAt(courseDescription.Count() - 1);
                }
                else
                {
                    break;
                }
            }

            while (secretDescription.Count() != 0)
            {
                LineDescriptionEx lde = secretDescription.Last();

                if (lde == null || lde.IsEmpty())
                {
                    secretDescription.RemoveAt(secretDescription.Count() - 1);
                }
                else
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        //TODO: Store in file
        static public LayoutDescriptionEx GenerateDefault()
        {
            List <LineDescriptionEx> courseLD = new LineDescriptionEx[16].ToList();
            List <LineDescriptionEx> secretLD = new LineDescriptionEx[16].ToList();

            int[]    linesForSecrets     = { 0, 1, 2, 3, 9, 5, 6, 7, 13, 14, 15, 11 };
            int[]    offsetForSecrets    = { 0, 0xb, 0xb, 0, 0, 0xb, 0xb, 0xb, 0, 0, 0, 0 };
            byte[]   highlightForSecrets = { 0, 1 << 4 | 1 << 6, 1 << 5 | 1 << 7, 0, 0, 1 << 2, 1 << 1, 1 << 3, 0, 0, 0, 0 };
            string[] namesForSecrets     = { "--", "B1", "B2", "B3", "Sl", "MC", "WC", "VC", "S1", "S2", "S3", "OW" };

            courseLD[0] = new TextOnlyLineDescription("Main Courses");
            for (int course = 1; course <= 15; course++)
            {
                string drawString = course.ToString("D2");
                courseLD[course] = new StarsLineDescription(drawString, 255, course + 11, 0, 0);
            }

            for (int course = 1; course <= 10; course++) //Secret course
            {
                secretLD[linesForSecrets[course]] = new StarsLineDescription(namesForSecrets[course], 255, course + 26, highlightForSecrets[course], offsetForSecrets[course]);
            }
            secretLD[linesForSecrets[11]] = new StarsLineDescription(namesForSecrets[11], 255, 8, 0, 0);

            secretLD[0]  = new TextOnlyLineDescription("Bowser Courses");
            secretLD[4]  = new TextOnlyLineDescription("Cap Levels");
            secretLD[8]  = new TextOnlyLineDescription("Slide");
            secretLD[10] = new TextOnlyLineDescription("Overworld Stars");
            secretLD[12] = new TextOnlyLineDescription("Secret Stars");

            return(new LayoutDescriptionEx(courseLD, secretLD, Resource.gold_star, "182", 7));
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textOnlyCheckbox.Checked)
            {
                lind = new TextOnlyLineDescription(stringTextBox.Text);
            }
            else
            {
                byte mask   = 0;
                int  offset = 0;

                if (checkBox1.Checked)
                {
                    mask |= (1 << 0);
                }
                if (checkBox2.Checked)
                {
                    mask |= (1 << 1);
                }
                if (checkBox3.Checked)
                {
                    mask |= (1 << 2);
                }
                if (checkBox4.Checked)
                {
                    mask |= (1 << 3);
                }
                if (checkBox5.Checked)
                {
                    mask |= (1 << 4);
                }
                if (checkBox6.Checked)
                {
                    mask |= (1 << 5);
                }
                if (checkBox7.Checked)
                {
                    mask |= (1 << 6);
                }
                if (checkBox8.Checked)
                {
                    mask |= (1 << 7);
                }

                offset = offsetComboBox.SelectedIndex + 8;
                int.TryParse(highlightOffsetTextBox.Text, out int highlightOffset);

                lind = new StarsLineDescription(stringTextBox.Text, oldMask, offset, mask, highlightOffset);
            }

            starsShown = is8StarsCheckbox.Checked ? 8 : 7;

            this.Close();
        }
Esempio n. 4
0
        public void Trim()
        {
            while (courseDescription.Count() != 0)
            {
                LineDescriptionEx lde = courseDescription.Last();

                if (lde == null || lde.IsEmpty())
                {
                    courseDescription.RemoveAt(courseDescription.Count() - 1);
                }
                else
                {
                    break;
                }
            }

            while (secretDescription.Count() != 0)
            {
                LineDescriptionEx lde = secretDescription.Last();

                if (lde == null || lde.IsEmpty())
                {
                    secretDescription.RemoveAt(secretDescription.Count() - 1);
                }
                else
                {
                    break;
                }
            }

            foreach (var ld in courseDescription)
            {
                if (ld is object)
                {
                    ld.FixType();
                }
            }
            foreach (var ld in secretDescription)
            {
                if (ld is object)
                {
                    ld.FixType();
                }
            }
        }
        private void EditWarps()
        {
            if (mm.IsDecomp)
            {
                MessageBox.Show("No cheating on decomp ROMs allowed FUNgineer", "Decomp Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int  X = picX; int Y = picY;
            int  line     = (int)Math.Floor(Y / gm.SHeight);
            bool isSecret = ((int)Math.Floor(X / (gm.Width / 2))) == 1;
            int  star     = (int)Math.Floor((X - (isSecret ? (gm.Width / 2) : 0)) / gm.SWidth);

            if (line > ld.GetLength())
            {
                return;
            }

            try
            {
                LineDescriptionEx curld = null;
                do
                {
                    curld = isSecret ? ld.secretDescription[line] : ld.courseDescription[line];

                    if (line > ld.GetLength())
                    {
                        return;
                    }

                    line++;
                } while (curld == null || (curld is TextOnlyLineDescription));


                if (curld is StarsLineDescription sld)
                {
                    mm.WriteWarp(wd is object?wd.warp: (byte)0xa, (byte)LevelInfo.FindByEEPOffset(sld.offset).Level, wd is object?wd.area: (byte)1);
                }

                return;
            }
            catch (Exception) { }
        }
Esempio n. 6
0
        private void EditWarps()
        {
            int  X = picX; int Y = picY;
            int  line     = (int)Math.Floor(Y / gm.SHeight);
            bool isSecret = ((int)Math.Floor(X / (gm.Width / 2))) == 1;
            int  star     = (int)Math.Floor((X - (isSecret ? (gm.Width / 2) : 0)) / gm.SWidth);

            if (line > ld.GetLength())
            {
                return;
            }

            try
            {
                LineDescriptionEx curld = null;
                do
                {
                    curld = isSecret ? ld.secretDescription[line] : ld.courseDescription[line];

                    if (line > ld.GetLength())
                    {
                        return;
                    }

                    line++;
                } while (curld == null || (curld is TextOnlyLineDescription));


                if (curld is StarsLineDescription sld)
                {
                    mm.WriteWarp(wd.warp, (byte)LevelInfo.FindByEEPOffset(sld.offset).Level, wd.area);
                }

                return;
            }
            catch (Exception) { }
        }
        public LayoutDescriptionEx(LineDescription[] courseDescriptionOut, LineDescription[] secretDescriptionOut, Bitmap star, string starAmount)
        {
            starsShown = 7;

            courseDescription = new List <LineDescriptionEx>();
            secretDescription = new List <LineDescriptionEx>();

            foreach (LineDescription lined in courseDescriptionOut)
            {
                LineDescriptionEx lde = null;

                if (lined != null)
                {
                    if (lined.isTextOnly)
                    {
                        lde = new TextOnlyLineDescription(lined.text);
                    }
                    else
                    {
                        byte highlightStarMask   = 0;
                        int  highlightStarOffset = 0;

                        if (lined.text == "WC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 1;
                        }

                        if (lined.text == "MC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 2;
                        }

                        if (lined.text == "VC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 3;
                        }

                        if (lined.text == "B1")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 4 | 1 << 6;
                        }

                        if (lined.text == "B2")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 5 | 1 << 7;
                        }

                        lde = new StarsLineDescription(lined.text, (byte)((lined.starMask >> 1) | 1 << 7), lined.offset + 8, highlightStarMask, highlightStarOffset);
                    }
                }

                courseDescription.Add(lde);
            }

            foreach (LineDescription lined in secretDescriptionOut)
            {
                LineDescriptionEx lde = null;

                if (lined != null)
                {
                    if (lined.isTextOnly)
                    {
                        lde = new TextOnlyLineDescription(lined.text);
                    }
                    else
                    {
                        byte highlightStarMask   = 0;
                        int  highlightStarOffset = 0;

                        if (lined.text == "WC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 1;
                        }

                        if (lined.text == "MC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 2;
                        }

                        if (lined.text == "VC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 3;
                        }

                        if (lined.text == "B1")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 4 | 1 << 6;
                        }

                        if (lined.text == "B2")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 5 | 1 << 7;
                        }

                        lde = new StarsLineDescription(lined.text, (byte)(lined.starMask >> 1 | (1 << 7)), lined.offset + 8, highlightStarMask, highlightStarOffset);
                    }
                }

                secretDescription.Add(lde);
            }

            this.starAmount = starAmount;

            Trim();

            goldStar = star;
            darkStar = new Bitmap(goldStar.Width, goldStar.Height);
            if (goldStar.Width != 20 || goldStar.Height != 20)
            {
                Compress();
            }

            GenerateDarkStar();
            GenerateOutline();
        }
        // Method for converting from old to new Layouts
        public LayoutDescriptionEx(LayoutDescription ld)
        {
            starsShown = 7;

            courseDescription = new List <LineDescriptionEx>();
            secretDescription = new List <LineDescriptionEx>();

            foreach (LineDescription lined in ld.courseDescription)
            {
                LineDescriptionEx lde = null;

                if (lined != null)
                {
                    if (lined.isTextOnly)
                    {
                        lde = new TextOnlyLineDescription(lined.text);
                    }
                    else
                    {
                        byte highlightStarMask   = 0;
                        int  highlightStarOffset = 0;

                        if (lined.text == "WC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 1;
                        }

                        if (lined.text == "MC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 2;
                        }

                        if (lined.text == "VC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 3;
                        }

                        if (lined.text == "B1")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 4 | 1 << 6;
                        }

                        if (lined.text == "B2")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 5 | 1 << 7;
                        }

                        lde = new StarsLineDescription(lined.text, (byte)(lined.starMask >> 1 | (1 << 7)), lined.offset + 8, highlightStarMask, highlightStarOffset);
                    }
                }

                courseDescription.Add(lde);
            }

            foreach (LineDescription lined in ld.secretDescription)
            {
                LineDescriptionEx lde = null;

                if (lined != null)
                {
                    if (lined.isTextOnly)
                    {
                        lde = new TextOnlyLineDescription(lined.text);
                    }
                    else
                    {
                        byte highlightStarMask   = 0;
                        int  highlightStarOffset = 0;

                        if (lined.text == "WC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 1;
                        }

                        if (lined.text == "MC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 2;
                        }

                        if (lined.text == "VC")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 3;
                        }

                        if (lined.text == "B1")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 4 | 1 << 6;
                        }

                        if (lined.text == "B2")
                        {
                            highlightStarOffset = 0xB;
                            highlightStarMask   = 1 << 5 | 1 << 7;
                        }

                        lde = new StarsLineDescription(lined.text, (byte)(lined.starMask >> 1 | (1 << 7)), lined.offset + 8, highlightStarMask, highlightStarOffset);
                    }
                }

                secretDescription.Add(lde);
            }

            this.goldStar     = ld.goldStar;
            this.darkStar     = ld.darkStar;
            this.redOutline   = ld.redOutline;
            this.greenOutline = ld.greenOutline;
            this.starAmount   = ld.starAmount;

            Trim();
        }
        public Settings(LineDescriptionEx lind, int starsShown)
        {
            InitializeComponent();
            this.lind       = lind;
            this.starsShown = starsShown;
            if (starsShown == 8)
            {
                this.is8StarsCheckbox.Checked = true;
            }

            textOnlyCheckbox.Checked = lind is TextOnlyLineDescription;

            if (lind is TextOnlyLineDescription told)
            {
                stringTextBox.Text = told.text;
                oldMask            = 0x7F;
            }
            if (lind is StarsLineDescription sld)
            {
                stringTextBox.Text = sld.text;
                if (sld.offset != 0 && sld.offset != 8)
                {
                    offsetComboBox.SelectedIndex = sld.offset - 12;
                }
                else
                {
                    offsetComboBox.SelectedIndex = offsetComboBox.Items.Count - 1;
                }

                byte mask = sld.highlightStarMask;
                if ((mask & (1 << 0)) != 0)
                {
                    checkBox1.Checked = true;
                }
                if ((mask & (1 << 1)) != 0)
                {
                    checkBox2.Checked = true;
                }
                if ((mask & (1 << 2)) != 0)
                {
                    checkBox3.Checked = true;
                }
                if ((mask & (1 << 3)) != 0)
                {
                    checkBox4.Checked = true;
                }
                if ((mask & (1 << 4)) != 0)
                {
                    checkBox5.Checked = true;
                }
                if ((mask & (1 << 5)) != 0)
                {
                    checkBox6.Checked = true;
                }
                if ((mask & (1 << 6)) != 0)
                {
                    checkBox7.Checked = true;
                }
                if ((mask & (1 << 7)) != 0)
                {
                    checkBox8.Checked = true;
                }

                oldMask = sld.starMask;
                highlightOffsetTextBox.Text = sld.highlightOffset.ToString();

                offsetComboBox.SelectedIndex = sld.offset == 8 ? offsetComboBox.Items.Count - 1 : sld.offset - 12;
            }

            highlightPresetComboBox.SelectedIndex = 0;

            stringTextBox.Select();
        }