mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 18:39:18 +02:00
cleanup
This commit is contained in:
90
launcher/textures_scanner.h
Normal file
90
launcher/textures_scanner.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include "Texture.h"
|
||||
|
||||
namespace ui {
|
||||
enum class vehicle_type {
|
||||
none = -1,
|
||||
electric_loco,
|
||||
diesel_loco,
|
||||
steam_loco,
|
||||
railcar,
|
||||
emu,
|
||||
utility,
|
||||
draisine,
|
||||
tram,
|
||||
carriage,
|
||||
truck,
|
||||
bus,
|
||||
car,
|
||||
man,
|
||||
animal,
|
||||
unknown
|
||||
};
|
||||
|
||||
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;
|
||||
operator bool() const;
|
||||
|
||||
GLuint get() const;
|
||||
glm::ivec2 size() const;
|
||||
|
||||
private:
|
||||
mutable std::string path;
|
||||
mutable texture_handle image = 0;
|
||||
};
|
||||
|
||||
struct skin_set {
|
||||
std::vector<std::filesystem::path> skins;
|
||||
deferred_image mini;
|
||||
std::string group;
|
||||
};
|
||||
|
||||
struct vehicle_desc;
|
||||
struct texture_rule {
|
||||
std::shared_ptr<vehicle_desc> previous_vehicle;
|
||||
std::vector<std::pair<std::string, std::string>> replace_rules;
|
||||
};
|
||||
|
||||
struct coupling_rule {
|
||||
std::shared_ptr<vehicle_desc> coupled_vehicle;
|
||||
int coupling_flag;
|
||||
};
|
||||
|
||||
struct vehicle_desc {
|
||||
vehicle_type type;
|
||||
std::filesystem::path path;
|
||||
|
||||
std::vector<skin_set> matching_skinsets;
|
||||
std::vector<coupling_rule> coupling_rules;
|
||||
std::vector<texture_rule> texture_rules;
|
||||
};
|
||||
|
||||
class vehicles_bank {
|
||||
public:
|
||||
std::unordered_map<vehicle_type, deferred_image> category_icons;
|
||||
std::map<std::string, deferred_image> group_icons;
|
||||
|
||||
std::map<std::filesystem::path, std::shared_ptr<vehicle_desc>> vehicles;
|
||||
std::map<std::string, std::set<std::shared_ptr<vehicle_desc>>> group_map;
|
||||
void scan_textures();
|
||||
|
||||
private:
|
||||
void parse_entry(const std::string &line);
|
||||
void parse_category_entry(const std::string ¶m);
|
||||
void parse_coupling_rule(const std::string &target, const std::string ¶m);
|
||||
void parse_texture_rule(const std::string &target, const std::string ¶m);
|
||||
void parse_texture_info(const std::string &target, const std::string ¶m, const std::string &comment);
|
||||
|
||||
std::shared_ptr<vehicle_desc> get_vehicle(const std::string &name);
|
||||
|
||||
vehicle_type ctx_type = vehicle_type::unknown;
|
||||
std::filesystem::path ctx_path;
|
||||
std::string ctx_model;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user