From: Miguel A. B. L. <ari...@us...> - 2005-10-19 16:03:51
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18376/src/games/stendhal/client/gui Modified Files: InGameGUI.java j2DClient.java Log Message: Inventory working at 90%. Only fails when moving from chest to slot or a multiple slot on player ( none by now ) to chest. Index: InGameGUI.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/InGameGUI.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** InGameGUI.java 18 Oct 2005 17:24:45 -0000 1.40 --- InGameGUI.java 19 Oct 2005 16:03:31 -0000 1.41 *************** *** 169,172 **** --- 169,173 ---- if(param[0] instanceof Entity) { + // From floor to inventory RPAction action=new RPAction(); action.put("type","equip"); *************** *** 178,188 **** else if(param[0] instanceof wtDroppableArea) { RPAction action=new RPAction(); action.put("type","moveequip"); ! action.put("targetslot",((wtDroppableArea)param[1]).getName()); action.put("targetobject",playerid); ! action.put("sourceslot",((wtDroppableArea)param[0]).getName()); ! action.put("sourceobject",playerid); InGameGUI.this.client.send(action); } --- 179,206 ---- else if(param[0] instanceof wtDroppableArea) { + // From another droppable area to inventory RPAction action=new RPAction(); + + wtDroppableArea sourceSlot=((wtDroppableArea)param[0]); //left_003 + wtDroppableArea targetSlot=((wtDroppableArea)param[1]); //bag + + logger.info("Drop slot "+sourceSlot.getName()+" to slot "+targetSlot.getName()); action.put("type","moveequip"); ! action.put("targetslot",targetSlot.getName()); action.put("targetobject",playerid); ! if(sourceSlot.getName().startsWith("left")) ! { ! // To inspected object ! action.put("baseobject",inspectedEntity.getID().getObjectID()); ! action.put("sourceslot","content"); ! } ! else ! { ! // To player ! action.put("baseobject",playerid); ! action.put("sourceslot",sourceSlot.getName()); ! } ! InGameGUI.this.client.send(action); } *************** *** 229,248 **** public void onAction(Object... param) { - /**TODO: FIXME: BUG: Code this correctly.*/ if(param[0] instanceof Entity) { RPAction action=new RPAction(); action.put("type","equip"); action.put("target",((Entity)param[0]).getID().getObjectID()); ! action.put("slot",((wtDroppableArea)param[1]).getName()); InGameGUI.this.client.send(action); } else if(param[0] instanceof wtDroppableArea) { RPAction action=new RPAction(); action.put("type","moveequip"); ! action.put("targetslot",((wtDroppableArea)param[1]).getName()); ! action.put("sourceslot",((wtDroppableArea)param[0]).getName()); InGameGUI.this.client.send(action); } } --- 247,294 ---- public void onAction(Object... param) { if(param[0] instanceof Entity) { + // Moved from floor to droppable area + logger.info("Drop object "+param[0]+" to slot "+((wtDroppableArea)param[1]).getName()); RPAction action=new RPAction(); action.put("type","equip"); action.put("target",((Entity)param[0]).getID().getObjectID()); ! /* It doesn't matter which droppable area we use, the slot name is ! * content for chests and corpses. */ ! action.put("slot","content"); ! action.put("baseobject",inspectedEntity.getID().getObjectID()); InGameGUI.this.client.send(action); } else if(param[0] instanceof wtDroppableArea) { + // Move from other droppable area to droppable object + wtDroppableArea sourceSlot=((wtDroppableArea)param[0]); + wtDroppableArea targetSlot=((wtDroppableArea)param[1]); + + logger.info("Drop slot "+sourceSlot.getName()+" to slot "+targetSlot.getName()); RPAction action=new RPAction(); action.put("type","moveequip"); ! ! /* It doesn't matter which droppable area we use, the slot name is ! * content for chests and corpses. */ ! action.put("targetslot","content"); ! action.put("targetobject",inspectedEntity.getID().getObjectID()); ! ! action.put("sourceslot",sourceSlot.getName()); ! if(sourceSlot.getName().startsWith("left")) ! { ! // To inspected object ! action.put("baseobject",inspectedEntity.getID().getObjectID()); ! } ! else ! { ! // To player ! int playerid=client.getPlayer().getID().getObjectID(); ! action.put("baseobject",playerid); ! } ! InGameGUI.this.client.send(action); + + logger.info("Action: "+action); } } *************** *** 533,536 **** --- 579,584 ---- if(e.isShiftDown()) { + /* We are going to use shift to move to previous/next line of text with arrows + * so we just ignore the keys if shift is pressed. */ return; } *************** *** 538,541 **** --- 586,590 ---- if(e.getKeyCode()==KeyEvent.VK_L && e.isControlDown()) { + /* Ifwe Ctrl+L we set the Game log dialog visible */ client.getGameLogDialog().setVisible(true); } *************** *** 545,552 **** --- 594,603 ---- if(e.isControlDown()) { + // We use Ctrl+arrow to face action.put("type","face"); } else { + // While arrow only moves the player action.put("type","move"); } *************** *** 583,586 **** --- 634,638 ---- case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: + // Notify server that player is stopped. int keys=(pressed.containsKey(KeyEvent.VK_LEFT)?1:0)+(pressed.containsKey(KeyEvent.VK_RIGHT)?1:0)+(pressed.containsKey(KeyEvent.VK_UP)?1:0)+(pressed.containsKey(KeyEvent.VK_DOWN)?1:0); if(keys==1) *************** *** 614,617 **** --- 666,670 ---- if (e.getKeyChar() == 27) { + // On ESC key we stop the player and RPAction rpaction=new RPAction(); rpaction.put("type","stop"); *************** *** 628,631 **** --- 681,686 ---- } + /** This methods inspects an entity by enabling all the droppable areas. + * To stop inspecting this method is called with entity=null */ public void inspect(Entity entity, RPSlot slot) { *************** *** 639,642 **** --- 694,698 ---- } + /** Returns true if the given object is being inspected */ public boolean isInspecting(Entity entity, String slot) { *************** *** 658,663 **** --- 714,721 ---- public void draw(GameScreen screen) { + // Draw the inventory graphics screen.drawInScreen(inGameInventory,510,10); + // Draw the inventory's droppable areas for(wtDroppableArea item: droppableAreas) { *************** *** 668,671 **** --- 726,730 ---- if(player!=null) { + // For each of the existing slots we draw the item in it. String[] slots=new String[]{"lhand","rhand","armor","bag"}; for(String slotName: slots) *************** *** 674,679 **** { RPSlot slot=player.getSlot(slotName); ! if(slot.size()==1) { wtDroppableArea dropArea=getDroppableArea(slotName); RPObject object=slot.iterator().next(); --- 733,739 ---- { RPSlot slot=player.getSlot(slotName); ! if(slot.size()>0) { + // BUG: Only draws one object... we need a new way of drawing slots. wtDroppableArea dropArea=getDroppableArea(slotName); RPObject object=slot.iterator().next(); *************** *** 683,696 **** } screen.drawInScreen(screen.createString("HP : "+player.get("hp")+"/"+player.get("base_hp"),Color.white),550, 184); screen.drawInScreen(screen.createString("ATK: "+player.get("atk")+" ("+player.get("atk_xp")+")",Color.white),550, 204); screen.drawInScreen(screen.createString("DEF: "+player.get("def")+" ("+player.get("def_xp")+")",Color.white),550, 224); screen.drawInScreen(screen.createString("XP : "+player.get("xp"),Color.white),550, 244); ! if(inspectedSlot!=null) { int i=1; for(RPObject object: inspectedSlot) { wtDroppableArea area=getDroppableArea("left_00"+i); screen.drawInScreen(slot,area.getx()-4,area.gety()-4); --- 743,760 ---- } + // Write player info in screen screen.drawInScreen(screen.createString("HP : "+player.get("hp")+"/"+player.get("base_hp"),Color.white),550, 184); screen.drawInScreen(screen.createString("ATK: "+player.get("atk")+" ("+player.get("atk_xp")+")",Color.white),550, 204); screen.drawInScreen(screen.createString("DEF: "+player.get("def")+" ("+player.get("def_xp")+")",Color.white),550, 224); screen.drawInScreen(screen.createString("XP : "+player.get("xp"),Color.white),550, 244); ! if(inspectedSlot!=null) { + /* If we are inspecting an object, we draw all the objects that the + * inspected object's slot contains. */ int i=1; for(RPObject object: inspectedSlot) { + // BUG: Only draws upto existing areas... we can have a problem with this... wtDroppableArea area=getDroppableArea("left_00"+i); screen.drawInScreen(slot,area.getx()-4,area.gety()-4); *************** *** 698,702 **** i++; } ! if(inspectedEntity.distance(player)>2.5*2.5) { --- 762,767 ---- i++; } ! ! /* If we are far from the inspected object, we stop inspecting it. */ if(inspectedEntity.distance(player)>2.5*2.5) { *************** *** 711,720 **** } } ! ! for(wtDroppableArea item: droppableAreas) ! { ! item.draw(screen); ! } ! for(wtButton button: buttons) { --- 776,781 ---- } } ! ! // Draw any relevant button if needed. for(wtButton button: buttons) { *************** *** 722,725 **** --- 783,787 ---- } + // If there is a context menu (aka Command list) open, draw it if(widgetCommandList!=null) { *************** *** 733,738 **** Point2D p = lastDraggedEvent.getPoint(); screen.drawInScreen(choosenEntity.getSprite(), (int) p.getX(), (int) p.getY()); ! } ! } } --- 795,799 ---- Point2D p = lastDraggedEvent.getPoint(); screen.drawInScreen(choosenEntity.getSprite(), (int) p.getX(), (int) p.getY()); ! } } } Index: j2DClient.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/j2DClient.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** j2DClient.java 18 Oct 2005 21:01:44 -0000 1.53 --- j2DClient.java 19 Oct 2005 16:03:31 -0000 1.54 *************** *** 409,413 **** { oldTime=System.nanoTime(); - System.out.println("FPS: "+Integer.toString(fps)); logger.info("FPS: "+Integer.toString(fps)); fps=0; --- 409,412 ---- |