summaryrefslogtreecommitdiff
path: root/NET/worlds/console/SnapTool.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/SnapTool.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/console/SnapTool.java')
-rw-r--r--NET/worlds/console/SnapTool.java114
1 files changed, 114 insertions, 0 deletions
diff --git a/NET/worlds/console/SnapTool.java b/NET/worlds/console/SnapTool.java
new file mode 100644
index 0000000..0a6af6b
--- /dev/null
+++ b/NET/worlds/console/SnapTool.java
@@ -0,0 +1,114 @@
+package NET.worlds.console;
+
+import NET.worlds.core.IniFile;
+import NET.worlds.scape.Point2;
+import NET.worlds.scape.Point3Temp;
+
+public class SnapTool {
+ private static SnapTool theSnapTool = null;
+ private int snapX = 1;
+ private int snapY = 1;
+ private int snapZ = 1;
+ private boolean useSnap = false;
+
+ public static SnapTool snapTool() {
+ if (theSnapTool == null) {
+ theSnapTool = new SnapTool();
+ }
+
+ return theSnapTool;
+ }
+
+ private SnapTool() {
+ this.snapX = IniFile.gamma().getIniInt("Shaper.snapX", 100);
+ this.snapY = IniFile.gamma().getIniInt("Shaper.snapY", 100);
+ this.snapZ = IniFile.gamma().getIniInt("Shaper.snapZ", 1);
+ this.useSnap = IniFile.gamma().getIniInt("Shaper.useSnapTool", 0) != 0;
+ }
+
+ public Point3Temp snapTo(Point3Temp inVal) {
+ if (!this.useSnap) {
+ return inVal;
+ } else {
+ float newX = this.snapTo(inVal.x, this.snapX);
+ float newY = this.snapTo(inVal.y, this.snapY);
+ float newZ = this.snapTo(inVal.z, this.snapZ);
+ return Point3Temp.make(newX, newY, newZ);
+ }
+ }
+
+ public Point2 snapTo(Point2 inVal) {
+ if (!this.useSnap) {
+ return inVal;
+ } else {
+ float newX = this.snapTo(inVal.x, this.snapX);
+ float newY = this.snapTo(inVal.y, this.snapY);
+ return new Point2(newX, newY);
+ }
+ }
+
+ public float snapTo(float oldVal, int snapIncrement) {
+ if (!this.useSnap) {
+ return oldVal;
+ } else {
+ int multiple = Math.round(oldVal / snapIncrement);
+ return multiple * snapIncrement;
+ }
+ }
+
+ public int getSnapX() {
+ return this.snapX;
+ }
+
+ public void setSnapX(int newVal) {
+ if (newVal > 0) {
+ this.snapX = newVal;
+ IniFile.gamma().setIniInt("Shaper.snapX", newVal);
+ }
+ }
+
+ public int getSnapY() {
+ return this.snapY;
+ }
+
+ public void setSnapY(int newVal) {
+ if (newVal > 0) {
+ this.snapY = newVal;
+ IniFile.gamma().setIniInt("Shaper.snapY", newVal);
+ }
+ }
+
+ public int getSnapZ() {
+ return this.snapZ;
+ }
+
+ public void setSnapZ(int newVal) {
+ if (newVal > 0) {
+ this.snapZ = newVal;
+ IniFile.gamma().setIniInt("Shaper.snapZ", newVal);
+ }
+ }
+
+ public boolean useSnap() {
+ return this.useSnap;
+ }
+
+ public void setSnap(boolean use) {
+ this.useSnap = use;
+ IniFile.gamma().setIniInt("Shaper.useSnapTool", use ? 1 : 0);
+ }
+
+ public void print() {
+ System.out.println("SnapTool " + (this.useSnap ? "ON" : "OFF"));
+ System.out.println("SnapTool Settings: X=" + this.snapX + " Y=" + this.snapY + " Z=" + this.snapZ);
+ }
+
+ public void test() {
+ this.setSnapX(150);
+ this.setSnapY(200);
+ this.setSnapY(-100);
+ this.setSnapY(0);
+ this.setSnapZ(5);
+ this.print();
+ }
+}