Skip to content

Commit 8996cfa

Browse files
committed
ui logic
1 parent c322197 commit 8996cfa

File tree

4 files changed

+69
-22
lines changed

4 files changed

+69
-22
lines changed

Assets/UXF/Prefabs/[UXF_Rig].prefab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22909,10 +22909,10 @@ MonoBehaviour:
2290922909
m_Name:
2291022910
m_EditorClassIdentifier:
2291122911
startupMode: 0
22912-
settingsMode: 1
22912+
settingsMode: 0
2291322913
settingsSearchPattern: '*.json'
2291422914
jsonURL: https://gist.githubusercontent.com/jackbrookes/0f9770fcfe3d448e0f7a1973c2ac7419/raw/f2d234c92c77a817f9fc6390fcfcb39814c33d3c/example_settings.json
22915-
showPPIDElement: 1
22915+
ppidMode: 0
2291622916
participantDataPoints: []
2291722917
termsAndConditions: Please tick if you understand the instructions and agree for
2291822918
your data to be collected and used for research purposes.<color=red>*</color>

Assets/UXF/Scripts/Etc/Editor/SessionEditor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ protected override void DrawInspector()
5151
GUILayout.FlexibleSpace();
5252
GUILayout.EndHorizontal();
5353

54-
55-
5654
Rect rectBox = EditorGUILayout.BeginVertical("Box");
5755
float lw = EditorGUIUtility.labelWidth;
5856

Assets/UXF/Scripts/Etc/Editor/UIControllerEditor.cs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ public class UIControllerEditor : SubjectNerd.Utilities.ReorderableArrayInspecto
2626
{
2727
{ SessionSettingsMode.SelectWithUI, "TODO" },
2828
{ SessionSettingsMode.DownloadFromURL, "TODO" },
29-
{ SessionSettingsMode.None, "TODO" }
29+
{ SessionSettingsMode.Empty, "TODO" }
30+
};
31+
32+
static Dictionary<PPIDMode, string> ppidModeDescriptionMapping = new Dictionary<PPIDMode, string>()
33+
{
34+
{ PPIDMode.EnterWithUI, "TODO" },
35+
{ PPIDMode.GenerateUnique, "TODO" }
3036
};
3137

3238
protected override void InitInspector()
@@ -73,20 +79,40 @@ protected override void DrawInspector()
7379
switch (tabSelection)
7480
{
7581
case 0:
76-
string reasonText;
77-
if (!uiController.SettingsAreCompatible(out reasonText))
82+
83+
string ppidReasonText;
84+
if (!uiController.PPIDModeIsInvalid(out ppidReasonText))
85+
{
86+
string errorText = "Incompatibility Error: " + ppidReasonText;
87+
EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
88+
EditorGUILayout.Separator();
89+
}
90+
91+
string settingsReasonText;
92+
if (!uiController.SettingsModeIsCompatible(out settingsReasonText))
7893
{
79-
string errorText = "Incompatibility Error: " + reasonText;
94+
string errorText = "Incompatibility Error: " + settingsReasonText;
8095
EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
8196
EditorGUILayout.Separator();
8297
}
8398

8499
this.DrawProperty("startupMode");
85-
EditorGUILayout.HelpBox(uiController.startupMode.ToString() + ": " + startupModeDescriptionMapping[uiController.startupMode], UnityEditor.MessageType.Info);
100+
EditorGUILayout.HelpBox("Startup Mode " + uiController.startupMode.ToString() + ": " + startupModeDescriptionMapping[uiController.startupMode], UnityEditor.MessageType.Info);
101+
EditorGUILayout.Separator();
102+
103+
EditorGUI.BeginDisabledGroup(uiController.startupMode == StartupMode.Manual);
104+
if (uiController.startupMode == StartupMode.Manual)
105+
{
106+
EditorGUILayout.HelpBox("Manual is selected as the Startup Setting - the options below have no effect.", UnityEditor.MessageType.Info);
107+
EditorGUILayout.Separator();
108+
}
109+
110+
this.DrawProperty("ppidMode");
111+
EditorGUILayout.HelpBox("PPID Mode " + uiController.ppidMode.ToString() + ": " + ppidModeDescriptionMapping[uiController.ppidMode], UnityEditor.MessageType.Info);
86112
EditorGUILayout.Separator();
87113

88114
this.DrawProperty("settingsMode");
89-
EditorGUILayout.HelpBox(uiController.settingsMode.ToString() + ": " + settingsModeDescriptionMapping[uiController.settingsMode], UnityEditor.MessageType.Info);
115+
EditorGUILayout.HelpBox("Settings Mode " + uiController.settingsMode.ToString() + ": " + settingsModeDescriptionMapping[uiController.settingsMode], UnityEditor.MessageType.Info);
90116
switch (uiController.settingsMode)
91117
{
92118
case SessionSettingsMode.SelectWithUI:
@@ -96,36 +122,40 @@ protected override void DrawInspector()
96122
if (MiddleButton("Test URL")) throw new NotImplementedException("TODO");
97123
this.DrawProperty("jsonURL");
98124
break;
99-
case SessionSettingsMode.None:
125+
case SessionSettingsMode.Empty:
100126
break;
101127
}
128+
129+
EditorGUI.EndDisabledGroup();
130+
102131
EditorGUILayout.Separator();
103132
break;
104133
case 1:
134+
string datapointsReasonText;
105135
EditorGUILayout.HelpBox(
106136
"Below you can enter a series of datapoints to be collected about a participant" +
107137
"- such as their age, gender, or even things that could affect the task such as " +
108138
"the preferred hand of the participant. Press the Generate button to update the UI " +
109139
"to reflect your items.", UnityEditor.MessageType.Info);
110-
bool valid = uiController.DatapointsAreValid(out reasonText);
140+
bool valid = uiController.DatapointsAreValid(out datapointsReasonText);
111141
if (!valid)
112142
{
113-
string errorText = "Participant Datapoints Error: " + reasonText;
143+
string errorText = "Participant Datapoints Error: " + datapointsReasonText;
114144
EditorGUILayout.HelpBox(errorText, UnityEditor.MessageType.Error);
115145
EditorGUILayout.Separator();
116146
}
117147
if (MiddleButton("Generate", enabled: valid)) throw new NotImplementedException("TODO");
118148
EditorGUILayout.Separator();
119149
EditorGUI.indentLevel++;
120-
this.DrawProperty("showPPIDElement");
121150
DrawPropertiesFromUpTo("participantDataPoints", "termsAndConditions");
122151
EditorGUI.indentLevel--;
123152
break;
124153
case 2:
125154
EditorGUILayout.HelpBox(
126155
"You can edit the content that displays in the right side of the UI. This can " +
127156
"be used for instructions to the participant or researcher on how the study should " +
128-
"be performed. You can add any UI elements such as text, images, or even buttons to " +
157+
"be performed, and what types of data will be collected. " +
158+
"You can add any UI elements such as text, images, or even buttons to " +
129159
"the Instructions Panel Content GameObject. You can select it with the button below.", UnityEditor.MessageType.Info);
130160
if (MiddleButton("Select Content GameObject"))
131161
{
@@ -151,7 +181,7 @@ protected override void DrawInspector()
151181

152182
public void DrawUIDisabledMessage()
153183
{
154-
EditorGUILayout.HelpBox("The Built-in UI is not selected as the Startup Setting - these options have no effect.", UnityEditor.MessageType.Warning);
184+
EditorGUILayout.HelpBox("The Built-in UI is not selected as the Startup Setting - the options below have no effect.", UnityEditor.MessageType.Warning);
155185
EditorGUILayout.Separator();
156186
}
157187

Assets/UXF/Scripts/UI/UIController.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,20 @@ public class UIController : MonoBehaviour
1818
public SessionSettingsMode settingsMode = SessionSettingsMode.SelectWithUI;
1919

2020
[Tooltip("TODO")]
21+
[TextArea]
2122
public string settingsSearchPattern = "*.json";
2223

2324
[Tooltip("TODO")]
2425
public string jsonURL = "https://gist.githubusercontent.com/jackbrookes/0f9770fcfe3d448e0f7a1973c2ac7419/raw/f2d234c92c77a817f9fc6390fcfcb39814c33d3c/example_settings.json";
2526

26-
[Tooltip("Should the Participant ID element be shown in the UI? If now, a unique generated ID will be used.")]
27-
public bool showPPIDElement = true;
27+
[Tooltip("How should the Participant ID be collected?")]
28+
public PPIDMode ppidMode = PPIDMode.EnterWithUI;
2829

2930
[SubjectNerd.Utilities.Reorderable]
3031
public List<FormElementEntry> participantDataPoints = new List<FormElementEntry>();
3132

3233
[Tooltip("The text shown next to the terms and conditions checkbox.")]
34+
[TextArea]
3335
public string termsAndConditions = "Please tick if you understand the instructions and agree for your data to be collected and used for research purposes.<color=red>*</color>";
3436

3537
[Tooltip("Should the terms and conditions checkbox be pre-ticked?")]
@@ -54,13 +56,25 @@ void OnValidate()
5456
tsAndCsToggle.isOn = tsAndCsInitialState;
5557
}
5658

59+
public bool PPIDModeIsInvalid(out string reasonText)
60+
{
61+
reasonText = string.Empty;
62+
if (startupMode == StartupMode.Automatic && ppidMode == PPIDMode.EnterWithUI)
63+
{
64+
reasonText = "If startup mode is Automatic, you cannot use PPID (Participant ID) mode: Select With UI.";
65+
return false;
66+
}
67+
68+
return true;
69+
}
70+
5771

58-
public bool SettingsAreCompatible(out string reasonText)
72+
public bool SettingsModeIsCompatible(out string reasonText)
5973
{
6074
reasonText = string.Empty;
61-
if (startupMode != StartupMode.BuiltInUI && settingsMode == SessionSettingsMode.SelectWithUI)
75+
if (startupMode == StartupMode.Automatic && settingsMode == SessionSettingsMode.SelectWithUI)
6276
{
63-
reasonText = "If startup mode is not set to the Built-in UI, you cannot use session settings mode: Select With UI.";
77+
reasonText = "If startup mode is set to Automatic, you cannot use session settings mode: Select With UI.";
6478
return false;
6579
}
6680

@@ -117,6 +131,11 @@ public enum StartupMode
117131

118132
public enum SessionSettingsMode
119133
{
120-
SelectWithUI, DownloadFromURL, None
134+
SelectWithUI, DownloadFromURL, Empty
135+
}
136+
137+
public enum PPIDMode
138+
{
139+
EnterWithUI, GenerateUnique
121140
}
122141
}

0 commit comments

Comments
 (0)