@@ -22,16 +22,17 @@ public class UI implements Disposable {
22
22
public ScrollPane pane , ppane ;
23
23
public int right , prevState , prevEditing ;
24
24
public static int addingSpline ;
25
- public Label addingLabel ;
25
+ public Label addingLabel , widget ;
26
26
public boolean splineMode , prevMode , purePursuitMode , showing ;
27
- public TextButton pathId , addNode1 , addNode2 , spline , path , addPath , export , delete , deleteNode , purePursuit , ramsete ;
27
+ public TextButton pathId , addNode1 , addNode2 , spline , path , addPath , play , export , delete , deleteNode , purePursuit , ramsete ;
28
28
public ArrayList <TextField > splines = new ArrayList <>();
29
29
ArrayList <TextField > paths = new ArrayList <>();
30
30
public TextField .TextFieldStyle textFieldStyle ;
31
31
public Label .LabelStyle lStyle2 ;
32
32
public ArrayList <Actor > toggle = new ArrayList <>();
33
33
public ArrayList <Actor > splineEdit = new ArrayList <>();
34
34
public ArrayList <Actor > pathEdit = new ArrayList <>();
35
+ public ArrayList <Actor > notPathEdit = new ArrayList <>();
35
36
public DecimalFormat df , df2 ;
36
37
37
38
public String [] purePursuitLabels = {"Lookahead" , "End Threshold" , "Max Acceleration" , "Max Deceleration" , "Max Velocity" , "Max Angular Vel." , "Start Velocity" , "End Velocity" , "Adjust Threshold" , "Newton's Steps" };
@@ -56,6 +57,20 @@ public UI() {
56
57
container = new Table ();
57
58
table = new Table ();
58
59
ScrollPane .ScrollPaneStyle scrollPaneStyle = new ScrollPane .ScrollPaneStyle ();
60
+ Label .LabelStyle lStyle = new Label .LabelStyle ();
61
+ lStyle .font = PathSim .font ;
62
+ lStyle .font .getData ().setScale (0.5f );
63
+ lStyle .fontColor = new Color (104 /255f ,204 /255f ,220 /255f , 1f );
64
+
65
+ lStyle2 = new Label .LabelStyle ();
66
+ lStyle2 .font = PathSim .font ;
67
+ lStyle2 .font .getData ().setScale (0.6f );
68
+ lStyle2 .fontColor = Color .WHITE ;
69
+
70
+ Label .LabelStyle lStyle3 = new Label .LabelStyle ();
71
+ lStyle3 .font = PathSim .font ;
72
+ lStyle3 .font .getData ().setScale (0.5f );
73
+ lStyle3 .fontColor = Color .WHITE ;
59
74
// scrollPaneStyle.vScrollKnob = PathSim.skin.getDrawable("scroll_vertical_knob");
60
75
// scrollPaneStyle.background = PathSim.skin.getDrawable("btn_default_normal");
61
76
@@ -116,6 +131,10 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
116
131
addPath .getLabel ().setFontScale (0.7f );
117
132
addPath .setBounds (right +50 , Gdx .graphics .getHeight () - 265 , 200 , 50 );
118
133
134
+ play = new TextButton ("Pause Sim" , textButtonStyle );
135
+ play .getLabel ().setFontScale (0.7f );
136
+ play .setBounds (right +50 , Gdx .graphics .getHeight () - 265 , 200 , 50 );
137
+
119
138
addNode1 = new TextButton ("Add Start" , textButtonStyle );
120
139
addNode1 .getLabel ().setFontScale (0.5f );
121
140
addNode1 .setBounds (right +25 , Gdx .graphics .getHeight () - 395 , 130 , 40 );
@@ -156,6 +175,8 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
156
175
ramsete .getLabel ().setFontScale (0.5f );
157
176
ramsete .setBounds (right +145 , Gdx .graphics .getHeight () - 395 , 130 , 40 );
158
177
178
+ widget = new Label ("Manage Paths" , lStyle3 );
179
+
159
180
addListeners ();
160
181
161
182
toggle .add (path );
@@ -168,10 +189,14 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
168
189
169
190
pathEdit .add (purePursuit );
170
191
pathEdit .add (ramsete );
192
+ pathEdit .add (play );
171
193
172
194
stage .addActor (pathId );
173
- stage .addActor (addPath );
195
+ notPathEdit .add (addPath );
196
+ notPathEdit .add (widget );
197
+
174
198
199
+ for (Actor a : notPathEdit ) stage .addActor (a );
175
200
176
201
textFieldStyle = new TextField .TextFieldStyle (PathSim .font , Color .WHITE ,
177
202
PathSim .skin .getDrawable ("textfield_cursor" ), PathSim .skin .getDrawable ("textfield_selection" ), PathSim .skin .getDrawable ("textfield_default" ));
@@ -184,17 +209,8 @@ public boolean touchDown (InputEvent event, float x, float y, int pointer, int b
184
209
}
185
210
});
186
211
187
- Label .LabelStyle lStyle = new Label .LabelStyle ();
188
- lStyle .font = PathSim .font ;
189
- lStyle .font .getData ().setScale (0.5f );
190
- lStyle .fontColor = new Color (104 /255f ,204 /255f ,220 /255f , 1f );
191
-
192
- lStyle2 = new Label .LabelStyle ();
193
- lStyle2 .font = PathSim .font ;
194
- lStyle2 .font .getData ().setScale (0.6f );
195
- lStyle2 .fontColor = Color .WHITE ;
196
-
197
212
addingLabel = new Label ("" , lStyle );
213
+
198
214
prevEditing = -1 ;
199
215
}
200
216
@@ -253,17 +269,23 @@ public void update(float delta) {
253
269
deleteNode .remove ();
254
270
}
255
271
256
- if (splineMode && !prevMode && PathSim .pathManager .curEditingPath != - 1 ) {
272
+ if (splineMode && !prevMode && PathSim .pathManager .editingPath () ) {
257
273
for (Actor a : splineEdit ) stage .addActor (a );
258
274
for (Actor a : pathEdit ) a .remove ();
259
275
showing = true ;
260
- } else if (!splineMode && prevMode && PathSim .pathManager .curEditingPath != -1 ) {
276
+
277
+ for (Actor a : notPathEdit ) stage .addActor (a );
278
+ } else if (!splineMode && prevMode && PathSim .pathManager .editingPath ()) {
261
279
for (Actor a : pathEdit ) stage .addActor (a );
280
+ for (Actor a : notPathEdit ) a .remove ();
281
+ path .setText ("Pause Sim" );
262
282
for (Actor a : splineEdit ) a .remove ();
263
283
showing = true ;
264
284
populatePathEdit ();
265
285
}
266
286
287
+ widget .setBounds (PathSim .renderer2d .widgetX + 20 , PathSim .renderer2d .widgetY + PathSim .renderer2d .wh - 15 - widget .getPrefHeight ()/2 , widget .getPrefWidth (), widget .getPrefHeight ());
288
+
267
289
prevEditing = PathSim .pathManager .curEditingPath ;
268
290
prevMode = splineMode ;
269
291
@@ -784,6 +806,22 @@ public void changed(ChangeEvent event, Actor actor) {
784
806
}
785
807
});
786
808
809
+ play .addListener (new ChangeListener () {
810
+ @ Override
811
+ public void changed (ChangeEvent event , Actor actor ) {
812
+ if (PathSim .renderer3d .running ) {
813
+ PathSim .renderer3d .running = false ;
814
+ play .setText ("Resume Sim" );
815
+ } else {
816
+ if (PathSim .renderer3d .curInd == simulator .getEnd (purePursuitMode ) - 1 ) {
817
+ PathSim .renderer3d .curInd = 0 ;
818
+ }
819
+ PathSim .renderer3d .running = true ;
820
+ play .setText ("Pause Sim" );
821
+ }
822
+ }
823
+ });
824
+
787
825
addNode1 .addListener (new ChangeListener () {
788
826
@ Override
789
827
public void changed (ChangeEvent event , Actor actor ) {
0 commit comments