예제 #1
0
 /// <summary>
 /// Creates a new TextSprite given the text, font and position.
 /// </summary>
 /// <param name="textItem"></param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="position"></param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Point position)
     : this(textItem, font, true, position)
 {
 }
예제 #2
0
 void LoadInventory()
 {
     SdlDotNet.Graphics.Font font = Logic.Graphics.FontManager.LoadFont("tahoma", 10);
     lstInv.Items.Clear();
     for (int i = 1; i < Players.PlayerManager.MyPlayer.Inventory.Length; i++)
     {
         if (Players.PlayerManager.MyPlayer.Inventory[i].Num > 0)
         {
             string itemName = Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.Inventory[i].Num].Name;
             if (Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.Inventory[i].Num].Type == Enums.ItemType.Currency || Items.ItemHelper.Items[Players.PlayerManager.MyPlayer.Inventory[i].Num].StackCap > 0)
             {
                 itemName += " (" + Players.PlayerManager.MyPlayer.Inventory[i].Value + ")";
             }
             if (!string.IsNullOrEmpty(itemName))
             {
                 if (lstInv.Items.Count <= i - 1)
                 {
                     ListBoxTextItem item = new ListBoxTextItem(font, itemName);
                     item.Tag = i;
                     lstInv.Items.Add(item);
                 }
                 else
                 {
                     ((ListBoxTextItem)lstInv.Items[i - 1]).Text = itemName;
                 }
             }
         }
     }
 }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="font"></param>
 /// <param name="positionY"></param>
 /// <param name="phrase"></param>
 /// <param name="startTime"></param>
 public TextItem(string phrase, SdlDotNet.Graphics.Font font, int positionY, float startTime)
     : base(phrase, font, false, new Point(25, positionY))
 {
     base.Surface.Alpha         = 0;
     base.Surface.AlphaBlending = true;
     this.startTime             = startTime;
 }
예제 #4
0
 public TextboxLine(int maxWidth, SdlDotNet.Graphics.Font font, Color defaultForeColor)
 {
     mMaxWidth = maxWidth;
     mChars = new List<TextBoxChar>();
     mFont = font;
     mDefaultForeColor = defaultForeColor;
 }
예제 #5
0
 /// <summary>
 /// Creates a new TextSprite given the text, font and color.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="color">color of Text</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Color color)
     : this(textItem, font, color, true)
 {
 }
예제 #6
0
 /// <summary>
 /// Creates a new TextSprite given the text, font, color and anti-aliasing flag.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="color">Color of Text</param>
 /// <param name="antiAlias">A flag determining if it's to
 /// use anti-aliasing when rendering. Defaults to true.</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Color color, bool antiAlias)
     : this(textItem, font, color, antiAlias, new Point(0, 0))
 {
 }
예제 #7
0
        public mnuChangeWeather(string name, int price)
            : base(name)
        {
            this.price = price;

            this.Size          = new Size(250, 250);
            this.MenuDirection = Enums.MenuDirection.Vertical;
            this.Location      = Client.Logic.Graphics.DrawingSupport.GetCenter(Windows.WindowSwitcher.GameWindow.MapViewer.Size, this.Size);

            lblAddTile           = new Label("lblAddTile");
            lblAddTile.Location  = new Point(25, 15);
            lblAddTile.AutoSize  = false;
            lblAddTile.Size      = new System.Drawing.Size(this.Width - lblAddTile.X * 2, 20);
            lblAddTile.Text      = "Choose a weather condition:";
            lblAddTile.ForeColor = Color.WhiteSmoke;

            lstSound          = new ListBox("lstSound");
            lstSound.Location = new Point(lblAddTile.X, lblAddTile.Y + lblAddTile.Height);
            lstSound.Size     = new Size(180, 120);

            SdlDotNet.Graphics.Font font = Logic.Graphics.FontManager.LoadFont("PMDCP", 18);
            //string[] sfxFiles = System.IO.Directory.GetFiles(IO.Paths.SfxPath);
            for (int i = 1; i < 12; i++)
            {
                if ((Enums.Weather)i != Enums.Weather.DiamondDust)
                {
                    lstSound.Items.Add(new ListBoxTextItem(font, ((Enums.Weather)i).ToString()));
                }
            }
            lstSound.SelectedIndex = 0;

            lblPrice           = new Label("lblPrice");
            lblPrice.Location  = new Point(lblAddTile.X, lstSound.Y + lstSound.Height + 10);
            lblPrice.AutoSize  = false;
            lblPrice.Size      = new System.Drawing.Size(180, 30);
            lblPrice.Text      = "Changing the weather will cost " + price + " " + Items.ItemHelper.Items[1].Name + ".";
            lblPrice.ForeColor = Color.WhiteSmoke;

            btnAccept          = new Button("btnAccept");
            btnAccept.Location = new Point(lblAddTile.X, lblPrice.Y + lblPrice.Height + 10);
            btnAccept.Size     = new Size(80, 30);
            btnAccept.Text     = "Set Weather";
            btnAccept.Font     = FontManager.LoadFont("tahoma", 10);
            Skins.SkinManager.LoadButtonGui(btnAccept);
            btnAccept.Click += new EventHandler <MouseButtonEventArgs>(btnAccept_Click);

            btnCancel          = new Button("btnCancel");
            btnCancel.Location = new Point(btnAccept.X + btnAccept.Width, lblPrice.Y + lblPrice.Height + 10);
            btnCancel.Size     = new Size(80, 30);
            btnCancel.Text     = "Cancel";
            btnCancel.Font     = FontManager.LoadFont("tahoma", 10);
            Skins.SkinManager.LoadButtonGui(btnCancel);
            btnCancel.Click += new EventHandler <MouseButtonEventArgs>(btnCancel_Click);

            this.AddWidget(lblAddTile);
            this.AddWidget(lstSound);
            this.AddWidget(lblPrice);
            this.AddWidget(btnAccept);
            this.AddWidget(btnCancel);
        }
예제 #8
0
 public TextboxLine(int maxWidth, SdlDotNet.Graphics.Font font, Color defaultForeColor)
 {
     mMaxWidth         = maxWidth;
     mChars            = new List <TextBoxChar>();
     mFont             = font;
     mDefaultForeColor = defaultForeColor;
 }
예제 #9
0
파일: FontCache.cs 프로젝트: pzaps/CrossGFX
        /// <summary>
        /// Adds a font to the cache. Does not check if it already exists
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="size"></param>
        public static SdlDotNet.Graphics.Font AddFont(string filePath, int size)
        {
            SdlDotNet.Graphics.Font font = new SdlDotNet.Graphics.Font(filePath, size);

            cache.Add(new FontId(filePath, size), font);

            return font;
        }
예제 #10
0
 /// <summary>
 /// Creates a new TextSprite given the text, font, anti-aliasing flag and position.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="antiAlias">A flag determining if it's to use
 /// anti-aliasing when rendering. Defaults to true.</param>
 /// <param name="position">Position of sprite</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     bool antiAlias,
     Point position)
     : this(textItem, font, Color.White, antiAlias, position)
 {
 }
예제 #11
0
 /// <summary>
 /// Creates a new TextSprite given the text, font, color and background color.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="textColor">Text Color</param>
 /// <param name="backgroundColor">Background color</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Color textColor,
     Color backgroundColor)
     : this(textItem, font, textColor)
 {
     this.backgroundColor = backgroundColor;
 }
예제 #12
0
        public mnuAddSound(string name, int price)
            : base(name)
        {
            this.price = price;

            this.Size          = new Size(250, 250);
            this.MenuDirection = Enums.MenuDirection.Vertical;
            this.Location      = Client.Logic.Graphics.DrawingSupport.GetCenter(Windows.WindowSwitcher.GameWindow.MapViewer.Size, this.Size);

            lblAddTile           = new Label("lblAddTile");
            lblAddTile.Location  = new Point(25, 15);
            lblAddTile.AutoSize  = false;
            lblAddTile.Size      = new System.Drawing.Size(this.Width - lblAddTile.X * 2, 20);
            lblAddTile.Text      = "Choose a sound to play:";
            lblAddTile.ForeColor = Color.WhiteSmoke;

            lstSound          = new ListBox("lstSound");
            lstSound.Location = new Point(lblAddTile.X, lblAddTile.Y + lblAddTile.Height);
            lstSound.Size     = new Size(180, 120);

            SdlDotNet.Graphics.Font font = Logic.Graphics.FontManager.LoadFont("PMU", 18);
            string[] sfxFiles            = System.IO.Directory.GetFiles(IO.Paths.SfxPath);
            for (int i = 0; i < sfxFiles.Length; i++)
            {
                lstSound.Items.Add(new ListBoxTextItem(font, System.IO.Path.GetFileName(sfxFiles[i])));
            }
            lstSound.ItemSelected += new EventHandler(lstSound_ItemSelected);

            lblPrice           = new Label("lblPrice");
            lblPrice.Location  = new Point(lblAddTile.X, lstSound.Y + lstSound.Height + 10);
            lblPrice.AutoSize  = false;
            lblPrice.Size      = new System.Drawing.Size(120, 30);
            lblPrice.Text      = "Placing this tile will cost " + price + " " + Items.ItemHelper.Items[1].Name + ".";
            lblPrice.ForeColor = Color.WhiteSmoke;

            btnAccept          = new Button("btnAccept");
            btnAccept.Location = new Point(lblAddTile.X, lblPrice.Y + lblPrice.Height + 10);
            btnAccept.Size     = new Size(80, 30);
            btnAccept.Text     = "Place Sound";
            btnAccept.Font     = FontManager.LoadFont("tahoma", 10);
            Skins.SkinManager.LoadButtonGui(btnAccept);
            btnAccept.Click += new EventHandler <MouseButtonEventArgs>(btnAccept_Click);

            btnCancel          = new Button("btnCancel");
            btnCancel.Location = new Point(btnAccept.X + btnAccept.Width, lblPrice.Y + lblPrice.Height + 10);
            btnCancel.Size     = new Size(80, 30);
            btnCancel.Text     = "Cancel";
            btnCancel.Font     = FontManager.LoadFont("tahoma", 10);
            Skins.SkinManager.LoadButtonGui(btnCancel);
            btnCancel.Click += new EventHandler <MouseButtonEventArgs>(btnCancel_Click);

            this.AddWidget(lblAddTile);
            this.AddWidget(lstSound);
            this.AddWidget(lblPrice);
            this.AddWidget(btnAccept);
            this.AddWidget(btnCancel);
        }
예제 #13
0
 void LoadMusic()
 {
     SdlDotNet.Graphics.Font font = Logic.Graphics.FontManager.LoadFont("PMDCP", 18);
     string[] musicFiles          = System.IO.Directory.GetFiles(IO.Paths.MusicPath);
     for (int i = 0; i < musicFiles.Length; i++)
     {
         cmbMusic.Items.Add(new ListBoxTextItem(font, System.IO.Path.GetFileName(musicFiles[i])));
     }
     cmbMusic.SelectItem(properties.Music);
 }
예제 #14
0
 public void Init()
 {
     this.Quit();
     font      = new SdlDotNet.Graphics.Font(@"../../FreeSans.ttf", 12);
     flags     = (Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT);
     bpp       = 16;
     width     = 640;
     height    = 480;
     sleepTime = 500;
     //surfacePtr = IntPtr.Zero;
     //Sdl.SDL_FreeSurfaceInternal(surfacePtr);
 }
예제 #15
0
		public void Init()
		{
			this.Quit();
			font = new SdlDotNet.Graphics.Font(@"../../FreeSans.ttf", 12);
			flags = (Sdl.SDL_HWSURFACE|Sdl.SDL_DOUBLEBUF|Sdl.SDL_ANYFORMAT);
			bpp = 16;
			width = 640;
			height = 480;
			sleepTime = 500;
			//surfacePtr = IntPtr.Zero;
			//Sdl.SDL_FreeSurfaceInternal(surfacePtr);
		}
예제 #16
0
        public MapViewer(string name)
            : base(name)
        {
            base.BackColor = Color.Black;
            ScreenRenderer.Initialize();
            //gl = new Graphics.GLRoutines();
            //activeMap = new Maps.Map();
            font = Graphics.FontManager.LoadFont("PMU.ttf", 24);

            this.BufferResized += new EventHandler(MapViewer_Resized);

            this.RenderFrame += new EventHandler(MapViewer_RenderFrame);
        }
예제 #17
0
        public MapViewer(string name)
            : base(name)
        {
            base.BackColor = Color.Black;
            ScreenRenderer.Initialize();
            //gl = new Graphics.GLRoutines();
            //activeMap = new Maps.Map();
            font = Graphics.FontManager.LoadFont("PMU.ttf", 24);

            this.BufferResized += new EventHandler(MapViewer_Resized);

            this.RenderFrame += new EventHandler(MapViewer_RenderFrame);
        }
예제 #18
0
 /// <summary>
 /// Creates a new TextSprite given the text, font, color, anti-aliasing flag and position.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 /// <param name="color">Color of Text</param>
 /// <param name="antiAlias">A flag determining if it's to use anti-aliasing when rendering. Defaults to true.</param>
 /// <param name="position">Position of Sprite</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font,
     Color color,
     bool antiAlias,
     Point position)
     : base()
 {
     if (font == null)
     {
         throw new ArgumentNullException("font");
     }
     base.Surface   = font.Render(textItem, color);
     this.textItem  = textItem;
     this.font      = font;
     this.color     = color;
     this.antiAlias = antiAlias;
     base.Position  = position;
     this.RenderInternal();
 }
예제 #19
0
        /// <summary>
        /// Constructs the internal sprites needed for our demo.
        /// </summary>
        public FontMode()
        {
            if (File.Exists(Path.Combine(dataDirectory, "comic.ttf")))
            {
                filePath = "";
            }
            // Create our fonts
            SdlDotNet.Graphics.Font f1 =
                new SdlDotNet.Graphics.Font(Path.Combine(filePath, Path.Combine(dataDirectory, "comicbd.ttf")), 24);
            SdlDotNet.Graphics.Font f2 =
                new SdlDotNet.Graphics.Font(Path.Combine(filePath, Path.Combine(dataDirectory, "comicbd.ttf")), 48);
            SdlDotNet.Graphics.Font f3 =
                new SdlDotNet.Graphics.Font(Path.Combine(filePath, Path.Combine(dataDirectory, "comicbd.ttf")), 72);
            SdlDotNet.Graphics.Font f4 =
                new SdlDotNet.Graphics.Font(Path.Combine(filePath, Path.Combine(dataDirectory, "comicbd.ttf")), 15);

            // Create our text sprites
            Color c2 = Color.FromArgb(255, 0, 123);

            Sprites.Add(new TextSprite("Testing...", f1, new Point(5, 5)));
            Sprites.Add(new TextSprite("...one", f2, c2, new Point(5, 35)));
            Sprites.Add(new TextSprite("...two", f3, c2, new Point(5, 90)));

            Sprites.Add(new TextSprite("A quick brown fox", f2, new Point(5, 200)));
            Sprites.Add(new TextSprite("jumps over the lazy", f2, new Point(5, 280)));
            Sprites.Add(new TextSprite("dog. 1234567890", f2, new Point(5, 360)));

            Sprites.Add(new BoundedTextSprite("one", f4,
                                              0.1, 0.5, new Point(5, 450)));
            Sprites.Add(new BoundedTextSprite("one", f4,
                                              0.25, 0.0, new Point(50, 465)));
            Sprites.Add(new BoundedTextSprite("one", f4,
                                              0.5, 1.0, new Point(100, 480)));
            Sprites.Add(new BoundedTextSprite("one", f4,
                                              1.0, 0.5, new Point(150, 495)));

            // Add the moving one
            moving = new BoundedTextSprite("two", f4,
                                           0.0, 0.5, new Point(10, 510));
            Sprites.Add(moving);
        }
예제 #20
0
 /// <summary>
 /// Destroys the surface object and frees its memory
 /// </summary>
 /// <param name="disposing">If ture, dispose unmanaged resources</param>
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (!this.disposed)
         {
             if (disposing)
             {
                 if (this.font != null)
                 {
                     this.font.Dispose();
                     this.font = null;
                 }
             }
             this.disposed = true;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
예제 #21
0
 public void DrawText(SdlDotNet.Graphics.Font font, string text, Color textColor, Color backgroundColor, int destX, int destY)
 {
     DrawText(font, text, textColor, backgroundColor, new Point(destX, destY));
 }
예제 #22
0
 /// <summary>
 /// Creates a new TextSprite given the font.
 /// </summary>
 /// <param name="font">The font to use when rendering.</param>
 public TextSprite(SdlDotNet.Graphics.Font font)
     : this(" ", font)
 {
 }
예제 #23
0
 /// <summary>
 /// Creates a new TextSprite with given the text and font.
 /// </summary>
 /// <param name="textItem">Text to display</param>
 /// <param name="font">The font to use when rendering.</param>
 public TextSprite(
     string textItem,
     SdlDotNet.Graphics.Font font)
     : this(textItem, font, Color.White)
 {
 }
예제 #24
0
 public void DrawText(SdlDotNet.Graphics.Font font, string text, Color textColor, Color backgroundColor, Point destinationPosition)
 {
     SdlVideo.Screen.Blit(font.Render(text, textColor, backgroundColor), destinationPosition);
 }
예제 #25
0
파일: Font.cs 프로젝트: pzaps/CrossGFX
 private void UpdateCachedFont(int characterSize)
 {
     if (cachedFont == null || pointSize != characterSize) {
         cachedFont = FontCache.LookupFont(filePath, characterSize);
     }
 }