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

📄 gui.c

📁 著名ARC模拟器源码,包括多个平台
💻 C
📖 第 1 页 / 共 5 页
字号:
   return 0;}void build_game_avail_list(void){   int ta,oldcount;   build_game_list();   if(GameAvail) free_game_avail_list();   oldcount = my_game_count;   if (!my_game_count) my_game_count = 1; // To avoid the segfault with efence   // when there are no games at all !!!      GameAvail   = (int *) malloc(sizeof(int) * my_game_count);   GameMissing = (int *) malloc(sizeof(int) * my_game_count);   my_game_count=oldcount;      GameAvailCount = 0;   GameMissingCount = 0;   for(ta=0; ta<my_game_count; ta++){      if( game_exists(ta) )         GameAvail[GameAvailCount++] = ta;      else         GameMissing[GameMissingCount++] = ta;   }   ta = rgui_cfg.game_list_mode;   rgui_cfg.game_list_mode = 0;   game_select[GAME_LIST].d1 = raine_cfg.req_game_index;   set_game_list_mode(ta);}void free_game_avail_list(void){   if(GameAvail) free(GameAvail);   GameAvail = NULL;   if(GameMissing) free(GameMissing);   GameMissing = NULL;}// listbox_getter():// Get game names for game select list, three// different listing modes.char *get_long_name(GAME_MAIN *game){#if 0	int len;#endif    return game->long_name;  // The rest of this function was to add a "S" for sound at the end...#if 0  strncpy(name_buffer,game->long_name,BOARD_POS);  len = strlen(name_buffer);  if (len < BOARD_POS) {    memset(&name_buffer[len],32,BOARD_POS-len);    name_buffer[BOARD_POS] = 0;  }  if (game->sound_list) {    strncat(name_buffer,"S",MAX_NAME_BUFFER-BOARD_POS);  }  name_buffer[MAX_NAME_BUFFER-1] = 0;  return name_buffer;#endif}static int get_normal_index(int index){  return index;}static int get_avail_index(int index){  return GameAvail[index];}static int get_missing_index(int index){  return GameMissing[index];}static char* pad(char* s,int len){  int len0=strlen(s);  strcpy(pad_buf,s);  if (len>len0)    memset(&pad_buf[len0],0x20,len-len0);  pad_buf[len] = 0;  return pad_buf;}static char* ipad(int n, int len){  char buff[10];  sprintf(buff,"%d",n);  return pad(buff,len);}static char* game_type_name(int type,int len){  char buff[50];  int ta;  buff[0]=0;  for (ta=0; ta<=7; ta++)    if (type & (1 << ta)){      sprintf(buff+strlen(buff),"%s ",game_type[ta+1]);      break;    }  return pad(buff,len);}static void setup_game_bitmap() {  int new_scale,hx,hy,vx,vy;  game_select[GAME_BITMAP].dp   = snapshot;  new_scale = text_height(gui_main_font);  hx = 130 * new_scale / 8;  hy = 76 * new_scale / 8;  vx = 70 * new_scale / 8;  vy = 120 * new_scale / 8;  if (snapshot->w > snapshot->h) { // horizontal    game_select[GAME_BITMAP].x = ((game_select[0].x+150)*new_scale)/8;    game_select[GAME_BITMAP].y = ((game_select[0].y+145)*new_scale)/8+5;    game_select[GAME_BITMAP].w    = (snapshot->w < hx ? snapshot->w : hx);    game_select[GAME_BITMAP].h    = (snapshot->h < hy ? snapshot->h : hy);  } else { // vertical    game_select[GAME_BITMAP].x = ((game_select[0].x + 235)*new_scale)/8;    game_select[GAME_BITMAP].y = ((game_select[0].y + 100)*new_scale)/8+5;    game_select[GAME_BITMAP].w    = (snapshot->w < vx ? snapshot->w : vx);    game_select[GAME_BITMAP].h    = (snapshot->h < vy ? snapshot->h : vy);  }}void destroy_snapshot(int redraw) {  if (redraw) // stupid allegro...    rectfill(screen, game_select[GAME_BITMAP].x, game_select[GAME_BITMAP].y, game_select[GAME_BITMAP].x+game_select[GAME_BITMAP].w-1, game_select[GAME_BITMAP].y+game_select[GAME_BITMAP].h-1, CGUI_BOX_COL_MIDDLE);  destroy_mapped_bitmap(snapshot,snapshot_cols);  snapshot = NULL;}static BITMAP* load_snapshot(char *name) {  char str[256];  BITMAP *snapshot;  PALETTE my_palette;    if (text_height(gui_main_font) > 8)     sprintf(str,"%ssnapshot" SLASH "big" SLASH "%s.pcx", dir_cfg.exe_path,name);  else    sprintf(str,"%ssnapshot" SLASH "%s.pcx", dir_cfg.exe_path,name);  snapshot = load_pcx(str,my_palette);  if (!snapshot && text_height(gui_main_font) > 8) {    sprintf(str,"%ssnapshot" SLASH "%s.pcx", dir_cfg.exe_path,name);    snapshot = load_pcx(str,my_palette);  }  if (snapshot)    set_palette_range(my_palette,0,239,1);  return snapshot;}static int listbox_active = 0; // to know if we can redraw or not...char *listbox_getter(int index, int *list_size){   int ta=0,list_length=0;   char tb[2];   char tc[2];   int (*get_index)(int)=get_normal_index;   DIR_INFO *head;   UINT8 *dir;      switch(rgui_cfg.game_list_mode){   case 0x00:			// Mode 0: List all games     list_length = my_game_count;     get_index = get_normal_index;     break;   case 0x01:			// Mode 1: List available games     list_length = GameAvailCount;     get_index = get_avail_index;     break;   case 2:     list_length = GameMissingCount;     get_index = get_missing_index;   }      switch(index){   case -1:			// Return List Size     *list_size = list_length;     return NULL;     break;   case -2:			// Act upon List Object Selection     break;   case -4:      if (snapshot)       destroy_snapshot(1);     if ((rgui_cfg.game_list_mode==0 && my_game_count>0) ||	 (rgui_cfg.game_list_mode==1 && GameAvailCount>0) ||	 (rgui_cfg.game_list_mode==2 && GameMissingCount>0)) {       ta = get_index(*list_size);       sprintf(game_select[GAME_DATA].dp,	       pad(game_company_name(my_game_list[ta]->company_id),20));       sprintf(game_select[GAME_DATA+1].dp,	       ipad(my_game_list[ta]->year,20));       if (my_game_list[ta]->sound_list)	 sprintf(game_select[GAME_DATA+2].dp,"Yes  ");       else	 sprintf(game_select[GAME_DATA+2].dp,"No   ");       sprintf(game_select[GAME_DATA+3].dp,	       game_type_name(my_game_list[ta]->flags & 0xff,14));	        snapshot = load_snapshot(my_game_list[ta]->main_name);              snapshot_cols = 240;              if (!snapshot) {	 head = my_game_list[ta]->dir_list;	 for (; head; head++) {	   dir = head[0].maindir;	   if( dir ){	     	     if( IS_ROMOF(dir) ){	     	       GAME_MAIN *game_romof;	       game_romof = find_game(dir+1);	     	       snapshot = load_snapshot(game_romof->main_name);	       	       if (snapshot) break;	     }	   } else	     break;	 }       }     } else {       sprintf(game_select[GAME_DATA].dp,	       pad("---",20));       sprintf(game_select[GAME_DATA+1].dp,	       pad("---",20));       if (my_game_list[ta]->sound_list)	 sprintf(game_select[GAME_DATA+2].dp,"--- ");       else	 sprintf(game_select[GAME_DATA+2].dp,"--- ");       sprintf(game_select[GAME_DATA+3].dp,	       pad("---",14));       snapshot = NULL;            }            if (!snapshot) {       snapshot_cols = 7;       snapshot = make_mapped_bitmap(RaineData[RaineLogo].dat, &ta, RaineData[GUIPalette].dat, snapshot_cols);     }          setup_game_bitmap();          if (listbox_active) {        // Redraw data fields       for (ta = 0; ta < 4; ta++)	 SEND_MESSAGE(&game_select[GAME_DATA+ta], MSG_DRAW, 0);     // Redraw titles       for (ta = -4; ta < 0; ta++)	 SEND_MESSAGE(&game_select[GAME_DATA+ta], MSG_DRAW, 0);       SEND_MESSAGE(&game_select[GAME_BITMAP],MSG_DRAW,0);     }     return NULL;   case -3:			// Act Keyboard Input     tb[0] = *list_size & 0xFF;     tb[1] = 0;     tc[1] = 0;     for(ta=0;ta<list_length;ta++){       tc[0] = my_game_list[get_index(ta)]->long_name[0];       if(!(strcasecmp(tb,tc))){	 game_select[GAME_LIST].d1 = ta;	 if(ta < (game_select[GAME_LIST].d2     )) game_select[GAME_LIST].d2 = ta;	 if(ta > (game_select[GAME_LIST].d2 + GLIST_SIZE)) game_select[GAME_LIST].d2 = ta - GLIST_SIZE+1;	 *list_size = D_USED_CHAR;	 return NULL;       }     }     return NULL;     break;   default:     if((index >= 0)&&(index<list_length))       return get_long_name(my_game_list[get_index(index)]);     else       return NULL;     break;   }   return NULL;}// game_radio_proc():// Radio buttons for game list mode, need to be custom// to incorporate automatic update on button selection.int game_radio_proc(int msg, DIALOG *d, int c){   int i;   int ret=x_raine_radio_proc(msg, d, c);   if((msg==MSG_KEY)||(msg==MSG_CLICK)){      // Get selected List Mode      // ----------------------      if((game_select[5+0].flags)&D_SELECTED) i = 0;      else if((game_select[5+1].flags)&D_SELECTED) i = 1;      else if((game_select[5+2].flags)&D_SELECTED) i = 2;	  else i = 0;      set_game_list_mode(i);      // Refresh the Game List      // ---------------------      SEND_MESSAGE(&game_select[GAME_LIST], MSG_END, 0);      SEND_MESSAGE(&game_select[GAME_LIST], MSG_START, 0);      	scare_mouse();      broadcast_dialog_message(MSG_DRAW, 0);	unscare_mouse();      // Wait for release      // ----------------	while(gui_mouse_b()){	  dialog_oxygen();	}   }   return ret;}static UINT32 current_game_rom_count;static UINT32 current_game_rom_load_count;int load_game_proc(int msg, DIALOG *d, int c){  int oldbpp = 0;	(void)(d);	(void)(c);  switch(msg){      case MSG_IDLE:         mouse_on_real_screen();         dialog_on_real_screen();         LoadDefault();         load_error = 0;         load_debug = malloc(0x10000);         sprintf(load_debug,"Load Game\n---------\n\n");	 if (my_game_list) // normal loading	   current_game = my_game_list[raine_cfg.req_game_index];	 else // uses -g switch	   current_game = game_list[raine_cfg.req_game_index];	 // I have to change the depth BEFORE loading.	 // Probably because of the set_color_mapper in the loading function	 if(wants_switch_res) // && switch_res(current_game->video_info))){	   switch_res(current_game->video_info);#if 0	 // For now I disable automatic depth changing, now that almost	 // every game does support all the depths...	 // Because some people running raine in a 16bpp display might	 // prefer running 8bpp games in 16bpp (like me)	   if (bestbpp) {	     oldbpp = display_cfg.bpp;	     display_cfg.bpp = bestbpp;	   }#endif	          /*         count roms         */         {            ROM_INFO *rom_list;            current_game_rom_count = 0;            current_game_rom_load_count = 0;            rom_list = current_game->rom_list;            while(rom_list->name)            {               current_game_rom_count ++;               rom_list ++;            }            if(!current_game_rom_count)               current_game_rom_count ++;            loading_dialog[2].d1 = current_game_rom_load_count;            loading_dialog[2].d2 = current_game_rom_count;	      scare_mouse();            SEND_MESSAGE(&loading_dialog[2], MSG_DRAW,  0);	      unscare_mouse();         }         load_game_rom_info();	 	 if (!(load_error & LOAD_FATAL_ERROR)) {	   current_game->load_game();	   // bpp must be changed in the last moment !!!	   if (oldbpp)	     display_cfg.bpp = oldbpp;	   	   init_inputs();	   init_dsw();	   init_romsw();	   init_sound_list();	   hs_open();	 }         dialog_on_buffer_screen();         mouse_on_buffer_screen();         loading_dialog[2].d1 = current_game_rom_count;         loading_dialog[2].d2 = current_game_rom_count;	   scare_mouse();         SEND_MESSAGE(&loading_dialog[2], MSG_DRAW,  0);	   unscare_mouse();         dialog_oxygen();         return D_EXIT;      break;      default:         return D_O_K;      break;   }}void do_load_game(void){   BITMAP *load_mouse;   int ta,size;   /*   satisfy the request   */   raine_cfg.req_load_game = 0;   /*   don't reload if the game is already in memory   */   if(my_game_list && current_game == my_game_list[raine_cfg.req_game_index])      return;   /*   close down the current game (if there is one)   */   if(current_game){      save_game_config();      hs_close();      current_game->clear_game();      ClearDefault();      current_game = NULL;   }      // Do the load (via a loading window)     load_mouse = make_mapped_bitmap_2(RaineData[mouse_busy].dat, &ta, RaineData[mouse_busy_pal].dat, 16);      set_mouse_sprite(load_mouse);      loading_dialog[2].d1 = 0;      loading_dialog[2].d2 = 1;      FadeGUI();            raine_do_dialog(loading_dialog,-1);      set_mouse_sprite(RaineData[Mouse].dat);      destroy_mapped_bitmap(load_mouse, 16);      // Check if the load was successful, if ok, load game config, if bad clear the mess      switch(load_error&3){      case LOAD_WARNING:			// WARNING - IT MIGHT RUN OK         FadeGUI();	 strcat(load_debug,"\n\nThe game might not run correctly.");         load_problem[2].dp = load_debug;         raine_do_dialog(load_problem,-1);      case 0x00:				// SUCCESS	size = GetMemoryPoolSize()/1024; // Minimum Kb	memcpy(&prev_display_cfg, &display_cfg, sizeof(DISPLAY_CFG));	load_game_config();	reset_game_hardware();		{	  char name[40];	  	  strncpy(name,current_game->long_name,39);	  name[39] = 0;

⌨️ 快捷键说明

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