3
3
import com .badlogic .gdx .Gdx ;
4
4
import com .badlogic .gdx .Input ;
5
5
import com .badlogic .gdx .graphics .Color ;
6
+ import com .badlogic .gdx .graphics .Texture ;
6
7
import com .badlogic .gdx .scenes .scene2d .*;
7
8
import com .badlogic .gdx .scenes .scene2d .ui .*;
8
9
import com .badlogic .gdx .scenes .scene2d .utils .ChangeListener ;
9
10
import com .badlogic .gdx .scenes .scene2d .utils .ClickListener ;
11
+ import com .badlogic .gdx .scenes .scene2d .utils .TextureRegionDrawable ;
10
12
import com .badlogic .gdx .utils .Align ;
11
13
import com .badlogic .gdx .utils .Disposable ;
12
14
import com .github .mittyrobotics .PathSim ;
18
20
public class UI implements Disposable {
19
21
20
22
public Stage stage ;
21
- public Table container , table , pcontainer , ptable ;
22
- public ScrollPane pane , ppane ;
23
+ public Table container , table , pcontainer , ptable , widgetTable , widgetContainer ;
24
+ public ScrollPane pane , ppane , widgetPane ;
23
25
public int right , prevState , prevEditing ;
24
26
public static int addingSpline ;
25
27
public Label addingLabel , widget ;
@@ -119,6 +121,28 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
119
121
pcontainer .setBounds (right +25 , 82 , 250 , Gdx .graphics .getHeight () - 478 );
120
122
pathEdit .add (pcontainer );
121
123
124
+ widgetTable = new Table ();
125
+ widgetContainer = new Table ();
126
+
127
+ widgetPane = new ScrollPane (widgetTable , scrollPaneStyle );
128
+ widgetTable .align (Align .top );
129
+ widgetPane .setScrollingDisabled (true , false );
130
+ widgetPane .addListener (new ClickListener () {
131
+ @ Override
132
+ public void enter (InputEvent event , float x , float y , int pointer , Actor fromActor ) {
133
+ stage .setScrollFocus (widgetPane );
134
+ }
135
+
136
+ @ Override
137
+ public void exit (InputEvent event , float x , float y , int pointer , Actor toActor ) {
138
+ stage .setScrollFocus (null );
139
+ }
140
+ });
141
+ widgetPane .setFlickScroll (false );
142
+ widgetPane .layout ();
143
+ widgetContainer .add (widgetPane ).fill ().expand ();
144
+ widgetContainer .row ();
145
+
122
146
TextButton .TextButtonStyle textButtonStyle = new TextButton .TextButtonStyle ();
123
147
textButtonStyle .font = PathSim .font ;
124
148
textButtonStyle .up = PathSim .skin .getDrawable ("btn_default_normal" );
@@ -176,6 +200,7 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
176
200
ramsete .setBounds (right +145 , Gdx .graphics .getHeight () - 395 , 130 , 40 );
177
201
178
202
widget = new Label ("Manage Paths" , lStyle3 );
203
+ widget .setFontScale (0.65f );
179
204
180
205
addListeners ();
181
206
@@ -272,19 +297,24 @@ public void update(float delta) {
272
297
if (splineMode && !prevMode && PathSim .pathManager .editingPath ()) {
273
298
for (Actor a : splineEdit ) stage .addActor (a );
274
299
for (Actor a : pathEdit ) a .remove ();
275
- showing = true ;
276
-
277
300
for (Actor a : notPathEdit ) stage .addActor (a );
301
+ showing = true ;
278
302
} else if (!splineMode && prevMode && PathSim .pathManager .editingPath ()) {
279
303
for (Actor a : pathEdit ) stage .addActor (a );
280
304
for (Actor a : notPathEdit ) a .remove ();
281
- path .setText ("Pause Sim" );
282
305
for (Actor a : splineEdit ) a .remove ();
306
+ path .setText ("Pause Sim" );
283
307
showing = true ;
284
308
populatePathEdit ();
285
309
}
286
310
287
- widget .setBounds (PathSim .renderer2d .widgetX + 20 , PathSim .renderer2d .widgetY + PathSim .renderer2d .wh - 15 - widget .getPrefHeight ()/2 , widget .getPrefWidth (), widget .getPrefHeight ());
311
+ widget .setBounds (PathSim .renderer2d .rwx + 20 , PathSim .renderer2d .rwy + PathSim .renderer2d .wh - 20 - widget .getPrefHeight ()/2 , widget .getPrefWidth (), widget .getPrefHeight ());
312
+ widgetContainer .setBounds (PathSim .renderer2d .rwx , PathSim .renderer2d .rwy +10 , PathSim .renderer2d .ww , PathSim .renderer2d .wh - 55 );
313
+ if (PathSim .renderer2d .widgetExpanded ) {
314
+ stage .addActor (widgetContainer );
315
+ } else {
316
+ widgetContainer .remove ();
317
+ }
288
318
289
319
prevEditing = PathSim .pathManager .curEditingPath ;
290
320
prevMode = splineMode ;
@@ -295,6 +325,45 @@ public void update(float delta) {
295
325
updateExportFrame (false );
296
326
}
297
327
328
+ public void populateWidget () {
329
+ int i = 1 ;
330
+ widgetTable .clear ();
331
+ for (ExtendedPath p : PathSim .pathManager .paths ) {
332
+ Label l = new Label ("Path " + i , lStyle2 );
333
+ l .setFontScale (0.5f );
334
+ Image del = new Image (PathSim .renderer2d .trash );
335
+ del .addListener (new ClickListener () {
336
+ public void clicked (InputEvent event , float x , float y ){
337
+ PathSim .pathManager .delayRemove (p );
338
+ }
339
+ });
340
+ Image edit = new Image (PathSim .renderer2d .edit );
341
+ edit .addListener (new ClickListener () {
342
+ public void clicked (InputEvent event , float x , float y ){
343
+ PathSim .pathManager .chooseEditPath (p );
344
+ }
345
+ });
346
+ Image visible = new Image (p .visible ? PathSim .renderer2d .visible : PathSim .renderer2d .invisible );
347
+ visible .addListener (new ClickListener () {
348
+ public void clicked (InputEvent event , float x , float y ){
349
+ p .visible = !p .visible ;
350
+ if (p .visible ) visible .setDrawable (new TextureRegionDrawable (PathSim .renderer2d .visible ));
351
+ else visible .setDrawable (new TextureRegionDrawable (PathSim .renderer2d .invisible ));
352
+ if (PathSim .pathManager .paths .indexOf (p ) == PathSim .pathManager .curEditingPath ) {
353
+ PathSim .pathManager .curEditingPath = -1 ;
354
+ }
355
+ }
356
+ });
357
+
358
+ widgetTable .add (l ).height (30 ).width (140 ).align (Align .left ).pad (0 , 15 , 0 , 0 );
359
+ widgetTable .add (visible ).height (20 ).width (20 ).align (Align .right ).pad (0 , 0 , 0 , 5 );
360
+ widgetTable .add (edit ).height (20 ).width (20 ).align (Align .right ).pad (0 , 5 , 0 , 5 );
361
+ widgetTable .add (del ).height (20 ).width (20 ).align (Align .right ).pad (0 , 5 , 0 , 15 );
362
+ widgetTable .row ();
363
+ i ++;
364
+ }
365
+ }
366
+
298
367
public void populateSplineEdit () {
299
368
export .setText ("Export Spline" );
300
369
0 commit comments