Skin graphics and font are now recorded & reloaded.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@891 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									d4dcba62a6
								
							
						
					
					
						commit
						8b4533f105
					
				
							
								
								
									
										49
									
								
								buttons.c
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								buttons.c
									
									
									
									
									
								
							@ -1049,13 +1049,12 @@ void Button_Skins(void)
 | 
			
		||||
  short clicked_button;
 | 
			
		||||
  short temp;
 | 
			
		||||
  char skinsdir[MAX_PATH_CHARACTERS];
 | 
			
		||||
  static int selector_position=0;
 | 
			
		||||
  T_Config Config_choisie = Config;
 | 
			
		||||
  T_Dropdown_button * font_dropdown;
 | 
			
		||||
  T_Dropdown_button * cursor_dropdown;
 | 
			
		||||
  T_List_button * skin_list;
 | 
			
		||||
  T_Scroller_button * file_scroller;
 | 
			
		||||
  int selected_font=0;
 | 
			
		||||
  int selected_cursor=Config.Cursor;
 | 
			
		||||
  
 | 
			
		||||
  char * cursors[] = { "Solid", "Transparent", "Thin" };
 | 
			
		||||
 | 
			
		||||
@ -1076,7 +1075,7 @@ void Button_Skins(void)
 | 
			
		||||
  Sort_list_of_files(&Skin_files_list);
 | 
			
		||||
  Sort_list_of_files(&Font_files_list);
 | 
			
		||||
  
 | 
			
		||||
  //selected_font = Find_file_in_fileselector(&Font_files_list, Config_choisie.Font_name);
 | 
			
		||||
  selected_font = Find_file_in_fileselector(&Font_files_list, Config.Font_file);
 | 
			
		||||
  
 | 
			
		||||
  // --------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
@ -1096,11 +1095,13 @@ void Button_Skins(void)
 | 
			
		||||
  skin_list = Window_set_list_button(
 | 
			
		||||
    // Fileselector
 | 
			
		||||
    Window_set_special_button(8,FILESEL_Y+1,144,80), // 2
 | 
			
		||||
    // Scroller du fileselector
 | 
			
		||||
    // Scroller for the fileselector
 | 
			
		||||
    (file_scroller = Window_set_scroller_button(160,FILESEL_Y+1,82,
 | 
			
		||||
		Skin_files_list.Nb_elements,10,selector_position)), // 3
 | 
			
		||||
		Skin_files_list.Nb_elements,10,0)), // 3
 | 
			
		||||
    Draw_one_skin_name); // 4
 | 
			
		||||
  
 | 
			
		||||
  skin_list->Cursor_position = Find_file_in_fileselector(&Skin_files_list, Config.Skin_file);
 | 
			
		||||
 | 
			
		||||
  // Buttons to choose a font
 | 
			
		||||
  font_dropdown = Window_set_dropdown_button(60,19,104,11,0, Get_item_by_index(&Font_files_list,selected_font)->Short_name,1,0,1,RIGHT_SIDE|LEFT_SIDE); // 5
 | 
			
		||||
  for (temp=0; temp<Font_files_list.Nb_files; temp++)
 | 
			
		||||
@ -1110,7 +1111,7 @@ void Button_Skins(void)
 | 
			
		||||
  Window_set_normal_button(62,136, 51,14,"Cancel",0,1,SDLK_ESCAPE); // 6
 | 
			
		||||
 | 
			
		||||
  // Dropdown list to choose cursor type
 | 
			
		||||
  cursor_dropdown = Window_set_dropdown_button(60,34,104,11,0,cursors[Config_choisie.Cursor],1,0,1,RIGHT_SIDE|LEFT_SIDE); // 7
 | 
			
		||||
  cursor_dropdown = Window_set_dropdown_button(60,34,104,11,0,cursors[selected_cursor],1,0,1,RIGHT_SIDE|LEFT_SIDE); // 7
 | 
			
		||||
  for (temp=0; temp<3; temp++)
 | 
			
		||||
    Window_dropdown_add_item(cursor_dropdown,temp,cursors[temp]);
 | 
			
		||||
  
 | 
			
		||||
@ -1139,7 +1140,7 @@ void Button_Skins(void)
 | 
			
		||||
        break;
 | 
			
		||||
	  // 5: Cancel
 | 
			
		||||
       case 7 : // Cursor
 | 
			
		||||
        Config_choisie.Cursor=Window_attribute2;
 | 
			
		||||
       selected_cursor = Window_attribute2;
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -1260,6 +1261,9 @@ void Button_Skins(void)
 | 
			
		||||
  if(clicked_button == 1)
 | 
			
		||||
  {
 | 
			
		||||
    T_Gui_skin * gfx;
 | 
			
		||||
    byte * new_font;
 | 
			
		||||
 | 
			
		||||
    // (Re-)load GUI graphics from selected skins
 | 
			
		||||
    strcpy(skinsdir, Get_item_by_index(&Skin_files_list, skin_list->List_start+skin_list->Cursor_position)->Full_name);
 | 
			
		||||
	  gfx=Load_graphics(skinsdir);
 | 
			
		||||
	  if (gfx == NULL) // Error
 | 
			
		||||
@ -1268,25 +1272,26 @@ void Button_Skins(void)
 | 
			
		||||
	  }
 | 
			
		||||
	  else
 | 
			
		||||
	  {
 | 
			
		||||
	    byte * new_font;
 | 
			
		||||
      free(Gfx);
 | 
			
		||||
      Gfx = gfx;
 | 
			
		||||
  	  // Font selection
 | 
			
		||||
  	  new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
 | 
			
		||||
  	  if (new_font)
 | 
			
		||||
  	  {
 | 
			
		||||
  	    const char * fname;
 | 
			
		||||
  	    free(Menu_font);
 | 
			
		||||
  	    Menu_font = new_font;
 | 
			
		||||
  	    free (Config_choisie.Font_name);
 | 
			
		||||
  	    fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name;
 | 
			
		||||
  	    Config_choisie.Font_name = strdup(fname);
 | 
			
		||||
  	  }
 | 
			
		||||
      
 | 
			
		||||
	    strcpy(Config_choisie.SkinFile,skinsdir);
 | 
			
		||||
      free(Config.Skin_file);
 | 
			
		||||
	    Config.Skin_file = strdup(skinsdir);
 | 
			
		||||
    }
 | 
			
		||||
	  // (Re-)load the selected font
 | 
			
		||||
	  new_font = Load_font(Get_item_by_index(&Font_files_list,selected_font)->Full_name);
 | 
			
		||||
	  if (new_font)
 | 
			
		||||
	  {
 | 
			
		||||
	    const char * fname;
 | 
			
		||||
	    
 | 
			
		||||
	    free(Menu_font);
 | 
			
		||||
	    Menu_font = new_font;
 | 
			
		||||
	    fname = Get_item_by_index(&Font_files_list,selected_font)->Full_name;
 | 
			
		||||
	    free(Config.Font_file);
 | 
			
		||||
	    Config.Font_file = strdup(fname);
 | 
			
		||||
	  }
 | 
			
		||||
 | 
			
		||||
	  Config = Config_choisie ;
 | 
			
		||||
    // Confirm the change of cursor shape
 | 
			
		||||
	  Config.Cursor = selected_cursor;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Close_window();
 | 
			
		||||
 | 
			
		||||
@ -318,7 +318,12 @@
 | 
			
		||||
 | 
			
		||||
  ; Name of the skinfile you want to  | Nom du fichier skin que vous voulez
 | 
			
		||||
  ; use.                              | utiliser.
 | 
			
		||||
  ; default 'skin_modern.png'
 | 
			
		||||
  Skin_file = skin_modern.png
 | 
			
		||||
  ; Default : (empty to let the program choose)
 | 
			
		||||
  Skin_file = 
 | 
			
		||||
 | 
			
		||||
  ; Name of the font file (8x8) you   | Nom du fichier police de caractère
 | 
			
		||||
  ; want to use.                      | 8x8 utilisée dans les menus.
 | 
			
		||||
  ; Default : (empty to let the program choose)
 | 
			
		||||
  Font_file = 
 | 
			
		||||
  
 | 
			
		||||
  ; end of configuration
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main.c
									
									
									
									
									
								
							@ -534,7 +534,7 @@ int Init_program(int argc,char * argv[])
 | 
			
		||||
  Analyze_command_line(argc,argv);
 | 
			
		||||
 | 
			
		||||
  // Load sprites, palette etc.
 | 
			
		||||
  strcpy(Gui_skin_file,Config.SkinFile);
 | 
			
		||||
  strcpy(Gui_skin_file,Config.Skin_file);
 | 
			
		||||
  Gfx = Load_graphics(Gui_skin_file);
 | 
			
		||||
  if (Gfx == NULL)
 | 
			
		||||
  {
 | 
			
		||||
@ -560,13 +560,12 @@ int Init_program(int argc,char * argv[])
 | 
			
		||||
  Back_color=MC_Black;
 | 
			
		||||
 | 
			
		||||
  // Font
 | 
			
		||||
  {
 | 
			
		||||
    byte *font;
 | 
			
		||||
    font = Load_font("font_Classic.png");
 | 
			
		||||
    if (font)
 | 
			
		||||
      Menu_font=font;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (!(Menu_font=Load_font(Config.Font_file)))
 | 
			
		||||
    if (!(Menu_font=Load_font("font_Classic.png")))
 | 
			
		||||
      {
 | 
			
		||||
        printf("Unable to open the default font file: %s\n", "font_Classic.png");
 | 
			
		||||
        Error(ERROR_GUI_MISSING);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
  memcpy(Main_palette, Gfx->Default_palette, sizeof(T_Palette));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -816,10 +816,15 @@ int Load_INI(T_Config * conf)
 | 
			
		||||
 | 
			
		||||
  // Optional, name of skin file. (>2.0)
 | 
			
		||||
  if(!Load_INI_get_string(file,buffer,"Skin_file",value_label,1))
 | 
			
		||||
	  strcpy(conf->SkinFile,value_label);
 | 
			
		||||
	  conf->Skin_file = strdup(value_label);
 | 
			
		||||
  else
 | 
			
		||||
    strcpy(conf->SkinFile,"skin_modern.png");
 | 
			
		||||
    conf->Skin_file = strdup("skin_modern.png");
 | 
			
		||||
 | 
			
		||||
  // Optional, name of font file. (>2.0)
 | 
			
		||||
  if(!Load_INI_get_string(file,buffer,"Font_file",value_label,1))
 | 
			
		||||
	  conf->Font_file = strdup(value_label);
 | 
			
		||||
  else
 | 
			
		||||
    conf->Font_file = strdup("font_Classic.png");
 | 
			
		||||
 | 
			
		||||
  fclose(file);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -639,7 +639,10 @@ int Save_INI(T_Config * conf)
 | 
			
		||||
  if ((return_code=Save_INI_set_values (Ancien_fichier,Nouveau_fichier,buffer,"Double_key_speed",1,values,0)))
 | 
			
		||||
    goto Erreur_Retour;
 | 
			
		||||
 | 
			
		||||
  if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Skin_file",conf->SkinFile)))
 | 
			
		||||
  if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Skin_file",conf->Skin_file)))
 | 
			
		||||
    goto Erreur_Retour;
 | 
			
		||||
    
 | 
			
		||||
  if ((return_code=Save_INI_set_strings (Ancien_fichier,Nouveau_fichier,buffer,"Font_file",conf->Font_file)))
 | 
			
		||||
    goto Erreur_Retour;
 | 
			
		||||
    
 | 
			
		||||
  Save_INI_flush(Ancien_fichier,Nouveau_fichier,buffer);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								struct.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								struct.h
									
									
									
									
									
								
							@ -261,8 +261,8 @@ typedef struct
 | 
			
		||||
/// This structure holds all the settings which are saved and loaded as gfx2.ini.
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  char *Font_name;                       ///< Name of the font used in the menus. Matches file skins/font_*.png (Case-sensitive on some filesystems)
 | 
			
		||||
  char SkinFile[64];                     ///< String, name of the file where all the graphic data is stored
 | 
			
		||||
  char *Font_file;                       ///< Name of the font used in the menus. Matches file skins/font_*.png (Case-sensitive on some filesystems)
 | 
			
		||||
  char *Skin_file;                        ///< String, name of the file where all the graphic data is stored
 | 
			
		||||
  int  Show_hidden_files;                ///< Boolean, true to show hidden files in fileselectors.
 | 
			
		||||
  int  Show_hidden_directories;          ///< Boolean, true to show hidden directories in fileselectors.
 | 
			
		||||
//  int  Show_system_directories;        ///< (removed when converted from DOS)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user