110d803b78
commit bdbcef41bfbc42beeb2d942e7db431b8ab627f1c Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 13:31:02 2019 +0200 Simplify the sprite related commands. commit 49c8e1cd01953ae31cff99bf35432ab887b45d62 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 13:05:20 2019 +0200 Rename "Reload Texture" button as "Reload Sprite", because it actually reloads both the xml and the texture. Add the button text into the localization file. commit 84f58d9e0bb46f29412f936d569348e46227c9d5 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 12:50:51 2019 +0200 Add the option to reload xml/texture/both for items when they are hovered over with the mouse. dry. commit 732084c044e6a2c220cee8d5c1d9b5e4ce05587d Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 12:48:49 2019 +0200 Fix the sprite name of the right hand in the assistant job gear. commit 30344369d7e87a17312cc839f195c36c77c4a3b2 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 12:26:20 2019 +0200 Fix ReloadXML failing when multiple source elements are found. commit ddb6fb48b6e0789b18a1ea889dcdf408fcbb5b12 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 11:47:13 2019 +0200 Fix damagemodifier multiplier not applied on particles if no sound is played. commit 41206013be41d240b12dad48f4ddaba9b072742b Author: itchyOwl <lauri.harkanen@gmail.com> Date: Thu Mar 7 11:46:22 2019 +0200 Fix engigear lower arm sprite name. commit 8ce938305206ca65aeb00515639e799d9f2fd526 Merge: e6166d2ef 61703e8af Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Mar 6 18:53:36 2019 +0200 Merge branch 'dev' of https://github.com/Regalis11/Barotrauma into dev commit e6166d2ef24489bac6f217211849884013dbf4e6 Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Mar 6 18:53:30 2019 +0200 Implement husk sprite overlays as wearables. Add new husk injector (wip). commit 367c4f5b3784c65c3c26807dd6c10e837960c6bb Author: itchyOwl <lauri.harkanen@gmail.com> Date: Wed Mar 6 18:52:15 2019 +0200 Add console commands for changing the gender and race of the character. commit 61703e8af274c8f5d9e05575ebaf13c9bde8855f Author: Iiro Enges <iiro@fakefish.fi> Date: Wed Mar 6 17:47:09 2019 +0200 Refined environment item scales and colors
247 lines
5.6 KiB
C#
247 lines
5.6 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 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;
|
|
}
|
|
}
|
|
}
|