1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * Copyright (c) 2005-2011 Sam Hocevar <sam@hocevar.net> |
---|
5 | * |
---|
6 | * This software was released into the Public Domain. As with most public |
---|
7 | * domain software, no warranty is made or implied by Crack dot Com, by |
---|
8 | * Jonathan Clark, or by Sam Hocevar. |
---|
9 | */ |
---|
10 | |
---|
11 | #if defined HAVE_CONFIG_H |
---|
12 | # include "config.h" |
---|
13 | #endif |
---|
14 | |
---|
15 | #include <ctype.h> |
---|
16 | #include <string.h> |
---|
17 | |
---|
18 | #include "common.h" |
---|
19 | |
---|
20 | #include "dev.h" |
---|
21 | #include "input.h" |
---|
22 | #include "objects.h" |
---|
23 | #include "id.h" |
---|
24 | #include "lisp.h" |
---|
25 | #include "light.h" |
---|
26 | #include "devsel.h" |
---|
27 | #include "dprint.h" |
---|
28 | #include "property.h" |
---|
29 | #include "pmenu.h" |
---|
30 | #include "filesel.h" |
---|
31 | #include "tools.h" |
---|
32 | #include "game.h" |
---|
33 | #include "pcxread.h" |
---|
34 | #include "lisp_gc.h" |
---|
35 | #include "demo.h" |
---|
36 | #include "profile.h" |
---|
37 | #include "sbar.h" |
---|
38 | #include "compiled.h" |
---|
39 | #include "chat.h" |
---|
40 | |
---|
41 | #define make_above_tile(x) ((x)|0x4000) |
---|
42 | char backw_on=0,forew_on=0,show_menu_on=0,ledit_on=0,pmenu_on=0,omenu_on=0,commandw_on=0,tbw_on=0, |
---|
43 | searchw_on=0,small_render_on=0,interpolate_draw=0,disable_autolight=0,fps_on=0,profile_on=0, |
---|
44 | show_names=0,fg_reversed=0, |
---|
45 | raise_all; |
---|
46 | |
---|
47 | char const *symbol_str(char const *name) |
---|
48 | { |
---|
49 | LSymbol *sym = LSymbol::FindOrCreate(name); |
---|
50 | if (sym->GetValue() && item_type(sym->GetValue())==L_STRING) |
---|
51 | return lstring_value(sym->GetValue()); |
---|
52 | |
---|
53 | |
---|
54 | // maybe english.lsp was not loaded yet, let's try to do that |
---|
55 | LSpace *sp = LSpace::Current; |
---|
56 | LSpace::Current = &LSpace::Perm; |
---|
57 | |
---|
58 | char prog[50]; |
---|
59 | char const *cs=prog; |
---|
60 | strcpy(prog,"(setq section 'game_section)\n"); |
---|
61 | LObject::Compile(cs)->Eval(); |
---|
62 | strcpy(prog,"(load \"lisp/english.lsp\")\n"); |
---|
63 | cs=prog; |
---|
64 | if (!LObject::Compile(cs)->Eval()) |
---|
65 | { |
---|
66 | printf("unable to open file '%s'\n",lsf); |
---|
67 | exit(0); |
---|
68 | } |
---|
69 | LSpace::Current=sp; |
---|
70 | |
---|
71 | |
---|
72 | // check again to see if the symbol is there |
---|
73 | sym = LSymbol::FindOrCreate(name); |
---|
74 | if (sym->GetValue() && item_type(sym->GetValue())==L_STRING) |
---|
75 | return lstring_value(sym->GetValue()); |
---|
76 | |
---|
77 | |
---|
78 | // check to see if there is a missing symbol definition |
---|
79 | sym = LSymbol::FindOrCreate("missing_sym"); |
---|
80 | if (sym->GetValue() && item_type(sym->GetValue())==L_STRING) |
---|
81 | return lstring_value(sym->GetValue()); |
---|
82 | |
---|
83 | // last resort, return english string |
---|
84 | return "Missing language symbol!"; |
---|
85 | } |
---|
86 | |
---|
87 | |
---|
88 | static game_object *copy_object=NULL; |
---|
89 | |
---|
90 | pmenu *dev_menu=NULL; |
---|
91 | Jwindow *mess_win=NULL,*warn_win=NULL; |
---|
92 | |
---|
93 | game_object *edit_object; |
---|
94 | dev_controll *dev_cont=NULL; |
---|
95 | image *small_render=NULL; |
---|
96 | |
---|
97 | vec2i dlast; |
---|
98 | int scale_mult,scale_div; |
---|
99 | int last_created_type=-1; |
---|
100 | char level_file[100]="levels/level00.spe"; |
---|
101 | |
---|
102 | |
---|
103 | class cached_image : public visual_object |
---|
104 | { |
---|
105 | int id; |
---|
106 | public : |
---|
107 | cached_image(int Id) { id=Id; } |
---|
108 | virtual void draw(image *screen, int x, int y, Filter *f) |
---|
109 | { |
---|
110 | if (f) |
---|
111 | f->PutImage(screen, cache.img(id), vec2i(x, y)); |
---|
112 | else |
---|
113 | screen->PutImage(cache.img(id), vec2i(x, y)); |
---|
114 | } |
---|
115 | virtual int width() { return cache.img(id)->Size().x; } |
---|
116 | virtual int height() { return cache.img(id)->Size().y; } |
---|
117 | } ; |
---|
118 | |
---|
119 | |
---|
120 | #define DEV_MODES 3 |
---|
121 | cached_image *dev_mode_pict[DEV_MODES]; |
---|
122 | |
---|
123 | int dev_del,dev_move, dev_char_left,dev_char_right,dev_back,dev_front,dev_ok,dev_copy,dev_brain, |
---|
124 | dev_lights,dev_objects,dev_ai,dev_mode_icon[DEV_MODES], |
---|
125 | dev_forward,dev_backward; |
---|
126 | |
---|
127 | char const *dev_mode_icon_names[DEV_MODES] = |
---|
128 | { |
---|
129 | "pixel_mode", "pick_mode", /* "fill_mode", |
---|
130 | "line_mode","rect_mode","bar_mode", */ "area_select" |
---|
131 | }; |
---|
132 | |
---|
133 | int dev_mode_ids[DEV_MODES]={ ID_DMODE_DRAW,ID_DMODE_PICK, ID_DMODE_AREA}; |
---|
134 | |
---|
135 | int edit_mode=ID_DMODE_DRAW; |
---|
136 | |
---|
137 | |
---|
138 | dev_term *dev_console=NULL; |
---|
139 | int ldef_width=0,ldef_height=0,ldef_r1=1,ldef_r2=100; |
---|
140 | |
---|
141 | void make_screen_size(int w, int h); |
---|
142 | |
---|
143 | class amb_cont : public scroller |
---|
144 | { |
---|
145 | public : |
---|
146 | amb_cont(int X, int Y, ifield *Next) : scroller(X,Y,ID_NULL,100,wm->font()->height()+2,0,64,Next) |
---|
147 | { if (player_list) sx=player_list->ambient; } |
---|
148 | virtual void scroll_event(int newx, image *screen) |
---|
149 | { |
---|
150 | screen->Bar(m_pos, m_pos + vec2i(l - 1, h - 1), wm->dark_color()); |
---|
151 | char st[100]; |
---|
152 | sprintf(st,"%d",newx); |
---|
153 | wm->font()->put_string(screen,m_pos.x+30,m_pos.y+1,st,wm->bright_color()); |
---|
154 | if (player_list) |
---|
155 | player_list->ambient=newx; |
---|
156 | the_game->need_refresh(); |
---|
157 | } |
---|
158 | } ; |
---|
159 | |
---|
160 | |
---|
161 | int confirm_quit() |
---|
162 | { |
---|
163 | Jwindow *quitw; |
---|
164 | image *ok_image, *cancel_image; |
---|
165 | |
---|
166 | ok_image = cache.img(cache.reg("art/frame.spe", "dev_ok", |
---|
167 | SPEC_IMAGE, 1))->copy(); |
---|
168 | cancel_image = cache.img(cache.reg("art/frame.spe", "cancel", |
---|
169 | SPEC_IMAGE, 1))->copy(); |
---|
170 | |
---|
171 | quitw = wm->new_window(xres / 2 + 40, yres / 2, 80, -1, |
---|
172 | new button(10, wm->font()->height() + 4, ID_QUIT_OK, ok_image, |
---|
173 | new button(38, wm->font()->height() + 4, ID_CANCEL, cancel_image, |
---|
174 | new info_field(2, 2, ID_NULL, symbol_str("sure?"), NULL))), |
---|
175 | symbol_str("quit_title")); |
---|
176 | |
---|
177 | wm->grab_focus(quitw); |
---|
178 | int fin = 0, quit = 0; |
---|
179 | |
---|
180 | while(!fin) |
---|
181 | { |
---|
182 | wm->flush_screen(); |
---|
183 | |
---|
184 | Event ev; |
---|
185 | wm->get_event(ev); |
---|
186 | if(ev.type == EV_MESSAGE && ev.message.id == ID_QUIT_OK) |
---|
187 | fin = quit = 1; |
---|
188 | else if(ev.type == EV_MESSAGE && ev.message.id == ID_CANCEL) |
---|
189 | fin = 1; |
---|
190 | else if(ev.type == EV_KEY |
---|
191 | && toupper(ev.key) == toupper(*symbol_str("YES"))) |
---|
192 | fin = quit = 1; |
---|
193 | else if(ev.type == EV_KEY |
---|
194 | && toupper(ev.key) == toupper(*symbol_str("NO"))) |
---|
195 | fin = 1; |
---|
196 | if((ev.type == EV_KEY && ev.key == JK_ESC) |
---|
197 | || ev.type == EV_CLOSE_WINDOW) |
---|
198 | fin = 1; |
---|
199 | } |
---|
200 | |
---|
201 | delete ok_image; |
---|
202 | delete cancel_image; |
---|
203 | |
---|
204 | the_game->reset_keymap(); |
---|
205 | |
---|
206 | wm->close_window(quitw); |
---|
207 | wm->flush_screen(); |
---|
208 | return quit; |
---|
209 | } |
---|
210 | |
---|
211 | static void show_object_number (game_object *who) |
---|
212 | { |
---|
213 | int total=0,number=0; |
---|
214 | game_object *c; |
---|
215 | for (c=current_level->first_object(); c; c=c->next) |
---|
216 | { |
---|
217 | if (c->otype==who->otype) |
---|
218 | total++; |
---|
219 | if (c==who) number=total; |
---|
220 | } |
---|
221 | char msg[100]; |
---|
222 | sprintf(msg,"%s : %d of %d",object_names[who->otype],number,total); |
---|
223 | } |
---|
224 | |
---|
225 | void dev_controll::search_backward() |
---|
226 | { ; |
---|
227 | } |
---|
228 | |
---|
229 | |
---|
230 | static void single_render() |
---|
231 | { |
---|
232 | // enlarge clip area |
---|
233 | the_game->first_view->cx2=the_game->first_view->cx1+ |
---|
234 | (the_game->first_view->cx2-the_game->first_view->cx1+1)*2; |
---|
235 | the_game->first_view->cy2=the_game->first_view->cy1+ |
---|
236 | (the_game->first_view->cy2-the_game->first_view->cy1+1)*2; |
---|
237 | delete small_render; |
---|
238 | small_render=NULL; |
---|
239 | small_render_on=0; |
---|
240 | } |
---|
241 | |
---|
242 | static void double_render() |
---|
243 | { |
---|
244 | small_render_on=1; |
---|
245 | // reduce clip area |
---|
246 | the_game->first_view->cx2=the_game->first_view->cx1+ |
---|
247 | (the_game->first_view->cx2-the_game->first_view->cx1+1)/2; |
---|
248 | the_game->first_view->cy2=the_game->first_view->cy1+ |
---|
249 | (the_game->first_view->cy2-the_game->first_view->cy1+1)/2; |
---|
250 | |
---|
251 | small_render=new image(vec2i(the_game->first_view->cx2-the_game->first_view->cx1+1, the_game->first_view->cy2-the_game->first_view->cy1+1),NULL,2); |
---|
252 | } |
---|
253 | |
---|
254 | |
---|
255 | void dev_controll::search_forward() |
---|
256 | { |
---|
257 | if (search_window) // if no window then we can't get the object name |
---|
258 | { |
---|
259 | char *name=search_window->read(ID_SEARCH_TEXT); |
---|
260 | int type=-1; // see if this type existss |
---|
261 | int i; |
---|
262 | for (i=0; i<total_objects; i++) |
---|
263 | if (!strcmp(object_names[i],name)) |
---|
264 | type=i; |
---|
265 | if (type==-1) |
---|
266 | { |
---|
267 | char msg[60]; |
---|
268 | sprintf(msg,"Object type '%s' does not existss!\n",name); |
---|
269 | the_game->show_help(msg); |
---|
270 | the_game->need_refresh(); |
---|
271 | } else |
---|
272 | { |
---|
273 | game_object *first,*find=NULL; |
---|
274 | if (!search_object || search_object->otype!=type) |
---|
275 | first=current_level->first_object(); |
---|
276 | else |
---|
277 | first=search_object->next; |
---|
278 | for (; !find && first; first=first->next) |
---|
279 | if (first->otype==type) |
---|
280 | find=first; |
---|
281 | if (!find) |
---|
282 | { |
---|
283 | for (first=current_level->first_object(); first && !find; first=first->next) |
---|
284 | { |
---|
285 | if (first->otype==type) |
---|
286 | find=first; |
---|
287 | } |
---|
288 | } |
---|
289 | if (find) |
---|
290 | { |
---|
291 | search_object=find; |
---|
292 | show_object_number(search_object); |
---|
293 | } |
---|
294 | else |
---|
295 | { |
---|
296 | the_game->show_help("No object matching name exists in level\n"); |
---|
297 | |
---|
298 | } |
---|
299 | } |
---|
300 | } |
---|
301 | } |
---|
302 | |
---|
303 | |
---|
304 | int32_t dev_controll::snap_x(int32_t x) |
---|
305 | { |
---|
306 | if (wm->key_pressed(JK_CTRL_L) || wm->key_pressed(JK_CTRL_R)) |
---|
307 | return x-(x%the_game->ftile_width()); |
---|
308 | else if (wm->key_pressed(JK_ALT_L) || wm->key_pressed(JK_ALT_R)) |
---|
309 | return x-(x%the_game->ftile_width())+the_game->ftile_width()/2; |
---|
310 | else return x; |
---|
311 | } |
---|
312 | |
---|
313 | int32_t dev_controll::snap_y(int32_t y) |
---|
314 | { |
---|
315 | if (wm->key_pressed(JK_CTRL_L) || wm->key_pressed(JK_CTRL_R)) |
---|
316 | return y-(y%the_game->ftile_height())-1; |
---|
317 | else if (wm->key_pressed(JK_ALT_L) || wm->key_pressed(JK_ALT_R)) |
---|
318 | return y-(y%the_game->ftile_height())+the_game->ftile_height()/2-1; |
---|
319 | else return y; |
---|
320 | } |
---|
321 | |
---|
322 | void dev_controll::make_ambient() |
---|
323 | { |
---|
324 | if(ambw) |
---|
325 | return; |
---|
326 | |
---|
327 | ambw = wm->new_window(prop->getd("ambient x", -1), |
---|
328 | prop->getd("ambient y", -1), -1, -1, |
---|
329 | new amb_cont(0, 0, NULL), "ambient"); |
---|
330 | } |
---|
331 | |
---|
332 | void dev_term::execute(char *st) |
---|
333 | { |
---|
334 | if (!strcmp(st,"?")) |
---|
335 | { |
---|
336 | put_string("unchop x y, size x y,\n" |
---|
337 | "load, esave, name\n"); |
---|
338 | } else |
---|
339 | { |
---|
340 | Event ev; |
---|
341 | dv->do_command(st,ev); |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | static void load_dev_icons() |
---|
346 | { |
---|
347 | char const *artf="art/dev.spe"; |
---|
348 | dev_del=cache.reg(artf,"dev_del",SPEC_IMAGE,0); |
---|
349 | dev_move=cache.reg(artf,"dev_move",SPEC_IMAGE,0); |
---|
350 | dev_char_left=cache.reg(artf,"dev_char_left",SPEC_IMAGE,0); |
---|
351 | dev_char_right=cache.reg(artf,"dev_char_right",SPEC_IMAGE,0); |
---|
352 | dev_back=cache.reg(artf,"dev_back",SPEC_IMAGE,0); |
---|
353 | dev_front=cache.reg(artf,"dev_front",SPEC_IMAGE,0); |
---|
354 | dev_ok=cache.reg(artf,"dev_ok",SPEC_IMAGE,0); |
---|
355 | dev_copy=cache.reg(artf,"dev_copy",SPEC_IMAGE,0); |
---|
356 | dev_brain=cache.reg(artf,"brain",SPEC_IMAGE,0); |
---|
357 | dev_lights=cache.reg(artf,"lights",SPEC_IMAGE,0); |
---|
358 | dev_objects=cache.reg(artf,"objects",SPEC_IMAGE,0); |
---|
359 | dev_ai=cache.reg(artf,"ai",SPEC_IMAGE,0); |
---|
360 | dev_forward=cache.reg(artf,"forward",SPEC_IMAGE,0); |
---|
361 | dev_backward=cache.reg(artf,"backward",SPEC_IMAGE,0); |
---|
362 | |
---|
363 | for (int i=0; i<DEV_MODES; i++) |
---|
364 | dev_mode_icon[i]=cache.reg(artf,dev_mode_icon_names[i],SPEC_IMAGE,0); |
---|
365 | |
---|
366 | } |
---|
367 | |
---|
368 | void scale_put(image *im, image *screen, int x, int y, short new_width, short new_height) |
---|
369 | { |
---|
370 | unsigned char *sl1,*sl2; |
---|
371 | int32_t xstep=(im->Size().x<<16)/new_width, |
---|
372 | ystep=(im->Size().y<<16)/new_height,iy,ix,sx,ix_start,iy_start; |
---|
373 | screen->AddDirty(x, y, x + new_width, y + new_height); |
---|
374 | |
---|
375 | vec2i caa, cbb; |
---|
376 | screen->GetClip(caa, cbb); |
---|
377 | if (caa.x > cbb.x || caa.y > cbb.y || x>=cbb.x || y>=cbb.y || x+new_width<=caa.x || y+new_height<=caa.y) return ; |
---|
378 | if (x<caa.x) |
---|
379 | { |
---|
380 | ix_start=(caa.x-x)*xstep; |
---|
381 | new_width-=(caa.x-x); |
---|
382 | x=caa.x; |
---|
383 | } else ix_start=0; |
---|
384 | if (x+new_width>cbb.x) |
---|
385 | new_width-=x+new_width-cbb.x; |
---|
386 | if (y<caa.y) |
---|
387 | { |
---|
388 | iy_start=(caa.y-y)*ystep; |
---|
389 | new_height-=(caa.y-y); |
---|
390 | y=caa.y; |
---|
391 | } else iy_start=0; |
---|
392 | if (y+new_height>cbb.y) |
---|
393 | new_height-=y+new_height-cbb.y; |
---|
394 | |
---|
395 | screen->Lock(); |
---|
396 | im->Lock(); |
---|
397 | for (iy=iy_start; new_height>0; new_height--,y++,iy+=ystep) |
---|
398 | { |
---|
399 | sl1=im->scan_line(iy>>16); |
---|
400 | sl2=screen->scan_line(y)+x; |
---|
401 | for (ix=ix_start,sx=0; sx<new_width; sx++,ix+=xstep,sl2++) |
---|
402 | *sl2=sl1[ix>>16]; |
---|
403 | } |
---|
404 | im->Unlock(); |
---|
405 | screen->Unlock(); |
---|
406 | } |
---|
407 | |
---|
408 | |
---|
409 | void scale_put_trans(image *im, image *screen, int x, int y, short new_width, short new_height) |
---|
410 | { |
---|
411 | unsigned char *sl1,*sl2; |
---|
412 | int32_t xstep=(im->Size().x<<16)/new_width, |
---|
413 | ystep=(im->Size().y<<16)/new_height,iy,ix,sx,ix_start,iy_start; |
---|
414 | screen->AddDirty(x, y, x + new_width, y + new_height); |
---|
415 | |
---|
416 | vec2i caa, cbb; |
---|
417 | screen->GetClip(caa, cbb); |
---|
418 | if (caa.x > cbb.x || caa.y > cbb.y || x >= cbb.x || y >= cbb.y || x+new_width<=caa.x || y+new_height<=caa.y) return ; |
---|
419 | if (x<caa.x) |
---|
420 | { |
---|
421 | ix_start=(caa.x-x)*xstep; |
---|
422 | new_width-=(caa.x-x); |
---|
423 | x=caa.x; |
---|
424 | } else ix_start=0; |
---|
425 | if (x+new_width>cbb.x) |
---|
426 | new_width-=x+new_width-cbb.x; |
---|
427 | if (y<caa.y) |
---|
428 | { |
---|
429 | iy_start=(caa.y-y)*ystep; |
---|
430 | new_height-=(caa.y-y); |
---|
431 | y=caa.y; |
---|
432 | } else iy_start=0; |
---|
433 | if (y+new_height>cbb.y) |
---|
434 | new_height-=y+new_height-cbb.y; |
---|
435 | |
---|
436 | uint8_t d; |
---|
437 | screen->Lock(); |
---|
438 | for (iy=iy_start; new_height>0; new_height--,y++,iy+=ystep) |
---|
439 | { |
---|
440 | sl1=im->scan_line(iy>>16); |
---|
441 | sl2=screen->scan_line(y)+x; |
---|
442 | for (ix=ix_start,sx=0; sx<new_width; sx++,ix+=xstep,sl2++) |
---|
443 | { |
---|
444 | d=sl1[ix>>16]; |
---|
445 | if (d) |
---|
446 | *sl2=d; |
---|
447 | } |
---|
448 | } |
---|
449 | screen->Unlock(); |
---|
450 | } |
---|
451 | |
---|
452 | int dev_controll::need_plus_minus() |
---|
453 | { |
---|
454 | if (state==DEV_MOVE_LIGHT) return 1; else return 0; |
---|
455 | } |
---|
456 | |
---|
457 | int dev_controll::need_arrows() |
---|
458 | { |
---|
459 | if (state==DEV_MOVE_LIGHT) return 1; else return 0; |
---|
460 | } |
---|
461 | |
---|
462 | int dev_controll::repeat_key_mode() |
---|
463 | { |
---|
464 | if (state==DEV_MOVE_LIGHT) return 1; else return 0; |
---|
465 | } |
---|
466 | |
---|
467 | int last_link_x=0,last_link_y=0; |
---|
468 | |
---|
469 | void dev_controll::dev_draw(view *v) |
---|
470 | { |
---|
471 | int32_t x1,y1,x2,y2; |
---|
472 | if (dev&EDIT_MODE) |
---|
473 | { |
---|
474 | int32_t vx=v->xoff(),vy=v->yoff(); |
---|
475 | |
---|
476 | if (dev&DRAW_LINKS) |
---|
477 | { |
---|
478 | for (light_source *f=first_light_source; f; f=f->next) |
---|
479 | { |
---|
480 | if (f->x-vx>=0 && f->x-vx<=(v->cx2-v->cx1+1) && f->y-vy>=0 && f->y-vy<=(v->cy2-v->cy1+1)) |
---|
481 | { |
---|
482 | image *im = cache.img(light_buttons[f->type]); |
---|
483 | main_screen->PutImage(im, vec2i(f->x - vx + v->cx1 - im->Size().x / 2, |
---|
484 | f->y - vy + v->cy1 - im->Size().y / 2), 1); |
---|
485 | main_screen->Rectangle(vec2i(f->x1 - vx + v->cx1, f->y1 - vy + v->cy1), |
---|
486 | vec2i(f->x2 - vx + v->cx1, f->y2 - vy + v->cy1), |
---|
487 | wm->medium_color()); |
---|
488 | } |
---|
489 | } |
---|
490 | } |
---|
491 | |
---|
492 | if (link_object) |
---|
493 | { |
---|
494 | vec2i pos = the_game->GameToMouse(vec2i(link_object->x, link_object->y), v); |
---|
495 | main_screen->Line(pos, dlast, yellow); |
---|
496 | } |
---|
497 | |
---|
498 | if (selected_light) |
---|
499 | { |
---|
500 | image *im = cache.img(light_buttons[0]); |
---|
501 | vec2i pos = the_game->GameToMouse(vec2i(selected_light->x, selected_light->y), v); |
---|
502 | main_screen->Rectangle(pos - im->Size() / 2, pos + im->Size() / 2, |
---|
503 | wm->bright_color()); |
---|
504 | } |
---|
505 | |
---|
506 | game_object *o; |
---|
507 | if (show_names) |
---|
508 | for (o=current_level->first_object(); o; o=o->next) |
---|
509 | { |
---|
510 | vec2i pos = the_game->GameToMouse(vec2i(o->x, o->y), current_view); |
---|
511 | char *nm=object_names[o->otype]; |
---|
512 | console_font->put_string(main_screen, pos.x - strlen(nm) * console_font->width() / 2, pos.y + 2, nm); |
---|
513 | } |
---|
514 | |
---|
515 | if (dev&DRAW_LINKS) |
---|
516 | { |
---|
517 | // draw connections between objects |
---|
518 | for (o=current_level->first_object(); o; o=o->next) |
---|
519 | { |
---|
520 | vec2i pos1 = the_game->GameToMouse(vec2i(o->x, o->y), current_view); |
---|
521 | |
---|
522 | int i=0; |
---|
523 | for (; i<o->total_objects(); i++) |
---|
524 | { |
---|
525 | game_object *other=o->get_object(i); |
---|
526 | vec2i pos2 = the_game->GameToMouse(vec2i(other->x, other->y), current_view); |
---|
527 | main_screen->Line(pos1, pos2, wm->bright_color()); |
---|
528 | } |
---|
529 | |
---|
530 | for (i=0; i<o->total_lights(); i++) |
---|
531 | { |
---|
532 | light_source *l=o->get_light(i); |
---|
533 | vec2i pos2 = the_game->GameToMouse(vec2i(l->x, l->y), current_view); |
---|
534 | main_screen->Line(pos1, pos2, light_connection_color); |
---|
535 | } |
---|
536 | |
---|
537 | } |
---|
538 | } |
---|
539 | |
---|
540 | if (selected_object) |
---|
541 | { |
---|
542 | selected_object->picture_space(x1,y1,x2,y2); |
---|
543 | vec2i pos1 = the_game->GameToMouse(vec2i(x1, y1), v); |
---|
544 | vec2i pos2 = the_game->GameToMouse(vec2i(x2, y2), v); |
---|
545 | main_screen->Rectangle(pos1, pos2, wm->bright_color()); |
---|
546 | |
---|
547 | pos1 = the_game->GameToMouse(vec2i(selected_object->x, selected_object->y), current_view); |
---|
548 | for (int i=0; i<selected_object->total_objects(); i++) |
---|
549 | { |
---|
550 | game_object *other = selected_object->get_object(i); |
---|
551 | pos2 = the_game->GameToMouse(vec2i(other->x, other->y), current_view); |
---|
552 | main_screen->Line(pos1, pos2, light_connection_color); |
---|
553 | } |
---|
554 | } |
---|
555 | } |
---|
556 | } |
---|
557 | |
---|
558 | static light_source *find_light(int32_t x, int32_t y) |
---|
559 | { |
---|
560 | image *i=cache.img(light_buttons[0]); |
---|
561 | int l=i->Size().x/2,h=i->Size().y/2; |
---|
562 | for (light_source *f=first_light_source; f; f=f->next) |
---|
563 | { |
---|
564 | if (x>=f->x-l && x<=f->x+l && y>=f->y-h && y<=f->y+h) |
---|
565 | return f; |
---|
566 | } |
---|
567 | return NULL; |
---|
568 | } |
---|
569 | |
---|
570 | |
---|
571 | void dev_controll::toggle_toolbar() |
---|
572 | { |
---|
573 | if (tbw) |
---|
574 | { |
---|
575 | tbw_on=0; |
---|
576 | prop->setd("toolbar x",tbw->m_pos.x); |
---|
577 | prop->setd("toolbar y",tbw->m_pos.y); |
---|
578 | wm->close_window(tbw); |
---|
579 | tbw=NULL; |
---|
580 | } else |
---|
581 | { |
---|
582 | tbw_on=1; |
---|
583 | int setx=0; |
---|
584 | for (int i=0; i<DEV_MODES; i++) |
---|
585 | { |
---|
586 | if (edit_mode==dev_mode_ids[i]) |
---|
587 | setx=i; |
---|
588 | dev_mode_pict[i]=new cached_image(dev_mode_icon[i]); |
---|
589 | } |
---|
590 | |
---|
591 | tool_picker *tp=new tool_picker(0, 0, |
---|
592 | ID_NULL, |
---|
593 | 5,(visual_object **)dev_mode_pict,dev_mode_ids,DEV_MODES, |
---|
594 | pal,pal,NULL); |
---|
595 | tbw=wm->new_window(prop->getd("toolbar x",-1), |
---|
596 | prop->getd("toolbar y",-1),-1,-1,tp); |
---|
597 | tp->set_x(setx,tbw->m_surf); |
---|
598 | } |
---|
599 | } |
---|
600 | |
---|
601 | void dev_controll::toggle_show_menu() |
---|
602 | { |
---|
603 | if(show_menu) |
---|
604 | { |
---|
605 | show_menu_on = 0; |
---|
606 | prop->setd("layer x", show_menu->m_pos.x); |
---|
607 | prop->setd("layer y", show_menu->m_pos.y); |
---|
608 | wm->close_window(show_menu); |
---|
609 | show_menu = NULL; |
---|
610 | return; |
---|
611 | } |
---|
612 | |
---|
613 | show_menu_on = 1; |
---|
614 | |
---|
615 | button *lnb, *lb, *cb, *bb, *bdb, *fb; |
---|
616 | |
---|
617 | lnb = new button(0, 100, SHOW_LINKS, symbol_str("l_links"), NULL); |
---|
618 | if(dev & DRAW_LINKS) |
---|
619 | lnb->push(); |
---|
620 | lb = new button(0, 80, SHOW_LIGHT, symbol_str("l_light"), lnb); |
---|
621 | if(dev & DRAW_LIGHTS) |
---|
622 | lb->push(); |
---|
623 | cb = new button(0, 60, SHOW_CHARACTERS, symbol_str("l_char"), lb); |
---|
624 | if(dev & DRAW_PEOPLE_LAYER) |
---|
625 | cb->push(); |
---|
626 | bb = new button(0, 40, SHOW_BACKGROUND, symbol_str("l_back"), cb); |
---|
627 | if(dev & DRAW_BG_LAYER) |
---|
628 | bb->push(); |
---|
629 | bdb = new button(0, 20, SHOW_FOREGROUND_BOUND, symbol_str("l_bound"), bb); |
---|
630 | if(dev & DRAW_FG_BOUND_LAYER) |
---|
631 | bdb->push(); |
---|
632 | fb = new button(0, 0, SHOW_FOREGROUND, symbol_str("l_fore"), bdb); |
---|
633 | if(dev & DRAW_FG_LAYER) |
---|
634 | fb->push(); |
---|
635 | |
---|
636 | show_menu = wm->new_window(prop->getd("layer x", -1), |
---|
637 | prop->getd("layer y", -1), -1, -1, |
---|
638 | fb, symbol_str(symbol_str("SHOW?"))); |
---|
639 | } |
---|
640 | |
---|
641 | char **listable_objs=NULL; |
---|
642 | int total_listable; |
---|
643 | |
---|
644 | void dev_controll::toggle_omenu() |
---|
645 | { |
---|
646 | if(omenu) |
---|
647 | { |
---|
648 | omenu_on = 0; |
---|
649 | prop->setd("objects x", omenu->m_pos.x); |
---|
650 | prop->setd("objects y", omenu->m_pos.y); |
---|
651 | wm->close_window(omenu); |
---|
652 | omenu = NULL; |
---|
653 | free(listable_objs); |
---|
654 | listable_objs = NULL; |
---|
655 | return; |
---|
656 | } |
---|
657 | |
---|
658 | omenu_on = 1; |
---|
659 | total_listable = 0; |
---|
660 | |
---|
661 | int i, c; |
---|
662 | |
---|
663 | for(i = 0; i < total_objects; i++) |
---|
664 | if(!figures[i]->get_cflag(CFLAG_UNLISTABLE)) |
---|
665 | total_listable++; |
---|
666 | listable_objs = (char **)malloc(sizeof(char *) * total_listable); |
---|
667 | |
---|
668 | for(i = 0, c = 0; i < total_objects; i++) |
---|
669 | if(!figures[i]->get_cflag(CFLAG_UNLISTABLE)) |
---|
670 | { |
---|
671 | listable_objs[c] = object_names[i]; |
---|
672 | c++; |
---|
673 | } |
---|
674 | |
---|
675 | omenu = wm->new_window(prop->getd("objects x", 0), |
---|
676 | prop->getd("objects y", 0), -1, -1, |
---|
677 | new pick_list(0, 0, DEV_CREATE, |
---|
678 | yres / wm->font()->height() / 2, |
---|
679 | listable_objs, total_listable, 0, |
---|
680 | NULL, cache.img(window_texture))); |
---|
681 | } |
---|
682 | |
---|
683 | static int get_omenu_item(int x) |
---|
684 | { |
---|
685 | for (int i=0; i<total_objects; i++) |
---|
686 | if (listable_objs[x]==object_names[i]) |
---|
687 | return i; |
---|
688 | return 0; |
---|
689 | } |
---|
690 | |
---|
691 | void dev_controll::toggle_pmenu() |
---|
692 | { |
---|
693 | if(pmenu) |
---|
694 | { |
---|
695 | pmenu_on = 0; |
---|
696 | prop->setd("pal x", pmenu->m_pos.x); |
---|
697 | prop->setd("pal y", pmenu->m_pos.y); |
---|
698 | wm->close_window(pmenu); |
---|
699 | pmenu = NULL; |
---|
700 | free(pwin_list); |
---|
701 | return; |
---|
702 | } |
---|
703 | |
---|
704 | if(!total_pals) |
---|
705 | { |
---|
706 | the_game->show_help(symbol_str("no_pals")); |
---|
707 | return; |
---|
708 | } |
---|
709 | |
---|
710 | pmenu_on = 1; |
---|
711 | |
---|
712 | pwin_list = (char **)malloc(total_pals * sizeof(char *)); |
---|
713 | for(int i = 0; i < total_pals; i++) |
---|
714 | pwin_list[i] = pal_wins[i]->name; |
---|
715 | |
---|
716 | pmenu = wm->new_window(prop->getd("pal x",0), |
---|
717 | prop->getd("pal y",-1), -1,-1, |
---|
718 | new pick_list(0, 0, DEV_PALETTE, |
---|
719 | yres / wm->font()->height() / 2, |
---|
720 | pwin_list, total_pals, 0, NULL, |
---|
721 | cache.img(window_texture))); |
---|
722 | } |
---|
723 | |
---|
724 | |
---|
725 | void dev_controll::toggle_fgw() |
---|
726 | { |
---|
727 | if(forew) |
---|
728 | { |
---|
729 | forew_on = 1; |
---|
730 | prop->setd("fore x", forew->m_pos.x); |
---|
731 | prop->setd("fore y", forew->m_pos.y); |
---|
732 | wm->close_window(forew); |
---|
733 | forew = NULL; |
---|
734 | return; |
---|
735 | } |
---|
736 | |
---|
737 | /* FIXME: shouldn't this be 1? */ |
---|
738 | forew_on = 0; |
---|
739 | int maxh = (yres - 25) / (the_game->ftile_height() / fg_scale); |
---|
740 | |
---|
741 | /* FIXME: previous code had 1 instead of 0, investigate */ |
---|
742 | tile_picker *f_tp = new tile_picker(0, 0, DEV_FG_PICKER, SPEC_FORETILE, |
---|
743 | fg_scale, maxh, fg_w, NULL); |
---|
744 | f_tp->reverse(); |
---|
745 | |
---|
746 | forew = wm->new_window(prop->getd("fore x", -30), prop->getd("fore y", 0), |
---|
747 | -1, -1, f_tp,symbol_str("l_fg")); |
---|
748 | } |
---|
749 | |
---|
750 | void dev_controll::toggle_music_window() |
---|
751 | { |
---|
752 | /* if (!music_window) |
---|
753 | { |
---|
754 | music_window=wm->new_window(-1,30,0,0, |
---|
755 | new pick_list(0,0,DEV_MUSIC_PICKLIST,10,song_list,total_songs,0,NULL)); |
---|
756 | wm->fnt->put_string(music_window->m_surf,0,1,"songs"); |
---|
757 | } else |
---|
758 | { |
---|
759 | wm->close_window(music_window); |
---|
760 | music_window=NULL; |
---|
761 | }*/ |
---|
762 | } |
---|
763 | |
---|
764 | void dev_controll::toggle_bgw() |
---|
765 | { |
---|
766 | if(backw) |
---|
767 | { |
---|
768 | backw_on = 1; |
---|
769 | prop->setd("back x", backw->m_pos.x); |
---|
770 | prop->setd("back y", backw->m_pos.y); |
---|
771 | wm->close_window(backw); |
---|
772 | backw = NULL; |
---|
773 | return; |
---|
774 | } |
---|
775 | |
---|
776 | /* FIXME: shouldn't this be 1? */ |
---|
777 | backw_on = 0; |
---|
778 | int maxh = (yres - 25) / (the_game->btile_height() / bg_scale); |
---|
779 | |
---|
780 | /* FIXME: previous code had 1 instead of 0, investigate */ |
---|
781 | tile_picker *f_tp = new tile_picker(0, 0, DEV_BG_PICKER, SPEC_BACKTILE, |
---|
782 | bg_scale, maxh, bg_w, NULL); |
---|
783 | forew = wm->new_window(prop->getd("back x", -30), prop->getd("back y", 0), |
---|
784 | -1, -1, f_tp,symbol_str("l_bg")); |
---|
785 | } |
---|
786 | |
---|
787 | void dev_controll::toggle_search_window() |
---|
788 | { |
---|
789 | if(search_window) |
---|
790 | { |
---|
791 | searchw_on = 1; |
---|
792 | prop->setd("searchw x", search_window->m_pos.x); |
---|
793 | prop->setd("searchw y", search_window->m_pos.y); |
---|
794 | prop->set("search name", search_window->read(ID_SEARCH_TEXT)); |
---|
795 | wm->close_window(search_window); |
---|
796 | search_window = NULL; |
---|
797 | search_object = NULL; |
---|
798 | return; |
---|
799 | } |
---|
800 | |
---|
801 | int bw = cache.img(dev_forward)->Size().x; |
---|
802 | /* FIXME: previous code had 1,1 instead of 0,0 -- investigate */ |
---|
803 | search_window = wm->new_window(prop->getd("searchw x", -30), |
---|
804 | prop->getd("searchw y", 0), -1, -1, |
---|
805 | new text_field(0, 0, ID_SEARCH_TEXT, "object name>", |
---|
806 | "***************************", |
---|
807 | prop->get("search name", ""), |
---|
808 | new button(bw, wm->font()->height() + 5, ID_SEARCH_BACKWARD, |
---|
809 | cache.img(dev_backward), |
---|
810 | new button(bw * 3, wm->font()->height() + 5, ID_SEARCH_FOREWARD, |
---|
811 | cache.img(dev_forward), NULL))), "SEARCH"); |
---|
812 | |
---|
813 | /* FIXME: shouldn't this be 1? */ |
---|
814 | searchw_on = 0; |
---|
815 | } |
---|
816 | |
---|
817 | int open_owin=0,open_fwin=0,open_bwin=0,start_edit=0,start_nodelay=0,start_doubled=0,start_mem=0; |
---|
818 | |
---|
819 | |
---|
820 | int get_option(char const *name); |
---|
821 | |
---|
822 | |
---|
823 | void dev_init(int argc, char **argv) |
---|
824 | { |
---|
825 | scale_mult=1; |
---|
826 | scale_div=1; |
---|
827 | dev=0; |
---|
828 | int i; |
---|
829 | prop=new property_manager; |
---|
830 | prop->load("defaults.prp"); |
---|
831 | |
---|
832 | for (i=1; i<argc; i++) |
---|
833 | { |
---|
834 | if (!strcmp(argv[i],"-edit")) |
---|
835 | { |
---|
836 | dev|=EDIT_MODE; |
---|
837 | start_edit=1; |
---|
838 | start_running=1; |
---|
839 | disable_autolight=1; |
---|
840 | if (get_option("-2")) |
---|
841 | { |
---|
842 | printf("%s\n",symbol_str("no2")); |
---|
843 | exit(0); |
---|
844 | } |
---|
845 | } |
---|
846 | else if (!strcmp(argv[i],"-fwin")) |
---|
847 | open_fwin=1; |
---|
848 | else if (!strcmp(argv[i],"-show_mem")) |
---|
849 | start_mem=1; |
---|
850 | else if (!strcmp(argv[i],"-bwin")) |
---|
851 | open_bwin=1; |
---|
852 | else if (!strcmp(argv[i],"-owin")) |
---|
853 | open_owin=1; |
---|
854 | else if (!strcmp(argv[i],"-nodelay")) |
---|
855 | start_nodelay=1; |
---|
856 | // AK : NOTE: Commented this out as it causes a conflict |
---|
857 | /* else if (!strcmp(argv[i],"-scale")) |
---|
858 | { |
---|
859 | i++; |
---|
860 | scale_mult=atoi(argv[i++]); |
---|
861 | scale_div=atoi(argv[i]); |
---|
862 | }*/ |
---|
863 | else if (!strcmp(argv[i],"-f")) |
---|
864 | { |
---|
865 | i++; |
---|
866 | strncpy(level_file, argv[i], sizeof(level_file) - 1); |
---|
867 | level_file[sizeof(level_file) - 1] = '\0'; |
---|
868 | } else if (!strcmp(argv[i],"-2")) |
---|
869 | start_doubled=1; |
---|
870 | else if (!strcmp(argv[i],"-demo")) |
---|
871 | demo_start=1; |
---|
872 | |
---|
873 | } |
---|
874 | |
---|
875 | if (get_option("-no_autolight")) |
---|
876 | disable_autolight=0; |
---|
877 | |
---|
878 | if ((get_option("-size") || get_option("-vmode")) && !start_edit) |
---|
879 | { |
---|
880 | printf("%s\n",symbol_str("no_hirez")); |
---|
881 | exit(0); |
---|
882 | } |
---|
883 | |
---|
884 | fg_reversed=prop->getd("fg_reversed",0); |
---|
885 | mouse_scrolling=prop->getd("mouse_scrolling",0); |
---|
886 | palettes_locked=prop->getd("palettes_locked",0); |
---|
887 | view_shift_disabled=prop->getd("view_shift_disabled",0); |
---|
888 | fps_on=prop->getd("fps_on",0); |
---|
889 | show_names=prop->getd("show_names",0); |
---|
890 | raise_all=prop->getd("raise_all",0); |
---|
891 | } |
---|
892 | |
---|
893 | static pmenu *make_menu(int x, int y); |
---|
894 | |
---|
895 | |
---|
896 | dev_controll::dev_controll() |
---|
897 | { |
---|
898 | area_win=NULL; |
---|
899 | current_area=NULL; |
---|
900 | fg_w=bg_w=1; |
---|
901 | commandw=NULL; |
---|
902 | bg_scale=fg_scale=1; |
---|
903 | pal_wins=NULL; |
---|
904 | total_pals=0; |
---|
905 | state=DEV_SELECT; |
---|
906 | aiw=NULL; |
---|
907 | edit_light=NULL; |
---|
908 | selected_light=NULL; |
---|
909 | |
---|
910 | tbw=NULL; |
---|
911 | modew=NULL; |
---|
912 | link_object=NULL; |
---|
913 | selected_object=NULL; |
---|
914 | edit_object=NULL; |
---|
915 | ai_object=NULL; |
---|
916 | search_object = NULL; |
---|
917 | oedit=NULL; |
---|
918 | forew=NULL; |
---|
919 | backw=NULL; |
---|
920 | omenu=NULL; |
---|
921 | ledit=NULL; |
---|
922 | pmenu=NULL; |
---|
923 | lightw=NULL; |
---|
924 | search_window=NULL; |
---|
925 | show_menu=NULL; |
---|
926 | music_window=NULL; |
---|
927 | ambw=NULL; |
---|
928 | load_dev_icons(); |
---|
929 | |
---|
930 | if (open_owin) toggle_omenu(); |
---|
931 | if (open_fwin) toggle_fgw(); |
---|
932 | if (open_bwin) toggle_bgw(); |
---|
933 | if (start_nodelay) the_game->toggle_delay(); |
---|
934 | yellow=pal->find_closest(255,255,0); |
---|
935 | if (start_edit) |
---|
936 | { |
---|
937 | the_game->load_level(level_file); |
---|
938 | the_game->draw(); |
---|
939 | } |
---|
940 | |
---|
941 | dev_console=new dev_term(50,18,this); |
---|
942 | if (start_edit) |
---|
943 | dev_menu=make_menu(0,yres-wm->font()->height()-5); |
---|
944 | |
---|
945 | if (get_option("-nolight")) |
---|
946 | dev=dev^DRAW_LIGHTS; |
---|
947 | } |
---|
948 | |
---|
949 | |
---|
950 | void dev_controll::set_state(int new_state) |
---|
951 | { |
---|
952 | if (start_doubled && new_state==RUN_STATE && !small_render) |
---|
953 | double_render(); |
---|
954 | } |
---|
955 | |
---|
956 | void dev_controll::load_stuff() |
---|
957 | { |
---|
958 | if (dev & EDIT_MODE) |
---|
959 | { |
---|
960 | char prog[100]; |
---|
961 | char const *cs; |
---|
962 | strcpy(prog,"(compile-file \"edit.lsp\")"); |
---|
963 | cs=prog; |
---|
964 | LObject *p = LObject::Compile(cs); |
---|
965 | l_user_stack.push(p); |
---|
966 | p->Eval(); |
---|
967 | l_user_stack.pop(1); |
---|
968 | for (int i=0; i<total_pals; i++) |
---|
969 | pal_wins[i]->close_window(); |
---|
970 | } |
---|
971 | |
---|
972 | } |
---|
973 | |
---|
974 | void dev_controll::do_command(char const *command, Event &ev) |
---|
975 | { |
---|
976 | char fword[50]; |
---|
977 | char const *st; |
---|
978 | int l,h,x,y,i; |
---|
979 | if (command[0]=='(') // is this a lisp command? |
---|
980 | { |
---|
981 | LObject::Compile(command)->Eval(); |
---|
982 | return ; |
---|
983 | } |
---|
984 | |
---|
985 | sscanf(command,"%s",fword); |
---|
986 | for (st=command; *st && *st!=' '; st++); |
---|
987 | if (*st) st++; |
---|
988 | if (!strcmp(fword,"active")) |
---|
989 | { |
---|
990 | if (current_level && current_level->first_active_object()) |
---|
991 | { |
---|
992 | game_object *o=current_level->first_active_object(); |
---|
993 | while (o) |
---|
994 | { |
---|
995 | dprintf("%s %d %d %d %d\n",object_names[o->otype],o->x,o->y, |
---|
996 | figures[o->otype]->rangex, |
---|
997 | figures[o->otype]->rangey |
---|
998 | ); |
---|
999 | o=o->next_active; |
---|
1000 | } |
---|
1001 | } |
---|
1002 | } |
---|
1003 | |
---|
1004 | if (!strcmp(fword,"clear_weapons")) |
---|
1005 | { |
---|
1006 | view *f=NULL; |
---|
1007 | for (f=player_list; f; f=f->next) |
---|
1008 | { |
---|
1009 | int i; |
---|
1010 | for (i=0; i<total_weapons; i++) |
---|
1011 | f->weapons[i]=-1; |
---|
1012 | |
---|
1013 | if (total_weapons) |
---|
1014 | f->weapons[0]=0; |
---|
1015 | } |
---|
1016 | } |
---|
1017 | |
---|
1018 | if (!strcmp(fword,"reload")) |
---|
1019 | { |
---|
1020 | if (current_level && player_list && player_list->focus) |
---|
1021 | { |
---|
1022 | edit_object=selected_object=NULL; |
---|
1023 | int32_t cx=player_list->focus->x,cy=player_list->focus->y; |
---|
1024 | |
---|
1025 | // save the old weapon array |
---|
1026 | int32_t *w=(int32_t *)malloc(total_weapons*sizeof(int32_t)); |
---|
1027 | memcpy(w,player_list->weapons,total_weapons*sizeof(int32_t)); |
---|
1028 | |
---|
1029 | char tmp[100]; |
---|
1030 | strcpy(tmp,current_level->name()); |
---|
1031 | the_game->load_level(tmp); |
---|
1032 | current_level->unactivate_all(); |
---|
1033 | |
---|
1034 | if (main_screen) // don't draw if graphics haven't been setup yet. |
---|
1035 | the_game->draw(); |
---|
1036 | player_list->reset_player(); |
---|
1037 | player_list->focus->x=cx; |
---|
1038 | player_list->focus->y=cy; |
---|
1039 | |
---|
1040 | memcpy(player_list->weapons,w,total_weapons*sizeof(int32_t)); |
---|
1041 | free(w); |
---|
1042 | |
---|
1043 | the_game->need_refresh(); |
---|
1044 | } |
---|
1045 | } |
---|
1046 | |
---|
1047 | if (!strcmp(fword,"unchop")) |
---|
1048 | { |
---|
1049 | vec2i tile = the_game->GetBgTile(dlast); |
---|
1050 | if (tile.x>=0 && tile.y>=0) |
---|
1051 | { |
---|
1052 | if (sscanf(command,"%s%d%d",fword,&l,&h)==3) |
---|
1053 | { |
---|
1054 | dprintf("unchopped %dx%d to ",l,h); |
---|
1055 | l=(l+the_game->btile_width()-1)/the_game->btile_width(); |
---|
1056 | h=(h+the_game->btile_height()-1)/the_game->btile_height(); |
---|
1057 | for (y=0,i=cur_bg; y<h; y++) |
---|
1058 | for (x=0; x<l; x++) |
---|
1059 | the_game->put_bg(tile.x+x,tile.y+y,i++); |
---|
1060 | dprintf("%dx%d\n",l,h); |
---|
1061 | } else dprintf(symbol_str("unchop1")); |
---|
1062 | |
---|
1063 | } |
---|
1064 | } |
---|
1065 | if (!strcmp(fword,"center")) |
---|
1066 | { |
---|
1067 | view *v=the_game->first_view; |
---|
1068 | for (; v; v=v->next) |
---|
1069 | { |
---|
1070 | v->pan_x=0; |
---|
1071 | v->pan_y=0; |
---|
1072 | } |
---|
1073 | the_game->need_refresh(); |
---|
1074 | } |
---|
1075 | |
---|
1076 | if (!strcmp(fword,"size")) |
---|
1077 | { |
---|
1078 | int l,w; |
---|
1079 | if (sscanf(command,"%s%d%d",fword,&l,&w)==3) |
---|
1080 | { |
---|
1081 | current_level->set_size(l,w); |
---|
1082 | dprintf("level is now %dx%d\n",l,w); |
---|
1083 | } else dprintf(symbol_str("size1")); |
---|
1084 | |
---|
1085 | |
---|
1086 | } |
---|
1087 | if (!strcmp(fword,"name")) |
---|
1088 | { |
---|
1089 | while (*command && *command!=' ') command++; |
---|
1090 | if (*command) |
---|
1091 | current_level->set_name(command+1); |
---|
1092 | dprintf(symbol_str("name_now"),current_level->name()); |
---|
1093 | } |
---|
1094 | if (!strcmp(fword,"set_first_level")) |
---|
1095 | { |
---|
1096 | strcpy(level_file,st); |
---|
1097 | dprintf("first level will be '%s'\n",level_file); |
---|
1098 | } |
---|
1099 | |
---|
1100 | if (!strcmp(fword,"load")) |
---|
1101 | { |
---|
1102 | if (!strcmp(st,"STARTING_LEVEL")) |
---|
1103 | st=level_file; |
---|
1104 | |
---|
1105 | dprintf("loading '%s'\n",st); |
---|
1106 | the_game->load_level(st); |
---|
1107 | current_level->unactivate_all(); |
---|
1108 | |
---|
1109 | the_game->need_refresh(); |
---|
1110 | } |
---|
1111 | |
---|
1112 | if (!strcmp(fword,"mem")) |
---|
1113 | { |
---|
1114 | if (st[0]) |
---|
1115 | show_char_mem(st); |
---|
1116 | else show_mem(); |
---|
1117 | } |
---|
1118 | |
---|
1119 | if (!strcmp(fword,"esave")) |
---|
1120 | { |
---|
1121 | dprintf(symbol_str("esave")); |
---|
1122 | save(); |
---|
1123 | } |
---|
1124 | |
---|
1125 | if (!strcmp(fword,"delete")) |
---|
1126 | { |
---|
1127 | if (selected_object) |
---|
1128 | { |
---|
1129 | if (!(dev&EDIT_MODE) && current_level->is_attacker(selected_object)) |
---|
1130 | the_game->show_help(symbol_str("nd_player")); |
---|
1131 | else |
---|
1132 | { |
---|
1133 | if (selected_object->controller()) |
---|
1134 | the_game->show_help(symbol_str("nd_player")); |
---|
1135 | else |
---|
1136 | { |
---|
1137 | current_level->delete_object(selected_object); |
---|
1138 | if (S_DELETE_SND>0) cache.sfx(S_DELETE_SND)->play(sfx_volume/2); |
---|
1139 | selected_object=NULL; |
---|
1140 | } |
---|
1141 | } |
---|
1142 | } else if (selected_light) |
---|
1143 | { |
---|
1144 | if (!edit_light) |
---|
1145 | { |
---|
1146 | if (current_level) |
---|
1147 | { |
---|
1148 | current_level->remove_light(selected_light); |
---|
1149 | if (S_DELETE_SND>0) cache.sfx(S_DELETE_SND)->play(sfx_volume/2); |
---|
1150 | } |
---|
1151 | else |
---|
1152 | delete_light(selected_light); |
---|
1153 | selected_light=NULL; |
---|
1154 | } |
---|
1155 | } else the_game->show_help(symbol_str("d_nosel")); |
---|
1156 | the_game->need_refresh(); |
---|
1157 | } |
---|
1158 | |
---|
1159 | if (!strcmp(fword,"create")) |
---|
1160 | { |
---|
1161 | char oname[100]; |
---|
1162 | sscanf(command,"%s%s",fword,oname); // read the type of object to create |
---|
1163 | int x,t=-1; |
---|
1164 | for (x=0; x<total_objects; x++) // find the object type by name |
---|
1165 | if (!strcmp(object_names[x],oname)) |
---|
1166 | t=x; |
---|
1167 | |
---|
1168 | if (t>=0) // did we find it? |
---|
1169 | { |
---|
1170 | vec2i pos = the_game->MouseToGame(dlast); |
---|
1171 | edit_object=create(t, pos.x, pos.y); |
---|
1172 | current_level->add_object(edit_object); |
---|
1173 | the_game->need_refresh(); |
---|
1174 | last_created_type=t; |
---|
1175 | } else |
---|
1176 | { |
---|
1177 | sprintf(fword,"No such object type : %s\n",oname); |
---|
1178 | the_game->show_help(fword); |
---|
1179 | } |
---|
1180 | } |
---|
1181 | |
---|
1182 | if (!strcmp(fword,"move")) |
---|
1183 | { |
---|
1184 | if (selected_object) |
---|
1185 | edit_object=selected_object; |
---|
1186 | |
---|
1187 | if (edit_object) |
---|
1188 | state=DEV_MOVE_OBJECT; |
---|
1189 | else the_game->show_help("No object selected"); |
---|
1190 | |
---|
1191 | } |
---|
1192 | if (!strcmp(fword,"move_light")) |
---|
1193 | { |
---|
1194 | if (selected_light) |
---|
1195 | edit_light=selected_light; |
---|
1196 | |
---|
1197 | if (edit_light) |
---|
1198 | state=DEV_MOVE_LIGHT; |
---|
1199 | else the_game->show_help("No light selected"); |
---|
1200 | |
---|
1201 | } |
---|
1202 | |
---|
1203 | |
---|
1204 | if (!strcmp(fword,"clear_auto")) |
---|
1205 | { |
---|
1206 | int32_t i,j; |
---|
1207 | for (i=0; i<current_level->foreground_width(); i++) |
---|
1208 | for (j=0; j<current_level->foreground_height(); j++) |
---|
1209 | current_level->clear_fg(i,j); |
---|
1210 | } |
---|
1211 | |
---|
1212 | if (!strcmp(fword,"fg_select")) |
---|
1213 | { |
---|
1214 | vec2i tile = the_game->GetFgTile(dlast); |
---|
1215 | if (tile.x >= 0 && tile.y >= 0 && |
---|
1216 | tile.x < current_level->foreground_width() && |
---|
1217 | tile.y < current_level->foreground_height()) |
---|
1218 | { |
---|
1219 | cur_fg=current_level->get_fg(tile.x, tile.y); |
---|
1220 | if (forew) |
---|
1221 | ((tile_picker *)forew->read(DEV_FG_PICKER))->recenter(forew->m_surf); |
---|
1222 | the_game->need_refresh(); |
---|
1223 | } |
---|
1224 | } |
---|
1225 | |
---|
1226 | if (!strcmp(fword,"toggle_fg_raise")) |
---|
1227 | { |
---|
1228 | vec2i tile = the_game->GetFgTile(dlast); |
---|
1229 | if (tile.x >= 0 && tile.y >= 0 && |
---|
1230 | tile.x < current_level->foreground_width() && |
---|
1231 | tile.y < current_level->foreground_height()) |
---|
1232 | current_level->fg_set_raised(tile.x, tile.y,!current_level->fg_raised(tile.x,tile.y)); |
---|
1233 | } |
---|
1234 | |
---|
1235 | if (!strcmp(fword,"fg_add")) |
---|
1236 | { |
---|
1237 | int x; |
---|
1238 | if (sscanf(st,"%d",&x)) |
---|
1239 | { |
---|
1240 | cur_fg++; |
---|
1241 | if (cur_fg<0) cur_fg=0; |
---|
1242 | if (cur_fg>=nforetiles) cur_fg=nforetiles-1; |
---|
1243 | |
---|
1244 | if (forew) |
---|
1245 | ((tile_picker *)forew->read(DEV_FG_PICKER))->recenter(forew->m_surf); |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | if (!strcmp(fword,"restart")) |
---|
1250 | { |
---|
1251 | current_level->restart(); |
---|
1252 | } |
---|
1253 | if (!strcmp(fword,"quit")) |
---|
1254 | { |
---|
1255 | the_game->end_session(); |
---|
1256 | } |
---|
1257 | |
---|
1258 | if (!strcmp(fword,"to_front")) |
---|
1259 | { |
---|
1260 | game_object *which=selected_object; |
---|
1261 | if (!selected_object) which=edit_object; |
---|
1262 | if (which) |
---|
1263 | current_level->to_front(which); |
---|
1264 | else the_game->show_help(symbol_str("forward?")); |
---|
1265 | } |
---|
1266 | |
---|
1267 | if (!strcmp(fword,"to_back")) |
---|
1268 | { |
---|
1269 | game_object *which=selected_object; |
---|
1270 | if (!selected_object) which=edit_object; |
---|
1271 | if (which) |
---|
1272 | current_level->to_back(which); |
---|
1273 | else the_game->show_help(symbol_str("back?")); |
---|
1274 | } |
---|
1275 | |
---|
1276 | if (!strcmp(fword,"set_aitype")) |
---|
1277 | { |
---|
1278 | game_object *which=selected_object; |
---|
1279 | if (!selected_object) which=edit_object; |
---|
1280 | if (which) |
---|
1281 | { |
---|
1282 | int x; |
---|
1283 | if (*st && sscanf(st,"%d",&x)!=EOF) |
---|
1284 | which->change_aitype(x); |
---|
1285 | else |
---|
1286 | { |
---|
1287 | switch (ev.key) |
---|
1288 | { |
---|
1289 | case '0' : which->change_aitype(0); break; |
---|
1290 | case '1' : which->change_aitype(1); break; |
---|
1291 | case '2' : which->change_aitype(2); break; |
---|
1292 | case '3' : which->change_aitype(3); break; |
---|
1293 | case '4' : which->change_aitype(4); break; |
---|
1294 | case '5' : which->change_aitype(5); break; |
---|
1295 | case '6' : which->change_aitype(6); break; |
---|
1296 | case '7' : which->change_aitype(7); break; |
---|
1297 | case '8' : which->change_aitype(8); break; |
---|
1298 | case '9' : which->change_aitype(9); break; |
---|
1299 | case ')' : which->change_aitype(10); break; |
---|
1300 | case '!' : which->change_aitype(11); break; |
---|
1301 | case '@' : which->change_aitype(12); break; |
---|
1302 | case '#' : which->change_aitype(13); break; |
---|
1303 | case '$' : which->change_aitype(14); break; |
---|
1304 | case '%' : which->change_aitype(15); break; |
---|
1305 | case '^' : which->change_aitype(16); break; |
---|
1306 | case '&' : which->change_aitype(17); break; |
---|
1307 | case '*' : which->change_aitype(18); break; |
---|
1308 | case '(' : which->change_aitype(19); break; |
---|
1309 | } |
---|
1310 | } |
---|
1311 | the_game->need_refresh(); |
---|
1312 | } |
---|
1313 | else the_game->show_help(symbol_str("aitype")); |
---|
1314 | } |
---|
1315 | } |
---|
1316 | |
---|
1317 | |
---|
1318 | void dev_controll::toggle_light_window() |
---|
1319 | { |
---|
1320 | if(lightw) |
---|
1321 | { |
---|
1322 | prop->setd("light create x", lightw->m_pos.x); |
---|
1323 | prop->setd("light create y", lightw->m_pos.y); |
---|
1324 | prop->setd("light create w", atoi(lightw->read(DEV_LIGHTW))); |
---|
1325 | prop->setd("light create h", atoi(lightw->read(DEV_LIGHTH))); |
---|
1326 | prop->setd("light create r1", atoi(lightw->read(DEV_LIGHTR1))); |
---|
1327 | prop->setd("light create r2", atoi(lightw->read(DEV_LIGHTR2))); |
---|
1328 | wm->close_window(lightw); |
---|
1329 | lightw = NULL; |
---|
1330 | return; |
---|
1331 | } |
---|
1332 | |
---|
1333 | int bh = 16 + 6, bw = 20 + 6, th = wm->font()->height() + 4; |
---|
1334 | |
---|
1335 | lightw = wm->new_window(prop->getd("light create x", 0), |
---|
1336 | prop->getd("light create y", 0), -1, -1, |
---|
1337 | new button_box(0, 0, DEV_LIGHT_BUTTON_BOX, 1, |
---|
1338 | new button(bw * 0, bh * 0, DEV_LIGHT0, cache.img(light_buttons[0]), |
---|
1339 | new button(bw * 1, bh * 0, DEV_LIGHT1, cache.img(light_buttons[1]), |
---|
1340 | new button(bw * 2, bh * 0, DEV_LIGHT2, cache.img(light_buttons[2]), |
---|
1341 | new button(bw * 0, bh * 1, DEV_LIGHT3, cache.img(light_buttons[3]), |
---|
1342 | new button(bw * 1, bh * 1, DEV_LIGHT4, cache.img(light_buttons[4]), |
---|
1343 | new button(bw * 2, bh * 1, DEV_LIGHT5, cache.img(light_buttons[5]), |
---|
1344 | new button(bw * 0, bh * 2, DEV_LIGHT6, cache.img(light_buttons[6]), |
---|
1345 | new button(bw * 1, bh * 2, DEV_LIGHT7, cache.img(light_buttons[7]), |
---|
1346 | new button(bw * 2, bh * 2, DEV_LIGHT8, cache.img(light_buttons[8]), |
---|
1347 | new button(bw * 0, bh * 3, DEV_LIGHT9, cache.img(light_buttons[9]), |
---|
1348 | new button(bw * 1, bh * 3, DEV_AMBIENT, cache.img(light_buttons[11]), |
---|
1349 | NULL))))))))))), |
---|
1350 | new text_field(0, bh * 4, DEV_LIGHTW, "W ", "******", |
---|
1351 | prop->getd("light create w", 0), |
---|
1352 | new text_field(0, bh * 4 + th * 1, DEV_LIGHTH, "H ", "******", |
---|
1353 | prop->getd("light create h", 0), |
---|
1354 | new text_field(0, bh * 4 + th * 2, DEV_LIGHTR1, "R1", "******", |
---|
1355 | prop->getd("light create r1", 1), |
---|
1356 | new text_field(0, bh * 4 + th * 3, DEV_LIGHTR2, "R2", "******", |
---|
1357 | prop->getd("light create r2", 100), NULL))))), |
---|
1358 | symbol_str("l_light")); |
---|
1359 | } |
---|
1360 | |
---|
1361 | void dev_controll::make_ai_window(game_object *o) |
---|
1362 | { |
---|
1363 | ai_object=o; |
---|
1364 | int th=wm->font()->height()+4,wl = 0, wh = 20; |
---|
1365 | if (figures[o->otype]->total_fields) |
---|
1366 | { |
---|
1367 | int maxl=0; |
---|
1368 | int i=0; |
---|
1369 | for (; i<figures[o->otype]->total_fields; i++) |
---|
1370 | if( strlen(figures[o->otype]->fields[i]->descript_name) > (unsigned)maxl ) |
---|
1371 | maxl=strlen(figures[o->otype]->fields[i]->descript_name); |
---|
1372 | |
---|
1373 | int owh=wh; |
---|
1374 | ifield *first=NULL,*last=NULL; |
---|
1375 | for (i=0; i<figures[o->otype]->total_fields; i++) |
---|
1376 | { |
---|
1377 | char tmp[200]; |
---|
1378 | strcpy(tmp,figures[o->otype]->fields[i]->descript_name); |
---|
1379 | for (int j=maxl-strlen(figures[o->otype]->fields[i]->descript_name); j; j--) |
---|
1380 | strcat(tmp," "); |
---|
1381 | int er; |
---|
1382 | ifield *p=new text_field(wl,wh,ID_NULL,tmp,"######", |
---|
1383 | (double)o->get_var_by_name(figures[o->otype]->fields[i]->real_name,er), |
---|
1384 | NULL); |
---|
1385 | if (last) |
---|
1386 | last->next=p; |
---|
1387 | else |
---|
1388 | first=p; |
---|
1389 | last=p; |
---|
1390 | wh+=th; |
---|
1391 | } |
---|
1392 | aiw=wm->new_window(prop->getd("ai x",0), |
---|
1393 | prop->getd("ai y",0), |
---|
1394 | -1,-1, |
---|
1395 | new button(wl,owh-20,DEV_AI_OK,cache.img(dev_ok),first),"ai"); |
---|
1396 | |
---|
1397 | } |
---|
1398 | else |
---|
1399 | { |
---|
1400 | aiw=wm->new_window(prop->getd("ai x",0), |
---|
1401 | prop->getd("ai y",0), |
---|
1402 | -1,-1, |
---|
1403 | new button(wl,wh-20,DEV_AI_OK,cache.img(dev_ok), |
---|
1404 | new text_field(wl,wh+th*0, DEV_AI_XVEL, symbol_str("ai_xvel"),"#####",(double)o->xvel(), |
---|
1405 | new text_field(wl,wh+th*1, DEV_AI_YVEL, symbol_str("ai_yvel"),"#####",(double)o->yvel(), |
---|
1406 | new text_field(wl,wh+th*2, DEV_AI_XACEL, symbol_str("ai_xacel"),"#####",(double)o->xacel(), |
---|
1407 | new text_field(wl,wh+th*3, DEV_AI_YACEL, symbol_str("ai_yacel"),"#####",(double)o->yacel(), |
---|
1408 | new text_field(wl,wh+th*4, DEV_AI_STTIME, symbol_str("ai_stime"),"####",(double)o->aistate_time(), |
---|
1409 | new text_field(wl,wh+th*5, DEV_AI_GRAVITY, symbol_str("ai_gravity"),"####",(double)o->gravity(), |
---|
1410 | new text_field(wl,wh+th*6, DEV_AI_HEALTH, symbol_str("ai_health"),"####",(double)o->hp(), |
---|
1411 | new text_field(wl,wh+th*7, DEV_AI_MORPHPR, symbol_str("ai_morph"),"####",(double)o->mp(), |
---|
1412 | new text_field(wl,wh+th*8, DEV_AI_TYPE, symbol_str("ai_type"),"####",(double)o->aitype(), |
---|
1413 | new text_field(wl,wh+th*9,DEV_AI_STATE, symbol_str("ai_state"),"####",(double)o->aistate(), |
---|
1414 | new text_field(wl,wh+th*10,DEV_AI_FADE, symbol_str("ai_fade"),"####",(double)o->fade_count(), |
---|
1415 | NULL)))))))))))),"ai"); |
---|
1416 | } |
---|
1417 | |
---|
1418 | wm->grab_focus(aiw); |
---|
1419 | } |
---|
1420 | |
---|
1421 | void dev_controll::notify_deleted_light(light_source *l) |
---|
1422 | { |
---|
1423 | if (l==edit_light) |
---|
1424 | { |
---|
1425 | if (ledit) |
---|
1426 | { |
---|
1427 | prop->setd("ledit x",ledit->m_pos.x); |
---|
1428 | prop->setd("ledit y",ledit->m_pos.y); |
---|
1429 | wm->close_window(ledit); ledit=NULL; |
---|
1430 | } |
---|
1431 | edit_light=NULL; |
---|
1432 | } |
---|
1433 | if (l==selected_light) |
---|
1434 | selected_light=NULL; |
---|
1435 | } |
---|
1436 | |
---|
1437 | void dev_controll::notify_deleted_object(game_object *o) |
---|
1438 | { |
---|
1439 | if (o==edit_object) |
---|
1440 | { |
---|
1441 | state=DEV_SELECT; |
---|
1442 | close_oedit_window(); |
---|
1443 | } |
---|
1444 | |
---|
1445 | if (o==ai_object) |
---|
1446 | close_ai_window(); |
---|
1447 | if (o==search_object) |
---|
1448 | { if (search_window) |
---|
1449 | toggle_search_window(); |
---|
1450 | search_object=NULL; |
---|
1451 | } |
---|
1452 | if (o==link_object) |
---|
1453 | link_object=NULL; |
---|
1454 | if (o==selected_object) |
---|
1455 | { |
---|
1456 | selected_object=NULL; |
---|
1457 | state=DEV_SELECT; |
---|
1458 | } |
---|
1459 | |
---|
1460 | } |
---|
1461 | |
---|
1462 | void dev_controll::close_ai_window() |
---|
1463 | { |
---|
1464 | if (aiw) |
---|
1465 | { |
---|
1466 | game_object *o=ai_object; |
---|
1467 | int32_t x; |
---|
1468 | if (o) |
---|
1469 | { |
---|
1470 | if (figures[o->otype]->total_fields) |
---|
1471 | { |
---|
1472 | ifield *f=aiw->inm->get(DEV_AI_OK)->next; |
---|
1473 | for (int i=0; i<figures[o->otype]->total_fields; i++) |
---|
1474 | { |
---|
1475 | x=atoi(f->read()); |
---|
1476 | char *v=figures[o->otype]->fields[i]->real_name; |
---|
1477 | int er; |
---|
1478 | if (o->get_var_by_name(v,er)!=x) |
---|
1479 | o->set_var_by_name(v,x); |
---|
1480 | f=f->next; |
---|
1481 | } |
---|
1482 | } |
---|
1483 | else |
---|
1484 | { |
---|
1485 | x=atoi(aiw->read(DEV_AI_XVEL)); if (x!=o->xvel()) o->set_xvel(x); |
---|
1486 | x=atoi(aiw->read(DEV_AI_YVEL)); if (x!=o->yvel()) o->set_yvel(x); |
---|
1487 | |
---|
1488 | x=atoi(aiw->read(DEV_AI_XACEL)); if (x!=o->xacel()) o->set_xacel(x); |
---|
1489 | x=atoi(aiw->read(DEV_AI_YACEL)); if (x!=o->yacel()) o->set_yacel(x); |
---|
1490 | |
---|
1491 | x=atoi(aiw->read(DEV_AI_STTIME)); if (x!=o->aistate_time()) o->set_aistate_time(x); |
---|
1492 | x=atoi(aiw->read(DEV_AI_GRAVITY)); if (x!=o->gravity()) o->set_gravity(x); |
---|
1493 | |
---|
1494 | x=atoi(aiw->read(DEV_AI_HEALTH)); if (x!=o->hp()) o->set_hp(x); |
---|
1495 | x=atoi(aiw->read(DEV_AI_MORPHPR)); if (x!=o->mp()) o->set_mp(x); |
---|
1496 | |
---|
1497 | x=atoi(aiw->read(DEV_AI_TYPE)); if (x!=o->aitype()) o->set_aitype(x); |
---|
1498 | x=atoi(aiw->read(DEV_AI_STATE)); if (x!=o->aistate()) o->set_aistate(x); |
---|
1499 | x=atoi(aiw->read(DEV_AI_FADE)); if (x!=o->fade_count()) o->set_fade_count(x); |
---|
1500 | } |
---|
1501 | } |
---|
1502 | prop->setd("ai x",aiw->m_pos.x); |
---|
1503 | prop->setd("ai y",aiw->m_pos.y); |
---|
1504 | wm->close_window(aiw); |
---|
1505 | aiw=NULL; |
---|
1506 | ai_object=NULL; |
---|
1507 | the_game->need_refresh(); |
---|
1508 | } |
---|
1509 | } |
---|
1510 | |
---|
1511 | |
---|
1512 | void dev_controll::area_handle_input(Event &ev) |
---|
1513 | { |
---|
1514 | |
---|
1515 | if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button) |
---|
1516 | { |
---|
1517 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
1518 | if (!current_level) return ; |
---|
1519 | current_area=current_level->area_list=new area_controller(pos.x, pos.y, |
---|
1520 | the_game->ftile_width(), |
---|
1521 | the_game->ftile_height(), |
---|
1522 | current_level->area_list); |
---|
1523 | the_game->need_refresh(); |
---|
1524 | state=DEV_DRAG_AREA_BOTTOM; |
---|
1525 | } |
---|
1526 | } |
---|
1527 | |
---|
1528 | void dev_controll::close_area_win(int read_values) |
---|
1529 | { |
---|
1530 | if (area_win) |
---|
1531 | { |
---|
1532 | prop->setd("area_box x",area_win->m_pos.x); |
---|
1533 | prop->setd("area_box y",area_win->m_pos.y); |
---|
1534 | |
---|
1535 | if (current_area && read_values) |
---|
1536 | { |
---|
1537 | current_area->ambient=atoi(area_win->read(DEV_AREA_AMBIENT)); |
---|
1538 | current_area->ambient_speed=atoi(area_win->read(DEV_AREA_AMBIENT_SPEED)); |
---|
1539 | current_area->view_xoff=atoi(area_win->read(DEV_AREA_VIEW_XOFF)); |
---|
1540 | current_area->view_yoff=atoi(area_win->read(DEV_AREA_VIEW_YOFF)); |
---|
1541 | current_area->view_xoff_speed=atoi(area_win->read(DEV_AREA_VIEW_XOFF_SPEED)); |
---|
1542 | current_area->view_yoff_speed=atoi(area_win->read(DEV_AREA_VIEW_YOFF_SPEED)); |
---|
1543 | } |
---|
1544 | wm->close_window(area_win); |
---|
1545 | area_win=NULL; |
---|
1546 | } |
---|
1547 | } |
---|
1548 | |
---|
1549 | void dev_controll::pick_handle_input(Event &ev) |
---|
1550 | { |
---|
1551 | area_controller *find=NULL; |
---|
1552 | int find_top=0; |
---|
1553 | if (!current_level) return; |
---|
1554 | if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button) |
---|
1555 | { |
---|
1556 | vec2i m = last_demo_mpos; |
---|
1557 | view *v = the_game->GetView(m); |
---|
1558 | for (area_controller *a=current_level->area_list; a; a=a->next) |
---|
1559 | { |
---|
1560 | vec2i pos1 = the_game->GameToMouse(vec2i(a->x, a->y), v); |
---|
1561 | vec2i pos2 = the_game->GameToMouse(vec2i(a->x + a->w, a->y + a->h), v); |
---|
1562 | if (abs(pos1.x - m.x) < 2 && abs(pos1.y - m.y) < 2) |
---|
1563 | { find = a; find_top = 1; } |
---|
1564 | else if (abs(pos2.x - m.x) < 2 && abs(pos2.y - m.y) < 2) |
---|
1565 | { find = a; find_top = 0; } |
---|
1566 | } |
---|
1567 | |
---|
1568 | time_marker now; |
---|
1569 | int dc=now.diff_time(&last_area_click)<0.5; |
---|
1570 | last_area_click.get_time(); |
---|
1571 | if (find && current_area && dc) |
---|
1572 | { |
---|
1573 | if (area_win) close_area_win(0); |
---|
1574 | int wl=0,wh=0,th=wm->font()->height()+12,bw=cache.img(dev_ok)->Size().x+10; |
---|
1575 | area_win=wm->new_window(prop->getd("area_box x",0), |
---|
1576 | prop->getd("area_box y",0), |
---|
1577 | -1,-1, |
---|
1578 | |
---|
1579 | new button(wl+bw*0,wh-8,DEV_AREA_OK,cache.img(dev_ok), |
---|
1580 | new button(wl+bw*1,wh-8,DEV_AREA_DELETE,cache.img(dev_del), |
---|
1581 | |
---|
1582 | new text_field(wl,wh+th*1,DEV_AREA_AMBIENT, symbol_str("a_ambient"),"******",current_area->ambient, |
---|
1583 | new text_field(wl,wh+th*2,DEV_AREA_AMBIENT_SPEED, symbol_str("a_aspeed"),"******",current_area->ambient_speed, |
---|
1584 | new text_field(wl,wh+th*3,DEV_AREA_VIEW_XOFF, symbol_str("a_view_xoff"),"******",current_area->view_xoff, |
---|
1585 | new text_field(wl,wh+th*4,DEV_AREA_VIEW_YOFF, symbol_str("a_view_yoff"),"******",current_area->view_yoff, |
---|
1586 | new text_field(wl,wh+th*5,DEV_AREA_VIEW_XOFF_SPEED, symbol_str("a_view_xspd"),"******",current_area->view_xoff_speed, |
---|
1587 | new text_field(wl,wh+th*6,DEV_AREA_VIEW_YOFF_SPEED, symbol_str("a_view_yspd"),"******",current_area->view_yoff_speed, |
---|
1588 | NULL))))))))); |
---|
1589 | } else if (find) |
---|
1590 | { |
---|
1591 | current_area=find; |
---|
1592 | current_area->active=1; |
---|
1593 | if (find_top) |
---|
1594 | state=DEV_DRAG_AREA_TOP; |
---|
1595 | else state=DEV_DRAG_AREA_BOTTOM; |
---|
1596 | the_game->need_refresh(); |
---|
1597 | } else if (current_area) |
---|
1598 | { |
---|
1599 | current_area->active=0; |
---|
1600 | current_area=NULL; |
---|
1601 | the_game->need_refresh(); |
---|
1602 | } |
---|
1603 | } |
---|
1604 | } |
---|
1605 | |
---|
1606 | void dev_controll::close_oedit_window() |
---|
1607 | { |
---|
1608 | if (oedit) |
---|
1609 | { |
---|
1610 | prop->setd("oedit x",oedit->m_pos.x); |
---|
1611 | prop->setd("oedit y",oedit->m_pos.y); |
---|
1612 | wm->close_window(oedit); |
---|
1613 | oedit=NULL; |
---|
1614 | edit_object=NULL; |
---|
1615 | } |
---|
1616 | } |
---|
1617 | |
---|
1618 | int screen_shot_on=1; |
---|
1619 | int sshot_fcount=-1; |
---|
1620 | |
---|
1621 | void dev_controll::handle_event(Event &ev) |
---|
1622 | { |
---|
1623 | int32_t x,y; |
---|
1624 | if (link_object && (dlast.x!=last_link_x || dlast.y!=last_link_y)) |
---|
1625 | { |
---|
1626 | last_link_x=dlast.x; |
---|
1627 | last_link_y=dlast.y; |
---|
1628 | the_game->need_refresh(); |
---|
1629 | } |
---|
1630 | |
---|
1631 | if (dev_menu && dev_menu->handle_event(ev,main_screen)) return ; |
---|
1632 | |
---|
1633 | if (!current_level) return ; |
---|
1634 | |
---|
1635 | for (x=0; x<total_pals; x++) |
---|
1636 | pal_wins[x]->handle_event(ev); |
---|
1637 | if (ev.type==EV_MOUSE_MOVE) |
---|
1638 | dlast = last_demo_mpos; |
---|
1639 | if (dev_console && dev_console->handle_event(ev)) |
---|
1640 | return; |
---|
1641 | |
---|
1642 | if (ev.type==EV_KEY && ev.key==JK_F2) |
---|
1643 | write_PCX(main_screen,pal,"scrnshot.pcx"); |
---|
1644 | else if (ev.type==EV_KEY && ev.key==JK_F3) |
---|
1645 | { |
---|
1646 | char name[100]; |
---|
1647 | sprintf(name,"shot%04d.pcx",screen_shot_on++); |
---|
1648 | write_PCX(main_screen,pal,name); |
---|
1649 | } else if (ev.type==EV_KEY && ev.key==JK_F5) |
---|
1650 | { |
---|
1651 | if (sshot_fcount!=-1) |
---|
1652 | { |
---|
1653 | sshot_fcount=-1; |
---|
1654 | the_game->show_help(symbol_str("seqs_off")); |
---|
1655 | } |
---|
1656 | else |
---|
1657 | { |
---|
1658 | sshot_fcount=0; |
---|
1659 | the_game->show_help(symbol_str("seqs_on")); |
---|
1660 | } |
---|
1661 | } |
---|
1662 | |
---|
1663 | switch (state) |
---|
1664 | { |
---|
1665 | case DEV_MOUSE_RELEASE : |
---|
1666 | { |
---|
1667 | if (!ev.mouse_button) |
---|
1668 | state=DEV_SELECT; |
---|
1669 | } break; |
---|
1670 | |
---|
1671 | case DEV_CREATE_OBJECT : |
---|
1672 | { |
---|
1673 | if (!ev.mouse_button) |
---|
1674 | state=DEV_MOVE_OBJECT; |
---|
1675 | } break; |
---|
1676 | |
---|
1677 | |
---|
1678 | case DEV_MOVE_OBJECT : |
---|
1679 | { |
---|
1680 | if (!edit_object) |
---|
1681 | { state=DEV_SELECT; } |
---|
1682 | else |
---|
1683 | { |
---|
1684 | if (ev.type==EV_MOUSE_MOVE) |
---|
1685 | { |
---|
1686 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
1687 | edit_object->x = snap_x(pos.x); |
---|
1688 | edit_object->y = snap_y(pos.y); |
---|
1689 | the_game->need_refresh(); |
---|
1690 | } |
---|
1691 | else if (ev.mouse_button==1 && ev.window==NULL) |
---|
1692 | { |
---|
1693 | state=DEV_MOUSE_RELEASE; |
---|
1694 | selected_object=edit_object=NULL; |
---|
1695 | } |
---|
1696 | if (ev.window==NULL && ev.type==EV_KEY && ev.key=='d') |
---|
1697 | { |
---|
1698 | int32_t xv=0,yv=100; |
---|
1699 | edit_object->try_move(edit_object->x,edit_object->y,xv,yv,1); |
---|
1700 | edit_object->y+=yv; |
---|
1701 | state=DEV_SELECT; |
---|
1702 | selected_object=edit_object=NULL; |
---|
1703 | } |
---|
1704 | } |
---|
1705 | } break; |
---|
1706 | |
---|
1707 | |
---|
1708 | case DEV_MOVE_LIGHT : |
---|
1709 | { |
---|
1710 | if (edit_light) |
---|
1711 | { |
---|
1712 | if (ev.type==EV_MOUSE_MOVE) |
---|
1713 | { |
---|
1714 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
1715 | edit_light->x = snap_x(pos.x); |
---|
1716 | edit_light->y = snap_y(pos.y); |
---|
1717 | |
---|
1718 | edit_light->calc_range(); |
---|
1719 | the_game->need_refresh(); |
---|
1720 | } else if (ev.type==EV_KEY) |
---|
1721 | { |
---|
1722 | int rd=0; |
---|
1723 | switch (ev.key) |
---|
1724 | { |
---|
1725 | case '+' : |
---|
1726 | { |
---|
1727 | if (edit_light->type==9) |
---|
1728 | { |
---|
1729 | if (edit_light->inner_radius<64) |
---|
1730 | { edit_light->inner_radius++; rd=1; } |
---|
1731 | } else { edit_light->outer_radius++; rd=1; } |
---|
1732 | } break; |
---|
1733 | case '-' : |
---|
1734 | { |
---|
1735 | if (edit_light->type==9) |
---|
1736 | { |
---|
1737 | if (edit_light->inner_radius>0) |
---|
1738 | { edit_light->inner_radius--; rd=1; } |
---|
1739 | } else if (edit_light->outer_radius>edit_light->inner_radius+1) |
---|
1740 | { edit_light->outer_radius--; rd=1; } |
---|
1741 | } break; |
---|
1742 | case JK_RIGHT : |
---|
1743 | { |
---|
1744 | if (edit_light->type==9) |
---|
1745 | { edit_light->xshift++; rd=1; } |
---|
1746 | else if (edit_light->xshift>0) |
---|
1747 | { edit_light->xshift--; rd=1; } |
---|
1748 | } break; |
---|
1749 | case JK_LEFT : |
---|
1750 | { |
---|
1751 | if (edit_light->type==9) |
---|
1752 | { |
---|
1753 | if (edit_light->xshift>1) |
---|
1754 | { edit_light->xshift--; rd=1; } |
---|
1755 | } |
---|
1756 | else |
---|
1757 | { edit_light->xshift++; rd=1; } |
---|
1758 | } break; |
---|
1759 | case JK_UP : |
---|
1760 | { |
---|
1761 | if (edit_light->type==9) |
---|
1762 | { edit_light->yshift++; rd=1; } |
---|
1763 | else if (edit_light->yshift>0) |
---|
1764 | { edit_light->yshift--; rd=1; } |
---|
1765 | } break; |
---|
1766 | case JK_DOWN : |
---|
1767 | { |
---|
1768 | if (edit_light->type==9) |
---|
1769 | { |
---|
1770 | if (edit_light->yshift>1) |
---|
1771 | { edit_light->yshift--; rd=1; } |
---|
1772 | } |
---|
1773 | else |
---|
1774 | { edit_light->yshift++; rd=1; } |
---|
1775 | } break; |
---|
1776 | |
---|
1777 | } |
---|
1778 | if (rd) |
---|
1779 | { |
---|
1780 | edit_light->calc_range(); |
---|
1781 | the_game->need_refresh(); |
---|
1782 | } |
---|
1783 | |
---|
1784 | } |
---|
1785 | } |
---|
1786 | |
---|
1787 | if ((ev.mouse_button==1 && ev.window==NULL) || !edit_light) |
---|
1788 | state=DEV_MOUSE_RELEASE; |
---|
1789 | } break; |
---|
1790 | |
---|
1791 | |
---|
1792 | case DEV_DRAG_AREA_BOTTOM : |
---|
1793 | { |
---|
1794 | if (current_area) |
---|
1795 | { |
---|
1796 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
1797 | if (pos.x>current_area->x && pos.y>current_area->y) |
---|
1798 | { |
---|
1799 | if (pos.x-current_area->x!=current_area->w || pos.y-current_area->y!=current_area->h) |
---|
1800 | { |
---|
1801 | the_game->need_refresh(); |
---|
1802 | current_area->w=pos.x-current_area->x; |
---|
1803 | current_area->h=pos.y-current_area->y; |
---|
1804 | } |
---|
1805 | } |
---|
1806 | if (ev.type==EV_MOUSE_BUTTON && !ev.mouse_button) |
---|
1807 | { |
---|
1808 | current_area->active=0; |
---|
1809 | state=DEV_SELECT; |
---|
1810 | } |
---|
1811 | } |
---|
1812 | } break; |
---|
1813 | |
---|
1814 | case DEV_DRAG_AREA_TOP : |
---|
1815 | { |
---|
1816 | if (current_area) |
---|
1817 | { |
---|
1818 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
1819 | if (pos.x<current_area->x+current_area->w && pos.y<current_area->y+current_area->h) |
---|
1820 | { |
---|
1821 | if (pos.x!=current_area->x || pos.y!=current_area->y) |
---|
1822 | { |
---|
1823 | the_game->need_refresh(); |
---|
1824 | current_area->x=pos.x; |
---|
1825 | current_area->y=pos.y; |
---|
1826 | } |
---|
1827 | } |
---|
1828 | if (ev.type==EV_MOUSE_BUTTON && !ev.mouse_button) |
---|
1829 | { |
---|
1830 | current_area->active=0; |
---|
1831 | state=DEV_SELECT; |
---|
1832 | } |
---|
1833 | } |
---|
1834 | } break; |
---|
1835 | |
---|
1836 | case DEV_SELECT : |
---|
1837 | { |
---|
1838 | if (dev&EDIT_MODE) |
---|
1839 | { |
---|
1840 | game_object *old=selected_object; |
---|
1841 | selected_object=NULL; |
---|
1842 | if (ev.window==NULL) |
---|
1843 | { |
---|
1844 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
1845 | |
---|
1846 | if (!(dev & MAP_MODE)) |
---|
1847 | { |
---|
1848 | if (dev&DRAW_PEOPLE_LAYER) |
---|
1849 | selected_object=current_level->find_object(pos.x, pos.y); |
---|
1850 | light_source *old_light=selected_light; |
---|
1851 | selected_light = selected_object ? NULL : find_light(pos.x, pos.y); |
---|
1852 | if (selected_light!=old_light) |
---|
1853 | the_game->need_refresh(); |
---|
1854 | } else { selected_light=NULL; } |
---|
1855 | |
---|
1856 | if (edit_mode==ID_DMODE_DRAW) |
---|
1857 | { |
---|
1858 | // FIXME: there is a bug here, the two if conditionals are the same |
---|
1859 | if (ev.mouse_button==1 && !selected_object && !selected_light) |
---|
1860 | { |
---|
1861 | vec2i tile = the_game->GetFgTile(last_demo_mpos); |
---|
1862 | if (tile.x>=0 && tile.y>=0 && tile.x<current_level->foreground_width() && |
---|
1863 | tile.y<current_level->foreground_height()) |
---|
1864 | current_level->put_fg(tile.x,tile.y,raise_all ? make_above_tile(cur_fg) : cur_fg); |
---|
1865 | the_game->need_refresh(); |
---|
1866 | } else if (ev.mouse_button==1 && !selected_object && !selected_light) |
---|
1867 | { |
---|
1868 | vec2i tile = the_game->GetBgTile(last_demo_mpos); |
---|
1869 | if (tile.x>=0 && tile.y>=0 && tile.x<current_level->background_width() && |
---|
1870 | tile.y<current_level->background_height()) |
---|
1871 | current_level->put_bg(tile.x,tile.y,cur_fg); |
---|
1872 | the_game->need_refresh(); |
---|
1873 | } |
---|
1874 | } else if (edit_mode==ID_DMODE_AREA) |
---|
1875 | area_handle_input(ev); |
---|
1876 | else if (edit_mode==ID_DMODE_PICK) |
---|
1877 | pick_handle_input(ev); |
---|
1878 | } |
---|
1879 | |
---|
1880 | if (old!=selected_object) |
---|
1881 | the_game->need_refresh(); |
---|
1882 | |
---|
1883 | |
---|
1884 | if (ev.mouse_button) |
---|
1885 | { |
---|
1886 | if (selected_object) |
---|
1887 | { |
---|
1888 | if (edit_object && edit_object!=selected_object) |
---|
1889 | edit_object->add_object(selected_object); |
---|
1890 | |
---|
1891 | if (oedit) |
---|
1892 | close_oedit_window(); |
---|
1893 | |
---|
1894 | int bw=20+6,bh=16+6; |
---|
1895 | |
---|
1896 | oedit=wm->new_window(prop->getd("oedit x",0), |
---|
1897 | prop->getd("oedit y",0), |
---|
1898 | -1,-1,new button_box(0,0,ID_NULL,1, |
---|
1899 | new button(bw*0,0,DEV_OEDIT_OK,cache.img(dev_ok), |
---|
1900 | new button(bw*1,0,DEV_OEDIT_MOVE,cache.img(dev_move), |
---|
1901 | new button(bw*2,0,DEV_OEDIT_FRONT,cache.img(dev_front), |
---|
1902 | new button(bw*3,0,DEV_OEDIT_BACK,cache.img(dev_back), |
---|
1903 | new button(bw*4,0,DEV_OEDIT_COPY,cache.img(dev_copy), |
---|
1904 | new button(bw*0,bh*1,DEV_OEDIT_DELETE,cache.img(dev_del), |
---|
1905 | NULL)))))), |
---|
1906 | new button(bw*5,bh*0,DEV_OEDIT_AI,cache.img(dev_ai), |
---|
1907 | |
---|
1908 | new button_box(bw*1,bh*1,DEV_OEDIT_CHAR_BOX,0, |
---|
1909 | new button(bw*1,bh*1,DEV_OEDIT_LEFT,cache.img(dev_char_left), |
---|
1910 | new button(bw*2,bh*1,DEV_OEDIT_RIGHT,cache.img(dev_char_right),NULL)), |
---|
1911 | |
---|
1912 | new button(bw*3,bh*1,DEV_OBJECTS_DELETE,cache.img(dev_objects), |
---|
1913 | new button(bw*4,bh*1,DEV_LIGHTS_DELETE,cache.img(dev_lights),NULL))))), |
---|
1914 | symbol_str("l_EDIT")); |
---|
1915 | |
---|
1916 | |
---|
1917 | edit_object=selected_object; |
---|
1918 | } else if (selected_light) |
---|
1919 | { |
---|
1920 | if (ledit) |
---|
1921 | { |
---|
1922 | prop->setd("ledit x",ledit->m_pos.x); |
---|
1923 | prop->setd("ledit x",ledit->m_pos.y); |
---|
1924 | wm->close_window(ledit); |
---|
1925 | } |
---|
1926 | int bw=20+6,bh=16+6,th=wm->font()->height()+4; |
---|
1927 | edit_light=selected_light; |
---|
1928 | if (edit_object) |
---|
1929 | { |
---|
1930 | edit_object->add_light(edit_light); |
---|
1931 | edit_light->known=1; |
---|
1932 | } |
---|
1933 | ledit=wm->new_window(prop->getd("ledit x",0), |
---|
1934 | prop->getd("ledit y",0), |
---|
1935 | -1,-1, |
---|
1936 | new button_box(0,0,ID_NULL,1, |
---|
1937 | new button(bw*0,0,DEV_LEDIT_OK,cache.img(dev_ok), |
---|
1938 | new button(bw*1,0,DEV_LEDIT_MOVE,cache.img(dev_move), |
---|
1939 | new button(bw*2,0,DEV_LEDIT_COPY,cache.img(dev_copy), |
---|
1940 | new button(bw*3,0,DEV_LEDIT_DEL,cache.img(dev_del),NULL)))), |
---|
1941 | new text_field(0,bh,DEV_LEDIT_W, "W ","******",edit_light->xshift, |
---|
1942 | new text_field(0,bh+th*1,DEV_LEDIT_H, "H ","******",edit_light->yshift, |
---|
1943 | new text_field(0,bh+th*2,DEV_LEDIT_R1,"R1","******",(int)(edit_light->inner_radius), |
---|
1944 | new text_field(0,bh+th*3,DEV_LEDIT_R2,"R2","******",(int)(edit_light->outer_radius), |
---|
1945 | NULL)))))); |
---|
1946 | } |
---|
1947 | else if (ev.window==NULL) |
---|
1948 | { |
---|
1949 | if (dlast.x>=0 && dlast.y>=0 && edit_mode==ID_DMODE_DRAW) |
---|
1950 | { |
---|
1951 | if ((dev & DRAW_FG_LAYER) && ev.mouse_button==1) |
---|
1952 | { |
---|
1953 | vec2i tile = the_game->GetFgTile(last_demo_mpos); |
---|
1954 | if (tile.x>=0 && tile.y>=0 && tile.x<current_level->foreground_width() && |
---|
1955 | tile.y<current_level->foreground_height()) |
---|
1956 | the_game->put_fg(tile.x,tile.y,raise_all ? make_above_tile(cur_fg) : cur_fg); |
---|
1957 | } |
---|
1958 | if ((dev & DRAW_BG_LAYER) && ev.mouse_button==2) |
---|
1959 | { |
---|
1960 | vec2i tile = the_game->GetBgTile(last_demo_mpos); |
---|
1961 | if (tile.x>=0 && tile.y>=0 && tile.x<current_level->background_width() && |
---|
1962 | tile.y<current_level->background_height()) |
---|
1963 | the_game->put_bg(tile.x,tile.y,cur_bg); |
---|
1964 | } |
---|
1965 | } |
---|
1966 | } |
---|
1967 | } |
---|
1968 | } |
---|
1969 | } |
---|
1970 | default: |
---|
1971 | break; |
---|
1972 | } |
---|
1973 | |
---|
1974 | switch (ev.type) |
---|
1975 | { |
---|
1976 | case EV_MESSAGE : |
---|
1977 | { |
---|
1978 | switch (ev.message.id) |
---|
1979 | { |
---|
1980 | case ID_DMODE_DRAW : |
---|
1981 | case ID_DMODE_PICK : |
---|
1982 | case ID_DMODE_FILL : |
---|
1983 | case ID_DMODE_LINE : |
---|
1984 | case ID_DMODE_RECT : |
---|
1985 | case ID_DMODE_BAR : |
---|
1986 | case ID_DMODE_AREA : |
---|
1987 | { |
---|
1988 | edit_mode=ev.message.id; |
---|
1989 | } break; |
---|
1990 | /* case ID_ENLARGE_RENDER : |
---|
1991 | { |
---|
1992 | if (!small_render) |
---|
1993 | double_render(); |
---|
1994 | else |
---|
1995 | single_render(); |
---|
1996 | |
---|
1997 | view_shift_disabled=!view_shift_disabled; |
---|
1998 | } break; */ |
---|
1999 | |
---|
2000 | case ID_SEARCH : |
---|
2001 | { |
---|
2002 | toggle_search_window(); |
---|
2003 | } break; |
---|
2004 | case ID_SEARCH_FOREWARD : |
---|
2005 | { search_forward(); |
---|
2006 | } break; |
---|
2007 | case ID_SEARCH_BACKWARD : |
---|
2008 | { search_forward(); |
---|
2009 | } break; |
---|
2010 | case ID_CANCEL : |
---|
2011 | { |
---|
2012 | if (mess_win) |
---|
2013 | { |
---|
2014 | wm->close_window(mess_win); |
---|
2015 | mess_win=NULL; |
---|
2016 | } break; |
---|
2017 | } break; |
---|
2018 | case ID_LEVEL_LOAD : |
---|
2019 | { |
---|
2020 | if (!mess_win) |
---|
2021 | { |
---|
2022 | mess_win=file_dialog(symbol_str("level_name"),current_level ? current_level->name() : "", |
---|
2023 | ID_LEVEL_LOAD_OK,symbol_str("ok_button"),ID_CANCEL,symbol_str("cancel_button"), |
---|
2024 | symbol_str("FILENAME"),ID_MESS_STR1); |
---|
2025 | wm->grab_focus(mess_win); |
---|
2026 | } |
---|
2027 | } break; |
---|
2028 | case ID_LEVEL_LOAD_OK : |
---|
2029 | { |
---|
2030 | char cmd[100]; |
---|
2031 | sprintf(cmd,"load %s",mess_win->read(ID_MESS_STR1)); |
---|
2032 | dev_cont->do_command(cmd,ev); |
---|
2033 | wm->Push(new Event(ID_CANCEL,NULL)); // close window |
---|
2034 | } break; |
---|
2035 | case ID_GAME_SAVE : |
---|
2036 | { |
---|
2037 | current_level->save("savegame.spe",1); |
---|
2038 | the_game->show_help(symbol_str("saved_game")); |
---|
2039 | the_game->need_refresh(); |
---|
2040 | } break; |
---|
2041 | case ID_LEVEL_SAVE : |
---|
2042 | { if (current_level) |
---|
2043 | { |
---|
2044 | if (current_level->save(current_level->name(),0)) |
---|
2045 | { |
---|
2046 | char msg[100]; |
---|
2047 | sprintf(msg,symbol_str("saved_level"),current_level->name()); |
---|
2048 | the_game->show_help(msg); |
---|
2049 | the_game->need_refresh(); |
---|
2050 | } |
---|
2051 | } |
---|
2052 | else the_game->show_help("no current level, cannot save"); |
---|
2053 | } break; |
---|
2054 | case ID_LEVEL_SAVEAS : |
---|
2055 | { |
---|
2056 | if (!mess_win) |
---|
2057 | { |
---|
2058 | mess_win=file_dialog(symbol_str("saveas_name"),current_level ? current_level->name() : "untitled.spe", |
---|
2059 | ID_LEVEL_SAVEAS_OK,symbol_str("ok_button"), |
---|
2060 | ID_CANCEL,symbol_str("cancel_button"), |
---|
2061 | symbol_str("FILENAME"),ID_MESS_STR1); |
---|
2062 | wm->grab_focus(mess_win); |
---|
2063 | } |
---|
2064 | } break; |
---|
2065 | case ID_LEVEL_SAVEAS_OK : |
---|
2066 | { |
---|
2067 | if (current_level) |
---|
2068 | { |
---|
2069 | current_level->set_name(mess_win->read(ID_MESS_STR1)); |
---|
2070 | wm->Push(new Event(ID_CANCEL,NULL)); // close window after save |
---|
2071 | wm->Push(new Event(ID_LEVEL_SAVE,NULL)); |
---|
2072 | } |
---|
2073 | } break; |
---|
2074 | case ID_EDIT_SAVE : |
---|
2075 | { |
---|
2076 | do_command("esave",ev); |
---|
2077 | the_game->show_help(symbol_str("edit_saved")); |
---|
2078 | } break; |
---|
2079 | case ID_CACHE_PROFILE : |
---|
2080 | { |
---|
2081 | if (current_level && !cache.prof_is_on()) |
---|
2082 | { |
---|
2083 | cache.prof_init(); |
---|
2084 | the_game->show_help("Cache profiling is now on."); |
---|
2085 | } |
---|
2086 | else the_game->show_help("Cache profiling is already on!"); |
---|
2087 | } break; |
---|
2088 | |
---|
2089 | case ID_CACHE_PROFILE_END : // ask the user for a file name to save as |
---|
2090 | { |
---|
2091 | if (cache.prof_is_on()) |
---|
2092 | { |
---|
2093 | cache.prof_uninit(); |
---|
2094 | the_game->show_help(symbol_str("prof_off")); |
---|
2095 | } else the_game->show_help(symbol_str("prof")); |
---|
2096 | } break; |
---|
2097 | |
---|
2098 | case ID_LEVEL_NEW : |
---|
2099 | { |
---|
2100 | if (!mess_win) |
---|
2101 | { |
---|
2102 | mess_win=wm->new_window(xres/2,yres/2,-1,-1, |
---|
2103 | new button(10,20,ID_LEVEL_NEW_OK,symbol_str("YES"), |
---|
2104 | new button(40,20,ID_CANCEL,symbol_str("NO"), |
---|
2105 | new info_field(0,0,ID_NULL,symbol_str("sure?"),NULL))),symbol_str("New?")); |
---|
2106 | wm->grab_focus(mess_win); |
---|
2107 | } |
---|
2108 | } break; |
---|
2109 | case ID_LEVEL_NEW_OK : |
---|
2110 | { |
---|
2111 | wm->Push(new Event(ID_CANCEL,NULL)); // close_window |
---|
2112 | if (current_level) |
---|
2113 | delete current_level; |
---|
2114 | current_level=new level(100,100,"untitled.spe"); |
---|
2115 | } break; |
---|
2116 | case ID_LEVEL_RESIZE : |
---|
2117 | { |
---|
2118 | if (!mess_win) |
---|
2119 | { |
---|
2120 | int h=wm->font()->height()+8; |
---|
2121 | mess_win=wm->new_window(xres/2,yres/2,-1,-1, |
---|
2122 | new text_field(0,h*0,ID_MESS_STR1,symbol_str("width_"),"****", |
---|
2123 | current_level ? current_level->foreground_width() : 100, |
---|
2124 | new text_field(0,h*1,ID_MESS_STR2,symbol_str("height_"),"****", |
---|
2125 | current_level ? current_level->foreground_height() : 100, |
---|
2126 | new button(10,h*4,ID_LEVEL_RESIZE_OK,symbol_str("ok_button"), |
---|
2127 | new button(40,h*4,ID_CANCEL,symbol_str("cancel_button"),NULL)))),symbol_str("_scroll")); |
---|
2128 | } |
---|
2129 | } break; |
---|
2130 | case ID_LEVEL_RESIZE_OK : |
---|
2131 | { |
---|
2132 | if (current_level) |
---|
2133 | { |
---|
2134 | current_level->set_size(atoi(mess_win->read(ID_MESS_STR1)), |
---|
2135 | atoi(mess_win->read(ID_MESS_STR2))); |
---|
2136 | } else the_game->show_help("Create a level first!"); |
---|
2137 | wm->Push(new Event(ID_CANCEL,NULL)); // close_window |
---|
2138 | } break; |
---|
2139 | |
---|
2140 | case ID_SUSPEND : |
---|
2141 | { |
---|
2142 | dev^=SUSPEND_MODE; |
---|
2143 | if (dev&SUSPEND_MODE) |
---|
2144 | the_game->show_help(symbol_str("suspend_on")); |
---|
2145 | else |
---|
2146 | the_game->show_help(symbol_str("suspend_off")); |
---|
2147 | } break; |
---|
2148 | case ID_PLAY_MODE : |
---|
2149 | { |
---|
2150 | dev^=EDIT_MODE; |
---|
2151 | } break; |
---|
2152 | case ID_QUIT : |
---|
2153 | { |
---|
2154 | if (confirm_quit()) |
---|
2155 | do_command("quit",ev); |
---|
2156 | } ; |
---|
2157 | case ID_TOGGLE_MAP : |
---|
2158 | { |
---|
2159 | if (dev&MAP_MODE) dev-=MAP_MODE; |
---|
2160 | else dev|=MAP_MODE; |
---|
2161 | the_game->need_refresh(); |
---|
2162 | } break; |
---|
2163 | case ID_TOGGLE_LIGHT : |
---|
2164 | { |
---|
2165 | dev^=DRAW_LIGHTS; |
---|
2166 | the_game->need_refresh(); |
---|
2167 | } break; |
---|
2168 | case ID_RECORD_DEMO : |
---|
2169 | { |
---|
2170 | if (!mess_win) |
---|
2171 | { |
---|
2172 | int h=wm->font()->height()+8; |
---|
2173 | mess_win=wm->new_window(xres/2,yres/2,-1,-1, |
---|
2174 | new text_field(0,h*0,ID_RECORD_DEMO_FILENAME, |
---|
2175 | "demo filename","*******************", |
---|
2176 | "demo.dat", |
---|
2177 | new button(10,h*2,ID_RECORD_DEMO_OK,symbol_str("ok_button"), |
---|
2178 | new button(40,h*2,ID_CANCEL,symbol_str("cancel_button"),NULL)))); |
---|
2179 | } |
---|
2180 | } break; |
---|
2181 | |
---|
2182 | case ID_RECORD_DEMO_OK : |
---|
2183 | { |
---|
2184 | demo_man.set_state(demo_manager::RECORDING,mess_win->read(ID_RECORD_DEMO_FILENAME)); |
---|
2185 | wm->Push(new Event(ID_CANCEL,NULL)); // close window |
---|
2186 | } break; |
---|
2187 | |
---|
2188 | case ID_PLAY_DEMO : |
---|
2189 | { |
---|
2190 | if (!mess_win) |
---|
2191 | { |
---|
2192 | int h=wm->font()->height()+8; |
---|
2193 | mess_win=wm->new_window(xres/2,yres/2,-1,-1, |
---|
2194 | new text_field(0,h*0,ID_PLAY_DEMO_FILENAME, |
---|
2195 | "demo filename","*******************", |
---|
2196 | "demo.dat", |
---|
2197 | new button(10,h*2,ID_PLAY_DEMO_OK,symbol_str("ok_button"), |
---|
2198 | new button(40,h*2,ID_CANCEL,symbol_str("cancel_button"),NULL)))); |
---|
2199 | } |
---|
2200 | } break; |
---|
2201 | |
---|
2202 | case ID_PLAY_DEMO_OK : |
---|
2203 | { |
---|
2204 | demo_man.set_state(demo_manager::PLAYING,mess_win->read(ID_PLAY_DEMO_FILENAME)); |
---|
2205 | wm->close_window(mess_win); |
---|
2206 | mess_win=NULL; |
---|
2207 | } break; |
---|
2208 | |
---|
2209 | case ID_SET_SCROLL : |
---|
2210 | { |
---|
2211 | if (!mess_win) |
---|
2212 | { |
---|
2213 | int h=wm->font()->height()+8; |
---|
2214 | mess_win=wm->new_window(xres/2,yres/2,-1,-1, |
---|
2215 | new text_field(0,h*0,ID_MESS_STR1,symbol_str("x_mul"),"****",bg_xmul, |
---|
2216 | new text_field(0,h*1,ID_MESS_STR2,symbol_str("x_div"),"****",bg_xdiv, |
---|
2217 | new text_field(0,h*2,ID_MESS_STR3,symbol_str("y_mul"),"****",bg_ymul, |
---|
2218 | new text_field(0,h*3,ID_MESS_STR4,symbol_str("y_div"),"****",bg_ydiv, |
---|
2219 | new button(10,h*4,ID_SET_SCROLL_CHECK,symbol_str("ok_button"), |
---|
2220 | new button(40,h*4,ID_CANCEL,symbol_str("cancel_button"),NULL)))))),symbol_str("_scroll")); |
---|
2221 | } |
---|
2222 | } break; |
---|
2223 | case ID_SET_SCROLL_CHECK : |
---|
2224 | { |
---|
2225 | int tbg_xmul=atoi(mess_win->read(ID_MESS_STR1)); |
---|
2226 | int tbg_xdiv=atoi(mess_win->read(ID_MESS_STR2)); |
---|
2227 | int tbg_ymul=atoi(mess_win->read(ID_MESS_STR3)); |
---|
2228 | int tbg_ydiv=atoi(mess_win->read(ID_MESS_STR4)); |
---|
2229 | |
---|
2230 | if ( (((float)tbg_xmul/(float)tbg_xdiv) < ((float)bg_xmul/(float)bg_xdiv)) || |
---|
2231 | (((float)tbg_ymul/(float)tbg_ydiv) < ((float)bg_ymul/(float)bg_ydiv))) |
---|
2232 | { |
---|
2233 | int h=wm->font()->height()+8; |
---|
2234 | |
---|
2235 | warn_win=wm->new_window(xres/2-40,yres/2-40,-1,-1, |
---|
2236 | new info_field(0,0,ID_NULL, |
---|
2237 | symbol_str("back_loss"), |
---|
2238 | new button(10,h*4,ID_SET_SCROLL_OK,symbol_str("ok_button"), |
---|
2239 | new button(40,h*4,ID_WARN_CANCEL,symbol_str("cancel_button"),NULL))), |
---|
2240 | symbol_str("WARNING")); |
---|
2241 | wm->grab_focus(warn_win); |
---|
2242 | } else wm->Push(new Event(ID_SET_SCROLL_OK,NULL)); |
---|
2243 | } break; |
---|
2244 | case ID_WARN_CANCEL : |
---|
2245 | { |
---|
2246 | wm->close_window(warn_win); warn_win=NULL; |
---|
2247 | wm->Push(new Event(ID_CANCEL,NULL)); |
---|
2248 | } break; |
---|
2249 | case ID_SET_SCROLL_OK : |
---|
2250 | { |
---|
2251 | if (warn_win) { wm->close_window(warn_win); warn_win=NULL; } |
---|
2252 | bg_xmul=atoi(mess_win->read(ID_MESS_STR1)); |
---|
2253 | bg_xdiv=atoi(mess_win->read(ID_MESS_STR2)); |
---|
2254 | bg_ymul=atoi(mess_win->read(ID_MESS_STR3)); |
---|
2255 | bg_ydiv=atoi(mess_win->read(ID_MESS_STR4)); |
---|
2256 | wm->Push(new Event(ID_CANCEL,NULL)); // close window |
---|
2257 | } break; |
---|
2258 | |
---|
2259 | case ID_CENTER_PLAYER : |
---|
2260 | { |
---|
2261 | do_command("center",ev); break; |
---|
2262 | } break; |
---|
2263 | |
---|
2264 | case ID_INTERPOLATE_DRAW : |
---|
2265 | { |
---|
2266 | interpolate_draw=!interpolate_draw; |
---|
2267 | } break; |
---|
2268 | |
---|
2269 | case ID_DISABLE_AUTOLIGHT : |
---|
2270 | { |
---|
2271 | disable_autolight=!disable_autolight; |
---|
2272 | } break; |
---|
2273 | |
---|
2274 | case ID_ADD_PALETTE : |
---|
2275 | { |
---|
2276 | if (!mess_win) |
---|
2277 | { |
---|
2278 | int h=wm->font()->height()+8; |
---|
2279 | mess_win=wm->new_window(xres/2,yres/2,-1,-1, |
---|
2280 | new text_field(0,h*0,ID_MESS_STR1,symbol_str("ap_width"),"****",2, |
---|
2281 | new text_field(0,h*1,ID_MESS_STR2,symbol_str("ap_height"),"****",2, |
---|
2282 | new text_field(0,h*2,ID_MESS_STR3,symbol_str("ap_name"),"***********","pal", |
---|
2283 | new button(10,h*3,ID_ADD_PALETTE_OK,symbol_str("ok_button"), |
---|
2284 | new button(40,h*3,ID_CANCEL,symbol_str("cancel_button"),NULL))))),symbol_str("ap_pal")); |
---|
2285 | } |
---|
2286 | } break; |
---|
2287 | case ID_ADD_PALETTE_OK : |
---|
2288 | { |
---|
2289 | char name[70]; |
---|
2290 | sprintf(name,"(add_palette \"%s\" %d %d)",mess_win->read(ID_MESS_STR3), |
---|
2291 | atoi(mess_win->read(ID_MESS_STR1)), |
---|
2292 | atoi(mess_win->read(ID_MESS_STR2))); |
---|
2293 | char const *s=name; |
---|
2294 | LObject::Compile(s)->Eval(); |
---|
2295 | wm->Push(new Event(ID_CANCEL,NULL)); // close window |
---|
2296 | } break; |
---|
2297 | case ID_TOGGLE_DELAY : |
---|
2298 | { |
---|
2299 | the_game->toggle_delay(); break; |
---|
2300 | } break; |
---|
2301 | |
---|
2302 | case ID_SMALL_MODE : |
---|
2303 | { |
---|
2304 | make_screen_size(311,160); break; |
---|
2305 | } break; |
---|
2306 | case ID_CLEAR_WEAPONS : |
---|
2307 | { |
---|
2308 | Event ev; |
---|
2309 | do_command("clear_weapons",ev); |
---|
2310 | } break; |
---|
2311 | case ID_GOD_MODE : |
---|
2312 | { |
---|
2313 | for (view *v=player_list; v; v=v->next) |
---|
2314 | v->god=!v->god; |
---|
2315 | } break; |
---|
2316 | case ID_MOUSE_SCROLL : |
---|
2317 | { |
---|
2318 | mouse_scrolling=!mouse_scrolling; |
---|
2319 | prop->setd("mouse_scrolling",mouse_scrolling); |
---|
2320 | if (mouse_scrolling) |
---|
2321 | the_game->show_help(symbol_str("ms_on")); |
---|
2322 | else |
---|
2323 | the_game->show_help(symbol_str("ms_off")); |
---|
2324 | } break; |
---|
2325 | |
---|
2326 | case ID_LOCK_PALETTES : |
---|
2327 | { |
---|
2328 | palettes_locked=!palettes_locked; |
---|
2329 | prop->setd("palettes_locked",palettes_locked); |
---|
2330 | if (palettes_locked) |
---|
2331 | the_game->show_help(symbol_str("pal_lock")); |
---|
2332 | else the_game->show_help(symbol_str("pal_unlock")); |
---|
2333 | } break; |
---|
2334 | |
---|
2335 | case ID_DISABLE_VIEW_SHIFT : |
---|
2336 | { |
---|
2337 | view_shift_disabled=!view_shift_disabled; |
---|
2338 | prop->setd("view_shift_disabled",view_shift_disabled); |
---|
2339 | if (view_shift_disabled) |
---|
2340 | the_game->show_help(symbol_str("vs_dis")); |
---|
2341 | else the_game->show_help(symbol_str("vs_en")); |
---|
2342 | } break; |
---|
2343 | |
---|
2344 | case ID_WIN_FORE : |
---|
2345 | { |
---|
2346 | toggle_fgw(); |
---|
2347 | } break; |
---|
2348 | case ID_WIN_BACK : |
---|
2349 | { |
---|
2350 | toggle_bgw(); |
---|
2351 | } break; |
---|
2352 | case ID_WIN_OBJECTS : |
---|
2353 | { |
---|
2354 | toggle_omenu(); |
---|
2355 | } break; |
---|
2356 | case ID_WIN_PALETTES : |
---|
2357 | { |
---|
2358 | toggle_pmenu(); |
---|
2359 | } break; |
---|
2360 | case ID_WIN_LIGHTING : |
---|
2361 | { |
---|
2362 | toggle_light_window(); |
---|
2363 | } break; |
---|
2364 | case ID_WIN_LAYERS : |
---|
2365 | { |
---|
2366 | toggle_show_menu(); |
---|
2367 | } break; |
---|
2368 | case ID_WIN_CONSOLE : |
---|
2369 | { |
---|
2370 | if (dev_console) dev_console->toggle(); |
---|
2371 | } break; |
---|
2372 | case ID_WIN_TOOLBAR : |
---|
2373 | { |
---|
2374 | toggle_toolbar(); |
---|
2375 | } break; |
---|
2376 | |
---|
2377 | case DEV_AMBIENT : |
---|
2378 | { if (!ambw) make_ambient(); } break; |
---|
2379 | case DEV_AREA_OK : |
---|
2380 | { close_area_win(1); } break; |
---|
2381 | case DEV_AREA_DELETE : |
---|
2382 | { close_area_win(0); |
---|
2383 | if (current_area && current_level) |
---|
2384 | { |
---|
2385 | if (current_level->area_list==current_area) |
---|
2386 | current_level->area_list=current_level->area_list->next; |
---|
2387 | else |
---|
2388 | { |
---|
2389 | area_controller *a=current_level->area_list,*l=NULL; |
---|
2390 | for (; a!=current_area && a; a=a->next) { l=a; } |
---|
2391 | l->next=a->next; |
---|
2392 | delete a; |
---|
2393 | } |
---|
2394 | current_area=NULL; |
---|
2395 | the_game->need_refresh(); |
---|
2396 | } |
---|
2397 | } break; |
---|
2398 | case DEV_AI_OK : |
---|
2399 | close_ai_window(); break; |
---|
2400 | case DEV_OEDIT_AI : |
---|
2401 | make_ai_window(edit_object); break; |
---|
2402 | case DEV_OBJECTS_DELETE : |
---|
2403 | { |
---|
2404 | if (edit_object) |
---|
2405 | { |
---|
2406 | for (int i=0; i<edit_object->total_objects(); i++) |
---|
2407 | edit_object->remove_object(edit_object->get_object(0)); |
---|
2408 | the_game->need_refresh(); |
---|
2409 | } |
---|
2410 | } break; |
---|
2411 | |
---|
2412 | case DEV_LIGHTS_DELETE : |
---|
2413 | { |
---|
2414 | if (edit_object) |
---|
2415 | { |
---|
2416 | for (int i=0; i<edit_object->total_lights(); i++) |
---|
2417 | edit_object->remove_light(edit_object->get_light(0)); |
---|
2418 | the_game->need_refresh(); |
---|
2419 | } |
---|
2420 | } break; |
---|
2421 | |
---|
2422 | case DEV_LEDIT_DEL : |
---|
2423 | { |
---|
2424 | prop->setd("ledit x",ledit->m_pos.x); |
---|
2425 | prop->setd("ledit y",ledit->m_pos.y); |
---|
2426 | wm->close_window(ledit); ledit=NULL; |
---|
2427 | if (current_level) |
---|
2428 | current_level->remove_light(edit_light); |
---|
2429 | else |
---|
2430 | delete_light(edit_light); |
---|
2431 | edit_light=NULL; |
---|
2432 | the_game->need_refresh(); |
---|
2433 | } break; |
---|
2434 | case DEV_LEDIT_OK : |
---|
2435 | { |
---|
2436 | edit_light->xshift=atoi(ledit->read(DEV_LEDIT_W)); |
---|
2437 | edit_light->yshift=atoi(ledit->read(DEV_LEDIT_H)); |
---|
2438 | edit_light->inner_radius=atoi(ledit->read(DEV_LEDIT_R1)); |
---|
2439 | edit_light->outer_radius=atoi(ledit->read(DEV_LEDIT_R2)); |
---|
2440 | if (edit_light->outer_radius<=edit_light->inner_radius) |
---|
2441 | { |
---|
2442 | edit_light->inner_radius=edit_light->outer_radius-1; |
---|
2443 | if (edit_light->inner_radius<1) |
---|
2444 | { |
---|
2445 | edit_light->inner_radius=1; |
---|
2446 | edit_light->outer_radius=2; |
---|
2447 | } |
---|
2448 | } |
---|
2449 | |
---|
2450 | edit_light->calc_range(); |
---|
2451 | edit_light=NULL; |
---|
2452 | prop->setd("ledit x",ledit->m_pos.x); |
---|
2453 | prop->setd("ledit y",ledit->m_pos.y); |
---|
2454 | wm->close_window(ledit); ledit=NULL; |
---|
2455 | the_game->need_refresh(); |
---|
2456 | } break; |
---|
2457 | case DEV_LEDIT_MOVE : |
---|
2458 | { |
---|
2459 | prop->setd("ledit x",ledit->m_pos.x); |
---|
2460 | prop->setd("ledit y",ledit->m_pos.y); |
---|
2461 | wm->close_window(ledit); ledit=NULL; |
---|
2462 | state=DEV_MOVE_LIGHT; |
---|
2463 | } break; |
---|
2464 | case DEV_LEDIT_COPY : |
---|
2465 | { |
---|
2466 | edit_light=edit_light->copy(); |
---|
2467 | prop->setd("ledit x",ledit->m_pos.x); |
---|
2468 | prop->setd("ledit y",ledit->m_pos.y); |
---|
2469 | wm->close_window(ledit); ledit=NULL; |
---|
2470 | state=DEV_MOVE_LIGHT; |
---|
2471 | } break; |
---|
2472 | |
---|
2473 | |
---|
2474 | case DEV_LIGHT0 : |
---|
2475 | case DEV_LIGHT1 : |
---|
2476 | case DEV_LIGHT2 : |
---|
2477 | case DEV_LIGHT3 : |
---|
2478 | case DEV_LIGHT4 : |
---|
2479 | case DEV_LIGHT5 : |
---|
2480 | case DEV_LIGHT6 : |
---|
2481 | case DEV_LIGHT7 : |
---|
2482 | case DEV_LIGHT8 : |
---|
2483 | case DEV_LIGHT9 : |
---|
2484 | { |
---|
2485 | vec2i pos = the_game->MouseToGame(last_demo_mpos); |
---|
2486 | edit_light = add_light_source(ev.message.id - DEV_LIGHT0, |
---|
2487 | snap_x(pos.x), snap_y(pos.y), |
---|
2488 | atoi(lightw->read(DEV_LIGHTR1)), |
---|
2489 | atoi(lightw->read(DEV_LIGHTR2)), |
---|
2490 | atoi(lightw->read(DEV_LIGHTW)), |
---|
2491 | atoi(lightw->read(DEV_LIGHTH))); |
---|
2492 | state=DEV_MOVE_LIGHT; |
---|
2493 | } break; |
---|
2494 | case ID_RAISE_ALL : |
---|
2495 | { |
---|
2496 | raise_all=!raise_all; |
---|
2497 | prop->setd("raise_all",raise_all); |
---|
2498 | if (raise_all) |
---|
2499 | the_game->show_help(symbol_str("fg_r")); |
---|
2500 | else |
---|
2501 | the_game->show_help(symbol_str("fg_l")); |
---|
2502 | } break; |
---|
2503 | case DEV_OEDIT_COPY : |
---|
2504 | { |
---|
2505 | game_object *use=copy_object; |
---|
2506 | if (!use) use=edit_object; |
---|
2507 | if (use) |
---|
2508 | { |
---|
2509 | game_object *old=use; |
---|
2510 | close_oedit_window(); |
---|
2511 | if (use->controller()) |
---|
2512 | the_game->show_help(symbol_str("no_clone")); |
---|
2513 | else |
---|
2514 | { |
---|
2515 | edit_object=old->copy(); |
---|
2516 | |
---|
2517 | current_level->add_object(edit_object); |
---|
2518 | the_game->need_refresh(); |
---|
2519 | state=DEV_MOVE_OBJECT; |
---|
2520 | |
---|
2521 | close_oedit_window(); |
---|
2522 | copy_object=NULL; |
---|
2523 | } |
---|
2524 | } |
---|
2525 | } break; |
---|
2526 | case DEV_OEDIT_LEFT : |
---|
2527 | { |
---|
2528 | if (edit_object) |
---|
2529 | { |
---|
2530 | the_game->need_refresh(); |
---|
2531 | edit_object->direction=-1; |
---|
2532 | } |
---|
2533 | } break; |
---|
2534 | case DEV_OEDIT_RIGHT : |
---|
2535 | { |
---|
2536 | if (edit_object) |
---|
2537 | { |
---|
2538 | the_game->need_refresh(); |
---|
2539 | edit_object->direction=1; |
---|
2540 | } |
---|
2541 | } break; |
---|
2542 | |
---|
2543 | |
---|
2544 | case DEV_COMMAND_OK : |
---|
2545 | { |
---|
2546 | char cmd[100]; |
---|
2547 | strcpy(cmd,commandw->inm->get(DEV_COMMAND)->read()); |
---|
2548 | prop->setd("commandw x",commandw->m_pos.x); |
---|
2549 | prop->setd("commandw y",commandw->m_pos.y); |
---|
2550 | wm->close_window(commandw); |
---|
2551 | commandw=NULL; |
---|
2552 | do_command(cmd,ev); |
---|
2553 | } break; |
---|
2554 | |
---|
2555 | case ID_SHOW_FPS : |
---|
2556 | { fps_on=!fps_on; } break; |
---|
2557 | case ID_PROFILE : |
---|
2558 | { profile_toggle(); |
---|
2559 | profile_on=!profile_on; |
---|
2560 | } break; |
---|
2561 | |
---|
2562 | case ID_TOGGLE_NAMES : { show_names=!show_names; } break; |
---|
2563 | case DEV_QUIT : the_game->end_session(); break; |
---|
2564 | case DEV_EDIT_FG : dev=1; break; //the_game->draw(); break; |
---|
2565 | case DEV_EDIT_BG : dev=2; break; //the_game->draw(); break; |
---|
2566 | case DEV_EDIT_FGBG : dev=3; break; //the_game->draw(); break; |
---|
2567 | case DEV_PLAY : dev=0; break; //the_game->draw(); break; |
---|
2568 | case SHOW_FOREGROUND : |
---|
2569 | { dev=dev^DRAW_FG_LAYER; the_game->need_refresh(); } break; |
---|
2570 | case SHOW_FOREGROUND_BOUND : |
---|
2571 | { dev=dev^DRAW_FG_BOUND_LAYER; the_game->need_refresh(); } break; |
---|
2572 | case SHOW_BACKGROUND : |
---|
2573 | { dev=dev^DRAW_BG_LAYER; the_game->need_refresh(); } break; |
---|
2574 | case SHOW_CHARACTERS : |
---|
2575 | { dev=dev^DRAW_PEOPLE_LAYER; the_game->need_refresh(); } break; |
---|
2576 | case SHOW_LIGHT : |
---|
2577 | { dev=dev^DRAW_LIGHTS; the_game->need_refresh(); } break; |
---|
2578 | case SHOW_LINKS : |
---|
2579 | { dev=dev^DRAW_LINKS; the_game->need_refresh(); } break; |
---|
2580 | |
---|
2581 | |
---|
2582 | case DEV_CREATE : |
---|
2583 | { |
---|
2584 | int val=get_omenu_item(((pick_list *)ev.message.data)->get_selection()); |
---|
2585 | char cmd[100]; |
---|
2586 | sprintf(cmd,"create %s",object_names[val]); |
---|
2587 | do_command(cmd,ev); |
---|
2588 | state=DEV_CREATE_OBJECT; |
---|
2589 | dev|=(EDIT_MODE | DRAW_PEOPLE_LAYER); |
---|
2590 | } |
---|
2591 | break; |
---|
2592 | |
---|
2593 | case DEV_PALETTE : |
---|
2594 | { |
---|
2595 | int val=((pick_list *)ev.message.data)->get_selection(); |
---|
2596 | pal_wins[val]->open_window(); |
---|
2597 | } break; |
---|
2598 | |
---|
2599 | case DEV_MUSIC_PICKLIST : |
---|
2600 | { |
---|
2601 | /* int *val=((int *)((pick_list *)ev.message.data)->read()); |
---|
2602 | if (current_song) delete current_song; |
---|
2603 | current_song=new song(song_list[*val]); |
---|
2604 | current_song->play(); */ |
---|
2605 | } |
---|
2606 | break; |
---|
2607 | |
---|
2608 | case DEV_OEDIT_OK : |
---|
2609 | { close_oedit_window(); } break; |
---|
2610 | |
---|
2611 | case DEV_OEDIT_DELETE : |
---|
2612 | { |
---|
2613 | selected_object=edit_object; |
---|
2614 | do_command("delete",ev); |
---|
2615 | close_oedit_window(); |
---|
2616 | } |
---|
2617 | break; |
---|
2618 | |
---|
2619 | case DEV_OEDIT_FRONT : |
---|
2620 | { |
---|
2621 | do_command("to_front",ev); |
---|
2622 | close_oedit_window(); |
---|
2623 | } |
---|
2624 | break; |
---|
2625 | |
---|
2626 | case DEV_OEDIT_BACK : |
---|
2627 | { |
---|
2628 | do_command("to_back",ev); |
---|
2629 | close_oedit_window(); |
---|
2630 | } |
---|
2631 | break; |
---|
2632 | |
---|
2633 | case DEV_OEDIT_MOVE : |
---|
2634 | { |
---|
2635 | game_object *o=edit_object; |
---|
2636 | close_oedit_window(); |
---|
2637 | edit_object=o; |
---|
2638 | do_command("move",ev); |
---|
2639 | } |
---|
2640 | break; |
---|
2641 | } |
---|
2642 | } break; |
---|
2643 | |
---|
2644 | |
---|
2645 | case EV_CLOSE_WINDOW : |
---|
2646 | { |
---|
2647 | if (ev.window) |
---|
2648 | { |
---|
2649 | if (ev.window==commandw) |
---|
2650 | { |
---|
2651 | prop->setd("commandw x",commandw->m_pos.x); |
---|
2652 | prop->setd("commandw y",commandw->m_pos.y); |
---|
2653 | wm->close_window(commandw); |
---|
2654 | commandw=NULL; |
---|
2655 | } else if (ev.window==oedit) |
---|
2656 | close_oedit_window(); |
---|
2657 | else if (ev.window==ambw) |
---|
2658 | { wm->close_window(ambw); ambw=NULL; } |
---|
2659 | else if (ev.window==backw) toggle_bgw(); |
---|
2660 | else if (ev.window==forew) toggle_fgw(); |
---|
2661 | else if (ev.window==lightw) toggle_light_window(); |
---|
2662 | else if (ev.window==show_menu) toggle_show_menu(); |
---|
2663 | else if (ev.window==pmenu) toggle_pmenu(); |
---|
2664 | else if (ev.window==tbw) toggle_toolbar(); |
---|
2665 | else if (ev.window==omenu) toggle_omenu(); |
---|
2666 | else if (ev.window==search_window) toggle_search_window(); |
---|
2667 | else if (profile_handle_event(ev)) profile_on=!profile_on; |
---|
2668 | else if (chat->chat_event(ev)) chat->toggle(); |
---|
2669 | |
---|
2670 | } |
---|
2671 | } |
---|
2672 | break; |
---|
2673 | case EV_KEYRELEASE : |
---|
2674 | { |
---|
2675 | if (ev.key==JK_CTRL_L) |
---|
2676 | { |
---|
2677 | if (!edit_object && link_object && selected_object && link_object!=selected_object) |
---|
2678 | { |
---|
2679 | link_object->add_object(selected_object); |
---|
2680 | if (S_LINK_SND>0) cache.sfx(S_LINK_SND)->play(sfx_volume/2); |
---|
2681 | the_game->need_refresh(); |
---|
2682 | } |
---|
2683 | |
---|
2684 | link_object=NULL; |
---|
2685 | } |
---|
2686 | } break; |
---|
2687 | case EV_KEY : |
---|
2688 | { |
---|
2689 | if (backw && ev.window==backw) |
---|
2690 | { if (ev.key=='-' && bg_scale<the_game->btile_height()/2) |
---|
2691 | { toggle_bgw(); |
---|
2692 | bg_scale++; |
---|
2693 | toggle_bgw(); |
---|
2694 | } else if (ev.key=='+' && bg_scale>1) |
---|
2695 | { toggle_bgw(); |
---|
2696 | bg_scale--; |
---|
2697 | toggle_bgw(); |
---|
2698 | } else if (ev.key=='b') toggle_bgw(); |
---|
2699 | else if (ev.key=='B') { toggle_bgw(); bg_w++; if (bg_w>6) bg_w=1; toggle_bgw(); } |
---|
2700 | } |
---|
2701 | if (forew && ev.window==forew) |
---|
2702 | { if (ev.key=='-' && fg_scale<the_game->ftile_height()/2) |
---|
2703 | { toggle_fgw(); |
---|
2704 | fg_scale++; |
---|
2705 | toggle_fgw(); |
---|
2706 | } else if (ev.key=='+' && fg_scale>1) |
---|
2707 | { toggle_fgw(); |
---|
2708 | fg_scale--; |
---|
2709 | toggle_fgw(); |
---|
2710 | } else if (ev.key=='i') |
---|
2711 | { |
---|
2712 | toggle_fgw(); |
---|
2713 | fg_reversed=!fg_reversed; |
---|
2714 | prop->setd("fg_reversed",fg_reversed); |
---|
2715 | toggle_fgw(); |
---|
2716 | } else if (ev.key=='f') toggle_fgw(); |
---|
2717 | |
---|
2718 | else if (ev.key=='F') { toggle_fgw(); fg_w++; if (fg_w>6) fg_w=1; toggle_fgw(); } |
---|
2719 | } |
---|
2720 | if (ev.window==NULL || ev.window==pmenu || |
---|
2721 | ev.window==forew || is_pal_win(ev.window)) // main window actions |
---|
2722 | { |
---|
2723 | switch (ev.key) |
---|
2724 | { |
---|
2725 | case JK_CTRL_L : if (!edit_object && !link_object) { link_object=selected_object; } |
---|
2726 | case 'n' : current_level->next_focus(); break; |
---|
2727 | // case '/' : if (dev_console) dev_console->toggle(); break; |
---|
2728 | case 't' : |
---|
2729 | { |
---|
2730 | if (ev.window==NULL || ev.window==forew) |
---|
2731 | { |
---|
2732 | vec2i tile = the_game->GetFgTile(last_demo_mpos); |
---|
2733 | fg_fill(cur_fg, tile.x, tile.y, NULL); |
---|
2734 | } |
---|
2735 | } break; |
---|
2736 | case 'f' : toggle_fgw(); break; |
---|
2737 | case 'M' : toggle_music_window(); break; |
---|
2738 | |
---|
2739 | case 'b' : toggle_bgw(); break; |
---|
2740 | case 'a' : toggle_toolbar(); break; |
---|
2741 | case 'A' : { if (selected_object) |
---|
2742 | { |
---|
2743 | if (oedit) wm->Push(new Event(DEV_OEDIT_OK,NULL)); |
---|
2744 | make_ai_window(selected_object); |
---|
2745 | } |
---|
2746 | } break; |
---|
2747 | |
---|
2748 | case 'o' : toggle_omenu(); break; |
---|
2749 | |
---|
2750 | case '<' : do_command("to_back",ev); break; |
---|
2751 | |
---|
2752 | case '>' : do_command("to_front",ev); break; |
---|
2753 | case 'p' : toggle_pmenu(); break; |
---|
2754 | case 'P' : profile_toggle(); break; |
---|
2755 | case '.' : |
---|
2756 | { |
---|
2757 | if (last_created_type>=0) |
---|
2758 | { |
---|
2759 | int val=last_created_type; |
---|
2760 | char cmd[100]; |
---|
2761 | sprintf(cmd,"create %s",object_names[val]); |
---|
2762 | do_command(cmd,ev); |
---|
2763 | state=DEV_CREATE_OBJECT; |
---|
2764 | dev|=(EDIT_MODE | DRAW_PEOPLE_LAYER); |
---|
2765 | } |
---|
2766 | } |
---|
2767 | break; |
---|
2768 | |
---|
2769 | |
---|
2770 | case 'd' : { do_command("delete",ev); the_game->need_refresh(); } break; |
---|
2771 | case 'i' : |
---|
2772 | { |
---|
2773 | fg_reversed=!fg_reversed; |
---|
2774 | prop->setd("fg_reversed",fg_reversed); |
---|
2775 | if (forew) |
---|
2776 | { |
---|
2777 | toggle_fgw(); |
---|
2778 | toggle_fgw(); |
---|
2779 | } |
---|
2780 | } break; |
---|
2781 | case 'l' : toggle_light_window(); break; |
---|
2782 | case '!' : |
---|
2783 | case '@' : |
---|
2784 | case '#' : |
---|
2785 | case '$' : |
---|
2786 | case '%' : |
---|
2787 | case '^' : |
---|
2788 | case '&' : |
---|
2789 | case '*' : |
---|
2790 | case '(' : |
---|
2791 | case ')' : |
---|
2792 | |
---|
2793 | case '0' : |
---|
2794 | case '1' : |
---|
2795 | case '2' : |
---|
2796 | case '3' : |
---|
2797 | case '4' : |
---|
2798 | case '5' : |
---|
2799 | case '6' : |
---|
2800 | case '7' : |
---|
2801 | case '8' : |
---|
2802 | case '9' : do_command("set_aitype",ev); break; |
---|
2803 | case 'c' : do_command("center",ev); break; |
---|
2804 | case 'C' : |
---|
2805 | if (selected_object && selected_object->controller()==NULL) |
---|
2806 | { copy_object=selected_object; |
---|
2807 | wm->Push(new Event(DEV_OEDIT_COPY,NULL)); } break; |
---|
2808 | |
---|
2809 | case 'D' : the_game->toggle_delay(); break; |
---|
2810 | case 'L' : toggle_show_menu(); break; |
---|
2811 | case '`' : do_command("fg_select",ev); break; |
---|
2812 | case 'r' : { do_command("toggle_fg_raise",ev); the_game->need_refresh(); } break; |
---|
2813 | case '[' : do_command("fg_add -1",ev); break; |
---|
2814 | case ']' : do_command("fg_add 1",ev); break; |
---|
2815 | case 'R' : do_command("reload",ev); break; |
---|
2816 | case 'w' : |
---|
2817 | { |
---|
2818 | vec2i pos = the_game->MouseToGame(dlast); |
---|
2819 | char msg[100]; sprintf(msg, symbol_str("mouse_at"), pos.x, pos.y); |
---|
2820 | the_game->show_help(msg); |
---|
2821 | the_game->need_refresh(); |
---|
2822 | } break; |
---|
2823 | case 'k' : |
---|
2824 | { |
---|
2825 | if (selected_object && selected_object->total_objects()) |
---|
2826 | selected_object->remove_object(selected_object->get_object(0)); |
---|
2827 | the_game->need_refresh(); |
---|
2828 | } break; |
---|
2829 | case 'K' : |
---|
2830 | { |
---|
2831 | if (selected_object && selected_object->total_objects()) |
---|
2832 | selected_object->remove_object(selected_object->get_object(selected_object->total_objects()-1)); |
---|
2833 | the_game->need_refresh(); |
---|
2834 | } break; |
---|
2835 | case 'j' : |
---|
2836 | { |
---|
2837 | if (current_level && player_list && player_list->focus) |
---|
2838 | { |
---|
2839 | vec2i pos = the_game->MouseToGame(dlast); |
---|
2840 | player_list->focus->x = pos.x; |
---|
2841 | player_list->focus->y = pos.y; |
---|
2842 | do_command("center",ev); |
---|
2843 | the_game->need_refresh(); |
---|
2844 | } |
---|
2845 | } break; |
---|
2846 | case 'z' : do_command("clear_weapons",ev); break; |
---|
2847 | case 'Z' : if (dev&EDIT_MODE) |
---|
2848 | { view *v = the_game->GetView(last_demo_mpos); |
---|
2849 | if (v) |
---|
2850 | { |
---|
2851 | v->god=!v->god; |
---|
2852 | sbar.redraw(main_screen); |
---|
2853 | } |
---|
2854 | } break; |
---|
2855 | case ' ' : |
---|
2856 | { |
---|
2857 | if (dev & EDIT_MODE) |
---|
2858 | { |
---|
2859 | if (selected_object) |
---|
2860 | { |
---|
2861 | if (oedit) |
---|
2862 | close_oedit_window(); |
---|
2863 | edit_object=selected_object; |
---|
2864 | do_command("move",ev); |
---|
2865 | } else if (selected_light) |
---|
2866 | { |
---|
2867 | if (ledit) |
---|
2868 | { |
---|
2869 | wm->close_window(ledit); |
---|
2870 | ledit=NULL; |
---|
2871 | } |
---|
2872 | edit_light=selected_light; |
---|
2873 | do_command("move_light",ev); |
---|
2874 | } |
---|
2875 | |
---|
2876 | } break; |
---|
2877 | } |
---|
2878 | case 'x' : |
---|
2879 | { |
---|
2880 | if (selected_object) |
---|
2881 | { if (selected_object->direction>0) |
---|
2882 | selected_object->direction=-1; |
---|
2883 | else selected_object->direction=1; |
---|
2884 | } |
---|
2885 | } break; |
---|
2886 | |
---|
2887 | } |
---|
2888 | } |
---|
2889 | } |
---|
2890 | } |
---|
2891 | |
---|
2892 | |
---|
2893 | } |
---|
2894 | |
---|
2895 | |
---|
2896 | void dev_controll::add_palette(void *args) |
---|
2897 | { |
---|
2898 | total_pals++; |
---|
2899 | pal_wins=(pal_win **)realloc(pal_wins,sizeof(pal_win *)*total_pals); |
---|
2900 | pal_wins[total_pals-1]=new pal_win(args); |
---|
2901 | } |
---|
2902 | |
---|
2903 | |
---|
2904 | pal_win::pal_win(void *args) |
---|
2905 | { |
---|
2906 | int i=0; |
---|
2907 | Cell *ao=(Cell *)args; |
---|
2908 | |
---|
2909 | name = strdup(lstring_value(CAR(args))); |
---|
2910 | ao=CDR(ao); |
---|
2911 | scale=w=h=1; |
---|
2912 | x=y=0; |
---|
2913 | |
---|
2914 | if (!NILP(ao)) |
---|
2915 | { |
---|
2916 | w=lnumber_value(CAR(ao)); ao=CDR(ao); |
---|
2917 | if (!NILP(ao)) |
---|
2918 | { |
---|
2919 | h=lnumber_value(CAR(ao)); ao=CDR(ao); |
---|
2920 | if (!NILP(ao)) |
---|
2921 | { |
---|
2922 | x=lnumber_value(CAR(ao)); ao=CDR(ao); |
---|
2923 | if (!NILP(ao)) |
---|
2924 | { |
---|
2925 | y=lnumber_value(CAR(ao)); ao=CDR(ao); |
---|
2926 | if (!NILP(ao)) |
---|
2927 | scale=lnumber_value(CAR(ao)); ao=CDR(ao); |
---|
2928 | } |
---|
2929 | } |
---|
2930 | } |
---|
2931 | } |
---|
2932 | |
---|
2933 | if (w<=0) w=0; |
---|
2934 | if (h<=0) h=0; |
---|
2935 | |
---|
2936 | pat=(unsigned short *)malloc(w*h*sizeof(unsigned short)); |
---|
2937 | memset(pat,0,sizeof(unsigned short)*w*h); // set the palette to black if no parameters are given |
---|
2938 | while (!NILP(ao)) // loop until we run out of parameters |
---|
2939 | { |
---|
2940 | if (i>w*h) |
---|
2941 | { |
---|
2942 | lbreak("to many parameters to add_palette "); |
---|
2943 | exit(0); |
---|
2944 | } |
---|
2945 | pat[i]=lnumber_value(CAR(ao)); |
---|
2946 | // make sure the tile that they suggested exists |
---|
2947 | if (pat[i]<=0 || pat[i]>nforetiles || foretiles[pat[i]]<0) |
---|
2948 | pat[i]=0; |
---|
2949 | ao=CDR(ao); |
---|
2950 | i++; |
---|
2951 | } |
---|
2952 | last_selected=-1; |
---|
2953 | me=NULL; |
---|
2954 | open_window(); |
---|
2955 | } |
---|
2956 | |
---|
2957 | void pal_win::open_window() |
---|
2958 | { |
---|
2959 | if (me) close_window(); |
---|
2960 | me=wm->new_window(x,y,w*f_wid/scale,h*f_hi/scale,NULL,name); |
---|
2961 | draw(); |
---|
2962 | } |
---|
2963 | |
---|
2964 | void pal_win::close_window() |
---|
2965 | { |
---|
2966 | if (me) // dont' close the window if the window is already closed |
---|
2967 | { |
---|
2968 | x=me->m_pos.x; // save the old poisition of the window so that when we open it |
---|
2969 | // it will be in the same spot |
---|
2970 | y=me->m_pos.y; |
---|
2971 | wm->close_window(me); |
---|
2972 | me=NULL; |
---|
2973 | |
---|
2974 | } |
---|
2975 | } |
---|
2976 | |
---|
2977 | void pal_win::draw() |
---|
2978 | { |
---|
2979 | int i,d=cur_fg; |
---|
2980 | if (me) |
---|
2981 | { |
---|
2982 | me->clear(); |
---|
2983 | image *im=new image(vec2i(the_game->ftile_width(),the_game->ftile_height())); |
---|
2984 | int th=the_game->ftile_height()/scale,tw=the_game->ftile_width()/scale; |
---|
2985 | |
---|
2986 | for (i=0; i<w*h; i++) |
---|
2987 | { |
---|
2988 | im->clear(); |
---|
2989 | the_game->get_fg(pat[i])->im->PutImage(im, vec2i(0,0)); |
---|
2990 | scale_put(im,me->m_surf,me->x1()+(i%w)*tw, |
---|
2991 | me->y1()+(i/w)*th,tw,th); |
---|
2992 | if (d==pat[i]) |
---|
2993 | { |
---|
2994 | me->m_surf->Rectangle(vec2i(me->x1() + (i % w) * tw, |
---|
2995 | me->y1() + (i / w) * th), |
---|
2996 | vec2i(me->x1() + (i % w) * tw + tw - 1, |
---|
2997 | me->y1() + (i / w) * th + th - 1), |
---|
2998 | wm->bright_color()); |
---|
2999 | } |
---|
3000 | } |
---|
3001 | delete im; |
---|
3002 | last_selected=d; |
---|
3003 | } |
---|
3004 | } |
---|
3005 | |
---|
3006 | void pal_win::handle_event(Event &ev) |
---|
3007 | { |
---|
3008 | int d=cur_fg; |
---|
3009 | |
---|
3010 | if (d!=last_selected) // if so see if we need to hilight any of our tiles. |
---|
3011 | { |
---|
3012 | int i,dr=0; |
---|
3013 | for (i=0; i<w*h; i++) |
---|
3014 | { |
---|
3015 | if (pat[i]==d || pat[i]==last_selected) |
---|
3016 | dr=1; |
---|
3017 | } |
---|
3018 | if (dr) draw(); |
---|
3019 | last_selected=d; |
---|
3020 | } |
---|
3021 | |
---|
3022 | if (ev.window && ev.window==me) |
---|
3023 | { |
---|
3024 | switch (ev.type) |
---|
3025 | { |
---|
3026 | case EV_MOUSE_BUTTON : |
---|
3027 | { |
---|
3028 | if (ev.mouse_button==1) |
---|
3029 | { |
---|
3030 | int selx=(last_demo_mpos.x-me->m_pos.x-me->x1())/(the_game->ftile_width()/scale), |
---|
3031 | sely=(last_demo_mpos.y-me->m_pos.y-me->y1())/(the_game->ftile_height()/scale); |
---|
3032 | if (selx>=0 && sely>=0 && selx<w && sely<h) |
---|
3033 | { |
---|
3034 | cur_fg=pat[selx+sely*w]; |
---|
3035 | if (dev_cont->forew) |
---|
3036 | ((tile_picker *)dev_cont->forew-> |
---|
3037 | read(DEV_FG_PICKER))->recenter(dev_cont->forew->m_surf); |
---|
3038 | } |
---|
3039 | } else if (ev.mouse_button==2) |
---|
3040 | { |
---|
3041 | if (palettes_locked) |
---|
3042 | the_game->show_help(symbol_str("pal_lock")); |
---|
3043 | else |
---|
3044 | { |
---|
3045 | int selx=(last_demo_mpos.x-me->m_pos.x-me->x1())/(the_game->ftile_width()/scale), |
---|
3046 | sely=(last_demo_mpos.y-me->m_pos.y-me->y1())/(the_game->ftile_height()/scale); |
---|
3047 | if (selx>=0 && sely>=0 && selx<w && sely<h) |
---|
3048 | { |
---|
3049 | pat[selx+sely*w]=cur_fg; |
---|
3050 | draw(); |
---|
3051 | } |
---|
3052 | } |
---|
3053 | } |
---|
3054 | } break; |
---|
3055 | |
---|
3056 | case EV_KEY : |
---|
3057 | { |
---|
3058 | switch (ev.key) |
---|
3059 | { |
---|
3060 | case '+' : |
---|
3061 | { if (scale>1) |
---|
3062 | { |
---|
3063 | close_window(); |
---|
3064 | scale--; |
---|
3065 | open_window(); |
---|
3066 | } |
---|
3067 | } break; |
---|
3068 | case '-' : |
---|
3069 | { if (scale<the_game->ftile_height()/2) |
---|
3070 | { |
---|
3071 | close_window(); |
---|
3072 | scale++; |
---|
3073 | open_window(); |
---|
3074 | } |
---|
3075 | } break; |
---|
3076 | case JK_LEFT : |
---|
3077 | { |
---|
3078 | if (palettes_locked) the_game->show_help(symbol_str("pal_lock")); |
---|
3079 | else if (w>1) resize(-1,0); |
---|
3080 | } break; |
---|
3081 | case JK_RIGHT : |
---|
3082 | { |
---|
3083 | if (palettes_locked) the_game->show_help(symbol_str("pal_lock")); |
---|
3084 | else |
---|
3085 | resize(1,0); |
---|
3086 | } break; |
---|
3087 | case JK_UP : |
---|
3088 | { |
---|
3089 | if (palettes_locked) the_game->show_help(symbol_str("pal_lock")); |
---|
3090 | else if (h>1) resize(0,-1); |
---|
3091 | } break; |
---|
3092 | case JK_DOWN : |
---|
3093 | { |
---|
3094 | if (palettes_locked) |
---|
3095 | the_game->show_help(symbol_str("pal_lock")); |
---|
3096 | else |
---|
3097 | resize(0,1); |
---|
3098 | } break; |
---|
3099 | case JK_ESC : close_window(); break; |
---|
3100 | case ' ' : |
---|
3101 | { |
---|
3102 | int32_t xx, yy; |
---|
3103 | vec2i tile = the_game->GetFgTile(me->m_pos); |
---|
3104 | |
---|
3105 | for (xx=tile.x; xx<tile.x+w; xx++) |
---|
3106 | { |
---|
3107 | for (yy=tile.y; yy<tile.y+h; yy++) |
---|
3108 | { |
---|
3109 | if (xx>=0 && yy>=0 && xx<current_level->foreground_width() && |
---|
3110 | yy<current_level->foreground_height()) |
---|
3111 | the_game->put_fg(xx,yy,raise_all ? make_above_tile(pat[xx-tile.x+(yy-tile.y)*w]) : pat[xx-tile.x+(yy-tile.y)*w] ); |
---|
3112 | } |
---|
3113 | } |
---|
3114 | } break; |
---|
3115 | case 't' : |
---|
3116 | { |
---|
3117 | vec2i tile = the_game->GetFgTile(me->m_pos); |
---|
3118 | dev_cont->fg_fill(-1, tile.x, tile.y, this); |
---|
3119 | } break; |
---|
3120 | |
---|
3121 | } |
---|
3122 | } break; |
---|
3123 | |
---|
3124 | case EV_CLOSE_WINDOW : close_window(); break; |
---|
3125 | } |
---|
3126 | } |
---|
3127 | |
---|
3128 | |
---|
3129 | } |
---|
3130 | |
---|
3131 | |
---|
3132 | void pal_win::resize(int xa, int ya) |
---|
3133 | { |
---|
3134 | int i,j; |
---|
3135 | unsigned short *npat; |
---|
3136 | if (w+xa<1 || y+ya<1) return ; |
---|
3137 | |
---|
3138 | npat=(unsigned short *)malloc(sizeof(unsigned short)*(w+xa)*(h+ya)); |
---|
3139 | memset(npat,0,sizeof(unsigned short)*(w+xa)*(h+ya)); |
---|
3140 | for (i=0; i<(w+xa); i++) |
---|
3141 | for (j=0; j<(h+ya); j++) |
---|
3142 | if (i+j*w<w*h) |
---|
3143 | npat[i+j*(w+xa)]=pat[i+j*w]; |
---|
3144 | free(pat); |
---|
3145 | w+=xa; |
---|
3146 | h+=ya; |
---|
3147 | pat=npat; |
---|
3148 | last_selected=-1; |
---|
3149 | close_window(); |
---|
3150 | open_window(); |
---|
3151 | } |
---|
3152 | |
---|
3153 | |
---|
3154 | void pal_win::save(FILE *fp) |
---|
3155 | { |
---|
3156 | if (me) |
---|
3157 | { |
---|
3158 | x=me->m_pos.x; |
---|
3159 | y=me->m_pos.y; |
---|
3160 | } |
---|
3161 | |
---|
3162 | fprintf(fp,"(add_palette \"%s\" %ld %ld %ld %ld %ld ",name,(long)w,(long)h,(long)x,(long)y,(long)scale); |
---|
3163 | int i; |
---|
3164 | for (i=0; i<w*h; i++) |
---|
3165 | fprintf(fp,"%d ",pat[i]&0x7fff); |
---|
3166 | fprintf(fp,")\n"); |
---|
3167 | |
---|
3168 | } |
---|
3169 | |
---|
3170 | void dev_controll::save() |
---|
3171 | { |
---|
3172 | FILE *fp=open_FILE("edit.lsp","w"); |
---|
3173 | if (!fp) |
---|
3174 | the_game->show_help(symbol_str("no_edit.lsp")); |
---|
3175 | else |
---|
3176 | { |
---|
3177 | fprintf(fp,"(set_zoom %d)\n",the_game->zoom); |
---|
3178 | |
---|
3179 | int i; |
---|
3180 | for (i=0; i<total_pals; i++) |
---|
3181 | { |
---|
3182 | pal_wins[i]->save(fp); |
---|
3183 | } |
---|
3184 | fprintf(fp,"\n"); |
---|
3185 | fclose(fp); |
---|
3186 | } |
---|
3187 | |
---|
3188 | } |
---|
3189 | |
---|
3190 | int dev_controll::is_pal_win(Jwindow *win) |
---|
3191 | { |
---|
3192 | int i; |
---|
3193 | for (i=0; i<total_pals; i++) |
---|
3194 | if (win==pal_wins[i]->me) return 1; |
---|
3195 | return 0; |
---|
3196 | } |
---|
3197 | |
---|
3198 | |
---|
3199 | class fill_rec |
---|
3200 | { |
---|
3201 | public : |
---|
3202 | short x,y; |
---|
3203 | fill_rec *last; |
---|
3204 | fill_rec(short X, short Y, fill_rec *Last) |
---|
3205 | { x=X; y=Y; last=Last; } |
---|
3206 | } ; |
---|
3207 | |
---|
3208 | static int get_color(int color, int x, int y, pal_win *p) |
---|
3209 | { |
---|
3210 | if (p) |
---|
3211 | { |
---|
3212 | while (x<0) x+=p->width(); |
---|
3213 | while (y<0) y+=p->height(); |
---|
3214 | return p->get_pat(x%p->width(),y%p->height()); |
---|
3215 | } |
---|
3216 | else return color; |
---|
3217 | } |
---|
3218 | |
---|
3219 | void dev_controll::fg_fill(int color, int x, int y, pal_win *p) |
---|
3220 | { |
---|
3221 | unsigned short *sl,*above,*below; |
---|
3222 | fill_rec *recs=NULL,*r; |
---|
3223 | unsigned short fcolor; |
---|
3224 | sl=current_level->get_fgline(y); |
---|
3225 | fcolor=fgvalue(sl[x]); |
---|
3226 | int startx=x,starty=y; |
---|
3227 | if (fcolor==color) return ; |
---|
3228 | do |
---|
3229 | { |
---|
3230 | if (recs) |
---|
3231 | { r=recs; |
---|
3232 | recs=recs->last; |
---|
3233 | x=r->x; y=r->y; |
---|
3234 | delete r; |
---|
3235 | } |
---|
3236 | sl=current_level->get_fgline(y); |
---|
3237 | if (fgvalue(sl[x])==fcolor) |
---|
3238 | { |
---|
3239 | while (x>0 && fgvalue(sl[x])==fcolor) x--; |
---|
3240 | if (fgvalue(sl[x])!=fgvalue(fcolor) && x<current_level->foreground_width()-1) x++; |
---|
3241 | if (y>0) |
---|
3242 | { |
---|
3243 | above=current_level->get_fgline(y-1); |
---|
3244 | if (fgvalue(above[x])==fcolor) |
---|
3245 | { r=new fill_rec(x,y-1,recs); |
---|
3246 | recs=r; |
---|
3247 | } |
---|
3248 | } |
---|
3249 | if (y<current_level->foreground_height()-1) |
---|
3250 | { |
---|
3251 | above=current_level->get_fgline(y+1); |
---|
3252 | if (above[x]==fcolor) |
---|
3253 | { r=new fill_rec(x,y+1,recs); |
---|
3254 | recs=r; |
---|
3255 | } |
---|
3256 | } |
---|
3257 | |
---|
3258 | |
---|
3259 | |
---|
3260 | do |
---|
3261 | { |
---|
3262 | sl[x]=get_color(color,x-startx,y-starty,p); |
---|
3263 | if (y>0) |
---|
3264 | { above=current_level->get_fgline(y-1); |
---|
3265 | if (x>0 && fgvalue(above[x-1])!=fgvalue(fcolor) && fgvalue(above[x])==fgvalue(fcolor)) |
---|
3266 | { r=new fill_rec(x,y-1,recs); |
---|
3267 | recs=r; |
---|
3268 | } |
---|
3269 | } |
---|
3270 | if (y<current_level->foreground_height()-1) |
---|
3271 | { below=current_level->get_fgline(y+1); |
---|
3272 | if (x>0 && fgvalue(below[x-1])!=fgvalue(fcolor) && fgvalue(below[x])==fgvalue(fcolor)) |
---|
3273 | { r=new fill_rec(x,y+1,recs); |
---|
3274 | recs=r; |
---|
3275 | } |
---|
3276 | } |
---|
3277 | x++; |
---|
3278 | } while (fgvalue(sl[x])==fgvalue(fcolor) && x<current_level->foreground_width()); |
---|
3279 | x--; |
---|
3280 | if (y>0) |
---|
3281 | { |
---|
3282 | above=current_level->get_fgline(y-1); |
---|
3283 | if (fgvalue(above[x])==fgvalue(fcolor)) |
---|
3284 | { r=new fill_rec(x,y-1,recs); |
---|
3285 | recs=r; |
---|
3286 | } |
---|
3287 | } |
---|
3288 | if (y<current_level->foreground_height()-1) |
---|
3289 | { |
---|
3290 | above=current_level->get_fgline(y+1); |
---|
3291 | if (fgvalue(above[x])==fgvalue(fcolor)) |
---|
3292 | { r=new fill_rec(x,y+1,recs); |
---|
3293 | recs=r; |
---|
3294 | } |
---|
3295 | } |
---|
3296 | } |
---|
3297 | } while (recs); |
---|
3298 | the_game->need_refresh(); |
---|
3299 | } |
---|
3300 | |
---|
3301 | static int get_char_mem(int type, int print) |
---|
3302 | { |
---|
3303 | int t=0; |
---|
3304 | for (int j=0; j<MAX_STATE; j++) |
---|
3305 | { |
---|
3306 | if (figures[type]->has_sequence((character_state)j)) |
---|
3307 | { |
---|
3308 | int s=figures[type]->get_sequence((character_state)j)->MemUsage(); |
---|
3309 | if (print) |
---|
3310 | dprintf("(%s=%d)",state_names[j],s); |
---|
3311 | t+=s; |
---|
3312 | } |
---|
3313 | } |
---|
3314 | if (print) |
---|
3315 | dprintf("\ntotal=%d\n",t); |
---|
3316 | return t; |
---|
3317 | } |
---|
3318 | |
---|
3319 | void dev_controll::show_char_mem(char const *name) |
---|
3320 | { |
---|
3321 | int find=-1; |
---|
3322 | for (int i=0; i<total_objects; i++) |
---|
3323 | { |
---|
3324 | if (!strcmp(name,object_names[i])) |
---|
3325 | find=i; |
---|
3326 | } |
---|
3327 | if (find<0) |
---|
3328 | dprintf("No character '%s' defined\n",name); |
---|
3329 | else |
---|
3330 | get_char_mem(find,1); |
---|
3331 | |
---|
3332 | } |
---|
3333 | |
---|
3334 | void dev_controll::show_mem() |
---|
3335 | { |
---|
3336 | int t=0,s=0; |
---|
3337 | int i=0; |
---|
3338 | for (; i<nforetiles; i++) |
---|
3339 | { |
---|
3340 | if (foretiles[i]>=0) |
---|
3341 | { |
---|
3342 | if (cache.loaded(foretiles[i])) |
---|
3343 | { |
---|
3344 | t++; |
---|
3345 | s+=cache.foret(foretiles[i])->size(); |
---|
3346 | } |
---|
3347 | } |
---|
3348 | } |
---|
3349 | dprintf("%d loaded foretiles=%d bytes\n",t,s); |
---|
3350 | |
---|
3351 | t=0; s=0; |
---|
3352 | for (i=0; i<nbacktiles; i++) |
---|
3353 | { |
---|
3354 | if (backtiles[i]>=0) |
---|
3355 | { |
---|
3356 | if (cache.loaded(foretiles[i])) |
---|
3357 | { |
---|
3358 | t++; |
---|
3359 | s+=cache.backt(backtiles[i])->size(); |
---|
3360 | } |
---|
3361 | } |
---|
3362 | } |
---|
3363 | dprintf("%d loaded backtiles=%d bytes\n",t,s); |
---|
3364 | |
---|
3365 | t=0; s=0; |
---|
3366 | for (i=0; i<total_objects; i++) |
---|
3367 | { |
---|
3368 | t++; |
---|
3369 | s+=get_char_mem(i,0); |
---|
3370 | } |
---|
3371 | dprintf("%d character=%d bytes\n",t,s); |
---|
3372 | |
---|
3373 | } |
---|
3374 | |
---|
3375 | |
---|
3376 | |
---|
3377 | void dev_cleanup() |
---|
3378 | { |
---|
3379 | if (start_edit) |
---|
3380 | prop->save("defaults.prp"); |
---|
3381 | delete prop; |
---|
3382 | if (listable_objs) |
---|
3383 | { |
---|
3384 | free(listable_objs); |
---|
3385 | listable_objs=NULL; |
---|
3386 | } |
---|
3387 | crc_manager.clean_up(); |
---|
3388 | |
---|
3389 | } |
---|
3390 | |
---|
3391 | |
---|
3392 | |
---|
3393 | struct pmi |
---|
3394 | { |
---|
3395 | char const *name; |
---|
3396 | int id; |
---|
3397 | char const *on_off; |
---|
3398 | int key; |
---|
3399 | } ; |
---|
3400 | |
---|
3401 | |
---|
3402 | static pmi filemenu[]={ |
---|
3403 | { "menu1_load", ID_LEVEL_LOAD,NULL,-1}, |
---|
3404 | { NULL,0,NULL,-1}, |
---|
3405 | { "menu1_save", ID_LEVEL_SAVE,NULL,-1}, |
---|
3406 | { "menu1_saveas", ID_LEVEL_SAVEAS,NULL,-1}, |
---|
3407 | { "menu1_savegame", ID_GAME_SAVE,NULL,-1}, |
---|
3408 | { "menu1_new", ID_LEVEL_NEW,NULL,-1}, |
---|
3409 | { "menu1_resize", ID_LEVEL_RESIZE,NULL,-1}, |
---|
3410 | { NULL,0,NULL,-1}, |
---|
3411 | { "menu1_suspend",ID_SUSPEND,NULL,-1}, |
---|
3412 | { "menu1_toggle",ID_PLAY_MODE,NULL,-1}, |
---|
3413 | { NULL,0,NULL,-1}, |
---|
3414 | { "menu1_savepal",ID_EDIT_SAVE,NULL,-1}, |
---|
3415 | // { "menu1_startc",ID_CACHE_PROFILE,NULL,-1}, |
---|
3416 | // { "menu1_endc",ID_CACHE_PROFILE_END,NULL,-1}, |
---|
3417 | { NULL,0,NULL,-1}, |
---|
3418 | { "menu1_quit", ID_QUIT,NULL,-1}, |
---|
3419 | { NULL,-1,NULL,-1} |
---|
3420 | }; |
---|
3421 | |
---|
3422 | |
---|
3423 | static pmi editmenu[]={ |
---|
3424 | { "menu2_light", ID_TOGGLE_LIGHT,NULL,-1}, |
---|
3425 | { "menu2_scroll", ID_SET_SCROLL,NULL,-1}, |
---|
3426 | { "menu2_center", ID_CENTER_PLAYER,NULL,-1}, |
---|
3427 | { "menu2_addpal", ID_ADD_PALETTE,NULL,-1}, |
---|
3428 | { "menu2_delay", ID_TOGGLE_DELAY,NULL,-1}, |
---|
3429 | |
---|
3430 | { "menu2_god", ID_GOD_MODE,NULL,-1}, |
---|
3431 | { "menu2_clear", ID_CLEAR_WEAPONS,NULL,-1}, |
---|
3432 | { "menu2_mscroll", ID_MOUSE_SCROLL,&mouse_scrolling,-1}, |
---|
3433 | { "menu2_lock", ID_LOCK_PALETTES,&palettes_locked,-1}, |
---|
3434 | { "menu2_raise", ID_RAISE_ALL,&raise_all,-1}, |
---|
3435 | { "menu2_names", ID_TOGGLE_NAMES,&show_names,-1}, |
---|
3436 | |
---|
3437 | { NULL,0,NULL,-1}, |
---|
3438 | { "menu2_map", ID_TOGGLE_MAP,NULL,-1}, |
---|
3439 | // { "Shrink to 320x200 (F10)", ID_SMALL_MODE,NULL,-1}, |
---|
3440 | { "menu2_view", ID_DISABLE_VIEW_SHIFT,&view_shift_disabled,-1}, |
---|
3441 | // { "Ultra Smooth draw (U)", ID_INTERPOLATE_DRAW, &interpolate_draw,'U'}, |
---|
3442 | { "menu2_alight", ID_DISABLE_AUTOLIGHT, &disable_autolight,'A'}, |
---|
3443 | { "menu2_fps", ID_SHOW_FPS, &fps_on,-1}, |
---|
3444 | // { NULL,0,NULL,-1}, |
---|
3445 | // { "Record demo", ID_RECORD_DEMO,NULL,-1}, |
---|
3446 | // { "Play demo", ID_PLAY_DEMO,NULL,-1}, |
---|
3447 | { NULL,-1,NULL,-1} |
---|
3448 | }; |
---|
3449 | |
---|
3450 | |
---|
3451 | |
---|
3452 | // Window Menus |
---|
3453 | static pmi winmenu[]={ |
---|
3454 | { "menu3_fore", ID_WIN_FORE, &forew_on,-1}, |
---|
3455 | { "menu3_back", ID_WIN_BACK, &backw_on,-1}, |
---|
3456 | { "menu3_layers", ID_WIN_LAYERS, &show_menu_on,-1}, |
---|
3457 | { "menu3_light", ID_WIN_LIGHTING,&ledit_on,-1}, |
---|
3458 | { "menu3_pal", ID_WIN_PALETTES,&pmenu_on,-1}, |
---|
3459 | { "menu3_objs", ID_WIN_OBJECTS, &omenu_on,-1}, |
---|
3460 | // { "menu3_console", ID_WIN_CONSOLE, &commandw_on,-1}, |
---|
3461 | { "menu3_toolbar", ID_WIN_TOOLBAR, &tbw_on,-1}, |
---|
3462 | // { "Search (s)", ID_SEARCH, &searchw_on,-1}, |
---|
3463 | { "menu3_prof", ID_PROFILE, &profile_on,-1}, |
---|
3464 | { "menu3_save", ID_SAVE_WINDOWS,NULL,-1}, |
---|
3465 | { NULL,-1,NULL,-1} |
---|
3466 | }; |
---|
3467 | |
---|
3468 | |
---|
3469 | |
---|
3470 | /* |
---|
3471 | static pmi filemenu[]={ |
---|
3472 | { "Load Level", ID_LEVEL_LOAD,NULL,-1}, |
---|
3473 | { NULL,0,NULL,-1}, |
---|
3474 | { "Save Level (S)", ID_LEVEL_SAVE,NULL,-1}, |
---|
3475 | { "Save level as", ID_LEVEL_SAVEAS,NULL,-1}, |
---|
3476 | { "Save game", ID_GAME_SAVE,NULL,-1}, |
---|
3477 | { "New level", ID_LEVEL_NEW,NULL,-1}, |
---|
3478 | { "Resize map", ID_LEVEL_RESIZE,NULL,-1}, |
---|
3479 | { NULL,0,NULL,-1}, |
---|
3480 | { "Suspend non-players",ID_SUSPEND,NULL,-1}, |
---|
3481 | { "Play mode toggle (TAB)",ID_PLAY_MODE,NULL,-1}, |
---|
3482 | { NULL,0,NULL,-1}, |
---|
3483 | { "Save Palettes ",ID_EDIT_SAVE,NULL,-1}, |
---|
3484 | { "Start cache profile ",ID_CACHE_PROFILE,NULL,-1}, |
---|
3485 | { "End cache profile ",ID_CACHE_PROFILE_END,NULL,-1}, |
---|
3486 | { NULL,0,NULL,-1}, |
---|
3487 | { "Quit (Q)", ID_QUIT,NULL,-1}, |
---|
3488 | { NULL,-1,NULL,-1} |
---|
3489 | }; |
---|
3490 | |
---|
3491 | |
---|
3492 | static pmi editmenu[]={ |
---|
3493 | { "Toggle light", ID_TOGGLE_LIGHT,NULL,-1}, |
---|
3494 | { "Set scroll rate", ID_SET_SCROLL,NULL,-1}, |
---|
3495 | { "Center on player (c)", ID_CENTER_PLAYER,NULL,-1}, |
---|
3496 | { "Add palette", ID_ADD_PALETTE,NULL,-1}, |
---|
3497 | { "Toggle Delays (D)", ID_TOGGLE_DELAY,NULL,-1}, |
---|
3498 | |
---|
3499 | { "God mode", ID_GOD_MODE,NULL,-1}, |
---|
3500 | { "Clear weapons (z)", ID_CLEAR_WEAPONS,NULL,-1}, |
---|
3501 | { "Mouse scroll", ID_MOUSE_SCROLL,&mouse_scrolling,-1}, |
---|
3502 | { "Lock palette windows", ID_LOCK_PALETTES,&palettes_locked,-1}, |
---|
3503 | { "Raise all foreground", ID_RAISE_ALL,&raise_all,-1}, |
---|
3504 | { "Toggle object names", ID_TOGGLE_NAMES,&show_names,-1}, |
---|
3505 | |
---|
3506 | { NULL,0,NULL,-1}, |
---|
3507 | { "Toggle map (m)", ID_TOGGLE_MAP,NULL,-1}, |
---|
3508 | // { "Shrink to 320x200 (F10)", ID_SMALL_MODE,NULL,-1}, |
---|
3509 | { "Disable view shifts", ID_DISABLE_VIEW_SHIFT,&view_shift_disabled,-1}, |
---|
3510 | // { "Ultra Smooth draw (U)", ID_INTERPOLATE_DRAW, &interpolate_draw,'U'}, |
---|
3511 | { "Disable Autolight (A)", ID_DISABLE_AUTOLIGHT, &disable_autolight,'A'}, |
---|
3512 | { "Show FPS/Obj count", ID_SHOW_FPS, &fps_on,-1}, |
---|
3513 | // { NULL,0,NULL,-1}, |
---|
3514 | // { "Record demo", ID_RECORD_DEMO,NULL,-1}, |
---|
3515 | // { "Play demo", ID_PLAY_DEMO,NULL,-1}, |
---|
3516 | { NULL,-1,NULL,-1} |
---|
3517 | }; |
---|
3518 | |
---|
3519 | |
---|
3520 | |
---|
3521 | // Window Menus |
---|
3522 | static pmi winmenu[]={ |
---|
3523 | { "Foreground (f)", ID_WIN_FORE, &forew_on,-1}, |
---|
3524 | { "Background (b)", ID_WIN_BACK, &backw_on,-1}, |
---|
3525 | { "Draw layers (L)", ID_WIN_LAYERS, &show_menu_on,-1}, |
---|
3526 | { "Lighting (l)", ID_WIN_LIGHTING,&ledit_on,-1}, |
---|
3527 | { "Palettes (p)", ID_WIN_PALETTES,&pmenu_on,-1}, |
---|
3528 | { "Objects (o)", ID_WIN_OBJECTS, &omenu_on,-1}, |
---|
3529 | { "Console (/)", ID_WIN_CONSOLE, &commandw_on,-1}, |
---|
3530 | { "Tool Bar (a)", ID_WIN_TOOLBAR, &tbw_on,-1}, |
---|
3531 | // { "Search (s)", ID_SEARCH, &searchw_on,-1}, |
---|
3532 | { "Profile (P)", ID_PROFILE, &profile_on,-1}, |
---|
3533 | { "Save positions", ID_SAVE_WINDOWS,NULL,-1}, |
---|
3534 | { NULL,-1,NULL,-1} |
---|
3535 | }; |
---|
3536 | |
---|
3537 | */ |
---|
3538 | |
---|
3539 | static pmenu_item *i_recurse(pmi *first) |
---|
3540 | { |
---|
3541 | if (first->id==-1) |
---|
3542 | return NULL; |
---|
3543 | else |
---|
3544 | return new pmenu_item(first->id,first->name ? symbol_str(first->name) : 0,first->on_off,first->key,i_recurse(first+1)); |
---|
3545 | } |
---|
3546 | |
---|
3547 | static pmenu *make_menu(int x, int y) |
---|
3548 | { |
---|
3549 | return new pmenu(x,y, |
---|
3550 | new pmenu_item(symbol_str("file_top"),new psub_menu(i_recurse(filemenu),NULL), |
---|
3551 | new pmenu_item(symbol_str("edit_top"),new psub_menu(i_recurse(editmenu),NULL), |
---|
3552 | new pmenu_item(symbol_str("window_top"),new psub_menu(i_recurse(winmenu),NULL),NULL))),main_screen); |
---|
3553 | } |
---|
3554 | |
---|
3555 | |
---|
3556 | |
---|
3557 | void toggle_edit_mode() |
---|
3558 | { |
---|
3559 | dev=dev^EDIT_MODE; |
---|
3560 | if (dev&EDIT_MODE) |
---|
3561 | { |
---|
3562 | wm->SetMouseShape(cache.img(c_normal)->copy(), vec2i(1, 1)); |
---|
3563 | pal->load(); |
---|
3564 | } |
---|
3565 | else |
---|
3566 | { |
---|
3567 | if (dev&MAP_MODE) dev-=MAP_MODE; // no map mode while playing! |
---|
3568 | wm->SetMouseShape(cache.img(c_target)->copy(), vec2i(8, 8)); |
---|
3569 | } |
---|
3570 | if ((dev&EDIT_MODE) && !dev_menu) |
---|
3571 | { |
---|
3572 | dev_menu=make_menu(0,yres-wm->font()->height()-5); |
---|
3573 | } |
---|
3574 | else if (!(dev&EDIT_MODE) && dev_menu) |
---|
3575 | { |
---|
3576 | delete dev_menu; |
---|
3577 | dev_menu=NULL; |
---|
3578 | } |
---|
3579 | } |
---|
3580 | |
---|
3581 | |
---|
3582 | int dev_controll::ok_to_scroll() |
---|
3583 | { |
---|
3584 | if (state==DEV_MOVE_LIGHT || state==DEV_MOVE_OBJECT || mouse_scrolling) return 1; |
---|
3585 | else return 0; |
---|
3586 | } |
---|
3587 | |
---|
3588 | dev_controll::~dev_controll() |
---|
3589 | { |
---|
3590 | for (int i=0; i<total_pals; i++) |
---|
3591 | delete pal_wins[i]; |
---|
3592 | if (total_pals) |
---|
3593 | free(pal_wins); |
---|
3594 | } |
---|
3595 | |
---|
3596 | |
---|
3597 | |
---|
3598 | pal_win::~pal_win() |
---|
3599 | { |
---|
3600 | free(pat); |
---|
3601 | free(name); |
---|
3602 | } |
---|