[Jcrossclient-cvs] jcrossclient CFclient.java,1.34,1.35 Changelog,1.40,1.41 StatWin.java,1.6,1.7
Status: Alpha
Brought to you by:
cavesomething
From: <jcr...@li...> - 2006-03-25 00:49:29
|
Update of /cvsroot/jcrossclient/jcrossclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17142 Modified Files: CFclient.java Changelog StatWin.java Log Message: add a change title dialog to the stats window Index: CFclient.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFclient.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** CFclient.java 24 Mar 2006 16:29:50 -0000 1.34 --- CFclient.java 25 Mar 2006 00:49:15 -0000 1.35 *************** *** 1197,1201 **** void addWindows(Container parent) { ! statwin = new StatWin(playerstats); skillwin = new SkillWin(this); invwin = new InvWin(this, allobjects.getPlayerInv()); --- 1197,1201 ---- void addWindows(Container parent) { ! statwin = new StatWin(this, playerstats); skillwin = new SkillWin(this); invwin = new InvWin(this, allobjects.getPlayerInv()); Index: StatWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/StatWin.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** StatWin.java 24 Mar 2006 16:29:55 -0000 1.6 --- StatWin.java 25 Mar 2006 00:49:15 -0000 1.7 *************** *** 19,26 **** import java.awt.*; ! class StatWin extends TextArea ! { PlayerStats playerstats; static public void errmsg(String str) { --- 19,82 ---- import java.awt.*; + import java.awt.event.*; ! class SetTitle extends Dialog implements ActionListener { ! TextField newname; ! CFclient Parent; ! ! public void actionPerformed(ActionEvent evt) { ! String cmd = evt.getActionCommand(); ! if(cmd.equals("Set") ||evt.getSource().equals(newname)) { ! setVisible(false); ! Parent.send_command("title " + get_newtitle()); ! return; ! } ! else if (cmd.equals("Cancel")) { ! setVisible(false); ! return; ! } ! } ! ! public String get_newtitle() { ! return newname.getText(); ! } ! ! public SetTitle(CFclient parent, PlayerStats playerstats) { ! super(parent); ! Parent = parent; ! ! setTitle(new String("Set Title")); ! ! add(new Label("How do you wish to be addressed?"), "North"); ! newname=new TextField(40); ! newname.addActionListener(this); ! add(newname); ! /* make the initial text be the current title, defined as the ! * bit after the first space after player: */ ! newname.setText(playerstats.playerTitle.substring( ! playerstats.playerTitle.indexOf(' ', 8))); ! ! Button set, cancel; ! ! set=new Button("Set"); ! cancel =new Button("Cancel"); ! Panel buttonholder=new Panel(); ! buttonholder.setLayout(new FlowLayout()); ! set.addActionListener(this); ! cancel.addActionListener(this); ! buttonholder.add(set); ! buttonholder.add(cancel); ! add(buttonholder, "South"); ! } ! } ! ! ! class StatWin extends Panel implements ActionListener { PlayerStats playerstats; + TextArea MainArea; + ScrollPane scrollpane; + Button namebutton; + CFclient toplevel; + SetTitle set_title; static public void errmsg(String str) { *************** *** 30,36 **** /* redraw the stats box */ public void updateStats() { StringBuffer newtext = new StringBuffer(); - - newtext.append(playerstats.playerTitle+"\n"); newtext.append("Exp: "+playerstats.exp+" Level: "+playerstats.level+"\n"); newtext.append("Hp: "+playerstats.hp+"/"+playerstats.maxhp+"\n"); --- 86,91 ---- /* redraw the stats box */ public void updateStats() { + namebutton.setLabel(playerstats.playerTitle); StringBuffer newtext = new StringBuffer(); newtext.append("Exp: "+playerstats.exp+" Level: "+playerstats.level+"\n"); newtext.append("Hp: "+playerstats.hp+"/"+playerstats.maxhp+"\n"); *************** *** 62,77 **** newtext.append(playerstats.attunements_display(-2)); } ! setText(newtext.toString()); } ! public StatWin(PlayerStats pl) { ! // evil, evil! But no other way. sigh. ! super("", 0, 0, SCROLLBARS_VERTICAL_ONLY); playerstats = pl; ! setEditable(false); ! setRows(7); ! setColumns(30); updateStats(); --- 117,146 ---- newtext.append(playerstats.attunements_display(-2)); } ! MainArea.setText(newtext.toString()); } ! public void actionPerformed(ActionEvent evt) { ! set_title=new SetTitle(toplevel, playerstats); ! set_title.pack(); ! set_title.setVisible(true); ! } ! ! public StatWin(CFclient tl, PlayerStats pl) { ! ! super(new BorderLayout()); ! MainArea = new TextArea("", 0, 0, TextArea.SCROLLBARS_NONE); ! namebutton = new Button(); ! namebutton.addActionListener(this); ! scrollpane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); ! scrollpane.add(MainArea); ! this.add(namebutton, "North"); ! this.add(scrollpane); playerstats = pl; + toplevel = tl; ! MainArea.setEditable(false); ! MainArea.setRows(7); ! MainArea.setColumns(30); updateStats(); Index: Changelog =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Changelog,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Changelog 24 Mar 2006 16:29:54 -0000 1.40 --- Changelog 25 Mar 2006 00:49:15 -0000 1.41 *************** *** 298,299 **** --- 298,303 ---- - paint the server list + 25/03/2006 - CFclient - pass the CFclient object to StatWin + + StatWin - Make the player's name a button, which brings up + a dialog to set title when pressed. |