diff --git a/data/json/effects_on_condition/example_eocs.json b/data/json/effects_on_condition/example_eocs.json index db0c5c823fd76..80cbba03bdf6c 100644 --- a/data/json/effects_on_condition/example_eocs.json +++ b/data/json/effects_on_condition/example_eocs.json @@ -3,12 +3,16 @@ "type": "effect_on_condition", "id": "EOC_selector_test", "effect": [ + { "set_string_var": "EOC Selector Test", "target_var": { "context_val": "title" } }, + { "set_string_var": "name_3", "target_var": { "context_val": "name" } }, + { "set_string_var": "option 3", "target_var": { "context_val": "description" } }, { "run_eoc_selector": [ "EOC_selector_test_1", "EOC_selector_test_2", "EOC_selector_test_3", "EOC_selector_test_4" ], - "names": [ "name_1", "name_2", "name_3", "should_fail" ], + "names": [ "name_1", "name_2", "", "should_fail" ], "keys": [ "a", "b", "c", "d" ], - "descriptions": [ "option 1", "option 2", "option 3", "should not be available" ], + "descriptions": [ "option 1", "option 2", "", "should not be available" ], "variables": [ { "val": "8" } ], + "title": "", "allow_cancel": true } ] diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 4d2fd1e972e54..9533f71a5fba1 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -4648,9 +4648,15 @@ void talk_effect_fun_t::set_run_eoc_selector( const JsonObject &jo, std::string_ hide_failing, allow_cancel]( dialogue & d ) { uilist eoc_list; + std::unique_ptr default_talker = get_talker_for( get_player_character() ); + talker &alpha = d.has_alpha ? *d.actor( false ) : *default_talker; + talker &beta = d.has_beta ? *d.actor( true ) : *default_talker; + + eoc_list.text = title; eoc_list.allow_cancel = allow_cancel; eoc_list.desc_enabled = !eoc_descriptions.empty(); + parse_tags( eoc_list.text, alpha, beta, d ); for( size_t i = 0; i < eocs.size(); i++ ) { effect_on_condition_id eoc_id = effect_on_condition_id( eocs[i].evaluate( d ) ); @@ -4669,17 +4675,23 @@ void talk_effect_fun_t::set_run_eoc_selector( const JsonObject &jo, std::string_ continue; } + std::string name; std::string description; + if( eoc_names.empty() ) { + name = eoc_id.str(); + } else { + name = eoc_names[i].evaluate( d ); + parse_tags( name, alpha, beta, d ); + } if( !eoc_descriptions.empty() ) { description = eoc_descriptions[i].evaluate( d ); + parse_tags( description, alpha, beta, d ); } if( eoc_keys.empty() ) { - eoc_list.entries.emplace_back( static_cast( i ), display, std::nullopt, - ( eoc_names.empty() ? eoc_id.str() : eoc_names[i].evaluate( d ) ), description ); + eoc_list.entries.emplace_back( static_cast( i ), display, std::nullopt, name, description ); } else { - eoc_list.entries.emplace_back( static_cast( i ), display, eoc_keys[i], - ( eoc_names.empty() ? eoc_id.str() : eoc_names[i].evaluate( d ) ), description ); + eoc_list.entries.emplace_back( static_cast( i ), display, eoc_keys[i], name, description ); } }