1 /*
2 * file mi_map.c - background for menus
3 *
4 * $Id: mi_map.c,v 1.7 2006/02/09 21:21:24 fzago Exp $
5 *
6 * Program XBLAST
7 * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation; either version 2; or (at your option)
12 * any later version
13 *
14 * This program is distributed in the hope that it will be entertaining,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include "xblast.h"
25
26 /*
27 * local variables
28 */
29 /* graphics */
30 static BMBlockTile menuBlockTile[MENU_MAX_TILE] = {
31 /* 0 */ {"score_floor", COLOR_BLACK, COLOR_SPRING_GREEN, COLOR_BLACK},
32 /* 1 */ {"score_right_down", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_BLACK},
33 /* 2 */ {"menu_left_up", COLOR_BLACK, COLOR_LIGHT_STEEL_BLUE, COLOR_SPRING_GREEN},
34 /* 3 */ {"menu_right_up", COLOR_BLACK, COLOR_LIGHT_STEEL_BLUE, COLOR_SPRING_GREEN},
35 /* 4 */ {"score_pipe_end", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_SPRING_GREEN},
36 /* 5 */ {"menu_left_down", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_STEEL_BLUE},
37 /* 6 */ {"menu_right_down", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_STEEL_BLUE},
38 /* 7 */ {"score_right_up", COLOR_BLACK, COLOR_LIGHT_STEEL_BLUE, COLOR_BLACK},
39 /* 8 */ {"score_pipe_mid", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_BLACK},
40 /* 9 */ {"score_pipe_begin", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_BLACK},
41 /* 10 */ {"menu_left", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
42 /* 11 */ {"menu_center", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
43 /* 12 */ {"menu_right", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
44 /* 13 */ {"menu_list_center", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
45 /* 14 */ {"menu_list_join", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
46 /* 15 */ {"menu_list_left", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
47 /* 16 */ {"menu_list_right", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
48 /* 17 */ {"menu_join", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
49 /* 18 */ {"menu_top", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
50 /* 19 */ {"menu_vertical", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
51 /* 20 */ {"menu_bottom", COLOR_BLACK, COLOR_FIRE_BRICK_1, COLOR_LIGHT_GOLDENROD},
52 };
53
54 /* default layout for menu */
55 static int map[MAZE_H + 1][MAZE_W];
56 static int defaultMap[MAZE_H][MAZE_W] = {
57 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,},
58 {0, 0, 0, 0, 2, 7, 7, 7, 7, 7, 3, 0, 0, 0, 0,},
59 {7, 7, 7, 7, 5, 1, 1, 1, 1, 1, 6, 7, 7, 7, 7,},
60 {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},
61 {9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9,},
62 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
63 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
64 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
65 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
66 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
67 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
68 {8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8,},
69 {8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8,},
70 };
71
72 /*
73 * load graphics for menu
74 */
75 void
MenuLoadTiles(void)76 MenuLoadTiles (void)
77 {
78 int i;
79
80 for (i = 0; i < MENU_MAX_TILE; i++) {
81 GUI_LoadBlockCch (i, menuBlockTile[i].name, menuBlockTile[i].fg,
82 menuBlockTile[i].bg, menuBlockTile[i].add);
83 }
84 } /* MenuUnloadTiles */
85
86 /*
87 * unload graphics for menu
88 */
89 void
MenuUnloadTiles(void)90 MenuUnloadTiles (void)
91 {
92 int i;
93
94 for (i = 0; i < MENU_MAX_TILE; i++) {
95 GUI_FreeBlock (i);
96 }
97 } /* MenuUnloadTiles */
98
99 /*
100 * clear current map for menus
101 */
102 void
MenuClearMap(void)103 MenuClearMap (void)
104 {
105 int x, y;
106
107 /* copy default
108 for(y=0;y<MAZE_H+2;y++)
109 memcpy (map+y*MAZE_W+1, defaultMap+MAZE_H+1,MAZE_W );
110 */
111 memcpy (map, defaultMap, sizeof (defaultMap));
112
113 /* draw it */
114 for (x = 0; x < MAZE_W; x++) {
115 for (y = 0; y < MAZE_H; y++) {
116 SetMazeBlock (x, y, map[y][x]);
117 }
118 }
119 ClearStatusBar (4, BTFree);
120 } /* MenuClearMap */
121
122 /*
123 * add large frame for object
124 */
125 void
MenuAddLargeFrame(int left,int right,int row)126 MenuAddLargeFrame (int left, int right, int row)
127 {
128 int x;
129
130 /* sanity check */
131 assert (left < right);
132 assert (left < MAZE_W);
133 assert (right < MAZE_W);
134 assert (row < MAZE_H + 1);
135 /* left side */
136 if (map[row][left] == 12) {
137 map[row][left] = 17;
138 }
139 else {
140 map[row][left] = 10;
141 }
142 /* right side */
143 if (map[row][right] == 10) {
144 map[row][right] = 17;
145 }
146 else {
147 map[row][right] = 12;
148 }
149 /* middle */
150 for (x = left + 1; x < right; x++) {
151 map[row][x] = 11;
152 }
153 /* draw it */
154 for (x = left; x <= right; x++) {
155 SetMazeBlock (x, row, map[row][x]);
156 }
157 } /* MenuAddLargeFrame */
158
159 /*
160 * add small frame for object
161 */
162 void
MenuAddSmallFrame(int left,int right,int row)163 MenuAddSmallFrame (int left, int right, int row)
164 {
165 int x;
166
167 /* sanity check */
168 assert (left < right);
169 assert (left < MAZE_W);
170 assert (right < MAZE_W);
171 assert (row < MAZE_H);
172 /* left side */
173 if (map[row][left] == 16) {
174 map[row][left] = 14;
175 }
176 else if (map[row][left] != 14) {
177 map[row][left] = 15;
178 }
179 /* right side */
180 if (map[row][right] == 15) {
181 map[row][right] = 14;
182 }
183 else if (map[row][right] != 14) {
184 map[row][right] = 16;
185 }
186 /* middle */
187 for (x = left + 1; x < right; x++) {
188 map[row][x] = 13;
189 }
190 /* draw it */
191 for (x = left; x <= right; x++) {
192 SetMazeBlock (x, row, map[row][x]);
193 }
194 } /* MenuAddSmallFrame */
195
196 /*
197 * vertical frame
198 */
199 void
MenuAddVerticalFrame(int col,int top,int bottom)200 MenuAddVerticalFrame (int col, int top, int bottom)
201 {
202 int y;
203
204 /* sanity check */
205 assert (top < bottom);
206 assert (top < MAZE_H);
207 assert (bottom < MAZE_H);
208 assert (col < MAZE_W);
209 /* set new tiles */
210 map[top][col] = 18;
211 map[bottom][col] = 20;
212 for (y = top + 1; y < bottom; y++) {
213 map[y][col] = 19;
214 }
215 /* correct pipes */
216 if (bottom + 1 < MAZE_H && map[bottom + 1][col] == 8) {
217 map[++bottom][col] = 9;
218 }
219 /* draw it */
220 for (y = top; y <= bottom; y++) {
221 SetMazeBlock (col, y, map[y][col]);
222 }
223 } /* MenuAddVerticalFrame */
224
225 /*
226 * end of file mi_map.c
227 */
228