Mercurial > hg > ristipolku
comparison game/Engine.java @ 176:9d3ff9605555
Change AboutBox to a "dialog" and implement Ok/close button for closing it.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Mar 2017 10:44:38 +0200 |
parents | 55ea5821c802 |
children | ac5cf78a1cd2 |
comparison
equal
deleted
inserted
replaced
175:55ea5821c802 | 176:9d3ff9605555 |
---|---|
18 import java.io.*; | 18 import java.io.*; |
19 import game.*; | 19 import game.*; |
20 import javax.sound.sampled.*; | 20 import javax.sound.sampled.*; |
21 | 21 |
22 | 22 |
23 class AboutBox extends IDMWidget | 23 class AboutBox extends IDMContainer |
24 { | 24 { |
25 BufferedImage aboutImg; | 25 BufferedImage aboutImg; |
26 | 26 |
27 public AboutBox() | 27 public AboutBox() |
28 { | 28 { |
29 setPos(150f, 150f); | 29 setPos(150f, 150f); |
30 setSize(720f, 420f); | 30 setSize(720f, 470f); |
31 setModal(true); | |
32 | |
33 add(new BtnOK(500f, 390f)); | |
31 } | 34 } |
32 | 35 |
33 public void paint(Graphics2D g) | 36 public void paint(Graphics2D g) |
34 { | 37 { |
35 g.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.7f)); | 38 g.setPaint(new Color(0.0f, 0.0f, 0.0f, 0.7f)); |
72 drawString(g, | 75 drawString(g, |
73 "\nObjective: Create a path long as possible by rotating\n"+ | 76 "\nObjective: Create a path long as possible by rotating\n"+ |
74 "and placing pieces. More points will be awarded for\n"+ | 77 "and placing pieces. More points will be awarded for\n"+ |
75 "advancing the path by several segments per turn." | 78 "advancing the path by several segments per turn." |
76 ); | 79 ); |
77 } | 80 super.paint(g); |
78 | |
79 public boolean keyPressed(KeyEvent e) | |
80 { | |
81 clicked(); | |
82 return true; | |
83 } | 81 } |
84 | 82 |
85 public void clicked() | 83 public void clicked() |
86 { | 84 { |
87 parent.remove(this); | 85 parent.remove(this); |
86 } | |
87 | |
88 class BtnOK extends IDMButton | |
89 { | |
90 public BtnOK(float x, float y) | |
91 { | |
92 super(x, y, KeyEvent.VK_ESCAPE, G.fonts[1], "OK"); | |
93 } | |
94 | |
95 public void clicked() | |
96 { | |
97 parent.clicked(); | |
98 } | |
88 } | 99 } |
89 } | 100 } |
90 | 101 |
91 | 102 |
92 class GameBoard extends IDMWidget | 103 class GameBoard extends IDMWidget |