Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SelectionHolder.cs
Go to the documentation of this file.
2using System.Linq;
4using Terraria.IO;
5
7
8public abstract class SelectionHolder<TCycleType> where TCycleType : class, IConfigKeyHolder
9{
11
12 protected TCycleType ActiveSelection;
13
14 protected string ActiveSelectionConfigKey;
15
16 protected bool LoadedContent;
17
18 public string ActiveSelectionKeyName { get; private set; }
19
21 {
22 preferences.OnLoad += Wrapped_Configuration_OnLoad;
23 preferences.OnSave += Configuration_Save;
24 }
25
26 protected abstract void Configuration_Save(Preferences obj);
27
28 protected abstract void Configuration_OnLoad(Preferences obj);
29
38
39 protected abstract void PopulateOptionsAndLoadContent(AssetRequestMode mode);
40
41 public void LoadContent(AssetRequestMode mode)
42 {
43 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
45 LoadedContent = true;
47 }
48
49 public void CycleSelection()
50 {
51 TCycleType lastFrame = null;
52 Options.Values.FirstOrDefault(delegate(TCycleType frame)
53 {
54 if (frame == ActiveSelection)
55 {
56 return true;
57 }
58 lastFrame = frame;
59 return false;
60 });
61 if (lastFrame == null)
62 {
63 lastFrame = Options.Values.Last();
64 }
66 }
67
72
73 private void SetActiveFrame(string frameName)
74 {
75 TCycleType val = Options.FirstOrDefault((KeyValuePair<string, TCycleType> pair) => pair.Key == frameName).Value;
76 if (val == null)
77 {
78 val = Options.Values.First();
79 }
80 SetActiveFrame(val);
81 }
82
83 private void SetActiveFrame(TCycleType frame)
84 {
85 ActiveSelection = frame;
86 ActiveSelectionConfigKey = frame.ConfigKey;
87 ActiveSelectionKeyName = frame.NameKey;
88 }
89}
void Wrapped_Configuration_OnLoad(Preferences obj)
void LoadContent(AssetRequestMode mode)
void Configuration_OnLoad(Preferences obj)
Dictionary< string, TCycleType > Options
void BindTo(Preferences preferences)
void PopulateOptionsAndLoadContent(AssetRequestMode mode)
void Configuration_Save(Preferences obj)