Obj macrochar(Obj port, int c1, int c2){ Obj fn, fv; fn = maksym_c("macro-handler"); fv = getvalue(fn); if( DEFINEDP(fv) && !FALSEP(Fprocp(fv)) ) return funcall_3("#<internal:macrochar>", fn, port, MAKCHAR(c1), c2?MAKCHAR(c2):IC_UNSPEC); return JLERROR("#<internal:macrochar>", port, "no macro-handler"); }
static int binding_for_player( int player ) { char tmp[40]; sprintf( tmp, "player%d", player ); LSymbol *f = LSymbol::Find(tmp); if( !NILP(f) && DEFINEDP(f->GetValue())) { void *what = f->GetValue(); if(what == LSymbol::FindOrCreate("keyboard")) return 1; else if(what == LSymbol::FindOrCreate("joystick")) return 2; } return 0; }
void save_difficulty() { FILE *fp=open_FILE("hardness.lsp","wb"); if (!fp) dprintf("Unable to write to file hardness.lsp\n"); else { fprintf(fp,"(setf difficulty '"); if (DEFINEDP(symbol_value(l_difficulty))) { if (symbol_value(l_difficulty)==l_extreme) fprintf(fp,"extreme)\n"); else if (symbol_value(l_difficulty)==l_hard) fprintf(fp,"hard)\n"); else if (symbol_value(l_difficulty)==l_easy) fprintf(fp,"easy)\n"); else fprintf(fp,"medium)\n"); } else fprintf(fp,"medium)\n"); fclose(fp); } }
void status_bar::draw_update() { if (total_weapons && v) { if (DEFINEDP(symbol_value(l_mouse_can_switch)) && symbol_value(l_mouse_can_switch) && mouse_in_area()) { if ((current_level->tick_counter()&4)==0) wm->set_mouse_shape(cache.img(c_mouse1)->copy(),4,4); else wm->set_mouse_shape(cache.img(c_mouse2)->copy(),4,4); changed_cursor=1; } else if (changed_cursor) { if (!(dev&EDIT_MODE)) wm->set_mouse_shape(cache.img(c_target)->copy(),8,8); else wm->set_mouse_shape(cache.img(c_normal)->copy(),1,1); changed_cursor=0; } if (need_rf) redraw(screen); } }
void prnobj(Obj a, Obj stream, int how){ int typ = TYPEOFX(a); int (*printfnc)(Obj,Obj,int); char buf[8]; char *foo; Obj radix; int base; switch( typ ){ case TPVF_IMMED: if( INUMP( a )){ /* int */ radix = getvalue( sym_oradix); if(DEFINEDP(radix)&& INUMP(radix)) base = CINT(radix); else base = 10; if(how) base = 10; printnum(stream, CINT(a), base, 0,0); } else if( ICHARP( a )){ /* char */ foo = 0; if(how){ writestr(stream, "#\\"); foo = spec_repr( CCHAR(a), 0 ); } if(foo) writestr(stream, foo); else writechar(stream, CCHAR(a)); } else if( ICONSTP( a )){ /* const sym */ switch( a ){ case IC_NIL: writestr(stream, "()"); break; case IC_TRUE: writestr(stream, "#t"); break; case IC_FALSE: writestr(stream, "#f"); break; case IC_UNDEF: writestr(stream, "#<undefined>"); break; case IC_UNSPEC: writestr(stream, "#<unspecified>"); break; case IC_EOF: writestr(stream, "#<EOF>"); break; default: writestr(stream, "#<<send in bug report> IC_0x"); printnum(stream, a, 16,0,0); writestr(stream, "?>"); break; } } else if ( SYMBOLP( a )){ writestr(stream, symbolname(a) ); } else { writestr(stream, "#<<send in bug report> IMM_0x"); printnum(stream, a, 16,0,0); writestr(stream, "?>"); } break; #if 0 case TPV_SYMBOL: writestr(stream, CCHARS(a)); break; #endif case TPV_SYM_BOX: if(how) writestr(stream, symbolname( MAKSYM(CSYM_BOX(a)->id ))); else{ writestr(stream, "#<["); writestr(stream, symbolname( MAKSYM(CSYM_BOX(a)->id ))); writestr(stream, "]>"); } break; default: printfnc = jlisp_vtbl[ typ ].print; if( !printfnc || ! printfnc(a, stream, how) ){ writestr(stream, "#<_"); printnum(stream, typ, 10,0,0); writestr(stream, "_0x"); printnum(stream, a, 16, 0,0); writestr(stream, ">"); } break; } }
void gamma_correct(palette *&pal, int force_menu) { long dg=0,old_dg=0; int abort=0; // see if user has already done this routine LSymbol *gs = LSymbol::Find("darkest_gray"); if(old_pal) { delete pal; pal = old_pal; old_pal = NULL; } if(gs && DEFINEDP(gs->GetValue()) && !force_menu) { dg = lnumber_value(gs->GetValue()); } #ifdef __QNXNTO__ else if (!force_menu) { dg = 36; } #endif // __QNXNTO__ else { if(gs && DEFINEDP(gs->GetValue())) { dg = old_dg = lnumber_value(gs->GetValue()); } // load in a fine gray palette they can chose from palette *gray_pal = pal->copy(); int i = 0; int tc = 32; for(; i < tc; i++) { gray_pal->set(i, i * 4, i * 4, i * 4); } gray_pal->load(); int wm_bc = wm->bright_color(), wm_mc = wm->medium_color(), wm_dc = wm->dark_color(); int br_r = pal->red(wm_bc) + 20; if(br_r > 255) br_r = 255; int br_g = pal->green(wm_bc) + 20; if(br_g > 255) br_g = 255; int br_b = pal->blue(wm_bc) + 20; if(br_b > 255) br_b = 255; int md_r = pal->red(wm_mc) - 20; if(md_r < 0) md_r = 0; int md_g = pal->green(wm_mc) - 20; if(md_g < 0) md_g = 0; int md_b = pal->blue(wm_mc) - 20; if(md_b < 0) md_b = 0; int dr_r = pal->red(wm_dc) - 40; if(dr_r < 0) dr_r = 0; int dr_g = pal->green(wm_dc) - 40; if(dr_g < 0) dr_g = 0; int dr_b = pal->blue(wm_dc) - 40; if(dr_b < 0) dr_b = 0; wm->set_colors(gray_pal->find_closest(br_r, br_g, br_b), gray_pal->find_closest(md_r, md_g, md_b), gray_pal->find_closest(dr_r, dr_g, dr_b)); int sh = wm->font()->Size().y + 35; button *but = new button(5, 5 + sh * 3, ID_GAMMA_OK, cache.img(ok_button), new info_field(35, 10 + sh * 3, ID_NULL, lang_string("gamma_msg"), 0)); gray_picker *gp = new gray_picker(2, 5 + sh, ID_GREEN_PICKER, 0, dg / 4, but); gp->set_pos(dg / 4); Jwindow *gw = wm->CreateWindow(ivec2(xres / 2 - 190, yres / 2 - 90), ivec2(-1), gp); Event ev; wm->flush_screen(); do { do { wm->get_event(ev); } while(ev.type == EV_MOUSE_MOVE && wm->IsPending()); wm->flush_screen(); if(ev.type == EV_CLOSE_WINDOW) abort = 1; if(ev.type == EV_KEY && ev.key == JK_ESC) abort = 1; } while(!abort && (ev.type != EV_MESSAGE || ev.message.id != ID_GAMMA_OK)); dg = ((spicker *)gw->inm->get(ID_GREEN_PICKER))->first_selected() * 4; wm->close_window(gw); wm->flush_screen(); wm->set_colors(wm_bc, wm_mc, wm_dc); delete gray_pal; if(!abort) { char *gammapath; FILE *fp; gammapath = (char *)malloc(strlen(get_save_filename_prefix()) + 10); sprintf(gammapath, "%sgamma.lsp", get_save_filename_prefix()); fp = open_FILE(gammapath, "wb"); if(fp) { fprintf(fp, "(setq darkest_gray %ld)\n", dg); fclose(fp); LSpace *sp = LSpace::Current; LSpace::Current = &LSpace::Perm; LSymbol::FindOrCreate("darkest_gray")->SetNumber(dg); LSpace::Current = sp; } else { dprintf("Unable to write to file gamma.lsp\n"); } free(gammapath); } } if(abort) dg = old_dg; if(dg < 1) dg = 1; else if(dg > 128) dg = 128; double gamma = log(dg / 255.0) / log(16.0 / 255.0); old_pal = pal; pal = new palette; for(int i = 0; i < 256; i++) { uint8_t oldr, oldg, oldb; old_pal->get(i, oldr, oldg, oldb); pal->set(i, (int)(pow(oldr / 255.0, gamma) * 255), (int)(pow(oldg / 255.0, gamma) * 255), (int)(pow(oldb / 255.0, gamma) * 255)); } pal->load(); }
void status_bar::step() { if (!v) return ; if (!DEFINEDP(symbol_value(l_mouse_can_switch)) || !symbol_value(l_mouse_can_switch)) return ; int sb_w,sb_h; if (sbar>0 && total_weapons) { image *sb=cache.img(sbar); // status bar width & height sb_w=sb->Size().x; sb_h=sb->Size().y; } // see if the mouse is in the sbar region (demo_x already corrected for small_render) int sx1,sy1,sx2,sy2; area(sx1,sy1,sx2,sy2); int view_y2=small_render ? (v->cy2-v->cy1+1)*2+v->cy1 : v->cy2; if (sy1<view_y2) // tell view to shrink if it is overlapping the status bar { v->suggest.send_view=1; v->suggest.cx1=v->cx1; v->suggest.cy1=v->cy1; v->suggest.cx2=v->cx2; v->suggest.cy2=small_render ? (sy1-v->cy1-2)/2+v->cy1 : sy1-2; } if (sbar<=0 || !total_weapons) return ; int mx=small_render ? (last_demo_mx-v->cx1)*2+v->cx1 : last_demo_mx; int my=small_render ? (last_demo_my-v->cy1)*2+v->cy1 : last_demo_my; if (mx>sx1 && my>sy1 && mx<sx2 && my<sy2) { int new_target; mx-=sx1; if (small_render) mx/=2; mx-=47; if (mx<0) new_target=0; else { new_target=mx/33; if (new_target>=TOTAL_WEAPONS) new_target=TOTAL_WEAPONS-1; if (new_target>=total_weapons) new_target=total_weapons-1; } if (v->has_weapon(new_target) && new_target!=icon_in_selection) { icon_in_selection=new_target; need_refresh(); } if (last_demo_mbut==2 && icon_in_selection!=v->current_weapon && icon_in_selection!=-1) // the user requested a weapon change { v->suggest.send_weapon_change=1; v->suggest.new_weapon=icon_in_selection; } } else { if (icon_in_selection!=-1) { icon_in_selection=-1; need_refresh(); } } // see if a new weapon has been selected other than the one // we think is selected, if so redraw the status bar if (currently_selected_weapon!=v->current_weapon) { currently_selected_weapon=v->current_weapon; need_refresh(); } }
void main_menu() { int y=yres/2-210; ico_button *list=make_conditional_buttons(xres-51,y); list=make_default_buttons(xres-51,y,list); input_manager *inm=new input_manager(screen,eh,list); inm->allow_no_selections(); inm->clear_current(); time_marker old_time; screen->add_dirty(0,0,xres-1,yres-1); int eoff=0,coff=0; event ev; #ifdef __MAC__ int command = 0; #endif int state=0,stop_menu=0; time_marker start; eh->flush_screen(); do { time_marker new_time; if (eh->event_waiting()) { do { eh->get_event(ev); } while (ev.type==EV_MOUSE_MOVE && eh->event_waiting()); inm->handle_event(ev,NULL,eh); #ifdef __MAC__ if ((ev.type==EV_KEY || ev.type==EV_KEYRELEASE) && ev.key==JK_COMMAND) command = (ev.type == EV_KEY); if (ev.type==EV_KEY && ev.key=='q' && command) eh->push_event(new event(ID_QUIT,NULL)); #else if (ev.type==EV_KEY && ev.key==JK_ESC) eh->push_event(new event(ID_QUIT,NULL)); #endif menu_handler(ev,inm); start.get_time(); eh->flush_screen(); } if (new_time.diff_time(&start)>22) { if (volume_window) start.get_time(); else { if (!current_demo) { void *d=make_find_symbol("demos"); if (DEFINEDP(symbol_value(d))) current_demo=symbol_value(d); } if (current_demo) { demo_man.set_state(demo_manager::PLAYING,lstring_value(CAR(current_demo))); stop_menu=1; current_demo=CDR(current_demo); } } } if (volume_window) stop_menu=0; // can't exit with colume window open else if (main_net_cfg && main_net_cfg->restart_state()) stop_menu=1; else if (the_game->state==RUN_STATE) stop_menu=1; else if (ev.type==EV_MESSAGE) { if (ev.message.id==ID_START_GAME || ev.message.id==ID_RETURN) stop_menu=1; else if (ev.message.id==ID_QUIT) { #ifdef __MAC__ stop_menu=1; #else if (confirm_quit()) stop_menu=1; else { ev.type=EV_SPURIOUS; start.get_time(); } #endif } } } while (!stop_menu); delete inm; if (ev.type==EV_MESSAGE && ev.message.id==ID_QUIT) // propogate the quit message the_game->end_session(); }
ico_button *make_default_buttons(int x,int &y, ico_button *append_list) { int h; int diff_on; if (DEFINEDP(symbol_value(l_difficulty))) { if (symbol_value(l_difficulty)==l_extreme) diff_on=3; else if (symbol_value(l_difficulty)==l_hard) diff_on=2; else if (symbol_value(l_difficulty)==l_easy) diff_on=0; else diff_on=1; } else diff_on=3; ico_button *start; ifield **cur=(ifield **)&start; if (!player_list->next) { *cur=load_icon(0,ID_START_GAME,x,y,h,NULL,"ic_start"); cur=&((*cur)->next); y+=h; } ico_switch_button *set=NULL; if (!main_net_cfg || (main_net_cfg->state!=net_configuration::SERVER && main_net_cfg->state!=net_configuration::CLIENT)) { *cur=new ico_switch_button(x,y,ID_NULL,diff_on, load_icon(3,ID_EASY,x,y,h, load_icon(8,ID_MEDIUM,x,y,h, load_icon(9,ID_HARD,x,y,h, load_icon(10,ID_EXTREME,x,y,h,NULL,"ic_extreme"), "ic_hard"),"ic_medium"),"ic_easy"),NULL); cur=&((*cur)->next); y+=h; } *cur=load_icon(4,ID_LIGHT_OFF,x,y,h,NULL,"ic_gamma"); cur=&((*cur)->next); y+=h; *cur=load_icon(5,ID_VOLUME,x,y,h,NULL,"ic_volume"); cur=&((*cur)->next); y+=h; if (registered && prot) { *cur = load_icon(11,ID_NETWORKING,x,y,h,NULL,"ic_networking"); cur=&((*cur)->next); y+=h; } *cur = load_icon(2,ID_SHOW_SELL,x,y,h,NULL,"ic_sell"); cur=&((*cur)->next); y+=h; *cur = load_icon(12,ID_MACCONF,x,y,h,NULL,"ic_macconf"); cur=&((*cur)->next); y+=h; *cur = load_icon(13,ID_MACKEYS,x,y,h,NULL,"ic_mackeys"); cur=&((*cur)->next); y+=h; *cur=load_icon(6,ID_QUIT,x,y,h,NULL,"ic_quit"); cur=&((*cur)->next); y+=h; ico_button *list=append_list; if (append_list) { while (append_list->next) append_list=(ico_button *)append_list->next; append_list->next=start; } else list=start; return list; }
void show_sell(int abortable) { #if 0 void *ss=make_find_symbol("sell_screens"); if (!DEFINEDP(symbol_value(ss))) { int sp=current_space; current_space=PERM_SPACE; // char *prog="((\"art/help.spe\" . \"sell2\")(\"art/help.spe\" . \"sell4\")(\"art/help.spe\" . \"sell3\")(\"art/endgame.spe\" . \"credit\"))"; char *prog="((\"art/endgame.spe\" . \"credit\") (\"art/help.spe\" . \"sell6\"))"; set_symbol_value(ss,compile(prog)); current_space=sp; } if (DEFINEDP(symbol_value(ss))) { image blank(2,2); blank.clear(); eh->set_mouse_shape(blank.copy(),0,0); // don't show mouse ss=symbol_value(ss); int quit=0; while (ss && !quit) { int im=cash.reg_object("art/help.spe",CAR(ss),SPEC_IMAGE,1); fade_in(cash.img(im),16); event ev; do { eh->flush_screen(); eh->get_event(ev); } while (ev.type!=EV_KEY); if (ev.key==JK_ESC && abortable) quit=1; fade_out(16); ss=CDR(ss); } eh->set_mouse_shape(cash.img(c_normal)->copy(),1,1); } #else image blank(2,2); blank.clear(); eh->set_mouse_shape(blank.copy(),0,0); // don't show mouse screen->clear(); image *im; event ev; int i; im=cash.img(cash.reg("art/endgame.spe","credit",SPEC_IMAGE,1)); char *str=lstring_value(eval(make_find_symbol("thanks_text"))); int dx=(xres+1)/2-im->width()/2,dy=(yres+1)/2-im->height()/2; im->put_image(screen,dx,dy); fade_in(0,16); uchar cmap[32]; for (i=0;i<32;i++) cmap[i]=pal->find_closest(i*256/32,i*256/32,i*256/32); i = 0; int tx = 300, ty = 350, twx = 319, twy = 119; while (eh->event_waiting()) eh->get_event(ev); ev.type = EV_SPURIOUS; time_marker start; int txti = 0; do { im->put_part(screen,dx+tx,dy+ty,tx,ty,tx+twx,ty+twy); txti++; text_draw(twy+5-txti,dx+tx+15,dy+ty,dx+tx+twx-15,dy+ty+twy,str,eh->font(),cmap,eh->bright_color()); eh->flush_screen(); time_marker now; while (now.diff_time(&start)<0.10) now.get_time(); start.get_time(); while (eh->event_waiting() && ev.type!=EV_KEY) eh->get_event(ev); } while (txti<600 && ev.type!=EV_KEY && ev.type!=EV_MOUSE_BUTTON); fade_out(16); if (!abortable || !(ev.type==EV_KEY && ev.key==JK_ESC)) { im=cash.img(cash.reg("art/help.spe","sell6",SPEC_IMAGE,1)); fade_in(im,16); do { eh->flush_screen(); eh->get_event(ev); } while (ev.type!=EV_KEY && ev.type!=EV_MOUSE_BUTTON); fade_out(16); } eh->set_mouse_shape(cash.img(c_normal)->copy(),1,1); #endif }
void load_data(int argc, char **argv) { total_objects=0; total_weapons=0; weapon_types=NULL; figures=NULL; nforetiles=nbacktiles=0; foretiles=NULL; backtiles=NULL; pal=NULL; color_table=NULL; # if 0 int should_save_sd_cache = 0; char *cachepath; cachepath = (char *)malloc( strlen( get_save_filename_prefix() ) + 12 + 1 ); sprintf( cachepath, "%ssd_cache.tmp", get_save_filename_prefix() ); bFILE *load = open_file( cachepath, "rb" ); if( !load->open_failure() ) { sd_cache.load( load ); } else { should_save_sd_cache = 1; } delete load; #endif // don't let them specify a startup file we are connect elsewhere if (!net_start()) { for (int i=1; i<argc; i++) { if (!strcmp(argv[i],"-lsf")) { i++; strcpy(lsf,argv[i]); } if (!strcmp(argv[i],"-a")) { i++; snprintf(lsf, sizeof(lsf), "addon/%s/%s.lsp", argv[i], argv[i]); } } } else if (!get_remote_lsf(net_server,lsf)) { dprintf("Unable to get remote lsf from %s\n",net_server); exit(0); } char prog[100]; char const *cs; c_mouse1=cache.reg("art/dev.spe","c_mouse1",SPEC_IMAGE,0); c_mouse2=cache.reg("art/dev.spe","c_mouse2",SPEC_IMAGE,0); c_normal=cache.reg("art/dev.spe","c_normal",SPEC_IMAGE,0); c_target=cache.reg("art/dev.spe","c_target",SPEC_IMAGE,0); snprintf(prog, sizeof(prog), "(load \"%s\")\n", lsf); cs=prog; if (!LObject::Compile(cs)->Eval()) { printf("unable to open file '%s'\n",lsf); exit(0); } compiled_init(); LSpace::Tmp.Clear(); dprintf("Engine : Registering base graphics\n"); for (int z=0; z<=11; z++) { char nm[10]; snprintf(nm, sizeof(nm), "l%d", z); light_buttons[z]=cache.reg("art/dev.spe",nm,SPEC_IMAGE,0); } image *tmp_image = new image(ivec2(192, 104), fnt6x13); big_font=new JCFont(tmp_image); delete tmp_image; char const *ff; // FIXME: unnecessary duplicate call if (DEFINEDP(LSymbol::FindOrCreate("frame_file")->GetValue())) ff = lstring_value(LSymbol::FindOrCreate("frame_file")->GetValue()); else ff = "art/frame.spe"; ok_button = cache.reg(ff,"dev_ok",SPEC_IMAGE); cancel_button = cache.reg(ff,"cancel",SPEC_IMAGE); // clouds = cache.reg(ff,"clouds",SPEC_IMAGE); lower_volume= cache.reg(ff,"lower_volume",SPEC_IMAGE); raise_volume= cache.reg(ff,"raise_volume",SPEC_IMAGE); music_button= cache.reg(ff,"music",SPEC_IMAGE); sfx_button= cache.reg(ff,"sound_fx",SPEC_IMAGE); record_button= cache.reg(ff,"record",SPEC_IMAGE); play_button= cache.reg(ff,"play",SPEC_IMAGE); window_colors= cache.reg(ff,"window_colors",SPEC_IMAGE); pause_image= cache.reg(ff,"pause_image",SPEC_IMAGE); vmm_image= cache.reg(ff,"vmm",SPEC_IMAGE); border_tile= cache.reg(ff,"border_tile",SPEC_IMAGE); window_texture= cache.reg(ff,"window_texture",SPEC_IMAGE); help_screens=NULL; total_help_screens=0; if (DEFINEDP(symbol_value(l_help_screens))) { void *v=symbol_value(l_help_screens); char *ff=lstring_value(CAR(v)); v=CDR(v); total_help_screens=0; while (v) { total_help_screens++; v=CDR(v); } if (total_help_screens) { help_screens=(int *)malloc(sizeof(int)*total_help_screens); v=CDR(symbol_value(l_help_screens)); int i=0; for (; v; v=CDR(v),i++) help_screens[i]=cache.reg(ff,lstring_value(CAR(v)),SPEC_IMAGE); } else dprintf("Warning no help images following filename\n"); } int i; for (i=1; i<argc; i++) { if (!strcmp(argv[i],"-ec")) l_empty_cache->SetValue(true_symbol); if (!strcmp(argv[i],"-t")) { i++; insert_tiles(argv[i]); } } if (DEFINEDP(symbol_value(l_title_screen))) title_screen=cache.reg_object(NULL,(LObject *)symbol_value(l_title_screen),SPEC_IMAGE,1); else title_screen=-1; if (DEFINEDP(symbol_value(l_cdc_logo))) cdc_logo=cache.reg_object(NULL,(LObject *)symbol_value(l_cdc_logo),SPEC_IMAGE,1); else cdc_logo=-1; start_position_type=0xffff; for(i=0; i<total_objects; i++) if (!strcmp(object_names[i],"START")) start_position_type=i; if (start_position_type==0xffff) { printf("No object named START, cannot start game.\n"); exit(0); } sbar.load(); load_number_icons(); ERROR(nbacktiles,"No background tiles defined!"); ERROR(nforetiles,"No foreground tiles defined!"); ERROR(foretiles[0]>=0,"No black (0) foreground tile defined!"); ERROR(backtiles[0]>=0,"No black (0) background tile defined!"); ERROR(big_font_pict!=-1 || small_font_pict!=-1, "No font loaded (use load_big_font or load_small_font)!"); f_wid=cache.foret(foretiles[0])->im->Size().x; f_hi=cache.foret(foretiles[0])->im->Size().y; b_wid=cache.backt(backtiles[0])->im->Size().x; b_hi=cache.backt(backtiles[0])->im->Size().y; #if 0 if( should_save_sd_cache ) { bFILE *save = open_file( cachepath, "wb" ); if( !save->open_failure() ) { sd_cache.save( save ); } delete save; } #endif sd_cache.clear(); past_startup = 1; #if 0 free( cachepath ); #endif }
void main_menu() { image *Earth=cash.img(earth); image *Emap=cash.img(earth_mask); char name[20]; ico_button *buts[MENU_TICONS]; long maxx=0,maxy=0; int i=0; for (;i<MENU_TICONS;i++) { sprintf(name,"icon%04d.pcx",i*3+1); menu_icons[i*3]=cash.reg("art/icons.spe",name,SPEC_IMAGE,1); sprintf(name,"icon%04d.pcx",i*3+2); menu_icons[i*3+1]=cash.reg("art/icons.spe",name,SPEC_IMAGE,1); sprintf(name,"icon%04d.pcx",i*3+2); menu_icons[i*3+2]=cash.reg("art/icons.spe",name,SPEC_IMAGE,1); long x=WINDOW_FRAME_LEFT+(i%9)*cash.img(menu_icons[0])->width(); long y=WINDOW_FRAME_TOP+(i/9)*cash.img(menu_icons[0])->height(); if (x>maxx) maxx=x; if (y>maxy) maxy=y; buts[i]=new ico_button(x,y,menu_icons_ids[i], menu_icons[i*3],menu_icons[i*3], menu_icons[i*3+1],menu_icons[i*3+2],NULL); } buts[0]->next=buts[1]; int b1,b2,b3,b4; if (DEFINEDP(symbol_value)) { if (symbol_value(l_difficulty)==l_extreme) { b1=18; b2=10; b3=12; b4=14; } else if (symbol_value(l_difficulty)==l_hard) { b1=14; b2=18; b3=10; b4=12; } else if (symbol_value(l_difficulty)==l_easy) { b1=10; b2=12; b3=14; b4=18; } else { b1=12; b2=14; b3=18; b4=10; } } else { b1=12; b2=14; b3=18; b4=10; } buts[b1]->next=buts[b2]; buts[b2]->next=buts[b3]; buts[b3]->next=buts[b4]; buts[1]->next=new ico_switch_button(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*2, ID_NULL, buts[b1],buts[17]); buts[17]->next=buts[8]; buts[1]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*1); buts[12]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*2); buts[17]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*3); buts[8]->set_xy(buts[0]->X(), buts[0]->Y()+cash.img(menu_icons[0])->height()*4); ico_win=eh->new_window(-1,yres/2-80,-1,-1,buts[0],"Menu"); // pmenu *main_pm=new pmenu(0,0,game_sub,screen,eh); time_marker old_time; screen->add_dirty(0,0,319,199); // create sphere map mask_line *p=make_mask_lines(Emap,Earth->width()); int eoff=0,coff=0; event ev; // main_pm->draw(screen,eh,1); long x=84,y=60; Cell *v=find_symbol("earth_x"); if (v && DEFINEDP(v)) x=lnumber_value(symbol_value(v)); v=find_symbol("earth_y"); if (v && DEFINEDP(v)) y=lnumber_value(symbol_value(v)); int state=0,stop_menu=0; time_marker start; do { time_marker new_time; if (state || new_time.diff_time(&old_time)>0.15) { old_time.get_time(); scan_map(screen,x,y,Earth,NULL,p,Emap->height(),eoff,coff); if (state) { eoff+=8; coff+=4; } else { eoff+=2; coff+=1; } if (eoff>=320) eoff-=320; if (coff>=320) coff-=320; eh->flush_screen(); } if (eh->event_waiting()) { eh->get_event(ev); start.get_time(); // reset time till demo starts up menu_handler(ev,ico_win); if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button && ev.mouse_move.x>=x && ev.mouse_move.y>=y && ev.mouse_move.x<=x+Emap->width() && ev.mouse_move.y<=y+Emap->height()) { state=1; } else if (ev.type==EV_MOUSE_BUTTON && !ev.mouse_button) state=0; eh->flush_screen(); } if (new_time.diff_time(&start)>10) { if (!current_demo) { void *d=make_find_symbol("demos"); if (DEFINEDP(d)) current_demo=symbol_value(d); } if (current_demo) { if (set_demo_mode(DEMO_PLAY,lstring_value(CAR(current_demo)),eh)) stop_menu=1; current_demo=CDR(current_demo); } } } while (!stop_menu && (ev.type!=EV_MESSAGE || (ev.message.id!=ID_START_GAME && ev.message.id!=ID_QUIT))); for (i=0;i<MENU_TICONS;i++) { ifield *ic=ico_win->inm->unlink(menu_icons_ids[i]); if (i) delete ic; else delete buts[i]; } eh->close_window(ico_win); for (int xx=0;xx<Emap->height();xx++) jfree(p[xx].remap); jfree(p); if (ev.message.id==ID_QUIT) // propogate the quit message the_game->end_session(); // delete main_pm; }