16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 19:29:19 +02:00

fix scenery_list crashes when missing vehicles

This commit is contained in:
milek7
2023-05-28 21:25:05 +02:00
parent 54e5e186a3
commit b01c19308c

View File

@@ -216,6 +216,8 @@ void ui::scenerylist_panel::render_contents()
void ui::scenerylist_panel::draw_summary_tooltip(const dynamic_desc &dyn_desc) void ui::scenerylist_panel::draw_summary_tooltip(const dynamic_desc &dyn_desc)
{ {
if (dyn_desc.vehicle && dyn_desc.skin)
{
std::string name = (dyn_desc.vehicle->path.parent_path() / dyn_desc.vehicle->path.stem()).string(); std::string name = (dyn_desc.vehicle->path.parent_path() / dyn_desc.vehicle->path.stem()).string();
std::string skin = dyn_desc.skin->skin; std::string skin = dyn_desc.skin->skin;
ImGui::Text(STR_C("ID: %s"), dyn_desc.name.c_str()); ImGui::Text(STR_C("ID: %s"), dyn_desc.name.c_str());
@@ -224,6 +226,7 @@ void ui::scenerylist_panel::draw_summary_tooltip(const dynamic_desc &dyn_desc)
ImGui::Text(STR_C("Type: %s"), name.c_str()); ImGui::Text(STR_C("Type: %s"), name.c_str());
ImGui::Text(STR_C("Skin: %s"), skin.c_str()); ImGui::Text(STR_C("Skin: %s"), skin.c_str());
ImGui::NewLine(); ImGui::NewLine();
}
if (dyn_desc.drivertype != "nobody") if (dyn_desc.drivertype != "nobody")
ImGui::Text(STR_C("Occupied: %s"), dyn_desc.drivertype.c_str()); ImGui::Text(STR_C("Occupied: %s"), dyn_desc.drivertype.c_str());
@@ -366,13 +369,14 @@ void ui::dynamic_edit_popup::render_content()
STRN("nobody") STRN("nobody")
}; };
if (ImGui::InputText(STR_C("Name"), name_buf.data(), name_buf.size()))
dynamic.name = name_buf.data();
if (dynamic.vehicle && dynamic.skin)
{
std::string name = (dynamic.vehicle->path.parent_path() / dynamic.vehicle->path.stem()).string(); std::string name = (dynamic.vehicle->path.parent_path() / dynamic.vehicle->path.stem()).string();
ImGui::Text(STR_C("Type: %s"), name.c_str()); ImGui::Text(STR_C("Type: %s"), name.c_str());
ImGui::NewLine();
if (ImGui::InputText(STR_C("Name"), name_buf.data(), name_buf.size()))
dynamic.name = name_buf.data();
if (ImGui::BeginCombo(STR_C("Skin"), dynamic.skin->skin.c_str(), ImGuiComboFlags_HeightLargest)) if (ImGui::BeginCombo(STR_C("Skin"), dynamic.skin->skin.c_str(), ImGuiComboFlags_HeightLargest))
{ {
@@ -385,6 +389,7 @@ void ui::dynamic_edit_popup::render_content()
} }
ImGui::EndCombo(); ImGui::EndCombo();
} }
}
if (ImGui::BeginCombo(STR_C("Occupancy"), Translations.lookup_c(dynamic.drivertype.c_str()))) if (ImGui::BeginCombo(STR_C("Occupancy"), Translations.lookup_c(dynamic.drivertype.c_str())))
{ {