-
Notifications
You must be signed in to change notification settings - Fork 96
/
SCAN_SettingsResource.cs
249 lines (190 loc) · 5.83 KB
/
SCAN_SettingsResource.cs
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using SCANsat.Unity.Interfaces;
namespace SCANsat.Unity.Unity
{
public class SCAN_SettingsResource : SettingsPage
{
[SerializeField]
private Toggle m_BiomeLockToggle = null;
[SerializeField]
private Toggle m_NarrowBandToggle = null;
[SerializeField]
private Toggle m_InstantScanToggle = null;
[SerializeField]
private Toggle m_DisableStockToggle = null;
[SerializeField]
private GameObject m_StockThresholdObject = null;
[SerializeField]
private Toggle m_StockThresholdToggle = null;
[SerializeField]
private TextHandler m_StockThresholdValue = null;
[SerializeField]
private InputField m_ThresholdInput = null;
[SerializeField]
private TextHandler m_MapInterpolation = null;
[SerializeField]
private TextHandler m_MapHeight = null;
[SerializeField]
private TextHandler m_CoverageTransparency = null;
[SerializeField]
private TextHandler m_BiomeMapHeight = null;
private bool loaded;
private ISCAN_Settings settings;
public void setup(ISCAN_Settings set)
{
if (set == null)
return;
settings = set;
if (m_BiomeLockToggle != null)
m_BiomeLockToggle.isOn = set.BiomeLock;
if (m_NarrowBandToggle != null)
m_NarrowBandToggle.isOn = set.NarrowBand;
if (m_DisableStockToggle != null)
m_DisableStockToggle.isOn = set.DisableStock;
if (m_InstantScanToggle != null)
{
m_InstantScanToggle.isOn = set.InstantScan;
m_InstantScanToggle.gameObject.SetActive(!set.DisableStock);
}
if (m_StockThresholdObject != null)
m_StockThresholdObject.gameObject.SetActive(set.DisableStock);
if (m_StockThresholdToggle != null)
m_StockThresholdToggle.isOn = set.StockThreshold;
if (m_StockThresholdValue != null)
m_StockThresholdValue.OnTextUpdate.Invoke("Stock Scan Threshold: " + set.StockThresholdValue.ToString("P0"));
if (set.DisableStock)
{
if (m_InstantScanToggle != null)
m_InstantScanToggle.gameObject.SetActive(false);
}
else
{
if (m_StockThresholdObject != null)
m_StockThresholdObject.gameObject.SetActive(false);
}
if (m_MapInterpolation != null)
m_MapInterpolation.OnTextUpdate.Invoke(set.Interpolation.ToString());
if (m_MapHeight != null)
m_MapHeight.OnTextUpdate.Invoke(set.MapHeight.ToString());
if (m_CoverageTransparency != null)
m_CoverageTransparency.OnTextUpdate.Invoke(set.Transparency.ToString("P0"));
if (m_BiomeMapHeight != null)
m_BiomeMapHeight.OnTextUpdate.Invoke(set.BiomeMapHeight.ToString());
loaded = true;
}
public void BimomeLock(bool isOn)
{
if (!loaded || settings == null)
return;
settings.BiomeLock = isOn;
}
public void RequireNarrowBand(bool isOn)
{
if (!loaded || settings == null)
return;
settings.NarrowBand = isOn;
}
public void DisableStock(bool isOn)
{
if (!loaded || settings == null)
return;
settings.DisableStock = isOn;
if (m_InstantScanToggle != null)
m_InstantScanToggle.gameObject.SetActive(!isOn);
if (m_StockThresholdObject != null)
m_StockThresholdObject.gameObject.SetActive(isOn);
}
public void InstantScan(bool isOn)
{
if (!loaded || settings == null)
return;
settings.InstantScan = isOn;
}
public void StockTreshold(bool isOn)
{
if (!loaded || settings == null)
return;
settings.StockThreshold = isOn;
}
public void SetThreshold()
{
if (m_ThresholdInput == null || settings == null)
return;
float value = settings.StockThresholdValue;
if (float.TryParse(m_ThresholdInput.text, out value))
{
settings.StockThresholdValue = value;
if (m_StockThresholdValue != null)
m_StockThresholdValue.OnTextUpdate.Invoke("Stock Scan Threshold: " + value.ToString("P0"));
}
}
public void InterpolationDown()
{
if (settings == null)
return;
settings.Interpolation = Math.Max(2, settings.Interpolation / 2);
if (m_MapInterpolation != null)
m_MapInterpolation.OnTextUpdate.Invoke(settings.Interpolation.ToString());
}
public void InterpolationUp()
{
if (settings == null)
return;
settings.Interpolation = Math.Min(32, settings.Interpolation * 2);
if (m_MapInterpolation != null)
m_MapInterpolation.OnTextUpdate.Invoke(settings.Interpolation.ToString());
}
public void MapHeightDown()
{
if (settings == null)
return;
settings.MapHeight = Math.Max(64, settings.MapHeight / 2);
if (m_MapHeight != null)
m_MapHeight.OnTextUpdate.Invoke(settings.MapHeight.ToString());
}
public void MapHeightUp()
{
if (settings == null)
return;
settings.MapHeight = Math.Min(1024, settings.MapHeight * 2);
if (m_MapHeight != null)
m_MapHeight.OnTextUpdate.Invoke(settings.MapHeight.ToString());
}
public void TransparencyDown()
{
if (settings == null)
return;
settings.Transparency = Mathf.Max(0f, settings.Transparency - 0.1f);
if (m_CoverageTransparency != null)
m_CoverageTransparency.OnTextUpdate.Invoke(settings.Transparency.ToString("P0"));
}
public void TransparencyUp()
{
if (settings == null)
return;
settings.Transparency = Mathf.Min(1f, settings.Transparency + 0.1f);
if (m_CoverageTransparency != null)
m_CoverageTransparency.OnTextUpdate.Invoke(settings.Transparency.ToString("P0"));
}
public void BiomeMapHeightDown()
{
if (settings == null)
return;
settings.BiomeMapHeight = Math.Max(256, settings.BiomeMapHeight / 2);
if (m_BiomeMapHeight != null)
m_BiomeMapHeight.OnTextUpdate.Invoke(settings.BiomeMapHeight.ToString());
}
public void BiomeMapHeightUp()
{
if (settings == null)
return;
settings.BiomeMapHeight = Math.Min(1024, settings.BiomeMapHeight * 2);
if (m_BiomeMapHeight != null)
m_BiomeMapHeight.OnTextUpdate.Invoke(settings.BiomeMapHeight.ToString());
}
}
}