From: Kimmo R. <ki...@us...> - 2010-08-22 20:33:01
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/wt In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv31319/src/games/stendhal/client/gui/wt Modified Files: Character.java Log Message: Refresh at content changes. Fixes [3045987] "[Stendhal client] cvs - 'Look' sometimes not working" Index: Character.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/wt/Character.java,v retrieving revision 1.98 retrieving revision 1.99 diff -C2 -d -r1.98 -r1.99 *** Character.java 14 Aug 2010 10:38:42 -0000 1.98 --- Character.java 22 Aug 2010 20:32:52 -0000 1.99 *************** *** 20,25 **** import games.stendhal.client.ClientSingletonRepository; - import games.stendhal.client.GameObjects; import games.stendhal.client.IGameScreen; import games.stendhal.client.entity.IEntity; import games.stendhal.client.entity.User; --- 20,25 ---- import games.stendhal.client.ClientSingletonRepository; import games.stendhal.client.IGameScreen; + import games.stendhal.client.entity.EntityChangeListener; import games.stendhal.client.entity.IEntity; import games.stendhal.client.entity.User; *************** *** 44,48 **** * @author mtotz */ ! public class Character extends WtPanel { /** Height/width of slots. */ private static final int SLOT_SIZE = 39; --- 44,48 ---- * @author mtotz */ ! public class Character extends WtPanel implements EntityChangeListener { /** Height/width of slots. */ private static final int SLOT_SIZE = 39; *************** *** 62,68 **** private User playerEntity; - /** the last player modification counter. */ - private long oldPlayerModificationCount; - /** * Creates a new instance of Character. --- 62,65 ---- *************** *** 145,168 **** public void setPlayer(final User userEntity) { this.playerEntity = userEntity; } /** ! * refreshes the player stats and updates the text/slot panels. ! * ! * @param gameScreen */ ! private void refreshPlayerStats() { ! if (playerEntity == null) { ! return; ! } ! ! if (!playerEntity.isModified(oldPlayerModificationCount)) { ! return; ! } ! ! final GameObjects gameObjects = GameObjects.getInstance(); ! // traverse all carrying slots - for (final String slotName : Constants.CARRYING_SLOTS) { final RPSlot slot = playerEntity.getSlot(slotName); --- 142,154 ---- public void setPlayer(final User userEntity) { this.playerEntity = userEntity; + userEntity.addChangeListener(this); + refreshContents(); } /** ! * Updates the player slot panels. */ ! private void refreshContents() { // traverse all carrying slots for (final String slotName : Constants.CARRYING_SLOTS) { final RPSlot slot = playerEntity.getSlot(slotName); *************** *** 182,194 **** final RPObject object = iter.next(); ! IEntity entity = gameObjects.get(object); ! ! /* ! * TODO: Remove once object mapping verified to work in all ! * cases. ! */ ! if (entity == null) { ! entity = EntityFactory.createEntity(object); ! } entitySlot.setEntity(entity); --- 168,172 ---- final RPObject object = iter.next(); ! IEntity entity = EntityFactory.createEntity(object); entitySlot.setEntity(entity); *************** *** 200,205 **** setTitletext(playerEntity.getName()); - - oldPlayerModificationCount = playerEntity.getModificationCount(); } --- 178,181 ---- *************** *** 213,218 **** @Override protected void drawContent(final Graphics2D g) { - refreshPlayerStats(); - super.drawContent(g); } --- 189,192 ---- *************** *** 222,224 **** --- 196,204 ---- ClientSingletonRepository.getSound().getGroup(SoundLayer.USER_INTERFACE.groupName).play("click-6", 0, null, null, false, true); } + + public void entityChanged(IEntity entity, Object property) { + if (property == IEntity.PROP_CONTENT) { + refreshContents(); + } + } } |