package subconscious.graphics.widget; import subconscious.Actor; import subconscious.graphics.Palette; import subconscious.graphics.Fonts; import java.awt.Graphics2D; import java.awt.Dimension; public class ActorInfo extends Widget { public static final int WIDTH = 250; public static final int HEIGHT = 100; protected Actor observingActor = null; public ActorInfo(String uniqueName) { super(uniqueName, 0, 0, ActorInfo.WIDTH, ActorInfo.HEIGHT); } @Override public void render(Graphics2D g) { // background g.setColor(Palette.WHITE_T); g.fillRect(0, 0, ActorInfo.WIDTH, ActorInfo.HEIGHT); // border // g.setColor(Palette.BLACK); // g.drawRect(0, 0, this.width, this.height); g.setColor(Palette.BLACK); // draw title g.setFont(Fonts.TITLE); final int titleY = BORDER + g.getFontMetrics().getHeight(); g.drawString("Character", BORDER, titleY); g.setFont(Fonts.DEFAULT); final int postTitleY = BORDER * 2 + titleY; if (observingActor == null) { drawLineString(g, "No character selected", BORDER, postTitleY, 0); return; } // draw HP drawLineString(g, "Name : " + observingActor.getName(), BORDER, postTitleY, 0); drawLineString(g, "HP : " + Integer.toString(observingActor.getHP()), BORDER, postTitleY, 1); // TODO: show actor properties } public void setActor(Actor actor) { this.observingActor = actor; } public synchronized void unsetActor() { this.observingActor = null; } }