/// <summary> /// This should update anything that requires mouse, keyboard, gamepad, joystick, or other input controls. (Dragging, etc.) /// </summary> /// <param name="m">The current MouseState object.</param> /// <param name="gt">A value representing the elapsed <code>GameTime</code> since the last update.</param> /// <param name="hasFocus">A value indicating whether or not the application has focus.</param> public static void UpdateAll(GameTime gt, bool hasFocus) { if (MouseStateManager.WentDown(MouseButtons.Left) || MouseStateManager.WentDown(MouseButtons.Middle) || MouseStateManager.WentDown(MouseButtons.Right)) { int f = GetActiveForm(new EFD.Point(MouseStateManager.MouseStateNow.X, MouseStateManager.MouseStateNow.Y)); if (f > 0 || (f > -1 && ActiveForm == null)) { Forms[f].Activate(); } else if (f < 0) { ActiveForm = null; } } (ActiveForm as Form)?.Update(hasFocus, gt); for (int i = 0; i < Forms.Count; i++) { (Forms[i] as Form)?.Update(false, gt); } }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.GraphicsProfile = GraphicsProfile.HiDef; graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; IsMouseVisible = true; msm = new MouseStateManager(this); kbm = new KeyboardStateManager(this); camera = new Base3DCamera(this, .5f, 20000); camera.Position = new Vector3(0, 0, 0); camera.ClearColor = Color.Ivory; Components.Add(camera); Services.AddService(typeof(Base3DCamera), camera); skyBox = new BaseSkyBox(this, "Textures/SkyBox/HMcubemap"); //Components.Add(skyBox); ground = new HatchedPlane(this); ground.Position = new Vector3(0, -1.5f, -10); ground.UVMultiplier = Vector2.One * .75f; Components.Add(ground); cube = new HatchedCube(this); cube.Position = new Vector3(-2, -1, -10); cube.UVMultiplier = Vector2.One * .1f; cube.LightPosition = LightPosition; Components.Add(cube); cube2 = new Base3DObjectCrossHatch(this, "Models/Cube"); cube2.Position = new Vector3(-2, 1, -10); cube2.Rotate(Vector3.Left + Vector3.Up, 45); cube2.ColorAsset = "Textures/h2mcpCube"; cube2.BumpAsset = "Textures/h2mcpCubeNormal"; cube2.LightPosition = LightPosition; Components.Add(cube2); bunny = new Base3DObjectCrossHatch(this, "Models/bunny"); bunny.Position = new Vector3(0, -1.5f, -10); bunny.LightPosition = LightPosition; Components.Add(bunny); earth = new Base3DObjectCrossHatch(this, "Models/sphere"); earth.Position = new Vector3(2, -1, -10); earth.ColorAsset = "Textures/Earth_Diffuse"; earth.BumpAsset = "Textures/Earth_NormalMap"; earth.LightPosition = LightPosition; Components.Add(earth); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; graphics.GraphicsProfile = GraphicsProfile.HiDef; graphics.PreferredBackBufferWidth = 1920; graphics.PreferredBackBufferHeight = 1080; IsMouseVisible = true; msm = new MouseStateManager(this); kbm = new KeyboardStateManager(this); camera = new Base3DCamera(this, .5f, 20000); camera.Position = new Vector3(0, 0, 0); Components.Add(camera); Services.AddService(typeof(Base3DCamera), camera); skyBox = new BaseSkyBox(this, "Textures/SkyBox/HMcubemap"); Components.Add(skyBox); cube = new Base3DObject(this, "Models/cube"); cube.Name = "Cube"; cube.Position = new Vector3(-2, -1, -10); cube.ColorAsset = "Textures/h2mcpCube"; cube.BumpAsset = "Textures/h2mcpCubeNormal"; cube.LightPosition = LightPosition; cube.BoundingBox = new BoundingBox(-Vector3.One * .5f, Vector3.One * .5f); cube.BoundingSphere = new BoundingSphere(Vector3.Zero, .75f); Components.Add(cube); sceneObjects.Add(cube); bunny = new Base3DObject(this, "Models/bunny", "Shaders/RenderObjectNotTangentsOrTexCoords"); bunny.Name = "Bunny"; bunny.Position = new Vector3(0, -1.5f, -10); bunny.LightPosition = LightPosition; bunny.BoundingBox = new BoundingBox(new Vector3(-1, 0, -.6f), new Vector3(.7f, 1.65f, .7f)); bunny.BoundingSphere = new BoundingSphere(new Vector3(-.2f, .75f, 0), 1); Components.Add(bunny); sceneObjects.Add(bunny); earth = new Base3DObject(this, "Models/sphere"); earth.Name = "Globe"; earth.Position = new Vector3(2, -1, -10); earth.ColorAsset = "Textures/Earth_Diffuse"; earth.BumpAsset = "Textures/Earth_NormalMap"; earth.LightPosition = LightPosition; earth.BoundingBox = new BoundingBox(-Vector3.One, Vector3.One); earth.BoundingSphere = new BoundingSphere(Vector3.Zero, 1); Components.Add(earth); sceneObjects.Add(earth); }
public Game1() { graphics = new GraphicsDeviceManager(this); graphics.PreferredBackBufferHeight = 720; graphics.PreferredBackBufferWidth = 1208; graphics.ApplyChanges(); Content.RootDirectory = "Content"; msm = new MouseStateManager(this); kbm = new KeyboardStateManager(this); screenCanvas = new ScreenCanvasBase(this, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); Components.Add(screenCanvas); //scrollRect = new ScrollRectangleBase(this, new Rectangle(0, 0, 500, 256)); //imgTest = new ImageBase(this, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), "Textures/map"); //scrollRect.AddChild(imgTest); //screenCanvas.AddChild(scrollRect); //scrollRect.Transform.LocalPosition2D = new Vector2(128, 128); //vScrollBar = new ScrollBarBase(this, new Rectangle(0, 0, 16, scrollRect.RenderSize.Height)); //vScrollBar.ScrollBarType = RandomchaosMGUIBase.ScrollBarTypesEnum.Vertical; //vScrollBar.Transform.LocalPosition2D = new Vector2(630, 128); //vScrollBar.ScrollRect = scrollRect; //vScrollBar.BackgroundColor = new Color(100, 100, 100, 255); //screenCanvas.AddChild(vScrollBar); //hScrollBar = new ScrollBarBase(this, new Rectangle(0, 0, scrollRect.RenderSize.Width, 16)); //hScrollBar.ScrollBarType = RandomchaosMGUIBase.ScrollBarTypesEnum.Horizontal; //hScrollBar.Transform.LocalPosition2D = new Vector2(128, 386); //hScrollBar.ScrollRect = scrollRect; //hScrollBar.BackgroundColor = new Color(100, 100, 100, 255); //screenCanvas.AddChild(hScrollBar); btnShowWindow = new ButtonBase(this, new Rectangle(graphics.PreferredBackBufferWidth - 108, graphics.PreferredBackBufferHeight - 40, 100, 32), "Show Window", "Fonts/Airel12"); btnShowWindow.TextColor = Color.Black; btnShowWindow.ShadowOffset = Vector2.Zero; btnShowWindow.OnMouseClickEvent += ShowWindow; screenCanvas.AddChild(btnShowWindow); btnShowFileBrowser = new ButtonBase(this, new Rectangle(graphics.PreferredBackBufferWidth - 266, graphics.PreferredBackBufferHeight - 40, 150, 32), "Show File Browser", "Fonts/Airel12"); btnShowFileBrowser.TextColor = Color.Black; btnShowFileBrowser.ShadowOffset = Vector2.Zero; btnShowFileBrowser.OnMouseClickEvent += ShowWindow; screenCanvas.AddChild(btnShowFileBrowser); // Add this last of all. mr = new MouseRenderer(this, "Textures/Icons/Mouse"); Components.Add(mr); }
private void Update(bool hasFocus, GameTime gt) { // We should only process things that require input if the game is focused, the form is visible, and the form is enabled. if (Enabled && Visible && hasFocus) { if (MouseStateManager.MouseStateNow.X >= Bounds.Left && MouseStateManager.MouseStateNow.X < Bounds.Right && MouseStateManager.MouseStateNow.Y >= Bounds.Top && MouseStateManager.MouseStateNow.Y < Bounds.Bottom) { if (MouseStateManager.MouseStateNow.LeftButton == ButtonState.Pressed || MouseStateManager.MouseStateNow.RightButton == ButtonState.Pressed) { Select(); SelectControl(this, MouseStateManager.MouseStateNow); } if (MouseStateManager.WentUp(MouseButtons.Left)) { if (DateTime.UtcNow - _clickStart <= _clickTrigger) { OnClick(new MouseEventArgs(MouseStateManager.ButtonsDown(), 1, MouseStateManager.MouseStateNow.X, MouseStateManager.MouseStateNow.Y, 0)); } _inDrag = false; OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0, MouseStateManager.MouseStateNow.X, MouseStateManager.MouseStateNow.Y, MouseStateManager.MouseStateNow.ScrollWheelValue - MouseStateManager.MouseStatePrevious.ScrollWheelValue)); } else if (MouseStateManager.WentDown(MouseButtons.Left)) { _clickStart = DateTime.UtcNow; if (ShowTitleBar) { if (MouseStateManager.MouseStateNow.X >= Bounds.Left && MouseStateManager.MouseStateNow.X < Bounds.Right && MouseStateManager.MouseStateNow.Y >= Location.Y && MouseStateManager.MouseStateNow.Y < Location.Y + TitleBarHeight) { _dragMouseStart = new EFD.Point(MouseStateManager.MouseStateNow.X, MouseStateManager.MouseStateNow.Y); _dragPosStart = Location; _inDrag = true; } } OnMouseDown(new MouseEventArgs(MouseButtons.Left, 0, MouseStateManager.MouseStateNow.X, MouseStateManager.MouseStateNow.Y, MouseStateManager.MouseStateNow.ScrollWheelValue - MouseStateManager.MouseStatePrevious.ScrollWheelValue)); } } if (MouseStateManager.MouseStateNow.LeftButton == ButtonState.Pressed) { if (AllowDrag && _inDrag && ShowTitleBar) { Location = _dragPosStart + new EFD.Size(MouseStateManager.MouseStateNow.X - _dragMouseStart.X, MouseStateManager.MouseStateNow.Y - _dragMouseStart.Y); } } foreach (var c in Controls) { var updateableControl = c as IUpdateableControl; updateableControl?.Update(c == ActiveControl, gt); } } else if (Enabled && Visible) { // Down here we can do any updating that doesn't require input. The form must be both Enabled and Visible for us to do anything. } }