/* */ package NET.worlds.console; /* */ /* */ import NET.worlds.core.IniFile; /* */ import NET.worlds.core.ServerTableManager; /* */ import java.awt.BorderLayout; /* */ import java.awt.Color; /* */ import java.awt.Component; /* */ import java.awt.Event; /* */ import java.awt.GridLayout; /* */ import java.awt.Panel; /* */ import java.awt.Point; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ class ActionDialog /* */ extends PolledDialog /* */ implements ImageButtonsCallback /* */ { /* */ private static final long serialVersionUID = -1190930869038557992L; /* 157 */ BorderLayout overall = new BorderLayout(); /* */ /* */ ActionDialog(Vector inNames) { /* 160 */ super(Console.getFrame(), null, Console.message("Actions"), false); /* */ /* 162 */ String[] hiddenActions = ServerTableManager.instance().getTable( /* 163 */ "hiddenActions"); /* */ /* 165 */ String[] actionAliases = ServerTableManager.instance().getTable( /* 166 */ "actionAliases"); /* */ /* 168 */ if (IniFile.gamma().getIniInt("HideActions", 1) == 0) { /* 169 */ hiddenActions = null; /* */ } /* 171 */ this.names = new Vector(); /* 172 */ for (int i = 0; i < inNames.size(); i++) { /* 173 */ boolean hide = false; /* */ /* 175 */ if (hiddenActions != null) { /* 176 */ String inStr = (String)inNames.elementAt(i); /* 177 */ inStr = inStr.toLowerCase(); /* 178 */ for (int j = 0; j < hiddenActions.length; j++) { /* 179 */ if (inStr.equals(hiddenActions[j])) { /* 180 */ hide = true; /* */ } /* */ } /* */ } /* 184 */ if (!hide) { /* 185 */ String prettyName = (String)inNames.elementAt(i); /* */ /* 187 */ if (actionAliases != null) { /* 188 */ String inStr = prettyName; /* 189 */ inStr = inStr.toLowerCase(); /* 190 */ for (int j = 0; j < actionAliases.length; j += 2) { /* 191 */ if (inStr.equals(actionAliases[j])) { /* 192 */ prettyName = actionAliases[(j + 1)]; /* */ } /* */ } /* */ } /* 196 */ this.names.addElement(upperFirst(prettyName)); /* */ } /* */ } /* */ /* 200 */ setResizable(false); /* 201 */ setAlignment(2); /* 202 */ setLayout(this.overall); /* */ /* 204 */ ready(); /* */ } /* */ /* */ /* 208 */ static Point lastWindowLocation = null; /* */ /* */ /* */ /* */ /* */ /* */ protected boolean done(boolean confirmed) /* */ { /* 216 */ ActionsPart.showDialog = false; /* 217 */ lastWindowLocation = getLocation(); /* 218 */ return super.done(confirmed); /* */ } /* */ /* */ /* */ private static String upperFirst(String text) /* */ { /* 224 */ String ret = text.substring(0, 1).toUpperCase(); /* 225 */ if (text.length() > 1) { /* 226 */ ret = ret + text.substring(1); /* */ } /* */ /* 229 */ ret = ret.replace('_', ' '); /* */ /* 231 */ return ret; /* */ } /* */ /* */ /* 235 */ private Vector hunks = new Vector(); /* */ /* 237 */ private Vector names = new Vector(); /* */ /* */ private static final int buttonsPerHunk = 1; /* */ /* */ private static final int buttonWidth = 72; /* */ /* 243 */ private static final int[] buttonHeights = { 16 }; /* */ /* 245 */ private static final int[] xText = { 22 }; /* */ /* 247 */ private static final String topImageName = IniFile.override().getIniString( /* 248 */ "actionsTopGif", Console.message("actt.gif")); /* 249 */ private static final String buttonImageName = IniFile.override() /* 250 */ .getIniString("actionsButtonGif", "actm.gif"); /* 251 */ private static final String bottomImageName = IniFile.override() /* 252 */ .getIniString("actionsBottomGif", "actb.gif"); /* */ /* */ public synchronized Object imageButtonsCallback(Component who, int which) { /* 255 */ int whichHunk = this.hunks.indexOf(who); /* 256 */ if (whichHunk == -1) { /* 257 */ return null; /* */ } /* 259 */ Console.wake(); /* 260 */ ActionsPart.actionToPerform = whichHunk * 1 + which; /* 261 */ return null; /* */ } /* */ /* */ protected void build() /* */ { /* 266 */ int numHunks = (this.names.size() + 1 - 1) / 1; /* 267 */ int numRows = (numHunks + 1) / 2; /* 268 */ numHunks = numRows * 2; /* */ /* 270 */ Panel hunky = new Panel(new GridLayout(numRows, 2)); /* 271 */ hunky.setBackground(Color.black); /* */ /* 273 */ int nextNameIndex = 0; /* 274 */ for (int i = 0; i < numHunks; i++) /* */ { /* 276 */ String[] strings = new String[1]; /* 277 */ for (int s = 0; s < 1; nextNameIndex++) { /* 278 */ if (nextNameIndex < this.names.size()) { /* 279 */ strings[s] = ((String)this.names.elementAt(nextNameIndex)); /* */ } /* 277 */ s++; /* */ } /* */ /* */ /* 281 */ TextImageButtons hunk = new TextImageButtons(buttonImageName, /* 282 */ 72, buttonHeights, xText, strings, this); /* */ /* 284 */ this.hunks.addElement(hunk); /* 285 */ hunky.add(hunk); /* */ } /* */ /* 288 */ add("North", new ImageCanvas(topImageName)); /* 289 */ add("Center", hunky); /* 290 */ add("South", new ImageCanvas(bottomImageName)); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ protected void initialSize(int width, int height) /* */ { /* 299 */ if (lastWindowLocation == null) { /* 300 */ super.initialSize(width, height); /* */ } else { /* 302 */ setLocation(lastWindowLocation); /* 303 */ setSize(width, height); /* */ } /* */ } /* */ /* */ /* */ @Deprecated /* */ public boolean handleEvent(Event event) /* */ { /* 311 */ if (event.id == 1004) { /* 312 */ Console.getFrame().requestFocus(); /* 313 */ return true; /* */ } /* 315 */ return super.handleEvent(event); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\ActionDialog.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */