Terraria ModLoader  0.11.7.8
A mod to make and play Terraria mods
ModHotkey.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using Terraria.GameInput;
3 
4 // Thanks to Yoraiz0r for the useful Properties approach.
5 
6 namespace Terraria.ModLoader
7 {
11  public class ModHotKey
12  {
13  internal readonly Mod mod;
14  internal readonly string name; // name from modder: "Random Buff"
15  internal readonly string uniqueName; // eg: "Example Mod: Random Buff" (currently also display name)
16  internal readonly string defaultKey; // from mod.Load
17 
18  internal ModHotKey(Mod mod, string name, string defaultKey) {
19  this.mod = mod;
20  this.name = name;
21  this.defaultKey = defaultKey;
22  this.uniqueName = mod.Name + ": " + name;
23  }
24 
30  public List<string> GetAssignedKeys(InputMode mode = InputMode.Keyboard) {
31  return PlayerInput.CurrentProfile.InputModes[mode].KeyStatus[uniqueName];
32  }
33 
34  public bool RetroCurrent {
35  get {
36  if (Main.drawingPlayerChat || Main.player[Main.myPlayer].talkNPC != -1 || Main.player[Main.myPlayer].sign != -1) return false;
37  return Current;
38  }
39  }
40 
44  public bool Current => PlayerInput.Triggers.Current.KeyStatus[uniqueName];
45 
49  public bool JustPressed => PlayerInput.Triggers.JustPressed.KeyStatus[uniqueName];
50 
54  public bool JustReleased => PlayerInput.Triggers.JustReleased.KeyStatus[uniqueName];
55 
59  public bool Old => PlayerInput.Triggers.Old.KeyStatus[uniqueName];
60  }
61 }
Represents a loaded hotkey. It is suggested to access the hotkey status only in ModPlayer.ProcessTriggers.
Definition: ModHotkey.cs:11
virtual string Name
Stores the name of the mod. This name serves as the mod&#39;s identification, and also helps with saving ...
Definition: Mod.cs:42
Mod is an abstract class that you will override. It serves as a central place from which the mod&#39;s co...
Definition: Mod.cs:24
List< string > GetAssignedKeys(InputMode mode=InputMode.Keyboard)
Gets the currently assigned keybindings. Useful for prompts, tooltips, informing users.
Definition: ModHotkey.cs:30