Skip to content

Commit dbc85e5

Browse files
committed
cache settings and pplist
1 parent e4401d4 commit dbc85e5

File tree

3 files changed

+69
-16
lines changed

3 files changed

+69
-16
lines changed

Assets/DevelopmentScene.unity

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ Prefab:
331331
- target: {fileID: 224661754932301978, guid: 0a3b6392f04558844bd340e68ced1ff9,
332332
type: 2}
333333
propertyPath: m_AnchoredPosition.x
334-
value: 171.125
334+
value: 182.125
335335
objectReference: {fileID: 0}
336336
- target: {fileID: 224661754932301978, guid: 0a3b6392f04558844bd340e68ced1ff9,
337337
type: 2}
@@ -351,7 +351,7 @@ Prefab:
351351
- target: {fileID: 224321436090849264, guid: 0a3b6392f04558844bd340e68ced1ff9,
352352
type: 2}
353353
propertyPath: m_AnchoredPosition.x
354-
value: 488.375
354+
value: 521.375
355355
objectReference: {fileID: 0}
356356
- target: {fileID: 224321436090849264, guid: 0a3b6392f04558844bd340e68ced1ff9,
357357
type: 2}
@@ -371,7 +371,7 @@ Prefab:
371371
- target: {fileID: 224146843657791948, guid: 0a3b6392f04558844bd340e68ced1ff9,
372372
type: 2}
373373
propertyPath: m_AnchoredPosition.x
374-
value: 805.625
374+
value: 860.625
375375
objectReference: {fileID: 0}
376376
- target: {fileID: 224146843657791948, guid: 0a3b6392f04558844bd340e68ced1ff9,
377377
type: 2}
@@ -391,7 +391,7 @@ Prefab:
391391
- target: {fileID: 224155073134331500, guid: 0a3b6392f04558844bd340e68ced1ff9,
392392
type: 2}
393393
propertyPath: m_AnchoredPosition.x
394-
value: 1122.875
394+
value: 1199.875
395395
objectReference: {fileID: 0}
396396
- target: {fileID: 224155073134331500, guid: 0a3b6392f04558844bd340e68ced1ff9,
397397
type: 2}
@@ -496,7 +496,7 @@ Prefab:
496496
- target: {fileID: 224235448540703324, guid: 0a3b6392f04558844bd340e68ced1ff9,
497497
type: 2}
498498
propertyPath: m_AnchoredPosition.y
499-
value: -10
499+
value: 0
500500
objectReference: {fileID: 0}
501501
- target: {fileID: 224235448540703324, guid: 0a3b6392f04558844bd340e68ced1ff9,
502502
type: 2}
@@ -506,7 +506,7 @@ Prefab:
506506
- target: {fileID: 224235448540703324, guid: 0a3b6392f04558844bd340e68ced1ff9,
507507
type: 2}
508508
propertyPath: m_SizeDelta.y
509-
value: 20
509+
value: 0
510510
objectReference: {fileID: 0}
511511
- target: {fileID: 224025734146448884, guid: 0a3b6392f04558844bd340e68ced1ff9,
512512
type: 2}
@@ -521,22 +521,22 @@ Prefab:
521521
- target: {fileID: 224025734146448884, guid: 0a3b6392f04558844bd340e68ced1ff9,
522522
type: 2}
523523
propertyPath: m_AnchoredPosition.x
524-
value: 730
524+
value: 774
525525
objectReference: {fileID: 0}
526526
- target: {fileID: 224025734146448884, guid: 0a3b6392f04558844bd340e68ced1ff9,
527527
type: 2}
528528
propertyPath: m_AnchoredPosition.y
529-
value: -10
529+
value: 0
530530
objectReference: {fileID: 0}
531531
- target: {fileID: 224025734146448884, guid: 0a3b6392f04558844bd340e68ced1ff9,
532532
type: 2}
533533
propertyPath: m_SizeDelta.x
534-
value: 1294
534+
value: 1382
535535
objectReference: {fileID: 0}
536536
- target: {fileID: 224025734146448884, guid: 0a3b6392f04558844bd340e68ced1ff9,
537537
type: 2}
538538
propertyPath: m_SizeDelta.y
539-
value: 20
539+
value: 0
540540
objectReference: {fileID: 0}
541541
- target: {fileID: 224999085726949720, guid: 0a3b6392f04558844bd340e68ced1ff9,
542542
type: 2}
@@ -551,12 +551,12 @@ Prefab:
551551
- target: {fileID: 224999085726949720, guid: 0a3b6392f04558844bd340e68ced1ff9,
552552
type: 2}
553553
propertyPath: m_AnchoredPosition.x
554-
value: 1415.5
554+
value: 1503.5
555555
objectReference: {fileID: 0}
556556
- target: {fileID: 224999085726949720, guid: 0a3b6392f04558844bd340e68ced1ff9,
557557
type: 2}
558558
propertyPath: m_AnchoredPosition.y
559-
value: -10
559+
value: 0
560560
objectReference: {fileID: 0}
561561
- target: {fileID: 224999085726949720, guid: 0a3b6392f04558844bd340e68ced1ff9,
562562
type: 2}
@@ -566,7 +566,7 @@ Prefab:
566566
- target: {fileID: 224999085726949720, guid: 0a3b6392f04558844bd340e68ced1ff9,
567567
type: 2}
568568
propertyPath: m_SizeDelta.y
569-
value: 20
569+
value: 0
570570
objectReference: {fileID: 0}
571571
- target: {fileID: 224286096967890162, guid: 0a3b6392f04558844bd340e68ced1ff9,
572572
type: 2}

Assets/UXF/Scripts/UI/ParticipantListSelection.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,28 @@ public class ParticipantListSelection : MonoBehaviour
2424
public PopupController popupController;
2525
public Button startButton;
2626

27+
string ppListLocKey = "ParticipantListLocation";
28+
2729
public void Init()
2830
{
2931
ExperimentStartupController.SetSelectableAndChildrenInteractable(participantSelector.gameObject, false);
3032
ExperimentStartupController.SetSelectableAndChildrenInteractable(form.gameObject, false);
3133
ExperimentStartupController.SetSelectableAndChildrenInteractable(startButton.gameObject, false);
34+
SetFromCache();
3235
}
3336

37+
public void SetFromCache()
38+
{
39+
if (PlayerPrefs.HasKey(ppListLocKey))
40+
{
41+
string loc = PlayerPrefs.GetString(ppListLocKey);
42+
if (File.Exists(loc))
43+
{
44+
CheckSetList(loc);
45+
}
46+
}
47+
}
48+
3449

3550
public void SelectList()
3651
{
@@ -69,6 +84,8 @@ public void GetCheckParticipantList()
6984

7085
void PrepNewPPList(string path)
7186
{
87+
if (path == "") return;
88+
7289
Popup pplistAttention = new Popup();
7390
pplistAttention.messageType = MessageType.Attention;
7491
pplistAttention.message = string.Format("An empty participant list has been created at {0}. Data you collect will be stored in the same folder as this list.", ppListPath);
@@ -128,12 +145,22 @@ public void SetPPList(DataTable data)
128145
participantSelector.SetParticipants(participants);
129146
participantSelector.SelectNewList();
130147

148+
PlayerPrefs.SetString(ppListLocKey, ppListPath);
149+
131150
// enable selector
132151
ExperimentStartupController.SetSelectableAndChildrenInteractable(participantSelector.gameObject, true);
133152
// enable form
134153
ExperimentStartupController.SetSelectableAndChildrenInteractable(form.gameObject, true);
135154
// enable start button
136155
ExperimentStartupController.SetSelectableAndChildrenInteractable(startButton.gameObject, true);
156+
157+
foreach (var dataPoint in startup.participantDataPoints)
158+
{
159+
if (!ppList.Columns.Contains(dataPoint.internalName))
160+
{
161+
ppList.Columns.Add(new DataColumn(dataPoint.internalName, typeof(string)));
162+
}
163+
}
137164
}
138165

139166

Assets/UXF/Scripts/UI/SettingsSelector.cs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ public class SettingsSelector : MonoBehaviour {
1717
[HideInInspector]
1818
public string experimentName;
1919

20+
string settingsFileKey = "SettingsFile";
21+
2022
void Start ()
2123
{
2224
settingsFolder = Application.streamingAssetsPath;
2325
TryGetSettingsList();
26+
SetFromCache();
2427
}
2528

2629

@@ -33,7 +36,6 @@ void TryGetSettingsList()
3336
if (settingsNames.Count > 0)
3437
{
3538
ddController.SetItems(settingsNames);
36-
LoadCurrentSettingsDict();
3739
}
3840
else
3941
{
@@ -49,16 +51,40 @@ void TryGetSettingsList()
4951

5052
}
5153

54+
void SetFromCache()
55+
{
56+
if (PlayerPrefs.HasKey(settingsFileKey))
57+
{
58+
string fname = PlayerPrefs.GetString(settingsFileKey);
59+
string settingsPath = Path.Combine(settingsFolder, fname);
60+
if (File.Exists(settingsPath))
61+
{
62+
ReadSettingsDict(fname);
63+
experimentName = Path.GetFileNameWithoutExtension(fname);
64+
ddController.SetContents(fname);
65+
}
66+
else
67+
{
68+
LoadCurrentSettingsDict();
69+
}
70+
}
71+
else
72+
{
73+
LoadCurrentSettingsDict();
74+
}
75+
}
76+
5277
public void LoadCurrentSettingsDict()
5378
{
5479
string fname = ddController.GetContents().ToString();
5580
ReadSettingsDict(fname);
5681
experimentName = Path.GetFileNameWithoutExtension(fname);
5782
}
5883

59-
void ReadSettingsDict(string settingsName)
84+
void ReadSettingsDict(string fname)
6085
{
61-
string settingsPath = Path.Combine(settingsFolder, settingsName);
86+
string settingsPath = Path.Combine(settingsFolder, fname);
87+
PlayerPrefs.SetString(settingsFileKey, fname);
6288
session.ReadSettingsFile(settingsPath, new System.Action<Dictionary<string, object>>((dict) => HandleSettingsDict(dict)));
6389
}
6490

0 commit comments

Comments
 (0)