From ba8ab07b4fe69dd7264031f076beff4f85c9a301 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 11:48:46 +0000 Subject: [PATCH 01/14] Absolute minimum --- data/mods/dda_tutorial/modinfo.json | 25 +++++++++++++++++++++++++ src/main_menu.cpp | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 data/mods/dda_tutorial/modinfo.json diff --git a/data/mods/dda_tutorial/modinfo.json b/data/mods/dda_tutorial/modinfo.json new file mode 100644 index 0000000000000..6ac47ffafb4e2 --- /dev/null +++ b/data/mods/dda_tutorial/modinfo.json @@ -0,0 +1,25 @@ +[ + { + "type": "MOD_INFO", + "id": "dda_tutorial", + "name": "Tutorial", + "description": "Tutorial for Cataclysm-DDA", + "category": "content", + "obsolete": true + }, + { + "type": "GENERIC", + "id": "test_item", + "symbol": ".", + "color": "red", + "name": "test item", + "description": "Just to check the tutorial mod is active.", + "price": "100 USD", + "price_postapoc": "50 USD", + "material": [ "wood" ], + "weight": "5 kg", + "volume": "1 L", + "flags": [ "NO_REPAIR", "FRAGILE_MELEE" ], + "melee_damage": { "bash": 6 } + } +] diff --git a/src/main_menu.cpp b/src/main_menu.cpp index edc2070d5e236..c6368139982f0 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -114,6 +114,7 @@ void demo_ui::run() } static const mod_id MOD_INFORMATION_dda( "dda" ); +static const mod_id MOD_INFORMATION_tutorial( "dda_tutorial" ); enum class main_menu_opts : int { MOTD = 0, @@ -891,6 +892,7 @@ bool main_menu::opening_screen() } world->active_mod_order.clear(); world->active_mod_order.emplace_back( MOD_INFORMATION_dda ); + world->active_mod_order.emplace_back( MOD_INFORMATION_tutorial ); world_generator->set_active_world( world ); try { g->setup(); From 6cadb124109d60a679e2c6913d94435d545c9dbf Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:21:43 +0000 Subject: [PATCH 02/14] Move all the tutorial objects I'm aware of to the mod --- data/json/monsters/misc.json | 21 -- .../overmap_terrain_hardcoded.json | 27 --- data/json/traps.json | 195 ----------------- .../dda_tutorial/mapgen.json} | 0 data/mods/dda_tutorial/modinfo.json | 16 +- data/mods/dda_tutorial/monsters.json | 23 ++ data/mods/dda_tutorial/overmap_terrain.json | 29 +++ .../dda_tutorial/snippets.json} | 0 .../dda_tutorial/specials.json} | 0 data/mods/dda_tutorial/traps.json | 197 ++++++++++++++++++ 10 files changed, 250 insertions(+), 258 deletions(-) rename data/{json/mapgen/tutorial.json => mods/dda_tutorial/mapgen.json} (100%) create mode 100644 data/mods/dda_tutorial/monsters.json create mode 100644 data/mods/dda_tutorial/overmap_terrain.json rename data/{json/snippets/tutorial.json => mods/dda_tutorial/snippets.json} (100%) rename data/{json/overmap/overmap_special/tutorial.json => mods/dda_tutorial/specials.json} (100%) create mode 100644 data/mods/dda_tutorial/traps.json diff --git a/data/json/monsters/misc.json b/data/json/monsters/misc.json index 0ef49fc5ee08a..fc03ed6fc7ace 100644 --- a/data/json/monsters/misc.json +++ b/data/json/monsters/misc.json @@ -403,26 +403,5 @@ "harvest": "exempt", "revert_to_itype": "mannequin_decoy", "flags": [ "IMMOBILE", "NO_BREATHE", "NOT_HALLUCINATION" ] - }, - { - "id": "mon_dummy_tutorial", - "type": "MONSTER", - "name": { "str": "dummy", "str_pl": "dummies" }, - "description": "This dummy serves for only one purpose - to teach players how to hit monsters.", - "looks_like": "f_mannequin", - "default_faction": "", - "species": [ "UNKNOWN" ], - "volume": "62500 ml", - "weight": "81500 g", - "hp": 50, - "speed": 100, - "material": [ "wood" ], - "symbol": "X", - "color": "white", - "melee_damage": [ { "damage_type": "cut", "amount": 0 } ], - "vision_day": 1, - "harvest": "exempt", - "death_function": { "corpse_type": "NO_CORPSE", "message": "The %s is destroyed." }, - "flags": [ "IMMOBILE", "NOT_HALLUCINATION" ] } ] diff --git a/data/json/overmap/overmap_terrain/overmap_terrain_hardcoded.json b/data/json/overmap/overmap_terrain/overmap_terrain_hardcoded.json index 6dfd9c5a6d771..5ddbc40c558c3 100644 --- a/data/json/overmap/overmap_terrain/overmap_terrain_hardcoded.json +++ b/data/json/overmap/overmap_terrain/overmap_terrain_hardcoded.json @@ -181,32 +181,5 @@ "see_cost": "opaque", "travel_cost_type": "impassable", "flags": [ "NO_ROTATE" ] - }, - { - "type": "overmap_terrain", - "id": "tutorial", - "name": "tutorial room", - "sym": "O", - "color": "cyan", - "see_cost": "full_high", - "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] - }, - { - "type": "overmap_terrain", - "id": "tutorial_roof", - "name": "tutorial room", - "sym": "O", - "color": "cyan", - "see_cost": "none", - "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] - }, - { - "type": "overmap_terrain", - "id": "tutorial_underground", - "name": "tutorial room", - "sym": "O", - "color": "cyan", - "see_cost": "full_high", - "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] } ] diff --git a/data/json/traps.json b/data/json/traps.json index 46b60d0db55c1..c3d38ab497c09 100644 --- a/data/json/traps.json +++ b/data/json/traps.json @@ -890,201 +890,6 @@ "benign": true, "funnel_radius": 342 }, - { - "type": "trap", - "id": "tr_tutorial_1", - "name": "look around tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_2", - "name": "movement modes tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_3", - "name": "melee tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_4", - "name": "reach attack tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_5", - "name": "wear items tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_6", - "name": "firearms tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_7", - "name": "inventory tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_8", - "name": "flashlight tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_9", - "name": "water container tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_10", - "name": "remote use tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_11", - "name": "crafting tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_12", - "name": "construction tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_13", - "name": "pain management tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_14", - "name": "throwing tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, - { - "type": "trap", - "id": "tr_tutorial_15", - "name": "tutorial finale", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "benign": true, - "always_invisible": true - }, { "type": "trap", "id": "tr_swirling_vortex", diff --git a/data/json/mapgen/tutorial.json b/data/mods/dda_tutorial/mapgen.json similarity index 100% rename from data/json/mapgen/tutorial.json rename to data/mods/dda_tutorial/mapgen.json diff --git a/data/mods/dda_tutorial/modinfo.json b/data/mods/dda_tutorial/modinfo.json index 6ac47ffafb4e2..990d222df3a3c 100644 --- a/data/mods/dda_tutorial/modinfo.json +++ b/data/mods/dda_tutorial/modinfo.json @@ -5,21 +5,7 @@ "name": "Tutorial", "description": "Tutorial for Cataclysm-DDA", "category": "content", + "//": "Marked as obsolete so it doesn't appear in the mod selection list", "obsolete": true - }, - { - "type": "GENERIC", - "id": "test_item", - "symbol": ".", - "color": "red", - "name": "test item", - "description": "Just to check the tutorial mod is active.", - "price": "100 USD", - "price_postapoc": "50 USD", - "material": [ "wood" ], - "weight": "5 kg", - "volume": "1 L", - "flags": [ "NO_REPAIR", "FRAGILE_MELEE" ], - "melee_damage": { "bash": 6 } } ] diff --git a/data/mods/dda_tutorial/monsters.json b/data/mods/dda_tutorial/monsters.json new file mode 100644 index 0000000000000..5de9c8be2567d --- /dev/null +++ b/data/mods/dda_tutorial/monsters.json @@ -0,0 +1,23 @@ +[ + { + "id": "mon_dummy_tutorial", + "type": "MONSTER", + "name": { "str": "dummy", "str_pl": "dummies" }, + "description": "This dummy serves for only one purpose - to teach players how to hit monsters.", + "looks_like": "f_mannequin", + "default_faction": "", + "species": [ "UNKNOWN" ], + "volume": "62500 ml", + "weight": "81500 g", + "hp": 50, + "speed": 100, + "material": [ "wood" ], + "symbol": "X", + "color": "white", + "melee_damage": [ { "damage_type": "cut", "amount": 0 } ], + "vision_day": 1, + "harvest": "exempt", + "death_function": { "corpse_type": "NO_CORPSE", "message": "The %s is destroyed." }, + "flags": [ "IMMOBILE", "NOT_HALLUCINATION" ] + } +] diff --git a/data/mods/dda_tutorial/overmap_terrain.json b/data/mods/dda_tutorial/overmap_terrain.json new file mode 100644 index 0000000000000..2451adf3a4722 --- /dev/null +++ b/data/mods/dda_tutorial/overmap_terrain.json @@ -0,0 +1,29 @@ +[ + { + "type": "overmap_terrain", + "id": "tutorial", + "name": "tutorial room", + "sym": "O", + "color": "cyan", + "see_cost": "full_high", + "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] + }, + { + "type": "overmap_terrain", + "id": "tutorial_roof", + "name": "tutorial room", + "sym": "O", + "color": "cyan", + "see_cost": "none", + "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] + }, + { + "type": "overmap_terrain", + "id": "tutorial_underground", + "name": "tutorial room", + "sym": "O", + "color": "cyan", + "see_cost": "full_high", + "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] + } +] diff --git a/data/json/snippets/tutorial.json b/data/mods/dda_tutorial/snippets.json similarity index 100% rename from data/json/snippets/tutorial.json rename to data/mods/dda_tutorial/snippets.json diff --git a/data/json/overmap/overmap_special/tutorial.json b/data/mods/dda_tutorial/specials.json similarity index 100% rename from data/json/overmap/overmap_special/tutorial.json rename to data/mods/dda_tutorial/specials.json diff --git a/data/mods/dda_tutorial/traps.json b/data/mods/dda_tutorial/traps.json new file mode 100644 index 0000000000000..8fd9143075b0c --- /dev/null +++ b/data/mods/dda_tutorial/traps.json @@ -0,0 +1,197 @@ +[ + { + "type": "trap", + "id": "tr_tutorial_1", + "name": "look around tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_2", + "name": "movement modes tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_3", + "name": "melee tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_4", + "name": "reach attack tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_5", + "name": "wear items tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_6", + "name": "firearms tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_7", + "name": "inventory tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_8", + "name": "flashlight tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_9", + "name": "water container tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_10", + "name": "remote use tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_11", + "name": "crafting tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_12", + "name": "construction tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_13", + "name": "pain management tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_14", + "name": "throwing tutorial", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + }, + { + "type": "trap", + "id": "tr_tutorial_15", + "name": "tutorial finale", + "color": "white", + "symbol": "x", + "visibility": 99, + "avoidance": 99, + "difficulty": 99, + "action": "none", + "benign": true, + "always_invisible": true + } +] From e2483c01dc401b7b9e132461e0b2bda2bf7d20ae Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:02:48 +0000 Subject: [PATCH 03/14] Remove all other mapgen --- data/mods/dda_tutorial/external_options.json | 65 ++++++++++++++++++++ data/mods/dda_tutorial/region_overlay.json | 12 ++++ data/mods/dda_tutorial/specials.json | 3 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 data/mods/dda_tutorial/external_options.json create mode 100644 data/mods/dda_tutorial/region_overlay.json diff --git a/data/mods/dda_tutorial/external_options.json b/data/mods/dda_tutorial/external_options.json new file mode 100644 index 0000000000000..f05ed55d59840 --- /dev/null +++ b/data/mods/dda_tutorial/external_options.json @@ -0,0 +1,65 @@ +[ + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_POPULATE_OUTSIDE_CONNECTIONS_FROM_NEIGHBORS", + "info": "Allows to populate outside connections from neighbors.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_RIVERS", + "info": "Allows to place procgen rivers during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_LAKES", + "info": "Allows to place procgen lakes during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_FORESTS", + "info": "Allows to place procgen forests during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_SWAMPS", + "info": "Allows to place procgen swamps during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_RAVINES", + "info": "Allows to place procgen ravines during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_CITIES", + "info": "Allows to place cities during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_FOREST_TRAILS", + "info": "Allows to place procgen forest trails during overmap generation.", + "stype": "bool", + "value": false + }, + { + "type": "EXTERNAL_OPTION", + "name": "OVERMAP_PLACE_ROADS", + "info": "Allows to place procgen roads during overmap generation.", + "stype": "bool", + "value": false + } +] \ No newline at end of file diff --git a/data/mods/dda_tutorial/region_overlay.json b/data/mods/dda_tutorial/region_overlay.json new file mode 100644 index 0000000000000..f80544d84bc83 --- /dev/null +++ b/data/mods/dda_tutorial/region_overlay.json @@ -0,0 +1,12 @@ +[ + { + "type": "region_overlay", + "regions": [ "all" ], + "overmap_feature_flag_settings": { + "clear_blacklist": false, + "blacklist": [ ], + "clear_whitelist": false, + "whitelist": [ "TUTORIAL" ] + } + } +] diff --git a/data/mods/dda_tutorial/specials.json b/data/mods/dda_tutorial/specials.json index 54424758eb89c..915f48e5d9448 100644 --- a/data/mods/dda_tutorial/specials.json +++ b/data/mods/dda_tutorial/specials.json @@ -8,6 +8,7 @@ { "point": [ 0, 0, -1 ], "overmap": "tutorial_underground" } ], "locations": [ "land" ], - "occurrences": [ 0, 0 ] + "occurrences": [ 0, 0 ], + "flags": [ "TUTORIAL" ] } ] From 5cdec4b1284b8172471bf14bdfd31effa684493a Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 14:59:28 +0000 Subject: [PATCH 04/14] Add keybind snippet handling to parse_tags --- src/npctalk.cpp | 32 ++++++++++++++++++++++++++++++++ src/output.cpp | 1 + 2 files changed, 33 insertions(+) diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 141c6fa7afce0..b417a27ffa0bb 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -2434,6 +2434,38 @@ void parse_tags( std::string &phrase, const talker &u, const talker &me, const d parse_tags( var, u, me, d, item_type ); // attempt to cast as an item phrase.replace( fa, l, spell_id( var )->description.translated() ); + } else if( tag.find( " + var.pop_back(); + std::string keybind = var; + + //deal with category specific binds like + size_t pos_category_split = var.find( ':' ); + + std::string category = "DEFAULTMODE"; + if( pos_category_split != std::string::npos ) { + category = var.substr( 0, pos_category_split ); + keybind = var.substr( pos_category_split + 1 ); + } + input_context ctxt( category ); + + std::string keybind_desc; + std::vector keys = ctxt.keys_bound_to( keybind, -1, false, false ); + if( keys.empty() ) { // Display description for unbound keys + keybind_desc = colorize( '<' + ctxt.get_desc( keybind ) + '>', c_red ); + + if( !ctxt.is_registered_action( keybind ) ) { + debugmsg( "Keybind specified by is invalid/missing", var ); + } + } else { + keybind_desc = enumerate_as_string( keys.begin(), keys.end(), []( const input_event & k ) { + return colorize( '\'' + k.long_description() + '\'', c_yellow ); + }, enumeration_conjunction::or_ ); + } + + phrase.replace( fa, l, keybind_desc ); } else if( tag.find( "" ) == 0 ) { std::string cityname = "nowhere"; tripoint_abs_sm abs_sub = get_map().get_abs_sub(); diff --git a/src/output.cpp b/src/output.cpp index 507f9af76d621..090e681ac45ee 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -2577,6 +2577,7 @@ void replace_city_tag( std::string &input, const std::string &name ) replace_substring( input, "", name, true ); } +// Legacy, moved to parse_tags void replace_keybind_tag( std::string &input ) { std::string keybind_tag_start = " Date: Wed, 30 Oct 2024 15:00:10 +0000 Subject: [PATCH 05/14] Unhardcode tutorial traps calling snippets --- data/mods/dda_tutorial/snippets.json | 155 +++++++++++------- data/mods/dda_tutorial/traps.json | 227 +++++++++++++++++++++++---- src/gamemode_tutorial.cpp | 29 +--- 3 files changed, 297 insertions(+), 114 deletions(-) diff --git a/data/mods/dda_tutorial/snippets.json b/data/mods/dda_tutorial/snippets.json index a02c4a46d7a1d..b1540714369dc 100644 --- a/data/mods/dda_tutorial/snippets.json +++ b/data/mods/dda_tutorial/snippets.json @@ -1,7 +1,106 @@ [ + { + "type": "snippet", + "category": "LESSON_LOOK", + "text": [ + "You can also use the mouse to see things around you. The Mouse view window will appear on the sidebar, and you'll be able to get information on the terrain, monsters, and items in the world around you. Alternatively, you can press to open the Look Around window." + ] + }, + { + "type": "snippet", + "category": "LESSON_MOVEMENT_MODES", + "text": [ + "Most of the time your character will be walking when you move. But sometimes it's useful to change your movement mode to something else.\n\nThere are four movement modes:\nWalking: default mode, average movement speed, stamina draining speed, and noise\nRunning: move much faster, but will drain your stamina quickly\nCrouching: will make your character less visible to monsters by allowing you to hide behind some obstacles, decreased movement speed and noise\nProne: even less visibility to monsters, even less movement speed and noise\n\nPressing will open the Movement Mode menu, which allows you to switch the mode at any time. There are extra keybindings that can be set to switch to each mode individually for convenience.\n\nTo continue the tutorial, please move to the end of the corridor." + ] + }, + { + "type": "snippet", + "category": "LESSON_MONSTER_SIGHTED", + "text": [ + "There is a dummy standing before you. Let's attack it. To do this, simply move into it.\n\nAfter you've dealt with it, please move to the door behind it." + ] + }, + { + "type": "snippet", + "category": "LESSON_REACH_ATTACK", + "text": [ + "There is another dummy standing behind the counters. Most melee weapons require standing directly adjacent to your target in order to hit it.\n\nFortunately, some long weapons such as spears are able to perform reach attack with a range of 2 or 3, so if you have one, you don't need to climb onto the counters to stand next to the dummy. The steel spear has a range of 2, so you can hit the dummy right over the counters. To use the reach attack, press the key. Once you select your target, press to confirm.\n\nAfter you've dealt with the dummy, please move to the corridor to the south." + ] + }, + { + "type": "snippet", + "category": "LESSON_HOLSTERS_WEAR", + "text": [ + "Always wielding a steel spear in your hands might be inconvenient. Fortunately, there is a spear strap lying on the rack nearby. You can wear it by pressing .\nTo take off any worn item, you can press .\n\nTo continue the tutorial, please wear the spear strap." + ] + }, + { + "type": "snippet", + "category": "LESSON_GUN_LOAD", + "text": [ + "In the next room you'll find a row of racks with a gun, a magazine for it, and ammo for it. To be able to fire a gun, you'll need to insert a magazine with ammo in it. Press to open the Reload item menu and put ammo in the magazine, and then press once again to insert a magazine into a gun.\n\nIf you wish to unload your gun, possibly to change ammunition types, press ." + ] + }, + { + "type": "snippet", + "category": "LESSON_INVENTORY", + "text": [ + "Cataclysm uses a container-based inventory. Putting something into your inventory requires wearing some clothing or container with pockets that are big enough to hold it. The spear strap is one example of such containers. Pockets have finite dimensions, so you can't put an item that has more volume or is longer than a pocket.\n\nTo view your inventory, press . You'll see that you have only your worn clothes, of which only your jeans have 4 small pockets. Select your jeans and press to see their description and amount of pockets. To scroll through the description, press and .\n\nTo continue the tutorial, move to the western rack and wear () the backpack to increase the available capacity of your inventory." + ] + }, + { + "type": "snippet", + "category": "LESSON_FLASHLIGHT", + "text": [ + "There is a flashlight and a light disposable battery lying on the rack. Flashlights are very useful tools as they allow you to see in the dark.\n\nTo continue the tutorial, please reload the flashlight by pressing . Take it with you and move to the stairs." + ] + }, + { + "type": "snippet", + "category": "LESSON_INTERACT", + "text": [ + "There is a water dispenser around the corner. Pick up the plastic bottle from the rack and proceed to the dispenser." + ] + }, + { + "type": "snippet", + "category": "LESSON_REMOTE_USE", + "text": [ + "A flashlight is a good thing to have, but it drains its battery quickly, so it won't last very long. A much better solution for long-lasting lighting is a gasoline lantern. Reload the lantern with gasoline () and then activate it () while standing nearby. A lighter will help you to fire the lantern.\n\nSome tools (such as lamps, dehydrators, bathroom scales etc) don't need to be picked up before activating and allow remote use.\n\nAfter you light the lantern, you can safely turn off your flashlight to conserve its energy; the lit lantern will give you enough light for any actions and will last much longer.\n\nTo continue the tutorial, please light the lantern and then move to the corridor to the east." + ] + }, + { + "type": "snippet", + "category": "LESSON_CRAFTING_FOOD", + "text": [ + "Looks like you're hungry! The hunger status is indicated on the sidebar. Let's make a peanut butter sandwich from peanut butter and crackers on the counter next to the wall.\n\nTo make food, you need to use the Crafting menu. Press to open the menu. Press and to toggle crafting categories and select the FOOD category. From there, select peanut butter sandwich and press to start crafting.\n\nNote that you don't need to stand directly near the counter to be able to craft. The crafting radius is 6 tiles, so while you're standing no farther than 6 tiles from any crafting components and tools, your character is able to still get them in order to use them.\n\nTo continue the tutorial, please craft the peanut butter sandwich and then eat it by pressing ." + ] + }, + { + "type": "snippet", + "category": "LESSON_CONSTRUCTION", + "text": [ + "In the next room, you can find a paint brush and several cans of paint. You can use them to paint the wall in your preferred color. To do this, open the Construction menu by pressing and toggling the categories with and . Find the Decorative category and select one of the options to paint the wall.\n\nTo continue the tutorial, please paint some walls and move further south." + ] + }, + { + "type": "snippet", + "category": "LESSON_THROWING", + "text": [ + "There are 10 baseballs lying on the floor. You might not need all 10, or you might not have enough space in your pockets. To pick up a specific amount of items, press , select the stack of items, and type a number on the keyboard (Multiple numbers can be used for large stacks). Finish the selection with . The cursor should change to a # symbol.\n\nYou can throw a baseball at the dummy in the end of the corridor by pressing .\n\nTo complete the tutorial, throw some baseballs at the dummy and then move to the end of the corridor to the north." + ] + }, + { + "type": "snippet", + "category": "LESSON_FINALE", + "text": [ + "Congratulations! You have completed the tutorial. Here is some last-minute advice.\n\nYou can press to open the Action menu. It provides a convenient way to access various actions.\n\nNot sure what keys you can press in a given menu? Press the to open the Keybindings menu. It allows you to view the existing keybindings and modify them to your liking. Sometimes there will be lesser used or convenience actions without a default keybinding, which you can also set.\n\nYou can continue exploring the tutorial rooms, or you can exit the tutorial by pressing . This will save your game and exit to the main menu." + ] + }, { "type": "snippet", "category": "tutorial_messages", + "//": "These use hardcoded calls", "text": [ { "id": "LESSON_INTRO", @@ -11,14 +110,6 @@ "id": "LESSON_MOVE", "text": "The character in the center of the screen represents you. By default, you can move around using the numpad, vikeys, or the arrow keys.\n\nMovement Controls:\nNorth: \nSouth: \nWest: \nEast: \nNorthwest: \nNortheast: \nSouthwest: \nSoutheast: \nWait in place: \n\nYou can also use to select the location you want to move, and then press it again to confirm the movement.\n\nTo continue the tutorial, please move to the door to the east." }, - { - "id": "LESSON_MOVEMENT_MODES", - "text": "Most of the time your character will be walking when you move. But sometimes it's useful to change your movement mode to something else.\n\nThere are four movement modes:\nWalking: default mode, average movement speed, stamina draining speed, and noise\nRunning: move much faster, but will drain your stamina quickly\nCrouching: will make your character less visible to monsters by allowing you to hide behind some obstacles, decreased movement speed and noise\nProne: even less visibility to monsters, even less movement speed and noise\n\nPressing will open the Movement Mode menu, which allows you to switch the mode at any time. There are extra keybindings that can be set to switch to each mode individually for convenience.\n\nTo continue the tutorial, please move to the end of the corridor." - }, - { - "id": "LESSON_LOOK", - "text": "You can also use the mouse to see things around you. The Mouse view window will appear on the sidebar, and you'll be able to get information on the terrain, monsters, and items in the world around you. Alternatively, you can press to open the Look Around window." - }, { "id": "LESSON_OPEN", "text": "You're standing next to a closed door. To open it, either walk into it, or press and then a movement key. Using will also let you open windows, gates, fences, safes and more." @@ -43,10 +134,6 @@ "id": "LESSON_EXAMINE", "text": "There is a display rack next to you with a steel spear lying on it. You can press to directly wield an item, without the need of picking it up first. Pressing will open the Wield item menu. Select the item you want to wield and confirm by pressing .\n\nAs you have no free space in your inventory, you will have to drop the baseball bat on the ground before you can wield the spear.\n\nIf you wish to free your hands (i.e. wield nothing), press and select your currently wielded item. Alternatively, you could drop the wielded item by pressing and selecting your currently wielded item.\n\nTo continue the tutorial, please wield the spear and move to the counters west of you." }, - { - "id": "LESSON_INTERACT", - "text": "There is a water dispenser around the corner. Pick up the plastic bottle from the rack and proceed to the dispenser." - }, { "id": "LESSON_GOT_ARMOR", "text": "The item you just picked up is a type of clothing! To wear clothing, press and then select an item. To take off clothing, press , or simply take it off and drop it in one action by pressing ." @@ -119,10 +206,6 @@ "id": "LESSON_ACT_BUBBLEWRAP", "text": "This thing here on the floor is a trap. Traps are permanent until set off, and can be an important defensive tactic, particularly when sleeping in unsafe territory. Try stepping on the bubble wrap. Don't worry, it's harmless, but it will make some noise. There are other types of traps that will cause varying amounts of damage or even teleport you, so watch your step carefully." }, - { - "id": "LESSON_GUN_LOAD", - "text": "In the next room you'll find a row of racks with a gun, a magazine for it, and ammo for it. To be able to fire a gun, you'll need to insert a magazine with ammo in it. Press to open the Reload item menu and put ammo in the magazine, and then press once again to insert a magazine into a gun.\n\nIf you wish to unload your gun, possibly to change ammunition types, press ." - }, { "id": "LESSON_GUN_FIRE", "text": "Finally, to fire a gun, press . You'll automatically target the last monster you shot at, or the closest monster to you. You can change your target with the movement keys, or cycle through monsters with and . Select the dummy as a target and press to fire a single shot. With many guns, you can change the fire mode to burst or full auto by pressing .\n\nThere are detailed instructions on how to aim and fire in the Aiming and firing menu, so make sure to check it carefully.\n\nTo continue the tutorial, please fire a couple of times at the dummy and move to the corridor to the west." @@ -147,10 +230,6 @@ "id": "LESSON_PICKUP_WATER", "text": "From a water source like this, you can fill any containers you might have. Examine the dispenser by pressing . Next, press 'c' to fill a container, then select the plastic bottle to put the water into.\n\nThe Examine command () can be used for interacting with many types of terrain and furniture.\n\nTo continue the tutorial, please fill the plastic bottle with water, drink a little of it (by pressing and selecting clean water), and then move to the corridor to the north." }, - { - "id": "LESSON_MONSTER_SIGHTED", - "text": "There is a dummy standing before you. Let's attack it. To do this, simply move into it.\n\nAfter you've dealt with it, please move to the door behind it." - }, { "id": "LESSON_LOCKED_DOOR", "text": "This door is locked. There are several ways to deal with locked doors (lockpicking and prying being the most common), but right now you don't have the necessary tools at hand. Instead, you can simply bash it with your baseball bat by pressing and then selecting the direction.\n\nNote that not every door can be bashed down. Some doors will require more strength than you have or a stronger weapon. If you're not seeing any damage being done after a few swings, an alternative approach might be needed.\n\nTo continue the tutorial, please smash the door." @@ -159,45 +238,9 @@ "id": "LESSON_RESTORE_STAMINA", "text": "Bashing things is hard work that will deplete your stamina. You can see how much stamina you have on the sidebar. The less stamina you have, the slower your movement and most actions will be. To restore stamina, you need only to wait. You can press to open the Wait for how long menu and select the amount of time you want to wait. Select option Wait until you catch your breath to fully restore all lost stamina.\n\nBe careful about doing too many strenuous activities as you will build up your weariness over time, which will stack movement and action penalties on top of your stamina cost. You can watch your Weary Transition in the sidebar as you are performing longer activities to see their effect on your weariness. To reduce your weariness, you just need to rest or do less strenuous activities for a while." }, - { - "id": "LESSON_REACH_ATTACK", - "text": "There is another dummy standing behind the counters. Most melee weapons require standing directly adjacent to your target in order to hit it.\n\nFortunately, some long weapons such as spears are able to perform reach attack with a range of 2 or 3, so if you have one, you don't need to climb onto the counters to stand next to the dummy. The steel spear has a range of 2, so you can hit the dummy right over the counters. To use the reach attack, press the key. Once you select your target, press to confirm.\n\nAfter you've dealt with the dummy, please move to the corridor to the south." - }, - { - "id": "LESSON_HOLSTERS_WEAR", - "text": "Always wielding a steel spear in your hands might be inconvenient. Fortunately, there is a spear strap lying on the rack nearby. You can wear it by pressing .\nTo take off any worn item, you can press .\n\nTo continue the tutorial, please wear the spear strap." - }, { "id": "LESSON_HOLSTERS_ACTIVATE", "text": "You can put the steel spear in the spear strap to free your hands. Press to open the Use item menu, then select the spear strap, then select the spear, and finally press to confirm.\n\nTo continue the tutorial, please put the steel spear in the spear strap and move down the corridor." - }, - { - "id": "LESSON_INVENTORY", - "text": "Cataclysm uses a container-based inventory. Putting something into your inventory requires wearing some clothing or container with pockets that are big enough to hold it. The spear strap is one example of such containers. Pockets have finite dimensions, so you can't put an item that has more volume or is longer than a pocket.\n\nTo view your inventory, press . You'll see that you have only your worn clothes, of which only your jeans have 4 small pockets. Select your jeans and press to see their description and amount of pockets. To scroll through the description, press and .\n\nTo continue the tutorial, move to the western rack and wear () the backpack to increase the available capacity of your inventory." - }, - { - "id": "LESSON_FLASHLIGHT", - "text": "There is a flashlight and a light disposable battery lying on the rack. Flashlights are very useful tools as they allow you to see in the dark.\n\nTo continue the tutorial, please reload the flashlight by pressing . Take it with you and move to the stairs." - }, - { - "id": "LESSON_REMOTE_USE", - "text": "A flashlight is a good thing to have, but it drains its battery quickly, so it won't last very long. A much better solution for long-lasting lighting is a gasoline lantern. Reload the lantern with gasoline () and then activate it () while standing nearby. A lighter will help you to fire the lantern.\n\nSome tools (such as lamps, dehydrators, bathroom scales etc) don't need to be picked up before activating and allow remote use.\n\nAfter you light the lantern, you can safely turn off your flashlight to conserve its energy; the lit lantern will give you enough light for any actions and will last much longer.\n\nTo continue the tutorial, please light the lantern and then move to the corridor to the east." - }, - { - "id": "LESSON_CRAFTING_FOOD", - "text": "Looks like you're hungry! The hunger status is indicated on the sidebar. Let's make a peanut butter sandwich from peanut butter and crackers on the counter next to the wall.\n\nTo make food, you need to use the Crafting menu. Press to open the menu. Press and to toggle crafting categories and select the FOOD category. From there, select peanut butter sandwich and press to start crafting.\n\nNote that you don't need to stand directly near the counter to be able to craft. The crafting radius is 6 tiles, so while you're standing no farther than 6 tiles from any crafting components and tools, your character is able to still get them in order to use them.\n\nTo continue the tutorial, please craft the peanut butter sandwich and then eat it by pressing ." - }, - { - "id": "LESSON_CONSTRUCTION", - "text": "In the next room, you can find a paint brush and several cans of paint. You can use them to paint the wall in your preferred color. To do this, open the Construction menu by pressing and toggling the categories with and . Find the Decorative category and select one of the options to paint the wall.\n\nTo continue the tutorial, please paint some walls and move further south." - }, - { - "id": "LESSON_THROWING", - "text": "There are 10 baseballs lying on the floor. You might not need all 10, or you might not have enough space in your pockets. To pick up a specific amount of items, press , select the stack of items, and type a number on the keyboard (Multiple numbers can be used for large stacks). Finish the selection with . The cursor should change to a # symbol.\n\nYou can throw a baseball at the dummy in the end of the corridor by pressing .\n\nTo complete the tutorial, throw some baseballs at the dummy and then move to the end of the corridor to the north." - }, - { - "id": "LESSON_FINALE", - "text": "Congratulations! You have completed the tutorial. Here is some last-minute advice.\n\nYou can press to open the Action menu. It provides a convenient way to access various actions.\n\nNot sure what keys you can press in a given menu? Press the to open the Keybindings menu. It allows you to view the existing keybindings and modify them to your liking. Sometimes there will be lesser used or convenience actions without a default keybinding, which you can also set.\n\nYou can continue exploring the tutorial rooms, or you can exit the tutorial by pressing . This will save your game and exit to the main menu." } ] } diff --git a/data/mods/dda_tutorial/traps.json b/data/mods/dda_tutorial/traps.json index 8fd9143075b0c..dbe3424c6e545 100644 --- a/data/mods/dda_tutorial/traps.json +++ b/data/mods/dda_tutorial/traps.json @@ -2,16 +2,28 @@ { "type": "trap", "id": "tr_tutorial_1", - "name": "look around tutorial", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, "color": "white", "symbol": "x", "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_LOOK" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_LOOK", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_LOOK" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_LOOK", + "effect": [ { "u_message": "LESSON_LOOK", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_2", @@ -21,10 +33,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_MOVEMENT_MODES" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_MOVEMENT_MODES", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_MOVEMENT_MODES" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_MOVEMENT_MODES", + "effect": [ { "u_message": "LESSON_MOVEMENT_MODES", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_3", @@ -34,10 +58,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_MONSTER_SIGHTED" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_MONSTER_SIGHTED", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_MONSTER_SIGHTED" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_MONSTER_SIGHTED", + "effect": [ { "u_message": "LESSON_MONSTER_SIGHTED", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_4", @@ -47,10 +83,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_REACH_ATTACK" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_REACH_ATTACK", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_REACH_ATTACK" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_REACH_ATTACK", + "effect": [ { "u_message": "LESSON_REACH_ATTACK", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_5", @@ -60,10 +108,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_HOLSTERS_WEAR" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_HOLSTERS_WEAR", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_HOLSTERS_WEAR" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_HOLSTERS_WEAR", + "effect": [ { "u_message": "LESSON_HOLSTERS_WEAR", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_6", @@ -73,10 +133,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_GUN_LOAD" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_GUN_LOAD", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_GUN_LOAD" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_GUN_LOAD", + "effect": [ { "u_message": "LESSON_GUN_LOAD", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_7", @@ -86,10 +158,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_INVENTORY" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_INVENTORY", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_INVENTORY" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_INVENTORY", + "effect": [ { "u_message": "LESSON_INVENTORY", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_8", @@ -99,10 +183,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_FLASHLIGHT" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_FLASHLIGHT", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_FLASHLIGHT" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_FLASHLIGHT", + "effect": [ { "u_message": "LESSON_FLASHLIGHT", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_9", @@ -112,10 +208,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_INTERACT" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_INTERACT", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_INTERACT" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_INTERACT", + "effect": [ { "u_message": "LESSON_INTERACT", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_10", @@ -125,10 +233,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_REMOTE_USE" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_REMOTE_USE", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_REMOTE_USE" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_REMOTE_USE", + "effect": [ { "u_message": "LESSON_REMOTE_USE", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_11", @@ -138,10 +258,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_CRAFTING_FOOD" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_CRAFTING_FOOD", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_CRAFTING_FOOD" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_CRAFTING_FOOD", + "effect": [ { "u_message": "LESSON_CRAFTING_FOOD", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_12", @@ -151,10 +283,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_CONSTRUCTION" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_CONSTRUCTION", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_CONSTRUCTION" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_CONSTRUCTION", + "effect": [ { "u_message": "LESSON_CONSTRUCTION", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_13", @@ -165,7 +309,6 @@ "avoidance": 99, "difficulty": 99, "action": "none", - "benign": true, "always_invisible": true }, { @@ -177,10 +320,22 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_THROWING" }, "always_invisible": true }, + { + "type": "SPELL", + "id": "LESSON_THROWING", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_THROWING" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_THROWING", + "effect": [ { "u_message": "LESSON_THROWING", "popup": true, "snippet": true } ] + }, { "type": "trap", "id": "tr_tutorial_15", @@ -190,8 +345,20 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "none", - "benign": true, + "action": "spell", + "spell_data": { "id": "LESSON_FINALE" }, "always_invisible": true + }, + { + "type": "SPELL", + "id": "LESSON_FINALE", + "name": { "str": "tutorial message", "//~": "NO_I18N" }, + "copy-from": "trap_base", + "effect_str": "EOC_LESSON_FINALE" + }, + { + "type": "effect_on_condition", + "id": "EOC_LESSON_FINALE", + "effect": [ { "u_message": "LESSON_FINALE", "popup": true, "snippet": true } ] } ] diff --git a/src/gamemode_tutorial.cpp b/src/gamemode_tutorial.cpp index 1fa52f03b6bab..2bb9196e81a0a 100644 --- a/src/gamemode_tutorial.cpp +++ b/src/gamemode_tutorial.cpp @@ -264,38 +264,11 @@ void tutorial_game::per_turn() add_message( tut_lesson::LESSON_PICKUP ); } - if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_1 ) { - add_message( tut_lesson::LESSON_LOOK ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_2 ) { - add_message( tut_lesson::LESSON_MOVEMENT_MODES ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_3 ) { - add_message( tut_lesson::LESSON_MONSTER_SIGHTED ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_4 ) { - add_message( tut_lesson::LESSON_REACH_ATTACK ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_5 ) { - add_message( tut_lesson::LESSON_HOLSTERS_WEAR ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_6 ) { - add_message( tut_lesson::LESSON_GUN_LOAD ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_7 ) { - add_message( tut_lesson::LESSON_INVENTORY ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_8 ) { - add_message( tut_lesson::LESSON_FLASHLIGHT ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_9 ) { - add_message( tut_lesson::LESSON_INTERACT ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_10 ) { - add_message( tut_lesson::LESSON_REMOTE_USE ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_11 ) { + if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_11 ) { player_character.set_hunger( 100 ); player_character.stomach.empty(); - add_message( tut_lesson::LESSON_CRAFTING_FOOD ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_12 ) { - add_message( tut_lesson::LESSON_CONSTRUCTION ); } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_13 ) { player_character.set_pain( 20 ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_14 ) { - add_message( tut_lesson::LESSON_THROWING ); - } else if( here.tr_at( player_character.pos_bub() ) == tr_tutorial_15 ) { - add_message( tut_lesson::LESSON_FINALE ); } } From 4efa5ede7d22e5802298468260a293ee3a646d7f Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:16:30 +0000 Subject: [PATCH 06/14] Make more liberal use of copy-from Tweak a couple of load functions to not be mandatory if it's a child --- data/mods/dda_tutorial/traps.json | 158 ++++++------------------------ src/trap.cpp | 12 ++- 2 files changed, 39 insertions(+), 131 deletions(-) diff --git a/data/mods/dda_tutorial/traps.json b/data/mods/dda_tutorial/traps.json index dbe3424c6e545..b55b1e49eefa8 100644 --- a/data/mods/dda_tutorial/traps.json +++ b/data/mods/dda_tutorial/traps.json @@ -8,9 +8,10 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, + "always_invisible": true, + "flags": [ "UNDODGEABLE", "AVATAR_ONLY" ], "action": "spell", - "spell_data": { "id": "LESSON_LOOK" }, - "always_invisible": true + "spell_data": { "id": "LESSON_LOOK" } }, { "type": "SPELL", @@ -27,15 +28,8 @@ { "type": "trap", "id": "tr_tutorial_2", - "name": "movement modes tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_MOVEMENT_MODES" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_MOVEMENT_MODES" } }, { "type": "SPELL", @@ -52,15 +46,8 @@ { "type": "trap", "id": "tr_tutorial_3", - "name": "melee tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_MONSTER_SIGHTED" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_MONSTER_SIGHTED" } }, { "type": "SPELL", @@ -77,15 +64,8 @@ { "type": "trap", "id": "tr_tutorial_4", - "name": "reach attack tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_REACH_ATTACK" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_REACH_ATTACK" } }, { "type": "SPELL", @@ -102,15 +82,8 @@ { "type": "trap", "id": "tr_tutorial_5", - "name": "wear items tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_HOLSTERS_WEAR" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_HOLSTERS_WEAR" } }, { "type": "SPELL", @@ -127,15 +100,8 @@ { "type": "trap", "id": "tr_tutorial_6", - "name": "firearms tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_GUN_LOAD" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_GUN_LOAD" } }, { "type": "SPELL", @@ -152,15 +118,8 @@ { "type": "trap", "id": "tr_tutorial_7", - "name": "inventory tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_INVENTORY" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_INVENTORY" } }, { "type": "SPELL", @@ -177,15 +136,8 @@ { "type": "trap", "id": "tr_tutorial_8", - "name": "flashlight tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_FLASHLIGHT" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_FLASHLIGHT" } }, { "type": "SPELL", @@ -202,15 +154,8 @@ { "type": "trap", "id": "tr_tutorial_9", - "name": "water container tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_INTERACT" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_INTERACT" } }, { "type": "SPELL", @@ -227,15 +172,8 @@ { "type": "trap", "id": "tr_tutorial_10", - "name": "remote use tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_REMOTE_USE" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_REMOTE_USE" } }, { "type": "SPELL", @@ -252,15 +190,8 @@ { "type": "trap", "id": "tr_tutorial_11", - "name": "crafting tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_CRAFTING_FOOD" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_CRAFTING_FOOD" } }, { "type": "SPELL", @@ -277,15 +208,8 @@ { "type": "trap", "id": "tr_tutorial_12", - "name": "construction tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_CONSTRUCTION" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_CONSTRUCTION" } }, { "type": "SPELL", @@ -302,27 +226,14 @@ { "type": "trap", "id": "tr_tutorial_13", - "name": "pain management tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "none", - "always_invisible": true + "copy-from": "tr_tutorial_1", + "action": "none" }, { "type": "trap", "id": "tr_tutorial_14", - "name": "throwing tutorial", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_THROWING" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_THROWING" } }, { "type": "SPELL", @@ -339,15 +250,8 @@ { "type": "trap", "id": "tr_tutorial_15", - "name": "tutorial finale", - "color": "white", - "symbol": "x", - "visibility": 99, - "avoidance": 99, - "difficulty": 99, - "action": "spell", - "spell_data": { "id": "LESSON_FINALE" }, - "always_invisible": true + "copy-from": "tr_tutorial_1", + "spell_data": { "id": "LESSON_FINALE" } }, { "type": "SPELL", diff --git a/src/trap.cpp b/src/trap.cpp index 43e561dac555f..efe206ee8e24b 100644 --- a/src/trap.cpp +++ b/src/trap.cpp @@ -116,8 +116,9 @@ void trap::load( const JsonObject &jo, const std::string_view ) { mandatory( jo, was_loaded, "id", id ); mandatory( jo, was_loaded, "name", name_ ); - if( !assign( jo, "color", color ) ) { - jo.throw_error( "missing mandatory member \"color\"" ); + // TODO: Is there a generic_factory version of this? + if( !assign( jo, "color", color ) && !was_loaded ) { + jo.throw_error( "Missing mandatory member \"color\"" ); } mandatory( jo, was_loaded, "symbol", sym, one_char_symbol_reader ); mandatory( jo, was_loaded, "visibility", visibility ); @@ -141,8 +142,11 @@ void trap::load( const JsonObject &jo, const std::string_view ) optional( jo, was_loaded, "flags", _flags ); optional( jo, was_loaded, "trap_radius", trap_radius, 0 ); // TODO: Is there a generic_factory version of this? - act = trap_function_from_string( jo.get_string( "action" ) ); - + if( jo.has_string( "action" ) ) { + act = trap_function_from_string( jo.get_string( "action" ) ); + } else if( !was_loaded ) { + jo.throw_error( "Missing mandatory member \"action\"" ); + } optional( jo, was_loaded, "map_regen", map_regen, update_mapgen_none ); optional( jo, was_loaded, "benign", benign, false ); optional( jo, was_loaded, "always_invisible", always_invisible, false ); From adc330c2710ab78b8ac914ecd38a4764cdd34bde Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:24:26 +0000 Subject: [PATCH 07/14] Missed an end of file line --- data/mods/dda_tutorial/external_options.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/mods/dda_tutorial/external_options.json b/data/mods/dda_tutorial/external_options.json index f05ed55d59840..2725ff4b9aca6 100644 --- a/data/mods/dda_tutorial/external_options.json +++ b/data/mods/dda_tutorial/external_options.json @@ -62,4 +62,4 @@ "stype": "bool", "value": false } -] \ No newline at end of file +] From 7fcf4d1e00161e250f19ff8f59da1ec64ae6250b Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:05:25 +0000 Subject: [PATCH 08/14] Unobfuscate messages --- data/mods/dda_tutorial/snippets.json | 98 ---------------------------- data/mods/dda_tutorial/traps.json | 98 ++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 112 deletions(-) diff --git a/data/mods/dda_tutorial/snippets.json b/data/mods/dda_tutorial/snippets.json index b1540714369dc..b5352efcf3789 100644 --- a/data/mods/dda_tutorial/snippets.json +++ b/data/mods/dda_tutorial/snippets.json @@ -1,102 +1,4 @@ [ - { - "type": "snippet", - "category": "LESSON_LOOK", - "text": [ - "You can also use the mouse to see things around you. The Mouse view window will appear on the sidebar, and you'll be able to get information on the terrain, monsters, and items in the world around you. Alternatively, you can press to open the Look Around window." - ] - }, - { - "type": "snippet", - "category": "LESSON_MOVEMENT_MODES", - "text": [ - "Most of the time your character will be walking when you move. But sometimes it's useful to change your movement mode to something else.\n\nThere are four movement modes:\nWalking: default mode, average movement speed, stamina draining speed, and noise\nRunning: move much faster, but will drain your stamina quickly\nCrouching: will make your character less visible to monsters by allowing you to hide behind some obstacles, decreased movement speed and noise\nProne: even less visibility to monsters, even less movement speed and noise\n\nPressing will open the Movement Mode menu, which allows you to switch the mode at any time. There are extra keybindings that can be set to switch to each mode individually for convenience.\n\nTo continue the tutorial, please move to the end of the corridor." - ] - }, - { - "type": "snippet", - "category": "LESSON_MONSTER_SIGHTED", - "text": [ - "There is a dummy standing before you. Let's attack it. To do this, simply move into it.\n\nAfter you've dealt with it, please move to the door behind it." - ] - }, - { - "type": "snippet", - "category": "LESSON_REACH_ATTACK", - "text": [ - "There is another dummy standing behind the counters. Most melee weapons require standing directly adjacent to your target in order to hit it.\n\nFortunately, some long weapons such as spears are able to perform reach attack with a range of 2 or 3, so if you have one, you don't need to climb onto the counters to stand next to the dummy. The steel spear has a range of 2, so you can hit the dummy right over the counters. To use the reach attack, press the key. Once you select your target, press to confirm.\n\nAfter you've dealt with the dummy, please move to the corridor to the south." - ] - }, - { - "type": "snippet", - "category": "LESSON_HOLSTERS_WEAR", - "text": [ - "Always wielding a steel spear in your hands might be inconvenient. Fortunately, there is a spear strap lying on the rack nearby. You can wear it by pressing .\nTo take off any worn item, you can press .\n\nTo continue the tutorial, please wear the spear strap." - ] - }, - { - "type": "snippet", - "category": "LESSON_GUN_LOAD", - "text": [ - "In the next room you'll find a row of racks with a gun, a magazine for it, and ammo for it. To be able to fire a gun, you'll need to insert a magazine with ammo in it. Press to open the Reload item menu and put ammo in the magazine, and then press once again to insert a magazine into a gun.\n\nIf you wish to unload your gun, possibly to change ammunition types, press ." - ] - }, - { - "type": "snippet", - "category": "LESSON_INVENTORY", - "text": [ - "Cataclysm uses a container-based inventory. Putting something into your inventory requires wearing some clothing or container with pockets that are big enough to hold it. The spear strap is one example of such containers. Pockets have finite dimensions, so you can't put an item that has more volume or is longer than a pocket.\n\nTo view your inventory, press . You'll see that you have only your worn clothes, of which only your jeans have 4 small pockets. Select your jeans and press to see their description and amount of pockets. To scroll through the description, press and .\n\nTo continue the tutorial, move to the western rack and wear () the backpack to increase the available capacity of your inventory." - ] - }, - { - "type": "snippet", - "category": "LESSON_FLASHLIGHT", - "text": [ - "There is a flashlight and a light disposable battery lying on the rack. Flashlights are very useful tools as they allow you to see in the dark.\n\nTo continue the tutorial, please reload the flashlight by pressing . Take it with you and move to the stairs." - ] - }, - { - "type": "snippet", - "category": "LESSON_INTERACT", - "text": [ - "There is a water dispenser around the corner. Pick up the plastic bottle from the rack and proceed to the dispenser." - ] - }, - { - "type": "snippet", - "category": "LESSON_REMOTE_USE", - "text": [ - "A flashlight is a good thing to have, but it drains its battery quickly, so it won't last very long. A much better solution for long-lasting lighting is a gasoline lantern. Reload the lantern with gasoline () and then activate it () while standing nearby. A lighter will help you to fire the lantern.\n\nSome tools (such as lamps, dehydrators, bathroom scales etc) don't need to be picked up before activating and allow remote use.\n\nAfter you light the lantern, you can safely turn off your flashlight to conserve its energy; the lit lantern will give you enough light for any actions and will last much longer.\n\nTo continue the tutorial, please light the lantern and then move to the corridor to the east." - ] - }, - { - "type": "snippet", - "category": "LESSON_CRAFTING_FOOD", - "text": [ - "Looks like you're hungry! The hunger status is indicated on the sidebar. Let's make a peanut butter sandwich from peanut butter and crackers on the counter next to the wall.\n\nTo make food, you need to use the Crafting menu. Press to open the menu. Press and to toggle crafting categories and select the FOOD category. From there, select peanut butter sandwich and press to start crafting.\n\nNote that you don't need to stand directly near the counter to be able to craft. The crafting radius is 6 tiles, so while you're standing no farther than 6 tiles from any crafting components and tools, your character is able to still get them in order to use them.\n\nTo continue the tutorial, please craft the peanut butter sandwich and then eat it by pressing ." - ] - }, - { - "type": "snippet", - "category": "LESSON_CONSTRUCTION", - "text": [ - "In the next room, you can find a paint brush and several cans of paint. You can use them to paint the wall in your preferred color. To do this, open the Construction menu by pressing and toggling the categories with and . Find the Decorative category and select one of the options to paint the wall.\n\nTo continue the tutorial, please paint some walls and move further south." - ] - }, - { - "type": "snippet", - "category": "LESSON_THROWING", - "text": [ - "There are 10 baseballs lying on the floor. You might not need all 10, or you might not have enough space in your pockets. To pick up a specific amount of items, press , select the stack of items, and type a number on the keyboard (Multiple numbers can be used for large stacks). Finish the selection with . The cursor should change to a # symbol.\n\nYou can throw a baseball at the dummy in the end of the corridor by pressing .\n\nTo complete the tutorial, throw some baseballs at the dummy and then move to the end of the corridor to the north." - ] - }, - { - "type": "snippet", - "category": "LESSON_FINALE", - "text": [ - "Congratulations! You have completed the tutorial. Here is some last-minute advice.\n\nYou can press to open the Action menu. It provides a convenient way to access various actions.\n\nNot sure what keys you can press in a given menu? Press the to open the Keybindings menu. It allows you to view the existing keybindings and modify them to your liking. Sometimes there will be lesser used or convenience actions without a default keybinding, which you can also set.\n\nYou can continue exploring the tutorial rooms, or you can exit the tutorial by pressing . This will save your game and exit to the main menu." - ] - }, { "type": "snippet", "category": "tutorial_messages", diff --git a/data/mods/dda_tutorial/traps.json b/data/mods/dda_tutorial/traps.json index b55b1e49eefa8..ea411fc540a26 100644 --- a/data/mods/dda_tutorial/traps.json +++ b/data/mods/dda_tutorial/traps.json @@ -23,7 +23,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_LOOK", - "effect": [ { "u_message": "LESSON_LOOK", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "You can also use the mouse to see things around you. The Mouse view window will appear on the sidebar, and you'll be able to get information on the terrain, monsters, and items in the world around you. Alternatively, you can press to open the Look Around window.", + "popup": true + } + ] }, { "type": "trap", @@ -41,7 +46,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_MOVEMENT_MODES", - "effect": [ { "u_message": "LESSON_MOVEMENT_MODES", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "Most of the time your character will be walking when you move. But sometimes it's useful to change your movement mode to something else.\n\nThere are four movement modes:\nWalking: default mode, average movement speed, stamina draining speed, and noise\nRunning: move much faster, but will drain your stamina quickly\nCrouching: will make your character less visible to monsters by allowing you to hide behind some obstacles, decreased movement speed and noise\nProne: even less visibility to monsters, even less movement speed and noise\n\nPressing will open the Movement Mode menu, which allows you to switch the mode at any time. There are extra keybindings that can be set to switch to each mode individually for convenience.\n\nTo continue the tutorial, please move to the end of the corridor.", + "popup": true + } + ] }, { "type": "trap", @@ -59,7 +69,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_MONSTER_SIGHTED", - "effect": [ { "u_message": "LESSON_MONSTER_SIGHTED", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "There is a dummy standing before you. Let's attack it. To do this, simply move into it.\n\nAfter you've dealt with it, please move to the door behind it.", + "popup": true + } + ] }, { "type": "trap", @@ -77,7 +92,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_REACH_ATTACK", - "effect": [ { "u_message": "LESSON_REACH_ATTACK", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "There is another dummy standing behind the counters. Most melee weapons require standing directly adjacent to your target in order to hit it.\n\nFortunately, some long weapons such as spears are able to perform reach attack with a range of 2 or 3, so if you have one, you don't need to climb onto the counters to stand next to the dummy. The steel spear has a range of 2, so you can hit the dummy right over the counters. To use the reach attack, press the key. Once you select your target, press to confirm.\n\nAfter you've dealt with the dummy, please move to the corridor to the south.", + "popup": true + } + ] }, { "type": "trap", @@ -95,7 +115,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_HOLSTERS_WEAR", - "effect": [ { "u_message": "LESSON_HOLSTERS_WEAR", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "Always wielding a steel spear in your hands might be inconvenient. Fortunately, there is a spear strap lying on the rack nearby. You can wear it by pressing .\nTo take off any worn item, you can press .\n\nTo continue the tutorial, please wear the spear strap.", + "popup": true + } + ] }, { "type": "trap", @@ -113,7 +138,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_GUN_LOAD", - "effect": [ { "u_message": "LESSON_GUN_LOAD", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "In the next room you'll find a row of racks with a gun, a magazine for it, and ammo for it. To be able to fire a gun, you'll need to insert a magazine with ammo in it. Press to open the Reload item menu and put ammo in the magazine, and then press once again to insert a magazine into a gun.\n\nIf you wish to unload your gun, possibly to change ammunition types, press .", + "popup": true + } + ] }, { "type": "trap", @@ -131,7 +161,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_INVENTORY", - "effect": [ { "u_message": "LESSON_INVENTORY", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "Cataclysm uses a container-based inventory. Putting something into your inventory requires wearing some clothing or container with pockets that are big enough to hold it. The spear strap is one example of such containers. Pockets have finite dimensions, so you can't put an item that has more volume or is longer than a pocket.\n\nTo view your inventory, press . You'll see that you have only your worn clothes, of which only your jeans have 4 small pockets. Select your jeans and press to see their description and amount of pockets. To scroll through the description, press and .\n\nTo continue the tutorial, move to the western rack and wear () the backpack to increase the available capacity of your inventory.", + "popup": true + } + ] }, { "type": "trap", @@ -149,7 +184,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_FLASHLIGHT", - "effect": [ { "u_message": "LESSON_FLASHLIGHT", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "There is a flashlight and a light disposable battery lying on the rack. Flashlights are very useful tools as they allow you to see in the dark.\n\nTo continue the tutorial, please reload the flashlight by pressing . Take it with you and move to the stairs.", + "popup": true + } + ] }, { "type": "trap", @@ -167,7 +207,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_INTERACT", - "effect": [ { "u_message": "LESSON_INTERACT", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "There is a water dispenser around the corner. Pick up the plastic bottle from the rack and proceed to the dispenser.", + "popup": true + } + ] }, { "type": "trap", @@ -185,7 +230,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_REMOTE_USE", - "effect": [ { "u_message": "LESSON_REMOTE_USE", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "A flashlight is a good thing to have, but it drains its battery quickly, so it won't last very long. A much better solution for long-lasting lighting is a gasoline lantern. Reload the lantern with gasoline () and then activate it () while standing nearby. A lighter will help you to fire the lantern.\n\nSome tools (such as lamps, dehydrators, bathroom scales etc) don't need to be picked up before activating and allow remote use.\n\nAfter you light the lantern, you can safely turn off your flashlight to conserve its energy; the lit lantern will give you enough light for any actions and will last much longer.\n\nTo continue the tutorial, please light the lantern and then move to the corridor to the east.", + "popup": true + } + ] }, { "type": "trap", @@ -203,7 +253,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_CRAFTING_FOOD", - "effect": [ { "u_message": "LESSON_CRAFTING_FOOD", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "Looks like you're hungry! The hunger status is indicated on the sidebar. Let's make a peanut butter sandwich from peanut butter and crackers on the counter next to the wall.\n\nTo make food, you need to use the Crafting menu. Press to open the menu. Press and to toggle crafting categories and select the FOOD category. From there, select peanut butter sandwich and press to start crafting.\n\nNote that you don't need to stand directly near the counter to be able to craft. The crafting radius is 6 tiles, so while you're standing no farther than 6 tiles from any crafting components and tools, your character is able to still get them in order to use them.\n\nTo continue the tutorial, please craft the peanut butter sandwich and then eat it by pressing .", + "popup": true + } + ] }, { "type": "trap", @@ -221,7 +276,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_CONSTRUCTION", - "effect": [ { "u_message": "LESSON_CONSTRUCTION", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "In the next room, you can find a paint brush and several cans of paint. You can use them to paint the wall in your preferred color. To do this, open the Construction menu by pressing and toggling the categories with and . Find the Decorative category and select one of the options to paint the wall.\n\nTo continue the tutorial, please paint some walls and move further south.", + "popup": true + } + ] }, { "type": "trap", @@ -245,7 +305,12 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_THROWING", - "effect": [ { "u_message": "LESSON_THROWING", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "There are 10 baseballs lying on the floor. You might not need all 10, or you might not have enough space in your pockets. To pick up a specific amount of items, press , select the stack of items, and type a number on the keyboard (Multiple numbers can be used for large stacks). Finish the selection with . The cursor should change to a # symbol.\n\nYou can throw a baseball at the dummy in the end of the corridor by pressing .\n\nTo complete the tutorial, throw some baseballs at the dummy and then move to the end of the corridor to the north.", + "popup": true + } + ] }, { "type": "trap", @@ -263,6 +328,11 @@ { "type": "effect_on_condition", "id": "EOC_LESSON_FINALE", - "effect": [ { "u_message": "LESSON_FINALE", "popup": true, "snippet": true } ] + "effect": [ + { + "u_message": "Congratulations! You have completed the tutorial. Here is some last-minute advice.\n\nYou can press to open the Action menu. It provides a convenient way to access various actions.\n\nNot sure what keys you can press in a given menu? Press the to open the Keybindings menu. It allows you to view the existing keybindings and modify them to your liking. Sometimes there will be lesser used or convenience actions without a default keybinding, which you can also set.\n\nYou can continue exploring the tutorial rooms, or you can exit the tutorial by pressing . This will save your game and exit to the main menu.", + "popup": true + } + ] } ] From 1eb9dcf7fcbf99ac4a0dee129c93dd633eddd571 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 16:46:55 +0000 Subject: [PATCH 09/14] Allow u_/npc_message popups to use a popup flag I think the C++ allows using multiple flags at once but that implementing that seems overly complicated until someone has a want for it --- data/mods/dda_tutorial/traps.json | 42 ++++++++++++++++++++----------- doc/EFFECT_ON_CONDITION.md | 11 ++++++++ src/npctalk.cpp | 8 +++--- src/output.cpp | 12 +++++++++ src/output.h | 4 ++- 5 files changed, 59 insertions(+), 18 deletions(-) diff --git a/data/mods/dda_tutorial/traps.json b/data/mods/dda_tutorial/traps.json index ea411fc540a26..f03fd0d37e7ae 100644 --- a/data/mods/dda_tutorial/traps.json +++ b/data/mods/dda_tutorial/traps.json @@ -26,7 +26,8 @@ "effect": [ { "u_message": "You can also use the mouse to see things around you. The Mouse view window will appear on the sidebar, and you'll be able to get information on the terrain, monsters, and items in the world around you. Alternatively, you can press to open the Look Around window.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -49,7 +50,8 @@ "effect": [ { "u_message": "Most of the time your character will be walking when you move. But sometimes it's useful to change your movement mode to something else.\n\nThere are four movement modes:\nWalking: default mode, average movement speed, stamina draining speed, and noise\nRunning: move much faster, but will drain your stamina quickly\nCrouching: will make your character less visible to monsters by allowing you to hide behind some obstacles, decreased movement speed and noise\nProne: even less visibility to monsters, even less movement speed and noise\n\nPressing will open the Movement Mode menu, which allows you to switch the mode at any time. There are extra keybindings that can be set to switch to each mode individually for convenience.\n\nTo continue the tutorial, please move to the end of the corridor.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -72,7 +74,8 @@ "effect": [ { "u_message": "There is a dummy standing before you. Let's attack it. To do this, simply move into it.\n\nAfter you've dealt with it, please move to the door behind it.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -95,7 +98,8 @@ "effect": [ { "u_message": "There is another dummy standing behind the counters. Most melee weapons require standing directly adjacent to your target in order to hit it.\n\nFortunately, some long weapons such as spears are able to perform reach attack with a range of 2 or 3, so if you have one, you don't need to climb onto the counters to stand next to the dummy. The steel spear has a range of 2, so you can hit the dummy right over the counters. To use the reach attack, press the key. Once you select your target, press to confirm.\n\nAfter you've dealt with the dummy, please move to the corridor to the south.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -118,7 +122,8 @@ "effect": [ { "u_message": "Always wielding a steel spear in your hands might be inconvenient. Fortunately, there is a spear strap lying on the rack nearby. You can wear it by pressing .\nTo take off any worn item, you can press .\n\nTo continue the tutorial, please wear the spear strap.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -141,7 +146,8 @@ "effect": [ { "u_message": "In the next room you'll find a row of racks with a gun, a magazine for it, and ammo for it. To be able to fire a gun, you'll need to insert a magazine with ammo in it. Press to open the Reload item menu and put ammo in the magazine, and then press once again to insert a magazine into a gun.\n\nIf you wish to unload your gun, possibly to change ammunition types, press .", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -164,7 +170,8 @@ "effect": [ { "u_message": "Cataclysm uses a container-based inventory. Putting something into your inventory requires wearing some clothing or container with pockets that are big enough to hold it. The spear strap is one example of such containers. Pockets have finite dimensions, so you can't put an item that has more volume or is longer than a pocket.\n\nTo view your inventory, press . You'll see that you have only your worn clothes, of which only your jeans have 4 small pockets. Select your jeans and press to see their description and amount of pockets. To scroll through the description, press and .\n\nTo continue the tutorial, move to the western rack and wear () the backpack to increase the available capacity of your inventory.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -187,7 +194,8 @@ "effect": [ { "u_message": "There is a flashlight and a light disposable battery lying on the rack. Flashlights are very useful tools as they allow you to see in the dark.\n\nTo continue the tutorial, please reload the flashlight by pressing . Take it with you and move to the stairs.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -210,7 +218,8 @@ "effect": [ { "u_message": "There is a water dispenser around the corner. Pick up the plastic bottle from the rack and proceed to the dispenser.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -233,7 +242,8 @@ "effect": [ { "u_message": "A flashlight is a good thing to have, but it drains its battery quickly, so it won't last very long. A much better solution for long-lasting lighting is a gasoline lantern. Reload the lantern with gasoline () and then activate it () while standing nearby. A lighter will help you to fire the lantern.\n\nSome tools (such as lamps, dehydrators, bathroom scales etc) don't need to be picked up before activating and allow remote use.\n\nAfter you light the lantern, you can safely turn off your flashlight to conserve its energy; the lit lantern will give you enough light for any actions and will last much longer.\n\nTo continue the tutorial, please light the lantern and then move to the corridor to the east.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -256,7 +266,8 @@ "effect": [ { "u_message": "Looks like you're hungry! The hunger status is indicated on the sidebar. Let's make a peanut butter sandwich from peanut butter and crackers on the counter next to the wall.\n\nTo make food, you need to use the Crafting menu. Press to open the menu. Press and to toggle crafting categories and select the FOOD category. From there, select peanut butter sandwich and press to start crafting.\n\nNote that you don't need to stand directly near the counter to be able to craft. The crafting radius is 6 tiles, so while you're standing no farther than 6 tiles from any crafting components and tools, your character is able to still get them in order to use them.\n\nTo continue the tutorial, please craft the peanut butter sandwich and then eat it by pressing .", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -279,7 +290,8 @@ "effect": [ { "u_message": "In the next room, you can find a paint brush and several cans of paint. You can use them to paint the wall in your preferred color. To do this, open the Construction menu by pressing and toggling the categories with and . Find the Decorative category and select one of the options to paint the wall.\n\nTo continue the tutorial, please paint some walls and move further south.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -308,7 +320,8 @@ "effect": [ { "u_message": "There are 10 baseballs lying on the floor. You might not need all 10, or you might not have enough space in your pockets. To pick up a specific amount of items, press , select the stack of items, and type a number on the keyboard (Multiple numbers can be used for large stacks). Finish the selection with . The cursor should change to a # symbol.\n\nYou can throw a baseball at the dummy in the end of the corridor by pressing .\n\nTo complete the tutorial, throw some baseballs at the dummy and then move to the end of the corridor to the north.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] }, @@ -331,7 +344,8 @@ "effect": [ { "u_message": "Congratulations! You have completed the tutorial. Here is some last-minute advice.\n\nYou can press to open the Action menu. It provides a convenient way to access various actions.\n\nNot sure what keys you can press in a given menu? Press the to open the Keybindings menu. It allows you to view the existing keybindings and modify them to your liking. Sometimes there will be lesser used or convenience actions without a default keybinding, which you can also set.\n\nYou can continue exploring the tutorial rooms, or you can exit the tutorial by pressing . This will save your game and exit to the main menu.", - "popup": true + "popup": true, + "popup_flag": "PF_ON_TOP" } ] } diff --git a/doc/EFFECT_ON_CONDITION.md b/doc/EFFECT_ON_CONDITION.md index c8b12364cd885..8ce7986e42930 100644 --- a/doc/EFFECT_ON_CONDITION.md +++ b/doc/EFFECT_ON_CONDITION.md @@ -3759,6 +3759,7 @@ Display a text message in the log. `u_message` and `npc_message` display a mess | "snippet" | optional | boolean | default false; if true, the effect instead display a random snippet from `u_message` | | "same_snippet" | optional | boolean | default false; if true, and `snippet` is true, it will connect the talker and snippet, and will always provide the same snippet, if used by this talker; require snippets to have id's set | | "popup" | optional | boolean | default false; if true, the message would generate a popup with `u_message` | +| "popup_flag" | optional | string | default PF_NONE; if specified, the popup is modified by the specified flag, for allowed values see below | | "popup_w_interrupt_query" | optional | boolean | default false; if true, and `popup` is true, the popup will interrupt any activity to send a message | | "interrupt_type" | optional | boolean | default is "neutral"; `distraction_type`, that would be used to interrupt, one that used in distraction manager; full list exist inactivity_type.cpp | @@ -3768,6 +3769,11 @@ Display a text message in the log. `u_message` and `npc_message` display a mess | ------ | --------- | --------- | ---- | ------- | --- | | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | +##### popup_flag +`PF_GET_KEY` - Cancels the popup on any user input as opposed to being limited to Return, Space and Escape. +`PF_ON_TOP` - Makes the window appear on the top of the screen (at the upper most row). Without this flag, the popup is centered on the screen. +`PF_FULLSCREEN` makes the window have a size of `FULL_SCREEN_WIDTH` by `FULL_SCREEN_HEIGHT`. The `FULL_SCREEN` part is a misnomer from legacy code as the popup is not actually full-screen. + ##### Examples Send a red-colored `Bad json! Bad!` message in the log ```json @@ -3779,6 +3785,11 @@ Print a snippet from `local_files_simple`, and popup it. The snippet is always t { "u_message": "local_files_simple", "snippet": true, "same_snippet": true, "popup": true } ``` +Print `uninvasive text` as a centre aligned popup at the top of the screen. +```json + { "u_message": "uninvasive text", "popup": true, "popup_flag": "PF_ON_TOP" } +``` + Print a text with a context variable ```json { "u_message": "Test event with trait_id FIRE! ", "type": "good" } diff --git a/src/npctalk.cpp b/src/npctalk.cpp index b417a27ffa0bb..46f5bab5f0c5c 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -4764,6 +4764,8 @@ talk_effect_fun_t::func f_message( const JsonObject &jo, std::string_view member const bool sound = jo.get_bool( "sound", false ); const bool popup_msg = jo.get_bool( "popup", false ); const bool popup_w_interrupt_query_msg = jo.get_bool( "popup_w_interrupt_query", false ); + const PopupFlags popup_flag = jo.has_member( "popup_flag" ) ? + popup_flag_from_string( jo.get_string( "popup_flag" ) ) : PF_NONE; str_or_var interrupt_type; if( jo.has_member( "interrupt_type" ) ) { interrupt_type = get_str_or_var( jo.get_member( "interrupt_type" ), "interrupt_type", true ); @@ -4777,8 +4779,8 @@ talk_effect_fun_t::func f_message( const JsonObject &jo, std::string_view member } else { type_string.str_val = "neutral"; } - return [snip_id, message, outdoor_only, sound, snippet, same_snippet, type_string, - popup_msg, popup_w_interrupt_query_msg, interrupt_type, global, is_npc] + return [snip_id, message, outdoor_only, sound, snippet, same_snippet, type_string, popup_msg, + popup_w_interrupt_query_msg, popup_flag, interrupt_type, global, is_npc] ( dialogue const & d ) { Character const *target; if( global ) { @@ -4850,7 +4852,7 @@ talk_effect_fun_t::func f_message( const JsonObject &jo, std::string_view member } } if( popup_msg ) { - popup( translated_message ); + popup( translated_message, popup_flag ); g->cancel_activity_or_ignore_query( distraction_type::eoc, "" ); } if( popup_w_interrupt_query_msg ) { diff --git a/src/output.cpp b/src/output.cpp index 090e681ac45ee..ad9d01a51da88 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -908,6 +908,18 @@ std::vector get_hotkeys( const std::string_view s ) return hotkeys; } +PopupFlags popup_flag_from_string( const std::string str ) +{ + if( str == "PF_GET_KEY" ) { + return PF_GET_KEY; + } else if( str == "PF_ON_TOP" ) { + return PF_ON_TOP; + } else if( str == "PF_FULLSCREEN" ) { + return PF_FULLSCREEN; + } + return PF_NONE; +} + int popup( const std::string &text, PopupFlags flags ) { #if defined(__ANDROID__) diff --git a/src/output.h b/src/output.h index 05239be551cc3..50d937b3a2513 100644 --- a/src/output.h +++ b/src/output.h @@ -483,7 +483,7 @@ std::vector get_hotkeys( std::string_view s ); * * The message is a printf-like string. It may contain @ref color_tags, which are used while printing. * - * - PF_GET_KEY (ignored when combined with PF_NO_WAIT) cancels the popup on *any* user input. + * - PF_GET_KEY cancels the popup on *any* user input. * Without the flag the popup is only canceled when the user enters new-line, Space and Escape. * This flag is passed by @ref popup_getkey. * - PF_ON_TOP makes the window appear on the top of the screen (at the upper most row). Without @@ -503,6 +503,8 @@ enum PopupFlags { PF_FULLSCREEN = 1 << 3, }; +PopupFlags popup_flag_from_string( const std::string str ); + template inline int popup_getkey( const char *const mes, Args &&... args ) { From d7274ebc8b5fa951f665da6007c86eea46ed4d15 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:17:07 +0000 Subject: [PATCH 10/14] Lint --- data/mods/dda_tutorial/region_overlay.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/data/mods/dda_tutorial/region_overlay.json b/data/mods/dda_tutorial/region_overlay.json index f80544d84bc83..1ed80be6b68cf 100644 --- a/data/mods/dda_tutorial/region_overlay.json +++ b/data/mods/dda_tutorial/region_overlay.json @@ -2,11 +2,6 @@ { "type": "region_overlay", "regions": [ "all" ], - "overmap_feature_flag_settings": { - "clear_blacklist": false, - "blacklist": [ ], - "clear_whitelist": false, - "whitelist": [ "TUTORIAL" ] - } + "overmap_feature_flag_settings": { "clear_blacklist": false, "blacklist": [ ], "clear_whitelist": false, "whitelist": [ "TUTORIAL" ] } } ] From a4a752fa907f977b2b233fb5721f193e97f46a43 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:55:53 +0000 Subject: [PATCH 11/14] Add a tutorial label and remove the mod label from such changes Hopefully this syntax is correct I forget which labeller we use --- .github/labeler.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/labeler.yml b/.github/labeler.yml index 1dc93de326668..c0ee26dc91d16 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -279,8 +279,7 @@ - data/mods/Isolation-Protocol/**/* "Mods": - - any: [ 'data/mods/**' ] - all: [ '!data/mods/TEST_DATA/**' ] + - all: [ 'data/mods/**', '!data/mods/TEST_DATA/**', '!data/mods/dda/**', '!data/mods/dda_tutorial/**' ] "Mechanics: Enchantments / Spells": - "**/**enchantment**" @@ -301,6 +300,9 @@ "Mods: Defense Mode": - "data/mods/Defense_Mode/**" +"Tutorial": + - "data/mods/dda_tutorial/**" + "ImGui": - "src/third-party/imgui/**" - "src/third-party/imtui/**" From 61e48e836ae4304c903a1bd7278f1526ea7b5595 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:58:04 +0000 Subject: [PATCH 12/14] Remove string extractors expectation for traps name not to be copied --- lang/string_extractor/parsers/trap.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lang/string_extractor/parsers/trap.py b/lang/string_extractor/parsers/trap.py index 989f21af42724..62424d5186c93 100644 --- a/lang/string_extractor/parsers/trap.py +++ b/lang/string_extractor/parsers/trap.py @@ -2,25 +2,26 @@ def parse_trap(json, origin): - name = json["name"] - write_text(name, origin, comment="Name of a trap") + id = json["id"] + if "name" in json: + write_text(json["name"], origin, comment="Name of a trap") if "vehicle_data" in json and "sound" in json["vehicle_data"]: write_text(json["vehicle_data"]["sound"], origin, comment="Trap-vehicle collision message for trap '{}'" - .format(name)) + .format(id)) for key in ["memorial_male", "memorial_female"]: if key in json: write_text(json[key], origin, - comment="Memorial message of trap \"{}\"".format(name)) + comment="Memorial message of trap \"{}\"".format(id)) if "trigger_message_u" in json: write_text(json["trigger_message_u"], origin, comment="Message when player triggers trap \"{}\"" - .format(name)) + .format(id)) if "trigger_message_npc" in json: write_text(json["trigger_message_npc"], origin, comment="Message when NPC triggers trap \"{}\"" - .format(name)) + .format(id)) From 02dcad491382d181dfb6544122202646fe73b362 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sat, 2 Nov 2024 19:11:42 +0000 Subject: [PATCH 13/14] Appease our clang overlords --- src/gamemode_tutorial.cpp | 13 ------------- src/main_menu.cpp | 4 ++-- src/output.cpp | 2 +- src/output.h | 2 +- 4 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/gamemode_tutorial.cpp b/src/gamemode_tutorial.cpp index 2bb9196e81a0a..e3896121c21f4 100644 --- a/src/gamemode_tutorial.cpp +++ b/src/gamemode_tutorial.cpp @@ -50,21 +50,8 @@ static const ter_str_id ter_t_water_dispenser( "t_water_dispenser" ); static const ter_str_id ter_t_window( "t_window" ); static const trap_str_id tr_bubblewrap( "tr_bubblewrap" ); -static const trap_str_id tr_tutorial_1( "tr_tutorial_1" ); -static const trap_str_id tr_tutorial_10( "tr_tutorial_10" ); static const trap_str_id tr_tutorial_11( "tr_tutorial_11" ); -static const trap_str_id tr_tutorial_12( "tr_tutorial_12" ); static const trap_str_id tr_tutorial_13( "tr_tutorial_13" ); -static const trap_str_id tr_tutorial_14( "tr_tutorial_14" ); -static const trap_str_id tr_tutorial_15( "tr_tutorial_15" ); -static const trap_str_id tr_tutorial_2( "tr_tutorial_2" ); -static const trap_str_id tr_tutorial_3( "tr_tutorial_3" ); -static const trap_str_id tr_tutorial_4( "tr_tutorial_4" ); -static const trap_str_id tr_tutorial_5( "tr_tutorial_5" ); -static const trap_str_id tr_tutorial_6( "tr_tutorial_6" ); -static const trap_str_id tr_tutorial_7( "tr_tutorial_7" ); -static const trap_str_id tr_tutorial_8( "tr_tutorial_8" ); -static const trap_str_id tr_tutorial_9( "tr_tutorial_9" ); namespace io { diff --git a/src/main_menu.cpp b/src/main_menu.cpp index c6368139982f0..f747c4d376398 100644 --- a/src/main_menu.cpp +++ b/src/main_menu.cpp @@ -114,7 +114,7 @@ void demo_ui::run() } static const mod_id MOD_INFORMATION_dda( "dda" ); -static const mod_id MOD_INFORMATION_tutorial( "dda_tutorial" ); +static const mod_id MOD_INFORMATION_dda_tutorial( "dda_tutorial" ); enum class main_menu_opts : int { MOTD = 0, @@ -892,7 +892,7 @@ bool main_menu::opening_screen() } world->active_mod_order.clear(); world->active_mod_order.emplace_back( MOD_INFORMATION_dda ); - world->active_mod_order.emplace_back( MOD_INFORMATION_tutorial ); + world->active_mod_order.emplace_back( MOD_INFORMATION_dda_tutorial ); world_generator->set_active_world( world ); try { g->setup(); diff --git a/src/output.cpp b/src/output.cpp index ad9d01a51da88..5d745602683f6 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -908,7 +908,7 @@ std::vector get_hotkeys( const std::string_view s ) return hotkeys; } -PopupFlags popup_flag_from_string( const std::string str ) +PopupFlags popup_flag_from_string( const std::string &str ) { if( str == "PF_GET_KEY" ) { return PF_GET_KEY; diff --git a/src/output.h b/src/output.h index 50d937b3a2513..5cb1e43c633a5 100644 --- a/src/output.h +++ b/src/output.h @@ -503,7 +503,7 @@ enum PopupFlags { PF_FULLSCREEN = 1 << 3, }; -PopupFlags popup_flag_from_string( const std::string str ); +PopupFlags popup_flag_from_string( const std::string &str ); template inline int popup_getkey( const char *const mes, Args &&... args ) From 2d88b84c4d9220c676931d0079f7c2167d3da26e Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Sun, 3 Nov 2024 14:44:37 +0000 Subject: [PATCH 14/14] Remove alt_map_key override that wasn't even doing anything even ignoring that the map is irrelevant in the current tutorial --- data/mods/alt_map_key/overmap_terrain.json | 8 -------- data/mods/dda_tutorial/overmap_terrain.json | 18 +++--------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/data/mods/alt_map_key/overmap_terrain.json b/data/mods/alt_map_key/overmap_terrain.json index dba29b8265404..c6db38a85ecc3 100644 --- a/data/mods/alt_map_key/overmap_terrain.json +++ b/data/mods/alt_map_key/overmap_terrain.json @@ -2166,14 +2166,6 @@ "sym": "O", "color": "red" }, - { - "type": "overmap_terrain", - "id": "tutorial", - "copy-from": "tutorial", - "name": "tutorial room", - "sym": "O", - "color": "cyan" - }, { "type": "overmap_terrain", "id": "mall_a_1", diff --git a/data/mods/dda_tutorial/overmap_terrain.json b/data/mods/dda_tutorial/overmap_terrain.json index 2451adf3a4722..37546d48ca106 100644 --- a/data/mods/dda_tutorial/overmap_terrain.json +++ b/data/mods/dda_tutorial/overmap_terrain.json @@ -1,7 +1,7 @@ [ { "type": "overmap_terrain", - "id": "tutorial", + "id": [ "tutorial", "tutorial_underground" ], "name": "tutorial room", "sym": "O", "color": "cyan", @@ -11,19 +11,7 @@ { "type": "overmap_terrain", "id": "tutorial_roof", - "name": "tutorial room", - "sym": "O", - "color": "cyan", - "see_cost": "none", - "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] - }, - { - "type": "overmap_terrain", - "id": "tutorial_underground", - "name": "tutorial room", - "sym": "O", - "color": "cyan", - "see_cost": "full_high", - "flags": [ "NO_ROTATE", "SHOULD_NOT_SPAWN" ] + "copy-from": "tutorial", + "see_cost": "none" } ]