Skip to content

Commit f7cfd5c

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 4f71581 + f73a0ea commit f7cfd5c

File tree

5 files changed

+53
-5
lines changed

5 files changed

+53
-5
lines changed

core/src/main/java/com/amhsrobotics/circuitsim/gui/CircuitGUIManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -584,9 +584,9 @@ public void exit(InputEvent event, float x, float y, int pointer, Actor toActor)
584584
tbStyle.down = Constants.SKIN.getDrawable("button_02");
585585

586586
TextButton dontshow = new TextButton(" Don't Show Again ", tbStyle);
587-
welcomeMenu.add(dontshow).colspan(1).padRight(10).align(Align.right);
587+
// welcomeMenu.add(dontshow).colspan(1).padRight(10).align(Align.right);
588588
TextButton close = new TextButton(" Close ", tbStyle);
589-
welcomeMenu.add(close).colspan(1).padLeft(10).align(Align.left);
589+
welcomeMenu.add(close).colspan(2).align(Align.center);
590590

591591
dontshow.addListener(new ChangeListener() {
592592
@Override

core/src/main/java/com/amhsrobotics/circuitsim/hardware/Hardware.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,13 @@ public void update(SpriteBatch batch, ModifiedShapeRenderer renderer, ClippedCam
470470
}
471471

472472
//SET OWN POSITION
473-
setPosition(vec.x + diffX, vec.y + diffY);
473+
474+
Vector2 isOutOfBounds = Tools.checkOutOfBounds(getSpriteBox(), getPosition());
475+
if(isOutOfBounds != null) {
476+
setPosition(isOutOfBounds.x, isOutOfBounds.y);
477+
} else {
478+
setPosition(vec.x + diffX, vec.y + diffY);
479+
}
474480
}
475481

476482
}

core/src/main/java/com/amhsrobotics/circuitsim/screens/CircuitScreen.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.amhsrobotics.circuitsim.Constants;
44
import com.amhsrobotics.circuitsim.files.FileManager;
55
import com.amhsrobotics.circuitsim.gui.CircuitGUIManager;
6+
import com.amhsrobotics.circuitsim.gui.ConfirmDialog;
67
import com.amhsrobotics.circuitsim.hardware.Hardware;
78
import com.amhsrobotics.circuitsim.hardware.HardwareManager;
89
import com.amhsrobotics.circuitsim.hardware.HardwareType;
@@ -107,7 +108,9 @@ public boolean touchDragged(int screenX, int screenY, int pointer) {
107108
}
108109
}
109110
for(Hardware h : selected) {
111+
// if(h.getSpriteBox().x - 10 > Tools.mouseScreenToWorld(camera).x) {
110112
h.move(x, -y);
113+
// }
111114
}
112115
selectMultiple1.add(x, -y);
113116
selectMultiple2.add(x, -y);
@@ -133,7 +136,7 @@ public boolean scrolled(float amountX, float amountY) {
133136

134137
Vector3 worldCoordsBefore = camera.getCamera().unproject(new Vector3(screenCoords));
135138

136-
camera.getCamera().zoom += amountY * camera.getCamera().zoom * 0.015f;
139+
camera.getCamera().zoom += amountY * camera.getCamera().zoom * 0.1f;
137140
camera.getCamera().update();
138141

139142
Vector3 worldCoordsAfter = camera.getCamera().unproject(new Vector3(screenCoords));
@@ -163,6 +166,7 @@ public boolean scrolled(float amountX, float amountY) {
163166

164167
@Override
165168
public void render(float delta) {
169+
// Gdx.app.log(Tools.mouseScreenToWorld(camera).toString(), "");
166170

167171
camera.update();
168172
camera.calculateBounds();
@@ -255,7 +259,16 @@ public void render(float delta) {
255259

256260

257261
if (currentPlacingHardware != null && currentPlacingHardware.type == Constants.placing_object) {
258-
currentPlacingHardware.setPosition(vec2.x, vec2.y);
262+
263+
Vector2 isOutOfBounds = Tools.checkOutOfBounds(currentPlacingHardware.getSpriteBox(), currentPlacingHardware.getPosition());
264+
if(isOutOfBounds != null) {
265+
currentPlacingHardware.setPosition(isOutOfBounds.x, isOutOfBounds.y);
266+
} else {
267+
currentPlacingHardware.setPosition(vec2.x, vec2.y);
268+
}
269+
270+
271+
259272
} else {
260273
if (Constants.placing_object == HardwareType.WIRE || Constants.placing_object == HardwareType.ETHERNET || Constants.placing_object == HardwareType.TUBING || Constants.placing_object == HardwareType.CURVEDCABLE) {
261274
drawPlacing(vec2.x, vec2.y);
@@ -408,6 +421,15 @@ public void show() { }
408421
@Override
409422
public void resize(int width, int height) {
410423
stage.getViewport().update(width, height, true);
424+
// TODO add confirm dialog for resize, tell user to save, go to title screen, come back
425+
// ConfirmDialog.createWindow(
426+
// new Runnable() {
427+
// @Override
428+
// public void run() {
429+
//
430+
// }
431+
// }
432+
// );
411433
}
412434
@Override
413435
public void pause() { }

core/src/main/java/com/amhsrobotics/circuitsim/utility/Tools.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package com.amhsrobotics.circuitsim.utility;
22

3+
import com.amhsrobotics.circuitsim.Constants;
34
import com.badlogic.gdx.Gdx;
45
import com.badlogic.gdx.files.FileHandle;
56
import com.badlogic.gdx.graphics.g2d.BitmapFont;
67
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
78
import com.badlogic.gdx.math.Interpolation;
9+
import com.badlogic.gdx.math.Rectangle;
810
import com.badlogic.gdx.math.Vector2;
911
import com.badlogic.gdx.math.Vector3;
1012
import com.badlogic.gdx.scenes.scene2d.Actor;
@@ -41,6 +43,23 @@ public static boolean collide(Vector2 r1p1, Vector2 r1p2, Vector2 r2p1, Vector2
4143
r1p1.y >= r2p2.y);
4244
}
4345

46+
// returns coordinates to reset to if out of bounds
47+
public static Vector2 checkOutOfBounds(Rectangle spriteBox, Vector2 originPosition) {
48+
if(spriteBox.x <= 0) {
49+
return new Vector2(5 + (float)(spriteBox.width / 2), originPosition.y);
50+
} else if(spriteBox.x + spriteBox.width >= Constants.WORLD_DIM.x) {
51+
return new Vector2(Constants.WORLD_DIM.x - 5 - (float)(spriteBox.width / 2), originPosition.y);
52+
}
53+
54+
if(spriteBox.y <= 0) {
55+
return new Vector2(originPosition.x, 5 + (float)(spriteBox.height / 2));
56+
} else if(spriteBox.y + spriteBox.height >= Constants.WORLD_DIM.y) {
57+
return new Vector2(originPosition.x, Constants.WORLD_DIM.y - 5 - (float)(spriteBox.height / 2));
58+
}
59+
60+
return null;
61+
}
62+
4463
public static void slideIn(Actor actor, String location, float duration, Interpolation interp, int offset, Runnable... runnable) {
4564
Vector2 actorXY = new Vector2(actor.getX(), actor.getY());
4665

lwjgl3/src/main/java/com/amhsrobotics/circuitsim/lwjgl3/Lwjgl3Launcher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ private static Lwjgl3ApplicationConfiguration getDefaultConfiguration() {
1717
Lwjgl3ApplicationConfiguration configuration = new Lwjgl3ApplicationConfiguration();
1818
configuration.setTitle("TKO Circuit Simulator");
1919
configuration.setWindowedMode(1366, 768);
20+
configuration.setResizable(false);
2021
configuration.setWindowIcon("logo.png");
2122
configuration.setBackBufferConfig(8, 8, 8, 8, 16, 0, 3);
2223
return configuration;

0 commit comments

Comments
 (0)