示例#1
0
 /// <summary>
 /// <para>Searches for colour in the palette and returns the index of the colour.</para>
 /// </summary>
 /// <param name="col">The colour to search for.</param>
 /// <returns>The index of where the colour is located.</returns>
 public byte GetIndex(ManiaColor col)
 {
     for (byte i = 0; i < Palette.Colours.Length; ++i)
     {
         if (Palette.Colours[i].Red == col.Red &&
             Palette.Colours[i].Green == col.Green &&
             Palette.Colours[i].Blue == col.Blue)
         {
             return(i);
         }
     }
     return(0);
 }
示例#2
0
 // TODO: Make this function static
 /// <summary>
 /// <para>Searches for colour in a given palette and returns the index of the colour.</para>
 /// </summary>
 /// <param name="col">The colour to search for.</param>
 /// <param name="pal">The palette to search in.</param>
 /// <returns>The index of where the colour is located.</returns>
 public byte GetIndex(ManiaColor col, ManiaColor[] pal)
 {
     for (byte i = 0; i < pal.Length; ++i)
     {
         if (pal[i].Red == col.Red &&
             pal[i].Green == col.Green &&
             pal[i].Blue == col.Blue)
         {
             return(i);
         }
     }
     return(0);
 }
        private void UI_PaletteSlot_LeftMouseDown(object sender, MouseButtonEventArgs e)
        {
            Memory.Attach("SonicMania");
            int addr = PaletteAddresses[CurrentPaletteSet] + 2 * (int)(sender as Grid).Tag;

            if (!ready)
            {
                return;
            }
            ready = false;
            if (ColourPickerClosed)
            {
                ColorPicker = null;
            }
            else if (ColorPicker != null)
            {
                Palettes[CurrentPaletteSet].Colours[CurrentColourSlot] = OldColour;
                CurrentColourSlot = (int)(sender as Grid).Tag;
                OldColour         = Palettes[CurrentPaletteSet].Colours[CurrentColourSlot];
                ColorPicker.Invoke(new Action(() =>
                {
                    ColorPicker.Color = System.Drawing.Color.FromArgb(
                        Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Red,
                        Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Green,
                        Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Blue
                        );
                    ColorPicker.Activate();
                }));
                ready = true;
                return;
            }
            ColourPickerClosed = false;
            CurrentColourSlot  = (int)(sender as Grid).Tag;
            new Thread(() =>
            {
                OldColour             = Palettes[CurrentPaletteSet].Colours[CurrentColourSlot];
                ColorPicker           = new ColorPickerDialog();
                ColorPicker.BackColor = System.Drawing.Color.FromArgb(0x2D, 0x2D, 0x30);
                ColorPicker.ForeColor = System.Drawing.Color.FromArgb(0xEE, 0xEE, 0xEE);
                ColorPicker.Color     = System.Drawing.Color.FromArgb(
                    Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Red,
                    Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Green,
                    Palettes[CurrentPaletteSet].Colours[CurrentColourSlot].Blue
                    );
                ColorPicker.FormClosed   += ColorPicker_FormClosed;
                ColorPicker.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
                ready = true;
                ColorPicker.ShowDialog();
            }).Start();
        }