Пример #1
0
 /// <summary>
 /// Removes a single glyph provider from the region tile.
 /// </summary>
 /// <param name="g">The glyph provider to remove</param>
 public void RemoveGlyphProvider(IGlyphProvider g)
 {
     this.glyphList.Remove(g);
     if (displaytile != null)
     {
         displaytile.MakeRenderDirty();
     }
 }
Пример #2
0
 /// <summary>
 /// Adds a glyph to the tile.
 /// </summary>
 /// <remarks>
 /// Many glyphs can be in a single tile, and they will just overlay each other.
 /// Make sure to invoke DisplayTile.ClearGlyphs() or DisplayTile.Reset() if
 /// you want to fully replace them.
 /// </remarks>
 /// <param name="g">The pre-created glyph to add.</param>
 public void AddGlyphProvider(IGlyphProvider g)
 {
     if (!this.glyphList.Contains(g))
     {
         this.glyphList.Add(g);
     }
     if (displaytile != null)
     {
         displaytile.MakeRenderDirty();
     }
 }
Пример #3
0
        public GameControl(IGlyphProvider <TGlyph> glyphProvider, IColorProvider <TColor> colorProvider, int heightInGlyphs,
                           int widthInGlyphs)
        {
            _glyphProvider  = glyphProvider;
            _colorProvider  = colorProvider;
            _heightInGlyphs = heightInGlyphs;
            _widthInGlyphs  = widthInGlyphs;

            Controls.Add(CreateMainMenu());
            Controls.Add(CreateGame());
            Controls.Add(CreateLocalMenu());
            Controls.Add(CreateSaveMenu());
            Controls.Add(CreateLoadMenu());

            OnPageChanged += (pages, args) =>
            {
                _previousPage = args.OldValue;
            };
        }
Пример #4
0
 public LevelControl(IGlyphProvider <TGlyph> glyphProvider, IColorProvider <TColor> colorProvider)
 {
     _glyphProvider = glyphProvider;
     _colorProvider = colorProvider;
 }
Пример #5
0
        private void DrawWindow()
        {
            GL.MatrixMode(MatrixMode.Modelview);

            GL.LoadIdentity();

            int w = this.GlyphPalette.GlyphDimensions.Width;
            int h = this.GlyphPalette.GlyphDimensions.Height;

            List <KeyValuePair <Point, IGlyphProvider> > gproviders = new List <KeyValuePair <Point, IGlyphProvider> >();

            for (int x = 0; x < this.Size.Width; x++)
            {
                for (int y = 0; y < this.Size.Height; y++)
                {
                    DisplayTile tile = this.tiles[x, y];
                    foreach (RegionTile t in tile.RegionTiles)
                    {
                        foreach (IGlyphProvider p in t.GlyphProviders)
                        {
                            gproviders.Add(new KeyValuePair <Point, IGlyphProvider>(new Point(x, y), p));
                        }
                    }
                }
            }

            /* Draw Glyphs */
            GL.Begin(PrimitiveType.Quads);
            foreach (KeyValuePair <Point, IGlyphProvider> kvp in gproviders)
            {
                IGlyphProvider glyphpro = kvp.Value;
                Point          loc      = kvp.Key;

                int screen_x = loc.X * w;
                int screen_y = loc.Y * h;
                {
                    int uvrow = (int)Sharplike.UI.GlyphDefault.Block / GlyphPalette.ColumnCount;
                    int uvcol = (int)Sharplike.UI.GlyphDefault.Block % GlyphPalette.ColumnCount;

                    double u  = (double)uvcol / (double)GlyphPalette.ColumnCount;
                    double v  = (double)uvrow / (double)GlyphPalette.RowCount;
                    double du = 1.0 / (double)GlyphPalette.ColumnCount;
                    double dv = 1.0 / (double)GlyphPalette.RowCount;

                    GL.Color4(glyphpro.BackgroundColor);
                    GL.TexCoord2(u, v); GL.Vertex2(screen_x, screen_y);
                    GL.TexCoord2(du + u, v); GL.Vertex2(screen_x + w, screen_y);
                    GL.TexCoord2(du + u, dv + v); GL.Vertex2(screen_x + w, h + screen_y);
                    GL.TexCoord2(u, dv + v); GL.Vertex2(screen_x, h + screen_y);
                }

                foreach (Glyph glyph in glyphpro.Glyphs)
                {
                    int uvrow = glyph.Index / GlyphPalette.ColumnCount;
                    int uvcol = glyph.Index % GlyphPalette.ColumnCount;

                    double u  = (double)uvcol / (double)GlyphPalette.ColumnCount;
                    double v  = (double)uvrow / (double)GlyphPalette.RowCount;
                    double du = 1.0 / (double)GlyphPalette.ColumnCount;
                    double dv = 1.0 / (double)GlyphPalette.RowCount;

                    GL.Color4(glyph.Color);
                    GL.TexCoord2(u, v); GL.Vertex2(screen_x, screen_y);
                    GL.TexCoord2(du + u, v); GL.Vertex2(screen_x + w, screen_y);
                    GL.TexCoord2(du + u, dv + v); GL.Vertex2(screen_x + w, h + screen_y);
                    GL.TexCoord2(u, dv + v); GL.Vertex2(screen_x, h + screen_y);
                }
            }
            GL.End();
        }
Пример #6
0
 /// <summary>
 /// Removes a single glyph provider from the region tile.
 /// </summary>
 /// <param name="g">The glyph provider to remove</param>
 public void RemoveGlyphProvider(IGlyphProvider g)
 {
     this.glyphList.Remove(g);
     if (displaytile != null)
         displaytile.MakeRenderDirty();
 }
Пример #7
0
 /// <summary>
 /// Adds a glyph to the tile.
 /// </summary>
 /// <remarks>
 /// Many glyphs can be in a single tile, and they will just overlay each other.
 /// Make sure to invoke DisplayTile.ClearGlyphs() or DisplayTile.Reset() if
 /// you want to fully replace them.
 /// </remarks>
 /// <param name="g">The pre-created glyph to add.</param>
 public void AddGlyphProvider(IGlyphProvider g)
 {
     this.glyphList.Add(g);
     if (displaytile != null)
         displaytile.MakeRenderDirty();
 }