From: Erik V. <ev...@us...> - 2009-01-07 21:03:35
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv20068/rails/ui/swing Modified Files: StartRoundWindow.java Log Message: Added start packet item info to the StartRoundWindow. Index: StartRoundWindow.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/StartRoundWindow.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** StartRoundWindow.java 11 Dec 2008 20:12:30 -0000 1.27 --- StartRoundWindow.java 7 Jan 2009 21:03:24 -0000 1.28 *************** *** 13,16 **** --- 13,17 ---- import rails.game.*; import rails.game.action.*; + import rails.game.special.SpecialPropertyI; import rails.ui.swing.elements.*; import rails.util.LocalText; *************** *** 52,55 **** --- 53,58 ---- private Field playerFree[]; private int playerFreeCashXOffset, playerFreeCashYOffset; + private Field info[]; + private int infoXOffset, infoYOffset; private Caption[] upperPlayerCaption; *************** *** 62,65 **** --- 65,70 ---- private final ActionButton passButton; + private ImageIcon infoIcon = null; + private final int np; // Number of players private final int ni; // Number of start items *************** *** 157,160 **** --- 162,167 ---- actionableItems = new StartItemAction[ni]; + infoIcon = createInfoIcon(); + init(); *************** *** 182,185 **** --- 189,193 ---- minBid = new Field[ni]; bidPerPlayer = new Field[ni][np]; + info = new Field[ni]; upperPlayerCaption = new Caption[np]; lowerPlayerCaption = new Caption[np]; *************** *** 200,203 **** --- 208,214 ---- bidPerPlayerYOffset = lastY; + infoXOffset = bidPerPlayerXOffset + np; + infoYOffset = lastY; + // Bottom rows lastY += (ni - 1); *************** *** 254,257 **** --- 265,272 ---- 1, 1, 0); } + + f = info[i] = new Field (infoIcon); + f.setToolTipText(getStartItemDescription(items[i])); + addField (f, infoXOffset, infoYOffset + i, 1, 1, WIDE_LEFT); } *************** *** 616,619 **** --- 631,676 ---- } + private String getStartItemDescription (StartItem item) { + StringBuffer b = new StringBuffer("<html>"); + b.append (item.getPrimary().toString()); + if (item.getPrimary() instanceof PrivateCompany) { + PrivateCompany priv = (PrivateCompany) item.getPrimary(); + b.append ("<br>Revenue: ").append(Bank.format(priv.getRevenue())); + List<MapHex> blockedHexes = priv.getBlockedHexes(); + if (blockedHexes == null) { + } else if (blockedHexes.size() == 1) { + b.append("<br>Blocked hex: ").append(blockedHexes.get(0).getName()); + } else if (blockedHexes.size() > 1) { + b.append("<br>Blocked hexes:"); + for (MapHex hex : blockedHexes) { + b.append(" ").append(hex.getName()); + } + } + if (priv.hasSpecialProperties()) { + b.append("<br><b>Special properties:</b>"); + for (SpecialPropertyI sp : priv.getSpecialProperties()) { + b.append("<br>").append(sp.toString()); + } + } + } + if (item.getSecondary() != null) { + b.append("<br><b>Also contains:</b><br>"); + b.append(item.getSecondary().toString()); + } + return b.toString(); + } + + private ImageIcon createInfoIcon() { + + String path = "/rails/ui/images/Inform.gif"; + java.net.URL imgURL = getClass().getResource(path); + if (imgURL != null) { + return new ImageIcon(imgURL, "Info"); + } else { + System.err.println("Couldn't find file: " + path); + return null; + } + } + public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_F1) { |