Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(UI): move item notes to be with description, move MAGIC_FOCUS flag description to flag section #4339

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@
"id": "MAGIC_FOCUS",
"type": "json_flag",
"context": [ "item" ],
"//": "You can cast spells with this item in your hand."
"info": "This item is a <info>magical focus</info>. You can cast spells with it in your hand."
},
{
"id": "HOSTILE_SUMMON",
Expand Down
49 changes: 21 additions & 28 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1655,11 +1655,6 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
} else if( idescription != item_vars.end() ) {
info.emplace_back( "DESCRIPTION", idescription->second );
} else {
if( has_flag( flag_MAGIC_FOCUS ) ) {
info.emplace_back( "DESCRIPTION",
_( "This item is a <info>magical focus</info>. "
"You can cast spells with it in your hand." ) );
}
if( is_craft() ) {
const std::string desc = _( "This is an in progress %s. "
"It is %d percent complete." );
Expand All @@ -1671,6 +1666,27 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
info.emplace_back( "DESCRIPTION", type->description.translated() );
}
}
std::map<std::string, std::string>::const_iterator item_note = item_vars.find( "item_note" );
std::map<std::string, std::string>::const_iterator item_note_tool =
item_vars.find( "item_note_tool" );

if( item_note != item_vars.end() && parts->test( iteminfo_parts::DESCRIPTION_NOTES ) ) {
std::string ntext;
const inscribe_actor *use_actor = nullptr;
if( item_note_tool != item_vars.end() ) {
const use_function *use_func = itype_id( item_note_tool->second )->get_use( "inscribe" );
use_actor = dynamic_cast<const inscribe_actor *>( use_func->get_actor_ptr() );
}
if( use_actor ) {
//~ %1$s: gerund (e.g. carved), %2$s: item name, %3$s: inscription text
ntext = string_format( pgettext( "carving", "<info>%1$s on the %2$s is:</info> %3$s" ),
use_actor->gerund, tname(), item_note->second );
} else {
//~ %1$s: inscription text
ntext = string_format( pgettext( "carving", "Note: %1$s" ), item_note->second );
}
info.emplace_back( "DESCRIPTION", ntext );
}
insert_separation_line( info );
}

Expand Down Expand Up @@ -3879,29 +3895,6 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query &parts_
}
}

std::map<std::string, std::string>::const_iterator item_note = item_vars.find( "item_note" );
std::map<std::string, std::string>::const_iterator item_note_tool =
item_vars.find( "item_note_tool" );

if( item_note != item_vars.end() && parts->test( iteminfo_parts::DESCRIPTION_NOTES ) ) {
insert_separation_line( info );
std::string ntext;
const inscribe_actor *use_actor = nullptr;
if( item_note_tool != item_vars.end() ) {
const use_function *use_func = itype_id( item_note_tool->second )->get_use( "inscribe" );
use_actor = dynamic_cast<const inscribe_actor *>( use_func->get_actor_ptr() );
}
if( use_actor ) {
//~ %1$s: gerund (e.g. carved), %2$s: item name, %3$s: inscription text
ntext = string_format( pgettext( "carving", "%1$s on the %2$s is: %3$s" ),
use_actor->gerund, tname(), item_note->second );
} else {
//~ %1$s: inscription text
ntext = string_format( pgettext( "carving", "Note: %1$s" ), item_note->second );
}
info.emplace_back( "DESCRIPTION", ntext );
}

if( this->get_var( "die_num_sides", 0 ) != 0 ) {
info.emplace_back( "DESCRIPTION",
string_format( _( "* This item can be used as a <info>die</info>, "
Expand Down
Loading