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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
/* */ package NET.worlds.console;
/* */
/* */ import NET.worlds.network.URL;
/* */ import NET.worlds.scape.BGLoaded;
/* */ import NET.worlds.scape.BackgroundLoader;
/* */ import NET.worlds.scape.FrameEvent;
/* */ import NET.worlds.scape.Pilot;
/* */ import NET.worlds.scape.Room;
/* */ import NET.worlds.scape.SendURLAction;
/* */ import NET.worlds.scape.TeleportAction;
/* */ import NET.worlds.scape.World;
/* */ import java.awt.Component;
/* */ import java.awt.Container;
/* */ import java.awt.Dimension;
/* */ import java.awt.Event;
/* */ import java.awt.Graphics;
/* */ import java.awt.Image;
/* */ import java.awt.Rectangle;
/* */ import java.io.DataInputStream;
/* */ import java.io.FileInputStream;
/* */ import java.io.IOException;
/* */ import java.util.StringTokenizer;
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */
/* */ public class MapPart
/* */ extends ImageButtons
/* */ implements FramePart, ImageButtonsCallback, BGLoaded
/* */ {
/* */ private static final long serialVersionUID = 1886153221201046188L;
/* */ private static final int width = 158;
/* */ private static final int height = 124;
/* */ private URL lastURL;
/* */ private URL mapURL;
/* */ private URL infURL;
/* */ private int filesLoaded;
/* */ private Rectangle[] hotspots;
/* */ private String[] names;
/* */ private String[] locations;
/* */ private int cursedButton;
/* */ private DefaultConsole console;
/* */
/* */ public MapPart()
/* */ {
/* 83 */ setHandler(this);
/* 84 */ setBackground(true);
/* 85 */ setWidth(158);
/* 86 */ setHeight(124);
/* */ }
/* */
/* */ private synchronized void changeURL(URL url) {
/* 90 */ this.lastURL = url;
/* 91 */ String path = url.getAbsolute();
/* 92 */ path = path.substring(0, path.lastIndexOf('.'));
/* 93 */ this.filesLoaded = 0;
/* 94 */ setHotspots(new Rectangle[0]);
/* 95 */ this.console.exploreButton.setVisible(true);
/* 96 */ this.console.relayoutMap();
/* 97 */ this.locations = null;
/* 98 */ repaint();
/* 99 */ BackgroundLoader.get(this, this.mapURL = URL.make(path + "-map.gif"), true);
/* 100 */ BackgroundLoader.get(this, this.infURL = URL.make(path + "-map.inf"), true);
/* */ }
/* */
/* */ private boolean readInfo(String localName) {
/* 104 */ DataInputStream in = null;
/* */ try {
/* 106 */ in = new DataInputStream(new FileInputStream(localName));
/* */
/* 108 */ int item = -1;
/* 109 */ String line; while ((line = in.readLine()) != null) {
/* 110 */ String line = line.trim();
/* 111 */ if (item == -1) {
/* 112 */ int count = Integer.parseInt(line);
/* 113 */ this.hotspots = new Rectangle[count];
/* 114 */ this.names = new String[count];
/* 115 */ this.locations = new String[count];
/* */ } else {
/* 117 */ StringTokenizer tok = new StringTokenizer(line);
/* 118 */ this.hotspots[item] = new Rectangle(Integer.parseInt(tok
/* 119 */ .nextToken()), Integer.parseInt(tok.nextToken()),
/* 120 */ Integer.parseInt(tok.nextToken()),
/* 121 */ Integer.parseInt(tok.nextToken()));
/* 122 */ this.names[item] = tok.nextToken().replace('_', ' ');
/* 123 */ this.locations[item] = tok.nextToken();
/* 124 */ for (; tok.hasMoreTokens();
/* 125 */ tmp167_162[tmp167_165] = (tmp167_162[tmp167_165] + " " + tok.nextToken())) {}
/* */ }
/* 127 */ item++;
/* */ }
/* 129 */ return true;
/* */ }
/* */ catch (Exception localException) {}finally {
/* */ try {
/* 133 */ if (in != null) {
/* 134 */ in.close();
/* */ }
/* */ } catch (IOException localIOException2) {}
/* */ }
/* 138 */ return false;
/* */ }
/* */
/* */ private int hasLink(String name)
/* */ {
/* 143 */ if (this.locations != null) {
/* 144 */ for (int i = 0; i < this.locations.length; i++)
/* 145 */ if (name.equals(this.locations[i]))
/* 146 */ return i;
/* */ }
/* 148 */ return -1;
/* */ }
/* */
/* */
/* */
/* */ public synchronized void paint(Graphics g)
/* */ {
/* 155 */ if (this.filesLoaded == 2) {
/* 156 */ super.paint(g);
/* */ }
/* */ }
/* */
/* */ @Deprecated
/* */ public synchronized boolean handleEvent(Event event)
/* */ {
/* 163 */ return super.handleEvent(event);
/* */ }
/* */
/* */ public Dimension getPreferredSize()
/* */ {
/* 168 */ return new Dimension(158, 124);
/* */ }
/* */
/* */
/* */
/* */ protected Graphics drawButton(Graphics g, int button, int state)
/* */ {
/* 175 */ Graphics ret = super.drawButton(g, button, state);
/* 176 */ if ((state == 2) || (state == 3)) {
/* 177 */ this.cursedButton = button;
/* 178 */ if ((button != -1) && (this.console != null))
/* 179 */ this.console.overrideStatusMsg(this.names[button]);
/* 180 */ } else if ((state == 1) && (button == this.cursedButton)) {
/* 181 */ this.cursedButton = -1;
/* 182 */ if (this.console != null)
/* 183 */ this.console.overrideStatusMsg(null);
/* */ }
/* 185 */ return ret;
/* */ }
/* */
/* */
/* */ public synchronized Object imageButtonsCallback(Component who, int which)
/* */ {
/* 191 */ String loc = this.locations[which];
/* 192 */ if (loc.startsWith("pnm:")) {
/* 193 */ new SendURLAction(loc).startBrowser();
/* 194 */ return null; }
/* 195 */ if (loc.equals("system:universe")) {
/* 196 */ this.console.toggleUniverseMode();
/* 197 */ return null; }
/* 198 */ if (loc.charAt(0) == '-') {
/* 199 */ loc = loc.substring(1);
/* */ } else
/* 201 */ loc = this.lastURL.getAbsolute() + "#" + loc;
/* 202 */ TeleportAction.teleport(loc, null);
/* 203 */ return null;
/* */ }
/* */
/* */
/* */
/* */ public void activate(Console c, Container f, Console prev)
/* */ {
/* 210 */ this.console = ((DefaultConsole)c);
/* */ }
/* */
/* */
/* */ public void deactivate() {}
/* */
/* */
/* */ public synchronized boolean handle(FrameEvent f)
/* */ {
/* 219 */ Pilot pilot = Pilot.getActive();
/* 220 */ if (pilot != null) {
/* 221 */ World world = pilot.getWorld();
/* 222 */ if (world != null) {
/* 223 */ URL sourceURL = world.getSourceURL();
/* 224 */ if ((sourceURL != this.lastURL) && (sourceURL != null))
/* 225 */ changeURL(sourceURL);
/* */ }
/* */ }
/* 228 */ return true;
/* */ }
/* */
/* */
/* */
/* */ public Object asyncBackgroundLoad(String localName, URL remoteURL)
/* */ {
/* 235 */ boolean success = false;
/* 236 */ if (localName != null) {
/* 237 */ if (remoteURL == this.mapURL) {
/* 238 */ this.image_ = loadImage(URL.make(localName), this);
/* 239 */ success = this.image_ != null;
/* 240 */ if (success) {
/* 241 */ setWidth(this.image_.getWidth(null) / 4);
/* 242 */ setHeight(this.image_.getHeight(null));
/* */ }
/* */ } else {
/* 245 */ success = readInfo(localName);
/* */
/* */ int link;
/* 248 */ if ((link = hasLink("system:universe")) >= 0) {
/* 249 */ this.console.exploreButton.setVisible(false);
/* 250 */ this.console.relayoutMap();
/* */ }
/* */ }
/* */ }
/* 254 */ if (success) {
/* 255 */ synchronized (this) {
/* 256 */ if (++this.filesLoaded == 2) {
/* 257 */ setHotspots(this.hotspots);
/* 258 */ repaint();
/* */ }
/* */ }
/* */ }
/* 262 */ return null;
/* */ }
/* */
/* */ public boolean syncBackgroundLoad(Object obj, URL remoteURL)
/* */ {
/* 267 */ return false;
/* */ }
/* */
/* */ public Room getBackgroundLoadRoom()
/* */ {
/* 272 */ return null;
/* */ }
/* */ }
/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\MapPart.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/
|