示例#1
0
        void loadStuff()
        {
            Readable r = new Readable("Loading planets for\r\nthis star system.\r\nYou can scroll around and\r\nMove this window.\r\n", 30, 30, 140, 80, 10f, Color.White);
            Popup p = new Popup("Loading", 20, this.Width / 2 - 100, this.Height / 2 - 50, 200, 120, 12f, Color.White, new SolidBrush(Color.SteelBlue), Color.DarkSlateBlue, Color.Black);
            p.readables = new List<Readable>();
            //home planet on the home star system
            p.readables.Add(r);
            p.isMovable = true;
            popups.Add(p);

            starSystem = new StarSystem();
            starSystem.width = STARSYSTEM_SIZE;
            starSystem.height = STARSYSTEM_SIZE;
            starSystem.numPlanets = noise.random.Next(10, 21);

            starSystem.planets = new List<Planet>();
            Planet planet = new Planet();
            planet.generate(noise, seed);
            planet.x = noise.random.Next(planet.width, gfx.totalAreaWidth - planet.width);
            planet.y = noise.random.Next(planet.height, gfx.totalAreaHeight - planet.height);
            starSystem.planets.Add(planet);

            gfx.targetViewAreaX = (planet.x + (planet.width / 2)) - (gfx.viewAreaWidth / 2);
            gfx.targetViewAreaY = (planet.y + (planet.height / 2)) - (gfx.viewAreaHeight / 2);
            gfx.centerViewAreaImediately();
            for (int j = 0; j < starSystem.numPlanets; j++)
            {
                Planet pl = new Planet();
                pl.generate(noise, seed);
                pl.x = noise.random.Next(pl.width, gfx.totalAreaWidth - pl.width);
                pl.y = noise.random.Next(pl.height, gfx.totalAreaHeight - pl.height);
                starSystem.planets.Add(pl);
            }
            gfx.drawMap = true;
        }
示例#2
0
        void drawPopup(Popup p)
        {
            Pen pp = new Pen(p.foreColor);
            Brush pb = new SolidBrush(p.fontColor);
            LinearGradientBrush lgb = new LinearGradientBrush(new Rectangle(p.x, p.y, p.width, p.height), p.backColor1, p.backColor2, LinearGradientMode.Vertical);
            popupFont = new Font("Arial", p.fontSize, FontStyle.Regular, GraphicsUnit.Pixel);
            offscreenGFX.FillRectangle(lgb, p.x, p.y, p.width, p.height);
            offscreenGFX.DrawRectangle(pp, p.x + 2, p.y + 2, p.width - 4, p.height - 4);
            offscreenGFX.DrawRectangle(pp, p.x + 2, p.y + 2, p.width - 4, p.titleHeight);
            offscreenGFX.DrawString(p.title, popupFont, pb, p.x + 4, p.y + 3);

            if(p.clickables != null)
            {
                foreach (Clickable c in p.clickables)
                {
                    pb = new SolidBrush(c.fontColor);
                    popupFont = new Font("Arial", c.fontSize, FontStyle.Regular, GraphicsUnit.Pixel);
                    offscreenGFX.FillRectangle(c.isMouseDown ? c.clicked : c.unclicked, c.x + p.x, c.y + p.y, c.width, c.height);
                    offscreenGFX.DrawRectangle(pp, c.x + 2 + p.x, c.y + 2 + p.y, c.width - 4, c.height - 4);
                    offscreenGFX.DrawString(c.text, popupFont, pb, c.x + p.x + c.width / 20, p.y + c.y + c.height / 4);
                }
            }
            if(p.viewables != null)
            {
                foreach (Viewable v in p.viewables)
                {
                    offscreenGFX.DrawRectangle(pp, v.x - 2 + p.x, v.y - 2 + p.y, v.width + 4, v.height + 4);
                    offscreenGFX.DrawImage(v.bitmap, v.x + p.x, v.y + p.y, v.width, v.height);
                }
            }
            if(p.readables != null)
            {
                foreach (Readable r in p.readables)
                {
                    pb = new SolidBrush(r.fontColor);
                    popupFont = new Font("Arial", r.fontSize, FontStyle.Regular, GraphicsUnit.Pixel);
                    offscreenGFX.DrawRectangle(pp, r.x + 2 + p.x, r.y + 2 + p.y, r.width - 4, r.height - 4);
                    offscreenGFX.DrawString(r.text, popupFont, pb, r.x + 10 + p.x, r.y + 10 + p.y);
                }
            }
        }