summaryrefslogtreecommitdiff
path: root/NET/worlds/console/SnapTool.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/console/SnapTool.java
downloadworlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz
worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/console/SnapTool.java')
-rw-r--r--NET/worlds/console/SnapTool.java127
1 files changed, 127 insertions, 0 deletions
diff --git a/NET/worlds/console/SnapTool.java b/NET/worlds/console/SnapTool.java
new file mode 100644
index 0000000..028f6a5
--- /dev/null
+++ b/NET/worlds/console/SnapTool.java
@@ -0,0 +1,127 @@
+/* */ package NET.worlds.console;
+/* */
+/* */ import NET.worlds.core.IniFile;
+/* */ import NET.worlds.scape.Point2;
+/* */ import NET.worlds.scape.Point3Temp;
+/* */ import java.io.PrintStream;
+/* */
+/* */
+/* */
+/* */
+/* */ public class SnapTool
+/* */ {
+/* 13 */ private static SnapTool theSnapTool = null;
+/* */
+/* 15 */ private int snapX = 1;
+/* 16 */ private int snapY = 1;
+/* 17 */ private int snapZ = 1;
+/* */
+/* 19 */ private boolean useSnap = false;
+/* */
+/* */ public static SnapTool snapTool() {
+/* 22 */ if (theSnapTool == null) {
+/* 23 */ theSnapTool = new SnapTool();
+/* */ }
+/* 25 */ return theSnapTool;
+/* */ }
+/* */
+/* */ private SnapTool() {
+/* 29 */ this.snapX = IniFile.gamma().getIniInt("Shaper.snapX", 100);
+/* 30 */ this.snapY = IniFile.gamma().getIniInt("Shaper.snapY", 100);
+/* 31 */ this.snapZ = IniFile.gamma().getIniInt("Shaper.snapZ", 1);
+/* 32 */ this.useSnap = (IniFile.gamma().getIniInt("Shaper.useSnapTool", 0) != 0);
+/* */ }
+/* */
+/* */ public Point3Temp snapTo(Point3Temp inVal) {
+/* 36 */ if (!this.useSnap) {
+/* 37 */ return inVal;
+/* */ }
+/* */
+/* 40 */ float newX = snapTo(inVal.x, this.snapX);
+/* 41 */ float newY = snapTo(inVal.y, this.snapY);
+/* 42 */ float newZ = snapTo(inVal.z, this.snapZ);
+/* */
+/* 44 */ return Point3Temp.make(newX, newY, newZ);
+/* */ }
+/* */
+/* */ public Point2 snapTo(Point2 inVal) {
+/* 48 */ if (!this.useSnap) {
+/* 49 */ return inVal;
+/* */ }
+/* 51 */ float newX = snapTo(inVal.x, this.snapX);
+/* 52 */ float newY = snapTo(inVal.y, this.snapY);
+/* */
+/* 54 */ return new Point2(newX, newY);
+/* */ }
+/* */
+/* */ public float snapTo(float oldVal, int snapIncrement) {
+/* 58 */ if (!this.useSnap) {
+/* 59 */ return oldVal;
+/* */ }
+/* 61 */ int multiple = Math.round(oldVal / snapIncrement);
+/* 62 */ return multiple * snapIncrement;
+/* */ }
+/* */
+/* */ public int getSnapX() {
+/* 66 */ return this.snapX;
+/* */ }
+/* */
+/* */ public void setSnapX(int newVal) {
+/* 70 */ if (newVal > 0) {
+/* 71 */ this.snapX = newVal;
+/* 72 */ IniFile.gamma().setIniInt("Shaper.snapX", newVal);
+/* */ }
+/* */ }
+/* */
+/* */ public int getSnapY() {
+/* 77 */ return this.snapY;
+/* */ }
+/* */
+/* */ public void setSnapY(int newVal) {
+/* 81 */ if (newVal > 0) {
+/* 82 */ this.snapY = newVal;
+/* 83 */ IniFile.gamma().setIniInt("Shaper.snapY", newVal);
+/* */ }
+/* */ }
+/* */
+/* */ public int getSnapZ() {
+/* 88 */ return this.snapZ;
+/* */ }
+/* */
+/* */ public void setSnapZ(int newVal) {
+/* 92 */ if (newVal > 0) {
+/* 93 */ this.snapZ = newVal;
+/* 94 */ IniFile.gamma().setIniInt("Shaper.snapZ", newVal);
+/* */ }
+/* */ }
+/* */
+/* */ public boolean useSnap() {
+/* 99 */ return this.useSnap;
+/* */ }
+/* */
+/* */ public void setSnap(boolean use) {
+/* 103 */ this.useSnap = use;
+/* 104 */ IniFile.gamma().setIniInt("Shaper.useSnapTool", use ? 1 : 0);
+/* */ }
+/* */
+/* */ public void print() {
+/* 108 */ System.out.println("SnapTool " + (this.useSnap ? "ON" : "OFF"));
+/* 109 */ System.out.println("SnapTool Settings: X=" + this.snapX + " Y=" + this.snapY +
+/* 110 */ " Z=" + this.snapZ);
+/* */ }
+/* */
+/* */ public void test() {
+/* 114 */ setSnapX(150);
+/* 115 */ setSnapY(200);
+/* 116 */ setSnapY(-100);
+/* 117 */ setSnapY(0);
+/* 118 */ setSnapZ(5);
+/* 119 */ print();
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\SnapTool.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file