diff --git a/data/mods/alternate_loading_images/modinfo.json b/data/mods/alternate_loading_images/modinfo.json new file mode 100644 index 0000000000000..5a6d5c939a762 --- /dev/null +++ b/data/mods/alternate_loading_images/modinfo.json @@ -0,0 +1,13 @@ +[ + { + "type": "MOD_INFO", + "id": "alternate_loading_images", + "name": "Alternate loading screen images", + "authors": [ "RenechCDDA" ], + "description": "Provides more possible images for the graphical loading screen.", + "category": "graphical", + "dependencies": [ "dda" ], + "loading_images": [ "loadscreen_by_db48x.png", "loadscreen_by_vetall812.png" ], + "path": "" + } +] diff --git a/data/mods/default.json b/data/mods/default.json index 93012859958a7..7f188d301ffc5 100644 --- a/data/mods/default.json +++ b/data/mods/default.json @@ -4,6 +4,6 @@ "id": "dev:default", "name": "default", "description": "contains all the mods recommended by the developers", - "dependencies": [ "dda", "no_npc_food", "personal_portal_storms", "no_fungal_growth", "No_Rail_Stations" ] + "dependencies": [ "dda", "no_npc_food", "personal_portal_storms", "no_fungal_growth", "No_Rail_Stations", "alternate_loading_images" ] } ] diff --git a/doc/MODDING.md b/doc/MODDING.md index 190829f369ffc..2fc07a4331687 100644 --- a/doc/MODDING.md +++ b/doc/MODDING.md @@ -22,14 +22,34 @@ A barebones `modinfo.json` file looks like this: { "type": "MOD_INFO", "id": "Mod_ID", - "name": "Mod's Display Name", - "authors": [ "Your name here", "Your friend's name if you want" ], - "description": "Your description here", - "category": "content", - "dependencies": [ "dda" ] + "name": "Mod's Display Name" } ] ```` + +This is the absolute bare minimum, but you may want to add `authors`(You!), a `description` and a `category`. See below for more possibilities. + +### All MOD_INFO fields +Here is a full list of supported values for MOD_INFO: +````json +[ + { + "type": "MOD_INFO", // Mandatory, you're making one of these! + "id": "Mod_ID", // Mandatory, unique id for your mod. You should not use the same id as any other mod. + "name": "Mod's Display Name", // Mandatory. + "authors": [ "Me", "A really cool friend" ], // Optional, but you probably want to put your name here. More than one entry can be added, as shown. + "description": "The best mod ever!", // Optional + "category": "graphical", // Optional, see below for a full list of supported values. The category is just for information purposes, so don't worry if your mod might fit more than one category. + "dependencies": [ "dda" ], // Optional. What other mods are required for this mod to function? If your mod depends on another one to work properly, adding that mod's `id` attribute to the array causes Cataclysm to force that mod to load before yours. + "loading_images": [ "cool.png", "cool2.png" ], // Optional. Filenames for any loading screen images the mod may have. Loading screens are only present on the graphical/"tiles" version. Only supports .png files. Actual loading screen image will be picked randomly from among all mod loading screens, including other loaded mods that have loading screens. + "version": "1.3.bacon", // Optional. For informational purposes only. No versioning system is provided, so whatever you put here is up to you. Feel free to name your versions after ice cream. + "core": false, // Optional, default false. Core mods will be loaded before anything else. Used for DDA, third-party use will not be supported. + "obsolete": false, // Optional, default false. Obsolete mods are loaded for legacy saves but cannot be used when starting new worlds + "path": "my_mod_files/" // Optional, this directory relative to modinfo.json's location will be considered the mod's actual directory. e.g. if modinfo.json is located at C:\CDDA\my_mod\modinfo.json, then the mod files would be considered to be at C:\CDDA\my_mod\my_mod_files\. A file such as C:\CDDA\my_mod\some_other_file.json would be ignored, it isn't located inside the specified directory. + } +] +```` + The `category` attribute denotes where the mod will appear in the mod selection menu. These are the available categories to choose from, with some examples chosen from mods that existed when this document was written. Pick whichever one applies best to your mod when writing your modinfo file. - `content` - A mod that adds a lot of stuff. Typically reserved for large mods (eg: Core game files, Aftershock) - `total_conversion` - A mod that fundamentally changes the game. In particular, the assumption is that a player should not use two total conversion mods at the same time, and so they will not be tested together. However, nothing prevents players from using more than one if they wish. (eg: Dark Skies Above) @@ -44,8 +64,6 @@ The `category` attribute denotes where the mod will appear in the mod selection - `monster_exclude` - A mod that stops certain monster varieties from spawning in the world (eg: No fungal monsters, No monsters) - `graphical` - A mod that adjusts game graphics in some way (eg: Graphical overmap) -The `dependencies` attribute is used to tell Cataclysm that your mod is dependent on something present in another mod. If you have no dependencies outside of the core game, then just including `dda` in the list is good enough. If your mod depends on another one to work properly, adding that mod's `id` attribute to the array causes Cataclysm to force that mod to load before yours. - ## Actually adding things to your mod Now that you have a basic mod, you can get around to actually putting some stuff into it! diff --git a/src/game.cpp b/src/game.cpp index 7161fbc4f3674..e642ed9c07f2d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3226,7 +3226,6 @@ void game::load_packs( const std::string &msg, const std::vector &packs } load_data_from_dir( mod.path, mod.ident.str() ); } - loading_ui::done(); std::unordered_set removed_mods { MOD_INFORMATION_Graphical_Overmap // Removed in 0.I diff --git a/src/loading_ui.cpp b/src/loading_ui.cpp index 0b550d484e1b2..bb454ef4bcc68 100644 --- a/src/loading_ui.cpp +++ b/src/loading_ui.cpp @@ -9,9 +9,11 @@ #define IMGUI_DEFINE_MATH_OPERATORS #include "imgui/imgui.h" #undef IMGUI_DEFINE_MATH_OPERATORS +#include "mod_manager.h" #include "path_info.h" #include "sdltiles.h" #include "sdl_wrappers.h" +#include "worldfactory.h" #else #include "cursesdef.h" #endif // TILES @@ -23,6 +25,7 @@ struct ui_state { ImVec2 window_size; ImVec2 splash_size; SDL_Texture_Ptr splash; + cata_path chosen_load_img; #else size_t splash_width = 0; std::vector splash; @@ -90,8 +93,25 @@ 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() ); + std::vector imgs; + std::vector &active_mod_list = world_generator->active_world->active_mod_order; + for( mod_id &some_mod : active_mod_list ) { + const MOD_INFORMATION &mod = *some_mod; + for( std::string img_name : mod.loading_images ) { + // There may be more than one file matching the name, so we need to get all of them + for( cata_path &img_path : get_files_from_path( img_name, mod.path, true ) ) { + imgs.emplace_back( img_path ); + } + } + } + if( gLUI->chosen_load_img == cata_path() ) { + if( imgs.empty() ) { + gLUI->chosen_load_img = PATH_INFO::gfxdir() / "cdda.png"; //default load screen + } else { + gLUI->chosen_load_img = random_entry( imgs ); + } + } + SDL_Surface_Ptr surf = load_image( gLUI->chosen_load_img.get_unrelative_path().u8string().c_str() ); gLUI->splash_size = { static_cast( surf->w ), static_cast( surf->h ) }; gLUI->splash = CreateTextureFromSurface( get_sdl_renderer(), surf ); gLUI->window_size = gLUI->splash_size + ImVec2{ 0.0f, 2.0f * ImGui::GetTextLineHeightWithSpacing() }; @@ -126,6 +146,9 @@ void loading_ui::show( const std::string &context, const std::string &step ) void loading_ui::done() { if( gLUI != nullptr ) { +#ifdef TILES + gLUI->chosen_load_img = cata_path(); +#endif delete gLUI->ui; delete gLUI->bg; delete gLUI; diff --git a/src/mod_manager.cpp b/src/mod_manager.cpp index 083b0ffcc28f4..579deec2b959d 100644 --- a/src/mod_manager.cpp +++ b/src/mod_manager.cpp @@ -267,6 +267,7 @@ void mod_manager::load_modfile( const JsonObject &jo, const cata_path &path ) assign( jo, "dependencies", modfile.dependencies ); assign( jo, "core", modfile.core ); assign( jo, "obsolete", modfile.obsolete ); + assign( jo, "loading_images", modfile.loading_images ); if( std::find( modfile.dependencies.begin(), modfile.dependencies.end(), modfile.ident ) != modfile.dependencies.end() ) { diff --git a/src/mod_manager.h b/src/mod_manager.h index 96f541645dba1..94b07669fa756 100644 --- a/src/mod_manager.h +++ b/src/mod_manager.h @@ -47,6 +47,9 @@ struct MOD_INFORMATION { */ std::set maintainers; + /** Full filenames (including extension) of any loading screens this mod may have */ + std::set loading_images; + translation description; std::string version;