summaryrefslogtreecommitdiff
path: root/NET/worlds/console/SnapTool.java
blob: 028f6a588b5aa947b3977ae7804ec62e93b8b4ee (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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
 */