@@ -145,6 +145,8 @@ void Player::OnEngineInitialized()
145145 GameLoopManager->RegisterForFrameUpdate (delegate, 1 );
146146
147147 AddBindings ();
148+
149+ LoadActorTypesAndResourceIDs ();
148150}
149151
150152void Player::OnDrawMenu ()
@@ -931,9 +933,46 @@ void Player::RenderActorsTabItem()
931933 static char numberOfActorsToSpawn[4 ]{ " 1" };
932934
933935 ImGui::AlignTextToFramePadding ();
934- ImGui::Text (" Actor Resource ID " );
936+ ImGui::Text (" Actor Variation " );
935937 ImGui::SameLine ();
936- ImGui::InputText (" ##ActorsResourceID" , actorResourceID, sizeof (actorResourceID));
938+
939+ static char actorVariation[128 ]{ " " };
940+ const bool isInputTextEnterPressed = ImGui::InputText (" ##ActorVariation" , actorVariation, sizeof (actorVariation), ImGuiInputTextFlags_EnterReturnsTrue);
941+ const bool isInputTextActive = ImGui::IsItemActive ();
942+
943+ if (ImGui::IsItemActivated ())
944+ {
945+ ImGui::OpenPopup (" ##ActorVariationPopup" );
946+ }
947+
948+ ImGui::SetNextWindowPos (ImVec2 (ImGui::GetItemRectMin ().x , ImGui::GetItemRectMax ().y ));
949+ ImGui::SetNextWindowSize (ImVec2 (ImGui::GetItemRectSize ().x , 300 ));
950+
951+ if (ImGui::BeginPopup (" ##ActorVariationPopup" , ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_ChildWindow))
952+ {
953+ for (auto it = actorVariationsToResourceIDs.begin (); it != actorVariationsToResourceIDs.end (); ++it)
954+ {
955+ if (!StringUtility::Contains (it->first , actorVariation, false ))
956+ {
957+ continue ;
958+ }
959+
960+ if (ImGui::Selectable (it->first .c_str ()))
961+ {
962+ ImGui::ClearActiveID ();
963+ strcpy_s (actorVariation, it->first .c_str ());
964+
965+ actorResourceID = it->second .c_str ();
966+ }
967+ }
968+
969+ if (isInputTextEnterPressed || (!isInputTextActive && !ImGui::IsWindowFocused ()))
970+ {
971+ ImGui::CloseCurrentPopup ();
972+ }
973+
974+ ImGui::EndPopup ();
975+ }
937976
938977 ImGui::AlignTextToFramePadding ();
939978 ImGui::Text (" Actor Name" );
@@ -963,8 +1002,8 @@ void Player::RenderActorsTabItem()
9631002 ImGui::SameLine ();
9641003
9651004 static char actorWeaponName[50 ]{ " " };
966- const bool isInputTextEnterPressed = ImGui::InputText (" ##WeaponName" , actorWeaponName, sizeof (actorWeaponName), ImGuiInputTextFlags_EnterReturnsTrue);
967- const bool isInputTextActive = ImGui::IsItemActive ();
1005+ const bool isInputTextEnterPressed2 = ImGui::InputText (" ##WeaponName" , actorWeaponName, sizeof (actorWeaponName), ImGuiInputTextFlags_EnterReturnsTrue);
1006+ const bool isInputTextActive2 = ImGui::IsItemActive ();
9681007
9691008 if (ImGui::IsItemActivated ())
9701009 {
@@ -1360,7 +1399,7 @@ void Player::SpawnActor()
13601399
13611400 if (spawnCivilianActor)
13621401 {
1363- if (! strstr ( actorResourceID, " male civilian" ))
1402+ if (actorResourceID. contains ( " male civilian" ))
13641403 {
13651404 SetPropertiesForCivilianActor (entityRef);
13661405 }
@@ -1369,7 +1408,7 @@ void Player::SpawnActor()
13691408 }
13701409 else
13711410 {
1372- if (! strstr ( actorResourceID, " male guard" ))
1411+ if (actorResourceID. contains ( " male guard" ))
13731412 {
13741413 SetPropertiesForGuardActor (entityRef);
13751414 }
@@ -1489,6 +1528,21 @@ void Player::SetPropertiesForGuardActor(ZEntityRef& entityRef)
14891528 entityRef.SetProperty (" Oneliner_Attenuation" , -3 .f );
14901529}
14911530
1531+ void Player::LoadActorTypesAndResourceIDs ()
1532+ {
1533+ std::ifstream ifstream = std::ifstream (" assets/Actors.txt" );
1534+ std::string line;
1535+
1536+ while (getline (ifstream, line))
1537+ {
1538+ const size_t index = line.find (" #" );
1539+ const std::string actorType = line.substr (0 , index);
1540+ const std::string resourceID = line.substr (index + 1 );
1541+
1542+ actorVariationsToResourceIDs.insert (std::make_pair (actorType, resourceID));
1543+ }
1544+ }
1545+
14921546ZEntityType** __fastcall ZEntityManager_ConstructUninitializedEntityHook (ZEntityManager* pThis, int edx, const ZString& sDebugName , IEntityFactory* pEntityFactory, unsigned char * pMemBlock)
14931547{
14941548 ZEntityType** entityType = Hooks::ZEntityManager_ConstructUninitializedEntity.CallOriginalFunction (pThis, sDebugName , pEntityFactory, pMemBlock);
0 commit comments