예제 #1
0
        private void switchColors_Click(object sender, EventArgs e)
        {
            if (AllowSwitchSwap)
            {
                Data.GBAcolor oldColor = Editor.CurrentSprite.Palette.Colors[Index];

                Editor.CurrentSprite.Palette.Colors[Index]  = Editor.CurrentSprite.Palette.Colors[nIndex];
                Editor.CurrentSprite.Palette.Colors[nIndex] = oldColor;

                if (Editor.CurrentSprite.Type == Data.Sprite.SpriteType.Color256)
                {
                    #region 256color
                    for (int i = 0; i < Editor.CurrentSprite.ImageData.Length; i++)
                    {
                        if (Editor.CurrentSprite.ImageData[i] == Index)
                        {
                            Editor.CurrentSprite.ImageData[i] = (byte)nIndex;
                        }
                        else if (Editor.CurrentSprite.ImageData[i] == nIndex)
                        {
                            Editor.CurrentSprite.ImageData[i] = Index;
                        }
                    }
                    #endregion
                }
                else if (Editor.CurrentSprite.Type == Data.Sprite.SpriteType.Color16)
                {
                    #region 16color
                    for (int i = 0; i < Editor.CurrentSprite.ImageData.Length; i++)
                    {
                        byte r = (byte)(Editor.CurrentSprite.ImageData[i] & 0x0F);
                        byte l = (byte)((Editor.CurrentSprite.ImageData[i] & 0x0F0) >> 4);

                        if (r == Index)
                        {
                            r = (byte)nIndex;
                        }
                        else if (r == nIndex)
                        {
                            r = Index;
                        }

                        if (l == Index)
                        {
                            l = (byte)nIndex;
                        }
                        else if (l == nIndex)
                        {
                            l = Index;
                        }

                        Editor.CurrentSprite.ImageData[i] = (byte)((l << 4) | r);
                    }
                    #endregion
                }

                Redraw();
                Editor.Redraw();
            }
        }
예제 #2
0
        private void swapColors_Click(object sender, EventArgs e)
        {
            if (AllowSwitchSwap)
            {
                Data.GBAcolor oldColor = Editor.CurrentSprite.Palette.Colors[Index];

                Editor.CurrentSprite.Palette.Colors[Index]  = Editor.CurrentSprite.Palette.Colors[nIndex];
                Editor.CurrentSprite.Palette.Colors[nIndex] = oldColor;

                Redraw();
                Editor.Redraw();
            }
        }