@@ -35,12 +35,18 @@ void CObjectFactory::init_spawn_data()
3535
3636 SpawnCategory category = try_detect_spawn_category (kind, wpclass, clsid);
3737
38- if (category >= SpawnCategory::ItemsFood && category <= SpawnCategory::ItemsUpgrades )
38+ if (category >= SpawnCategory::Artefacts && category <= SpawnCategory::WeaponsMiscellaneous )
3939 {
40- if (pSettings->read_if_exists <bool >(name, " quest_item" , false ))
40+ const auto width = pSettings->read_if_exists <u32 >(name, " inv_grid_width" , 0 );
41+ const auto height = pSettings->read_if_exists <u32 >(name, " inv_grid_height" , 0 );
42+
43+ if (width == 0 && height == 0 ) // ban fake items
44+ category = SpawnCategory::Unknown;
45+ else if (pSettings->read_if_exists <bool >(name, " quest_item" , false ))
4146 category = SpawnCategory::ItemsQuest;
4247 }
43- else if (category >= SpawnCategory::WeaponsAmmo && category <= SpawnCategory::WeaponsExplosives)
48+
49+ if (category >= SpawnCategory::WeaponsAmmo && category <= SpawnCategory::WeaponsExplosives)
4450 {
4551 cpcstr parent_section = pSettings->read_if_exists <pcstr>(name, " parent_section" , name.c_str ());
4652 if (parent_section != name)
@@ -215,6 +221,8 @@ void CObjectFactory::on_tool_frame()
215221
216222 window_size.x = std::max (window_size.x , ImGui::GetContentRegionAvail ().x / 3 .0f );
217223
224+ const auto & sections = m_spawner_sections[u8 (spawn_category)];
225+
218226 // 2. Display the list of items available for spawning
219227 if (ImGui::BeginChild (" Sections list" , window_size, child_flags, window_flags))
220228 {
@@ -225,8 +233,6 @@ void CObjectFactory::on_tool_frame()
225233 };
226234 static int display_mode = DisplayLTXSections;
227235
228- const auto & sections = m_spawner_sections[u8 (spawn_category)];
229-
230236 if (ImGui::BeginMenuBar ())
231237 {
232238 ImGui::Text (" Available: %zu" , sections.size ());
@@ -369,18 +375,42 @@ void CObjectFactory::on_tool_frame()
369375 ImGui::EndMenuBar ();
370376 }
371377
372- ImGui::TextWrapped (" In the future update of the spawner you will see items icons here." );
373-
374378 switch (where_to_spawn)
375379 {
380+ case Spawn::NearActor:
381+ case Spawn::ToInventory:
382+ {
383+ ImGui::PushStyleColor (ImGuiCol_Button, 0 );
384+
385+ const auto tex = InventoryUtilities::GetEquipmentIconsShader ()->GetImGuiTextureId ();
386+
387+ for (const CInifile::Sect* section : sections)
388+ {
389+ const float w = pSettings->read_if_exists <float >(section->Name , " inv_grid_width" , 0 ) * INV_GRID_WIDTH;
390+ const float h = pSettings->read_if_exists <float >(section->Name , " inv_grid_height" , 0 ) * INV_GRID_HEIGHT;
391+
392+ if (fis_zero (w) || fis_zero (h))
393+ continue ;
394+
395+ const float x = pSettings->r_float (section->Name , " inv_grid_x" ) * INV_GRID_WIDTH;
396+ const float y = pSettings->r_float (section->Name , " inv_grid_y" ) * INV_GRID_HEIGHT;
397+
398+ const bool spawn = ImGui::ImageButton (section->Name .c_str (), tex.texture , { w , h },
399+ { x / tex.size .x , y / tex.size .y }, { (x + w) / tex.size .x , (y + h) / tex.size .y });
400+ if (spawn)
401+ spawn_section = section->Name .c_str ();
402+ }
403+ ImGui::PopStyleColor ();
404+ break ;
405+ }
376406 case Spawn::OnSmart:
377407 {
378408 auto * alife = ai ().get_alife ();
379409 const auto * game_graph = ai ().get_game_graph ();
380410
381411 if (!alife || !game_graph)
382412 {
383- ImGui::Text (" A-Life should be loaded for this spawn method to work." );
413+ ImGui::TextWrapped (" A-Life should be loaded for this spawn method to work." );
384414 break ;
385415 }
386416
0 commit comments