Skip to content

Commit

Permalink
Allow multiple possible loading screens, including from mods
Browse files Browse the repository at this point in the history
  • Loading branch information
RenechCDDA committed Sep 11, 2024
1 parent dd272dd commit 24312ae
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Binary file added data/mods/alternate_loading_images/cdda.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions data/mods/alternate_loading_images/modinfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"type": "MOD_INFO",
"id": "alternate_loading_images",
"name": "Alternate loading screen images",
"authors": [ "RenechCDDA" ],
"description": "Makes more images available on the loading screen, picks randomly. WIP",

Check failure on line 7 in data/mods/alternate_loading_images/modinfo.json

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

(~[slow] ~[.],starting_items)=> insufficient spaces at this location. 2 required, but only 1 found. Suggested fix: insert " " At the following position (marked with caret) "name": "Alternate loading screen images", "authors": [ "RenechCDDA" ], "description": "Makes more images available on the loading screen, picks randomly. WIP", ▲▲▲ "category": "graphical", "dependencies": [ "dda" ],

Check failure on line 7 in data/mods/alternate_loading_images/modinfo.json

View workflow job for this annotation

GitHub Actions / Basic Build and Test (Clang 10, Ubuntu, Curses)

([slow] ~starting_items)=> insufficient spaces at this location. 2 required, but only 1 found. Suggested fix: insert " " At the following position (marked with caret) "name": "Alternate loading screen images", "authors": [ "RenechCDDA" ], "description": "Makes more images available on the loading screen, picks randomly. WIP", ▲▲▲ "category": "graphical", "dependencies": [ "dda" ],
"category": "graphical",
"dependencies": [ "dda" ],
"path": ""
}
]
15 changes: 13 additions & 2 deletions src/loading_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,19 @@ static void update_state( const std::string &context, const std::string &step )
} );

#ifdef TILES
cata_path path = PATH_INFO::gfxdir() / "cdda.png";
SDL_Surface_Ptr surf = load_image( path.get_unrelative_path().u8string().c_str() );
cata_path default_load_img = PATH_INFO::gfxdir() / "cdda.png";
std::vector<cata_path> imgs;
imgs.emplace_back( default_load_img );
static const std::string LOAD_IMG_SEARCH_FILE( "cdda.png" );
for( cata_path &img_path : get_files_from_path( LOAD_IMG_SEARCH_FILE, PATH_INFO::moddir(),
true ) ) {
imgs.emplace_back( img_path );
}
static cata_path chosen_load_img;
if( chosen_load_img == cata_path() ) {
chosen_load_img = random_entry( imgs );
}
SDL_Surface_Ptr surf = load_image( chosen_load_img.get_unrelative_path().u8string().c_str() );
gLUI->splash_size = { static_cast<float>( surf->w ), static_cast<float>( surf->h ) };
gLUI->splash = CreateTextureFromSurface( get_sdl_renderer(), surf );
gLUI->window_size = gLUI->splash_size + ImVec2{ 0.0f, 2.0f * ImGui::GetTextLineHeightWithSpacing() };
Expand Down

0 comments on commit 24312ae

Please sign in to comment.