mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-19 12:45:00 +00:00
Game Config: make tc/color_info take a string_view and allow heterogeneous lookup
This commit is contained in:
parent
f71e0b3b17
commit
8619e403a8
@ -140,11 +140,11 @@ std::vector<color_t> red_green_scale_text;
|
|||||||
static std::vector<color_t> blue_white_scale;
|
static std::vector<color_t> blue_white_scale;
|
||||||
static std::vector<color_t> blue_white_scale_text;
|
static std::vector<color_t> blue_white_scale_text;
|
||||||
|
|
||||||
std::map<std::string, color_range> team_rgb_range;
|
std::map<std::string, color_range, std::less<>> team_rgb_range;
|
||||||
// Map [color_range]id to [color_range]name, or "" if no name
|
// Map [color_range]id to [color_range]name, or "" if no name
|
||||||
std::map<std::string, t_string> team_rgb_name;
|
std::map<std::string, t_string, std::less<>> team_rgb_name;
|
||||||
|
|
||||||
std::map<std::string, std::vector<color_t>> team_rgb_colors;
|
std::map<std::string, std::vector<color_t>, std::less<>> team_rgb_colors;
|
||||||
|
|
||||||
std::vector<std::string> default_colors;
|
std::vector<std::string> default_colors;
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ void reset_color_info()
|
|||||||
team_rgb_range.clear();
|
team_rgb_range.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const color_range& color_info(const std::string& name)
|
const color_range& color_info(std::string_view name)
|
||||||
{
|
{
|
||||||
auto i = team_rgb_range.find(name);
|
auto i = team_rgb_range.find(name);
|
||||||
if(i != team_rgb_range.end()) {
|
if(i != team_rgb_range.end()) {
|
||||||
@ -521,7 +521,7 @@ const color_range& color_info(const std::string& name)
|
|||||||
return color_info(name);
|
return color_info(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<color_t>& tc_info(const std::string& name)
|
const std::vector<color_t>& tc_info(std::string_view name)
|
||||||
{
|
{
|
||||||
auto i = team_rgb_colors.find(name);
|
auto i = team_rgb_colors.find(name);
|
||||||
if(i != team_rgb_colors.end()) {
|
if(i != team_rgb_colors.end()) {
|
||||||
|
@ -157,9 +157,9 @@ namespace game_config
|
|||||||
* Colors defined by WML [color_range] tags. In addition to team colors such as "red" and
|
* Colors defined by WML [color_range] tags. In addition to team colors such as "red" and
|
||||||
* "blue", this also contains the colors used on the minimap for "cave", "fungus" etc.
|
* "blue", this also contains the colors used on the minimap for "cave", "fungus" etc.
|
||||||
*/
|
*/
|
||||||
extern std::map<std::string, color_range> team_rgb_range;
|
extern std::map<std::string, color_range, std::less<>> team_rgb_range;
|
||||||
extern std::map<std::string, t_string> team_rgb_name;
|
extern std::map<std::string, t_string, std::less<>> team_rgb_name;
|
||||||
extern std::map<std::string, std::vector<color_t>> team_rgb_colors;
|
extern std::map<std::string, std::vector<color_t>, std::less<>> team_rgb_colors;
|
||||||
|
|
||||||
extern std::vector<std::string> default_colors;
|
extern std::vector<std::string> default_colors;
|
||||||
|
|
||||||
@ -187,8 +187,8 @@ namespace game_config
|
|||||||
|
|
||||||
void add_color_info(const game_config_view& v);
|
void add_color_info(const game_config_view& v);
|
||||||
void reset_color_info();
|
void reset_color_info();
|
||||||
const std::vector<color_t>& tc_info(const std::string& name);
|
const std::vector<color_t>& tc_info(std::string_view name);
|
||||||
const color_range& color_info(const std::string& name);
|
const color_range& color_info(std::string_view name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a color corresponding to the value val
|
* Return a color corresponding to the value val
|
||||||
|
Loading…
x
Reference in New Issue
Block a user