Ejemplo n.º 1
0
        void AddLogo(List <Texture2D> list, int count)
        {
            List <string> planets = new[] { "Sun", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune" }.ToList();

            if (FixLoadingScreen.keepStockLogo)
            {
                planets.Add("StockLogo");
            }

            for (int i = 0; i < Math.Min(count, 9); i++)
            {
                int       planetIndex = rnd.Next(planets.Count);
                Texture2D tex         = PNGtools.Load(path + "Planets/" + planets[planetIndex] + ".png");
                Color[]   logo        = PNGtools.Load(path + "Fixes/SASSlogo.png", false).GetPixels();

                planets.RemoveAt(planetIndex);

                if (tex == null || logo.Length == 0)
                {
                    if (StockLogo != null && !list.Contains(StockLogo))
                    {
                        list.Add(StockLogo);
                    }
                    continue;
                }

                int x = -1;
                int y = 0;
                for (int p = 0; p < logo.Length; p++)
                {
                    x++;
                    if (x == tex.width)
                    {
                        x = 0;
                        y++;
                    }
                    if (y == tex.height)
                    {
                        break;
                    }
                    Color color = new Color(logo[p].r, logo[p].g, logo[p].b, 1);
                    tex.SetPixel(x, y, Color.Lerp(tex.GetPixel(x, y), color, logo[p].a));
                }

                tex.Apply();
                list.Add(tex);
            }
        }
Ejemplo n.º 2
0
        public List <Texture2D> SASSScreens()
        {
            List <Texture2D> list = new List <Texture2D>();

            bool addKerbals = FixLoadingScreen.recolorKerbals || FixLoadingScreen.keepGreenKerbals;

            if (addKerbals)
            {
                if (FixLoadingScreen.keepGreenKerbals)
                {
                    return(new List <Texture2D>());
                }

                foreach (string name in names)
                {
                    Texture2D custom = PNGtools.Load(path + "Recolored/" + name + ".png");
                    if (custom == null)
                    {
                        continue;
                    }

                    if (name == "apollo11")
                    {
                        Texture2D pole = PNGtools.Load(path + "Fixes/pole.png");
                        Texture2D flag = PNGtools.Load(path + "Fixes/flags.png");
                        if (pole != null && flag != null)
                        {
                            PNGtools.Overlay(custom, pole, 1844, 269);
                            PNGtools.Overlay(custom, flag.GetPixels(rnd.Next(flag.width / 42) * 42, 0, 42, 26), 42, 1850, 527);
                            custom.Apply();
                        }
                    }

                    list.Add(custom);
                }
            }

            AddLogo(list, 16 - list.Count);

            if (list.Count > 0)
            {
                return(list);
            }

            return(new List <Texture2D>());
        }
Ejemplo n.º 3
0
        void SmallLogo(Texture2D texture, string name)
        {
            Texture2D smallLogo = null;

            if (texture.height == 1280)
            {
                smallLogo = PNGtools.Load(path + "Fixes/SASSLogoSmall.png");
            }
            else
            {
                smallLogo = PNGtools.Load(path + "Fixes/SASSLogoXSmall.png");
            }

            if (smallLogo != null)
            {
                PNGtools.Overlay(texture, smallLogo, texture.width - (int)(46d / 768d * texture.height) - smallLogo.width, texture.height - (int)(43d / 768d * texture.height) - smallLogo.height);
            }

            PNGtools.Export(texture, path + "Recolored/", name);
        }
Ejemplo n.º 4
0
        void Recolor(string name, int dx = 0, int dy = 0, float hue = 0)
        {
            Texture2D tex = Utility.CreateReadable(Resources.FindObjectsOfTypeAll <Texture2D>().FirstOrDefault(t => t.name == name));

            if (tex == null)
            {
                return;
            }

            if (name == "apollo11")
            {
                SmallLogo(tex, name);
                return;
            }

            Texture2D mask = PNGtools.Load(path + "Fixes/" + name + ".png");

            if (mask == null)
            {
                return;
            }

            // Change color
            for (int x = 0; (x < mask.width) && (x + dx < tex.width); x++)
            {
                for (int y = 0; (y < mask.height) && (y + dy < tex.height); y++)
                {
                    Color maskColor = mask.GetPixel(x, y);
                    if (maskColor.maxColorComponent == 0)
                    {
                        continue;
                    }
                    Color recolored = PNGtools.Lerp(tex.GetPixel(x + dx, y + dy), hue);
                    tex.SetPixel(x + dx, y + dy, recolored);
                }
            }

            SmallLogo(tex, name);
        }
Ejemplo n.º 5
0
        void Start()
        {
            // FIX URANUS RINGS

            // Load OPM's texture 'Urlum_ring'
            Texture2D uranusRing = PNGtools.Load("GameData/OPM/OPM_Textures/Urlum_ring.png");

            // If the texture does not exist generate one
            if (uranusRing == null)
            {
                uranusRing = new Texture2D(2, 2);

                for (int i = 0; i < 4; i++)
                {
                    uranusRing.SetPixel(i % 2, i / 2, new Color(1f, 1f, 1f, 0));
                }
            }
            // If the texture is vertical, switch to horizontal
            else if (uranusRing.height > uranusRing.width)
            {
                Color[] colors = uranusRing.GetPixels(0, 0, uranusRing.width, uranusRing.height);
                uranusRing = new Texture2D(uranusRing.height, uranusRing.width);

                for (int i = 0; i < uranusRing.height; i++)
                {
                    uranusRing.SetPixels(0, i, uranusRing.width, 1, colors.Skip(i * uranusRing.width).Take(uranusRing.width).ToArray());
                }
            }

            // Apply and Rename
            uranusRing.Apply();
            uranusRing.name = "UranusRingFix";


            // RECOLOR SATURN RINGS

            // Load OPM's texture 'Sarnus_ring'
            Texture2D saturn = PNGtools.Load("GameData/OPM/OPM_Textures/Sarnus_ring.png");

            // If the texture does not exist generate one
            if (saturn == null)
            {
                saturn = new Texture2D(2, 2);

                for (int i = 0; i < 4; i++)
                {
                    saturn.SetPixel(i % 2, i / 2, new Color(1f, 1f, 1f, 0));
                }
            }
            else
            {
                Color[] colors = saturn.GetPixels(0, 0, saturn.width, saturn.height);

                // Fix the colors
                for (int x = 0; x < colors.Length; x++)
                {
                    colors[x] =
                        new Color
                        (
                            colors[x].r * 0.895f,
                            colors[x].g * 1.010f,
                            colors[x].b * 1.095f,
                            colors[x].a
                        );
                }

                // If the texture is vertical, switch to horizontal
                if (saturn.height > saturn.width)
                {
                    saturn = new Texture2D(saturn.height, saturn.width);

                    for (int i = 0; i < saturn.height; i++)
                    {
                        saturn.SetPixels(0, i, saturn.width, 1, colors.Skip(i * saturn.width).Take(saturn.width).ToArray());
                    }
                }
                else
                {
                    saturn.SetPixels(0, 0, saturn.width, saturn.height, colors);
                }

                // Move F Ring
                Color[] RingF = saturn.GetPixels(saturn.width - saturn.width / 16, 0, saturn.width / 16, saturn.height).Reverse().ToArray();

                Color[] Rings = saturn.GetPixels(0, 0, saturn.width * 15 / 16, saturn.height);
                saturn.SetPixels(saturn.width / 16, 0, Rings.Length / saturn.height, saturn.height, Rings);
                saturn.SetPixels(0, 0, saturn.width / 16, saturn.height, RingF);
            }

            // Apply and Rename
            saturn.Apply();
            saturn.name = "SaturnRingRecolor";


            // RECOLOR JUPITER

            // Load Revolting Jool Texture
            Texture2D jupiter = PNGtools.Load("GameData/RevoltingJoolRecolor/Textures/Revolting_Jool_Color.png");

            // If the texture does not exist generate one
            if (jupiter == null)
            {
                jupiter = new Texture2D(2, 2);
                for (int i = 0; i < 4; i++)
                {
                    jupiter.SetPixel(i % 2, i / 2, new Color(0.463f, 0.259f, 0.173f, 1));
                }
            }
            else
            {
                // Fix the colors
                Color[] colors = jupiter.GetPixels();

                for (int i = 0; i < colors.Length; i++)
                {
                    colors[i] =
                        new Color
                        (
                            Math.Max(colors[i].r, colors[i].g),
                            Math.Min(colors[i].r, colors[i].g) * 0.6f + colors[i].b * 0.4f,
                            colors[i].b,
                            colors[i].a
                        );
                }

                // Set the colors
                jupiter.SetPixels(colors);
            }

            // Skip if the texture still does not exist
            if (jupiter != null)
            {
                // Apply and Rename
                jupiter.Apply();
                jupiter.name = "JupiterRecolor";
            }


            // CREATE URANUS TEXTURE

            Texture2D uranus = new Texture2D(2, 2);

            for (int i = 0; i < 4; i++)
            {
                uranus.SetPixel(i % 2, i / 2, new Color(0.800f, 0.871f, 0.518f, 1));
            }

            uranus.Apply();
            uranus.name = "UranusRecolor";


            // RECOLOR NEPTUNE

            // Generate a temporary texture
            Texture2D neptune = neptune = new Texture2D(2, 2);

            // Color it blue in case the real texture is not found later
            for (int i = 0; i < 4; i++)
            {
                neptune.SetPixel(i % 2, i / 2, new Color(0.300f, 0.500f, 1.000f, 1));
            }

            // Apply and Rename
            neptune.Apply();
            neptune.name = "NeptuneRecolor";
        }