Mouse buttons properly recognized in interface.
Also file mode changes. I don't care.
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
@@ -52,37 +52,41 @@ 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);
|
||||
|
||||
// Deselect all units
|
||||
if (!ks.IsKeyDown(Keys.LeftControl))
|
||||
if (args.LeftButton == ButtonState.Pressed)
|
||||
{
|
||||
foreach (var unit in core.Squad)
|
||||
unit.Selected = false;
|
||||
|
||||
foreach (var unitFrame in UnitFrames)
|
||||
unitFrame.Color = Color.Black;
|
||||
}
|
||||
|
||||
// Select all units in the rectangle
|
||||
foreach (var soldier in core.Squad)
|
||||
{
|
||||
if (mouseWorldRectangle.Intersects(soldier.GetComponent<Component.Collision>().Rectangle))
|
||||
// Deselect all units
|
||||
if (!ks.IsKeyDown(Keys.LeftControl))
|
||||
{
|
||||
soldier.Selected = true;
|
||||
foreach (var unit in core.Squad)
|
||||
unit.Selected = false;
|
||||
|
||||
foreach (var unitFrame in UnitFrames)
|
||||
unitFrame.Color = Color.Black;
|
||||
}
|
||||
|
||||
// Select all units in the rectangle
|
||||
foreach (var soldier in core.Squad)
|
||||
{
|
||||
if (mouseWorldRectangle.Intersects(soldier.GetComponent<Component.Collision>().Rectangle))
|
||||
{
|
||||
if (unitFrame["soldier"] == soldier)
|
||||
unitFrame.Color = Color.Blue;
|
||||
soldier.Selected = true;
|
||||
|
||||
foreach (var unitFrame in UnitFrames)
|
||||
{
|
||||
if (unitFrame["soldier"] == soldier)
|
||||
unitFrame.Color = Color.Blue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
|
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 222 B After Width: | Height: | Size: 222 B |
|
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 405 B |