Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
KeyConfiguration.cs
Go to the documentation of this file.
2using System.Linq;
3
4namespace Terraria.GameInput;
5
6public class KeyConfiguration
7{
9
11 {
12 get
13 {
14 if (KeyStatus["Grapple"].Count > 0 && KeyStatus["MouseRight"].Count > 0)
15 {
16 return KeyStatus["MouseRight"].Contains(KeyStatus["Grapple"][0]);
17 }
18 return false;
19 }
20 }
21
22 public void SetupKeys()
23 {
25 foreach (string knownTrigger in PlayerInput.KnownTriggers)
26 {
28 }
29 }
30
31 public void Processkey(TriggersSet set, string newKey, InputMode mode)
32 {
33 foreach (KeyValuePair<string, List<string>> item in KeyStatus)
34 {
35 if (item.Value.Contains(newKey))
36 {
37 set.KeyStatus[item.Key] = true;
38 set.LatestInputMode[item.Key] = mode;
39 }
40 }
41 if (set.Up || set.Down || set.Left || set.Right || set.HotbarPlus || set.HotbarMinus || ((Main.gameMenu || Main.ingameOptionsWindow) && (set.MenuUp || set.MenuDown || set.MenuLeft || set.MenuRight)))
42 {
43 set.UsedMovementKey = true;
44 }
45 }
46
48 {
49 foreach (KeyValuePair<string, List<string>> item in KeyStatus)
50 {
51 if (item.Value.Contains(newKey))
52 {
53 newSet.KeyStatus[item.Key] = oldSet.KeyStatus[item.Key];
54 }
55 }
56 }
57
58 public void ReadPreferences(Dictionary<string, List<string>> dict)
59 {
60 foreach (KeyValuePair<string, List<string>> item in dict)
61 {
62 if (!KeyStatus.ContainsKey(item.Key))
63 {
64 continue;
65 }
66 KeyStatus[item.Key].Clear();
67 foreach (string item2 in item.Value)
68 {
69 KeyStatus[item.Key].Add(item2);
70 }
71 }
72 }
73
75 {
77 foreach (KeyValuePair<string, List<string>> item in KeyStatus)
78 {
79 if (item.Value.Count > 0)
80 {
81 dictionary.Add(item.Key, item.Value.ToList());
82 }
83 }
84 if (!dictionary.ContainsKey("MouseLeft") || dictionary["MouseLeft"].Count == 0)
85 {
86 dictionary["MouseLeft"] = new List<string> { "Mouse1" };
87 }
88 if (!dictionary.ContainsKey("Inventory") || dictionary["Inventory"].Count == 0)
89 {
90 dictionary["Inventory"] = new List<string> { "Escape" };
91 }
92 return dictionary;
93 }
94}
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
void CopyKeyState(TriggersSet oldSet, TriggersSet newSet, string newKey)
Dictionary< string, List< string > > WritePreferences()
Dictionary< string, List< string > > KeyStatus
void Processkey(TriggersSet set, string newKey, InputMode mode)
void ReadPreferences(Dictionary< string, List< string > > dict)
static List< string > KnownTriggers
static bool ingameOptionsWindow
Definition Main.cs:704
static bool gameMenu
Definition Main.cs:1926