Exemple #1
0
        private Bitmap SetPaletteColors(Bitmap _Bitmap, string _PaletteDataPath)
        {
            Bitmap ModifiedStandardBitmap = _Bitmap.Clone(new Rectangle(0, 0, _Bitmap.Width, _Bitmap.Height), PixelFormat.Format8bppIndexed);

            //Encore Palettes (WIP Potentially Improvable)
            RSDKv5.Color[] PaletteColors = new RSDKv5.Color[256];
            if (_PaletteDataPath != null && File.Exists(_PaletteDataPath))
            {
                PaletteDataPath = _PaletteDataPath;
                using (var stream = File.OpenRead(PaletteDataPath))
                {
                    for (int y = 0; y < 255; ++y)
                    {
                        PaletteColors[y].R = (byte)stream.ReadByte();
                        PaletteColors[y].G = (byte)stream.ReadByte();
                        PaletteColors[y].B = (byte)stream.ReadByte();
                    }
                }

                ColorPalette pal = ModifiedStandardBitmap.Palette;
                for (int y = 0; y < 255; ++y)
                {
                    pal.Entries[y] = SystemColor.FromArgb(PaletteColors[y].R, PaletteColors[y].G, PaletteColors[y].B);
                }
                ModifiedStandardBitmap.Palette = pal;

                return(ModifiedStandardBitmap);
            }
            else
            {
                return(_Bitmap);
            }
        }
        public static Bitmap SetEncoreColors(Bitmap map, bool NoEncoreColors)
        {
            if (Methods.Solution.SolutionState.Main.UseEncoreColors && NoEncoreColors == false)
            {
                return(SetColors((Bitmap)map.Clone(), ManiacEditor.Methods.Solution.SolutionPaths.EncorePalette[0]));
            }
            else
            {
                return(map);
            }

            Bitmap SetColors(Bitmap _bitmap, string encoreColors)
            {
                if (encoreColors == "")
                {
                    return(_bitmap);
                }
                Bitmap _bitmapEditMemory;

                _bitmapEditMemory = _bitmap.Clone(new Rectangle(0, 0, _bitmap.Width, _bitmap.Height), PixelFormat.Format8bppIndexed);

                //Encore Palettes (WIP Potentially Improvable)
                RSDKv5.Color[] readableColors    = new RSDKv5.Color[256];
                bool           loadSpecialColors = false;

                if (encoreColors != null && File.Exists(encoreColors))
                {
                    using (var stream = File.OpenRead(encoreColors))
                    {
                        for (int y = 0; y < 255; ++y)
                        {
                            readableColors[y].R = (byte)stream.ReadByte();
                            readableColors[y].G = (byte)stream.ReadByte();
                            readableColors[y].B = (byte)stream.ReadByte();
                        }
                    }
                    loadSpecialColors = true;
                }

                if (loadSpecialColors == true)
                {
                    ColorPalette pal = _bitmapEditMemory.Palette;
                    if (_bitmapEditMemory.Palette.Entries.Length == 256)
                    {
                        for (int y = 0; y < 255; ++y)
                        {
                            if (readableColors[y].R != 255 && readableColors[y].G != 0 && readableColors[y].B != 255)
                            {
                                pal.Entries[y] = SystemColor.FromArgb(readableColors[y].R, readableColors[y].G, readableColors[y].B);
                            }
                        }
                        _bitmapEditMemory.Palette = pal;
                    }
                }
                _bitmap = (Bitmap)_bitmapEditMemory.Clone();
                _bitmapEditMemory.Dispose();
                return(_bitmap);
            }
        }
Exemple #3
0
 public static RSDKv5.Color AttributesMapColor(string name, EditorEntity entity)
 {
     if (entity.attributesMap.ContainsKey(name))
     {
         RSDKv5.Color value = entity.attributesMap[name].ValueColor;
         return(value);
     }
     else
     {
         return(RSDKv5.Color.EMPTY);
     }
 }
Exemple #4
0
        private void LoadEncoreColors(string encoreColors = null)
        {
            Bitmap _bitmapEditMemory;

            _bitmapEditMemory = _bitmap.Clone(new Rectangle(0, 0, _bitmap.Width, _bitmap.Height), PixelFormat.Format8bppIndexed);
            //Debug.Print(_bitmapEditMemory.Palette.Entries.Length.ToString() + "(1)");

            //Encore Palettes (WIP Potentially Improvable)
            RSDKv5.Color[] readableColors    = new RSDKv5.Color[256];
            bool           loadSpecialColors = false;

            if (encoreColors != null && File.Exists(encoreColors))
            {
                using (var stream = File.OpenRead(encoreColors))
                {
                    for (int y = 0; y < 255; ++y)
                    {
                        readableColors[y].R = (byte)stream.ReadByte();
                        readableColors[y].G = (byte)stream.ReadByte();
                        readableColors[y].B = (byte)stream.ReadByte();
                    }
                }
                loadSpecialColors = true;
            }

            if (loadSpecialColors == true)
            {
                ColorPalette pal = _bitmapEditMemory.Palette;
                //Debug.Print(_bitmapEditMemory.Palette.Entries.Length.ToString() + "(2)");
                for (int y = 0; y < 255; ++y)
                {
                    //if (readableColors[y].R != 255 && readableColors[y].G != 0 && readableColors[y].B != 255)
                    //{
                    pal.Entries[y] = SystemColor.FromArgb(readableColors[y].R, readableColors[y].G, readableColors[y].B);
                    //}
                }
                _bitmapEditMemory.Palette = pal;
            }
            _bitmap = _bitmapEditMemory;
        }
Exemple #5
0
        private void Init()
        {
            SceneLayer layer = scene.Layers.Single(a => a.Name == "Playfield\0");

            Width  = layer.Width;
            Height = layer.Height;
            Layout = new SphereType[Width, Height];
            for (ushort y = 0; y < Height; y++)
            {
                for (ushort x = 0; x < Width; x++)
                {
                    SphereType sp = (SphereType)(layer.Tiles[y][x] & 0x3FF);
                    switch (sp)
                    {
                    case SphereType.StartN:
                    case SphereType.StartW:
                    case SphereType.StartS:
                    case SphereType.StartE:
                        Angle  = (byte)(sp - SphereType.StartN);
                        StartX = x;
                        StartY = y;
                        break;

                    case (SphereType)0x3FF:
                        break;

                    default:
                        Layout[x, y] = sp;
                        break;
                    }
                }
            }
            SceneLayer rings = scene.Layers.Single(a => a.Name == "Ring Count\0");

            for (int y = 0; y < Math.Min(rings.Height, Height); y++)
            {
                for (int x = 0; x < Math.Min(rings.Width, Width); x++)
                {
                    if ((SphereType)(rings.Tiles[y][x] & 0x3FF) == SphereType.Ring)
                    {
                        Layout[x, y] |= SphereType.RingFlag;
                    }
                }
            }
            SceneEntity palent = scene.Objects.SingleOrDefault(a => a.Name.Name == "BSS_Palette")?.Entities[0];

            if (palent != null)
            {
                HasPal     = true;
                PaletteID  = palent.GetAttribute("paletteID").ValueVar;
                SkyAlpha   = palent.GetAttribute("skyAlpha").ValueUInt8;
                GlobeAlpha = palent.GetAttribute("globeAlpha").ValueUInt8;
                RSDKColor tmp = palent.GetAttribute("playfieldA").ValueColor;
                PlayfieldA = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B);
                tmp        = palent.GetAttribute("playfieldB").ValueColor;
                PlayfieldB = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B);
                tmp        = palent.GetAttribute("bgColor1").ValueColor;
                BGColor1   = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B);
                tmp        = palent.GetAttribute("bgColor2").ValueColor;
                BGColor2   = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B);
                tmp        = palent.GetAttribute("bgColor3").ValueColor;
                BGColor3   = DrawingColor.FromArgb(tmp.R, tmp.G, tmp.B);
            }
        }