From: Stefan F. <ste...@us...> - 2010-05-29 09:39:06
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv1284/rails/ui/swing Modified Files: UpgradesPanel.java ORUIManager.java Log Message: Start of refining of the map correction Index: UpgradesPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/UpgradesPanel.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** UpgradesPanel.java 28 Mar 2010 17:05:56 -0000 1.25 --- UpgradesPanel.java 29 May 2010 09:38:58 -0000 1.26 *************** *** 173,177 **** HexLabel hexLabel = new HexLabel(hexIcon, tile.getId()); hexLabel.setName(tile.getName()); ! hexLabel.setText("" + tile.getExternalId()); hexLabel.setOpaque(true); hexLabel.setVisible(true); --- 173,177 ---- HexLabel hexLabel = new HexLabel(hexIcon, tile.getId()); hexLabel.setName(tile.getName()); ! hexLabel.setText("<HTML><BODY>" + tile.getExternalId() + "<BR/>#" + tile.countFreeTiles() + "</BODY></HTML>"); hexLabel.setOpaque(true); hexLabel.setVisible(true); *************** *** 191,195 **** // populate version for corrections ! public void showCorrectionUpgrades() { upgradePanel.removeAll(); GridLayout panelLayout = (GridLayout)upgradePanel.getLayout(); --- 191,195 ---- // populate version for corrections ! public void showCorrectionTileUpgrades() { upgradePanel.removeAll(); GridLayout panelLayout = (GridLayout)upgradePanel.getLayout(); *************** *** 218,222 **** hexLabel.setName(tile.getName()); if (tile.getExternalId() > 0) ! hexLabel.setText("" + tile.getExternalId()); else hexLabel.setText(""); --- 218,222 ---- hexLabel.setName(tile.getName()); if (tile.getExternalId() > 0) ! hexLabel.setText("<HTML><BODY>" + tile.getExternalId() + "<BR/>#" + tile.countFreeTiles() + "</BODY></HTML>"); else hexLabel.setText(""); *************** *** 237,240 **** --- 237,287 ---- } + // populate version for corrections + public void showCorrectionTokenUpgrades() { + upgradePanel.removeAll(); + GridLayout panelLayout = (GridLayout)upgradePanel.getLayout(); + List<? extends TokenI> tokens = orUIManager.tokenLays; + + if (tokens == null || tokens.size() == 0) { + // reset to the number of elements + panelLayout.setRows(defaultNbPanelElements); + // set to position 0 + scrollPane.getVerticalScrollBar().setValue(0); + } else { + Color fgColour = null; + Color bgColour = null; + String text = null; + String description = null; + TokenIcon icon; + ActionLabel tokenLabel; + tokenLabels = new ArrayList<ActionLabel>(); + for (TokenI token:tokens) { + if (token instanceof BaseToken) { + PublicCompanyI comp = ((BaseToken)token).getCompany(); + fgColour = comp.getFgColour(); + bgColour = comp.getBgColour(); + description = text = comp.getName(); + } + icon = new TokenIcon(25, fgColour, bgColour, text); + tokenLabel = new ActionLabel(icon); + tokenLabel.setName(description); + tokenLabel.setText(description); + tokenLabel.setBackground(defaultLabelBgColour); + tokenLabel.setOpaque(true); + tokenLabel.setVisible(true); + tokenLabel.setBorder(border); + tokenLabel.addMouseListener(this); + tokenLabels.add(tokenLabel); + upgradePanel.add(tokenLabel); + } + + } + upgradePanel.add(doneButton); + upgradePanel.add(cancelButton); + + // repaint(); + revalidate(); + + } public void clear() { Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.75 retrieving revision 1.76 diff -C2 -d -r1.75 -r1.76 *** ORUIManager.java 24 May 2010 07:49:26 -0000 1.75 --- ORUIManager.java 29 May 2010 09:38:58 -0000 1.76 *************** *** 52,55 **** --- 52,56 ---- private boolean tokenLayingEnabled = false; public List<LayToken> allowedTokenLays = new ArrayList<LayToken>(); + public List<? extends TokenI> tokenLays; private int selectedTokenIndex; private LayToken selectedTokenAllowance; *************** *** 588,592 **** switch (mapCorrectionAction.getStep()) { case SELECT_HEX: ! case SELECT_TILE: // if tile is selected see checkClickedHex = true; break; --- 589,593 ---- switch (mapCorrectionAction.getStep()) { case SELECT_HEX: ! case SELECT_TILE: // if tile is selected checkClickedHex = true; break; *************** *** 1694,1697 **** --- 1695,1700 ---- setLocalStep(MAP_CORRECTION); + GUIHex selectedHex = map.getSelectedHex(); + boolean showTilesInUpgrade = true; switch (action.getStep()) { case SELECT_HEX: *************** *** 1702,1705 **** --- 1705,1709 ---- upgradePanel.setCancelEnabled(false); tileUpgrades = new ArrayList<TileI>(); + showTilesInUpgrade = true; break; case SELECT_TILE: *************** *** 1709,1712 **** --- 1713,1722 ---- upgradePanel.setCancelEnabled(true); tileUpgrades = action.getTiles(); + // checks if there is still a tile displayed (due to errors) + if (selectedHex.canFixTile()){ + selectedHex.removeTile(); + map.setSelectedHex(selectedHex); + } + showTilesInUpgrade = true; break; case SELECT_ORIENTATION: *************** *** 1715,1722 **** upgradePanel.setCancelText("Cancel"); upgradePanel.setCancelEnabled(true); - // next step already set to finished => preprinted tile with fixed orientation if (action.getNextStep() == MapCorrectionManager.ActionStep.FINISHED) { - GUIHex selectedHex = map.getSelectedHex(); selectedHex.setTileOrientation(action.getOrientation()); map.repaint(selectedHex.getBounds()); --- 1725,1730 ---- *************** *** 1729,1737 **** return; } break; } log.debug("Active map tile correction"); ! upgradePanel.showCorrectionUpgrades(); } --- 1737,1757 ---- return; } + showTilesInUpgrade = true; break; + case RELAY_BASETOKENS: + upgradePanel.setDoneText("RelayToken"); + upgradePanel.setDoneEnabled(true); + upgradePanel.setCancelText("Cancel"); + upgradePanel.setCancelEnabled(true); + tokenLays= action.getTokensToRelay(); + showTilesInUpgrade = false; } log.debug("Active map tile correction"); ! if (showTilesInUpgrade) { ! upgradePanel.showCorrectionTileUpgrades(); ! } else { ! upgradePanel.showCorrectionTokenUpgrades(); ! } } |