source: lost-perception/gamegui/Window.java@ ebd3538

Last change on this file since ebd3538 was ebd3538, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Initial commit. This codebase for the Lost Perception game was created by decompiling code from a jar file.

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