From: Sean B. <sbr...@ya...> - 2007-07-21 16:40:22
|
This is checked in with commit, http://triplea.svn.sourceforge.net/viewvc/triplea?view=rev&revision=1856 Thanks, Sean --- Gansito Frito <gan...@gm...> wrote: > Hi all, > > I attached the updated patch. > > Thanks, > Gansito > > > Sean Bridges wrote, On 7/14/2007 12:30 PM: > > I think this needs to be optional. It would be > good > > in the lobby, but for a game it is a bit much. > Also, > > could you use SimpleDateFormat to format the time. > > > Something like > > > > SimpleDateFormat f = new SimpleDateFormat(...); > > f.format(new Date)); > > > > > > --- Gansito Frito <gan...@gm...> wrote: > > > > > >> Hi all, > >> > >> This patch adds the time to a chat message, so it > >> would show up like: > >> > >> (17:47:02) Gansito Frito: Blah Blah Blah > >> > >> I always like to see the time during a chat, I > >> believe there was a > >> feature request filed for it as well. > >> > >> I hope you like it, > >> Gansito > >> > >>> Index: > >>> > >> games/strategy/engine/chat/ChatMessagePanel.java > >> > >> > > > =================================================================== > > > >> --- > games/strategy/engine/chat/ChatMessagePanel.java > >> (revision 1841) > >> +++ > games/strategy/engine/chat/ChatMessagePanel.java > >> (working copy) > >> @@ -22,12 +22,30 @@ > >> import games.strategy.net.INode; > >> import games.strategy.triplea.sound.SoundPath; > >> > >> -import java.awt.*; > >> +import java.awt.BorderLayout; > >> +import java.awt.Container; > >> +import java.awt.Insets; > >> import java.awt.event.ActionEvent; > >> -import java.util.*; > >> +import java.util.Calendar; > >> +import java.util.Collection; > >> +import java.util.Collections; > >> > >> -import javax.swing.*; > >> -import javax.swing.text.*; > >> +import javax.swing.AbstractAction; > >> +import javax.swing.Action; > >> +import javax.swing.BoundedRangeModel; > >> +import javax.swing.InputMap; > >> +import javax.swing.JButton; > >> +import javax.swing.JOptionPane; > >> +import javax.swing.JPanel; > >> +import javax.swing.JScrollPane; > >> +import javax.swing.JTextField; > >> +import javax.swing.JTextPane; > >> +import javax.swing.KeyStroke; > >> +import javax.swing.SwingUtilities; > >> +import javax.swing.text.BadLocationException; > >> +import javax.swing.text.Document; > >> +import javax.swing.text.SimpleAttributeSet; > >> +import javax.swing.text.StyleConstants; > >> > >> /** > >> * A Chat window. > >> @@ -216,11 +234,19 @@ > >> final String message = > >> trimMessage(originalMessage); > >> try > >> { > >> + Calendar > >> calendar=Calendar.getInstance(); > >> + int > >> hour=calendar.get(Calendar.HOUR_OF_DAY); > >> + int > >> minute=calendar.get(Calendar.MINUTE); > >> + int > >> second=calendar.get(Calendar.SECOND); > >> + String hourStr=(hour>=10 ? hour+"" : > >> "0"+hour); > >> + String minuteStr=(minute>=10 ? > >> minute+"" : "0"+minute); > >> + String secondStr=(second>=10 ? > >> second+"" : "0"+second); > >> + String > >> > time=("("+hourStr+":"+minuteStr+":"+secondStr+")"); > >> Document doc = m_text.getDocument(); > >> if(thirdperson) > >> - > doc.insertString(doc.getLength(), > >> "*"+from, bold); > >> + > doc.insertString(doc.getLength(), > >> "* "+time+" "+from, bold); > >> else > >> - > doc.insertString(doc.getLength(), > >> from+": ", bold); > >> + > doc.insertString(doc.getLength(), > >> time +" "+ from+": ", bold); > >> doc.insertString(doc.getLength()," > >> "+message + "\n", normal); > >> > >> //don't let the chat get too big > >> > > > ------------------------------------------------------------------------- > > > >> This SF.net email is sponsored by DB2 Express > >> Download DB2 Express C - the FREE version of DB2 > >> express and take > >> control of your XML. No limits. Just data. Click > to > >> get it now. > >> http://sourceforge.net/powerbar/db2/> > >> > > _______________________________________________ > > > >> Triplea-developers mailing list > >> Tri...@li... > >> > >> > > > https://lists.sourceforge.net/lists/listinfo/triplea-developers > > > > > > > > > > > > > ____________________________________________________________________________________ > > Expecting? Get great news right away with email > Auto-Check. > > Try the Yahoo! Mail Beta. > > > http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html > > > > > > > Index: > C:/Files/eclipseworkspace/TripleA/src/games/strategy/triplea/ui/TripleAFrame.java > =================================================================== > --- > C:/Files/eclipseworkspace/TripleA/src/games/strategy/triplea/ui/TripleAFrame.java > (revision 1848) > +++ > C:/Files/eclipseworkspace/TripleA/src/games/strategy/triplea/ui/TripleAFrame.java > (working copy) > @@ -1398,6 +1398,11 @@ > { > return m_statsPanel; > } > + > + void setShowChatTime(boolean showTime) > + { > + m_chatPanel.setShowChatTime(showTime); > + } > } > > > Index: > C:/Files/eclipseworkspace/TripleA/src/games/strategy/triplea/ui/TripleaMenu.java > =================================================================== > --- > C:/Files/eclipseworkspace/TripleA/src/games/strategy/triplea/ui/TripleaMenu.java > (revision 1848) > +++ > C:/Files/eclipseworkspace/TripleA/src/games/strategy/triplea/ui/TripleaMenu.java > (working copy) > @@ -177,9 +177,30 @@ > addShowUnits(menuView); > addMapSkinsMenu(menuView); > addShowMapDetails(menuView); > + addChatTimeMenu(menuView); > > } > + > + private void addChatTimeMenu(JMenu parentMenu) > + { > + final JCheckBoxMenuItem chatTimeBox = new > JCheckBoxMenuItem("Show Chat Times"); > + > + chatTimeBox.addActionListener(new > ActionListener() > + { > > + public void actionPerformed(ActionEvent > e) > + { > + > m_frame.setShowChatTime(chatTimeBox.isSelected()); > + > + } > + > + }); > + > + chatTimeBox.setSelected(false); > + parentMenu.add(chatTimeBox); > + > + } > + > > private void addZoomMenu(JMenu menuGame) > { > Index: > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/chat/ChatPanel.java > =================================================================== > --- > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/chat/ChatPanel.java > (revision 1848) > +++ > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/chat/ChatPanel.java > (working copy) > @@ -109,6 +109,11 @@ > > m_chatPlayerPanel.setPlayerRenderer(renderer); > > } > + > + public void setShowChatTime(boolean showTime) > + { > + m_chatMessagePanel.setShowTime(showTime); > + } > > > > Index: > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/chat/ChatMessagePanel.java > =================================================================== > --- > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/chat/ChatMessagePanel.java > (revision 1848) > +++ > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/chat/ChatMessagePanel.java > (working copy) > @@ -22,12 +22,32 @@ > import games.strategy.net.INode; > import games.strategy.triplea.sound.SoundPath; > > -import java.awt.*; > +import java.awt.BorderLayout; > +import java.awt.Container; > +import java.awt.Insets; > import java.awt.event.ActionEvent; > -import java.util.*; > +import java.text.SimpleDateFormat; > +import java.util.Calendar; > +import java.util.Collection; > +import java.util.Collections; > +import java.util.Date; > > -import javax.swing.*; > -import javax.swing.text.*; > +import javax.swing.AbstractAction; > +import javax.swing.Action; > +import javax.swing.BoundedRangeModel; > +import javax.swing.InputMap; > +import javax.swing.JButton; > +import javax.swing.JOptionPane; > +import javax.swing.JPanel; > +import javax.swing.JScrollPane; > +import javax.swing.JTextField; > +import javax.swing.JTextPane; > +import javax.swing.KeyStroke; > +import javax.swing.SwingUtilities; > +import javax.swing.text.BadLocationException; > +import javax.swing.text.Document; > +import javax.swing.text.SimpleAttributeSet; > +import javax.swing.text.StyleConstants; > > /** > * A Chat window. > @@ -49,6 +69,9 @@ > private JButton m_setStatus; > private Chat m_chat; > > + private boolean m_showTime=false; > + > + private final SimpleDateFormat simpleDateFormat > = new SimpleDateFormat("'('HH:mm:ss')'"); > > private final SimpleAttributeSet bold = new > SimpleAttributeSet(); > private final SimpleAttributeSet italic = new > SimpleAttributeSet(); > @@ -119,6 +142,11 @@ > { > return m_chat; > } > + > + public void setShowTime(boolean showTime) > + { > + m_showTime = showTime; > + } > > private void layoutComponents() > { > @@ -216,11 +244,12 @@ > final String message = > trimMessage(originalMessage); > try > { > + String time=simpleDateFormat.format(new > Date()); > Document doc = m_text.getDocument(); > if(thirdperson) > - doc.insertString(doc.getLength(), > "*"+from, bold); > + doc.insertString(doc.getLength(), > (m_showTime ? "* "+time+" "+from : "* "+from), > bold); > else > - doc.insertString(doc.getLength(), > from+": ", bold); > + doc.insertString(doc.getLength(), > (m_showTime ? time +" "+ from+": " : from+": "), > bold); > doc.insertString(doc.getLength()," > "+message + "\n", normal); > > //don't let the chat get too big > Index: > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/lobby/client/ui/LobbyFrame.java > =================================================================== > --- > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/lobby/client/ui/LobbyFrame.java > (revision 1848) > +++ > C:/Files/eclipseworkspace/TripleA/src/games/strategy/engine/lobby/client/ui/LobbyFrame.java > (working copy) > @@ -49,6 +49,7 @@ > > private final LobbyClient m_client; > > + private final ChatMessagePanel > m_chatMessagePanel; > > > public LobbyFrame(LobbyClient client) > @@ -59,8 +60,10 @@ > === message truncated ===> ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 > express and take > control of your XML. No limits. Just data. Click to > get it now. > http://sourceforge.net/powerbar/db2/> _______________________________________________ > Triplea-developers mailing list > Tri...@li... > https://lists.sourceforge.net/lists/listinfo/triplea-developers > ____________________________________________________________________________________ Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games. http://sims.yahoo.com/ |