[Jcrossclient-cvs] jcrossclient MagicMap.java,NONE,1.1 CFclient.java,1.26,1.27 Changelog,1.30,1.31 S
Status: Alpha
Brought to you by:
cavesomething
From: <jcr...@li...> - 2006-01-26 14:53:56
|
Update of /cvsroot/jcrossclient/jcrossclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6124 Modified Files: CFclient.java Changelog StatWin.java Added Files: MagicMap.java Log Message: magic map support --- NEW FILE: MagicMap.java --- /* * Copyright (c) 1997, Phil Brown, ph...@bo... * Copyright (c) 2005, Brendan Lally, bre...@gm... * * This file is part of jcrossclient. * * Jcrossclient is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later version. * * Jcrossclient is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * Jcrossclient; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ //This class handles display of stat-bars. import java.awt.*; import java.awt.event.*; class magicmapsquare { static final int FACE_FLOOR = 0x80; static final int FACE_WALL = 0x40; byte colour; boolean is_floor; boolean is_wall; magicmapsquare(byte data) { if ((data & FACE_FLOOR) >0) is_floor = true; if ((data & FACE_WALL) >0) is_wall = true; /* a byte in data corresponds to one we should use in colour, * if it is set in data, and isn't one of the flags */ colour = (byte)(data & 0x0F); } } class MagicMap extends Canvas { magicmapsquare squares[][]; StringBuffer word; char nextchar; int width, height; Graphics gc=null; int playerwidth, playerheight; CFclient Parent; public MagicMap (CFclient parent) { word = new StringBuffer(); } public void parse(String mapdata) { int i,j; int space[] = new int[4]; space[0] = mapdata.indexOf(' '); space[1] = mapdata.indexOf(' ', space[0]+1); space[2] = mapdata.indexOf(' ', space[1]+1); space[3] = mapdata.indexOf(' ', space[2]+1); width = Integer.parseInt(mapdata.substring(0,space[0])); height = Integer.parseInt(mapdata.substring(space[0]+1, space[1])); playerwidth = Integer.parseInt(mapdata.substring(space[1]+1, space[2])); playerheight = Integer.parseInt(mapdata.substring(space[2]+1, space[3])); squares = new magicmapsquare[width][height]; for (i=0; i<height;i++) { for (j=0;j<width;j++) { /* the data starts on the byte after the fourth space, * and goes left to right, top to bottom */ squares[i][j]=new magicmapsquare((byte)mapdata.charAt(space[3]+1+(i*width)+j)); } } repaint(); } public void paint(Graphics gc) { int i,j; /* reset this to black in case it was changed before */ gc.setColor(Color.black); for (i=0; i<width;i++) { for (j=0;j<height;j++) { switch (squares[i][j].colour & 0x0F) { case 0: gc.setColor(Color.black); break; case 1: gc.setColor(Color.white); break; case 2: gc.setColor(Color.blue); break; case 3: gc.setColor(Color.red); break; case 4: gc.setColor(Color.orange); break; case 5: gc.setColor(Color.cyan); break; case 6: gc.setColor(Color.magenta); break; case 7: gc.setColor(Color.green); break; case 8: gc.setColor(Color.green); break; case 9: gc.setColor(Color.gray); break; case 10: gc.setColor(Color.pink); break; case 11: gc.setColor(Color.yellow); break; case 12: gc.setColor(Color.pink); break; default: gc.setColor(Color.black); break; } gc.fillRect(j*8, i*8, 8, 8); } } } } Index: CFclient.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFclient.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** CFclient.java 25 Jan 2006 02:57:58 -0000 1.26 --- CFclient.java 26 Jan 2006 14:53:48 -0000 1.27 *************** *** 139,152 **** CFObjectStore allobjects; ! StatWin statwin; ! SkillWin skillwin; ! InvWin invwin; ! SpellWin spellwin; ! SettingsWin settingswin; ! MapWin mapwin; ! ExamineWin examinewin; ! TalkWin talkwin; ! StatbarWin miscwin; public ScrollPane iscrollp, escrollp, sscrollp, spscrollp; ServerDialog chooseserver; --- 139,154 ---- CFObjectStore allobjects; ! StatWin statwin; ! SkillWin skillwin; ! InvWin invwin; ! SpellWin spellwin; ! SettingsWin settingswin; ! MapWin mapwin; ! ExamineWin examinewin; ! TalkWin talkwin; ! StatbarWin miscwin; ! MagicMap magicmap; public ScrollPane iscrollp, escrollp, sscrollp, spscrollp; + Panel viewpane; ServerDialog chooseserver; *************** *** 523,526 **** --- 525,532 ---- } + if (cmd.equals("Toggle Map")) { + CardLayout cl = (CardLayout)viewpane.getLayout(); + cl.next(viewpane); + } if(cmd.equals("Debug on")) { debugflag=true; *************** *** 920,927 **** } } - - void MagicMapCmd(String cmd) { - debug("Ignoring MagicMapCmd\n"); - } void PlayerCmd(DataInputStream playerdata) throws IOException { --- 926,929 ---- *************** *** 1204,1208 **** return; } ! int size = data.available(); byte[] databa = new byte[size]; --- 1206,1210 ---- return; } ! int size = data.available(); byte[] databa = new byte[size]; *************** *** 1223,1226 **** --- 1225,1232 ---- return; } + if(cmd.startsWith("magicmap")) { + magicmap.parse(datastr); + return; + } if(cmd.startsWith("anim")) { debug("IGNORING anim cmd"); *************** *** 1249,1257 **** return; } - - if(cmd.startsWith("magicmap")) { - MagicMapCmd(datastr); - return; - } if(cmd.startsWith("addme_failed")) { debug("Addme FAILED?!!"); --- 1255,1258 ---- *************** *** 1355,1370 **** talkwin = new TalkWin(this); miscwin = new StatbarWin(this); ! TabPanel leftside = new TabPanel(); ! Panel topside = new VertPanel(); ! Panel rightside = new VertPanel(); ! Panel viewpane = new Panel(new CardLayout()); ! Panel items = new VertPanel(); ! iscrollp= new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); ! spscrollp= new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); ! // ALLWAYS, to not mess with speed of hide/show ! escrollp= new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); ! sscrollp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); iscrollp.setSize(290,210); --- 1356,1372 ---- talkwin = new TalkWin(this); miscwin = new StatbarWin(this); + magicmap = new MagicMap(this); ! TabPanel leftside = new TabPanel(); ! Panel topside = new VertPanel(); ! Panel rightside = new VertPanel(); ! /* we defined this in the main class, because other functions need it */ ! viewpane = new Panel(new CardLayout()); ! Panel items = new VertPanel(); ! iscrollp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); ! spscrollp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); ! escrollp = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS); ! sscrollp = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED); iscrollp.setSize(290,210); *************** *** 1379,1388 **** (escrollp.getVAdjustable()).setUnitIncrement(10); - spscrollp.setSize(290,210); spscrollp.add(spellwin); (spscrollp.getVAdjustable()).setUnitIncrement(10); - sscrollp.add(skillwin); items.add(iscrollp); --- 1381,1388 ---- *************** *** 1394,1404 **** leftside.add("settings", settingswin); viewpane.add("map", mapwin); topside.add(viewpane); topside.add(miscwin); rightside.add(talkwin); - placeWindow(parent, leftside, 0, 0, 1, 3); placeWindow(parent, topside, 1, 0, 1, 3); - placeWindow(parent, rightside, 2, 0, 1, 3); --- 1394,1404 ---- leftside.add("settings", settingswin); viewpane.add("map", mapwin); + viewpane.add("magicmap", magicmap); topside.add(viewpane); topside.add(miscwin); rightside.add(talkwin); + placeWindow(parent, leftside, 0, 0, 1, 3); placeWindow(parent, topside, 1, 0, 1, 3); placeWindow(parent, rightside, 2, 0, 1, 3); *************** *** 1431,1434 **** --- 1431,1435 ---- dmenu.add(newMenuItem("Local refresh")); dmenu.add(newMenuItem("Full redraw")); + dmenu.add(newMenuItem("Toggle Map")); help.add(newMenuItem("Help on jcrossclient")); *************** *** 1479,1485 **** void initWindows() { Frame topwin; - //topwin= new Frame(); - - // new test stuff, this line topwin = this; topwin.setLayout(new GridBagLayout()); --- 1480,1483 ---- Index: StatWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/StatWin.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** StatWin.java 25 Jan 2006 02:57:58 -0000 1.4 --- StatWin.java 26 Jan 2006 14:53:48 -0000 1.5 *************** *** 34,38 **** newtext.append(playerstats.playerTitle+"\n"); newtext.append("Exp: "+playerstats.exp+" Level: "+playerstats.level+"\n"); ! newtext.append("Hp: "+playerstats.hp+" Mana: "+playerstats.mana+" Grace:"+playerstats.gr+"\n"); newtext.append("Str: "+playerstats.Str + "\n"); newtext.append("Dex: "+playerstats.Dex+ "\n"); --- 34,40 ---- newtext.append(playerstats.playerTitle+"\n"); newtext.append("Exp: "+playerstats.exp+" Level: "+playerstats.level+"\n"); ! newtext.append("Hp: "+playerstats.hp+"/"+playerstats.maxhp+"\n"); ! newtext.append("Mana: "+playerstats.mana+"/"+playerstats.maxmana+"\n"); ! newtext.append("Grace: "+playerstats.gr+"/"+playerstats.maxgr+"\n"); newtext.append("Str: "+playerstats.Str + "\n"); newtext.append("Dex: "+playerstats.Dex+ "\n"); Index: Changelog =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Changelog,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Changelog 25 Jan 2006 02:57:58 -0000 1.30 --- Changelog 26 Jan 2006 14:53:48 -0000 1.31 *************** *** 235,236 **** --- 235,244 ---- - display spell paths + 26/01/2005 - CFClient - add a MagicMap to the class, make viewpane a global + - add 'Toggle Map' entry to debug menu, to switch between viewpane cards + - pass of magicmap packets to the magic map class + - remove MagicMapCmd + + StatWin - Show HP, mana and grace on their own lines, along with the maximum values of each + + MagicMap - new file, handles magic map parsing and drawing \ No newline at end of file |