{
popup_timer.init(false);
- char filename[1024];
-
- if(!icon_file.empty())
- {
- snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file.c_str());
- if(!faccessible(filename))
- snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
- }
- else
- {
- snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
- }
-
- if(mw != -1 || mh != -1)
- {
- icon = new Surface(filename,USE_ALPHA);
- icon->resize(mw,mh);
- }
- else
- icon = new Surface(filename,USE_ALPHA);
+ add_icon(icon_file,mw,mh);
info = ninfo;
rect.x = x;
rect.y = y;
- rect.w = icon->w;
- rect.h = icon->h;
+ rect.w = icon[0]->w;
+ rect.h = icon[0]->h;
tag = -1;
state = BUTTON_NONE;
show_info = false;
- bkgd = NULL;
game_object = NULL;
}
-void Button::change_icon(std::string icon_file, int /*mw*/, int /*mh*/)
+void Button::add_icon(std::string icon_file, int mw, int mh)
{
char filename[1024];
snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str());
}
- delete icon;
- icon = new Surface(filename,USE_ALPHA);
+ if(mw != -1 || mh != -1)
+ {
+ icon.push_back(new Surface(filename,USE_ALPHA));
+ icon.back()->resize(mw,mh);
+ }
+ else
+ icon.push_back(new Surface(filename,USE_ALPHA));
+
}
void Button::draw()
fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200);
fillrect(rect.x+1,rect.y+1,rect.w-2,rect.h-2,175,175,175,200);
- if(bkgd != NULL)
- {
- bkgd->draw(rect.x,rect.y);
- }
- icon->draw(rect.x,rect.y);
+
+ for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it)
+ (*it)->draw(rect.x,rect.y);
+
if(game_object != NULL)
{
game_object->draw_on_screen();
Button::~Button()
{
- delete icon;
+ for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it)
+ delete (*it);
+ icon.clear();
delete game_object;
}
bool IsTile() { return is_tile; };
//Returns true for a GameObject
bool IsObject() { return !is_tile; };
+ void Init() { tile = 0; obj = NULL; is_tile = true; };
bool is_tile; //true for tile (false for object)
unsigned int tile;
}
else if(menu == subset_settings_menu)
{
- if(le_level_subset->title.compare(subset_settings_menu->get_item_by_id(MNID_TITLE).input) == 0 && le_level_subset->description.compare(subset_settings_menu->get_item_by_id(MNID_DESCRIPTION).input) == 0 )
- subset_settings_menu->get_item_by_id(MNID_SAVE_CHANGES).kind = MN_DEACTIVE;
+ if(le_level_subset->title.compare(subset_settings_menu->get_item_by_id(MNID_SUBSETTITLE).input) == 0 && le_level_subset->description.compare(subset_settings_menu->get_item_by_id(MNID_SUBSETDESCRIPTION).input) == 0 )
+ subset_settings_menu->get_item_by_id(MNID_SUBSETSAVECHANGES).kind = MN_DEACTIVE;
else
- subset_settings_menu->get_item_by_id(MNID_SAVE_CHANGES).kind = MN_ACTION;
+ subset_settings_menu->get_item_by_id(MNID_SUBSETSAVECHANGES).kind = MN_ACTION;
switch (i = subset_settings_menu->check())
{
- case MNID_SAVE_CHANGES:
+ case MNID_SUBSETSAVECHANGES:
save_subset_settings_menu();
//FIXME:show_menu = true;
Menu::set_current(leveleditor_menu);
subset_settings_menu->additem(MN_LABEL,"Level Subset Settings",0,0);
subset_settings_menu->additem(MN_HL,"",0,0);
- subset_settings_menu->additem(MN_TEXTFIELD,"Title",0,0);
- subset_settings_menu->additem(MN_TEXTFIELD,"Description",0,0);
+ subset_settings_menu->additem(MN_TEXTFIELD,"Title",0,0,MNID_SUBSETTITLE);
+ subset_settings_menu->additem(MN_TEXTFIELD,"Description",0,0,MNID_SUBSETDESCRIPTION);
subset_settings_menu->additem(MN_HL,"",0,0);
- subset_settings_menu->additem(MN_ACTION,"Save Changes",0,0);
+ subset_settings_menu->additem(MN_ACTION,"Save Changes",0,0,MNID_SUBSETSAVECHANGES);
subset_settings_menu->additem(MN_HL,"",0,0);
subset_settings_menu->additem(MN_BACK,"Back",0,0);
sit != (*it).tiles.end(); ++sit, ++i)
{
std::string imagefile = "/images/tilesets/" ;
+ bool only_editor_image = false;
if(!TileManager::instance()->get(*sit)->filenames.empty())
{
imagefile += TileManager::instance()->get(*sit)->filenames[0];
else if(!TileManager::instance()->get(*sit)->editor_filenames.empty())
{
imagefile += TileManager::instance()->get(*sit)->editor_filenames[0];
+ only_editor_image = true;
}
else
{
}
Button* button = new Button(imagefile, it->name, SDLKey(SDLK_a + i),
0, 0, 32, 32);
+ if(!only_editor_image)
+ if(!TileManager::instance()->get(*sit)->editor_filenames.empty())
+ {
+ imagefile = "/images/tilesets/" + TileManager::instance()->get(*sit)->editor_filenames[0];
+ button->add_icon(imagefile,32,32);
+ }
tilegroups_map[it->name]->additem(button, *sit);
}
}
int le_init()
{
level_subsets = dsubdirs("/levels", "info");
-
le_level_subset = new LevelSubset;
active_tm = TM_IA;
-
le_show_grid = true;
+ scroll_x = 0;
- /* level_changed = NO;*/
fire = DOWN;
done = 0;
le_frame = 0; /* support for frames in some tiles, like waves and bad guys */
le_tilemap_panel->additem(new Button("/images/icons/bkgrd.png","Background",SDLK_F4,0,0),TM_BG);
le_tilemap_panel->additem(new Button("/images/icons/intact.png","Interactive",SDLK_F4,0,0),TM_IA);
le_tilemap_panel->additem(new Button("/images/icons/frgrd.png","Foreground",SDLK_F4,0,0),TM_FG);
-
+
+ le_current.Init();
+
le_init_menus();
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
music_manager->halt_music();
- Menu::set_current(leveleditor_menu);
+ Menu::set_current(NULL);
le_world.arrays_free();
le_current_level->load_gfx();
le_world.activate_bad_guys();