Address misc recent feedback

This commit is contained in:
Charles Dang 2022-03-31 18:02:51 -04:00
parent 9ff098f2a9
commit 7108d218fd
6 changed files with 41 additions and 36 deletions

View file

@ -890,7 +890,8 @@ gui::button::TYPE string_to_button_type(const std::string& type)
const std::string& get_direction(std::size_t n)
{
static const std::array<std::string, 6> dirs{"-n", "-ne", "-se", "-s", "-sw", "-nw"};
using namespace std::literals::string_literals;
static const std::array dirs{"-n"s, "-ne"s, "-se"s, "-s"s, "-sw"s, "-nw"s};
return dirs[n >= dirs.size() ? 0 : n];
}
} // namespace

View file

@ -85,7 +85,7 @@ struct enum_base : public T
#define ENUM_AND_ARRAY(...) \
enum class type { __VA_ARGS__ }; \
\
/** Provide a variable template for an array of matching size. */ \
/** Provide a alias template for an array of matching size. */ \
template<typename T> \
using sized_array = std::array<T, std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value>; \
\

View file

@ -83,11 +83,11 @@ bool check_font_file(std::string name) {
namespace
{
#ifdef CAIRO_HAS_WIN32_FONT
bool is_valid_font_file(const std::string& file)
{
static const std::array font_exts { ".ttf", ".ttc", ".otf" };
using namespace std::literals::string_literals;
static const std::array font_exts { ".ttf"s, ".ttc"s, ".otf"s };
for(const std::string& ext : font_exts) {
if(filesystem::ends_with(file, ext)) {

View file

@ -106,7 +106,10 @@ static void verify(const unit_map& units, const config& cfg) {
u->write(u_cfg);
bool is_ok = true;
static const std::array fields {"type","hitpoints","experience","side"};
using namespace std::literals::string_literals;
static const std::array fields{"type"s, "hitpoints"s, "experience"s, "side"s};
for(const std::string& field : fields) {
if (u_cfg[field] != un[field]) {
errbuf << "ERROR IN FIELD '" << field << "' for unit at "

View file

@ -4725,40 +4725,38 @@ void game_lua_kernel::set_game_display(game_display * gd) {
* elsewhere (in the C++ code).
* Any child tags not in this list will be passed to Lua's on_load event.
*/
static const std::array handled_file_tags {
"color_palette",
"color_range",
"display",
"end_level_data",
"era",
"event",
"generator",
"label",
"lua",
"map",
"menu_item",
"modification",
"modify_unit_type",
"music",
"options",
"side",
"sound_source",
"story",
"terrain_graphics",
"time",
"time_area",
"tunnel",
"undo_stack",
"variables"
};
static bool is_handled_file_tag(const std::string& s)
{
for(const std::string& t : handled_file_tags) {
if (s == t) return true;
}
// Make sure this is sorted, since we binary_search!
using namespace std::literals::string_view_literals;
static const std::array handled_file_tags {
"color_palette"sv,
"color_range"sv,
"display"sv,
"end_level_data"sv,
"era"sv,
"event"sv,
"generator"sv,
"label"sv,
"lua"sv,
"map"sv,
"menu_item"sv,
"modification"sv,
"modify_unit_type"sv,
"music"sv,
"options"sv,
"side"sv,
"sound_source"sv,
"story"sv,
"terrain_graphics"sv,
"time"sv,
"time_area"sv,
"tunnel"sv,
"undo_stack"sv,
"variables"sv
};
return false;
return std::binary_search(handled_file_tags.begin(), handled_file_tags.end(), s);
}
/**

View file

@ -315,9 +315,12 @@ private:
static inline std::map<std::string, config> known_themes{};
public:
/** Copies the theme configs from the main game config. */
static void set_known_themes(const game_config_view* cfg);
/** Returns the saved config for the theme with the given ID. */
static const config& get_theme_config(const std::string& id);
/** Returns minimal info about saved themes, optionally including hidden ones. */
static std::vector<theme_info> get_basic_theme_info(bool include_hidden = false);
};