[Jcrossclient-cvs] jcrossclient CFObjectStore.java,1.4,1.5 CFclient.java,1.35,1.36 Changelog,1.42,1.
Status: Alpha
Brought to you by:
cavesomething
From: <jcr...@li...> - 2006-04-15 17:45:11
|
Update of /cvsroot/jcrossclient/jcrossclient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29338 Modified Files: CFObjectStore.java CFclient.java Changelog InvWin.java MapWin.java Log Message: Initial support for a container view Index: Changelog =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/Changelog,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Changelog 25 Mar 2006 01:25:42 -0000 1.42 --- Changelog 15 Apr 2006 17:45:00 -0000 1.43 *************** *** 304,305 **** --- 304,317 ---- Metaserver - display text of the server the mouse is currently over in a different colour + + 15/04/2006 - InvWin - Remove special case code for items in containers + + Mapwin - update the container view in the map thread + + ContainerWin - new file, handles viewing containers' contents + + CFObjectStore - track the currently open container. + - place items in containers into a special container vector + - add appropriate deletion/updating and inserting code for containers + + CFClient - container support Index: InvWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/InvWin.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** InvWin.java 19 Feb 2006 23:33:49 -0000 1.13 --- InvWin.java 15 Apr 2006 17:45:01 -0000 1.14 *************** *** 337,352 **** //for(int oc=objcount-1; oc>=0; oc--) for (int oc=0; oc<objcount; oc++) { - int inbag_offset=0; - CFObject item = (CFObject)PlayerInventory.elementAt(oc); int Ypos=objpixheight * oc; int Textpos=Ypos+ (objpixheight>>1) +3; - if ((item.getLocation() != playertag) && - (item.getTag() != playertag)) { - inbag_offset=15; - gc.drawString("=>", 0, Textpos); - } - Image face = toplevel.getPixmap(item.getFace()); if (face==null) { --- 337,344 ---- *************** *** 354,359 **** face=toplevel.getPixmap(0); } ! gc.drawImage(face, inbag_offset,Ypos, this); ! gc.drawString(item.getFlaggedName(), objpixheight+10+inbag_offset, Textpos); } --- 346,351 ---- face=toplevel.getPixmap(0); } ! gc.drawImage(face, 0, Ypos, this); ! gc.drawString(item.getFlaggedName(), objpixheight+10, Textpos); } Index: CFclient.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFclient.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** CFclient.java 25 Mar 2006 00:49:15 -0000 1.35 --- CFclient.java 15 Apr 2006 17:45:00 -0000 1.36 *************** *** 96,99 **** --- 96,100 ---- MapWin mapwin; ExamineWin examinewin; + ContainerWin containerwin; TalkWin talkwin; StatbarWin miscwin; *************** *** 328,332 **** cl.show(viewpane, panel); } ! /* Okay, this is somewhat ugly. We register ourselves as the * focus Listener for the mapwin, and other windows, --- 329,342 ---- cl.show(viewpane, panel); } ! ! /* figures out which object is open, and closes it, then sets focus back to ! * the map window. It does not reset the view, this will be done when the ! * appropriate upditem packet is recieved */ ! public void closeContainer() { ! applyObj(allobjects.getOpenContainer().getTag()); ! allobjects.setOpenContainer(null); ! focusGained(null); ! } ! /* Okay, this is somewhat ugly. We register ourselves as the * focus Listener for the mapwin, and other windows, *************** *** 591,594 **** --- 601,607 ---- } + /* if the item is sent to us in an open state, we need to mark it as the container */ + static final int F_OPEN =0x2000; + // add possibly multiple objects, to a single "location" // "location" can be either the floor, the player, or some object. *************** *** 655,661 **** debug("ItemCmd: added object "+tag+", location "+loc+", name "+name+" flags "+flags); ! // need to update, even if location is BAG that ! // player is holding. I suppose. sigh. ! // loc==0, means on floor } } --- 668,672 ---- debug("ItemCmd: added object "+tag+", location "+loc+", name "+name+" flags "+flags); ! if ((flags & F_OPEN) > 0) allobjects.setOpenContainer(newobj); } } *************** *** 669,672 **** --- 680,684 ---- static char UPD_ANIMSPEED =0x40; static char UPD_NROF =0x80; + // delete item(s), no matter where they are located *************** *** 700,703 **** --- 712,725 ---- val = itemdata.readInt(); valpos += 4; + /* if the object has been newly opened, show its contents */ + if (((thisobj.getFlags() & F_OPEN) == 0) && ((val & F_OPEN) > 0)) { + allobjects.setOpenContainer(thisobj); + showmap("container"); + } + /* if the object has been newly closed, show the map */ + if (((thisobj.getFlags() & F_OPEN) > 0) && ((val & F_OPEN) == 0)) { + allobjects.setOpenContainer(thisobj); + showmap(); + } thisobj.setFlags(val); should_update = true; *************** *** 1204,1207 **** --- 1226,1230 ---- mapwin = new MapWin(this); examinewin = new ExamineWin(this, allobjects.getObjsOnFloor()); + containerwin = new ContainerWin(this, allobjects.getContainerObjects()); talkwin = new TalkWin(this); miscwin = new StatbarWin(this); *************** *** 1265,1268 **** --- 1288,1292 ---- viewpane.add("magicmap", magicmap); viewpane.add("metaserver", metapanel); + viewpane.add("container", containerwin); topside.add(viewpane); topside.add(miscwin); *************** *** 1814,1817 **** --- 1838,1846 ---- floorchanged=true; } + + boolean containerchanged=false; + public void updateContainer() { + containerchanged=true; + } // called by MapUpdater thread, in MapWin *************** *** 1823,1826 **** --- 1852,1863 ---- } } + + // called by MapUpdater thread, in MapWin + public void drawContainer() { + if(containerchanged==true) { + containerchanged=false; + containerwin.updateDisplay(); + } + } public void lookat(int dx, int dy) { Index: MapWin.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/MapWin.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MapWin.java 1 Feb 2006 19:14:29 -0000 1.8 --- MapWin.java 15 Apr 2006 17:45:01 -0000 1.9 *************** *** 72,75 **** --- 72,76 ---- } toplevel.drawFloor(); + toplevel.drawContainer(); try { Thread.sleep(sleepms); Index: CFObjectStore.java =================================================================== RCS file: /cvsroot/jcrossclient/jcrossclient/CFObjectStore.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CFObjectStore.java 1 Feb 2006 19:14:29 -0000 1.4 --- CFObjectStore.java 15 Apr 2006 17:45:00 -0000 1.5 *************** *** 48,51 **** --- 48,53 ---- Vector objs_on_floor; // cache Vector PlayerInv; // cache + Vector ContainerObjects; + CFObject OpenContainer; /* the currently open container */ Hashtable AllObjects; *************** *** 73,76 **** --- 75,86 ---- } + CFObject getOpenContainer() { + return OpenContainer; + } + + void setOpenContainer(CFObject container) { + OpenContainer = container; + } + // Maybe we should cache THIS, as well as the floor thing. // dunno. sigh. *************** *** 97,105 **** deleteObjOnFloor(oldobj); toplevel.updateFloor(); ! } ! else { // probably should recurse or something? maybe not. deleteObjInInv(oldobj); toplevel.updateInventory(); } } --- 107,117 ---- deleteObjOnFloor(oldobj); toplevel.updateFloor(); ! } else if (oldobj.getLocation() == PlayerTag) { // probably should recurse or something? maybe not. deleteObjInInv(oldobj); toplevel.updateInventory(); + } else { + deleteObjInCon(oldobj); + toplevel.updateContainer(); } } *************** *** 147,168 **** if(oldloc==0) toplevel.updateFloor(); ! else toplevel.updateInventory(); ! return; } // else... if(oldloc==0) { deleteObjOnFloor(oldobj); ! } ! else { ! if(oldloc >0) { ! deleteObjInInv(oldobj); ! } } if(newloc==0) { objs_on_floor.addElement(newobj); ! } else { PlayerInv.addElement(newobj); Collections.sort(PlayerInv, new CFObjcompare()); } if(oldloc==0 || newloc ==0) --- 159,182 ---- if(oldloc==0) toplevel.updateFloor(); ! else { toplevel.updateInventory(); ! toplevel.updateContainer(); ! } return; } // else... if(oldloc==0) { deleteObjOnFloor(oldobj); ! } else if(oldloc ==PlayerTag) { ! deleteObjInInv(oldobj); ! } else { ! deleteObjInCon(oldobj); } if(newloc==0) { objs_on_floor.addElement(newobj); ! } else if(newloc==PlayerTag) { PlayerInv.addElement(newobj); Collections.sort(PlayerInv, new CFObjcompare()); + } else { + ContainerObjects.addElement(newobj); } if(oldloc==0 || newloc ==0) *************** *** 170,173 **** --- 184,188 ---- if(oldloc>0 || newloc > 0) toplevel.updateInventory(); + toplevel.updateContainer(); } *************** *** 184,202 **** } ! // return Ennumeration of objects carried by the object objtag ! // note: this means DIRECTLY carried. ! // It does not recurse into bags, for example ! public Vector getCarriedBy(int objtag) { ! Vector carried=new Vector(); ! Enumeration objs = AllObjects.elements(); ! CFObject tmpobj; ! while(objs.hasMoreElements()) { ! tmpobj= (CFObject)objs.nextElement(); ! ! if(tmpobj.getLocation() == objtag) { ! carried.addElement(tmpobj); ! } ! } ! return carried; } --- 199,204 ---- } ! public Vector getContainerObjects() { ! return ContainerObjects; } *************** *** 215,218 **** --- 217,226 ---- } } + public void deleteObjInCon(CFObject obj) { + synchronized (objs_on_floor) { + ContainerObjects.removeElement(obj); + } + } + // This is called a lot, so it deserves a special-case // Note that we do NOT trigger a floor update, because *************** *** 248,260 **** debug("delete: trying to delete obj "+tag); ! if(location==0) { ! deleteObjOnFloor(oldobj); ! } ! else { ! deleteObjInInv(oldobj); ! } AllObjects.remove(new Integer(tag)); } ! toplevel.updateInventory(); } --- 256,264 ---- debug("delete: trying to delete obj "+tag); ! deleteObjInCon(oldobj); AllObjects.remove(new Integer(tag)); } ! ContainerObjects.removeAllElements(); ! toplevel.updateContainer(); } *************** *** 265,268 **** --- 269,273 ---- objs_on_floor = new Vector(); PlayerInv = new Vector(); + ContainerObjects = new Vector(); toplevel = top; } |