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