mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 16:19:19 +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;
|
bool collapse_open = false;
|
||||||
|
|
||||||
for (auto const &desc : scenarios) {
|
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("-_"));
|
std::string prefix = name.substr(0, name.find_first_of("-_"));
|
||||||
if (prefix.empty())
|
if (prefix.empty())
|
||||||
prefix = name;
|
prefix = name;
|
||||||
@@ -120,8 +120,8 @@ void ui::scenerylist_panel::scan_scenarios()
|
|||||||
if (*(path.filename().string().begin()) == '$')
|
if (*(path.filename().string().begin()) == '$')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (string_ends_with(path, ".scn"))
|
if (string_ends_with(path.string(), ".scn"))
|
||||||
scan_scn(path);
|
scan_scn(path.string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ glm::ivec2 ui::deferred_image::size()
|
|||||||
ui::vehiclepicker_panel::vehiclepicker_panel()
|
ui::vehiclepicker_panel::vehiclepicker_panel()
|
||||||
: ui_panel(STR("Select vehicle"), true)
|
: ui_panel(STR("Select vehicle"), true)
|
||||||
{
|
{
|
||||||
auto now = std::chrono::high_resolution_clock::now();
|
|
||||||
bank.scan_textures();
|
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);
|
filter.resize(256, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,34 +81,45 @@ void ui::vehiclepicker_panel::render()
|
|||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
|
||||||
if (ImGui::BeginChild("box2")) {
|
std::vector<std::shared_ptr<vehicle_desc>> model_list;
|
||||||
|
std::vector<skin_set*> skinset_list;
|
||||||
|
|
||||||
for (auto const &v : bank.vehicles) {
|
for (auto const &v : bank.vehicles) {
|
||||||
auto desc = v.second;
|
auto desc = v.second;
|
||||||
if (selected_type == desc->type) {
|
|
||||||
if (desc->matching_skinsets.size() == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
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;
|
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;
|
selected_vehicle = desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
|
|
||||||
if (ImGui::BeginChild("box3")) {
|
if (ImGui::BeginChild("box3")) {
|
||||||
for (auto const &v : bank.vehicles) {
|
ImGuiListClipper clipper(skinset_list.size());
|
||||||
auto desc = v.second;
|
while (clipper.Step())
|
||||||
if (selected_vehicle == desc) {
|
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
|
||||||
for (auto &skin : desc->matching_skinsets) {
|
auto skin = skinset_list[i];
|
||||||
auto image = &skin.mini;
|
|
||||||
|
|
||||||
if (selectable_image(skin.skins[0].stem().c_str(), &skin == selected_skinset, image))
|
std::string label = skin->skins[0].stem().string();
|
||||||
selected_skinset = &skin;
|
if (selectable_image(label.c_str(), skin == selected_skinset, &skin->mini))
|
||||||
}
|
selected_skinset = skin;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
@@ -242,7 +250,7 @@ void ui::vehicles_bank::parse_texture_info(const std::string &target, const std:
|
|||||||
skin_set set;
|
skin_set set;
|
||||||
set.group = mini;
|
set.group = mini;
|
||||||
if (!miniplus.empty())
|
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::istringstream tex_stream(target);
|
||||||
std::string texture;
|
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);
|
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)
|
void ui::vehicles_bank::parse_coupling_rule(const std::string &target, const std::string ¶m)
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class deferred_image {
|
|||||||
public:
|
public:
|
||||||
deferred_image() = default;
|
deferred_image() = default;
|
||||||
deferred_image(const std::string &p) : path(p) { }
|
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();
|
GLuint get();
|
||||||
glm::ivec2 size();
|
glm::ivec2 size();
|
||||||
@@ -65,7 +68,7 @@ class vehicles_bank {
|
|||||||
public:
|
public:
|
||||||
std::unordered_map<vehicle_type, deferred_image> category_icons;
|
std::unordered_map<vehicle_type, deferred_image> category_icons;
|
||||||
std::map<std::filesystem::path, std::shared_ptr<vehicle_desc>> vehicles;
|
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();
|
void scan_textures();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ shape_node::import( cParser &Input, scene::node_data const &Nodedata ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// assigned material
|
// assigned material
|
||||||
|
replace_slashes(token);
|
||||||
m_data.material = GfxRenderer.Fetch_Material( token );
|
m_data.material = GfxRenderer.Fetch_Material( token );
|
||||||
|
|
||||||
// determine way to proceed from the assigned diffuse texture
|
// determine way to proceed from the assigned diffuse texture
|
||||||
|
|||||||
Reference in New Issue
Block a user