Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaShared/Source/PlayerInput.cs
Joonas Rikkonen e28ec38c40 e6715d6...5d2c9f2
commit 5d2c9f2e19d9d876d606415667f56c1f92fd1b8f
Author: ezjamsen <ezjames.fi@gmail.com>
Date:   Tue Mar 5 19:35:34 2019 +0200

    corrected cases

commit cd9cf4ed3117b9a5cc4cb57428d8dc11d756d274
Author: ezjamsen <ezjames.fi@gmail.com>
Date:   Tue Mar 5 19:01:54 2019 +0200

    updated settings

commit 84ad07149a8e56d59fd2d71b34fbb92479eba042
Author: Iiro Enges <iiro@fakefish.fi>
Date:   Tue Mar 5 18:48:26 2019 +0200

    Added an updated title text

commit 0ae68b0857ee259cac1480cb20a9c02f3bb88d8d
Author: Iiro Enges <iiro@fakefish.fi>
Date:   Tue Mar 5 18:46:59 2019 +0200

    Replaced old alien ruin textures with new ones (more variants to be added)

commit b57a6765f56ea1504ff5b39b14172f73b4122597
Author: Joonas Rikkonen <poe.regalis@gmail.com>
Date:   Tue Mar 5 17:44:46 2019 +0200

    Fixed particle jitter caused by a bug in the interpolation logic (was especially noticeable when the sub is moving fast)
2019-03-18 22:30:55 +02:00

237 lines
5.4 KiB
C#

using Microsoft.Xna.Framework.Input;
namespace Barotrauma
{
public enum InputType
{
Select,
Use,
Aim,
Up, Down, Left, Right,
Attack,
Run, Crouch,
InfoTab, Chat, RadioChat, CrewOrders,
Ragdoll, Health, Grab,
SelectNextCharacter,
SelectPreviousCharacter,
Voice
}
public class KeyOrMouse
{
public Keys Key { get; private set; }
public int? MouseButton { get; private set; }
public KeyOrMouse(Keys keyBinding)
{
this.Key = keyBinding;
}
public KeyOrMouse(int mouseButton)
{
this.MouseButton = mouseButton;
}
public bool IsDown()
{
switch (MouseButton)
{
case null:
return PlayerInput.KeyDown(Key);
case 0:
return PlayerInput.LeftButtonHeld();
case 1:
return PlayerInput.RightButtonHeld();
case 2:
return PlayerInput.MidButtonHeld();
case 3:
return PlayerInput.Mouse4ButtonHeld();
case 4:
return PlayerInput.Mouse5ButtonHeld();
case 5: // No real way of "holding" a mouse wheel key, but then again it makes no sense to bind the key to this kind of task.
return PlayerInput.MouseWheelUpClicked();
case 6:
return PlayerInput.MouseWheelDownClicked();
}
return false;
}
public bool IsHit()
{
switch (MouseButton)
{
case null:
return PlayerInput.KeyHit(Key);
case 0:
return PlayerInput.LeftButtonClicked();
case 1:
return PlayerInput.RightButtonClicked();
case 2:
return PlayerInput.MidButtonClicked();
case 3:
return PlayerInput.Mouse4ButtonClicked();
case 4:
return PlayerInput.Mouse5ButtonClicked();
case 5:
return PlayerInput.MouseWheelUpClicked();
case 6:
return PlayerInput.MouseWheelDownClicked();
}
return false;
}
public override string ToString()
{
switch (MouseButton)
{
case null:
return Key.ToString();
case 0:
return "Mouse1";
case 1:
return "Mouse2";
case 2:
return "Mouse3";
case 3:
return "Mouse4";
case 4:
return "Mouse5";
case 5:
return "MouseWheelUp";
case 6:
return "MouseWheelDown";
}
return "None";
}
}
class Key
{
private bool hit, hitQueue;
private bool held, heldQueue;
#if CLIENT
private InputType inputType;
public Key(InputType inputType)
{
this.inputType = inputType;
}
private InputType inputType;
public Key(InputType inputType)
{
this.inputType = inputType;
}
#if CLIENT
private KeyOrMouse binding
{
get { return GameMain.Config.KeyBind(inputType); }
}
public KeyOrMouse State
{
get { return binding; }
}
#endif
public void SetState()
{
hit = binding.IsHit();
if (hit) hitQueue = true;
held = binding.IsDown();
if (held) heldQueue = true;
}
#endif
public void SetState()
{
hit = binding.IsHit();
if (hit) hitQueue = true;
held = binding.IsDown();
if (held) heldQueue = true;
}
#endif
public bool Hit
{
get
{
return hit;
}
set
{
hit = value;
}
}
public bool Held
{
get
{
return held;
}
set
{
held = value;
}
}
public void SetState(bool hit, bool held)
{
if (hit) hitQueue = true;
if (held) heldQueue = true;
}
public bool DequeueHit()
{
bool value = hitQueue;
hitQueue = false;
return value;
}
public bool DequeueHeld()
{
bool value = heldQueue;
heldQueue = false;
return value;
}
public bool GetHeldQueue
{
get { return heldQueue; }
}
public bool GetHitQueue
{
get { return hitQueue; }
}
public void Reset()
{
hit = false;
held = false;
}
public void ResetHit()
{
hit = false;
//stateQueue = false;
}
public void ResetHeld()
{
held = false;
//stateQueue = false;
}
}
}