From: MadMetzger <mad...@us...> - 2011-01-10 20:19:32
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/gui/j2d In directory sfp-cvsdas-4.v30.ch3.sourceforge.com:/tmp/cvs-serv13826/src/games/stendhal/client/gui/j2d Added Files: RemovableSprite.java AchievementBoxFactory.java Removed Files: Text.java Log Message: add handling of reached_achievements events client side by drawing just a figure that's not visible --- Text.java DELETED --- --- NEW FILE: AchievementBoxFactory.java --- package games.stendhal.client.gui.j2d; import games.stendhal.client.sprite.ImageSprite; import games.stendhal.client.sprite.Sprite; import java.awt.Color; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.RenderingHints; import java.awt.Transparency; public class AchievementBoxFactory { private Graphics2D graphics; public AchievementBoxFactory(Graphics2D graphics) { this.graphics = graphics; } /** * Create a sprite for a reached achievement * @param title * @param description * @param category * @return the drawn sprite */ public Sprite createAchievementBox(String title, String description, String category) { System.out.println("Ich würde jetzt malen, wenn ich wüsste wie..."); final GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); final Image image = gc.createCompatibleImage(50, 50, Transparency.BITMASK); final Graphics2D g2d = (Graphics2D) image.getGraphics(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setColor(Color.RED); g2d.fill3DRect(0, 0, 100, 100, true); g2d.setColor(Color.BLUE); g2d.fill3DRect(1, 1, 99, 99, true); return new ImageSprite(image); } } --- NEW FILE: RemovableSprite.java --- /* $Id: RemovableSprite.java,v 1.1 2011/01/10 20:19:23 madmetzger Exp $ */ /*************************************************************************** * (C) Copyright 2003 - Marauroa * *************************************************************************** *************************************************************************** * * * This program 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. * * * ***************************************************************************/ package games.stendhal.client.gui.j2d; import games.stendhal.client.sprite.Sprite; import java.awt.Graphics; import java.awt.Rectangle; public class RemovableSprite { public static final long STANDARD_PERSISTENCE_TIME = 5000; private final int x; private final int y; protected final Sprite sprite; protected long removeTime; /** * Create a new text object. * * @param sprite * @param x x coordinate relative to the game screen * @param y y coordinate relative to the game screen * @param persistTime life time of the text object in milliseconds, or * 0 for <code>STANDARD_PERSISTENCE_TIME</code> */ public RemovableSprite(final Sprite sprite, final int x, final int y, final long persistTime) { this.sprite = sprite; this.x = x; this.y = y; if (persistTime == 0) { removeTime = System.currentTimeMillis() + STANDARD_PERSISTENCE_TIME; } else { removeTime = System.currentTimeMillis() + persistTime; } } public void draw(final Graphics g) { sprite.draw(g, x, y); } public Rectangle getArea() { return new Rectangle(x, y, sprite.getWidth(), sprite.getHeight()); } public int getX() { return x; } public int getY() { return y; } /** * Check if the <code>Text</code> is old enough to be removed. * * @return <code>true</code> if the text should be removed */ public boolean shouldBeRemoved() { return (System.currentTimeMillis() >= removeTime); } } |