Load valid zoom levels from [game_config]
This commit is contained in:
parent
a5bd278cf2
commit
b0510bfdc7
7 changed files with 28 additions and 17 deletions
|
@ -32,6 +32,7 @@
|
|||
|
||||
hp_bar_scaling=0.6
|
||||
xp_bar_scaling=0.5
|
||||
zoom_levels = 0.25, 0.33333333333333333, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 4.0
|
||||
|
||||
#temporary disable hex brightening
|
||||
hex_brightening=1.25
|
||||
|
|
|
@ -62,17 +62,15 @@ static lg::log_domain log_display("display");
|
|||
#define LOG_DP LOG_STREAM(info, log_display)
|
||||
#define DBG_DP LOG_STREAM(debug, log_display)
|
||||
|
||||
// These are macros instead of proper constants so that they auto-update if the game config is reloaded.
|
||||
#define zoom_levels (game_config::zoom_levels)
|
||||
#define final_zoom_index (static_cast<int>(zoom_levels.size()) - 1)
|
||||
#define DefaultZoom (game_config::tile_size)
|
||||
#define SmallZoom (DefaultZoom / 2)
|
||||
#define MinZoom (zoom_levels.front())
|
||||
#define MaxZoom (zoom_levels.back())
|
||||
|
||||
namespace {
|
||||
std::vector<unsigned int> zoom_levels {18, 24, 36, 54, 72, 90, 108, 144, 216, 288};
|
||||
|
||||
const int final_zoom_index = static_cast<int>(zoom_levels.size()) - 1;
|
||||
|
||||
const unsigned int DefaultZoom = game_config::tile_size;
|
||||
const unsigned int SmallZoom = DefaultZoom / 2;
|
||||
|
||||
const unsigned int MinZoom = zoom_levels.front();
|
||||
const unsigned int MaxZoom = zoom_levels.back();
|
||||
|
||||
bool benchmark = false;
|
||||
|
||||
bool debug_foreground = false;
|
||||
|
|
|
@ -186,7 +186,7 @@ void mouse_action::set_terrain_mouse_overlay(editor_display& disp, const t_trans
|
|||
adjust_surface_alpha(image, alpha);
|
||||
|
||||
// scale the image
|
||||
const int zoom = disp.hex_size();
|
||||
const unsigned int zoom = disp.hex_size();
|
||||
if (zoom != game_config::tile_size) {
|
||||
image = scale_surface(image, zoom, zoom);
|
||||
}
|
||||
|
|
|
@ -81,11 +81,13 @@ const int gold_carryover_percentage = 80;
|
|||
//
|
||||
// Terrain-related constants
|
||||
//
|
||||
int tile_size = 72;
|
||||
unsigned int tile_size = 72;
|
||||
|
||||
std::string default_terrain;
|
||||
std::string shroud_prefix, fog_prefix;
|
||||
|
||||
std::vector<unsigned int> zoom_levels {36, 72, 144};
|
||||
|
||||
//
|
||||
// Display scale constants
|
||||
//
|
||||
|
@ -269,6 +271,14 @@ void load_config(const config &v)
|
|||
default_terrain = v["default_terrain"].str();
|
||||
tile_size = v["tile_size"].to_int(72);
|
||||
|
||||
std::vector<std::string> zoom_levels_str = utils::split(v["zoom_levels"]);
|
||||
if(!zoom_levels_str.empty()) {
|
||||
zoom_levels.clear();
|
||||
std::transform(zoom_levels_str.begin(), zoom_levels_str.end(), std::back_inserter(zoom_levels), [](const std::string zoom) {
|
||||
return std::stold(zoom) * tile_size;
|
||||
});
|
||||
}
|
||||
|
||||
title_music = v["title_music"].str();
|
||||
lobby_music = v["lobby_music"].str();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace game_config
|
|||
extern int rest_heal_amount;
|
||||
extern int recall_cost;
|
||||
extern int kill_experience;
|
||||
extern int tile_size;
|
||||
extern unsigned int tile_size;
|
||||
extern unsigned lobby_network_timer;
|
||||
extern unsigned lobby_refresh;
|
||||
extern const std::string version;
|
||||
|
@ -43,6 +43,8 @@ namespace game_config
|
|||
extern const std::string default_title_string;
|
||||
extern std::string default_terrain;
|
||||
|
||||
extern std::vector<unsigned int> zoom_levels;
|
||||
|
||||
inline int kill_xp(int level)
|
||||
{
|
||||
return level ? kill_experience * level : kill_experience / 2;
|
||||
|
|
|
@ -190,8 +190,8 @@ int red_adjust = 0, green_adjust = 0, blue_adjust = 0;
|
|||
/** List of colors used by the TC image modification */
|
||||
std::vector<std::string> team_colors;
|
||||
|
||||
int zoom = tile_size;
|
||||
int cached_zoom = 0;
|
||||
unsigned int zoom = tile_size;
|
||||
unsigned int cached_zoom = 0;
|
||||
|
||||
/** Algorithm choices */
|
||||
//typedef std::function<surface(const surface &, int, int)> scaling_function;
|
||||
|
@ -715,7 +715,7 @@ const std::vector<std::string>& get_team_colors()
|
|||
return team_colors;
|
||||
}
|
||||
|
||||
void set_zoom(int amount)
|
||||
void set_zoom(unsigned int amount)
|
||||
{
|
||||
if(amount != zoom) {
|
||||
zoom = amount;
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace image {
|
|||
|
||||
///sets the amount scaled images should be scaled. Invalidates all
|
||||
///scaled images.
|
||||
void set_zoom(int zoom);
|
||||
void set_zoom(unsigned int zoom);
|
||||
|
||||
/// UNSCALED : image will be drawn "as is" without changing size, even in case of redraw
|
||||
/// SCALED_TO_ZOOM : image will be scaled taking zoom into account
|
||||
|
|
Loading…
Add table
Reference in a new issue