/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.OkCancelDialog; /* */ import NET.worlds.console.PolledDialog; /* */ import NET.worlds.core.ServerTableManager; /* */ import NET.worlds.network.URL; /* */ import java.io.IOException; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class SelectAvatarAction /* */ extends DialogAction /* */ { /* 47 */ URL url = null; /* */ /* */ /* */ /* */ String description; /* */ /* */ /* */ /* */ /* */ private URL getURLVal() /* */ { /* 58 */ URL val = this.url; /* 59 */ if (val == null) { /* 60 */ SuperRoot o = getOwner(); /* 61 */ if ((o instanceof Drone)) { /* 62 */ val = ((Drone)o).getSourceURL(); /* 63 */ } else if ((o instanceof PosableShape)) { /* 64 */ val = ((Shape)o).getURL(); /* 65 */ } else if ((o instanceof Hologram)) /* 66 */ val = ((Hologram)o).getMovieName(); /* */ } /* 68 */ return val; /* */ } /* */ /* */ public void doIt() { /* 72 */ Console console = Console.getActive(); /* 73 */ URL val = getURLVal(); /* 74 */ if ((console != null) && (val != null)) /* 75 */ console.setAvatar(val); /* */ } /* */ /* */ public PolledDialog getDialog() { /* 79 */ URL val = getURLVal(); /* */ /* 81 */ if ((!Console.getActive().getVIP()) && /* 82 */ (val.getInternal().toLowerCase().endsWith(".rwg"))) /* */ { /* 84 */ return new OkCancelDialog(Console.getFrame(), this, /* 85 */ Console.message("Cant-change-AV"), Console.message("OK"), /* 86 */ null, Console.message("Only-VIPs-change"), /* 87 */ false); /* */ } /* 89 */ String desc = this.description; /* */ /* 91 */ if ((desc == null) || (desc.length() == 0)) { /* 92 */ desc = getPrettyAvatarName(val.getBase()); /* */ } /* 94 */ return new ChangeAvatarDialog(Console.getFrame(), this, desc); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 105 */ static String[] avatarAliases = ServerTableManager.instance().getTable("avatarAliases"); /* */ /* */ public static String getPrettyAvatarName(String name) /* */ { /* 109 */ int extIndex = name.indexOf('.'); /* */ /* 111 */ if (extIndex >= 0) { /* 112 */ name = name.substring(0, extIndex).toLowerCase(); /* */ } else { /* 114 */ name = name.toLowerCase(); /* */ } /* */ /* 117 */ for (int i = 0; i < avatarAliases.length; i += 2) /* */ { /* 119 */ if (avatarAliases[i].equals(name)) { /* 120 */ return avatarAliases[(i + 1)]; /* */ } /* */ } /* 123 */ String properName = name.substring(0, 1).toUpperCase(); /* 124 */ if (name.length() > 1) { /* 125 */ properName = properName + name.substring(1); /* */ } /* 127 */ return properName; /* */ } /* */ /* */ public Persister trigger(Event e, Persister seqID) /* */ { /* 132 */ URL val = getURLVal(); /* */ /* 134 */ if (val == null) { /* 135 */ return null; /* */ } /* 137 */ return super.trigger(e, seqID); /* */ } /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 145 */ Object ret = null; /* 146 */ switch (index - offset) { /* */ case 0: /* 148 */ if (mode == 0) { /* 149 */ ret = URLPropertyEditor.make( /* 150 */ new Property(this, index, "Avatar URL").allowSetNull(), /* 151 */ "pilot;drone;rwx;rwg;mov"); /* */ } /* 153 */ else if (mode == 1) { /* 154 */ ret = this.url; /* 155 */ } else if (mode == 2) /* 156 */ this.url = ((URL)value); /* 157 */ break; /* */ default: /* 159 */ ret = super.properties(index, offset + 1, mode, value); /* */ } /* 161 */ return ret; /* */ } /* */ /* */ public String toString() { /* 165 */ return /* 166 */ super.toString() + "[url " + (this.url == null ? "null" : new StringBuilder(String.valueOf(this.url.getRelativeTo(this))).append("]").toString()); /* */ } /* */ /* */ /* 170 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 174 */ s.saveVersion(4, classCookie); /* 175 */ super.saveState(s); /* */ /* 177 */ URL.save(s, this.url); /* 178 */ s.saveString(this.description); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 183 */ int ver = r.restoreVersion(classCookie); /* 184 */ switch (ver) { /* */ case 3: /* */ case 4: /* 187 */ super.restoreState(r); /* 188 */ this.url = URL.restore(r, ".world"); /* 189 */ if (ver >= 4) /* 190 */ this.description = r.restoreString(); /* 191 */ break; /* */ /* */ case 2: /* 194 */ dialogActionSkipRestore(r); /* 195 */ this.url = URL.restore(r, ".world"); /* 196 */ this.showDialog = r.restoreBoolean(); /* 197 */ this.cancelOnly = r.restoreBoolean(); /* 198 */ break; /* */ /* */ case 1: /* 201 */ r.setOldFlag(); /* 202 */ dialogActionSkipRestore(r); /* 203 */ this.url = URL.restore(r, ".world"); /* 204 */ this.showDialog = r.restoreBoolean(); /* 205 */ break; /* */ /* */ case 0: /* 208 */ r.setOldFlag(); /* 209 */ dialogActionSkipRestore(r); /* 210 */ this.url = URL.restore(r, ".world"); /* 211 */ break; /* */ /* */ default: /* 214 */ throw new TooNewException(); /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\SelectAvatarAction.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */