-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDefaultColor.cs
More file actions
290 lines (263 loc) · 10.9 KB
/
Copy pathDefaultColor.cs
File metadata and controls
290 lines (263 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
using UnityEngine;
namespace IndicatorLights
{
/// <summary>
/// These are the logical identifiers of default colors that the modules in this
/// assembly will use if not told otherwise via config.
///
/// Each of these has a corresponding setting in Configuration to supply a value.
/// </summary>
public enum DefaultColor
{
// Maintenance note: any time a value is added to this list, need to update
// the DefaultValue and Value extension methods.
/// <summary>
/// The color used for lights that are "turned off".
/// Defaults to black.
/// </summary>
Off,
/// <summary>
/// The "on" color used for user-toggleable lights.
/// Defaults to bright green.
/// </summary>
ToggleLED,
/// <summary>
/// The color used to indicate that a resource container is nearly full.
/// Defaults to bright green.
/// </summary>
HighResource,
/// <summary>
/// The color used to indicate that a resource container is partially full.
/// Defaults to yellow.
/// </summary>
MediumResource,
/// <summary>
/// The color used to indicate that a resource container is nearly empty.
/// Defaults to red.
/// </summary>
LowResource,
/// <summary>
/// The color used to indicate that a reaction wheel is set to "normal" mode (pilot + SAS).
/// Defaults to green.
/// </summary>
ReactionWheelNormal,
/// <summary>
/// The color used to indicate that a reaction wheel is set to "pilot only" mode.
/// Defaults to blue.
/// </summary>
ReactionWheelPilotOnly,
/// <summary>
/// The color used to indicate that a reaction wheel is set to "SAS only" mode.
/// Defaults to yellow.
/// </summary>
ReactionWheelSASOnly,
/// <summary>
/// The color used to indicate that a docking port has crossfeed enabled.
/// Defaults to green.
/// </summary>
DockingCrossfeedOn,
/// <summary>
/// The color used to indicate that a docking port has crossfeed disabled.
/// Defaults to red.
/// </summary>
DockingCrossfeedOff,
/// <summary>
/// The color used to indicate that a crewable slot contains a pilot.
/// Defaults to orange.
/// </summary>
CrewPilot,
/// <summary>
/// The color used to indicate that a crewable slot contains an engineer.
/// Defaults to green.
/// </summary>
CrewEngineer,
/// <summary>
/// The color used to indicate that a crewable slot contains a scientist.
/// Defaults to blue.
/// </summary>
CrewScientist,
/// <summary>
/// The color used to indicate that a crewable slot contains a tourist.
/// Defaults to white.
/// </summary>
CrewTourist,
/// <summary>
/// The color associated with liquid fuel + oxidizer resources.
/// Defaults to cyan.
/// </summary>
ResourceLFO,
/// <summary>
/// The color associated with liquid fuel resources.
/// Defaults to green.
/// </summary>
ResourceLiquidFuel,
/// <summary>
/// The color associated with oxidizer resources.
/// Defaults to blue.
/// </summary>
ResourceOxidizer,
/// <summary>
/// The color associated with monopropellant resources.
/// Defaults to yellow.
/// </summary>
ResourceMonopropellant,
/// <summary>
/// The color displayed on science instruments with "high-value" results in them.
/// Defaults to bright green.
/// </summary>
HighScience,
/// <summary>
/// The color displayed on science instruments with "partial value" results in them.
/// Defaults to medium yellow.
/// </summary>
MediumScience,
/// <summary>
/// The color displayed on science instruments with "very low value" results in them.
/// Defaults to dim red.
/// </summary>
LowScience,
/// <summary>
/// Color displayed to indicate a problem.
/// </summary>
Warning,
/// <summary>
/// Used for handling the "anything else" case for indicators that show one of several
/// different colors to indicate one of several different known states. This provides
/// a way to handle unexpected cases that aren't errors, such as when some mod
/// adds new options that IndicatorLights doesn't know about.
/// Defaults to magenta.
/// </summary>
Unknown,
}
public static class DefaultColorExtensions
{
/// <summary>
/// Get the name of the enum as listed in the configuration file.
/// </summary>
/// <param name="defaultColor"></param>
/// <returns></returns>
public static string ConfigurationName(this DefaultColor defaultColor)
{
return defaultColor.ToString() + "Color";
}
/// <summary>
/// Gets the default value to use for this color if no configuration is available.
/// </summary>
/// <param name="defaultColor"></param>
/// <returns></returns>
public static Color DefaultValue(this DefaultColor defaultColor)
{
switch (defaultColor)
{
case DefaultColor.Off:
return Color.black;
case DefaultColor.ToggleLED:
return Color.green;
case DefaultColor.HighResource:
return Color.green;
case DefaultColor.MediumResource:
return Color.yellow * 0.7f;
case DefaultColor.LowResource:
return Color.red * 0.5f;
case DefaultColor.ReactionWheelNormal:
return Color.green;
case DefaultColor.ReactionWheelPilotOnly:
return Color.blue;
case DefaultColor.ReactionWheelSASOnly:
return Color.yellow * 0.7f;
case DefaultColor.DockingCrossfeedOn:
return Color.green * 0.7f;
case DefaultColor.DockingCrossfeedOff:
return Color.red * 0.6f;
case DefaultColor.CrewPilot:
return Color.Lerp(new Color(0.5f, 0.3f, 0, 1), Color.gray, 0.1f);
case DefaultColor.CrewEngineer:
return Color.Lerp(Color.green * 0.6f, Color.gray, 0.1f);
case DefaultColor.CrewScientist:
return Color.Lerp(Color.blue, Color.gray, 0.1f);
case DefaultColor.CrewTourist:
return Color.gray;
case DefaultColor.ResourceLFO:
return Color.Lerp(DefaultColor.ResourceLiquidFuel.DefaultValue(), DefaultColor.ResourceOxidizer.DefaultValue(), 0.5f);
case DefaultColor.ResourceLiquidFuel:
return Color.green;
case DefaultColor.ResourceOxidizer:
return new Color(0.1f, 0.4f, 1, 1);
case DefaultColor.ResourceMonopropellant:
return 0.9f * new Color(0.9f, 0.76f, 0, 1);
case DefaultColor.HighScience:
return new Color(0f, 0.85f, 0.15f);
case DefaultColor.MediumScience:
return Color.yellow * 0.6f;
case DefaultColor.LowScience:
return Color.red * 0.45f;
case DefaultColor.Warning:
return Color.red;
case DefaultColor.Unknown:
return Color.magenta;
default:
// this should only happen if there's a bug...
return DefaultValue(DefaultColor.Unknown);
}
}
/// <summary>
/// Gets the value for this color, as specified in the configuration file.
/// </summary>
/// <param name="defaultColor"></param>
/// <returns></returns>
public static Color Value(this DefaultColor defaultColor)
{
switch (defaultColor)
{
case DefaultColor.Off:
return defaultColor.DefaultValue();
case DefaultColor.ToggleLED:
return Configuration.ToggleLEDColor;
case DefaultColor.HighResource:
return Configuration.HighResourceColor;
case DefaultColor.MediumResource:
return Configuration.MediumResourceColor;
case DefaultColor.LowResource:
return Configuration.LowResourceColor;
case DefaultColor.ReactionWheelNormal:
return Configuration.ReactionWheelNormalColor;
case DefaultColor.ReactionWheelPilotOnly:
return Configuration.ReactionWheelPilotOnlyColor;
case DefaultColor.ReactionWheelSASOnly:
return Configuration.ReactionWheelSasOnlyColor;
case DefaultColor.DockingCrossfeedOn:
return Configuration.DockingCrossfeedOnColor;
case DefaultColor.DockingCrossfeedOff:
return Configuration.DockingCrossfeedOffColor;
case DefaultColor.CrewPilot:
return Configuration.CrewPilotColor;
case DefaultColor.CrewEngineer:
return Configuration.CrewEngineerColor;
case DefaultColor.CrewScientist:
return Configuration.CrewScientistColor;
case DefaultColor.CrewTourist:
return Configuration.CrewTouristColor;
case DefaultColor.ResourceLFO:
return Configuration.LfoColor;
case DefaultColor.ResourceLiquidFuel:
return Configuration.LiquidFuelColor;
case DefaultColor.ResourceOxidizer:
return Configuration.OxidizerColor;
case DefaultColor.ResourceMonopropellant:
return Configuration.MonopropellantColor;
case DefaultColor.HighScience:
return Configuration.HighScienceColor;
case DefaultColor.MediumScience:
return Configuration.MediumScienceColor;
case DefaultColor.LowScience:
return Configuration.LowScienceColor;
case DefaultColor.Warning:
return Configuration.WarningColor;
case DefaultColor.Unknown:
return Configuration.UnknownColor;
default:
return defaultColor.DefaultValue();
}
}
}
}