From: ChadF <ch...@us...> - 2007-05-27 18:42:43
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/entity In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv19794/src/games/stendhal/client/entity Modified Files: RPEntity.java Log Message: Removed rendering specific code [mostly] from floating message constructor. Almost ready to move drawing code to view. Index: RPEntity.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/entity/RPEntity.java,v retrieving revision 1.180 retrieving revision 1.181 diff -C2 -d -r1.180 -r1.181 *** RPEntity.java 27 May 2007 17:36:19 -0000 1.180 --- RPEntity.java 27 May 2007 18:42:43 -0000 1.181 *************** *** 769,776 **** if(!textIndicators.isEmpty()) { ! if(textIndicators.get(0).getAge() > 2000L) { ! textIndicators.remove(0); ! fireChange(PROP_TEXT_INDICATORS); } } } --- 769,783 ---- if(!textIndicators.isEmpty()) { ! Iterator<TextIndicator> iter = textIndicators.iterator(); ! ! while(iter.hasNext()) { ! TextIndicator textIndicator = iter.next(); ! ! if(textIndicator.addAge(delta) > 2000L) { ! iter.remove(); ! } } + + fireChange(PROP_TEXT_INDICATORS); } } *************** *** 1137,1148 **** public static class TextIndicator { /** ! * The text sprite. */ ! protected Sprite sprite; /** ! * The start time of the message. */ ! protected long start; /** --- 1144,1155 ---- public static class TextIndicator { /** ! * The text color. */ ! protected Color color; /** ! * The age of the message (in ms). */ ! protected long age; /** *************** *** 1160,1166 **** public TextIndicator(final String text, final Color color) { this.text = text; ! sprite = GameScreen.get().createString(text, color); ! start = System.currentTimeMillis(); } --- 1167,1173 ---- public TextIndicator(final String text, final Color color) { this.text = text; + this.color = color; ! age = 0L; } *************** *** 1180,1187 **** long age = getAge(); ! int tx = x + 20 - (sprite.getWidth() / 2); int ty = y - (int) (age * 5L / 300L); ! sprite.draw(g, tx, ty); } --- 1187,1197 ---- long age = getAge(); ! ! int width = g.getFontMetrics().stringWidth(text) + 2; ! ! int tx = x + 20 - (width / 2); int ty = y - (int) (age * 5L / 300L); ! GameScreen.get().drawOutlineString(g, color, text, tx, ty + 10); } *************** *** 1192,1195 **** --- 1202,1219 ---- /** + * Add to the age of this message. + * + * @param time The amout to add. + * + * @return The new age (in milliseconds). + */ + public long addAge(long time) { + age += time; + + return age; + } + + + /** * Get the age of this message. * *************** *** 1197,1201 **** */ public long getAge() { ! return System.currentTimeMillis() - start; } --- 1221,1225 ---- */ public long getAge() { ! return age; } |