無人機動兵器ダンジョン探索ゲーム JAVAベース
チップ表示サイズを変更できるようにした
@@ -20,9 +20,22 @@ | ||
20 | 20 | static final Color redFocusChipColor = new Color(255, 0, 0); |
21 | 21 | static final Color normalCodeColor = new Color(0, 0, 127); |
22 | 22 | static final Color condCodeColor = new Color(127, 0, 127); |
23 | + static int viewChipWidth = 16; | |
24 | + static int viewChipHeight = 16; | |
23 | 25 | Oke.ChipTrace traceData[]; |
24 | 26 | OkeSoftData software; |
25 | 27 | |
28 | + static void setViewChipSize(int w, int h) { | |
29 | + if (w < 8) { | |
30 | + w = 8; | |
31 | + } | |
32 | + if (h < 8) { | |
33 | + h = 8; | |
34 | + } | |
35 | + viewChipWidth = w; | |
36 | + viewChipHeight = h; | |
37 | + } | |
38 | + | |
26 | 39 | /** |
27 | 40 | * コンストラクタ |
28 | 41 | * |
@@ -35,14 +48,14 @@ | ||
35 | 48 | |
36 | 49 | @Override |
37 | 50 | public Dimension getPreferredSize() { |
38 | - return new Dimension(OkeSoftData.CHIPMAXX * 10 + 4, | |
39 | - OkeSoftData.CHIPMAXY * 10 + 4); | |
51 | + return new Dimension(OkeSoftData.CHIPMAXX * viewChipWidth + 4, | |
52 | + OkeSoftData.CHIPMAXY * viewChipHeight + 4); | |
40 | 53 | } |
41 | 54 | |
42 | 55 | @Override |
43 | 56 | public Dimension getMinimumSize() { |
44 | - return new Dimension(OkeSoftData.CHIPMAXX * 10 + 4, | |
45 | - OkeSoftData.CHIPMAXY * 10 + 4); | |
57 | + return new Dimension(OkeSoftData.CHIPMAXX * viewChipWidth + 4, | |
58 | + OkeSoftData.CHIPMAXY * viewChipHeight + 4); | |
46 | 59 | } |
47 | 60 | |
48 | 61 | @Override |
@@ -54,8 +67,8 @@ | ||
54 | 67 | public void paint(Graphics g) { |
55 | 68 | int x; |
56 | 69 | int y; |
57 | - int nwidth = OkeSoftData.CHIPMAXX * 10 + 4; | |
58 | - int nheight = OkeSoftData.CHIPMAXY * 10 + 4; | |
70 | + int nwidth = OkeSoftData.CHIPMAXX * viewChipWidth + 4; | |
71 | + int nheight = OkeSoftData.CHIPMAXY * viewChipHeight + 4; | |
59 | 72 | Image offscreen = createImage(nwidth, nheight); |
60 | 73 | Graphics offg = offscreen.getGraphics(); |
61 | 74 | offg.setColor(baseColor); |
@@ -63,7 +76,8 @@ | ||
63 | 76 | offg.setColor(Color.YELLOW); |
64 | 77 | for (y = 0; y < OkeSoftData.CHIPMAXY; y++) { |
65 | 78 | for (x = 0; x < OkeSoftData.CHIPMAXX; x++) { |
66 | - offg.drawRect(x * 10 + 2, y * 10 + 2, 10, 10); | |
79 | + offg.drawRect(x * viewChipWidth + 2, y * viewChipHeight + 2, | |
80 | + viewChipWidth, viewChipHeight); | |
67 | 81 | } |
68 | 82 | } |
69 | 83 | if (software != null) { |
@@ -73,7 +87,9 @@ | ||
73 | 87 | if (chip.nullchip() == false) { |
74 | 88 | offg.setColor(software.get(x, y).is_condchip() |
75 | 89 | ? condCodeColor : normalCodeColor); |
76 | - offg.fillRect(x * 10 + 2 + 1, y * 10 + 2 + 1, 8, 8); | |
90 | + offg.fillRect(x * viewChipWidth + 2 + 1, | |
91 | + y * viewChipHeight + 2 + 1, | |
92 | + viewChipWidth - 2, viewChipHeight - 2); | |
77 | 93 | } |
78 | 94 | } |
79 | 95 | } |
@@ -84,15 +100,19 @@ | ||
84 | 100 | for (i = 0; i < nmax; i++) { |
85 | 101 | offg.setColor(traceData[i].get_branch() |
86 | 102 | ? redChipColor : greenChipColor); |
87 | - offg.fillRect(traceData[i].get_position_x() * 10 + 2 + 1, | |
88 | - traceData[i].get_position_y() * 10 + 2 + 1, 8, 8); | |
103 | + offg.fillRect( | |
104 | + traceData[i].get_position_x() * viewChipWidth + 2 + 1, | |
105 | + traceData[i].get_position_y() * viewChipHeight + 2 + 1, | |
106 | + viewChipWidth - 2, viewChipHeight - 2); | |
89 | 107 | } |
90 | 108 | if (i > 0) { |
91 | 109 | //最終チップだけフォーカス表示 |
92 | 110 | offg.setColor(traceData[i].get_branch() |
93 | 111 | ? redFocusChipColor : greenFocusChipColor); |
94 | - offg.fillRect(traceData[i].get_position_x() * 10 + 2 + 1, | |
95 | - traceData[i].get_position_y() * 10 + 2 + 1, 8, 8); | |
112 | + offg.fillRect( | |
113 | + traceData[i].get_position_x() * viewChipWidth + 2 + 1, | |
114 | + traceData[i].get_position_y() * viewChipHeight + 2 + 1, | |
115 | + viewChipWidth - 2, viewChipHeight - 2); | |
96 | 116 | } |
97 | 117 | } |
98 | 118 | g.drawImage(offscreen, 0, 0, this); |