⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gui.c

📁 著名ARC模拟器源码,包括多个平台
💻 C
📖 第 1 页 / 共 5 页
字号:
// Get joy ID for joy numberint joystick_id(int index){   int tb;   tb = (sizeof(joystick_data) / sizeof(GUI_JOY));   if((index>=0)&&(index<tb)){      return joystick_data[index].id;   }   return joystick_data[1].id;		// None}void DoJoyEdit(void){   int ta,tb;   char *msg;   ta = joystick_id(joy_select[1].d1);   remove_joystick();   JoystickType = JOY_TYPE_NONE;   switch(ta){   case JOY_TYPE_NONE:      JoystickType=JOY_TYPE_NONE;      return;   break;   default:		// Allegro     show_mouse(NULL);   if(install_joystick(ta)){       show_mouse(screen);      raine_alert(raine_translate_text("Control Error"),raine_translate_text("Unable to initialise Joystick"),allegro_error,NULL,raine_translate_text("&Okay"),NULL,'O',0);      JoystickType=JOY_TYPE_NONE;      return;   }   if(!(num_joysticks)){       show_mouse(screen);      raine_alert(raine_translate_text("Control Error"),raine_translate_text("No Joysticks of type"),joy_name(ta),raine_translate_text("could be detected"),raine_translate_text("&Okay"),NULL,'O',0);      JoystickType=JOY_TYPE_NONE;      return;   }   for(tb=0; tb<num_joysticks; tb++){   while(joy[tb].flags & JOYFLAG_CALIBRATE){      msg=((char*)calibrate_joystick_name(tb));	show_mouse(screen);      raine_alert(raine_translate_text("Control Setup"),raine_translate_text("Joystick Calibration:"),msg,raine_translate_text("and press space..."),raine_translate_text("Space"),NULL,' ',0);	show_mouse(NULL);      if(calibrate_joystick(tb)){         show_mouse(screen);         raine_alert(raine_translate_text("Control Error"),NULL,raine_translate_text("Joystick Calibration error"),NULL,raine_translate_text("&Okay"),NULL,'O',0);         JoystickType=JOY_TYPE_NONE;         return;      }   }   }     show_mouse(screen);   JoystickType=ta;   return;   break;   }}int joy_edit_proc(int msg, DIALOG *d, int c){   int ret = x_raine_button_proc(msg, d, c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      DoJoyEdit();      ret = D_REDRAW;   }   return ret;}int joy_calib_proc(int msg, DIALOG *d, int c){   int ret = x_raine_button_proc(msg,d,c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      ret=0;      while((ret!=2)&&(ret!=-1)){         joy_select[1].d1 = joystick_number(JoystickType);         ret=raine_do_dialog(joy_select,-1);         if((ret!=2)&&(ret!=-1)){            FadeGUI();            DoJoyEdit();         }      }      ret = D_REDRAW;   }   return ret;}int game_reset_proc(int msg, DIALOG *d, int c){   int ret = x_raine_button_proc(msg, d, c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      reset_game_hardware();      ret = D_REDRAW;   }   return ret;}void DoLangEdit(void){   int ta;   ta=language_dialog[1].d1;   if(ta<LanguageSw.Count){      SetLanguageSwitch(ta);      sprintf(langname,"%s",LanguageSw.Mode[ta]);   }}// language_getter():// Get mode names for langauge/version select listchar *language_getter(int index, int *list_size){   switch(index){   case -1:      *list_size=LanguageSw.Count;      return NULL;   break;   case -2:			// Act upon List Object Selection      DoLangEdit();      *list_size=D_REDRAW;      return NULL;   break;   case -3:			// Act Keyboard Input      return NULL;   break;   default:      if((index >= 0)&&(index<LanguageSw.Count))         return LanguageSw.Mode[index];      else         return NULL;   break;   }}int language_proc(int msg, DIALOG *d, int c){   int ret=x_raine_button_proc(msg,d,c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      ret=GetLanguageSwitch();      if(LanguageSw.Count){         sprintf(langname,"%s",LanguageSw.Mode[ret]);         language_dialog[1].d1=ret;      }      else{         sprintf(langname,raine_translate_text("<No language switches>"));      }      ret=0;      while((ret!=2)&&(ret!=-1)){         ret = raine_do_dialog(language_dialog,-1);         if((ret!=2)&&(ret!=-1)){            DoLangEdit();         }      }      return D_REDRAW;   }   return ret;}int language_sel_proc(int msg, DIALOG *d, int c){   int ret=x_raine_button_proc(msg,d,c);   if(ret==D_CLOSE){      DoLangEdit();      return D_REDRAW;   }   return ret;}// game_setup_proc():// Does game setup options dialogint game_setup_proc(int msg, DIALOG *d, int c){   int ret=x_raine_button_proc(msg,d,c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      ret=0;      while((ret!=2)&&(ret!=-1)){         ret = raine_do_dialog(game_setup_dialog,-1);      }      return D_REDRAW;   }   return ret;}// control_setup_proc():// Does game setup options dialogint control_setup_proc(int msg, DIALOG *d, int c){   int ret=x_raine_button_proc(msg,d,c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      ret=0;      while((ret!=2)&&(ret!=-1)){         ret=raine_do_dialog(control_setup_dialog,-1);      }      return D_REDRAW;   }   return ret;}// raine_quit_proc():// Process a click on 'quit raine' buttonint raine_quit_proc(int msg, DIALOG *d, int c){   int ret=x_raine_button_proc(msg, d, c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      if((raine_alert(raine_translate_text("Warning"),NULL,raine_translate_text("Quit Raine?"),NULL,raine_translate_text("&Yes"),raine_translate_text("&No"),'Y','N'))!=1){         return D_REDRAW;      }      else{         WantQuit=1;         return D_EXIT;      }   }   return ret;}// game_play_proc():// Process a click on 'play game' buttonint game_play_proc(int msg, DIALOG *d, int c){   int ret = x_raine_button_proc(msg, d, c);   if(ret==D_CLOSE){      Unselect_Button(d);      FadeGUI();      if(!current_game){         raine_alert(raine_translate_text("Error"),raine_translate_text("No Game Loaded"),raine_translate_text("Click on Change Game"),raine_translate_text("to Select a Game."),raine_translate_text("&Okay"),NULL,'O',0);         ret = D_REDRAW;      }      else{         WantPlay = 1;         ret = D_EXIT;      }   }   return ret;}// real primitive pen allocationstatic int used_pens;int allocate_pens(int pens){   int ret;   if((used_pens+pens)<=256){      ret = used_pens;      used_pens += pens;   }   else{      ret = -1;   }   return ret;}void free_pens(int pens){   if((used_pens-pens)>=0){      used_pens -= pens;   }}void free_all_pens(void){   used_pens = 0;}// MakeGUIBack():// Make a faded copy of the game screen to go behind the gui.void MakeGUIBack(void){   BITMAP *gui_backdrop = NULL;   static BITMAP *backdrop = NULL;   static PALETTE backdrop_pal;   PALETTE new_pal;   UINT8 *BIT;   UINT8 mapcol[256];   int ccnt,ta,tb,tc,td,te,tcr,tcg,tcb;      if(screen_valid){          if (display_cfg.bpp == 8) {       gui_backdrop = create_bitmap_ex(display_cfg.bpp, display_cfg.screen_x, display_cfg.screen_y);              free_all_pens();              memset(new_pal,0x00, 256*4);       memset(mapcol, 0xFF, 256);              ccnt=1;	// Black=Colour0       blit(screen,gui_backdrop,0,0,0,0,display_cfg.screen_x, display_cfg.screen_y);       for(tb=0;tb<display_cfg.screen_y;tb++){	 BIT=gui_backdrop->line[tb];	 for(ta=0;ta<display_cfg.screen_x;ta++){	   tc=BIT[ta];	   if((te=mapcol[tc])==255){	     tcr=pal[tc].r;	     tcg=pal[tc].g;	     tcb=pal[tc].b;	     tcr = (tcr * 64) / 96;	     if(tcr<0) tcr=0;	     if(tcr>63) tcr=63;	     tcg = (tcg * 64) / 80;	     if(tcg<0) tcg=0;	     if(tcg>63) tcg=63;	     tcb = (tcb * 64) / 64;	     if(tcb<0) tcb=0;	     if(tcb>63) tcb=63;	     te=255;	     for(td=0;td<ccnt;td++){	       if((tcr==new_pal[td].r)&&(tcg==new_pal[td].g)&&(tcb==new_pal[td].b)){		 te=td;		 td=ccnt;		 mapcol[tc]=te;	       }	     }	     if(te==255){	       if(ccnt<216){		 new_pal[ccnt].r=tcr;		 new_pal[ccnt].g=tcg;		 new_pal[ccnt].b=tcb;		 te=ccnt;		 ccnt++;	       }	       else{			// No room! Find a close match... (allegro: slow)		 te=bestfit_color(new_pal,tcr,tcg,tcb);	       }	     }	   }	   BIT[ta]=te;	 }       }       memcpy(&gui_pal, &new_pal, ccnt*4);       allocate_pens(ccnt);     }        }   else{     // The backdrop image has historically always been 8bpp...     // For now it's better to keep it this way...     gui_backdrop = create_bitmap_ex(8, display_cfg.screen_x, display_cfg.screen_y);     free_all_pens();     memset(new_pal,0x00, 256*4);     memset(mapcol, 0xFF, 256);     ccnt=1;	// Black=Colour0     if(!backdrop){       if(rgui_cfg.bg_image[0])	 backdrop = load_pcx(rgui_cfg.bg_image, backdrop_pal);       if(!backdrop){	 	 backdrop = RaineData[Backdrop].dat;	 memcpy(&backdrop_pal, RaineData[Backdrop_pal].dat, 256*4);       }            }     clear_to_color(gui_backdrop,getpixel(backdrop,0,0));     blit(backdrop,gui_backdrop,0,0,(display_cfg.screen_x - backdrop->w)/2,(display_cfg.screen_y - backdrop->h)/2,backdrop->w,backdrop->h);     for(tb=0;tb<display_cfg.screen_y;tb++){      BIT=gui_backdrop->line[tb];      for(ta=0;ta<display_cfg.screen_x;ta++){      tc=BIT[ta];      if((te=mapcol[tc])==255){         tcr=backdrop_pal[tc].r;         tcg=backdrop_pal[tc].g;         tcb=backdrop_pal[tc].b;         te=255;         for(td=0;td<ccnt;td++){            if((tcr==new_pal[td].r)&&(tcg==new_pal[td].g)&&(tcb==new_pal[td].b)){               te=td;               td=ccnt;               mapcol[tc]=te;            }         }         if(te==255){            if(ccnt<216){               new_pal[ccnt].r=tcr;               new_pal[ccnt].g=tcg;               new_pal[ccnt].b=tcb;               te=ccnt;               ccnt++;            }            else{			// No room! Find a close match... (allegro: slow)               te=bestfit_color(new_pal,tcr,tcg,tcb);            }         }      }      BIT[ta]=te;      }      }      memcpy(&gui_pal, &new_pal, ccnt*4);      allocate_pens(ccnt);   }   set_palette_range(gui_pal,0,255,1);   if (gui_backdrop) {     blit(gui_backdrop,screen,0,0,0,0,display_cfg.screen_x,display_cfg.screen_y);     destroy_bitmap(gui_backdrop);     gui_backdrop = NULL;   }   if(raine_cfg.hide)   {      clear(screen);   }}#include "shiftjis.c"// StartGUI():// Actually does the gui/game loop, called from raine.c// Caters for command line load and no gui optionsint StartGUI(void){   char str[256];   #ifdef RAINE_DEBUG   print_debug("StartGUI(): START\n");#endif      SpriteGun1        = RaineData[Gun1].dat;   SpriteGun2        = RaineData[Gun2].dat;   sprintf(str, "%sconfig/language/%s", dir_cfg.exe_path, dir_cfg.language_file);   raine_push_config_state();   raine_set_config_file(str);   if(new_set_gfx_mode(display_cfg.screen_type,display_cfg.screen_x,display_cfg.screen_y,display_cfg.scanlines)!=0){     if(new_set_gfx_mode(GFX_AUTODETECT,320,240,0)){        printf("%s\n",raine_translate_text("Unable to detect any screenmode."));#ifdef RAINE_UNIX	 printf("%s\n",raine_translate_text("On the console, you need to be root to use svgalib (or modex) !"));#else												 	 printf("%s\n",raine_translate_text("Get Display Doctor from www.scitechsoft.com to fix this."));#endif				          printf("%s\n\n",raine_translate_text("Mail about this problem is not appreciated!"));         exit(1);      }      else{         display_cfg.screen_type= GFX_AUTODETECT;         display_cfg.screen_x   = 320;         display_cfg.screen_y   = 240;         display_cfg.scanlines  = 0;      }   }   sprintf(gamename, "%s %s", raine_translate_text("Game:"), raine_translate_text("<No Game Loaded>"));   sprintf(screenname,  raine_translate_text("%s %dx%d %dbpp; %s"), raine_translate_text("Screen:"), display_cfg.screen_x, display_cfg.screen_y, display_cfg.bpp, gfx_card_name(display_cfg.screen_type));   set_sound_variables(0);   memset(&gui_pal, 0x00, 256*4);   WantScreen=0;   WantQuit=0;   WantPlay=0;#ifdef RAINE_DEBUG   print_debug("StartGUI(): prepare international\n");#endif   register_uformat(U_SJIS, sjis_getc, sjis_getx, sjis_setc, sjis_width, sjis_cwidth, sjis_isok, 2);   set_uformat(U_SJIS);   while(!WantQuit){		// ----- Main Loop ------     set_gui_palette();     gui_fg_color = CGUI_COL_TEXT_1;     gui_bg_color = CGUI_BOX_COL_MIDDLE;     /* Be carefull here. Windows seems to have very unstable threads. You */  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -