1 /*
2  * XPilot NG XP-MapEdit, a map editor for xp maps.  Copyright (C) 1993 by
3  *
4  *      Aaron Averill           <averila@oes.orst.edu>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  * Modifications:
21  * 1996:
22  *      Robert Templeman        <mbcaprt@mphhpd.ph.man.ac.uk>
23  * 1997:
24  *      William Docter          <wad2@lehigh.edu>
25  */
26 
27 #include "xpmapedit.h"
28 
29 Window helpwin;
30 static int helppage = 0, helpsel, helpscreens = 3;
31 
32 const char *iconlabel[36] = {
33     "Space",
34     "Block", "Block", "Block", "Block", "Block",
35     "Decor", "Decor", "Decor", "Decor", "Decor",
36     "Fuel",
37     "Cannon", "Cannon", "Cannon", "Cannon",
38     "Treasure", "Target", "Item Concentrator",
39     "CntrClock Gravity", "Clockwise Gravity",
40     "Wormhole", "Wormhole In", "Wormhole Out",
41     "Positive Gravity", "Negative Gravity",
42     "Current", "Current", "Current", "Current",
43     "Base", "Base Facing",
44     "Empty (space)", "Empty Treasure", "Friction", "Asteroid Concentrator"
45 };
46 
47 char iconhelp[36] = {
48     ' ',
49     XPMAP_FILLED, XPMAP_REC_RD, XPMAP_REC_LD, XPMAP_REC_RU, XPMAP_REC_LU,
50     XPMAP_DECOR_FILLED, XPMAP_DECOR_RD, XPMAP_DECOR_LD, XPMAP_DECOR_RU, XPMAP_DECOR_LU,
51     XPMAP_FUEL,
52     XPMAP_CANNON_LEFT, XPMAP_CANNON_UP, XPMAP_CANNON_DOWN, XPMAP_CANNON_RIGHT,
53     XPMAP_TREASURE, XPMAP_TARGET, XPMAP_ITEM_CONCENTRATOR,
54     XPMAP_ACWISE_GRAV, XPMAP_CWISE_GRAV,
55     XPMAP_WORMHOLE_NORMAL, XPMAP_WORMHOLE_IN, XPMAP_WORMHOLE_OUT,
56     XPMAP_POS_GRAV, XPMAP_NEG_GRAV,
57     XPMAP_UP_GRAV, XPMAP_LEFT_GRAV, XPMAP_RIGHT_GRAV, XPMAP_DOWN_GRAV,
58     XPMAP_BASE, XPMAP_BASE_ATTRACTOR,
59     XPMAP_SPACE, XPMAP_EMPTY_TREASURE, XPMAP_FRICTION_AREA, XPMAP_ASTEROID_CONCENTRATOR
60 };
61 
62 
63 /***************************************************************************/
64 /* OpenHelpPopup                                                           */
65 /* Arguments :                                                             */
66 /*   win                                                                   */
67 /*   name                                                                  */
68 /* Purpose :                                                               */
69 /***************************************************************************/
OpenHelpPopup(HandlerInfo_t info)70 int OpenHelpPopup(HandlerInfo_t info)
71 {
72     helppage = 0;
73     BuildHelpForm(helpwin, helppage);
74     XMapWindow(display, helpwin);
75     return 0;
76 }
77 
78 /***************************************************************************/
79 /* BuildHelpForm                                                           */
80 /* Arguments :                                                             */
81 /*   win                                                                   */
82 /* Purpose :                                                               */
83 /***************************************************************************/
BuildHelpForm(Window win,int helppage)84 void BuildHelpForm(Window win, int helppage)
85 {
86     T_FormClear(win);
87     T_FormButton(win, "close_help", 10, HELP_HEIGHT - 10 - HELP_BTN_HEIGHT,
88 		 HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Close",
89 		 FormCloseHandler);
90     T_FormButton(win, "next_help", 20 + HELP_BTN_WIDTH,
91 		 HELP_HEIGHT - 10 - HELP_BTN_HEIGHT, HELP_BTN_WIDTH,
92 		 HELP_BTN_HEIGHT, "Next", NextHelp);
93     T_FormButton(win, "prev_help", 30 + 2 * HELP_BTN_WIDTH,
94 		 HELP_HEIGHT - 10 - HELP_BTN_HEIGHT, HELP_BTN_WIDTH,
95 		 HELP_BTN_HEIGHT, "Prev", PrevHelp);
96 
97     switch (helppage) {
98 
99     case 0:
100 	helpsel = 3;
101 	T_FormMultiButton(win, "help_icon_select", 10, 10, HELP_WIDTH * .3,
102 			  (int) (HELP_WIDTH * .3 * .8 * 1.75), 5, 7, "",
103 			  &helpsel, 1);
104 	break;
105 
106     case 1:
107 	helpsel = 1;
108 	T_FormMultiButton(win, "help_mode_select", 10,
109 			  10 + HELP_BTN_HEIGHT, HELP_WIDTH * .3,
110 			  HELP_BTN_HEIGHT, 3, 1, "Draw;Line;Select",
111 			  &helpsel, 0);
112 	T_FormButton(win, "help_zoom_in",
113 		     (int) (HELP_WIDTH * .65 - 10 - HELP_BTN_WIDTH),
114 		     (int) (100 + 3 * HELP_BTN_HEIGHT + .2 * HELP_WIDTH),
115 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Z", NULL);
116 	T_FormButton(win, "help_zoom_out", (int) (HELP_WIDTH * .65 + 10),
117 		     (int) (100 + 3 * HELP_BTN_HEIGHT + .2 * HELP_WIDTH),
118 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "z", NULL);
119 	T_FormButton(win, "help_prefs", 10,
120 		     (int) (120 + 3 * HELP_BTN_HEIGHT + .3 * HELP_WIDTH),
121 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Prefs", NULL);
122 	T_FormButton(win, "help_help", 10,
123 		     (int) (200 + 4 * HELP_BTN_HEIGHT + .3 * HELP_WIDTH),
124 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Help", NULL);
125 	break;
126 
127     case 2:
128 	T_FormButton(win, "help_load", 10, 10,
129 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Load", NULL);
130 	T_FormButton(win, "help_save", 10, 40 + HELP_BTN_HEIGHT,
131 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Save", NULL);
132 	T_FormButton(win, "help_new", 10, 70 + 2 * HELP_BTN_HEIGHT,
133 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "New", NULL);
134 	T_FormButton(win, "help_quit", 10, 100 + 3 * HELP_BTN_HEIGHT,
135 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Quit", NULL);
136 	T_FormButton(win, "help_cut", 10, 170 + 4 * HELP_BTN_HEIGHT,
137 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Cut", NULL);
138 	T_FormButton(win, "help_copy", 10, 200 + 5 * HELP_BTN_HEIGHT,
139 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Copy", NULL);
140 	T_FormButton(win, "help_paste", 10, 230 + 6 * HELP_BTN_HEIGHT,
141 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Paste", NULL);
142 	T_FormButton(win, "help_undo", 10, 260 + 7 * HELP_BTN_HEIGHT,
143 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Undo", NULL);
144 	break;
145 
146     case 3:
147 	T_FormButton(win, "help_round", 10, 10,
148 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Round", NULL);
149 	T_FormButton(win, "help_fill", 10, 40 + HELP_BTN_HEIGHT,
150 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Fill", NULL);
151 	T_FormButton(win, "help_grow", 10, 70 + 2 * HELP_BTN_HEIGHT,
152 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Grow", NULL);
153 	T_FormButton(win, "help_neg", 10, 100 + 3 * HELP_BTN_HEIGHT,
154 		     HELP_BTN_WIDTH, HELP_BTN_HEIGHT, "Neg.", NULL);
155 	break;
156     }
157 }
158 
NextHelp(HandlerInfo_t info)159 int NextHelp(HandlerInfo_t info)
160 {
161     XEvent report;
162 
163     helppage++;
164     if (helppage > helpscreens) {
165 	helppage = 0;
166     }
167     BuildHelpForm(helpwin, helppage);
168     T_ClearArea(helpwin, 0, 0, HELP_WIDTH, HELP_HEIGHT);
169     report.type = Expose;
170     report.xexpose.count = 0;
171     report.xexpose.window = helpwin;
172     T_FormExpose(&report);
173     DrawHelpWin();
174     return 0;
175 }
176 
PrevHelp(HandlerInfo_t info)177 int PrevHelp(HandlerInfo_t info)
178 {
179     XEvent report;
180 
181     helppage--;
182     if (helppage < 0) {
183 	helppage = helpscreens;
184     }
185     BuildHelpForm(helpwin, helppage);
186     T_ClearArea(helpwin, 0, 0, HELP_WIDTH, HELP_HEIGHT);
187     report.type = Expose;
188     report.xexpose.count = 0;
189     report.xexpose.window = helpwin;
190     T_FormExpose(&report);
191     DrawHelpWin();
192     return 0;
193 }
194 
195 /***************************************************************************/
196 /* DrawHelpWin                                                             */
197 /* Arguments :                                                             */
198 /*   win                                                                   */
199 /* Purpose :                                                               */
200 /***************************************************************************/
DrawHelpWin(void)201 void DrawHelpWin(void)
202 {
203     int i, j, w, sel;
204 
205     switch (helppage) {
206 
207     case 0:
208 	w = (HELP_WIDTH * .3) / 5;
209 	for (i = 0; i < 7; i++) {
210 	    for (j = 0; j < 5; j++) {
211 		sel = i * 5 + j + 1;
212 		if (sel == helpsel)
213 		    DrawMapPic(helpwin, 14 + j * w, 14 + i * w,
214 			       mapicon_ptr[iconmenu[sel] - 32], w - 7);
215 		else
216 		    DrawMapPic(helpwin, 13 + j * w, 13 + i * w,
217 			       mapicon_ptr[iconmenu[sel] - 32], w - 7);
218 	    }
219 	}
220 	for (i = 0; i < 35; i++) {
221 	    j = i / 12;
222 	    DrawMapPic(helpwin, (int) 10 + j * ((HELP_WIDTH - 30) / 3),
223 		       (int) (30 +
224 			      (HELP_WIDTH * .17 / 5 + 10) * (i - j * 12)) +
225 		       (HELP_WIDTH * .5 / 5 * 4),
226 		       mapicon_ptr[iconhelp[i + 1] - 32], w - 7);
227 	    T_DrawString(helpwin, 20 + j * ((HELP_WIDTH - 30) / 3) + w,
228 			 (int) (25 +
229 				(HELP_WIDTH * .17 / 5 + 10) * (i -
230 							       j * 12)) +
231 			 (HELP_WIDTH * .5 / 5 * 4),
232 			 (int) ((HELP_WIDTH - 20) / 3), w, BKGR,
233 			 iconlabel[i + 1], JUSTIFY_LEFT, CROP_RIGHT, -1);
234 	}
235 	T_DrawText(helpwin, (int) (HELP_WIDTH * .3 + 20),
236 		   (int) (10 + HELP_WIDTH * .03),
237 		   (int) (HELP_WIDTH * .7 - 20),
238 		   (int) (HELP_WIDTH * .3 / 5 * 4), BKGR,
239 		   "Select a map icon to draw with from the buttons at the top of the tool panel. The selected icon will also be used in the line and fill modes.\n\nThe map icon buttons may be turned off to draw empty spaces or the second mouse button can be used.");
240 	T_DrawText(helpwin, 10,
241 		   (int) (150 +
242 			  (HELP_WIDTH * .3 / 5 * 4 +
243 			   (HELP_WIDTH * .3 / 5 + 10) * 7)),
244 		   HELP_WIDTH - 20,
245 		   (int) (HELP_HEIGHT - (30 + (HELP_WIDTH * .3 / 5 * 11))),
246 		   BKGR,
247 		   "You can draw numbered bases and checkpoints by entering 0 through 9 and A through Z on the keyboard while the pointer is in the map region.");
248 	break;
249 
250     case 1:
251 	T_DrawText(helpwin, (int) (HELP_WIDTH * .3 + 20), 10,
252 		   (int) (HELP_WIDTH * .7 - 20), HELP_BTN_HEIGHT * 3, BKGR,
253 		   "The three button set below the map icon buttons determines what mode you are in.\n\nWhile in draw and line mode, the first button draws the selected map icon and the second button draws space.");
254 	T_DrawButton(helpwin, 10, 80 + 3 * HELP_BTN_HEIGHT,
255 		     HELP_WIDTH * .3, HELP_WIDTH * .3, LOWERED, 0);
256 	XFillRectangle(display, helpwin, Black_GC, 15,
257 		       85 + 3 * HELP_BTN_HEIGHT, HELP_WIDTH * .3 - 10,
258 		       HELP_WIDTH * .3 - 10);
259 	T_DrawText(helpwin, (int) (HELP_WIDTH * .3 + 20),
260 		   100 + 3 * HELP_BTN_HEIGHT, (int) (HELP_WIDTH * .7 - 20),
261 		   HELP_WIDTH * .3, BKGR,
262 		   "To move the map view around, press a button and drag the cursor in the small map area.\n\n\nUse the Z and z buttons to zoom in and out. If an area is selected, it will be centered in the view.");
263 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH,
264 		   (int) (120 + 3 * HELP_BTN_HEIGHT + .3 * HELP_WIDTH),
265 		   HELP_WIDTH - 30 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT + 80,
266 		   BKGR,
267 		   "The preferences popup allows you to save parameters that will change the behavior of the game. Only non-empty selections are saved in the map file for the fields and the yes/no buttons.");
268 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH,
269 		   (int) (200 + 4 * HELP_BTN_HEIGHT + .3 * HELP_WIDTH),
270 		   HELP_WIDTH - 30 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT + 80,
271 		   BKGR, "The Help button displays the help screens.");
272 	break;
273 
274     case 2:
275 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 10,
276 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
277 		   "Load a map or .xbm file.");
278 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 40 + HELP_BTN_HEIGHT,
279 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
280 		   "Save the current map.");
281 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 70 + 2 * HELP_BTN_HEIGHT,
282 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
283 		   "Create a new, empty map.");
284 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 100 + 3 * HELP_BTN_HEIGHT,
285 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
286 		   "Quit the map editor.");
287 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 170 + 4 * HELP_BTN_HEIGHT,
288 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
289 		   "While in select mode, the Cut button removes the selected map area and places the non-space icons into the cut buffer.");
290 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 200 + 5 * HELP_BTN_HEIGHT,
291 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
292 		   "While in select mode, the Copy button places the non-space icons from the selected map area into the cut buffer.");
293 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 230 + 6 * HELP_BTN_HEIGHT,
294 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
295 		   "While in select mode, the Paste button fills the selected area with icons from the cut-buffer. Only the selected area of the map will be affected and spaces from the cut buffer will not be copied.");
296 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 260 + 7 * HELP_BTN_HEIGHT,
297 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
298 		   "The Undo button reverts the map to the state it was before the last operation. You may undo successive operations until the beginning of the map editor session.");
299 	break;
300 
301     case 3:
302 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 10,
303 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
304 		   "While in select mode, the Round button attempts to round the selected area by adding and deleting corner icons. If no area is selected the entire view area is rounded.");
305 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 40 + HELP_BTN_HEIGHT,
306 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
307 		   "While in select mode, the currently selected area is filled with the selected map icon.");
308 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 70 + 2 * HELP_BTN_HEIGHT,
309 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
310 		   "Hold down the Grow button to grow from existing blocks. If no blocks are drawn in the selected area, blocks will grow from the center in proportion to the selected width and height.");
311 	T_DrawText(helpwin, 20 + HELP_BTN_WIDTH, 100 + 3 * HELP_BTN_HEIGHT,
312 		   HELP_WIDTH - 20 - HELP_BTN_WIDTH, HELP_BTN_HEIGHT, BKGR,
313 		   "The Neg. button reverses the filled blocks and spaces.");
314 	T_DrawText(helpwin, 10, 300 + 3 * HELP_BTN_HEIGHT, HELP_WIDTH - 20,
315 		   100, BKGR,
316 		   "XP-Mapedit was originally written by Aaron Averill\nPlease send any bugs, patches, enhancements or comments to the current maintainer at:\n\n" PACKAGE_BUGREPORT);
317     }
318 
319 }
320