Mouse buttons properly recognized in interface.

Also file mode changes. I don't care.
This commit is contained in:
2012-10-22 17:05:26 +02:00
parent 5f44eb257b
commit cd913a8401
28 changed files with 75 additions and 33 deletions
Regular → Executable
View File
Regular → Executable
View File
View File
View File
View File
@@ -14,7 +14,7 @@ namespace DepthsBelow.Component
public float Intensity = 1f;
public float Angle = 0;
public Vector2 Position { get; private set; }
public Vector2 Offset;
public Vector2 Origin;
public Texture2D Texture;
public Color Color;
@@ -25,19 +25,19 @@ namespace DepthsBelow.Component
{
Texture = GameServices.GetService<ContentManager>().Load<Texture2D>("images/lights/spot");
Color = Color.White;
Offset = new Vector2(-50, -60);
Origin = new Vector2(50, 60);
}
public override void Update(GameTime gameTime)
{
Position = Parent.Transform.World + Parent.Transform.World.Origin + Offset;
Position = Parent.Transform.World + Parent.Transform.World.Origin;
Angle = Parent.Transform.World.Rotation;
}
public void Draw(SpriteBatch spriteBatch)
{
if (IsOn)
spriteBatch.Draw(Texture, Position, null, Color * Intensity, 0, Vector2.Zero, Scale, SpriteEffects.None, 0);
spriteBatch.Draw(Texture, Position, null, Color * Intensity, Angle, Origin, Scale, SpriteEffects.None, 0);
}
}
View File
View File
+1 -1
View File
@@ -71,7 +71,7 @@
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="LuaInterface, Version=2.0.0.16708, Culture=neutral, processorArchitecture=x86">
View File
View File
+5
View File
@@ -22,6 +22,11 @@ namespace DepthsBelow
/// </summary>
public MouseState MouseState;
public ButtonState LeftButton;
public ButtonState MiddleButton;
public ButtonState RightButton;
public int ScrollWheelValue;
/// <summary>
/// The time of the click, since the start of the program.
/// </summary>
Regular → Executable
View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Regular → Executable
View File
+6 -2
View File
@@ -52,6 +52,8 @@ namespace DepthsBelow
var mouseWorldPos = core.Camera.ScreenToWorld(new Vector2(mousePos.X, mousePos.Y));
var mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1);
if (args.LeftButton == ButtonState.Pressed)
{
// Deselect all units
if (!ks.IsKeyDown(Keys.LeftControl))
{
@@ -76,13 +78,15 @@ namespace DepthsBelow
}
}
}
}
// Send orders with right click
if (ks.IsKeyDown(Keys.LeftControl))
if (args.RightButton == ButtonState.Pressed)
{
foreach (var unit in core.Squad)
if (unit.Selected)
unit.GetComponent<Component.PathFinder>().Goal = Grid.WorldToGrid(mouseWorldPos);
}
// Hide the selection rectangle
//selectionRectangle = Rectangle.Empty;
View File
+43 -10
View File
@@ -98,23 +98,56 @@ namespace DepthsBelow
Rectangle mouseWorldRectangle = new Rectangle((int)mouseWorldPos.X, (int)mouseWorldPos.Y, 1, 1);
KeyboardState ks = Keyboard.GetState();
// OnPress event
if (
(ms.LeftButton == ButtonState.Pressed && lastMouseState.LeftButton == ButtonState.Released)
|| (ms.RightButton == ButtonState.Pressed && lastMouseState.RightButton == ButtonState.Released)
)
// OnPress events
if (ms.LeftButton == ButtonState.Pressed && lastMouseState.LeftButton == ButtonState.Released)
{
var mouseEvent = new GUIManager.MouseEventArgs()
{
MouseState = ms,
Time = gameTime.TotalGameTime,
LeftButton = ButtonState.Pressed
};
OnPress(ms, gameTime);
}
if (ms.MiddleButton == ButtonState.Pressed && lastMouseState.MiddleButton == ButtonState.Released)
{
var mouseEvent = new GUIManager.MouseEventArgs()
{
MouseState = ms,
Time = gameTime.TotalGameTime,
MiddleButton = ButtonState.Pressed
};
OnPress(ms, gameTime);
}
if (ms.RightButton == ButtonState.Pressed && lastMouseState.RightButton == ButtonState.Released)
{
var mouseEvent = new GUIManager.MouseEventArgs()
{
MouseState = ms,
Time = gameTime.TotalGameTime,
RightButton = ButtonState.Pressed
};
OnPress(ms, gameTime);
}
// OnRelease event
if (
(ms.LeftButton == ButtonState.Released && lastMouseState.LeftButton == ButtonState.Pressed)
|| (ms.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed)
)
// OnRelease events
if (ms.LeftButton == ButtonState.Released && lastMouseState.LeftButton == ButtonState.Pressed)
{
OnClick(ms, gameTime);
OnRelease(ms, gameTime);
}
if (ms.MiddleButton == ButtonState.Released && lastMouseState.MiddleButton == ButtonState.Pressed)
{
OnClick(ms, gameTime);
OnRelease(ms, gameTime);
}
if (ms.RightButton == ButtonState.Released && lastMouseState.RightButton == ButtonState.Pressed)
{
OnClick(ms, gameTime);
OnRelease(ms, gameTime);
}
// TODO: OnClick events
// Tooltip stuff
var tooltip = core.Lua.GetObject<GUI.Frame>("ToolTip");
View File
View File
Regular → Executable
View File
View File
View File

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 670 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 222 B

View File

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 405 B

Regular → Executable
View File