diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/network/UpgradeDialog.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/network/UpgradeDialog.java')
| -rw-r--r-- | NET/worlds/network/UpgradeDialog.java | 462 |
1 files changed, 462 insertions, 0 deletions
diff --git a/NET/worlds/network/UpgradeDialog.java b/NET/worlds/network/UpgradeDialog.java new file mode 100644 index 0000000..76a99a6 --- /dev/null +++ b/NET/worlds/network/UpgradeDialog.java @@ -0,0 +1,462 @@ +/* */ package NET.worlds.network; +/* */ +/* */ import NET.worlds.console.Console; +/* */ import NET.worlds.console.MultiLineLabel; +/* */ import NET.worlds.console.PolledDialog; +/* */ import NET.worlds.core.IniFile; +/* */ import java.awt.Button; +/* */ import java.awt.Checkbox; +/* */ import java.awt.Component; +/* */ import java.awt.Event; +/* */ import java.awt.GridBagConstraints; +/* */ import java.awt.GridBagLayout; +/* */ import java.awt.GridLayout; +/* */ import java.awt.Insets; +/* */ import java.awt.Panel; +/* */ import java.awt.ScrollPane; +/* */ import java.text.MessageFormat; +/* */ import java.text.NumberFormat; +/* */ import java.util.Locale; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class UpgradeDialog +/* */ extends PolledDialog +/* */ { +/* */ private static final long serialVersionUID = -6015193016188781866L; +/* 78 */ private Button yesButton = new Button(Console.message("Yes-now")); +/* */ +/* */ +/* 81 */ private Button noButton = new Button(Console.message("No-later")); +/* */ +/* */ +/* 84 */ private Button moreInfo = new Button(Console.message("Show-me-more")); +/* */ +/* */ private Checkbox startupCheck; +/* */ +/* 88 */ private boolean forceUpgrades = IniFile.gamma().getIniInt("forceUpgrades", +/* 89 */ 1) == 1; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 109 */ private static String instructions = Console.message("Please-uncheck") + +/* 110 */ " \n" + " \n"; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 119 */ private static String forcedInstructions = Console.message("you-can-continue") + " \n" + " \n"; +/* */ +/* */ +/* 122 */ private static String title = Console.message("Upgrade"); +/* */ +/* */ private Vector<Checkbox> checkboxes; +/* */ +/* */ private String info; +/* */ +/* */ private Vector<String> list; +/* */ +/* */ private Vector<Integer> bytes; +/* */ +/* */ private boolean first; +/* */ +/* */ private boolean chooseOne; +/* */ +/* */ private String name; +/* */ +/* */ private Component getsFocus; +/* */ +/* */ private MultiLineLabel msgLabel; +/* */ +/* */ +/* */ public UpgradeDialog(Vector<String> list, Vector<Integer> bytes, boolean first, String name, String info, boolean chooseOne) +/* */ { +/* 145 */ super(Console.getFrame(), null, title, false); +/* 146 */ setAlignment(1); +/* 147 */ this.list = list; +/* 148 */ this.info = info; +/* 149 */ this.name = name; +/* 150 */ this.first = first; +/* 151 */ this.bytes = bytes; +/* 152 */ this.chooseOne = chooseOne; +/* */ +/* */ +/* 155 */ readySetGo(); +/* */ } +/* */ +/* */ protected void build() { +/* 159 */ this.startupCheck = new Checkbox(Console.message("Check-for-up-each"), +/* 160 */ IniFile.gamma().getIniInt("CheckUpgrades", 1) != 0); +/* */ +/* */ +/* 163 */ int count = this.list.size(); +/* */ +/* 165 */ this.checkboxes = new Vector(); +/* */ +/* 167 */ Panel p = new Panel(new GridLayout(count, 1)); +/* */ +/* 169 */ Checkbox chk = null; +/* */ +/* 171 */ for (int i = 0; i < count; i++) { +/* 172 */ int b = ((Integer)this.bytes.elementAt(i)).intValue(); +/* */ +/* 174 */ String kb = NumberFormat.getInstance().format(b / 1000); +/* 175 */ Object[] arguments = { new String(((String)this.list.elementAt(i)).toString()), +/* 176 */ new String(kb) }; +/* 177 */ String msg = MessageFormat.format(Console.message("Kbytes"), +/* 178 */ arguments); +/* 179 */ chk = new Checkbox(msg, true); +/* */ +/* 181 */ if (!this.forceUpgrades) { +/* 182 */ p.add(chk); +/* */ } else { +/* 184 */ p.add(new MultiLineLabel(msg)); +/* */ } +/* 186 */ this.checkboxes.addElement(chk); +/* */ } +/* */ +/* */ +/* 190 */ GridBagLayout gbag = new GridBagLayout(); +/* 191 */ setLayout(gbag); +/* 192 */ GridBagConstraints c = new GridBagConstraints(); +/* 193 */ c.anchor = 10; +/* 194 */ c.fill = 0; +/* 195 */ c.weightx = 1.0D; +/* 196 */ c.weighty = 1.0D; +/* 197 */ c.gridwidth = 0; +/* 198 */ c.gridheight = 1; +/* 199 */ c.insets = new Insets(0, 15, 0, 15); +/* */ +/* */ +/* */ +/* 203 */ Object[] arguments = { new String(this.name) }; +/* 204 */ String msg = this.first ? MessageFormat.format( +/* 205 */ Console.message("dont-have"), arguments) : +/* 206 */ MessageFormat.format(Console.message("update-available"), arguments); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 212 */ add(gbag, new MultiLineLabel(msg + "\n ", 5, 5), c); +/* */ +/* 214 */ if (count > 3) { +/* 215 */ ScrollPane sp = new ScrollPane(); +/* */ +/* 217 */ GridBagConstraints c2 = new GridBagConstraints(); +/* 218 */ c2.fill = 1; +/* 219 */ c2.gridwidth = 0; +/* 220 */ sp.setSize(280, 100); +/* 221 */ sp.validate(); +/* */ +/* 223 */ add(gbag, sp, c2); +/* 224 */ sp.add(p); +/* */ } else { +/* 226 */ add(gbag, p, c); +/* */ } +/* */ +/* 229 */ if (!this.forceUpgrades) { +/* 230 */ add(gbag, this.startupCheck, c); +/* */ } +/* 232 */ this.msgLabel = new MultiLineLabel(calcMsg(), 5, 5); +/* 233 */ add(gbag, this.msgLabel, c); +/* */ +/* 235 */ c.gridwidth = 2; +/* 236 */ add(gbag, this.getsFocus = this.yesButton, c); +/* */ +/* 238 */ if ((!this.forceUpgrades) || (this.first)) { +/* 239 */ c.gridwidth = 0; +/* 240 */ add(gbag, this.noButton, c); +/* */ +/* 242 */ c.insets.top = 5; +/* 243 */ c.insets.bottom = 15; +/* 244 */ add(gbag, this.moreInfo, c); +/* */ } +/* */ } +/* */ +/* */ private String calcMsg() { +/* 249 */ int totalBytes = 0; +/* 250 */ if (this.bytes != null) { +/* 251 */ for (int i = 0; i < this.bytes.size(); i++) +/* 252 */ if (((Checkbox)this.checkboxes.elementAt(i)).getState()) +/* 253 */ totalBytes += ((Integer)this.bytes.elementAt(i)).intValue(); +/* */ } +/* 255 */ String msg = ""; +/* */ +/* 257 */ String ins = this.forceUpgrades ? forcedInstructions : instructions; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 266 */ if (totalBytes == 0) { +/* 267 */ msg = Console.message("no-entries"); +/* */ +/* */ +/* */ +/* */ +/* 272 */ return "\n" + msg + " \n \n \n \n" + ins; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* 280 */ int modemMins = 10 * totalBytes / 288000 + 1; +/* */ +/* 282 */ String modemMinutes = +/* 283 */ modemMins / +/* 284 */ 10 + +/* 285 */ "." + +/* 286 */ modemMins % +/* 287 */ 10 + +/* 288 */ " " + ( +/* 289 */ modemMins == 10 ? Console.message("minute") : +/* 290 */ Console.message("minutes")); +/* */ +/* */ +/* */ +/* */ +/* 295 */ int cableMins = 10 * totalBytes / 1000000 + 1; +/* */ +/* 297 */ String cableMinutes = +/* 298 */ cableMins / +/* 299 */ 10 + +/* 300 */ "." + +/* 301 */ cableMins % +/* 302 */ 10 + +/* 303 */ " " + ( +/* 304 */ cableMins == 10 ? Console.message("minute") : +/* 305 */ Console.message("minutes")); +/* */ +/* */ +/* */ +/* */ +/* */ +/* 311 */ NumberFormat nF = NumberFormat.getNumberInstance(Locale.getDefault()); +/* 312 */ String kb = nF.format(totalBytes / 1000); +/* */ +/* 314 */ Object[] arguments = { new String(kb), new String(cableMinutes), +/* 315 */ new String(modemMinutes) }; +/* 316 */ msg = MessageFormat.format(Console.message("entries-total"), arguments); +/* */ +/* 318 */ return msg + ins; +/* */ } +/* */ +/* */ +/* */ +/* */ public void setVisible(boolean visible) +/* */ { +/* 325 */ super.setVisible(visible); +/* 326 */ if (visible) { +/* 327 */ this.getsFocus.requestFocus(); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public synchronized boolean confirmUpgrade() +/* */ { +/* 340 */ while (isActive()) { +/* */ try { +/* 342 */ wait(); +/* */ } +/* */ catch (InterruptedException localInterruptedException) {} +/* */ } +/* 346 */ return getConfirmed(); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public int confirmUpgradeFromList() +/* */ { +/* 359 */ if (!confirmUpgrade()) { +/* 360 */ return 0; +/* */ } +/* */ +/* 363 */ for (int i = 0; i < this.bytes.size(); i++) +/* 364 */ if (!((Checkbox)this.checkboxes.elementAt(i)).getState()) +/* */ break; +/* 366 */ return i; +/* */ } +/* */ +/* */ +/* */ +/* */ public Vector<String> rejectedList() +/* */ { +/* 373 */ if (!confirmUpgrade()) { +/* 374 */ return this.list; +/* */ } +/* 376 */ Vector<String> v = new Vector(); +/* */ +/* 378 */ for (int i = 0; i < this.bytes.size(); i++) +/* 379 */ if (!((Checkbox)this.checkboxes.elementAt(i)).getState()) +/* 380 */ v.addElement((String)this.list.elementAt(i)); +/* 381 */ return v; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected synchronized boolean done(boolean confirmed) +/* */ { +/* 390 */ boolean retCode = super.done(confirmed); +/* 391 */ notify(); +/* 392 */ return retCode; +/* */ } +/* */ +/* */ +/* */ @Deprecated +/* */ public boolean action(Event event, Object what) +/* */ { +/* 399 */ if (event.target == this.yesButton) +/* 400 */ return done(true); +/* 401 */ if (event.target == this.noButton) +/* 402 */ return done(false); +/* 403 */ if (event.target == this.moreInfo) { +/* 404 */ NetUpdate.showInfo(this.info); +/* 405 */ } else if (event.target == this.startupCheck) { +/* 406 */ IniFile.gamma().setIniInt("CheckUpgrades", +/* 407 */ this.startupCheck.getState() ? 1 : 0); +/* 408 */ } else if ((event.target instanceof Checkbox)) +/* */ { +/* 410 */ if (this.chooseOne) +/* */ { +/* 412 */ int i = this.checkboxes.indexOf(event.target); +/* 413 */ if (((Checkbox)event.target).getState()) { +/* */ do { +/* 415 */ ((Checkbox)this.checkboxes.elementAt(i)).setState(true);i--; +/* 414 */ } while (i >= 0); +/* */ } else { +/* */ do +/* */ { +/* 418 */ ((Checkbox)this.checkboxes.elementAt(i)).setState(false);i++; +/* 417 */ } while (i < this.checkboxes.size()); +/* */ } +/* */ } +/* */ +/* 421 */ this.msgLabel.setLabel(calcMsg()); +/* 422 */ return true; +/* */ } +/* 424 */ return false; +/* */ } +/* */ +/* */ @Deprecated +/* */ public boolean handleEvent(Event event) +/* */ { +/* 430 */ if ((this.forceUpgrades) && (event.id == 201)) { +/* 431 */ return done(true); +/* */ } +/* 433 */ return super.handleEvent(event); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ @Deprecated +/* */ public boolean keyDown(Event event, int key) +/* */ { +/* 446 */ if ((!this.forceUpgrades) && +/* 447 */ (key == 27)) { +/* 448 */ return done(false); +/* */ } +/* 450 */ return super.keyDown(event, key); +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\UpgradeDialog.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |