summaryrefslogtreecommitdiffstats
path: root/src/subconscious/graphics/widget/ActorInfo.java
blob: d381cd2e0e02d32c6ee9abc66fbd510353532a5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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;
	}
}