Skip to content

Commit

Permalink
Show Monster and Artifact names in the popup dialog of the Editor (#9380
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ihhub authored Dec 28, 2024
1 parent 91b433f commit ad9dbf9
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/fheroes2/editor/editor_object_popup_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
#include <utility>
#include <vector>

#include "artifact.h"
#include "editor_interface.h"
#include "ground.h"
#include "interface_gamearea.h"
#include "logging.h"
#include "map_object_info.h"
#include "maps_tiles.h"
#include "monster.h"
#include "mp2.h"
#include "resource.h"
#include "translations.h"
Expand Down Expand Up @@ -64,7 +66,35 @@ namespace

// This is an invalid object!
assert( 0 );
return "Invalid resource";
break;
}
case MP2::OBJ_ARTIFACT: {
for ( const auto & info : Maps::getObjectsByGroup( Maps::ObjectGroup::ADVENTURE_ARTIFACTS ) ) {
assert( !info.groundLevelParts.empty() );

if ( info.objectType == MP2::OBJ_ARTIFACT && info.groundLevelParts.front().icnIndex == tile.getMainObjectPart().icnIndex
&& info.groundLevelParts.front().icnType == tile.getMainObjectPart().icnType ) {
return MP2::StringObject( MP2::OBJ_ARTIFACT ) + std::string( "\n" ) + Artifact( static_cast<int32_t>( info.metadata[0] ) ).GetName();
}
}

// This is an invalid object!
assert( 0 );
break;
}
case MP2::OBJ_MONSTER: {
for ( const auto & info : Maps::getObjectsByGroup( Maps::ObjectGroup::MONSTERS ) ) {
assert( !info.groundLevelParts.empty() );

if ( info.objectType == MP2::OBJ_MONSTER && info.groundLevelParts.front().icnIndex == tile.getMainObjectPart().icnIndex
&& info.groundLevelParts.front().icnType == tile.getMainObjectPart().icnType ) {
return MP2::StringObject( MP2::OBJ_MONSTER ) + std::string( "\n" ) + Monster( static_cast<int32_t>( info.metadata[0] ) ).GetMultiName();
}
}

// This is an invalid object!
assert( 0 );
break;
}
default:
break;
Expand Down

0 comments on commit ad9dbf9

Please sign in to comment.