summary refs log tree commit diff stats
path: root/src/com/fourisland/fourpuzzle/window/SystemGraphic.java
blob: 75e2b45d0661d33140efc99a58cd07d47e1cdac7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.fourisland.fourpuzzle.window;

import com.fourisland.fourpuzzle.Display;
import com.fourisland.fourpuzzle.util.ObjectLoader;
import com.fourisland.fourpuzzle.util.TransparentPixelFilter;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;

/**
 *
 * @author hatkirby
 */
public class SystemGraphic {
    
    private static BufferedImage systemGraphic = null;
    private static String filename = "System";
    public static void setGraphic(String filename)
    {
        SystemGraphic.filename = filename;
    }
    
    public static void initalize()
    {
        BufferedImage temp = ObjectLoader.getImage("Picture", filename);
        systemGraphic = Display.createCanvas(160, 80);
        
        systemGraphic.createGraphics().drawImage(Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(temp.getRGB(159, 0)))),0,0,null);
    }
    
    public static BufferedImage getMessageBackground()
    {
        if (systemGraphic == null)
        {
            initalize();
        }
        
        return systemGraphic.getSubimage(0, 0, 32, 32);
    }
    
    public static BufferedImage getSelectionBackground(boolean isFlashing)
    {
        if (systemGraphic == null)
        {
            initalize();
        }
        
        return systemGraphic.getSubimage((isFlashing ? 96 : 64) + 15, 15, 1, 1);
    }
    
    public static BufferedImage getChoiceArea(Rectangle sca)
    {
        if (systemGraphic == null)
        {
            initalize();
        }
        
        return systemGraphic.getSubimage(sca.x, sca.y, sca.width, sca.height);
    }
    
    public static BufferedImage getTextColor()
    {
        if (systemGraphic == null)
        {
            initalize();
        }
        
        return systemGraphic.getSubimage(0, 48, 16, 16);
    }
    
    public static BufferedImage getUpArrow()
    {
        if (systemGraphic == null)
        {
            initalize();
        }
        
        return systemGraphic.getSubimage(43, 10, 10, 6);
    }
    
    public static BufferedImage getDownArrow()
    {
        if (systemGraphic == null)
        {
            initalize();
        }
        
        return systemGraphic.getSubimage(43, 18, 10, 6);
    }

}