pbutton->bkgd = NULL;
}
+button_type* button_change_icon(button_type* pbutton,char* icon_file)
+{
+ char filename[1024];
+
+ if(icon_file != NULL)
+ {
+ snprintf(filename, 1024, "%s/%s", DATA_PREFIX, icon_file);
+ if(!faccessible(filename))
+ snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+ }
+ else
+ {
+ snprintf(filename, 1024, "%s/images/icons/default-icon.png", DATA_PREFIX);
+ }
+
+ texture_free(&pbutton->icon);
+ texture_load(&pbutton->icon,filename,USE_ALPHA);
+}
+
button_type* button_create(char* icon_file, char* info, SDLKey shortcut, int x, int y)
{
button_type* pnew_button = (button_type*) malloc(sizeof(button_type));
row = (pbutton_panel->num_items-1) / max_cols;
col = (pbutton_panel->num_items-1) % max_cols;
- printf("R %d C %d\n",row,col);
-
pbutton_panel->item[pbutton_panel->num_items-1].x = pbutton_panel->x + col * 32;
pbutton_panel->item[pbutton_panel->num_items-1].y = pbutton_panel->y + row * 32;
pbutton_panel->item[pbutton_panel->num_items-1].tag = tag;
le_quit();
return 1;
}
+ le_update_buttons(le_current_level->theme);
le_set_defaults();
level_load_gfx(le_current_level);
le_activate_bad_guys();
le_quit();
return 1;
}
+ le_update_buttons(le_current_level->theme);
le_set_defaults();
level_load_gfx(le_current_level);
le_activate_bad_guys();
level_save(&new_lev,subset_name,1);
}
+le_update_buttons(char *theme)
+{
+ int i;
+ char filename[1024];
+ char pathname[1024];
+ SDLKey key;
+ string_list_type bkgd_files;
+ string_list_type fgd_files;
+
+ sprintf(pathname,"images/themes/%s",theme);
+ bkgd_files = dfiles(pathname,"bkgd-", NULL);
+ string_list_sort(&bkgd_files);
+
+ le_bkgd_panel.hidden = YES;
+ key = SDLK_a;
+ for(i = 0; i < bkgd_files.num_items; ++i)
+ {
+ sprintf(filename,"%s/%s",pathname,bkgd_files.item[i]);
+ printf("%s\n",filename);
+ button_change_icon(&le_bkgd_panel.item[i],filename);
+ }
+
+ sprintf(pathname,"images/themes/%s",theme);
+ fgd_files = dfiles(pathname,"solid", NULL);
+ string_list_sort(&fgd_files);
+ key = SDLK_a;
+ for(i = 0; i < fgd_files.num_items; ++i)
+ {
+ sprintf(filename,"%s/%s",pathname,fgd_files.item[i]);
+ button_change_icon(&le_fgd_panel.item[i],filename);
+ }
+
+ string_list_free(&fgd_files);
+ fgd_files = dfiles(pathname,"brick", NULL);
+ string_list_sort(&fgd_files);
+
+ for(i = 0; i < fgd_files.num_items; ++i)
+ {
+ sprintf(filename,"%s/%s",pathname,fgd_files.item[i]);
+ button_change_icon(&le_fgd_panel.item[i+14],filename);
+ }
+}
+
int le_init()
{
int i,j;
char str[80];
char filename[1024];
SDLKey key;
+ string_list_type fgd_files;
+ string_list_type bkgd_files;
+ string_list_type bad_files;
level_subsets = dsubdirs("/levels", "info");
le_show_grid = YES;
button_load(&le_bkgd_bt,"/images/icons/bgd.png","Background tiles", SDLK_F8,screen->w-43,82);
button_load(&le_bad_bt,"/images/icons/bad.png","Bad guys", SDLK_F9,screen->w-22,82);
- string_list_type bkgd_files = dfiles("images/themes/antarctica","bkgd-", NULL);
+ bkgd_files = dfiles("images/themes/antarctica","bkgd-", NULL);
string_list_sort(&bkgd_files);
button_panel_init(&le_bkgd_panel, screen->w - 64,98, 64, 318);
button_panel_additem(&le_bkgd_panel,button_create(filename, "Background Tile",(SDLKey)((int)key+i+8),0,0),i+8);
}
- string_list_type fgd_files = dfiles("images/themes/antarctica","solid", NULL);
+ fgd_files = dfiles("images/themes/antarctica","solid", NULL);
string_list_sort(&fgd_files);
key = SDLK_a;
button_panel_init(&le_fgd_panel, screen->w - 64,98, 64, 318);
string_list_free(&fgd_files);
fgd_files = dfiles("images/themes/antarctica","brick", NULL);
string_list_sort(&fgd_files);
-
+
for(i = 0; i < fgd_files.num_items; ++i)
{
sprintf(filename,"images/themes/antarctica/%s",fgd_files.item[i]);
button_panel_additem(&le_fgd_panel,button_create(filename, "Foreground Tile",(SDLKey)((int)key+i+14),0,0),i+14);
}
-
+
string_list_free(&fgd_files);
string_list_add_item(&fgd_files,"distro-0.png");
string_list_add_item(&fgd_files,"distro-0.png");
le_fgd_panel.item[16].bkgd = &le_fgd_panel.item[14].icon;
le_fgd_panel.item[17].bkgd = &le_fgd_panel.item[15].icon;
- string_list_type bad_files;
+ bad_files;
string_list_init(&bad_files);
string_list_add_item(&bad_files,"bsod-left-0.png");
string_list_add_item(&bad_files,"laptop-left-0.png");
if(strcmp(le_current_level->theme,string_list_active(level_settings_menu.item[3].list)) != 0)
{
strcpy(le_current_level->theme,string_list_active(level_settings_menu.item[3].list));
+ le_update_buttons(le_current_level->theme);
i = YES;
}
le_set_defaults();
+ le_update_buttons(le_current_level->theme);
+
level_free_gfx();
level_load_gfx(le_current_level);
selection.y2 = event.motion.y;
}
else if(event.button.button == SDL_BUTTON_RIGHT)
- le_mouse_pressed[RIGHT] = YES;
+ le_mouse_pressed[RIGHT] = YES;
break;
case SDL_MOUSEBUTTONUP:
if(event.button.button == SDL_BUTTON_LEFT)
- le_mouse_pressed[LEFT] = NO;
+ le_mouse_pressed[LEFT] = NO;
else if(event.button.button == SDL_BUTTON_RIGHT)
- le_mouse_pressed[RIGHT] = NO;
+ le_mouse_pressed[RIGHT] = NO;
break;
case SDL_MOUSEMOTION:
if(!show_menu)
if(le_mouse_pressed[RIGHT] == YES)
{
-fprintf(stderr, "mouse scrolling\n");
- pos_x += 1 * event.motion.xrel;
- }
+ fprintf(stderr, "mouse scrolling\n");
+ pos_x += 1 * event.motion.xrel;
+ }
}
break;
case SDL_QUIT: // window closed
if(event.type == SDL_KEYDOWN || event.type == SDL_KEYUP || ((event.type == SDL_MOUSEBUTTONDOWN || SDL_MOUSEMOTION) && (event.motion.x > screen->w-64 && event.motion.x < screen->w &&
event.motion.y > 0 && event.motion.y < screen->h)))
{
+ le_mouse_pressed[LEFT] = NO;
+ le_mouse_pressed[RIGHT] = NO;
+
if(show_menu == NO)
{
/* Check for button events */
else if(pbutton->tag == 16)
c = 'x';
else if(pbutton->tag == 17)
- c = 'y';
+ c = 'y';
if(c != '\0')
le_current_tile = c;
}
text_load(&red_text,DATA_PREFIX "/images/status/letters-red.png", TEXT_TEXT, 16,18);
text_load(&white_text,DATA_PREFIX "/images/status/letters-white.png", TEXT_TEXT, 16,18);
text_load(&white_small_text,DATA_PREFIX "/images/status/letters-white-small.png", TEXT_TEXT, 8,9);
- text_load(&white_big_text,DATA_PREFIX "/images/status/letters-white-big.png", TEXT_TEXT, 24,27);
+ text_load(&white_big_text,DATA_PREFIX "/images/status/letters-white-big.png", TEXT_TEXT, 20,23);
text_load(&yellow_nums,DATA_PREFIX "/images/status/numbers.png", TEXT_NUM, 32,32);
/* Load GUI/menu images: */
text_free(&blue_text);
text_free(&red_text);
text_free(&white_small_text);
+ text_free(&white_big_text);
/* Free GUI/menu images: */
texture_free(&checkbox);
texture_free(&checkbox_checked);
texture_free(&back);
-
+ texture_free(&arrow_left);
+ texture_free(&arrow_right);
+
/* Free menus */
menu_free(&main_menu);
menu_free(&game_menu);
menu_free(&options_menu);
menu_free(&highscore_menu);
+ menu_free(&save_game_menu);
+ menu_free(&load_game_menu);
}