source: last-defense/gamegui/Window.java

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

Initial commit, code decompiled from a jar

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