2023-02-13 19:45:26 -07:00
|
|
|
#pragma once
|
2023-02-21 19:05:15 -07:00
|
|
|
|
|
|
|
#include "modules/Materials.h"
|
|
|
|
|
|
|
|
#include "df/dfhack_material_category.h"
|
|
|
|
#include "df/item_quality.h"
|
|
|
|
|
|
|
|
class ItemFilter {
|
|
|
|
public:
|
|
|
|
ItemFilter();
|
2023-02-22 16:08:11 -07:00
|
|
|
ItemFilter(DFHack::color_ostream &out, std::string serialized);
|
2023-02-21 19:05:15 -07:00
|
|
|
|
|
|
|
void clear();
|
2023-02-22 16:08:11 -07:00
|
|
|
bool isEmpty() const;
|
2023-02-21 19:05:15 -07:00
|
|
|
std::string serialize() const;
|
|
|
|
|
|
|
|
void setMinQuality(int quality);
|
2023-03-06 00:04:03 -07:00
|
|
|
void setMaxQuality(int quality, bool is_default = false);
|
2023-02-21 19:05:15 -07:00
|
|
|
void setDecoratedOnly(bool decorated);
|
|
|
|
void setMaterialMask(uint32_t mask);
|
2023-03-02 18:50:12 -07:00
|
|
|
void setMaterials(const std::set<DFHack::MaterialInfo> &materials);
|
2023-02-21 19:05:15 -07:00
|
|
|
|
2023-02-27 00:38:00 -07:00
|
|
|
df::item_quality getMinQuality() const { return min_quality; }
|
|
|
|
df::item_quality getMaxQuality() const {return max_quality; }
|
|
|
|
bool getDecoratedOnly() const { return decorated_only; }
|
|
|
|
df::dfhack_material_category getMaterialMask() const { return mat_mask; }
|
2023-03-02 18:50:12 -07:00
|
|
|
std::set<DFHack::MaterialInfo> getMaterials() const { return materials; }
|
2023-02-21 19:05:15 -07:00
|
|
|
|
|
|
|
bool matches(df::dfhack_material_category mask) const;
|
|
|
|
bool matches(DFHack::MaterialInfo &material) const;
|
|
|
|
bool matches(df::item *item) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
df::item_quality min_quality;
|
|
|
|
df::item_quality max_quality;
|
2023-03-06 00:04:03 -07:00
|
|
|
df::item_quality default_max_quality;
|
2023-02-21 19:05:15 -07:00
|
|
|
bool decorated_only;
|
|
|
|
df::dfhack_material_category mat_mask;
|
2023-03-02 18:50:12 -07:00
|
|
|
std::set<DFHack::MaterialInfo> materials;
|
2023-02-21 19:05:15 -07:00
|
|
|
};
|
2023-02-22 16:08:11 -07:00
|
|
|
|
|
|
|
std::vector<ItemFilter> deserialize_item_filters(DFHack::color_ostream &out, const std::string &serialized);
|
|
|
|
std::string serialize_item_filters(const std::vector<ItemFilter> &filters);
|