From: Frederick W. <fre...@us...> - 2012-02-04 15:58:30
|
.classpath | 4 LocalisedText.properties | 10 + build.xml | 4 buildRails.xml | 4 data/Properties.xml | 4 lib/df_1.1.0/dockingFramesCommon.jar |binary lib/df_1.1.0/dockingFramesCore.jar |binary manifest | 2 rails/sound/SoundConfig.java | 3 rails/sound/SoundEventInterpreter.java | 9 + rails/ui/swing/GameUIManager.java | 1 rails/ui/swing/ORPanel.java | 85 ++++++++++++++-- rails/ui/swing/ORWindow.java | 170 +++++++++++++++++++++++++++++---- rails/ui/swing/UpgradesPanel.java | 18 +++ 14 files changed, 278 insertions(+), 36 deletions(-) New commits: commit 08f42f7eecaf26eca424b1f5012ecbd2e831fc21 Author: Frederick Weld <fre...@gm...> Date: Sat Feb 4 16:47:17 2012 +0100 Added saving/restoring dockable panel layout on a per-game basis Layout files (xml) are persisted into a dedicated subfolder of the save game folder. Each game has a specific layout associated to it. diff --git a/rails/ui/swing/GameUIManager.java b/rails/ui/swing/GameUIManager.java index 72a3aa7..f281034 100644 --- a/rails/ui/swing/GameUIManager.java +++ b/rails/ui/swing/GameUIManager.java @@ -126,6 +126,7 @@ public class GameUIManager implements DialogOwner { public void terminate () { getWindowSettings ().save(); + if (orWindow != null) orWindow.saveDockableLayout(); System.exit(0); } diff --git a/rails/ui/swing/ORWindow.java b/rails/ui/swing/ORWindow.java index 7e28b47..5f75ad9 100644 --- a/rails/ui/swing/ORWindow.java +++ b/rails/ui/swing/ORWindow.java @@ -4,6 +4,7 @@ package rails.ui.swing; import java.awt.BorderLayout; import java.awt.Rectangle; import java.awt.event.*; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -46,6 +47,11 @@ public class ORWindow extends JFrame implements ActionPerformer { List<LayTile> allowedTileLays = new ArrayList<LayTile>(); List<LayToken> allowedTokenLays = new ArrayList<LayToken>(); + CControl orWindowControl = null; + + private static final String layoutFolderName = "DockableLayout"; + private static final String layoutFileSuffix = "_layout.rails_ini"; + protected static Logger log = Logger.getLogger(ORWindow.class.getPackage().getName()); @@ -82,7 +88,7 @@ public class ORWindow extends JFrame implements ActionPerformer { //DOCKABLE LAYOUT //build the docking layout - CControl orWindowControl = new CControl( this ); + orWindowControl = new CControl( this ); orWindowControl.setTheme( ThemeMap.KEY_SMOOTH_THEME ); add( orWindowControl.getContentArea() ); CGrid orWindowLayout = new CGrid( orWindowControl ); @@ -164,6 +170,7 @@ public class ORWindow extends JFrame implements ActionPerformer { addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { + saveDockableLayout(); StatusWindow.uncheckMenuItemBox(StatusWindow.MAP_CMD); frame.dispose(); } @@ -191,6 +198,9 @@ public class ORWindow extends JFrame implements ActionPerformer { ws.set(frame); gameUIManager.reportWindow.updateLog(); + + //dockable panes: restore former layout (depending on game variant) + loadDockableLayout(); } public ORUIManager getORUIManager() { @@ -295,4 +305,51 @@ public class ORWindow extends JFrame implements ActionPerformer { public boolean isDockablePanelsEnabled() { return "yes".equals(Config.get("or.window.dockablePanels")); } + + + private String getLayoutName() { + return getClass().getSimpleName() + "_" + + gameUIManager.getGameManager().getGameName() ; + } + + private File getLayoutFile() { + try { + //get layout folder (and ensure that it is available) + File layoutFolder = new File(Config.get("save.directory"),layoutFolderName); + if (!layoutFolder.isDirectory()) { + layoutFolder.mkdirs(); + } + File layoutFile = new File(layoutFolder, + getLayoutName() + layoutFileSuffix ); + return layoutFile; + } catch (Exception e) { + //return no valid file if anything goes wrong + return null; + } + } + + public void saveDockableLayout() { + if (!isDockablePanelsEnabled()) return; + + File layoutFile = getLayoutFile(); + if (layoutFile != null) { + try { + orWindowControl.save(getLayoutName()); + orWindowControl.writeXML(layoutFile); + } catch (Exception e) {} //skip in case of issue + } + } + + private void loadDockableLayout() { + if (!isDockablePanelsEnabled()) return; + + File layoutFile = getLayoutFile(); + if (layoutFile != null) { + try { + orWindowControl.readXML(layoutFile); + orWindowControl.load(getLayoutName()); + } catch (Exception e) {} //skip if layout not found + } + } + } commit e1cada7237772dca0022a66e90f0bff0cb592c44 Author: Frederick Weld <fre...@gm...> Date: Sat Feb 4 07:25:35 2012 +0100 Rendered button panel as dockable pane (detachable from OR panel) Change only applies if config option for dockable or window panels is set. Button panel's sizing is also adjusted in order to allow for both vertical / horizontal / grid layouts of the buttons. As a pre-condition, the buttons are all given the same size. Added localized texts for the dock titles. diff --git a/LocalisedText.properties b/LocalisedText.properties index 86bdea9..071d381 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -288,6 +288,11 @@ DiscardsBaseToken={0} discards a {1} base token on {2} DoesNotExist=Item does not exist DoesNotForm={0} does not form DoesNotHaveTheShares=Does not have the shares +DockableTitle.orWindow.messagePanel = Messages +DockableTitle.orWindow.upgradePanel = Upgrades +DockableTitle.orWindow.mapPanel = Map +DockableTitle.orWindow.orPanel = Companies +DockableTitle.orWindow.buttonPanel = Commands Done=Done DoubleHeadingModifier1825={0} are two {1}-trains running as a {2}-train (double heading). ShortORExecuted=A short OR has been held, in which only the sold privates have paid out. diff --git a/rails/ui/swing/ORPanel.java b/rails/ui/swing/ORPanel.java index cdaad11..453db01 100644 --- a/rails/ui/swing/ORPanel.java +++ b/rails/ui/swing/ORPanel.java @@ -4,6 +4,7 @@ package rails.ui.swing; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import javax.swing.*; @@ -160,7 +161,11 @@ implements ActionListener, KeyListener, RevenueListener { setLayout(new BorderLayout()); add(statusPanel, BorderLayout.CENTER); - add(buttonPanel, BorderLayout.SOUTH); + + //only add button panel directly for conventional layout + if (!parent.isDockablePanelsEnabled()) { + add(buttonPanel, BorderLayout.SOUTH); + } menuBar = new JMenuBar(); @@ -268,8 +273,7 @@ implements ActionListener, KeyListener, RevenueListener { } private void initButtonPanel() { - buttonPanel = new JPanel(); - + // sfy: operatingcosts button buttonOC = new ActionButton(LocalText.getText("OCButtonLabel")); buttonOC.setActionCommand(OPERATING_COST_CMD); @@ -277,14 +281,12 @@ implements ActionListener, KeyListener, RevenueListener { buttonOC.addActionListener(this); buttonOC.setEnabled(false); buttonOC.setVisible(false); - buttonPanel.add(buttonOC); button1 = new ActionButton(LocalText.getText("LayTile")); button1.setActionCommand(LAY_TILE_CMD); button1.setMnemonic(KeyEvent.VK_T); button1.addActionListener(this); - button1.setEnabled(true); - buttonPanel.add(button1); + button1.setEnabled(false); button2 = new ActionButton(LocalText.getText("BUY_PRIVATE")); button2.setActionCommand(BUY_PRIVATE_CMD); @@ -292,30 +294,88 @@ implements ActionListener, KeyListener, RevenueListener { button2.addActionListener(this); button2.setEnabled(false); button2.setVisible(false); - buttonPanel.add(button2); button3 = new ActionButton(LocalText.getText("Done")); button3.setActionCommand(DONE_CMD); button3.setMnemonic(KeyEvent.VK_D); button3.addActionListener(this); - button3.setEnabled(true); - buttonPanel.add(button3); + button3.setEnabled(false); undoButton = new ActionButton(LocalText.getText("UNDO")); undoButton.setActionCommand(UNDO_CMD); undoButton.setMnemonic(KeyEvent.VK_U); undoButton.addActionListener(this); undoButton.setEnabled(false); - buttonPanel.add(undoButton); redoButton = new ActionButton(LocalText.getText("REDO")); redoButton.setActionCommand(REDO_CMD); redoButton.setMnemonic(KeyEvent.VK_R); redoButton.addActionListener(this); redoButton.setEnabled(false); + + //choose button panel layout depending on whether panel becomes a dockable + if (orWindow.isDockablePanelsEnabled()) { + + //customized panel for dockable layout + //the minimal size is defined by the size of one button + //(aim here: user can choose whether buttons are laid out + // vertically or horizontally or in a grid, since + // the minimal size's restriction is minimal indeed.) + buttonPanel = new JPanel() { + private static final long serialVersionUID = 1L; + @Override + public Dimension getMinimumSize() { + int width = 0; + int height = 0; + if (getComponents().length != 0) { + //getting the first component is sufficient as their + //size is all the same + width = getComponents()[0].getPreferredSize().width; + height = getComponents()[0].getPreferredSize().height; + } + //add a margin + width += 10; + height += 10; + return new Dimension(width,height); + } + public Dimension getPreferredSize() { + return getMinimumSize(); + } + }; + + } else { + //plain panel for conventional layout + buttonPanel = new JPanel(); + } + + buttonPanel.add(buttonOC); + buttonPanel.add(button1); + buttonPanel.add(button2); + buttonPanel.add(button3); + buttonPanel.add(undoButton); buttonPanel.add(redoButton); + //for dockable button panel, ensure that all buttons have the same size + //(necessary, otherwise vertical/box layout will look ugly) + if (orWindow.isDockablePanelsEnabled()) { + + //get maximum size + Dimension maxSize = new Dimension(); + for (Component c : Arrays.asList( buttonPanel.getComponents() )) { + if (c.getPreferredSize().width > maxSize.width) + maxSize.width = c.getPreferredSize().width; + if (c.getPreferredSize().height > maxSize.height) + maxSize.height = c.getPreferredSize().height; + } + //apply maximum size to all buttons + for (Component c : Arrays.asList( buttonPanel.getComponents() )) { + c.setPreferredSize(maxSize); + } + + } + buttonPanel.setOpaque(true); + } public MouseListener getCompanyCaptionMouseClickListener() { @@ -1288,6 +1348,9 @@ implements ActionListener, KeyListener, RevenueListener { public PublicCompanyI[] getOperatingCompanies() { return companies; } - + + public JPanel getButtonPanel() { + return buttonPanel; + } } \ No newline at end of file diff --git a/rails/ui/swing/ORWindow.java b/rails/ui/swing/ORWindow.java index 10480c5..7e28b47 100644 --- a/rails/ui/swing/ORWindow.java +++ b/rails/ui/swing/ORWindow.java @@ -95,33 +95,40 @@ public class ORWindow extends JFrame implements ActionPerformer { } //add message panel - DefaultSingleCDockable singleDockable = new DefaultSingleCDockable( - "MessagePanel", "MessagePanel" ); + String dockableName = LocalText.getText("DockableTitle.orWindow.messagePanel"); + DefaultSingleCDockable singleDockable = new DefaultSingleCDockable( dockableName, dockableName ); singleDockable.add( slider, BorderLayout.CENTER ); singleDockable.setCloseable( false ); orWindowLayout.add( 0, 0, 100, 10, singleDockable ); //add upgrade panel - singleDockable = new DefaultSingleCDockable( - "UpgradePanel", "UpgradePanel" ); + dockableName = LocalText.getText("DockableTitle.orWindow.upgradePanel"); + singleDockable = new DefaultSingleCDockable( dockableName, dockableName ); singleDockable.add( upgradePanel, BorderLayout.CENTER ); singleDockable.setCloseable( false ); orWindowLayout.add( 0, 10, 20, 70, singleDockable ); //add map panel - singleDockable = new DefaultSingleCDockable( - "MapPanel", "MapPanel" ); + dockableName = LocalText.getText("DockableTitle.orWindow.mapPanel"); + singleDockable = new DefaultSingleCDockable( dockableName, dockableName ); singleDockable.add( mapPanel, BorderLayout.CENTER ); singleDockable.setCloseable( false ); orWindowLayout.add( 20, 10, 80, 70, singleDockable ); //add or panel - singleDockable = new DefaultSingleCDockable( - "ORPanel", "ORPanel" ); + dockableName = LocalText.getText("DockableTitle.orWindow.orPanel"); + singleDockable = new DefaultSingleCDockable( dockableName, dockableName ); singleDockable.add( orPanel, BorderLayout.CENTER ); singleDockable.setCloseable( false ); - orWindowLayout.add( 0, 80, 100, 20, singleDockable ); + orWindowLayout.add( 0, 80, 100, 15, singleDockable ); + //add button panel of or panel + dockableName = LocalText.getText("DockableTitle.orWindow.buttonPanel"); + singleDockable = new DefaultSingleCDockable( dockableName, dockableName ); + singleDockable.add( orPanel.getButtonPanel(), BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 95, 100, 5, singleDockable ); + orWindowControl.getContentArea().deploy( orWindowLayout ); } else { commit c6880f1e074772b3ae60437e0239351b2e8745a0 Author: Frederick Weld <fre...@gm...> Date: Sat Feb 4 07:13:01 2012 +0100 Added sfx option for lay tile to distinguish between city / track upgrades diff --git a/LocalisedText.properties b/LocalisedText.properties index 5025b59..86bdea9 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -226,7 +226,8 @@ Config.label.sound.sfx.or.buyTrain=Buy Train (several files) Config.label.sound.sfx.or.decision.payout=Payout Revenue Config.label.sound.sfx.or.decision.split=Split Revenue Config.label.sound.sfx.or.decision.withhold=Withhold Revenue -Config.label.sound.sfx.or.layTile=Lay Tile +Config.label.sound.sfx.or.layTile.city=Lay Tile (city) +Config.label.sound.sfx.or.layTile.track=Lay Tile (track, town) Config.label.sound.sfx.or.layToken=Lay Token Config.label.sound.sfx.or.rotateTile=Rotate Tile Config.label.sound.sfx.or.setRevenue=Set Revenue diff --git a/data/Properties.xml b/data/Properties.xml index 972596e..4802f74 100644 --- a/data/Properties.xml +++ b/data/Properties.xml @@ -87,7 +87,8 @@ <Property name="sound.sfx.sr.sellShare.nonPresident" type="FILE" /> <Property name="sound.sfx.sr.companyFloats" type="FILE" /> <Property name="sound.sfx.or.rotateTile" type="FILE" /> - <Property name="sound.sfx.or.layTile" type="FILE" /> + <Property name="sound.sfx.or.layTile.track" type="FILE" /> + <Property name="sound.sfx.or.layTile.city" type="FILE" /> <Property name="sound.sfx.or.layToken" type="FILE" /> <Property name="sound.sfx.or.setRevenue" type="FILE" /> <Property name="sound.sfx.or.decision.payout" type="FILE" /> diff --git a/rails/sound/SoundConfig.java b/rails/sound/SoundConfig.java index 4e86877..6867ddf 100644 --- a/rails/sound/SoundConfig.java +++ b/rails/sound/SoundConfig.java @@ -37,7 +37,8 @@ public class SoundConfig { public static final String KEY_SFX_SR_SellShare_NonPresident = "sound.sfx.sr.sellShare.nonPresident"; public static final String KEY_SFX_SR_CompanyFloats = "sound.sfx.sr.companyFloats"; public static final String KEY_SFX_OR_RotateTile = "sound.sfx.or.rotateTile"; - public static final String KEY_SFX_OR_LayTile = "sound.sfx.or.layTile"; + public static final String KEY_SFX_OR_LayTile_track = "sound.sfx.or.layTile.track"; + public static final String KEY_SFX_OR_LayTile_city = "sound.sfx.or.layTile.city"; public static final String KEY_SFX_OR_LayToken = "sound.sfx.or.layToken"; public static final String KEY_SFX_OR_SetRevenue = "sound.sfx.or.setRevenue"; public static final String KEY_SFX_OR_Decision_Payout = "sound.sfx.or.decision.payout"; diff --git a/rails/sound/SoundEventInterpreter.java b/rails/sound/SoundEventInterpreter.java index ac6e640..48a8df2 100644 --- a/rails/sound/SoundEventInterpreter.java +++ b/rails/sound/SoundEventInterpreter.java @@ -102,7 +102,14 @@ public class SoundEventInterpreter { //OR actions else if (action instanceof LayTile) { - player.playSFXByConfigKey (SoundConfig.KEY_SFX_OR_LayTile); + LayTile lt = (LayTile)action; + if (lt.getLaidTile().getNumStations() == 0) { + //track upgrade + player.playSFXByConfigKey (SoundConfig.KEY_SFX_OR_LayTile_track); + } else { + //city upgrade + player.playSFXByConfigKey (SoundConfig.KEY_SFX_OR_LayTile_city); + } } else if (action instanceof LayToken) { player.playSFXByConfigKey (SoundConfig.KEY_SFX_OR_LayToken); commit 31fbe3a41c5f5c3e6331e23cb3a0f37c66840336 Author: Frederick Weld <fre...@gm...> Date: Fri Feb 3 16:36:05 2012 +0100 Aligned upgrade tile zoomstep with the hex map (dockable or panes only) Now, upgrade panel tiles are displayed in the same zoom step as the tiles of the map. This wasn't possible before as the upgrade panel's width couldn't be adjusted manually. diff --git a/rails/ui/swing/UpgradesPanel.java b/rails/ui/swing/UpgradesPanel.java index 1ac2332..02556b6 100644 --- a/rails/ui/swing/UpgradesPanel.java +++ b/rails/ui/swing/UpgradesPanel.java @@ -235,7 +235,7 @@ public class UpgradesPanel extends Box implements MouseListener, ActionListener if (tempGUITile != null) { //tile has been rotated to valid orientation //get unscaled image for this orientation - hexImage = tempGUITile.getTileImage(UPGRADE_TILE_ZOOM_STEP); + hexImage = tempGUITile.getTileImage(getZoomStep()); } } @@ -399,7 +399,21 @@ public class UpgradesPanel extends Box implements MouseListener, ActionListener } private BufferedImage getHexImage(int tileId) { - return GameUIManager.getImageLoader().getTile(tileId, UPGRADE_TILE_ZOOM_STEP); + return GameUIManager.getImageLoader().getTile(tileId, getZoomStep()); + } + + /** + * @return Default zoom step for conventional panes or, for dockable panes, + * the zoom step used in the map. + * Map zoom step can only be used for dockable panes as user-based pane sizing + * could be necessary when displaying tiles of an arbitrary size + */ + private int getZoomStep() { + if (orUIManager.getORWindow().isDockablePanelsEnabled()) { + return hexMap.getZoomStep(); + } else { + return UPGRADE_TILE_ZOOM_STEP; + } } @Override commit c16e31e8b9cf0014dfcc78c3833f5917e5b469ca Author: Frederick Weld <fre...@gm...> Date: Fri Feb 3 16:24:15 2012 +0100 Added option for dockable panels of OR window (disabled by default) The conventional layout has been reincluded into OR window ==> both conventional / docking mode are supported. Furthermore, fixed an issue with transferring rails default locale to the docking framework (if it was en_us). diff --git a/LocalisedText.properties b/LocalisedText.properties index b8ff06d..5025b59 100644 --- a/LocalisedText.properties +++ b/LocalisedText.properties @@ -173,6 +173,7 @@ Config.infoText.default_players=Enter player names separated by commas. Config.infoText.gridPanel.tableBorders=Grid layouts are used for the Status Window and the panel of the Operating Round Window. Config.infoText.map.displayCurrentRoutes=If enabled, optimal train routes are displayed for the company which is currently taking its turn. Config.infoText.map.highlightHexes=<html>If enabled, parts of the map are highlighted depending on the position of the mouse pointer:<ul><li><b>Private companies:</b> Point to the name of a private company in order to highlight the locations associated with it (e.g., its reserved hex).<ul><li>If you point to a set of private companies (in the player or company holding), the locations of all contained private companies are highlighted</ul><li><b>Minor & Public Companies:</b> Point to the name of the company in order to highlight the locations associated with it (home and destination).</ul></html> +Config.infoText.or.window.dockablePanels=<html>This alters the window of the Operating Round. If enabled, allows for the following:<ul><li>Manually resize panels.<li>Manually adjust the layout of the panels within the window.<li>Detach / retach panel from / to window.</ul></html> Config.infoText.sound.backgroundMusic=The only music file type supported is mp3. Config.infoText.sound.backgroundMusic.stockRound=<html>Enter assignment of music files to phases.<ul><li>Separate the assignments by commas.<li>Each assignment has the syntax phaseName=complete file path<li>Default music is defined by omitting "phaseName=" in the assignment.</ul><strong>Examples:</strong><ul><li>Set default music: <br><code>c:\SR-default.mp3</code><li>Set phase-dependent music and a default (for trains above 6): <br><code>2=c:\SR-2.mp3,3=c:\SR-3.mp3,4=c:\SR-4.mp3,5=c:\SR-5.mp3,6=c:\SR-6.mp3,c:\SR-D.mp3</code></ul> </html> Config.infoText.sound.backgroundMusic.operatingRound=<html>Enter assignment of music files to phases.<ul><li>Separate the assignments by commas.<li>Each assignment has the syntax phaseName=complete file path<li>Default music is defined by omitting "phaseName=" in the assignment.</ul><strong>Examples:</strong><ul><li>Set default music: <br><code>c:\OR-default.mp3</code><li>Set phase-dependent music and a default (for trains above 6): <br><code>2=c:\OR-2.mp3,3=c:\OR-3.mp3,4=c:\OR-4.mp3,5=c:\OR-5.mp3,6=c:\OR-6.mp3,c:\OR-D.mp3</code></ul> </html> @@ -197,6 +198,7 @@ Config.label.map.highlightHexes=Highlight company locations Config.label.map.zoomstep=Map zoomstep Config.label.money_format=Money format Config.label.or.number_format=OR number format +Config.label.or.window.dockablePanels=Flexible panels for operating round Config.label.report.directory=Report directory Config.label.report.filename.date_time_pattern=Report filename date pattern Config.label.report.filename.extension=Report filename extension diff --git a/data/Properties.xml b/data/Properties.xml index a5b1e51..972596e 100644 --- a/data/Properties.xml +++ b/data/Properties.xml @@ -40,6 +40,7 @@ <Property name="report.window.open" type="BOOLEAN" /> <Property name="report.window.editable" type="BOOLEAN" /> <Property name="stockchart.window.open" type="BOOLEAN" /> + <Property name="or.window.dockablePanels" type="BOOLEAN" /> </Section> <Section name="Format"> <Property name="money_format" type="STRING" /> diff --git a/rails/ui/swing/ORWindow.java b/rails/ui/swing/ORWindow.java index 7fcb336..10480c5 100644 --- a/rails/ui/swing/ORWindow.java +++ b/rails/ui/swing/ORWindow.java @@ -6,6 +6,7 @@ import java.awt.Rectangle; import java.awt.event.*; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -20,6 +21,7 @@ import bibliothek.gui.dock.common.theme.ThemeMap; import rails.common.GuiDef; import rails.common.LocalText; +import rails.common.parser.Config; import rails.game.GameManager; import rails.game.OperatingRound; import rails.game.action.*; @@ -75,41 +77,63 @@ public class ORWindow extends JFrame implements ActionPerformer { orPanel = new ORPanel(this, orUIManager); - //build the docking layout - CControl orWindowControl = new CControl( this ); - orWindowControl.setTheme( ThemeMap.KEY_SMOOTH_THEME ); - add( orWindowControl.getContentArea() ); - CGrid orWindowLayout = new CGrid( orWindowControl ); - - //add message panel - DefaultSingleCDockable singleDockable = new DefaultSingleCDockable( - "MessagePanel", "MessagePanel" ); - singleDockable.add( slider, BorderLayout.CENTER ); - singleDockable.setCloseable( false ); - orWindowLayout.add( 0, 0, 100, 10, singleDockable ); - - //add upgrade panel - singleDockable = new DefaultSingleCDockable( - "UpgradePanel", "UpgradePanel" ); - singleDockable.add( upgradePanel, BorderLayout.CENTER ); - singleDockable.setCloseable( false ); - orWindowLayout.add( 0, 10, 20, 70, singleDockable ); - - //add map panel - singleDockable = new DefaultSingleCDockable( - "MapPanel", "MapPanel" ); - singleDockable.add( mapPanel, BorderLayout.CENTER ); - singleDockable.setCloseable( false ); - orWindowLayout.add( 20, 10, 80, 70, singleDockable ); - - //add or panel - singleDockable = new DefaultSingleCDockable( - "ORPanel", "ORPanel" ); - singleDockable.add( orPanel, BorderLayout.CENTER ); - singleDockable.setCloseable( false ); - orWindowLayout.add( 0, 80, 100, 20, singleDockable ); - - orWindowControl.getContentArea().deploy( orWindowLayout ); + //create docking / conventional layout depending config + if (isDockablePanelsEnabled()) { + //DOCKABLE LAYOUT + + //build the docking layout + CControl orWindowControl = new CControl( this ); + orWindowControl.setTheme( ThemeMap.KEY_SMOOTH_THEME ); + add( orWindowControl.getContentArea() ); + CGrid orWindowLayout = new CGrid( orWindowControl ); + + //set docks tooltip language + if ("en_us".equalsIgnoreCase(Config.get("locale"))) { + //hard setting to default in case of US as this is DockingFrames default language + //don't use Locale constant as it is en_US (case sensitive) + orWindowControl.setLanguage(new Locale("")); + } + + //add message panel + DefaultSingleCDockable singleDockable = new DefaultSingleCDockable( + "MessagePanel", "MessagePanel" ); + singleDockable.add( slider, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 0, 100, 10, singleDockable ); + + //add upgrade panel + singleDockable = new DefaultSingleCDockable( + "UpgradePanel", "UpgradePanel" ); + singleDockable.add( upgradePanel, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 10, 20, 70, singleDockable ); + + //add map panel + singleDockable = new DefaultSingleCDockable( + "MapPanel", "MapPanel" ); + singleDockable.add( mapPanel, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 20, 10, 80, 70, singleDockable ); + + //add or panel + singleDockable = new DefaultSingleCDockable( + "ORPanel", "ORPanel" ); + singleDockable.add( orPanel, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 80, 100, 20, singleDockable ); + + orWindowControl.getContentArea().deploy( orWindowLayout ); + + } else { + // CONVENTIONAL LAYOUT + + getContentPane().setLayout(new BorderLayout()); + getContentPane().add(slider, BorderLayout.NORTH); + getContentPane().add(mapPanel, BorderLayout.CENTER); + getContentPane().add(upgradePanel, BorderLayout.WEST); + getContentPane().add(orPanel, BorderLayout.SOUTH); + + } orUIManager.init(this); @@ -148,7 +172,10 @@ public class ORWindow extends JFrame implements ActionPerformer { } }); - //pack(); + //rearrange layout only if no docking framework active + if (!isDockablePanelsEnabled()) { + pack(); + } WindowSettings ws = gameUIManager.getWindowSettings(); Rectangle bounds = ws.getBounds(this); @@ -207,7 +234,10 @@ public class ORWindow extends JFrame implements ActionPerformer { } public void repaintORPanel() { - //orPanel.revalidate(); + //rearrange layout only if no docking framework active + if (!isDockablePanelsEnabled()) { + orPanel.revalidate(); + } } public void activate(OperatingRound or) { @@ -219,14 +249,17 @@ public class ORWindow extends JFrame implements ActionPerformer { gameManager.getORId(), String.valueOf(gameManager.getRelativeORNumber()), numORs )); - /* - pack(); - if (lastBounds != null) { - Rectangle newBounds = getBounds(); - lastBounds.width = newBounds.width; - setBounds (lastBounds); + + //rearrange layout only if no docking framework active + if (!isDockablePanelsEnabled()) { + pack(); + if (lastBounds != null) { + Rectangle newBounds = getBounds(); + lastBounds.width = newBounds.width; + setBounds (lastBounds); + } } - */ + setVisible(true); requestFocus(); } @@ -251,4 +284,8 @@ public class ORWindow extends JFrame implements ActionPerformer { messagePanel.setMessage(""); setTitle(LocalText.getText("MapWindowTitle")); } + + public boolean isDockablePanelsEnabled() { + return "yes".equals(Config.get("or.window.dockablePanels")); + } } commit 2608a348b7b6dfe37b77fc3de3543905e9cf1a5f Author: Frederick Weld <fre...@gm...> Date: Thu Feb 2 13:35:06 2012 +0100 Put ORWindow on docking framework (panels stay as they were before) diff --git a/rails/ui/swing/ORWindow.java b/rails/ui/swing/ORWindow.java index 5c6f5bb..7fcb336 100644 --- a/rails/ui/swing/ORWindow.java +++ b/rails/ui/swing/ORWindow.java @@ -13,6 +13,11 @@ import javax.swing.JScrollPane; import org.apache.log4j.Logger; +import bibliothek.gui.dock.common.CControl; +import bibliothek.gui.dock.common.CGrid; +import bibliothek.gui.dock.common.DefaultSingleCDockable; +import bibliothek.gui.dock.common.theme.ThemeMap; + import rails.common.GuiDef; import rails.common.LocalText; import rails.game.GameManager; @@ -59,24 +64,52 @@ public class ORWindow extends JFrame implements ActionPerformer { gameUIManager.setORUIManager(orUIManager); orUIManager.setGameUIManager(gameUIManager); - getContentPane().setLayout(new BorderLayout()); - messagePanel = new MessagePanel(); JScrollPane slider = new JScrollPane(messagePanel); messagePanel.setParentSlider(slider); - getContentPane().add(slider, BorderLayout.NORTH); - - mapPanel = new MapPanel(gameUIManager); - getContentPane().add(mapPanel, BorderLayout.CENTER); - - upgradePanel = new UpgradesPanel(orUIManager); - getContentPane().add(upgradePanel, BorderLayout.WEST); addMouseListener(upgradePanel); + mapPanel = new MapPanel(gameUIManager); + orPanel = new ORPanel(this, orUIManager); - getContentPane().add(orPanel, BorderLayout.SOUTH); + + //build the docking layout + CControl orWindowControl = new CControl( this ); + orWindowControl.setTheme( ThemeMap.KEY_SMOOTH_THEME ); + add( orWindowControl.getContentArea() ); + CGrid orWindowLayout = new CGrid( orWindowControl ); + + //add message panel + DefaultSingleCDockable singleDockable = new DefaultSingleCDockable( + "MessagePanel", "MessagePanel" ); + singleDockable.add( slider, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 0, 100, 10, singleDockable ); + + //add upgrade panel + singleDockable = new DefaultSingleCDockable( + "UpgradePanel", "UpgradePanel" ); + singleDockable.add( upgradePanel, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 10, 20, 70, singleDockable ); + + //add map panel + singleDockable = new DefaultSingleCDockable( + "MapPanel", "MapPanel" ); + singleDockable.add( mapPanel, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 20, 10, 80, 70, singleDockable ); + + //add or panel + singleDockable = new DefaultSingleCDockable( + "ORPanel", "ORPanel" ); + singleDockable.add( orPanel, BorderLayout.CENTER ); + singleDockable.setCloseable( false ); + orWindowLayout.add( 0, 80, 100, 20, singleDockable ); + + orWindowControl.getContentArea().deploy( orWindowLayout ); orUIManager.init(this); @@ -115,7 +148,7 @@ public class ORWindow extends JFrame implements ActionPerformer { } }); - pack(); + //pack(); WindowSettings ws = gameUIManager.getWindowSettings(); Rectangle bounds = ws.getBounds(this); @@ -174,7 +207,7 @@ public class ORWindow extends JFrame implements ActionPerformer { } public void repaintORPanel() { - orPanel.revalidate(); + //orPanel.revalidate(); } public void activate(OperatingRound or) { @@ -186,12 +219,14 @@ public class ORWindow extends JFrame implements ActionPerformer { gameManager.getORId(), String.valueOf(gameManager.getRelativeORNumber()), numORs )); + /* pack(); if (lastBounds != null) { Rectangle newBounds = getBounds(); lastBounds.width = newBounds.width; setBounds (lastBounds); } + */ setVisible(true); requestFocus(); } commit 06e5c945cc5c977af10f383edb704c23325d319e Author: Frederick Weld <fre...@gm...> Date: Thu Feb 2 12:13:54 2012 +0100 Added DockingFrames library (LGPL licenced) diff --git a/.classpath b/.classpath index c705fd7..4dd2569 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry excluding="lib/JLayer1.0.1/|lib/batik-1.7/|lib/batik-1.7/|lib/batik-1.7/lib/|lib/batik-1.7/lib/|lib/jgraph5/|lib/jgraph5/|lib/jgrapht-0.7.3/|lib/jgrapht-0.7.3/|lib/junit-4.8.2|lib/log4j-1.2/|lib/log4j-1.2/" kind="src" path=""/> + <classpathentry excluding="lib/JLayer1.0.1/|lib/df_1.1.0/|lib/batik-1.7/|lib/batik-1.7/|lib/batik-1.7/lib/|lib/batik-1.7/lib/|lib/jgraph5/|lib/jgraph5/|lib/jgrapht-0.7.3/|lib/jgrapht-0.7.3/|lib/junit-4.8.2|lib/log4j-1.2/|lib/log4j-1.2/" kind="src" path=""/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="lib" path="lib/log4j-1.2/log4j-1.2.14.jar"/> <classpathentry exported="true" kind="lib" path="lib/jgrapht-0.7.3/jgrapht-jdk1.5.jar"/> @@ -27,5 +27,7 @@ <classpathentry kind="lib" path="lib/batik-1.7/lib/xml-apis-ext.jar"/> <classpathentry kind="lib" path="lib/batik-1.7/lib/batik-anim.jar"/> <classpathentry kind="lib" path="lib/batik-1.7/lib/batik-codec.jar"/> + <classpathentry kind="lib" path="lib/df_1.1.0/dockingFramesCommon.jar"/> + <classpathentry kind="lib" path="lib/df_1.1.0/dockingFramesCore.jar"/> <classpathentry kind="output" path="classes"/> </classpath> diff --git a/build.xml b/build.xml index f58cc8f..c098278 100644 --- a/build.xml +++ b/build.xml @@ -18,6 +18,8 @@ <pathelement location="lib/jgraph5/jgraph.jar"/> <pathelement location="lib/junit-4.8.2/junit.jar"/> <pathelement location="lib/JLayer1.0.1/jl1.0.1.jar"/> + <pathelement location="lib/df_1.1.0/dockingFramesCommon.jar"/> + <pathelement location="lib/df_1.1.0/dockingFramesCore.jar"/> <pathelement location="lib/batik-1.7/lib/batik-transcoder.jar"/> <pathelement location="lib/batik-1.7/lib/batik-dom.jar"/> <pathelement location="lib/batik-1.7/lib/batik-swing.jar"/> @@ -50,6 +52,7 @@ <exclude name="lib/batik-1.7/lib/"/> <exclude name="lib/batik-1.7/lib/"/> <exclude name="lib/JLayer1.0.1"/> + <exclude name="lib/df_1.1.0"/> <exclude name="lib/jgraph5/"/> <exclude name="lib/jgraph5/"/> <exclude name="lib/jgrapht-0.7.3/"/> @@ -75,6 +78,7 @@ <exclude name="lib/batik-1.7/lib/"/> <exclude name="lib/batik-1.7/lib/"/> <exclude name="lib/JLayer1.0.1"/> + <exclude name="lib/df_1.1.0"/> <exclude name="lib/jgraph5/"/> <exclude name="lib/jgraph5/"/> <exclude name="lib/jgrapht-0.7.3/"/> diff --git a/buildRails.xml b/buildRails.xml index e656d8a..07b6d96 100644 --- a/buildRails.xml +++ b/buildRails.xml @@ -65,6 +65,8 @@ <include name="jgraph5/jgraph.jar" /> <include name="junit-4.8.2/junit.jar" /> <include name="JLayer1.0.1/jl1.0.1.jar"/> + <include name="lib/df_1.1.0/dockingFramesCommon.jar"/> + <include name="lib/df_1.1.0/dockingFramesCore.jar"/> <include name="batik-1.7/lib/batik-transcoder.jar" /> <include name="batik-1.7/lib/batik-dom.jar" /> <include name="batik-1.7/lib/batik-swing.jar" /> @@ -110,6 +112,8 @@ ./lib/jgraph5/jgraph.jar ./lib/junit-4.8.2/junit.jar ./lib/JLayer1.0.1/jl1.0.1.jar + ./lib/df_1.1.0/dockingFramesCommon.jar + ./lib/df_1.1.0/dockingFramesCore.jar ./lib/batik-1.7/lib/batik-transcoder.jar ./lib/batik-1.7/lib/batik-dom.jar ./lib/batik-1.7/lib/batik-swing.jar diff --git a/lib/df_1.1.0/dockingFramesCommon.jar b/lib/df_1.1.0/dockingFramesCommon.jar new file mode 100644 index 0000000..e07f52e Binary files /dev/null and b/lib/df_1.1.0/dockingFramesCommon.jar differ diff --git a/lib/df_1.1.0/dockingFramesCore.jar b/lib/df_1.1.0/dockingFramesCore.jar new file mode 100644 index 0000000..0ef9fe9 Binary files /dev/null and b/lib/df_1.1.0/dockingFramesCore.jar differ diff --git a/manifest b/manifest index 924042b..2c8d7aa 100644 --- a/manifest +++ b/manifest @@ -1,3 +1,3 @@ Manifest-Version: 1.0 -Class-Path: ./my.properties ./LocalisedText.properties ./lib/log4j-1.2/log4j-1.2.14.jar ./lib/JLayer1.0.1/jl1.0.1.jar ./lib/batik-1.6/lib/batik-transcoder.jar ./lib/batik-1.6/batik.jar ./lib/batik-1.6/lib/batik-util.jar ./lib/batik-1.6/lib/batik-script.jar ./lib/batik-1.6/lib/batik-bridge.jar ./lib/batik-1.6/lib/batik-ext.jar ./lib/batik-1.6/lib/batik-awt-util.jar ./lib/batik-1.6/lib/batik-dom.jar ./lib/batik-1.6/lib/batik-gvt.jar +Class-Path: ./my.properties ./LocalisedText.properties ./lib/log4j-1.2/log4j-1.2.14.jar ./lib/df_1.1.0/dockingFramesCommon.jar ./lib/df_1.1.0/dockingFramesCore.jar ./lib/JLayer1.0.1/jl1.0.1.jar ./lib/batik-1.6/lib/batik-transcoder.jar ./lib/batik-1.6/batik.jar ./lib/batik-1.6/lib/batik-util.jar ./lib/batik-1.6/lib/batik-script.jar ./lib/batik-1.6/lib/batik-bridge.jar ./lib/batik-1.6/lib/batik-ext.jar ./lib/batik-1.6/lib/batik-awt-util.jar ./lib/batik-1.6/lib/batik-dom.jar ./lib/batik-1.6/lib/batik-gvt.jar Main-Class: rails.util.runGame |