diff --git a/launcher/scenery_list.cpp b/launcher/scenery_list.cpp index a1c0deca..99d1e80a 100644 --- a/launcher/scenery_list.cpp +++ b/launcher/scenery_list.cpp @@ -145,6 +145,11 @@ void ui::scenerylist_panel::add_replace_entry(const trainset_desc &trainset) set += std::to_string(trainset.offset) + " "; set += std::to_string(trainset.velocity) + "\n"; for (const auto &veh : trainset.vehicles) { + if (!veh.skin) { + ErrorLog("trainset contains invalid vehicle " + veh.name); + continue; + } + set += "node -1 0 " + veh.name + " dynamic "; set += veh.vehicle->path.parent_path().generic_string() + " "; set += veh.skin->skin + " "; diff --git a/launcher/textures_scanner.cpp b/launcher/textures_scanner.cpp index 4e0bebdb..5ea755c8 100644 --- a/launcher/textures_scanner.cpp +++ b/launcher/textures_scanner.cpp @@ -167,6 +167,11 @@ std::shared_ptr ui::vehicles_bank::parse_meta(const std::string & meta->texture_author = win1250_to_utf8(meta->texture_author); meta->photo_author = win1250_to_utf8(meta->photo_author); + std::replace(std::begin(meta->location), std::end(meta->location), '_', ' '); + std::replace(std::begin(meta->rev_company), std::end(meta->rev_company), '_', ' '); + std::replace(std::begin(meta->texture_author), std::end(meta->texture_author), '_', ' '); + std::replace(std::begin(meta->photo_author), std::end(meta->photo_author), '_', ' '); + if (!meta->rev_date.empty() && meta->rev_date != "?") { std::istringstream stream(meta->rev_date); std::string day, month; diff --git a/launcher/vehicle_picker.cpp b/launcher/vehicle_picker.cpp index 219de317..0cd8a7ca 100644 --- a/launcher/vehicle_picker.cpp +++ b/launcher/vehicle_picker.cpp @@ -171,24 +171,25 @@ void ui::vehiclepicker_panel::render() auto skin = skinset_list[i]; //std::string label = skin->skins[0].stem().string(); - std::string label = skin->meta->name; - if (label.empty() || label == "?") - label = skin->skin; + std::string label = skin->skin; + if (skin->meta && !skin->meta->name.empty() && skin->meta->name != "?") + label = skin->meta->name; auto mini = skin->mini ? &skin->mini : &placeholder_mini; if (selectable_image(label.c_str(), skin == selected_skinset, mini, skin)) selected_skinset = skin; - if (ImGui::IsItemHovered()) { + if (skin->meta && ImGui::IsItemHovered()) { ImGui::BeginTooltip(); - ImGui::TextUnformatted(skin->skin.c_str()); - ImGui::TextUnformatted(skin->vehicle.lock()->path.string().c_str()); - ImGui::TextUnformatted(skin->meta->short_id.c_str()); - ImGui::TextUnformatted(skin->meta->location.c_str()); - ImGui::TextUnformatted(skin->meta->rev_date.c_str()); - ImGui::TextUnformatted(skin->meta->rev_company.c_str()); - ImGui::TextUnformatted(skin->meta->texture_author.c_str()); - ImGui::TextUnformatted(skin->meta->photo_author.c_str()); + ImGui::Text(STR_C("Skin: %s\nType: %s\nCarrier code: %s\nDepot: %s\nMaintenance: %s, by %s\nSkin author: %s\nPhoto author: %s"), + skin->skin.c_str(), + skin->vehicle.lock()->path.string().c_str(), + skin->meta->short_id.c_str(), + skin->meta->location.c_str(), + skin->meta->rev_date.c_str(), + skin->meta->rev_company.c_str(), + skin->meta->texture_author.c_str(), + skin->meta->photo_author.c_str()); ImGui::EndTooltip(); } } @@ -208,8 +209,10 @@ bool ui::vehiclepicker_panel::selectable_image(const char *desc, bool selected, if (pickable) ImGui::SetItemAllowOverlap(); - if (!image) + if (!image) { + ImGui::PopID(); return ret; + } GLuint tex = image->get(); if (tex != -1) { @@ -235,6 +238,5 @@ bool ui::vehiclepicker_panel::selectable_image(const char *desc, bool selected, } ImGui::PopID(); - return ret; }