Exemple #1
0
void cOverworld_Manager::Load_Dir(const fs::path& dir, bool user_dir /* = false */)
{
    // set world directory
    vector<fs::path> subdirs = Get_Directory_Files(dir, "", true, false);
    std::sort(subdirs.begin(), subdirs.end());

    for (vector<fs::path>::iterator curdir = subdirs.begin(); curdir != subdirs.end(); ++curdir) {
        try {
            fs::path current_dir = *curdir;

            // only directories with an existing description
            if (File_Exists(current_dir / "description.xml")) {
                cOverworld* overworld = Get_from_Path(current_dir);

                // already available
                if (overworld) {
                    overworld->m_description->m_user = 2; // 2 = available in system *and* in user dir
                    continue;
                }

                overworld = cOverworld::Load_From_Directory(current_dir, user_dir);
                objects.push_back(overworld);
            }
        }
        catch (const std::exception& ex) {
            printf("%s %s\n", path_to_utf8(*curdir).c_str(), ex.what());
        }
    }
}
Exemple #2
0
void cOverworld_Manager :: Load_Dir( const std::string &dir, bool user_dir /* = 0 */ ) 
{
	// set world directory
	vector<std::string> subdirs = Get_Directory_Files( dir, "", 1, 0 );

	for( vector<std::string>::iterator curdir = subdirs.begin(); curdir != subdirs.end(); ++curdir )
	{
		try
		{
			std::string current_dir = *curdir;

			// only directories with an existing description
			if( File_Exists( current_dir + "/description.xml" ) )
			{
				cOverworld *overworld = Get_from_Path( current_dir );

				// already available
				if( overworld )
				{
					overworld->m_description->m_user = 2;
					continue;
				}

				overworld = new cOverworld();

				// get relative path
				std::string relative_path( current_dir, current_dir.rfind( '/' ) );

				// set relative path
				overworld->m_description->m_path = relative_path;
				// default name is the path
				overworld->m_description->m_name = relative_path;
				// set user
				overworld->m_description->m_user = user_dir;

				objects.push_back( overworld );

				overworld->Load();
			}
		}
		catch( const std::exception &ex )
		{
			printf( "%s %s\n", curdir->c_str(), ex.what() );
		}
	}
}
Exemple #3
0
void Preload_Images(bool draw_gui /* = 0 */)
{
    // progress bar
    CEGUI::ProgressBar* progress_bar = NULL;

    if (draw_gui) {
        // get progress bar
        progress_bar = static_cast<CEGUI::ProgressBar*>(CEGUI::WindowManager::getSingleton().getWindow("progress_bar"));
        progress_bar->setProgress(0);
        // set loading screen text
        Loading_Screen_Draw_Text(_("Loading Images"));
    }

    // image files
    vector<fs::path> image_files;

    // player
    vector<fs::path> player_small_images    = Get_Directory_Files(pResource_Manager->Get_Game_Pixmaps_Directory() / utf8_to_path("maryo/small"), ".png", false, false);
    vector<fs::path> player_big_images      = Get_Directory_Files(pResource_Manager->Get_Game_Pixmaps_Directory() / utf8_to_path("maryo/big"), ".png", false, false);
    vector<fs::path> player_fire_images     = Get_Directory_Files(pResource_Manager->Get_Game_Pixmaps_Directory() / utf8_to_path("maryo/fire"), ".png", false, false);
    vector<fs::path> player_ice_images      = Get_Directory_Files(pResource_Manager->Get_Game_Pixmaps_Directory() / utf8_to_path("maryo/ice"), ".png", false, false);
    vector<fs::path> player_ghost_images    = Get_Directory_Files(pResource_Manager->Get_Game_Pixmaps_Directory() / utf8_to_path("maryo/ghost"), ".png", false, false);

    image_files.insert(image_files.end(), player_small_images.begin(), player_small_images.end());
    image_files.insert(image_files.end(), player_big_images.begin(), player_big_images.end());
    image_files.insert(image_files.end(), player_fire_images.begin(), player_fire_images.end());
    image_files.insert(image_files.end(), player_ice_images.begin(), player_ice_images.end());
    image_files.insert(image_files.end(), player_ghost_images.begin(), player_ghost_images.end());

    // Mushrooms
    image_files.push_back(utf8_to_path("game/items/mushroom_red.png"));
    image_files.push_back(utf8_to_path("game/items/mushroom_green.png"));
    image_files.push_back(utf8_to_path("game/items/mushroom_blue.png"));
    image_files.push_back(utf8_to_path("game/items/mushroom_ghost.png"));
    // Fireberry
    image_files.push_back(utf8_to_path("game/items/fireberry_1.png"));
    image_files.push_back(utf8_to_path("game/items/fireberry_2.png"));
    image_files.push_back(utf8_to_path("game/items/fireberry_3.png"));
    // Star
    image_files.push_back(utf8_to_path("game/items/lemon_1.png"));
    // Feather
    //image_files.push_back( "game/items/feather_1.png" );
    // Yellow Goldpiece
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/1.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/2.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/3.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/4.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/5.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/6.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/7.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/8.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/9.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/10.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/1_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/2_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/3_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/4_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/5_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/6_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/7_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/8_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/9_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/yellow/10_falling.png"));
    // Red Goldpiece
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/1.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/2.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/3.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/4.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/5.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/6.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/7.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/8.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/9.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/10.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/1_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/2_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/3_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/4_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/5_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/6_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/7_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/8_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/9_falling.png"));
    image_files.push_back(utf8_to_path("game/items/goldpiece/red/10_falling.png"));

    // Brown Box
    image_files.push_back(utf8_to_path("game/box/brown1_1.png"));

    // Light animation
    image_files.push_back(utf8_to_path("animation/light_1/1.png"));
    image_files.push_back(utf8_to_path("animation/light_1/2.png"));
    image_files.push_back(utf8_to_path("animation/light_1/3.png"));
    // Particle animations
    image_files.push_back(utf8_to_path("animation/particles/fire_1.png"));
    image_files.push_back(utf8_to_path("animation/particles/fire_2.png"));
    image_files.push_back(utf8_to_path("animation/particles/fire_3.png"));
    image_files.push_back(utf8_to_path("animation/particles/fire_4.png"));
    image_files.push_back(utf8_to_path("animation/particles/smoke.png"));
    image_files.push_back(utf8_to_path("animation/particles/smoke_black.png"));
    image_files.push_back(utf8_to_path("animation/particles/light.png"));
    image_files.push_back(utf8_to_path("animation/particles/dirt.png"));
    image_files.push_back(utf8_to_path("animation/particles/ice_1.png"));
    image_files.push_back(utf8_to_path("animation/particles/cloud.png"));
    image_files.push_back(utf8_to_path("animation/particles/axis.png"));

    // Ball
    image_files.push_back(utf8_to_path("animation/fireball/1.png"));
    image_files.push_back(utf8_to_path("animation/iceball/1.png"));

    // HUD
    image_files.push_back(utf8_to_path("game/maryo_l.png"));
    image_files.push_back(utf8_to_path("game/gold_m.png"));
    image_files.push_back(utf8_to_path("game/itembox.png"));

    unsigned int loaded_files = 0;
    unsigned int file_count = image_files.size();

    // load images
    for (vector<fs::path>::iterator itr = image_files.begin(); itr != image_files.end(); ++itr) {
        // get filename
        fs::path filename = (*itr);

        // preload image
        pVideo->Get_Surface(filename);

        // count files
        loaded_files++;

        if (draw_gui) {
            // update progress
            progress_bar->setProgress(static_cast<float>(loaded_files) / static_cast<float>(file_count));

            Loading_Screen_Draw();
        }
    }
}