Exemple #1
0
 public void Add(clsTextLabel NewItem)
 {
     if (this.ItemCount == this.MaxCount)
     {
         Debugger.Break();
     }
     else
     {
         this.Items[this.ItemCount] = NewItem;
         this.ItemCount++;
     }
 }
 private void DrawView()
 {
     if (this.DrawView_Enabled & this.IsGLInitialized)
     {
         if (OpenTK.Graphics.GraphicsContext.CurrentContext != this.OpenGLControl.Context)
         {
             this.OpenGLControl.MakeCurrent();
         }
         GL.Clear(ClearBufferMask.ColorBufferBit);
         clsMap mainMap = this.MainMap;
         if (mainMap == null)
         {
             GL.Flush();
             this.OpenGLControl.SwapBuffers();
             this.Refresh();
         }
         else
         {
             GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Projection);
             GL.LoadMatrix(ref Matrix4.CreateOrthographicOffCenter(0f, (float) this.GLSize.X, (float) this.GLSize.Y, 0f, -1f, 1f));
             GL.MatrixMode(OpenTK.Graphics.OpenGL.MatrixMode.Modelview);
             GL.LoadIdentity();
             if (mainMap.Tileset != null)
             {
                 int num;
                 int num2;
                 modMath.sXY_sng _sng;
                 modMath.sXY_sng _sng2;
                 modMath.sXY_sng _sng3;
                 modMath.sXY_sng _sng4;
                 int num3;
                 int num4;
                 TileOrientation.GetTileRotatedTexCoords(modProgram.TextureOrientation, ref _sng, ref _sng2, ref _sng3, ref _sng4);
                 GL.Enable(EnableCap.Texture2D);
                 GL.Color4((float) 0f, (float) 0f, (float) 0f, (float) 1f);
                 int num5 = this.TextureCount.Y - 1;
                 for (num4 = 0; num4 <= num5; num4++)
                 {
                     int num6 = this.TextureCount.X - 1;
                     num3 = 0;
                     while (num3 <= num6)
                     {
                         num2 = ((this.TextureYOffset + num4) * this.TextureCount.X) + num3;
                         if (num2 >= mainMap.Tileset.TileCount)
                         {
                             break;
                         }
                         num = mainMap.Tileset.Tiles[num2].TextureView_GL_Texture_Num;
                         if (num == 0)
                         {
                             GL.BindTexture(TextureTarget.Texture2D, 0);
                         }
                         else
                         {
                             GL.BindTexture(TextureTarget.Texture2D, num);
                         }
                         GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, 0x2101);
                         GL.Begin(BeginMode.Quads);
                         GL.TexCoord2(_sng.X, _sng.Y);
                         GL.Vertex2((int) (num3 * 0x40), (int) (num4 * 0x40));
                         GL.TexCoord2(_sng3.X, _sng3.Y);
                         GL.Vertex2((int) (num3 * 0x40), (int) ((num4 * 0x40) + 0x40));
                         GL.TexCoord2(_sng4.X, _sng4.Y);
                         GL.Vertex2((int) ((num3 * 0x40) + 0x40), (int) ((num4 * 0x40) + 0x40));
                         GL.TexCoord2(_sng2.X, _sng2.Y);
                         GL.Vertex2((int) ((num3 * 0x40) + 0x40), (int) (num4 * 0x40));
                         GL.End();
                         num3++;
                     }
                 }
                 GL.Disable(EnableCap.Texture2D);
                 if (this.DisplayTileTypes)
                 {
                     GL.Begin(BeginMode.Quads);
                     int num7 = this.TextureCount.Y - 1;
                     for (num4 = 0; num4 <= num7; num4++)
                     {
                         int num8 = this.TextureCount.X - 1;
                         num3 = 0;
                         while (num3 <= num8)
                         {
                             num2 = ((this.TextureYOffset + num4) * this.TextureCount.X) + num3;
                             if (num2 >= mainMap.Tileset.TileCount)
                             {
                                 break;
                             }
                             num = mainMap.Tile_TypeNum[num2];
                             GL.Color3(modProgram.TileTypes[num].DisplayColour.Red, modProgram.TileTypes[num].DisplayColour.Green, modProgram.TileTypes[num].DisplayColour.Blue);
                             GL.Vertex2((int) ((num3 * 0x40) + 0x18), (int) ((num4 * 0x40) + 0x18));
                             GL.Vertex2((int) ((num3 * 0x40) + 0x18), (int) ((num4 * 0x40) + 40));
                             GL.Vertex2((int) ((num3 * 0x40) + 40), (int) ((num4 * 0x40) + 40));
                             GL.Vertex2((int) ((num3 * 0x40) + 40), (int) ((num4 * 0x40) + 0x18));
                             num3++;
                         }
                     }
                     GL.End();
                 }
                 if (modProgram.DisplayTileOrientation)
                 {
                     modMath.sXY_sng _sng5;
                     GL.Disable(EnableCap.CullFace);
                     _sng5.X = 0.25f;
                     _sng5.Y = 0.25f;
                     modMath.sXY_sng _sng6 = TileOrientation.GetTileRotatedPos_sng(modProgram.TextureOrientation, _sng5);
                     _sng5.X = 0.5f;
                     _sng5.Y = 0.25f;
                     modMath.sXY_sng _sng7 = TileOrientation.GetTileRotatedPos_sng(modProgram.TextureOrientation, _sng5);
                     _sng5.X = 0.5f;
                     _sng5.Y = 0.5f;
                     modMath.sXY_sng _sng8 = TileOrientation.GetTileRotatedPos_sng(modProgram.TextureOrientation, _sng5);
                     GL.Begin(BeginMode.Triangles);
                     GL.Color3((float) 1f, (float) 1f, (float) 0f);
                     int num9 = this.TextureCount.Y - 1;
                     for (num4 = 0; num4 <= num9; num4++)
                     {
                         int num10 = this.TextureCount.X - 1;
                         num3 = 0;
                         while (num3 <= num10)
                         {
                             num2 = ((this.TextureYOffset + num4) * this.TextureCount.X) + num3;
                             if (num2 >= mainMap.Tileset.TileCount)
                             {
                                 break;
                             }
                             GL.Vertex2((float) ((num3 * 0x40) + (_sng6.X * 64f)), (float) ((num4 * 0x40) + (_sng6.Y * 64f)));
                             GL.Vertex2((float) ((num3 * 0x40) + (_sng8.X * 64f)), (float) ((num4 * 0x40) + (_sng8.Y * 64f)));
                             GL.Vertex2((float) ((num3 * 0x40) + (_sng7.X * 64f)), (float) ((num4 * 0x40) + (_sng7.Y * 64f)));
                             num3++;
                         }
                     }
                     GL.End();
                     GL.Enable(EnableCap.CullFace);
                 }
                 if (this.DisplayTileNumbers & (modProgram.UnitLabelFont != null))
                 {
                     GL.Enable(EnableCap.Texture2D);
                     int num11 = this.TextureCount.Y - 1;
                     for (num4 = 0; num4 <= num11; num4++)
                     {
                         int num12 = this.TextureCount.X - 1;
                         for (num3 = 0; num3 <= num12; num3++)
                         {
                             num2 = ((this.TextureYOffset + num4) * this.TextureCount.X) + num3;
                             if (num2 >= mainMap.Tileset.TileCount)
                             {
                                 break;
                             }
                             clsTextLabel label = new clsTextLabel {
                                 Text = modIO.InvariantToString_int(num2),
                                 SizeY = 24f
                             };
                             label.Colour.Red = 1f;
                             label.Colour.Green = 1f;
                             label.Colour.Blue = 0f;
                             label.Colour.Alpha = 1f;
                             label.Pos.X = num3 * 0x40;
                             label.Pos.Y = num4 * 0x40;
                             label.TextFont = modProgram.UnitLabelFont;
                             label.Draw();
                         }
                     }
                     GL.Disable(EnableCap.Texture2D);
                 }
                 if ((modProgram.SelectedTextureNum >= 0) & (this.TextureCount.X > 0))
                 {
                     modMath.sXY_int _int;
                     num = modProgram.SelectedTextureNum - (this.TextureYOffset * this.TextureCount.X);
                     _int.X = num - (((int) Math.Round(((double) (((double) num) / ((double) this.TextureCount.X))))) * this.TextureCount.X);
                     _int.Y = (int) Math.Round(((double) (((double) num) / ((double) this.TextureCount.X))));
                     GL.Begin(BeginMode.LineLoop);
                     GL.Color3((float) 1f, (float) 1f, (float) 0f);
                     GL.Vertex2((int) (_int.X * 0x40), (int) (_int.Y * 0x40));
                     GL.Vertex2((double) (_int.X * 0x40), (_int.Y * 64.0) + 64.0);
                     GL.Vertex2((int) ((_int.X * 0x40) + 0x40), (int) ((_int.Y * 0x40) + 0x40));
                     GL.Vertex2((int) ((_int.X * 0x40) + 0x40), (int) (_int.Y * 0x40));
                     GL.End();
                 }
             }
             GL.Flush();
             this.OpenGLControl.SwapBuffers();
             this.Refresh();
         }
     }
 }