1 | package gamegui;
|
---|
2 |
|
---|
3 | import java.awt.*;
|
---|
4 | import java.awt.event.MouseEvent;
|
---|
5 | import java.util.ArrayList;
|
---|
6 |
|
---|
7 | public class Window extends Member {
|
---|
8 |
|
---|
9 | ArrayList<Member> members;
|
---|
10 | boolean fullscreen;
|
---|
11 |
|
---|
12 | public Window(String newName, int newX, int newY, int newWidth, int newHeight) {
|
---|
13 | super(newName, newX, newY, newWidth, newHeight);
|
---|
14 | this.members = new ArrayList<Member>();
|
---|
15 | }
|
---|
16 |
|
---|
17 | public Window(String newName, int newX, int newY, int newWidth, int newHeight, boolean full) {
|
---|
18 | super(newName, newX, newY, newWidth, newHeight);
|
---|
19 | this.members = new ArrayList<Member>();
|
---|
20 | this.fullscreen = full;
|
---|
21 | }
|
---|
22 |
|
---|
23 | public void draw(Graphics g) {
|
---|
24 | g.setColor(Color.black);
|
---|
25 | g.fillRect(getX(), getY(), getWidth(), getHeight());
|
---|
26 | if (!this.fullscreen) {
|
---|
27 | g.setColor(Color.red);
|
---|
28 | g.drawRect(getX(), getY(), getWidth(), getHeight());
|
---|
29 | }
|
---|
30 | for (int x = 0; x < this.members.size(); x++) {
|
---|
31 | ((Member)this.members.get(x)).draw(g);
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | public boolean handleEvent(MouseEvent e) {
|
---|
36 | boolean val = false;
|
---|
37 | for (int x = 0; x < this.members.size(); x++) {
|
---|
38 | val = !(!val && !((Member)this.members.get(x)).handleEvent(e));
|
---|
39 | }
|
---|
40 | return val;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void clear() {
|
---|
44 | for (int x = 0; x < this.members.size(); x++) {
|
---|
45 | ((Member)this.members.get(x)).clear();
|
---|
46 | }
|
---|
47 | }
|
---|
48 |
|
---|
49 | public void add(Member aMember) {
|
---|
50 | aMember.offset(getX(), getY());
|
---|
51 | this.members.add(aMember);
|
---|
52 | }
|
---|
53 |
|
---|
54 | public void offset(int xOffset, int yOffset) {
|
---|
55 | super.offset(xOffset, yOffset);
|
---|
56 | for (int x = 0; x < this.members.size(); x++) {
|
---|
57 | ((Member)this.members.get(x)).offset(xOffset, yOffset);
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | public Member getMember(String aName) {
|
---|
62 | for (int x = 0; x < this.members.size(); x++) {
|
---|
63 | if (((Member)this.members.get(x)).getName().equals(aName)) {
|
---|
64 | return this.members.get(x);
|
---|
65 | }
|
---|
66 | }
|
---|
67 | return null;
|
---|
68 | }
|
---|
69 | }
|
---|