Ejemplo n.º 1
0
void center_tbox(void *list, int c)
{
  int x1=0,y1=0,x2=79,y2=25;
  int h;

  if (item_type(list)==L_CONS_CELL)
    h=list_length(list);
  else h=1;

  int y=(y1+y2)/2-h/2+1;
  box(x1,(y1+y2)/2-h/2,x2,(y1+y2)/2-h/2+h+1,c);
  bar(x1+1,y,x2-1,(y1+y2)/2-h/2+h+1-1,' ',c);

  if (item_type(list)==L_CONS_CELL)
  {
    while (list)
    {
      char *s=lstring_value(CAR(list));
      put_string((x1+x2)/2-strlen(s)/2,y++,s,c);
      list=CDR(list);
    }
  } else 
  {
    char *s=lstring_value(list);
    put_string((x1+x2)/2-strlen(s)/2,y++,s,c);
  }
}
Ejemplo n.º 2
0
int CacheList::reg_object(char const *filename, LObject *object, int type,
		int rm_dups) {
	// See if we got a object with a filename included. Otherwise,
	// it's a string.
	if (item_type(object) == L_CONS_CELL) {
		filename = lstring_value(lcar(object));
		object = lcdr(object);
	}

	return reg(filename, lstring_value(object), type, rm_dups);
}
Ejemplo n.º 3
0
void status_bar::load()
{
  char sbname[100];
  char iname[20];
  void *l_name = LSymbol::FindOrCreate("sbar_file");
  if (symbol_value(l_name)!=l_undefined)
    strcpy(sbname,lstring_value(symbol_value(l_name)));
  else strcpy(sbname,"art/statbar.spe");

  int i;
  for (i=0; i<TOTAL_WEAPONS; i++)
  {
    sprintf(iname,"bweap%04d.pcx",i+1);
    bweap[i]=cache.reg(sbname,iname,SPEC_IMAGE);

    sprintf(iname,"dweap%04d.pcx",i+1);
    dweap[i]=cache.reg(sbname,iname,SPEC_IMAGE);
  }

  for (i=0; i<30; i++)
  {
    sprintf(iname,"bnum%02d",i);
    bnum[i]=cache.reg(sbname,iname,SPEC_IMAGE);
  }


  sbar=cache.reg(sbname,"sbar",SPEC_IMAGE);
  sbar_select=cache.reg(sbname,"sbar_select",SPEC_IMAGE);
  sbar_numpad=cache.reg(sbname,"sbar_numpad",SPEC_IMAGE);
}
Ejemplo n.º 4
0
static char const *lang_string(char const *symbol)
{
    LSymbol *v = LSymbol::Find(symbol);
    if (!v || !DEFINEDP(v->GetValue()))
        return "Language symbol missing!";
    return lstring_value(v->GetValue());
}
Ejemplo n.º 5
0
char *men_str(void *arg)
{
  switch (item_type(arg))
  {
    case L_STRING : 
    { return lstring_value(arg); } break;
    case L_CONS_CELL : 
    { return lstring_value(CAR(arg)); } break;
    default : 
    {
      lprint(arg);
      dprintf(" is not a valid menu option\n");
      exit(0);
    }
  }
  return NULL;
}
Ejemplo n.º 6
0
void *show_yes_no(void *t, void *msg, void *y, void *n)
{
  p_ref r1(t),r2(msg),r3(y),r4(n);
  t=eval(t); msg=eval(msg); y=eval(y); n=eval(n);
  int c;
  char *yes=lstring_value(y);
  char *no=lstring_value(n);
  do
  {
    dprintf("\n\n\n\n\n%s\n\n",lstring_value(t));
    void *v=msg;
    if (item_type(v)==L_CONS_CELL)
      while (v) { dprintf("** %s\n",lstring_value(CAR(v))); v=CDR(v); }
    else dprintf("** %s\n",lstring_value(v));
    char msg[100];
    fgets(msg,100,stdin);
    c=msg[0];
  } while (toupper(c)!=toupper(yes[0]) && toupper(c)!=toupper(no[0]));
  if (toupper(c)==toupper(yes[0]))
    return true_symbol;
  else return NULL;
}
Ejemplo n.º 7
0
void *nice_menu(void *main_title, void *menu_title, void *list)
{
  p_ref r1(main_title),r2(menu_title),r3(list);
  main_title=eval(main_title);  menu_title=eval(menu_title);  list=eval(list);
  char msg[100];
  int i=0,d;
  do
  {
    dprintf("\n\n\n\n\n%s\n\n%s\n-----------------------------------\n",
	   lstring_value(main_title),lstring_value(menu_title));

    void *v=list;
    for (;v;v=CDR(v),i++)
    {
      dprintf("%d) %s\n",i+1,lstring_value(CAR(v)));
    }
    dprintf("> ");
    fgets(msg,100,stdin);
    sscanf(msg,"%d",&d);
  } while (d-1>=i && d<=0);
  return new_lisp_number(d-1);
}
Ejemplo n.º 8
0
void *show_yes_no(void *t, void *msg, void *y, void *n)
{
  p_ref r1(t),r2(msg),r3(y),r4(n);
  y=eval(y);
  n=eval(n);
  put_title(lstring_value(eval(t)));

  int x1=0,y1=0,x2=79,y2=25;
  bar(x1,y1+1,x2,y2,176,0x01);  
  center_tbox(eval(msg),0x1f);
  int key;
  char *yes=lstring_value(y);
  char *no=lstring_value(n);
  set_cursor(0,25);
  do
  {
    key=getch();
    set_cursor(0,0);
  } while (toupper(key)!=toupper(yes[0]) && toupper(key)!=toupper(no[0]));
  cls();
  if (toupper(key)==toupper(yes[0]))
    return true_symbol;
  else return NULL;
}
Ejemplo n.º 9
0
long c_caller(long number, void *arg)  // exten c function switches on number
{
  switch (number)
  {
    case 0 : 
    {
      char cd[100];
      getcwd(cd,100);
      int t=change_dir(lstring_value(CAR(arg)));
      change_dir(cd);
      return t;
    } break;    
    case 1 :
    {
      if (change_dir(lstring_value(eval(CAR(arg)))))
        return 1;
      else return 0;
    } break; 
    case 2 :
    {
      return K_avail(lstring_value(CAR(arg)));
    } break;
    case 3 :
    {
      void *title=eval(CAR(arg)); arg=CDR(arg);   p_ref r1(title);
      void *source=eval(CAR(arg)); arg=CDR(arg);  p_ref r2(source);
      void *dest=eval(CAR(arg)); arg=CDR(arg);    p_ref r3(dest);

      return nice_copy(lstring_value(title),lstring_value(source),lstring_value(dest));
    } break;
    case 4 :
    {
      if (access(lstring_value(eval(CAR(arg))),R_OK)==0)
        return 1;
      else
        return 0;
    } break;
  }
  return 0;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
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
}
Ejemplo n.º 12
0
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();
}
Ejemplo n.º 13
0
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
}
Ejemplo n.º 14
0
int menu(void *args, JCFont *font)             // reurns -1 on esc
{
  main_menu();
  char *title=NULL;
  if (!NILP(CAR(args)))
    title=lstring_value(CAR(args));
  Cell *def=lcar(lcdr(lcdr(args)));
  args=CAR(CDR(args));

  int options=list_length(args);
  int mh=(font->height()+1)*options+10,maxw=0;

  Cell *c=(Cell *)args;
  for (;!NILP(c);c=CDR(c))
  {
    if (strlen(men_str(CAR(c)))>maxw)
      maxw=strlen(men_str(CAR(c)));
  }
  
  int mw=(font->width())*maxw+20;
  int mx=screen->width()/2-mw/2,
      my=screen->height()/2-mh/2;
  

  screen->add_dirty(mx,my,mx+mw-1,my+mh-1);

  if (title)
  {
    int tl=strlen(title)*font->width();
    int tx=screen->width()/2-tl/2;
    dark_wiget(tx-2,my-font->height()-4,tx+tl+2,my-2,eh->medium_color(),eh->dark_color(),180);
    font->put_string(screen,tx+1,my-font->height()-2,title,eh->bright_color());
  }
  
  dark_wiget(mx,my,mx+mw-1,my+mh-1,eh->medium_color(),eh->dark_color(),200);


  int y=my+5;
  for (c=(Cell *)args;!NILP(c);c=CDR(c))
  {
    char *ms=men_str(CAR(c));
    font->put_string(screen,mx+10+1,y+1,ms,eh->black());
    font->put_string(screen,mx+10,y,ms,eh->bright_color());
    y+=font->height()+1;
  }
  

  eh->flush_screen();
  event ev;
  int choice=0,done=0;
  int bh=font->height()+3;
  image *save=new image(mw-2,bh);
  int color=128,cdir=50;
  
  time_marker *last_color_time=NULL; 
  if (!NILP(def))
    choice=lnumber_value(def);
  do
  {
    eh->flush_screen();
    if (eh->event_waiting())
    {
      eh->get_event(ev);
      if (ev.type==EV_KEY)
      {
				switch (ev.key)
				{
				  case JK_ESC : 
				  { choice=-1; done=1; } break;
				  case JK_ENTER :
				  { done=1; } break;
				  case JK_DOWN : 
				  { if (choice<options-1) 
				    choice++;
				  else choice=0;
				  } break;
				  case JK_UP :
				  {
				    if (choice>0)
				    choice--;
				    else choice=options-1;
				  } break;		      
				}
      } else if (ev.type==EV_MOUSE_BUTTON && ev.mouse_button)
      {
				if (ev.mouse_move.x>mx && ev.mouse_move.x<mx+mw && ev.mouse_move.y>my &&
				    ev.mouse_move.y<my+mh)
				{
				  int msel=(ev.mouse_move.y-my)/(font->height()+1);
				  if (msel>=options) msel=options-1;
				  if (msel==choice)                    // clicked on already selected item, return it
				    done=1;
				  else choice=msel;                    // selects an item
				}
      }
    }

    time_marker cur_time;
    if (!last_color_time || (int)(cur_time.diff_time(last_color_time)*1000)>120)
    {       
      if (last_color_time)
        delete last_color_time;
      last_color_time=new time_marker;

      int by1=(font->height()+1)*choice+my+5-2;
      int by2=by1+bh-1;

      screen->put_part(save,0,0,mx+1,by1,mx+mw-2,by2);
      tint_area(mx+1,by1,mx+mw-2,by2,63,63,63,color);

      char *cur=men_str(nth(choice,args));
      font->put_string(screen,mx+10+1,by1+3,cur,eh->black());
      font->put_string(screen,mx+10,by1+2,cur,eh->bright_color());
      screen->rectangle(mx+1,by1,mx+mw-2,by2,eh->bright_color());

      color+=cdir;

      if (color<12 || color>256)
      {
				cdir=-cdir;
				color+=cdir;
      }
      eh->flush_screen();
      save->put_image(screen,mx+1,by1);
    } else milli_wait(10);

  } while (!done);
  if (last_color_time)
    delete last_color_time;
  delete save;
  the_game->draw(the_game->state==SCENE_STATE);

  if (choice!=-1)
  {
    void *val=nth(choice,args);
    if (item_type(val)==L_CONS_CELL)   // is there another value that the user want us to return?
      return lnumber_value(lcdr(val));  
  }
  return choice;
}
Ejemplo n.º 15
0
void *l_caller(long number, void *arg) 
{
  p_ref r1(arg);
  void *ret=NULL;
  switch (number)
  {
    case 0 :
    { system(lstring_value(eval(CAR(arg)))); } break;
    case 1 :
    {
      void *fn=eval(CAR(arg));  arg=CDR(arg);
      p_ref r1(fn);
      char *current_dir=lstring_value(eval(CAR(arg)));
      char *filename=lstring_value(fn);

      char *last=NULL,*s=filename,*dp;
      char dir[200],name[200];
      while (*s) { if (*s=='\\' || *s=='/') last=s+1; s++; }
      if (last)
      {
	for (dp=dir,s=filename;s!=last;dp++,s++) { *dp=*s; }
	*dp=0;
	strcpy(name,last);
      } else
      {
	strcpy(dir,current_dir);
	strcpy(name,filename);
      }
      void *cs=(void *)new_cons_cell();
      p_ref r24(cs);
      ((cons_cell *)cs)->car=new_lisp_string(dir);
      ((cons_cell *)cs)->cdr=new_lisp_string(name);
      ret=cs;
    } break;
    case 2 :
    {
      void *fn=eval(CAR(arg)); arg=CDR(arg);
      p_ref r1(fn);
      char *slash=lstring_value(eval(CAR(arg)));
      char *filename=lstring_value(fn);

      char tmp[200],*s=filename,*tp;
      
      for (tp=tmp;*s;s++,tp++)
      {
	if (*s=='/' || *s=='\\') 
	{
	  *tp=*slash;
//	  if (*slash=='\\') 
//	  { tp++; *tp='\\'; }
	}
	else *tp=*s;
      }
      *tp=0;
      ret=new_lisp_string(tmp);
    } break;
    case 3 :
    {
      char cd[100];
      getcwd(cd,100);

      char name_so_far[100];
      char *dir=lstring_value(eval(CAR(arg)));
      char *d,ch;
      d=dir;
      int err=0;
      while (*d && !err)
      {
	if ((*d=='\\' || *d=='/') && d!=dir && *(d-1)!=':')
	{
	  ch=*d;
	  *d=0;
	  if (!change_dir(dir))
	    if (make_dir(dir)!=0)
	      err=1;

	  *d=ch;
	  
	}
	d++;
      }
      change_dir(cd);

      if (err)
        ret=NULL;
      else ret=true_symbol;
    } break;
    case 4 :
    {
      char *fn=lstring_value(eval(CAR(arg)));
      char *l=NULL,*s=fn;
      while (*s) { if (*s=='.') l=s; s++; }
      if (l) ret=new_lisp_string(l);
      else ret=new_lisp_string("");
    } break;
    case 5 :
    {
      void *tit=eval(CAR(arg));  arg=CDR(arg);
      p_ref r1(tit);
      void *prompt=eval(CAR(arg));  arg=CDR(arg);
      p_ref r2(prompt);
      void *def=eval(CAR(arg));  arg=CDR(arg);
      p_ref r3(def);

      return nice_input(lstring_value(tit),lstring_value(prompt),lstring_value(def));
    } break;
    case 6 :
    {
      return nice_menu(CAR(arg),CAR(CDR(arg)),CAR(CDR(CDR(arg))));
    } break;
    case 7 :
    {
      return show_yes_no(CAR(arg),CAR(CDR(arg)),CAR(CDR(CDR(arg))),CAR(CDR(CDR(CDR(arg)))));
    } break;
    case 8 :
    {
      char cd[150];
      getcwd(cd,100);
      return new_lisp_string(cd);
    } break;
    case 9 :
    {
      return new_lisp_string(getenv(lstring_value(eval(CAR(arg)))));
    } break;
    case 10 :
    {
      char str[200];
      strcpy(str,lstring_value(eval(CAR(arg))));
      modify_install_path(str);
      return new_lisp_string(str);
    } break;
  }
  return ret;
}
Ejemplo n.º 16
0
void *nice_menu(void *main_title, void *menu_title, void *list)
{
  int x1=0,y1=0,x2=79,y2=25;

  p_ref r1(main_title),r2(menu_title),r3(list);
  main_title=eval(main_title);
  menu_title=eval(menu_title);
  char *t=lstring_value(main_title);
  put_title(t);

  bar(x1,y1+1,x2,y2,176,0x01);

  void *l=eval(list);
  p_ref r4(l);
  int menu_height=list_length(l),menu_length=0;
  void *m;
  for (m=l;m;m=CDR(m))
  { long l=strlen(lstring_value(CAR(m)));
    if (l>menu_length) menu_length=l;
  }

  char *mt=lstring_value(menu_title);
  if (strlen(mt)>menu_length) menu_length=strlen(mt);

  int mx=(x2+x1)/2-menu_length/2-1,my=(y2+y1)/2-menu_height/2-2;
  box(mx,my,mx+menu_length+2,my+menu_height+3,0x17);
  bar(mx+1,my+1,mx+menu_length+1,my+menu_height+2,' ',0x17);
  put_string(mx+1+menu_length/2-strlen(mt)/2,my,mt,0x1f);       // draw menu title
  set_cursor(0,25);

  int cur_sel=0;
  int key;
  do
  {
    int y=0;
    for (m=l;m;m=CDR(m),y++)
    {
      char *s=lstring_value(CAR(m));
      if (y==cur_sel)
      {
	bar(mx+1,my+2+y,mx+1+menu_length,my+2+y,' ',0x0f);
	put_string(mx+1+menu_length/2-strlen(s)/2,my+2+y,s,0x0f);
      }
      else
      {
	bar(mx+1,my+2+y,mx+1+menu_length,my+2+y,' ',0x1f);
	put_string(mx+1+menu_length/2-strlen(s)/2,my+2+y,s,0x1f);
      }
    }

    key=_bios_keybrd(_KEYBRD_READ);

    if (key==18432) 
    { cur_sel--; if (cur_sel==-1) cur_sel=menu_height-1; }
    if (key==20480)
    { cur_sel++; if (cur_sel==menu_height) cur_sel=0; }

  } while (key!=283 && key!=7181);
  cls();
  if (key==283) 
    return new_lisp_number(-1);

  return new_lisp_number(cur_sel);
}
Ejemplo n.º 17
0
void load_tiles(Cell *file_list)
{
  bFILE *fp;
  spec_directory *sd;
  spec_entry *spe;


  int num;



  Cell *fl;
  int old_fsize=nforetiles,
      old_bsize=nbacktiles;

  for (fl=file_list; !NILP(fl); fl=lcdr(fl))
  {
    fp=open_file(lstring_value(lcar(fl)),"rb");
    if (fp->open_failure())
    {
      printf("Warning : open %s for reading\n",lstring_value(lcar(fl)));
      delete fp;
    }
    else
    {
      sd=new spec_directory(fp);
      delete fp;
      int i;
      for (i=0; i<sd->total; i++)
      {
    spe=sd->entries[i];
        switch (spe->type)
        {
          case SPEC_BACKTILE :
            if (!sscanf(spe->name,"%d",&num))
              printf("Warning : background tile %s has no number\n",spe->name);
            else if (nbacktiles<=num) nbacktiles=num+1;
          break;

          case SPEC_FORETILE :
            if (!sscanf(spe->name,"%d",&num))
              printf("Warning : foreground tile %s has no number\n",spe->name);
            else if (nforetiles<=num) nforetiles=num+1;
          break;
        }
      }
      delete sd;
    }
  }

  // enlarge the arrays if needed.
  if (nbacktiles>old_bsize)
  {
    backtiles=(int *)realloc(backtiles,sizeof(int)*nbacktiles);
    memset(backtiles+old_bsize,-1,(nbacktiles-old_bsize)*sizeof(int));
  }

  if (nforetiles>old_fsize)
  {
    foretiles=(int *)realloc(foretiles,sizeof(int)*nforetiles);
    memset(foretiles+old_fsize,-1,(nforetiles-old_fsize)*sizeof(int));
  }


// now load them up
  for (fl=file_list; !NILP(fl); fl=lcdr(fl))
  {
    char const *fn=lstring_value(lcar(fl));
    fp=open_file(fn,"rb");
    if (!fp->open_failure())
    {
      sd=new spec_directory(fp);
      delete fp;

      int i;
      for (i=0; i<sd->total; i++)
      {
    spe=sd->entries[i];
        switch (spe->type)
        {
          case SPEC_BACKTILE :

            if (sscanf(spe->name,"%d",&num))
        {
          if (backtiles[num]>=0)
          {
        dprintf("Warning : background tile %d redefined\n",num);
        cache.unreg(backtiles[num]);
          }
          backtiles[num]=cache.reg(fn,spe->name,SPEC_BACKTILE);
        }
            break;
          case SPEC_FORETILE :
            if (sscanf(spe->name,"%d",&num))
        {
          if (foretiles[num]>=0)
          {
        dprintf("Warning : foreground tile %d redefined\n",num);
        cache.unreg(foretiles[num]);
          }
          foretiles[num]=cache.reg(fn,spe->name,SPEC_FORETILE);
        }
            break;
        }
      }
      delete sd;
    } else delete fp;
  }

}