From: Erik V. <ev...@us...> - 2010-01-16 15:06:52
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv8948/rails/ui/swing Modified Files: ORPanel.java Log Message: Added Privates item to Info menu. Added long private names for 1830. Index: ORPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORPanel.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** ORPanel.java 14 Jan 2010 20:50:08 -0000 1.39 --- ORPanel.java 16 Jan 2010 15:06:44 -0000 1.40 *************** *** 13,18 **** --- 13,20 ---- import rails.game.*; import rails.game.action.*; + import rails.game.special.SpecialPropertyI; import rails.ui.swing.elements.*; import rails.util.LocalText; + import rails.util.Util; public class ORPanel extends GridPanel *************** *** 44,47 **** --- 46,50 ---- private JMenu infoMenu; private JMenuItem remainingTilesMenuItem; + private JMenu privatesInfoMenu; private JMenu specialMenu; private JMenu loansMenu; *************** *** 153,156 **** --- 156,161 ---- menuBar.add(infoMenu); + addPrivatesInfo(); + specialMenu = new JMenu(LocalText.getText("SPECIAL")); specialMenu.setBackground(Color.YELLOW); *************** *** 459,462 **** --- 464,502 ---- } + + protected void addPrivatesInfo () { + + List<PrivateCompanyI> privates = orWindow.gameUIManager.getGameManager().getAllPrivateCompanies(); + if (privates == null || privates.isEmpty()) return; + + privatesInfoMenu = new JMenu(LocalText.getText("PRIVATES")); + privatesInfoMenu.setEnabled(true); + infoMenu.add(privatesInfoMenu); + + JMenu item; + List<SpecialPropertyI> sps; + StringBuffer b; + + for (PrivateCompanyI p : privates) { + sps = p.getSpecialProperties(); + b = new StringBuffer("<html>"); + if (Util.hasValue(p.getLongName())) { + b.append(p.getLongName()); + } + if (sps == null || sps.isEmpty()) { + if (b.length() > 6) b.append("<br>"); + b.append(LocalText.getText("NoSpecialProperty")); + } else { + for (SpecialPropertyI sp : sps) { + if (b.length() > 6) b.append("<br>"); + b.append(sp.toString()); + } + } + item = new JMenu (p.getName()); + item.setEnabled(true); + item.add(new JMenuItem(b.toString())); + privatesInfoMenu.add(item); + } + } public void finish() { |