summaryrefslogtreecommitdiff
path: root/NET/worlds/console/WorldButton.java
blob: ddb51b32c1db655cb891b5d3b75a26974cd27242 (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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*     */ package NET.worlds.console;
/*     */ 
/*     */ import NET.worlds.network.NetUpdate;
/*     */ import NET.worlds.scape.TeleportAction;
/*     */ import java.awt.Color;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Event;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.MenuItem;
/*     */ import java.awt.PopupMenu;
/*     */ import java.io.PrintStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ class WorldButton
/*     */   extends TextImageButtons
/*     */ {
/*     */   private static final long serialVersionUID = 8349532719484982330L;
/*     */   int buttonX;
/*     */   int buttonY;
/*     */   String pkg;
/*     */   int privacyLevel;
/*     */   boolean isLoaded;
/*     */   String readableName;
/*     */   DefaultConsole console;
/*  67 */   static String currentPackageName = "";
/*  68 */   private static Font wfont = new Font(Console.message("UniverseFont"), 
/*  69 */     0, 10);
/*     */   
/*     */ 
/*  72 */   private static final int[] xText = new int[1];
/*     */   
/*     */ 
/*     */ 
/*     */   PopupMenu lastPackageMenu;
/*     */   
/*     */ 
/*     */ 
/*     */   public WorldButton(boolean isLoaded, int buttonX, int buttonY, int buttonWidth, int buttonHeight, String[] texts, String pkg, int privacy, DefaultConsole console, ImageButtonsCallback handler)
/*     */   {
/*  82 */     super(null, buttonWidth, intToInts(buttonHeight), xText, texts, handler, wfont);
/*     */     
/*  84 */     this.readableName = texts[0];
/*  85 */     this.buttonX = buttonX;
/*  86 */     this.buttonY = buttonY;
/*  87 */     this.pkg = pkg;
/*  88 */     this.isLoaded = isLoaded;
/*  89 */     this.privacyLevel = privacy;
/*  90 */     this.console = console;
/*     */     
/*  92 */     setSize(buttonWidth, buttonHeight);
/*  93 */     setWidth(buttonWidth);
/*  94 */     setHeight(buttonHeight);
/*     */   }
/*     */   
/*     */   public static Dimension measure(String text) {
/*  98 */     return TextImageButtons.measure(text, wfont);
/*     */   }
/*     */   
/*     */ 
/*     */   public void doAction()
/*     */   {
/* 104 */     if ((this.console == null) || (!showPackageMenu())) {
/* 105 */       NetUpdate.loadWorld(this.pkg, true);
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public boolean showPackageMenu()
/*     */   {
/* 119 */     if (this.lastPackageMenu != null) {
/* 120 */       remove(this.lastPackageMenu);
/* 121 */       this.lastPackageMenu = null;
/*     */     }
/* 123 */     this.lastPackageMenu = WorldsMarkPart.getPackageMenu(this.pkg);
/*     */     
/* 125 */     if ((this.lastPackageMenu == null) || (this.lastPackageMenu.getItemCount() == 0)) {
/* 126 */       return false;
/*     */     }
/*     */     
/*     */ 
/* 130 */     MenuItem first = this.lastPackageMenu.getItem(0);
/* 131 */     if ((first instanceof BookmarkMenuItem)) {
/* 132 */       BookmarkMenuItem title = new BookmarkMenuItem(this.readableName + 
/* 133 */         " World:", ((BookmarkMenuItem)first).getTarget());
/*     */       
/* 135 */       this.lastPackageMenu.insert(title, 0);
/* 136 */       this.lastPackageMenu.insertSeparator(1);
/*     */     }
/*     */     
/* 139 */     add(this.lastPackageMenu);
/*     */     try {
/* 141 */       this.lastPackageMenu.show(this, -15, -7);
/*     */     }
/*     */     catch (RuntimeException e) {
/* 144 */       System.out.println("Warning - could not show teleport location menu.");
/*     */     }
/* 146 */     return true;
/*     */   }
/*     */   
/*     */   public void update(Graphics g)
/*     */   {
/* 151 */     paint(g);
/*     */   }
/*     */   
/*     */   @Deprecated
/*     */   public boolean action(Event event, Object what)
/*     */   {
/* 157 */     Object target = event.target;
/*     */     
/* 159 */     if ((target instanceof BookmarkMenuItem)) {
/* 160 */       TeleportAction.teleport(((BookmarkMenuItem)target).getTarget(), 
/* 161 */         null);
/* 162 */       this.console.toggleUniverseMode();
/*     */     } else {
/* 164 */       return super.action(event, what);
/*     */     }
/* 166 */     return true;
/*     */   }
/*     */   
/*     */   protected Graphics drawButton(Graphics g, int button, int state)
/*     */   {
/*     */     Color c;
/*     */     Color c;
/* 173 */     if (state == 1) { Color c;
/* 174 */       if (this.isLoaded) {
/* 175 */         c = currentPackageName.equalsIgnoreCase(this.pkg) ? new Color(192, 
/* 176 */           255, 192) : Color.white;
/*     */       } else
/* 178 */         c = Color.red; } else { Color c;
/* 179 */       if (state == 2) {
/* 180 */         c = new Color(255, 192, 192);
/*     */       } else
/* 182 */         c = Color.green;
/*     */     }
/* 184 */     g = super.drawButton(g, button, state, c);
/*     */     
/* 186 */     return g;
/*     */   }
/*     */ }


/* Location:              C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\WorldButton.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */