Skip to content

Commit 65a051d

Browse files
committed
look cool butoon
1 parent d8434aa commit 65a051d

File tree

4 files changed

+54
-21
lines changed

4 files changed

+54
-21
lines changed

core/assets/robot.g3db

180 KB
Binary file not shown.

core/src/com/github/mittyrobotics/tools/Renderer2D.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@ public void handleInput() {
276276
PathSim.pathManager.curOnPath = i;
277277
PathSim.pathManager.curHoveringNode = k + 1;
278278
}
279-
for (int t = 0; t <= 1; t += 1) {
280-
Point2D v = toPointOnScreen(group.getSpline(k).getDerivative(t, 1).multiply(t == 1 ? 1 / 5. : -1 / 5.).add(group.getSpline(k).getPoint(t)));
281-
if (distance(x, y, v) < points.getWidth() / 2f) {
282-
PathSim.pathManager.curOnPath = i;
283-
}
284-
}
285279
}
286280

287281
Point2D p = toPointOnScreen(group.getSpline(0).getPoint(0));

core/src/com/github/mittyrobotics/tools/Renderer3D.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public void render () {
139139
if (curInd >= s.getEnd(tempui.purePursuitMode)) {
140140
running = false;
141141
curInd = s.getEnd(tempui.purePursuitMode) - 1;
142+
tempui.play.setText("Run Sim");
142143
}
143144
}
144145
}

core/src/com/github/mittyrobotics/tools/UI.java

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@ public class UI implements Disposable {
2222
public ScrollPane pane, ppane;
2323
public int right, prevState, prevEditing;
2424
public static int addingSpline;
25-
public Label addingLabel;
25+
public Label addingLabel, widget;
2626
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;
2828
public ArrayList<TextField> splines = new ArrayList<>();
2929
ArrayList<TextField> paths = new ArrayList<>();
3030
public TextField.TextFieldStyle textFieldStyle;
3131
public Label.LabelStyle lStyle2;
3232
public ArrayList<Actor> toggle = new ArrayList<>();
3333
public ArrayList<Actor> splineEdit = new ArrayList<>();
3434
public ArrayList<Actor> pathEdit = new ArrayList<>();
35+
public ArrayList<Actor> notPathEdit = new ArrayList<>();
3536
public DecimalFormat df, df2;
3637

3738
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() {
5657
container = new Table();
5758
table = new Table();
5859
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;
5974
// scrollPaneStyle.vScrollKnob = PathSim.skin.getDrawable("scroll_vertical_knob");
6075
// scrollPaneStyle.background = PathSim.skin.getDrawable("btn_default_normal");
6176

@@ -116,6 +131,10 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
116131
addPath.getLabel().setFontScale(0.7f);
117132
addPath.setBounds(right+50, Gdx.graphics.getHeight() - 265, 200, 50);
118133

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+
119138
addNode1 = new TextButton("Add Start", textButtonStyle);
120139
addNode1.getLabel().setFontScale(0.5f);
121140
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)
156175
ramsete.getLabel().setFontScale(0.5f);
157176
ramsete.setBounds(right+145, Gdx.graphics.getHeight() - 395, 130, 40);
158177

178+
widget = new Label("Manage Paths", lStyle3);
179+
159180
addListeners();
160181

161182
toggle.add(path);
@@ -168,10 +189,14 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
168189

169190
pathEdit.add(purePursuit);
170191
pathEdit.add(ramsete);
192+
pathEdit.add(play);
171193

172194
stage.addActor(pathId);
173-
stage.addActor(addPath);
195+
notPathEdit.add(addPath);
196+
notPathEdit.add(widget);
197+
174198

199+
for(Actor a : notPathEdit) stage.addActor(a);
175200

176201
textFieldStyle = new TextField.TextFieldStyle(PathSim.font, Color.WHITE,
177202
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
184209
}
185210
});
186211

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-
197212
addingLabel = new Label("", lStyle);
213+
198214
prevEditing = -1;
199215
}
200216

@@ -253,17 +269,23 @@ public void update(float delta) {
253269
deleteNode.remove();
254270
}
255271

256-
if(splineMode && !prevMode && PathSim.pathManager.curEditingPath != -1) {
272+
if(splineMode && !prevMode && PathSim.pathManager.editingPath()) {
257273
for(Actor a : splineEdit) stage.addActor(a);
258274
for(Actor a : pathEdit) a.remove();
259275
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()) {
261279
for(Actor a : pathEdit) stage.addActor(a);
280+
for(Actor a : notPathEdit) a.remove();
281+
path.setText("Pause Sim");
262282
for(Actor a : splineEdit) a.remove();
263283
showing = true;
264284
populatePathEdit();
265285
}
266286

287+
widget.setBounds(PathSim.renderer2d.widgetX + 20, PathSim.renderer2d.widgetY + PathSim.renderer2d.wh - 15 - widget.getPrefHeight()/2, widget.getPrefWidth(), widget.getPrefHeight());
288+
267289
prevEditing = PathSim.pathManager.curEditingPath;
268290
prevMode = splineMode;
269291

@@ -784,6 +806,22 @@ public void changed(ChangeEvent event, Actor actor) {
784806
}
785807
});
786808

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+
787825
addNode1.addListener(new ChangeListener() {
788826
@Override
789827
public void changed(ChangeEvent event, Actor actor) {

0 commit comments

Comments
 (0)