From: Stefan F. <ste...@us...> - 2010-05-30 10:42:47
|
Update of /cvsroot/rails/18xx/rails/ui/swing In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv15333/rails/ui/swing Modified Files: UpgradesPanel.java ORUIManager.java ORPanel.java Log Message: Added GameOptions for revenue calculation and route awareness Index: UpgradesPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/UpgradesPanel.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** UpgradesPanel.java 29 May 2010 23:33:43 -0000 1.27 --- UpgradesPanel.java 30 May 2010 10:42:39 -0000 1.28 *************** *** 498,502 **** text.append("<HTML><BODY>" + tile.getExternalId()); if (tile.countFreeTiles() != -1) { ! text.append("<BR/>#" + tile.countFreeTiles()); } text.append("</BODY></HTML>"); --- 498,502 ---- text.append("<HTML><BODY>" + tile.getExternalId()); if (tile.countFreeTiles() != -1) { ! text.append("<BR> #" + tile.countFreeTiles()); } text.append("</BODY></HTML>"); Index: ORUIManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORUIManager.java,v retrieving revision 1.77 retrieving revision 1.78 diff -C2 -d -r1.77 -r1.78 *** ORUIManager.java 29 May 2010 23:33:43 -0000 1.77 --- ORUIManager.java 30 May 2010 10:42:39 -0000 1.78 *************** *** 10,13 **** --- 10,14 ---- import rails.algorithms.*; + import rails.common.GuiDef; import rails.game.*; import rails.game.action.*; *************** *** 198,231 **** boolean mapHexes = false; hexUpgrades = new ArrayList<MapHex>(); ! for (LayTile layTile:allowedTileLays) { ! switch (layTile.getType()) { ! case (LayTile.GENERIC): ! mapHexes = true; break; ! case (LayTile.SPECIAL_PROPERTY): ! SpecialPropertyI sp = layTile.getSpecialProperty(); if (sp == null || !(sp instanceof SpecialTileLay) || ((SpecialTileLay)sp).requiresConnection()) break; ! case (LayTile.LOCATION_SPECIFIC): ! if (layTile.getLocations() != null) ! hexUpgrades.addAll(layTile.getLocations()); } - } ! // standard upgrades ! if (mapHexes) { ! // generate network graph to indicate the allowed tiles ! List<MapHex> mapHexUpgrades = NetworkGraphBuilder.getMapHexes(getCompanyGraph()); ! for (MapHex hex:mapHexUpgrades) { ! if (hex.isUpgradeableNow(gameUIManager.getCurrentPhase())) ! hexUpgrades.add(hex); } - } ! // activate upgrades ! for (MapHex hex:hexUpgrades) { ! GUIHex guiHex = map.getHexByName(hex.getName()); ! guiHex.setSelectable(true); } } --- 199,236 ---- boolean mapHexes = false; hexUpgrades = new ArrayList<MapHex>(); ! ! if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) { ! for (LayTile layTile:allowedTileLays) { ! switch (layTile.getType()) { ! case (LayTile.GENERIC): ! mapHexes = true; break; ! case (LayTile.SPECIAL_PROPERTY): ! SpecialPropertyI sp = layTile.getSpecialProperty(); if (sp == null || !(sp instanceof SpecialTileLay) || ((SpecialTileLay)sp).requiresConnection()) break; ! case (LayTile.LOCATION_SPECIFIC): ! if (layTile.getLocations() != null) ! hexUpgrades.addAll(layTile.getLocations()); ! } } ! // standard upgrades ! if (mapHexes) { ! // generate network graph to indicate the allowed tiles ! List<MapHex> mapHexUpgrades = NetworkGraphBuilder.getMapHexes(getCompanyGraph()); ! for (MapHex hex:mapHexUpgrades) { ! if (hex.isUpgradeableNow(gameUIManager.getCurrentPhase())) ! hexUpgrades.add(hex); ! } } ! // activate upgrades ! for (MapHex hex:hexUpgrades) { ! GUIHex guiHex = map.getHexByName(hex.getName()); ! guiHex.setSelectable(true); ! } ! } } *************** *** 245,267 **** boolean mapHexes = false; hexUpgrades = new ArrayList<MapHex>(); ! for (LayToken layToken:allowedTokenLays) { ! SpecialPropertyI sp = layToken.getSpecialProperty(); ! if (sp == null) { ! mapHexes = true; ! } else if (layToken.getLocations() != null) ! hexUpgrades.addAll(layToken.getLocations()); ! } - // standard tokens - if (mapHexes) { - // generate network graph to indicate the token lays - hexUpgrades = NetworkGraphBuilder.getStationHexes(getCompanyGraph(), orComp); for (LayToken layToken:allowedTokenLays) { ! if (layToken.getLocations() != null) hexUpgrades.addAll(layToken.getLocations()); } ! for (MapHex hex:hexUpgrades) { ! GUIHex guiHex = map.getHexByName(hex.getName()); ! guiHex.setSelectable(true); } } --- 250,275 ---- boolean mapHexes = false; hexUpgrades = new ArrayList<MapHex>(); ! if (gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT)) { for (LayToken layToken:allowedTokenLays) { ! SpecialPropertyI sp = layToken.getSpecialProperty(); ! if (sp == null) { ! mapHexes = true; ! } else if (layToken.getLocations() != null) hexUpgrades.addAll(layToken.getLocations()); } ! ! // standard tokens ! if (mapHexes) { ! // generate network graph to indicate the token lays ! hexUpgrades = NetworkGraphBuilder.getStationHexes(getCompanyGraph(), orComp); ! for (LayToken layToken:allowedTokenLays) { ! if (layToken.getLocations() != null) ! hexUpgrades.addAll(layToken.getLocations()); ! } ! for (MapHex hex:hexUpgrades) { ! GUIHex guiHex = map.getHexByName(hex.getName()); ! guiHex.setSelectable(true); ! } } } Index: ORPanel.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/ui/swing/ORPanel.java,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 *** ORPanel.java 24 May 2010 11:42:35 -0000 1.69 --- ORPanel.java 30 May 2010 10:42:39 -0000 1.70 *************** *** 567,599 **** protected void addNetworkInfo() { - CompanyManagerI cm = orUIManager.getGameUIManager().getGameManager().getCompanyManager(); JMenu networkMenu = new JMenu(LocalText.getText("NetworkInfo")); networkMenu.setEnabled(true); infoMenu.add(networkMenu); ! JMenuItem item = new JMenuItem("All"); ! item.addActionListener(this); ! item.setActionCommand(NETWORK_INFO_CMD); ! networkMenu.add(item); ! ! for (PublicCompanyI comp : cm.getAllPublicCompanies()) { ! if (!comp.hasFloated() || comp.isClosed()) continue; ! item = new JMenuItem(comp.getName()); item.addActionListener(this); item.setActionCommand(NETWORK_INFO_CMD); networkMenu.add(item); } } protected void executeNetworkInfo(String companyName) { GameManagerI gm = orUIManager.getGameUIManager().getGameManager(); - MapManager mapManager = gm.getMapManager(); ! if (companyName.equals("All")) { NetworkGraphBuilder nwGraph = NetworkGraphBuilder.createMapGraph(gm); SimpleGraph<NetworkVertex, NetworkEdge> mapGraph = nwGraph.getMapGraph(); ! NetworkGraphBuilder.visualize(mapGraph, "Map Network"); mapGraph = NetworkGraphBuilder.optimizeGraph(mapGraph); NetworkGraphBuilder.visualize(mapGraph, "Optimized Map Network"); --- 567,607 ---- protected void addNetworkInfo() { + boolean route_highlight = orUIManager.gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.ROUTE_HIGHLIGHT); + boolean revenue_suggest = orUIManager.gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.REVENUE_SUGGEST); + + if (!route_highlight && !revenue_suggest) return; + JMenu networkMenu = new JMenu(LocalText.getText("NetworkInfo")); networkMenu.setEnabled(true); infoMenu.add(networkMenu); ! if (route_highlight) { ! JMenuItem item = new JMenuItem("Network"); item.addActionListener(this); item.setActionCommand(NETWORK_INFO_CMD); networkMenu.add(item); } + + if (revenue_suggest) { + CompanyManagerI cm = orUIManager.getGameUIManager().getGameManager().getCompanyManager(); + for (PublicCompanyI comp : cm.getAllPublicCompanies()) { + if (!comp.hasFloated() || comp.isClosed()) continue; + JMenuItem item = new JMenuItem(comp.getName()); + item.addActionListener(this); + item.setActionCommand(NETWORK_INFO_CMD); + networkMenu.add(item); + } + } } protected void executeNetworkInfo(String companyName) { GameManagerI gm = orUIManager.getGameUIManager().getGameManager(); ! if (companyName.equals("Network")) { NetworkGraphBuilder nwGraph = NetworkGraphBuilder.createMapGraph(gm); SimpleGraph<NetworkVertex, NetworkEdge> mapGraph = nwGraph.getMapGraph(); ! // NetworkGraphBuilder.visualize(mapGraph, "Map Network"); mapGraph = NetworkGraphBuilder.optimizeGraph(mapGraph); NetworkGraphBuilder.visualize(mapGraph, "Optimized Map Network"); *************** *** 777,783 **** // initialize and start the revenue adapter ! revenueAdapter = initRevenueCalculation(orComp); ! revenueThread = new Thread(revenueAdapter); ! revenueThread.start(); } --- 785,793 ---- // initialize and start the revenue adapter ! if (orUIManager.gameUIManager.getGameParameterAsBoolean(GuiDef.Parm.REVENUE_SUGGEST)) { ! revenueAdapter = initRevenueCalculation(orComp); ! revenueThread = new Thread(revenueAdapter); ! revenueThread.start(); ! } } |