public void TestRenderLines() { TestXNAGame.Start("TestRenderLines", delegate { }, delegate // 3d render code { for (int num = 0; num < 200; num++) { TestXNAGame.Instance.LineManager3D.AddLine( new Vector3(-12.0f + num / 4.0f, 13.0f, 0), new Vector3(-17.0f + num / 4.0f, -13.0f, 0), new Color((byte)(255 - num), 14, (byte)num)); } // for TestXNAGame.Instance.LineManager3D.DrawGroundShadows = true; TestXNAGame.Instance.LineManager3D.AddCenteredBox(new Vector3(4, 4, 4), 2, Color.Red); TestXNAGame.Instance.LineManager3D.WorldMatrix = Matrix.CreateTranslation(Vector3.Up * 30); for (int num = 0; num < 200; num++) { TestXNAGame.Instance.LineManager3D.AddLine( new Vector3(-12.0f + num / 4.0f, 13.0f, 0), new Vector3(-17.0f + num / 4.0f, -13.0f, 0), new Color((byte)(255 - num), 14, (byte)num)); } // for /*TextureFont.WriteText( 2, 30, * "cam pos=" + BaseGame.CameraPos );*/ }); } // TestRenderLines()
public static void TestRenderListBox() { TestXNAGame game = new TestXNAGame("Gui.GuiListBox.TestRenderListBox"); game.initCode = delegate { GuiListBox <int> listBox = new GuiListBox <int>(); game.Mouse.CursorEnabled = true; listBox.AddItem("Getal 1", 11); listBox.AddItem("Getal 2", 22); listBox.AddItem("Getal 3", 33); listBox.AddItem("Getal 4", 44); listBox.BackgroundColor = Microsoft.Xna.Framework.Graphics.Color.PowderBlue; listBox.Position = new Microsoft.Xna.Framework.Vector2(200, 100); listBox.Size = new Microsoft.Xna.Framework.Vector2(100, 300); listBox.font = game.Content.Load <Microsoft.Xna.Framework.Graphics.SpriteFont>(game.EngineFiles.DefaultFontAsset); listBox.TextColor = Microsoft.Xna.Framework.Graphics.Color.Red; listBox.TextAlign = GuiAlign.MiddleLeft; listBox.Service = game.GuiService; game.GuiService.TopLevelControls.Add(listBox); listBox.Load(game.GraphicsDevice); }; game.Run(); }
public static void TestRender001() { TestXNAGame main = null; GuiControl control = null; TestXNAGame.Start("TestRenderGuiControl001", delegate { main = TestXNAGame.Instance; control = new GuiControl(); control.position = new Vector2(100, 100); control.size = new Vector2(200, 100); control.backgroundColor = Color.RoyalBlue; control.Load(main.GraphicsDevice); }, delegate { DrawEventArgs e = new DrawEventArgs(); e.Device = main.GraphicsDevice; e.SpriteBatch = main.SpriteBatch; control.Draw(e); }); }
/// <summary> /// Start /// </summary> /// <param name="testName">Test name</param> /// <param name="initCode">Init code</param> /// <param name="renderCode">Render code</param> public static void Start(string testName, RenderDelegate initCode, RenderDelegate renderCode) { using (Instance = new TestXNAGame(testName, initCode, renderCode)) { Instance.Run(); } }
public static void TestRenderButton() { List <GuiButton> buttons = new List <GuiButton>(); TestXNAGame game = null; game = new TestXNAGame("Gui.GuiButton.TestRenderButton", delegate { game.Mouse.CursorEnabled = true; SpriteFont font = game.Content.Load <SpriteFont>(game.EngineFiles.DefaultFontAsset); GuiButton button; button = new GuiButton(); button.text = "TopLeft"; button.Position = new Vector2(30, 30); button.Size = new Vector2(120, 100); button.textAlign = GuiAlign.TopLeft; buttons.Add(button); button = new GuiButton(); button.text = "MiddleCenter Scaled"; button.Position = new Vector2(150, 30); button.Size = new Vector2(120, 90); buttons.Add(button); button = new GuiButton(); button.text = "Exit"; button.Position = new Vector2(500, 500); button.Size = new Vector2(90, 90); buttons.Add(button); button.MouseUp += delegate { game.Exit(); }; for (int i = 0; i < buttons.Count; i++) { buttons[i].Texture = Texture2D.FromFile(game.GraphicsDevice, game.EngineFiles.GuiButton001.GetFullFilename()); buttons[i].TileSet = new TileSet(18, 12, new int[] { 15, 194, 15 }, new int[] { 15, 43, 15 }); buttons[i].Font = font; buttons[i].Service = game.GuiService; game.GuiService.TopLevelControls.Add(buttons[i]); buttons[i].Load(game.GraphicsDevice); } }, delegate { }); game.Run(); }
/// <summary> /// Create test game /// </summary> /// <param name="setWindowsTitle">Set windows title</param> /// <param name="windowWidth">Window width</param> /// <param name="windowHeight">Window height</param> /// <param name="setInitCode">Set init code</param> /// <param name="setRenderCode">Set render code</param> public TestXNAGame(string setWindowsTitle, RenderDelegate setInitCode, RenderDelegate setRenderCode) { Instance = this; Instance.Window.Title = setWindowsTitle; //#if DEBUG // // Force window on top // WindowsHelper.ForceForegroundWindow( this.Window.Handle.ToInt32() ); //#endif initCode = setInitCode; renderCode = setRenderCode; UpdateEvent += new XNAGameLoopEventHandler(TestXNAGame_UpdateEvent); }
public static void TestRenderWindow001() { TestXNAGame game = null; GuiWindow control = null; DrawEventArgs e = new DrawEventArgs(); TestXNAGame.Start("GuiWindow.TestRenderWindow001", delegate { game = TestXNAGame.Instance; game.Mouse.CursorEnabled = true; //main.XNAGame.Graphics.ToggleFullScreen(); control = new GuiWindow(); control.tex = Texture2D.FromFile(game.GraphicsDevice, game.EngineFiles.GuiDefaultSkin.GetFullFilename()); control.tileSet = new TileSet(228, 150, new int[] { 52, 415, 80 }, new int[] { 76, 291, 49 }); control.Position = new Vector2(50, 50); control.Size = new Vector2(700, 500); control.BackgroundColor = Color.Red; control.Load(game.GraphicsDevice); control.Service = game.GuiService; game.GuiService.TopLevelControls.Add(control); }, delegate { //e.Device = main.XNAGame.GraphicsDevice; //e.SpriteBatch = main.SpriteBatch; //e.TempCreateGraphics(); //control.Graphics = e.Graphics; //e.SpriteBatch.Begin(); //control.Invalidate(); //control.Draw( e ); //e.SpriteBatch.End(); }); }
public static void TestRenderImage() { TestXNAGame game = new TestXNAGame("Gui.GuiImage.TestRenderImage"); game.initCode = delegate { Gui.GuiImage image = new GuiImage(); image.Texture = Texture2D.FromFile(game.GraphicsDevice, game.EngineFiles.Wallpaper001.GetFullFilename()); image.Position = new Vector2(100, 100); image.Size = new Vector2(640, 480); image.Load(game.GraphicsDevice); game.GuiService.TopLevelControls.Add(image); image.Service = game.GuiService; }; game.Run(); }
public TestXNAGame(string nWindowsTitle) { TestXNAGame.Instance = this; Window.Title = nWindowsTitle; }
/// <summary> /// Test empty game /// </summary> public static void TestEmptyGame() { TestXNAGame.Start(null); }