summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WearAction.java
blob: a6a28a65c1ee8e7c6c43e7169b543ebfb9e928e6 (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
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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
/*     */ package NET.worlds.scape;
/*     */ 
/*     */ import NET.worlds.console.Console;
/*     */ import NET.worlds.network.URL;
/*     */ import java.io.IOException;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class WearAction
/*     */   extends Action
/*     */ {
/*  31 */   char limb = 'B';
/*     */   
/*     */ 
/*  34 */   String val = "";
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public Persister trigger(Event e, Persister seqID)
/*     */   {
/*  42 */     Object owner = getOwner();
/*  43 */     if (owner != null) {
/*  44 */       setAvLimb(this.limb, this.val);
/*     */     }
/*  46 */     return null;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   public static void setAvLimb(char limb, String v)
/*     */   {
/*  66 */     String str = PosableShape.getCurrentAvCustomizable();
/*     */     
/*  68 */     if (str == null) {
/*  69 */       return;
/*     */     }
/*  71 */     int pos = str.indexOf(".", 7);
/*  72 */     String bodyType = str.substring(7, pos).toLowerCase();
/*     */     
/*     */     int matStart;
/*     */     
/*     */     int matEnd;
/*  77 */     if ((limb == 'H') || (limb == 'E')) {
/*  78 */       int head = str.lastIndexOf("NS");
/*  79 */       if (head < 0) {
/*  80 */         return;
/*     */       }
/*     */       
/*  83 */       if (v == null) {
/*  84 */         v = bodyType;
/*  85 */         if (limb == 'E')
/*     */         {
/*  87 */           limb = 'H';
/*     */           
/*  89 */           if ((head >= 0) && (str.charAt(head + 5) == 'G')) {
/*  90 */             v = PosableShape.readName(str, head + 6).toLowerCase();
/*     */           }
/*     */         }
/*     */       }
/*  94 */       int face = str.lastIndexOf("DgT");
/*  95 */       int faceEnd = -1;
/*  96 */       if (face < head) {
/*  97 */         if (limb == 'E') {
/*  98 */           Console.println(
/*  99 */             "Can't change the face of this type of head.");
/* 100 */           return;
/*     */         }
/*     */         
/* 103 */         face = -1;
/*     */       }
/*     */       else
/*     */       {
/* 107 */         faceEnd = face + 2;
/*     */         int i;
/* 109 */         while ((i = PosableShape.skipMat(str, faceEnd)) != faceEnd) { int i;
/* 110 */           faceEnd = i;
/*     */         }
/*     */       }
/*     */       
/*     */ 
/*     */ 
/* 116 */       URL urlVal = PosableShape.getAvURL(v);
/* 117 */       if (urlVal == null) {
/* 118 */         return;
/*     */       }
/* 120 */       String val = urlVal.getAbsolute();
/* 121 */       if (val == null) {
/* 122 */         return;
/*     */       }
/* 124 */       if (limb == 'H')
/*     */       {
/* 126 */         int newHead = val.lastIndexOf("NS");
/* 127 */         if (newHead < 0) {
/* 128 */           return;
/*     */         }
/* 130 */         String geom = "";
/* 131 */         pos = str.indexOf(".0E", 7);
/* 132 */         if (!v.equalsIgnoreCase(str.substring(7, pos))) {
/* 133 */           geom = "G" + PosableShape.getBodyType(v);
/*     */         }
/* 135 */         int matStart = head + 5;
/* 136 */         int matEnd = str.length();
/* 137 */         v = geom + val.substring(newHead + 5);
/*     */       }
/*     */       else {
/* 140 */         int newFace = val.lastIndexOf("Dg");
/* 141 */         if (newFace < 0) {
/* 142 */           return;
/*     */         }
/*     */         
/*     */ 
/* 146 */         int newEnd = newFace + 2;
/* 147 */         int i; while ((i = PosableShape.skipMat(val, newEnd)) != newEnd) { int i;
/* 148 */           newEnd = i;
/*     */         }
/* 150 */         int matStart = face;
/* 151 */         int matEnd = faceEnd;
/* 152 */         v = val.substring(newFace, newEnd);
/*     */       }
/* 154 */     } else if (limb == 'Q') {
/* 155 */       int sInd = str.lastIndexOf("NS");
/* 156 */       if (sInd < 0) {
/* 157 */         Console.println("Can't customize this avatar.");
/* 158 */         return;
/*     */       }
/* 160 */       int matStart = sInd + 2;
/* 161 */       int matEnd = sInd + 5;
/*     */       
/* 163 */       if (v == null)
/* 164 */         v = "000";
/* 165 */     } else if (limb == 'f')
/*     */     {
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 171 */       int face = str.lastIndexOf("Dg");
/* 172 */       if (face > 0)
/*     */       {
/*     */ 
/* 175 */         int end = face + 2;
/* 176 */         int i; while ((i = PosableShape.skipMat(str, end)) != end) { int i;
/* 177 */           end = i;
/*     */         }
/*     */         
/* 180 */         int len = str.length() - 4;
/*     */         
/* 182 */         String val = "";
/*     */         
/* 184 */         while (i < len)
/*     */         {
/* 186 */           char c = str.charAt(i);
/* 187 */           if (c == 'Q')
/*     */           {
/* 189 */             val = val + c;
/* 190 */             i++;
/*     */ 
/*     */           }
/* 193 */           else if ((c >= '0') && (c <= '9'))
/*     */           {
/* 195 */             val = val + c;
/* 196 */             i++;
/*     */ 
/*     */           }
/*     */           else
/*     */           {
/* 201 */             int j = PosableShape.skipMat(str, i);
/* 202 */             if (i != j)
/*     */             {
/* 204 */               val = val + "f";
/* 205 */               i = j;
/*     */             }
/*     */             else
/*     */             {
/* 209 */               i++;
/*     */             }
/*     */           }
/*     */         }
/*     */         
/*     */ 
/*     */ 
/* 216 */         if (v == null)
/*     */         {
/* 218 */           URL origURL = PosableShape.getAvURL(bodyType);
/* 219 */           String origStr = "";
/* 220 */           if (origURL != null)
/*     */           {
/* 222 */             origStr = origURL.getInternal();
/*     */           }
/* 224 */           int origFace = origStr.lastIndexOf("Dg");
/*     */           
/* 226 */           if (origFace > 0)
/*     */           {
/*     */ 
/* 229 */             int origEnd = origFace + 2;
/* 230 */             int k; while ((k = PosableShape.skipMat(origStr, 
/* 231 */               origEnd)) != origEnd) { int k;
/* 232 */               origEnd = k; }
/* 233 */             str = 
/* 234 */               str.substring(0, end) + origStr.substring(origEnd);
/*     */           }
/*     */         }
/*     */         else
/*     */         {
/* 239 */           str = str.substring(0, end) + val + ".rwg";
/*     */         }
/*     */       }
/*     */       
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 248 */       int matStart = PosableShape.getMatPosition(str, limb);
/* 249 */       if (matStart < 0)
/* 250 */         return;
/* 251 */       int matEnd = PosableShape.skipMat(str, matStart);
/*     */       
/* 253 */       if (v == null)
/*     */       {
/* 255 */         URL origURL = PosableShape.getAvURL(bodyType);
/*     */         
/* 257 */         if (origURL == null) {
/* 258 */           return;
/*     */         }
/* 260 */         String origStr = origURL.getInternal();
/* 261 */         int origMat = PosableShape.getMatPosition(origStr, limb);
/*     */         
/*     */ 
/* 264 */         if (origMat < 0) {
/* 265 */           return;
/*     */         }
/* 267 */         int origMatEnd = PosableShape.skipMat(origStr, origMat);
/*     */         
/* 269 */         v = origStr.substring(origMat, origMatEnd);
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/* 274 */       matStart = PosableShape.getMatPosition(str, limb);
/* 275 */       if (matStart < 0)
/* 276 */         return;
/* 277 */       matEnd = PosableShape.skipMat(str, matStart);
/*     */       
/* 279 */       if (v == null)
/*     */       {
/* 281 */         URL origURL = PosableShape.getAvURL(bodyType);
/* 282 */         if (origURL == null)
/*     */         {
/* 284 */           return;
/*     */         }
/*     */         
/* 287 */         String origStr = origURL.getInternal();
/* 288 */         int origMat = PosableShape.getMatPosition(origStr, limb);
/*     */         
/*     */ 
/* 291 */         if (origMat < 0) {
/* 292 */           return;
/*     */         }
/* 294 */         int origMatEnd = PosableShape.skipMat(origStr, origMat);
/*     */         
/* 296 */         v = origStr.substring(origMat, origMatEnd);
/*     */       }
/*     */     }
/*     */     
/* 300 */     Console co = Console.getActive();
/* 301 */     if (co != null)
/* 302 */       co.setAvatar(URL.make(str.substring(0, matStart) + 
/* 303 */         v + str.substring(matEnd)));
/*     */   }
/*     */   
/*     */   public static String makeMatString(int r, int g, int b) {
/* 307 */     StringBuffer sb = new StringBuffer("C");
/* 308 */     sb.append(toBase64(r));
/* 309 */     sb.append(toBase64(g));
/* 310 */     sb.append(toBase64(b));
/* 311 */     return sb.toString();
/*     */   }
/*     */   
/*     */   public static char toBase64(int i) {
/* 315 */     return PosableShape.base64.charAt(i);
/*     */   }
/*     */   
/* 318 */   private static String allowedLimbChars = "PBLMORUVIJKXYZabcdefHQE";
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public Object properties(int index, int offset, int mode, Object value)
/*     */     throws NoSuchPropertyException
/*     */   {
/* 326 */     Object ret = null;
/* 327 */     switch (index - offset) {
/*     */     case 0: 
/* 329 */       if (mode == 0) {
/* 330 */         ret = StringPropertyEditor.make(
/* 331 */           new Property(this, index, "Limb"));
/* 332 */       } else if (mode == 1) {
/* 333 */         ret = new String(this.limb);
/* 334 */       } else if (mode == 2) {
/* 335 */         String s = (String)value;
/* 336 */         if ((s.length() != 1) || 
/* 337 */           (allowedLimbChars.indexOf(s.charAt(0)) < 0)) {
/* 338 */           Console.println("Limb must one of " + allowedLimbChars);
/*     */         } else {
/* 340 */           this.limb = s.charAt(0);
/* 341 */           this.val = null;
/*     */         }
/*     */       }
/*     */       
/* 345 */       break;
/*     */     case 1: 
/* 347 */       if (mode == 0) {
/* 348 */         ret = StringPropertyEditor.make(
/* 349 */           new Property(this, index, "Value").allowSetNull());
/* 350 */       } else if (mode == 1) {
/* 351 */         ret = this.val;
/* 352 */       } else if (mode == 2) {
/* 353 */         String v = (String)value;
/* 354 */         if (v != null)
/*     */         {
/* 356 */           if ((this.limb == 'H') || (this.limb == 'E'))
/*     */           {
/* 358 */             if (PosableShape.readName(v, 0).length() != v.length()) {
/* 359 */               Console.println("Head and face must be set to  all-lowercase name of body type.");
/*     */               
/* 361 */               return ret;
/*     */             }
/* 363 */           } else if (this.limb == 'Q')
/*     */           {
/* 365 */             if (v.length() != 3) {
/* 366 */               Console.println(
/* 367 */                 "Head size must be three letters, usually all the same.");
/* 368 */               return ret;
/*     */             }
/*     */             
/* 371 */             for (int i = 0; i < 3; i++) {
/* 372 */               char c = v.charAt(i);
/* 373 */               if ((c != '0') && ((c < 'a') || (c > 'z')) && (
/* 374 */                 (c < 'A') || (c > 'Z')))
/*     */               {
/* 376 */                 Console.println(
/* 377 */                   "Head size letters must each be one of z-a9A-Z.");
/* 378 */                 return ret;
/*     */               }
/*     */             }
/*     */           }
/* 382 */           else if (v.length() < 1) {
/* 383 */             v = null;
/* 384 */           } else if ((v.charAt(0) != 'C') && 
/* 385 */             (v.charAt(0) != 'T'))
/*     */           {
/* 387 */             Console.println(
/* 388 */               "Material must be C_X, CXYZ, or Ttexname.");
/* 389 */             return ret;
/*     */           }
/*     */         }
/*     */         
/* 393 */         this.val = v;
/*     */       }
/* 395 */       break;
/*     */     default: 
/* 397 */       ret = super.properties(index, offset + 2, mode, value);
/*     */     }
/* 399 */     return ret;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/* 405 */   private static Object classCookie = new Object();
/*     */   
/*     */   public void saveState(Saver s) throws IOException
/*     */   {
/* 409 */     s.saveVersion(1, classCookie);
/* 410 */     super.saveState(s);
/* 411 */     s.saveString(this.val);
/* 412 */     s.saveString(this.limb);
/*     */   }
/*     */   
/*     */   public void restoreState(Restorer r) throws IOException, TooNewException
/*     */   {
/* 417 */     switch (r.restoreVersion(classCookie)) {
/*     */     case 0: 
/* 419 */       super.restoreState(r);
/*     */       
/* 421 */       int red = r.restoreInt();
/* 422 */       int green = r.restoreInt();
/* 423 */       int blue = r.restoreInt();
/* 424 */       String v = r.restoreString();
/*     */       
/* 426 */       if (v == null) {
/* 427 */         this.val = makeMatString(red, green, blue); } else { char c;
/* 428 */         if ((v.length() == 1) && ((c = v.charAt(0)) >= 'A') && (c <= 'Z')) {
/* 429 */           this.val = ("C_" + v);
/*     */         } else
/* 431 */           this.val = ("T" + v);
/*     */       }
/* 433 */       this.limb = r.restoreString().charAt(0);
/* 434 */       break;
/*     */     case 1: 
/* 436 */       super.restoreState(r);
/* 437 */       this.val = r.restoreString();
/* 438 */       this.limb = r.restoreString().charAt(0);
/* 439 */       break;
/*     */     default: 
/* 441 */       throw new TooNewException();
/*     */     }
/*     */   }
/*     */ }


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