mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-17 23:39:18 +02:00
add missing replace_slashes in node triangles deserializer, vehicle picker changes, explicit filesystem::path to string conversion
This commit is contained in:
@@ -29,7 +29,7 @@ void ui::scenerylist_panel::render()
|
||||
bool collapse_open = false;
|
||||
|
||||
for (auto const &desc : scenarios) {
|
||||
std::string name = desc.path.stem();
|
||||
std::string name = desc.path.stem().string();
|
||||
std::string prefix = name.substr(0, name.find_first_of("-_"));
|
||||
if (prefix.empty())
|
||||
prefix = name;
|
||||
@@ -120,8 +120,8 @@ void ui::scenerylist_panel::scan_scenarios()
|
||||
if (*(path.filename().string().begin()) == '$')
|
||||
continue;
|
||||
|
||||
if (string_ends_with(path, ".scn"))
|
||||
scan_scn(path);
|
||||
if (string_ends_with(path.string(), ".scn"))
|
||||
scan_scn(path.string());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,10 +32,7 @@ glm::ivec2 ui::deferred_image::size()
|
||||
ui::vehiclepicker_panel::vehiclepicker_panel()
|
||||
: ui_panel(STR("Select vehicle"), true)
|
||||
{
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
bank.scan_textures();
|
||||
auto diff = std::chrono::high_resolution_clock::now() - now;
|
||||
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(diff).count() << std::endl;
|
||||
filter.resize(256, 0);
|
||||
}
|
||||
|
||||
@@ -84,35 +81,46 @@ void ui::vehiclepicker_panel::render()
|
||||
ImGui::EndChild();
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::BeginChild("box2")) {
|
||||
for (auto const &v : bank.vehicles) {
|
||||
auto desc = v.second;
|
||||
if (selected_type == desc->type) {
|
||||
if (desc->matching_skinsets.size() == 0)
|
||||
continue;
|
||||
std::vector<std::shared_ptr<vehicle_desc>> model_list;
|
||||
std::vector<skin_set*> skinset_list;
|
||||
|
||||
for (auto const &v : bank.vehicles) {
|
||||
auto desc = v.second;
|
||||
|
||||
if (selected_type == desc->type && desc->matching_skinsets.size() > 0)
|
||||
model_list.push_back(desc);
|
||||
|
||||
if (selected_vehicle == desc) {
|
||||
for (auto &skin : desc->matching_skinsets)
|
||||
skinset_list.push_back(&skin);
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginChild("box2")) {
|
||||
ImGuiListClipper clipper(model_list.size());
|
||||
while (clipper.Step())
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
auto &desc = model_list[i];
|
||||
auto image = &desc->matching_skinsets[0].mini;
|
||||
|
||||
if (selectable_image(desc->path.stem().c_str(), desc == selected_vehicle, image))
|
||||
std::string label = desc->path.stem().string();
|
||||
if (selectable_image(label.c_str(), desc == selected_vehicle, image))
|
||||
selected_vehicle = desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
ImGui::NextColumn();
|
||||
|
||||
if (ImGui::BeginChild("box3")) {
|
||||
for (auto const &v : bank.vehicles) {
|
||||
auto desc = v.second;
|
||||
if (selected_vehicle == desc) {
|
||||
for (auto &skin : desc->matching_skinsets) {
|
||||
auto image = &skin.mini;
|
||||
ImGuiListClipper clipper(skinset_list.size());
|
||||
while (clipper.Step())
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||
auto skin = skinset_list[i];
|
||||
|
||||
if (selectable_image(skin.skins[0].stem().c_str(), &skin == selected_skinset, image))
|
||||
selected_skinset = &skin;
|
||||
}
|
||||
std::string label = skin->skins[0].stem().string();
|
||||
if (selectable_image(label.c_str(), skin == selected_skinset, &skin->mini))
|
||||
selected_skinset = skin;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -242,7 +250,7 @@ void ui::vehicles_bank::parse_texture_info(const std::string &target, const std:
|
||||
skin_set set;
|
||||
set.group = mini;
|
||||
if (!miniplus.empty())
|
||||
set.mini = deferred_image("textures/mini/" + ToLower(miniplus));
|
||||
set.mini = std::move(deferred_image("textures/mini/" + ToLower(miniplus)));
|
||||
|
||||
std::istringstream tex_stream(target);
|
||||
std::string texture;
|
||||
@@ -252,7 +260,9 @@ void ui::vehicles_bank::parse_texture_info(const std::string &target, const std:
|
||||
set.skins.push_back(path);
|
||||
}
|
||||
|
||||
get_vehicle(model)->matching_skinsets.push_back(set);
|
||||
auto vehicle = get_vehicle(model);
|
||||
group_map[set.group].insert(vehicle);
|
||||
vehicle->matching_skinsets.push_back(std::move(set));
|
||||
}
|
||||
|
||||
void ui::vehicles_bank::parse_coupling_rule(const std::string &target, const std::string ¶m)
|
||||
|
||||
@@ -26,6 +26,9 @@ class deferred_image {
|
||||
public:
|
||||
deferred_image() = default;
|
||||
deferred_image(const std::string &p) : path(p) { }
|
||||
deferred_image(const deferred_image&) = delete;
|
||||
deferred_image(deferred_image&&) = default;
|
||||
deferred_image &operator=(deferred_image&&) = default;
|
||||
|
||||
GLuint get();
|
||||
glm::ivec2 size();
|
||||
@@ -65,7 +68,7 @@ class vehicles_bank {
|
||||
public:
|
||||
std::unordered_map<vehicle_type, deferred_image> category_icons;
|
||||
std::map<std::filesystem::path, std::shared_ptr<vehicle_desc>> vehicles;
|
||||
std::map<std::string, std::vector<std::shared_ptr<vehicle_desc>>> group_map;
|
||||
std::map<std::string, std::set<std::shared_ptr<vehicle_desc>>> group_map;
|
||||
void scan_textures();
|
||||
|
||||
private:
|
||||
|
||||
@@ -190,7 +190,8 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
||||
}
|
||||
|
||||
// assigned material
|
||||
m_data.material = GfxRenderer.Fetch_Material( token );
|
||||
replace_slashes(token);
|
||||
m_data.material = GfxRenderer.Fetch_Material( token );
|
||||
|
||||
// determine way to proceed from the assigned diffuse texture
|
||||
// TBT, TODO: add methods to material manager to access these simpler
|
||||
|
||||
Reference in New Issue
Block a user