summary refs log tree commit diff stats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/window/ChoiceWindow.java8
-rw-r--r--src/com/fourisland/fourpuzzle/window/MessageWindow.java6
-rwxr-xr-xsrc/com/fourisland/fourpuzzle/window/SystemGraphic.java50
-rw-r--r--src/com/fourisland/fourpuzzle/window/Window.java25
4 files changed, 65 insertions, 24 deletions
diff --git a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java index 6a82c6a..bf193c1 100755 --- a/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java +++ b/src/com/fourisland/fourpuzzle/window/ChoiceWindow.java
@@ -5,7 +5,6 @@
5 5
6package com.fourisland.fourpuzzle.window; 6package com.fourisland.fourpuzzle.window;
7 7
8import com.fourisland.fourpuzzle.window.SystemGraphic;
9import com.fourisland.fourpuzzle.Audio; 8import com.fourisland.fourpuzzle.Audio;
10import com.fourisland.fourpuzzle.database.Database; 9import com.fourisland.fourpuzzle.database.Database;
11import com.fourisland.fourpuzzle.database.Sound; 10import com.fourisland.fourpuzzle.database.Sound;
@@ -54,11 +53,7 @@ public class ChoiceWindow {
54 53
55 width += SPACER*2; 54 width += SPACER*2;
56 55
57 cacheBase = new BufferedImage(Window.Default.getFullWidth(width), Window.Default.getFullHeight(height), BufferedImage.TYPE_INT_ARGB); 56 cacheBase = Window.Default.getImage(width, height);
58 Graphics2D g2 = cacheBase.createGraphics();
59
60 g2.drawImage(SystemGraphic.getMessageBackground(), 1, 1, Window.Default.getFullWidth(width)-2, Window.Default.getFullHeight(height)-2, null);
61 g2.drawImage(Window.Default.getImage(width, height), 0, 0, null);
62 } 57 }
63 58
64 public void render(Graphics2D g2, int x, int y) 59 public void render(Graphics2D g2, int x, int y)
@@ -81,7 +76,6 @@ public class ChoiceWindow {
81 76
82 if (getSelected().equals(choice)) 77 if (getSelected().equals(choice))
83 { 78 {
84 g2.drawImage(SystemGraphic.getSelectionBackground(), tx-1, ty-fh+3, fw+SPACER-2, fh+SPACER-2, null);
85 g2.drawImage(Window.Selector.getImage(fw-Window.Selector.getLeftX(), fh-Window.Selector.getTopY()), tx-SPACER, ty-fh, null); 79 g2.drawImage(Window.Selector.getImage(fw-Window.Selector.getLeftX(), fh-Window.Selector.getTopY()), tx-SPACER, ty-fh, null);
86 } 80 }
87 81
diff --git a/src/com/fourisland/fourpuzzle/window/MessageWindow.java b/src/com/fourisland/fourpuzzle/window/MessageWindow.java index 9e482ba..ea34ab9 100644 --- a/src/com/fourisland/fourpuzzle/window/MessageWindow.java +++ b/src/com/fourisland/fourpuzzle/window/MessageWindow.java
@@ -38,11 +38,7 @@ public class MessageWindow {
38 38
39 initalizeMessages(message, new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics()); 39 initalizeMessages(message, new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB).createGraphics());
40 40
41 cacheBase = new BufferedImage(Game.WIDTH, Window.Default.getFullHeight(HEIGHT), BufferedImage.TYPE_INT_ARGB); 41 cacheBase = Window.Default.getImage(width, HEIGHT);
42 Graphics2D g2 = cacheBase.createGraphics();
43
44 g2.drawImage(SystemGraphic.getMessageBackground(), 1, 1, Game.WIDTH-2, Window.Default.getFullHeight(HEIGHT)-2, null);
45 g2.drawImage(Window.Default.getImage(width, HEIGHT), 0, 0, null);
46 } 42 }
47 43
48 private void initalizeMessages(String message, Graphics2D g) 44 private void initalizeMessages(String message, Graphics2D g)
diff --git a/src/com/fourisland/fourpuzzle/window/SystemGraphic.java b/src/com/fourisland/fourpuzzle/window/SystemGraphic.java index 99941d9..bc13d0f 100755 --- a/src/com/fourisland/fourpuzzle/window/SystemGraphic.java +++ b/src/com/fourisland/fourpuzzle/window/SystemGraphic.java
@@ -6,10 +6,12 @@
6package com.fourisland.fourpuzzle.window; 6package com.fourisland.fourpuzzle.window;
7 7
8import com.fourisland.fourpuzzle.util.ObjectLoader; 8import com.fourisland.fourpuzzle.util.ObjectLoader;
9import com.fourisland.fourpuzzle.util.TransparentPixelFilter;
9import com.fourisland.fourpuzzle.window.Window.SystemArea; 10import com.fourisland.fourpuzzle.window.Window.SystemArea;
10import java.awt.Color;
11import java.awt.Rectangle; 11import java.awt.Rectangle;
12import java.awt.Toolkit;
12import java.awt.image.BufferedImage; 13import java.awt.image.BufferedImage;
14import java.awt.image.FilteredImageSource;
13 15
14/** 16/**
15 * 17 *
@@ -17,7 +19,7 @@ import java.awt.image.BufferedImage;
17 */ 19 */
18public class SystemGraphic { 20public class SystemGraphic {
19 21
20 private static BufferedImage systemGraphic; 22 private static BufferedImage systemGraphic = null;
21 private static String filename = "System"; 23 private static String filename = "System";
22 public static void setGraphic(String filename) 24 public static void setGraphic(String filename)
23 { 25 {
@@ -26,32 +28,70 @@ public class SystemGraphic {
26 28
27 public static void initalize() 29 public static void initalize()
28 { 30 {
29 systemGraphic = ObjectLoader.getImage("Picture", filename); 31 BufferedImage temp = ObjectLoader.getImage("Picture", filename);
32 systemGraphic = new BufferedImage(160, 80, BufferedImage.TYPE_INT_ARGB);
33
34 systemGraphic.createGraphics().drawImage(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(temp.getRGB(159, 0)))),0,0,null);
30 } 35 }
31 36
32 public static BufferedImage getMessageBackground() 37 public static BufferedImage getMessageBackground()
33 { 38 {
39 if (systemGraphic == null)
40 {
41 initalize();
42 }
43
34 return systemGraphic.getSubimage(0, 0, 32, 32); 44 return systemGraphic.getSubimage(0, 0, 32, 32);
35 } 45 }
36 46
37 public static BufferedImage getSelectionBackground() 47 public static BufferedImage getSelectionBackground()
38 { 48 {
49 if (systemGraphic == null)
50 {
51 initalize();
52 }
53
39 return systemGraphic.getSubimage(Window.Selector.getX(SystemArea.TOP_LEFT)+15, 15, 1, 1); 54 return systemGraphic.getSubimage(Window.Selector.getX(SystemArea.TOP_LEFT)+15, 15, 1, 1);
40 } 55 }
41 56
42 public static BufferedImage getChoiceArea(Rectangle sca) 57 public static BufferedImage getChoiceArea(Rectangle sca)
43 { 58 {
59 if (systemGraphic == null)
60 {
61 initalize();
62 }
63
44 return systemGraphic.getSubimage(sca.x, sca.y, sca.width, sca.height); 64 return systemGraphic.getSubimage(sca.x, sca.y, sca.width, sca.height);
45 } 65 }
46 66
47 public static BufferedImage getTextColor() 67 public static BufferedImage getTextColor()
48 { 68 {
69 if (systemGraphic == null)
70 {
71 initalize();
72 }
73
49 return systemGraphic.getSubimage(0, 48, 16, 16); 74 return systemGraphic.getSubimage(0, 48, 16, 16);
50 } 75 }
51 76
52 public static Color getTransparentColor() 77 public static BufferedImage getUpArrow()
53 { 78 {
54 return new Color(systemGraphic.getRGB(159, 0)); 79 if (systemGraphic == null)
80 {
81 initalize();
82 }
83
84 return systemGraphic.getSubimage(43, 10, 10, 6);
85 }
86
87 public static BufferedImage getDownArrow()
88 {
89 if (systemGraphic == null)
90 {
91 initalize();
92 }
93
94 return systemGraphic.getSubimage(43, 18, 10, 6);
55 } 95 }
56 96
57} 97}
diff --git a/src/com/fourisland/fourpuzzle/window/Window.java b/src/com/fourisland/fourpuzzle/window/Window.java index 8cdaf9a..da3216a 100644 --- a/src/com/fourisland/fourpuzzle/window/Window.java +++ b/src/com/fourisland/fourpuzzle/window/Window.java
@@ -6,13 +6,9 @@
6package com.fourisland.fourpuzzle.window; 6package com.fourisland.fourpuzzle.window;
7 7
8import com.fourisland.fourpuzzle.util.Interval; 8import com.fourisland.fourpuzzle.util.Interval;
9import com.fourisland.fourpuzzle.util.TransparentPixelFilter;
10import java.awt.Graphics2D; 9import java.awt.Graphics2D;
11import java.awt.Image;
12import java.awt.Rectangle; 10import java.awt.Rectangle;
13import java.awt.Toolkit;
14import java.awt.image.BufferedImage; 11import java.awt.image.BufferedImage;
15import java.awt.image.FilteredImageSource;
16 12
17/** 13/**
18 * 14 *
@@ -20,7 +16,13 @@ import java.awt.image.FilteredImageSource;
20 */ 16 */
21public enum Window 17public enum Window
22{ 18{
23 Default(32), 19 Default(32)
20 {
21 protected BufferedImage getBackground()
22 {
23 return SystemGraphic.getMessageBackground();
24 }
25 },
24 Selector(64) 26 Selector(64)
25 { 27 {
26 Interval in = Interval.createTickInterval(4); 28 Interval in = Interval.createTickInterval(4);
@@ -41,6 +43,11 @@ public enum Window
41 return super.getX(sa); 43 return super.getX(sa);
42 } 44 }
43 } 45 }
46
47 protected BufferedImage getBackground()
48 {
49 return SystemGraphic.getSelectionBackground();
50 }
44 }; 51 };
45 52
46 protected enum SystemArea 53 protected enum SystemArea
@@ -118,11 +125,15 @@ public enum Window
118 return getHeight(SystemArea.TOP_LEFT); 125 return getHeight(SystemArea.TOP_LEFT);
119 } 126 }
120 127
121 public Image getImage(int width, int height) 128 protected abstract BufferedImage getBackground();
129
130 public BufferedImage getImage(int width, int height)
122 { 131 {
123 BufferedImage temp = new BufferedImage(getFullWidth(width), getFullHeight(height), BufferedImage.TYPE_INT_ARGB); 132 BufferedImage temp = new BufferedImage(getFullWidth(width), getFullHeight(height), BufferedImage.TYPE_INT_ARGB);
124 Graphics2D g = temp.createGraphics(); 133 Graphics2D g = temp.createGraphics();
125 134
135 g.drawImage(getBackground(), 1, 1, getFullWidth(width)-2, getFullHeight(height)-2, null);
136
126 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_LEFT)), 0, 0, null); 137 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_LEFT)), 0, 0, null);
127 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP)), getWidth(SystemArea.TOP_LEFT), 0, width, getHeight(SystemArea.TOP), null); 138 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP)), getWidth(SystemArea.TOP_LEFT), 0, width, getHeight(SystemArea.TOP), null);
128 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_RIGHT)), getWidth(SystemArea.TOP_LEFT)+width, 0, null); 139 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_RIGHT)), getWidth(SystemArea.TOP_LEFT)+width, 0, null);
@@ -132,6 +143,6 @@ public enum Window
132 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.BOTTOM_RIGHT)), getWidth(SystemArea.BOTTOM_RIGHT)+width, getHeight(SystemArea.TOP_RIGHT)+height, null); 143 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.BOTTOM_RIGHT)), getWidth(SystemArea.BOTTOM_RIGHT)+width, getHeight(SystemArea.TOP_RIGHT)+height, null);
133 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.RIGHT)), (width+getWidth(SystemArea.TOP_LEFT)+getWidth(SystemArea.TOP_RIGHT))-getWidth(SystemArea.RIGHT), getHeight(SystemArea.TOP_RIGHT), getWidth(SystemArea.RIGHT), height, null); 144 g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.RIGHT)), (width+getWidth(SystemArea.TOP_LEFT)+getWidth(SystemArea.TOP_RIGHT))-getWidth(SystemArea.RIGHT), getHeight(SystemArea.TOP_RIGHT), getWidth(SystemArea.RIGHT), height, null);
134 145
135 return Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(SystemGraphic.getTransparentColor().getRGB()))); 146 return temp;
136 } 147 }
137} \ No newline at end of file 148} \ No newline at end of file