From: Jonathan F. <jon...@ya...> - 2008-11-17 06:18:05
|
Hello all, I haven't looked at the code in over a year (and really only lurked before that), so I thought I'd find something to fix to justify my continued presence. Here's a quick fix to ReportWindow that (a) installs a clearer border around the text, and (b) causes the scrollbar to wait until the text has been repainted before recomputing where the "bottom" of the window is. The (ab)use of a JLabel for the purpose of displaying the game log, which makes it impossible to select/copy the text, can be a lower-priority problem since all the info in this window is also available in the debug log file. -- Jonathan swing $ diff -u ReportWindow.java.orig ReportWindow.java --- ReportWindow.java.orig 2008-11-16 22:03:40.984375000 -0800 +++ ReportWindow.java 2008-11-16 16:30:58.203125000 -0800 @@ -32,6 +32,8 @@ message.setBackground(Color.WHITE); message.setOpaque(true); message.setVerticalAlignment(SwingConstants.TOP); + message.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + messagePanel = new JPanel(new GridBagLayout()); messageScroller = new JScrollPane(message, @@ -47,9 +49,6 @@ setSize(400, 400); setLocation(600, 400); - - messagePanel.setBorder(BorderFactory.createEtchedBorder()); - setTitle("Rails: Game log"); addWindowListener(this); addKeyListener(this); @@ -62,7 +61,11 @@ buffer.insert(buffer.length() - 7, newText.replaceAll("\n", "<br>")); messageWindow.message.setText(buffer.toString()); - messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); + } + }); } } |
From: Erik V. <eri...@hc...> - 2008-11-18 22:23:46
|
Jonathan, Thanks for this fix, which repairs a long-standing annoyance (at least to me). I have committed it into CVS. If you know a better way than a JLabel to achieve the same effect, I'd like to know it. This was the only way I could manage it. I think a separate and well-readable window report is needed for various reasons, not the least one being that, certainly in internet play, players would like to see a written account of the game actions, not cluttered by other log info. The format is like game reports I have seen published on the Internet, and indeed intended to be suitable for saving, emailing (PBEM), publishing etc. Erik. > -----Original Message----- > From: Jonathan Ferro [mailto:jon...@ya...] > Sent: Monday 17 November 2008 07:18 > To: rai...@li... > Subject: [Rails-devel] delurking with a quick ReportWindow fix > > Hello all, > > I haven't looked at the code in over a year (and really only > lurked before that), so I thought I'd find something to fix > to justify my continued presence. Here's a quick fix to > ReportWindow that (a) installs a clearer border around the > text, and (b) causes the scrollbar to wait until the text has > been repainted before recomputing where the "bottom" of the > window is. The (ab)use of a JLabel for the purpose of > displaying the game log, which makes it impossible to > select/copy the text, can be a lower-priority problem since > all the info in this window is also available in the debug log file. > > -- Jonathan > > swing $ diff -u ReportWindow.java.orig ReportWindow.java > --- ReportWindow.java.orig 2008-11-16 22:03:40.984375000 -0800 > +++ ReportWindow.java 2008-11-16 16:30:58.203125000 -0800 > @@ -32,6 +32,8 @@ > message.setBackground(Color.WHITE); > message.setOpaque(true); > message.setVerticalAlignment(SwingConstants.TOP); > + message.setBorder(BorderFactory.createEmptyBorder(5, > 5, 5, 5)); > + > messagePanel = new JPanel(new GridBagLayout()); > messageScroller = > new JScrollPane(message, > @@ -47,9 +49,6 @@ > > setSize(400, 400); > setLocation(600, 400); > - > - messagePanel.setBorder(BorderFactory.createEtchedBorder()); > - > setTitle("Rails: Game log"); > addWindowListener(this); > addKeyListener(this); > @@ -62,7 +61,11 @@ > buffer.insert(buffer.length() - 7, > newText.replaceAll("\n", "<br>")); > > messageWindow.message.setText(buffer.toString()); > - > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > + SwingUtilities.invokeLater(new Runnable() { > + public void run() { > + > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > + } > + }); > } > } > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |
From: Jonathan F. <jon...@ya...> - 2008-11-19 22:49:48
|
> If you know a better way than a JLabel to achieve the same effect, I'd like > to know it. This was the only way I could manage it. OK, done (appended) and it was much easier than I thought. In the process I destaticified some things, which felt like the right thing to do but please check it over. > I think a separate and well-readable window report is needed for various > reasons, not the least one being that, certainly in internet play, players > would like to see a written account of the game actions, not cluttered by > other log info. > The format is like game reports I have seen published on the Internet, and > indeed intended to be suitable for saving, emailing (PBEM), publishing etc. I think a next step might be to have the "game report" be separated from other debug logging by having it be completely regenerable from the same game history that undo uses. I've lost track--does the undo trail now include the entire game, or are there still unundoable actions that cause it to be truncated? -- Jonathan diff -r -x CVS -u --strip-trailing-cr 18xx.orig/rails/ui/swing/GameUIManager.java 18xx/rails/ui/swing/GameUIManager.java --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 13:35:29.000000000 -0700 +++ 18xx/rails/ui/swing/GameUIManager.java 2008-11-19 13:52:56.640625000 -0800 @@ -124,7 +124,7 @@ log.debug("==Result from server: " + result); activeWindow.displayServerMessage(); - ReportWindow.addLog(); + reportWindow.addLog(); // End of game checks if (gameManager.isGameOver()) { diff -r -x CVS -u --strip-trailing-cr 18xx.orig/rails/ui/swing/ORUIManager.java 18xx/rails/ui/swing/ORUIManager.java --- 18xx.orig/rails/ui/swing/ORUIManager.java 2008-10-12 07:36:44.000000000 -0700 +++ 18xx/rails/ui/swing/ORUIManager.java 2008-11-19 13:54:08.859375000 -0800 @@ -350,7 +350,7 @@ displayRemainingTiles(); } - ReportWindow.addLog(); + gameUIManager.reportWindow.addLog(); } /** Stub, can be overridden in subclasses */ diff -r -x CVS -u --strip-trailing-cr 18xx.orig/rails/ui/swing/ORWindow.java 18xx/rails/ui/swing/ORWindow.java --- 18xx.orig/rails/ui/swing/ORWindow.java 2008-06-30 13:35:29.000000000 -0700 +++ 18xx/rails/ui/swing/ORWindow.java 2008-11-19 13:54:20.078125000 -0800 @@ -77,7 +77,7 @@ setSize(800, 600); addWindowListener(this); - ReportWindow.addLog(); + gameUIManager.reportWindow.addLog(); } public ORUIManager getORUIManager() { diff -r -x CVS -u --strip-trailing-cr 18xx.orig/rails/ui/swing/ReportWindow.java 18xx/rails/ui/swing/ReportWindow.java --- 18xx.orig/rails/ui/swing/ReportWindow.java 2008-11-18 14:12:50.000000000 -0800 +++ 18xx/rails/ui/swing/ReportWindow.java 2008-11-19 13:57:43.781250000 -0800 @@ -15,29 +15,28 @@ public class ReportWindow extends JFrame implements WindowListener, KeyListener { private static final long serialVersionUID = 1L; - private JLabel message; + private JTextArea message; private JScrollPane messageScroller; private JScrollBar vbar; private JPanel messagePanel; - private static ReportWindow messageWindow; + private ReportWindow messageWindow; private GameManager gameManager; - private static StringBuffer buffer = new StringBuffer("<html></html>"); - public ReportWindow(GameManager gameManager) { messageWindow = this; this.gameManager = gameManager; - message = new JLabel(""); + message = new JTextArea(); + message.setEditable(false); + message.setLineWrap(false); message.setBackground(Color.WHITE); message.setOpaque(true); - message.setVerticalAlignment(SwingConstants.TOP); message.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); messagePanel = new JPanel(new GridBagLayout()); messageScroller = new JScrollPane(message, - ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, + ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); vbar = messageScroller.getVerticalScrollBar(); GridBagConstraints gbc = new GridBagConstraints(); @@ -55,12 +54,10 @@ } - public static void addLog() { + public void addLog() { String newText = ReportBuffer.get(); if (newText.length() > 0) { - buffer.insert(buffer.length() - 7, newText.replaceAll("\n", "<br>")); - - messageWindow.message.setText(buffer.toString()); + message.append(newText); SwingUtilities.invokeLater(new Runnable() { public void run() { messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); |
From: Erik V. <eri...@hc...> - 2008-11-19 23:29:36
|
Thanks. I'll try it out in the coming days, but on first sight the code looks good. I remember I had tried JTextArea before, but can't remember why I abandoned it. We'll see. Some answers below. > > If you know a better way than a JLabel to achieve the same > effect, I'd like > > > to know it. This was the only way I could manage it. > > OK, done (appended) and it was much easier than I thought. > In the process I destaticified some things, which felt like > the right thing to do but please check it over. Yes, I want to get rid of (most) statics. > > I think a separate and well-readable window report is > needed for various > > reasons, not the least one being that, certainly in > internet play, players > > would like to see a written account of the game actions, > not cluttered by > > other log info. > > The format is like game reports I have seen published on > the Internet, and > > indeed intended to be suitable for saving, emailing (PBEM), > publishing etc. > > I think a next step might be to have the "game report" be > separated from other debug logging by having it be completely > regenerable from the same game history that undo uses. I've > lost track--does the undo trail now include the entire game, > or are there still unundoable actions that cause it to be truncated? The fact that the report messages are also added to the log (as INFO) looks logical to me. I don't see why that should be avoided. The undo trail indeed covers the whole game, but the actions contained in it are much more granular: just the movements of the game pieces (cards, tokens) and cash, and status variable changes. I don't think the report messages can be reconstructed from such low-level movements. Saving the high-level game actions (PossibleAction instances) would have been another option, but that would have required lots of code to figure out the detailed consequences of those actions (and undoing these) from a different (post-action) game state than is now done from the pre-action state. I did not consider that to be a viable option. As undo/redo works now, it's pretty much invisible to the main code. All that needs be done is to make sure that all changes are applied by creating an instance of a Move subclass, or by calling a setter in a State subclass, and to call MoveSet.start() and MoveSet.finish() at the right moments. The internals of the move package handle all the rest of it. BTW Talking about reports and undo: currently Undo and Redo just write these words to the report. In stead, I would like Undo to remove the corresponding lines from the report. But *not* by keeping all versions of the whole report window in memory! I'm looking for a somewhat more intelligent way of linking ReportBuffer with MoveSet, so that each MoveSet contains just the latest addition(s) to the report window. It should not be too difficult, but I haven't got to it yet. Erik. |
From: Erik V. <eri...@hc...> - 2008-11-21 20:50:31
|
OK, I have picked up and committed these changes. One comment: It took me some trouble to apply these patches (I must add immediately that I have never worked with diff patches before). On lines like --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 13:35:29.000000000 -0700 it seems that Eclipse considers the date/time stuff as a part of the filename; I had to remove that. And the "orig" part I had to remove as well. Otherwise, thanks. Erik. > -----Original Message----- > From: Jonathan Ferro [mailto:jon...@ya...] > Sent: Wednesday 19 November 2008 23:50 > To: Development list for Rails: an 18xx game > Subject: Re: [Rails-devel] delurking with a quick ReportWindow fix > > > If you know a better way than a JLabel to achieve the same > effect, I'd like > > > to know it. This was the only way I could manage it. > > OK, done (appended) and it was much easier than I thought. > In the process I destaticified some things, which felt like > the right thing to do but please check it over. > > > I think a separate and well-readable window report is > needed for various > > reasons, not the least one being that, certainly in > internet play, players > > would like to see a written account of the game actions, > not cluttered by > > other log info. > > The format is like game reports I have seen published on > the Internet, and > > indeed intended to be suitable for saving, emailing (PBEM), > publishing etc. > > I think a next step might be to have the "game report" be > separated from other debug logging by having it be completely > regenerable from the same game history that undo uses. I've > lost track--does the undo trail now include the entire game, > or are there still unundoable actions that cause it to be truncated? > > -- Jonathan > > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/GameUIManager.java > 18xx/rails/ui/swing/GameUIManager.java > --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 > 13:35:29.000000000 -0700 > +++ 18xx/rails/ui/swing/GameUIManager.java 2008-11-19 > 13:52:56.640625000 -0800 > @@ -124,7 +124,7 @@ > log.debug("==Result from server: " + result); > activeWindow.displayServerMessage(); > > - ReportWindow.addLog(); > + reportWindow.addLog(); > > // End of game checks > if (gameManager.isGameOver()) { > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/ORUIManager.java > 18xx/rails/ui/swing/ORUIManager.java > --- 18xx.orig/rails/ui/swing/ORUIManager.java 2008-10-12 > 07:36:44.000000000 -0700 > +++ 18xx/rails/ui/swing/ORUIManager.java 2008-11-19 > 13:54:08.859375000 -0800 > @@ -350,7 +350,7 @@ > displayRemainingTiles(); > } > > - ReportWindow.addLog(); > + gameUIManager.reportWindow.addLog(); > } > > /** Stub, can be overridden in subclasses */ > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/ORWindow.java > 18xx/rails/ui/swing/ORWindow.java > --- 18xx.orig/rails/ui/swing/ORWindow.java 2008-06-30 > 13:35:29.000000000 -0700 > +++ 18xx/rails/ui/swing/ORWindow.java 2008-11-19 > 13:54:20.078125000 -0800 > @@ -77,7 +77,7 @@ > setSize(800, 600); > addWindowListener(this); > > - ReportWindow.addLog(); > + gameUIManager.reportWindow.addLog(); > } > > public ORUIManager getORUIManager() { > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/ReportWindow.java > 18xx/rails/ui/swing/ReportWindow.java > --- 18xx.orig/rails/ui/swing/ReportWindow.java 2008-11-18 > 14:12:50.000000000 -0800 > +++ 18xx/rails/ui/swing/ReportWindow.java 2008-11-19 > 13:57:43.781250000 -0800 > @@ -15,29 +15,28 @@ > public class ReportWindow extends JFrame implements > WindowListener, KeyListener { > > private static final long serialVersionUID = 1L; > - private JLabel message; > + private JTextArea message; > private JScrollPane messageScroller; > private JScrollBar vbar; > private JPanel messagePanel; > - private static ReportWindow messageWindow; > + private ReportWindow messageWindow; > private GameManager gameManager; > > - private static StringBuffer buffer = new > StringBuffer("<html></html>"); > - > public ReportWindow(GameManager gameManager) { > messageWindow = this; > this.gameManager = gameManager; > > - message = new JLabel(""); > + message = new JTextArea(); > + message.setEditable(false); > + message.setLineWrap(false); > message.setBackground(Color.WHITE); > message.setOpaque(true); > - message.setVerticalAlignment(SwingConstants.TOP); > message.setBorder(BorderFactory.createEmptyBorder(5, > 5, 5, 5)); > > messagePanel = new JPanel(new GridBagLayout()); > messageScroller = > new JScrollPane(message, > - > ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, > + > ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, > > ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); > vbar = messageScroller.getVerticalScrollBar(); > GridBagConstraints gbc = new GridBagConstraints(); > @@ -55,12 +54,10 @@ > > } > > - public static void addLog() { > + public void addLog() { > String newText = ReportBuffer.get(); > if (newText.length() > 0) { > - buffer.insert(buffer.length() - 7, > newText.replaceAll("\n", "<br>")); > - > - messageWindow.message.setText(buffer.toString()); > + message.append(newText); > SwingUtilities.invokeLater(new Runnable() { > public void run() { > > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |
From: <wak...@gm...> - 2008-11-21 21:05:13
|
It's easier to work with diffs outside of Eclipse. I generally apply patches with the linux patch command and then have Eclipse reload its code view. ---Brett Sent via BlackBerry from T-Mobile -----Original Message----- From: "Erik Vos" <eri...@hc...> Date: Fri, 21 Nov 2008 21:50:34 To: 'Development list for Rails: an 18xx game'<rai...@li...> Subject: Re: [Rails-devel] delurking with a quick ReportWindow fix OK, I have picked up and committed these changes. One comment: It took me some trouble to apply these patches (I must add immediately that I have never worked with diff patches before). On lines like --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 13:35:29.000000000 -0700 it seems that Eclipse considers the date/time stuff as a part of the filename; I had to remove that. And the "orig" part I had to remove as well. Otherwise, thanks. Erik. > -----Original Message----- > From: Jonathan Ferro [mailto:jon...@ya...] > Sent: Wednesday 19 November 2008 23:50 > To: Development list for Rails: an 18xx game > Subject: Re: [Rails-devel] delurking with a quick ReportWindow fix > > > If you know a better way than a JLabel to achieve the same > effect, I'd like > > > to know it. This was the only way I could manage it. > > OK, done (appended) and it was much easier than I thought. > In the process I destaticified some things, which felt like > the right thing to do but please check it over. > > > I think a separate and well-readable window report is > needed for various > > reasons, not the least one being that, certainly in > internet play, players > > would like to see a written account of the game actions, > not cluttered by > > other log info. > > The format is like game reports I have seen published on > the Internet, and > > indeed intended to be suitable for saving, emailing (PBEM), > publishing etc. > > I think a next step might be to have the "game report" be > separated from other debug logging by having it be completely > regenerable from the same game history that undo uses. I've > lost track--does the undo trail now include the entire game, > or are there still unundoable actions that cause it to be truncated? > > -- Jonathan > > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/GameUIManager.java > 18xx/rails/ui/swing/GameUIManager.java > --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 > 13:35:29.000000000 -0700 > +++ 18xx/rails/ui/swing/GameUIManager.java 2008-11-19 > 13:52:56.640625000 -0800 > @@ -124,7 +124,7 @@ > log.debug("==Result from server: " + result); > activeWindow.displayServerMessage(); > > - ReportWindow.addLog(); > + reportWindow.addLog(); > > // End of game checks > if (gameManager.isGameOver()) { > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/ORUIManager.java > 18xx/rails/ui/swing/ORUIManager.java > --- 18xx.orig/rails/ui/swing/ORUIManager.java 2008-10-12 > 07:36:44.000000000 -0700 > +++ 18xx/rails/ui/swing/ORUIManager.java 2008-11-19 > 13:54:08.859375000 -0800 > @@ -350,7 +350,7 @@ > displayRemainingTiles(); > } > > - ReportWindow.addLog(); > + gameUIManager.reportWindow.addLog(); > } > > /** Stub, can be overridden in subclasses */ > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/ORWindow.java > 18xx/rails/ui/swing/ORWindow.java > --- 18xx.orig/rails/ui/swing/ORWindow.java 2008-06-30 > 13:35:29.000000000 -0700 > +++ 18xx/rails/ui/swing/ORWindow.java 2008-11-19 > 13:54:20.078125000 -0800 > @@ -77,7 +77,7 @@ > setSize(800, 600); > addWindowListener(this); > > - ReportWindow.addLog(); > + gameUIManager.reportWindow.addLog(); > } > > public ORUIManager getORUIManager() { > diff -r -x CVS -u --strip-trailing-cr > 18xx.orig/rails/ui/swing/ReportWindow.java > 18xx/rails/ui/swing/ReportWindow.java > --- 18xx.orig/rails/ui/swing/ReportWindow.java 2008-11-18 > 14:12:50.000000000 -0800 > +++ 18xx/rails/ui/swing/ReportWindow.java 2008-11-19 > 13:57:43.781250000 -0800 > @@ -15,29 +15,28 @@ > public class ReportWindow extends JFrame implements > WindowListener, KeyListener { > > private static final long serialVersionUID = 1L; > - private JLabel message; > + private JTextArea message; > private JScrollPane messageScroller; > private JScrollBar vbar; > private JPanel messagePanel; > - private static ReportWindow messageWindow; > + private ReportWindow messageWindow; > private GameManager gameManager; > > - private static StringBuffer buffer = new > StringBuffer("<html></html>"); > - > public ReportWindow(GameManager gameManager) { > messageWindow = this; > this.gameManager = gameManager; > > - message = new JLabel(""); > + message = new JTextArea(); > + message.setEditable(false); > + message.setLineWrap(false); > message.setBackground(Color.WHITE); > message.setOpaque(true); > - message.setVerticalAlignment(SwingConstants.TOP); > message.setBorder(BorderFactory.createEmptyBorder(5, > 5, 5, 5)); > > messagePanel = new JPanel(new GridBagLayout()); > messageScroller = > new JScrollPane(message, > - > ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, > + > ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, > > ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); > vbar = messageScroller.getVerticalScrollBar(); > GridBagConstraints gbc = new GridBagConstraints(); > @@ -55,12 +54,10 @@ > > } > > - public static void addLog() { > + public void addLog() { > String newText = ReportBuffer.get(); > if (newText.length() > 0) { > - buffer.insert(buffer.length() - 7, > newText.replaceAll("\n", "<br>")); > - > - messageWindow.message.setText(buffer.toString()); > + message.append(newText); > SwingUtilities.invokeLater(new Runnable() { > public void run() { > > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Rails-devel mailing list Rai...@li... https://lists.sourceforge.net/lists/listinfo/rails-devel |
From: Erik V. <eri...@hc...> - 2008-11-21 22:35:37
|
Hmm, unfortunately I'm one of those poor guys still stuck with Windows. > -----Original Message----- > From: wak...@gm... [mailto:wak...@gm...] > Sent: Friday 21 November 2008 22:00 > To: Development list for Rails: an 18xx game > Subject: Re: [Rails-devel] delurking with a quick ReportWindow fix > > It's easier to work with diffs outside of Eclipse. I > generally apply patches with the linux patch command and then > have Eclipse reload its code view. > > ---Brett > > > Sent via BlackBerry from T-Mobile > > -----Original Message----- > From: "Erik Vos" <eri...@hc...> > > Date: Fri, 21 Nov 2008 21:50:34 > To: 'Development list for Rails: an 18xx > game'<rai...@li...> > Subject: Re: [Rails-devel] delurking with a quick ReportWindow fix > > > OK, I have picked up and committed these changes. > > One comment: > > It took me some trouble to apply these patches (I must add > immediately that > I have never worked with diff patches before). On lines like > --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 > 13:35:29.000000000 -0700 > it seems that Eclipse considers the date/time stuff as a part of the > filename; I had to remove that. > And the "orig" part I had to remove as well. > > Otherwise, thanks. > Erik. > > > -----Original Message----- > > From: Jonathan Ferro [mailto:jon...@ya...] > > Sent: Wednesday 19 November 2008 23:50 > > To: Development list for Rails: an 18xx game > > Subject: Re: [Rails-devel] delurking with a quick ReportWindow fix > > > > > If you know a better way than a JLabel to achieve the same > > effect, I'd like > > > > > to know it. This was the only way I could manage it. > > > > OK, done (appended) and it was much easier than I thought. > > In the process I destaticified some things, which felt like > > the right thing to do but please check it over. > > > > > I think a separate and well-readable window report is > > needed for various > > > reasons, not the least one being that, certainly in > > internet play, players > > > would like to see a written account of the game actions, > > not cluttered by > > > other log info. > > > The format is like game reports I have seen published on > > the Internet, and > > > indeed intended to be suitable for saving, emailing (PBEM), > > publishing etc. > > > > I think a next step might be to have the "game report" be > > separated from other debug logging by having it be completely > > regenerable from the same game history that undo uses. I've > > lost track--does the undo trail now include the entire game, > > or are there still unundoable actions that cause it to be truncated? > > > > -- Jonathan > > > > diff -r -x CVS -u --strip-trailing-cr > > 18xx.orig/rails/ui/swing/GameUIManager.java > > 18xx/rails/ui/swing/GameUIManager.java > > --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 > > 13:35:29.000000000 -0700 > > +++ 18xx/rails/ui/swing/GameUIManager.java 2008-11-19 > > 13:52:56.640625000 -0800 > > @@ -124,7 +124,7 @@ > > log.debug("==Result from server: " + result); > > activeWindow.displayServerMessage(); > > > > - ReportWindow.addLog(); > > + reportWindow.addLog(); > > > > // End of game checks > > if (gameManager.isGameOver()) { > > diff -r -x CVS -u --strip-trailing-cr > > 18xx.orig/rails/ui/swing/ORUIManager.java > > 18xx/rails/ui/swing/ORUIManager.java > > --- 18xx.orig/rails/ui/swing/ORUIManager.java 2008-10-12 > > 07:36:44.000000000 -0700 > > +++ 18xx/rails/ui/swing/ORUIManager.java 2008-11-19 > > 13:54:08.859375000 -0800 > > @@ -350,7 +350,7 @@ > > displayRemainingTiles(); > > } > > > > - ReportWindow.addLog(); > > + gameUIManager.reportWindow.addLog(); > > } > > > > /** Stub, can be overridden in subclasses */ > > diff -r -x CVS -u --strip-trailing-cr > > 18xx.orig/rails/ui/swing/ORWindow.java > > 18xx/rails/ui/swing/ORWindow.java > > --- 18xx.orig/rails/ui/swing/ORWindow.java 2008-06-30 > > 13:35:29.000000000 -0700 > > +++ 18xx/rails/ui/swing/ORWindow.java 2008-11-19 > > 13:54:20.078125000 -0800 > > @@ -77,7 +77,7 @@ > > setSize(800, 600); > > addWindowListener(this); > > > > - ReportWindow.addLog(); > > + gameUIManager.reportWindow.addLog(); > > } > > > > public ORUIManager getORUIManager() { > > diff -r -x CVS -u --strip-trailing-cr > > 18xx.orig/rails/ui/swing/ReportWindow.java > > 18xx/rails/ui/swing/ReportWindow.java > > --- 18xx.orig/rails/ui/swing/ReportWindow.java 2008-11-18 > > 14:12:50.000000000 -0800 > > +++ 18xx/rails/ui/swing/ReportWindow.java 2008-11-19 > > 13:57:43.781250000 -0800 > > @@ -15,29 +15,28 @@ > > public class ReportWindow extends JFrame implements > > WindowListener, KeyListener { > > > > private static final long serialVersionUID = 1L; > > - private JLabel message; > > + private JTextArea message; > > private JScrollPane messageScroller; > > private JScrollBar vbar; > > private JPanel messagePanel; > > - private static ReportWindow messageWindow; > > + private ReportWindow messageWindow; > > private GameManager gameManager; > > > > - private static StringBuffer buffer = new > > StringBuffer("<html></html>"); > > - > > public ReportWindow(GameManager gameManager) { > > messageWindow = this; > > this.gameManager = gameManager; > > > > - message = new JLabel(""); > > + message = new JTextArea(); > > + message.setEditable(false); > > + message.setLineWrap(false); > > message.setBackground(Color.WHITE); > > message.setOpaque(true); > > - message.setVerticalAlignment(SwingConstants.TOP); > > message.setBorder(BorderFactory.createEmptyBorder(5, > > 5, 5, 5)); > > > > messagePanel = new JPanel(new GridBagLayout()); > > messageScroller = > > new JScrollPane(message, > > - > > ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, > > + > > ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, > > > > ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); > > vbar = messageScroller.getVerticalScrollBar(); > > GridBagConstraints gbc = new GridBagConstraints(); > > @@ -55,12 +54,10 @@ > > > > } > > > > - public static void addLog() { > > + public void addLog() { > > String newText = ReportBuffer.get(); > > if (newText.length() > 0) { > > - buffer.insert(buffer.length() - 7, > > newText.replaceAll("\n", "<br>")); > > - > > - messageWindow.message.setText(buffer.toString()); > > + message.append(newText); > > SwingUtilities.invokeLater(new Runnable() { > > public void run() { > > > > messageWindow.vbar.setValue(messageWindow.vbar.getMaximum()); > > > > > > -------------------------------------------------------------- > > ----------- > > This SF.Net email is sponsored by the Moblin Your Move > > Developer's challenge > > Build the coolest Linux based applications with Moblin SDK & > > win great prizes > > Grand prize is a trip for two to an Open Source event > > anywhere in the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > Rails-devel mailing list > > Rai...@li... > > https://lists.sourceforge.net/lists/listinfo/rails-devel > > > > > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > -------------------------------------------------------------- > ----------- > This SF.Net email is sponsored by the Moblin Your Move > Developer's challenge > Build the coolest Linux based applications with Moblin SDK & > win great prizes > Grand prize is a trip for two to an Open Source event > anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Rails-devel mailing list > Rai...@li... > https://lists.sourceforge.net/lists/listinfo/rails-devel > |
From: John A. T. <ja...@ja...> - 2008-11-21 23:09:48
|
On Fri, 21 Nov 2008, Erik Vos wrote: > Hmm, unfortunately I'm one of those poor guys still stuck with Windows. Patch is avaialble for windows, plus you can use Tortoise to apply patches. -- John A. Tamplin ja...@ja... 770/436-5387 HOME 4116 Manson Ave Smyrna, GA 30082-3723 |
From: John A. T. <jat...@ja...> - 2008-11-21 21:05:04
|
On Fri, 21 Nov 2008, Erik Vos wrote: > It took me some trouble to apply these patches (I must add immediately that > I have never worked with diff patches before). On lines like > --- 18xx.orig/rails/ui/swing/GameUIManager.java 2008-06-30 > 13:35:29.000000000 -0700 > it seems that Eclipse considers the date/time stuff as a part of the > filename; I had to remove that. > And the "orig" part I had to remove as well. You should just be able to run patch -p1 <patchfile to apply the diffs -- -p1 tells it to strip off 1 path component, which in this case would be 18xx, so you should be in the top of your working copy. -- John A. Tamplin ja...@ja... 770/436-5387 HOME 4116 Manson Ave Smyrna, GA 30082-3723 |
From: Jonathan F. <jon...@ya...> - 2008-11-22 09:49:20
|
> It took me some trouble to apply these patches (I must add immediately that > I have never worked with diff patches before). The most recent information that I had is that "unified diff" was still the preferred format for beginning contributions. If that should be changed, just let me know. I don't see how to save the contents of an Eclipse "source compare" view in any meaningful way. I must add that whenever a non-coding task can be performed in Cygwin/Emacs instead of Eclipse, I almost always do so. :-) -- Jonathan |
From: brett l. <wak...@gm...> - 2008-11-22 17:01:00
|
On Sat, Nov 22, 2008 at 1:49 AM, Jonathan Ferro <jon...@ya...> wrote: >> It took me some trouble to apply these patches (I must add immediately that > >> I have never worked with diff patches before). > > The most recent information that I had is that "unified diff" was still the preferred format for beginning contributions. If that should be changed, just let me know. > > I don't see how to save the contents of an Eclipse "source compare" view in any meaningful way. I must add that whenever a non-coding task can be performed in Cygwin/Emacs instead of Eclipse, I almost always do so. :-) > > -- Jonathan > > I prefer unified diffs. Not only are there a bunch of tools built around using them, it is a very readable format for sending them in e-mail and being able to comment on them. ---Brett. |
From: Erik V. <eri...@hc...> - 2008-11-22 17:22:42
|
> The most recent information that I had is that "unified diff" > was still the preferred format for beginning contributions. > If that should be changed, just let me know. > > I don't see how to save the contents of an Eclipse "source > compare" view in any meaningful way. I must add that > whenever a non-coding task can be performed in Cygwin/Emacs > instead of Eclipse, I almost always do so. :-) Eclipse can create unified diffs via (right-click)Team/Create Patch, see example below. The paths in this patch do have date/time, so that can't have been the problem after all. And this patch can be applied via Team/Apply Patch. Perhaps it's more important that there is no "orig" in the paths; indeed I also had to remove that stuff and make both paths equal to have Eclipse accept the previous patches. N.B. The below patch only removes some dead code. I have committed it. Erik ### Eclipse Workspace Patch 1.0 #P Rails Index: rails/game/GameManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/GameManager.java,v retrieving revision 1.35 diff -u -r1.35 GameManager.java --- rails/game/GameManager.java 26 Oct 2008 20:47:37 -0000 1.35 +++ rails/game/GameManager.java 22 Nov 2008 17:12:15 -0000 @@ -54,7 +54,6 @@ protected int currentNumberOfOperatingRounds = 1; protected boolean skipFirstStockRound = false; - //protected boolean companiesCanBuyPrivates = false; protected boolean gameEndsWithBankruptcy = false; protected int gameEndsWhenBankHasLessOrEqual = 0; protected boolean gameEndsAfterSetOfORs = true; @@ -542,8 +541,6 @@ } // Note: round may have changed! - // log.debug("Calling setPossibleActions for round - // "+getCurrentRound().toString()); possibleActions.clear(); getCurrentRound().setPossibleActions(); @@ -612,8 +609,7 @@ } public void finishShareSellingRound() { - // currentRound = interruptedRound; - setRound(interruptedRound); + setRound(interruptedRound); ((OperatingRound) getCurrentRound()).resumeTrainBuying(); } @@ -815,57 +811,14 @@ } } - /* - public static void setCompaniesCanBuyPrivates() { - instance.companiesCanBuyPrivates = true; - } - */ - public String getHelp() { return getCurrentRound().getHelp(); } - /* - public static void setHasAnyParPrice(boolean hasAnyParPrice) { - instance.hasAnyParPrice = hasAnyParPrice; - } - */ - public boolean canAnyCompanyHoldShares() { return canAnyCompanyHoldShares; } - /* - public static void setCanAnyCompanyHoldShares( - boolean canAnyCompanyHoldShares) { - instance.canAnyCompanyHoldShares = canAnyCompanyHoldShares; - } - */ - - /* - public static boolean canAnyCompBuyPrivates() { - return instance.canAnyCompBuyPrivates; - } - */ - - /* - public static void setCanAnyCompBuyPrivates(boolean canAnyCompBuyPrivates) { - instance.canAnyCompanyBuyPrivates = canAnyCompBuyPrivates; - } - */ - - /* - public static boolean doBonusTokensExist() { - return instance.bonusTokensExist; - } - */ - - /* - public static void setBonusTokensExist(boolean bonusTokensExist) { - instance.bonusTokensExist = bonusTokensExist; - } - */ - public String getClassName (Defs.ClassName key) { switch (key) { |
From: brett l. <wak...@gm...> - 2008-11-22 17:33:41
|
On Sat, Nov 22, 2008 at 9:22 AM, Erik Vos <eri...@hc...> wrote: >> The most recent information that I had is that "unified diff" >> was still the preferred format for beginning contributions. >> If that should be changed, just let me know. >> >> I don't see how to save the contents of an Eclipse "source >> compare" view in any meaningful way. I must add that >> whenever a non-coding task can be performed in Cygwin/Emacs >> instead of Eclipse, I almost always do so. :-) > > Eclipse can create unified diffs via (right-click)Team/Create Patch, see > example below. > The paths in this patch do have date/time, so that can't have been the > problem after all. > And this patch can be applied via Team/Apply Patch. > > Perhaps it's more important that there is no "orig" in the paths; indeed I > also had to remove that stuff and make both paths equal to have Eclipse > accept the previous patches. > This is likely the issue. The patch command has a flag to specify the number of directories to strip off the patch's location. > N.B. The below patch only removes some dead code. I have committed it. > > Erik > ---Brett |