Move all game_config foo_image into sub-namespace images...

...(as we do for sounds).

Drop the _image suffix and reorganize order.
This commit is contained in:
Ali El Gariani 2010-08-04 03:22:00 +00:00
parent f4e96fbfec
commit 52bccc12fa
14 changed files with 154 additions and 113 deletions

View file

@ -191,7 +191,7 @@ void show_about(display &disp, const std::string &campaign)
}
surface map_image(scale_surface(image::get_image(image_list[0]), screen->w, screen->h));
if(! map_image){
image_list[0]=game_config::game_title;
image_list[0]=game_config::images::game_title;
map_image=surface(scale_surface(image::get_image(image_list[0]), screen->w, screen->h));
}

View file

@ -2037,9 +2037,9 @@ void display::draw_hex(const map_location& loc) {
// Draw the grid, if that's been enabled
if(grid_ && on_map && !off_map_tile) {
drawing_buffer_add(LAYER_GRID_TOP, loc, tblit(xpos, ypos,
image::get_image(game_config::grid_image_top, image::SCALED_TO_HEX)));
image::get_image(game_config::images::grid_top, image::SCALED_TO_HEX)));
drawing_buffer_add(LAYER_GRID_BOTTOM, loc, tblit(xpos, ypos,
image::get_image(game_config::grid_image_bottom, image::SCALED_TO_HEX)));
image::get_image(game_config::images::grid_bottom, image::SCALED_TO_HEX)));
}
}
@ -2309,7 +2309,7 @@ void display::refresh_report(reports::TYPE report_num, reports::report report)
if (area.w < img->w && image_count) {
// We have more than one image, and this one doesn't fit.
img = surface(image::get_image(game_config::ellipsis_image));
img = surface(image::get_image(game_config::images::ellipsis));
used_ellipsis = true;
}

View file

@ -82,9 +82,9 @@ void editor_display::draw_hex(const map_location& loc)
image::get_image("editor/selection-overlay.png", image::SCALED_TO_HEX)));
}
if(loc == mouseoverHex_ && !game_config::mouseover_image.empty()) {
if(loc == mouseoverHex_ && !game_config::images::mouseover.empty()) {
drawing_buffer_add(LAYER_MOVE_INFO, loc, tblit(xpos, ypos,
image::get_image(game_config::mouseover_image, image::UNMASKED)));
image::get_image(game_config::images::mouseover, image::UNMASKED)));
}
}
}

View file

@ -54,29 +54,51 @@ namespace game_config
int cache_compression_level = 6;
std::string game_icon, game_title, game_logo, title_music, lobby_music;
int title_logo_x = 0, title_logo_y = 0, title_buttons_x = 0, title_buttons_y = 0, title_buttons_padding = 0,
title_tip_x = 0, title_tip_width = 0, title_tip_padding = 0;
std::string terrain_mask_image;
std::string grid_image_top;
std::string grid_image_bottom;
std::string mouseover_image;
std::string selected_image;
std::string unreachable_image; /**< overlay image for unreachable tiles. */
std::string linger_image; /**< overlay image for tiles in linger mode. */
std::string title_music,
lobby_music,
default_victory_music,
default_defeat_music;
std::string shroud_prefix;
std::string fog_prefix;
namespace images {
std::string game_icon,
game_title,
game_logo,
// orbs and hp/xp bar
moved_ball,
unmoved_ball,
partmoved_ball,
enemy_ball,
ally_ball,
energy,
// flags
flag,
flag_icon,
// hex overlay
terrain_mask,
grid_top,
grid_bottom,
mouseover,
selected,
unreachable,
///@todo de-hardcode this
linger = "terrain/darken-linger.png",
// GUI elements
observer,
tod_bright,
tod_dark,
///@todo de-hardcode this
checked_menu = "buttons/checkbox-pressed.png",
unchecked_menu = "buttons/checkbox.png",
wml_menu = "buttons/WML-custom.png",
level,
ellipsis;
} //images
std::string shroud_prefix, fog_prefix;
std::string energy_image;
std::string moved_ball_image;
std::string unmoved_ball_image;
std::string partmoved_ball_image;
std::string enemy_ball_image;
std::string ally_ball_image;
std::string flag_image;
std::string flag_icon_image;
std::string flag_rgb;
std::vector<Uint32> red_green_scale;
std::vector<Uint32> red_green_scale_text;
@ -92,19 +114,6 @@ namespace game_config
std::string foot_teleport_enter;
std::string foot_teleport_exit;
std::string observer_image;
std::string tod_bright_image;
std::string tod_dark_image;
std::string unchecked_menu_image = "buttons/checkbox.png";
std::string checked_menu_image = "buttons/checkbox-pressed.png";
std::string wml_menu_image = "buttons/WML-custom.png";
std::string level_image;
std::string ellipsis_image;
std::string default_victory_music;
std::string default_defeat_music;
std::map<std::string, color_range > team_rgb_range;
std::map<std::string, t_string > team_rgb_name;
@ -169,31 +178,40 @@ namespace game_config
kill_experience = v["kill_experience"].to_int(8);
lobby_refresh = v["lobby_refresh"].to_int(2000);
game_icon = v["icon"].str();
game_title = v["title"].str();
game_logo = v["logo"].str();
title_music = v["title_music"].str();
lobby_music = v["lobby_music"].str();
default_victory_music = v["default_victory_music"].str();
default_defeat_music = v["default_defeat_music"].str();
title_logo_x = v["logo_x"];
title_logo_y = v["logo_y"];
title_buttons_x = v["buttons_x"];
title_buttons_y = v["buttons_y"];
title_buttons_padding = v["buttons_padding"];
{
using namespace game_config::images;
game_icon = v["icon"].str();
game_title = v["title"].str();
game_logo = v["logo"].str();
title_tip_x = v["tip_x"].to_int();
title_tip_width = v["tip_width"].to_int();
title_tip_padding = v["tip_padding"].to_int();
moved_ball = v["moved_ball_image"].str();
unmoved_ball = v["unmoved_ball_image"].str();
partmoved_ball = v["partmoved_ball_image"].str();
enemy_ball = v["enemy_ball_image"].str();
ally_ball = v["ally_ball_image"].str();
energy = v["energy_image"].str();
flag = v["flag_image"].str();
flag_icon = v["flag_icon_image"].str();
energy_image = v["energy_image"].str();
moved_ball_image = v["moved_ball_image"].str();
unmoved_ball_image = v["unmoved_ball_image"].str();
partmoved_ball_image = v["partmoved_ball_image"].str();
enemy_ball_image = v["enemy_ball_image"].str();
ally_ball_image = v["ally_ball_image"].str();
flag_image = v["flag_image"].str();
flag_icon_image = v["flag_icon_image"].str();
terrain_mask = v["terrain_mask_image"].str();
grid_top = v["grid_image_top"].str();
grid_bottom = v["grid_image_bottom"].str();
mouseover = v["mouseover_image"].str();
selected = v["selected_image"].str();
unreachable = v["unreachable_image"].str();
observer = v["observer_image"].str();
tod_bright = v["tod_bright_image"].str();
tod_dark = v["tod_dark_image"].str();
level = v["level_image"].str();
ellipsis = v["ellipsis_image"].str();
} // images
hp_bar_scaling = v["hp_bar_scaling"].to_double(0.666);
xp_bar_scaling = v["xp_bar_scaling"].to_double(0.5);
@ -205,28 +223,23 @@ namespace game_config
foot_teleport_enter = v["footprint_teleport_enter"].str();
foot_teleport_exit = v["footprint_teleport_exit"].str();
terrain_mask_image = v["terrain_mask_image"].str();
grid_image_top = v["grid_image_top"].str();
grid_image_bottom = v["grid_image_bottom"].str();
mouseover_image = v["mouseover_image"].str();
selected_image = v["selected_image"].str();
unreachable_image = v["unreachable_image"].str();
title_logo_x = v["logo_x"];
title_logo_y = v["logo_y"];
title_buttons_x = v["buttons_x"];
title_buttons_y = v["buttons_y"];
title_buttons_padding = v["buttons_padding"];
title_tip_x = v["tip_x"].to_int();
title_tip_width = v["tip_width"].to_int();
title_tip_padding = v["tip_padding"].to_int();
shroud_prefix = v["shroud_prefix"].str();
fog_prefix = v["fog_prefix"].str();
observer_image = v["observer_image"].str();
tod_bright_image = v["tod_bright_image"].str();
tod_dark_image = v["tod_dark_image"].str();
level_image = v["level_image"].str();
ellipsis_image = v["ellipsis_image"].str();
default_victory_music = v["default_victory_music"].str();
default_defeat_music = v["default_defeat_music"].str();
add_color_info(v);
if (const config::attribute_value *a = v.get("flag_rgb")) flag_rgb = a->str();
if (const config::attribute_value *a = v.get("flag_rgb"))
flag_rgb = a->str();
red_green_scale = string2rgb(v["red_green_scale"]);
if (red_green_scale.empty()) {

View file

@ -64,18 +64,46 @@ namespace game_config
};
extern std::vector<server_info> server_list;
extern std::string game_icon, game_title, game_logo, title_music, lobby_music,
moved_ball_image, unmoved_ball_image, partmoved_ball_image,
enemy_ball_image, ally_ball_image, energy_image,
flag_image, flag_icon_image,
terrain_mask_image,
grid_image_top, grid_image_bottom,
mouseover_image, selected_image,
unreachable_image, linger_image,
shroud_prefix, fog_prefix,
observer_image, tod_bright_image, tod_dark_image,
checked_menu_image, unchecked_menu_image, wml_menu_image, level_image,
ellipsis_image, default_victory_music, default_defeat_music;
extern std::string title_music,
lobby_music,
default_victory_music,
default_defeat_music;
namespace images {
extern std::string game_icon,
game_title,
game_logo,
// orbs and hp/xp bar
moved_ball,
unmoved_ball,
partmoved_ball,
enemy_ball,
ally_ball,
energy,
// flags
flag,
flag_icon,
// hex overlay
terrain_mask,
grid_top,
grid_bottom,
mouseover,
selected,
unreachable,
linger,
// GUI elements
observer,
tod_bright,
tod_dark,
checked_menu,
unchecked_menu,
wml_menu,
level,
ellipsis;
} //images
extern std::string shroud_prefix, fog_prefix;
extern double hp_bar_scaling, xp_bar_scaling;
extern double hex_brightening;

View file

@ -99,7 +99,7 @@ game_display::game_display(unit_map& units, CVideo& video, const gamemap& map,
std::string new_rgb = side_color;
if(flag.empty()) {
flag = game_config::flag_image;
flag = game_config::images::flag;
}
LOG_DP << "Adding flag for team " << i << " from animation " << flag << "\n";
@ -358,7 +358,7 @@ void game_display::draw_hex(const map_location& loc)
if (!is_shrouded && !reach_map_.empty()
&& reach_map_.find(loc) == reach_map_.end() && loc != attack_indicator_dst_) {
drawing_buffer_add(LAYER_REACHMAP, loc, tblit(xpos, ypos,
image::get_image(game_config::unreachable_image,image::UNMASKED)));
image::get_image(game_config::images::unreachable,image::UNMASKED)));
}
resources::whiteboard->draw_hex(loc);
@ -383,19 +383,19 @@ void game_display::draw_hex(const map_location& loc)
// Linger overlay unconditionally otherwise it might give glitches
// so it's drawn over the shroud and fog.
if(game_mode_ != RUNNING) {
blit.surf.push_back(image::get_image(game_config::linger_image, image::SCALED_TO_HEX));
blit.surf.push_back(image::get_image(game_config::images::linger, image::SCALED_TO_HEX));
drawing_buffer_add(LAYER_LINGER_OVERLAY, loc, blit);
blit.surf.clear();
}
if(on_map && loc == selectedHex_ && !game_config::selected_image.empty()) {
if(on_map && loc == selectedHex_ && !game_config::images::selected.empty()) {
drawing_buffer_add(LAYER_MOVE_INFO, loc, tblit(xpos, ypos,
image::get_image(game_config::selected_image, image::UNMASKED)));
image::get_image(game_config::images::selected, image::UNMASKED)));
}
if(on_map && loc == mouseoverHex_ && !game_config::mouseover_image.empty()) {
if(on_map && loc == mouseoverHex_ && !game_config::images::mouseover.empty()) {
drawing_buffer_add(LAYER_MOVE_INFO, loc, tblit(xpos, ypos,
image::get_image(game_config::mouseover_image, image::UNMASKED)));
image::get_image(game_config::images::mouseover, image::UNMASKED)));
}
// Show def% and turn to reach infos

View file

@ -123,7 +123,7 @@ report generate_report(TYPE type,
std::string mods = "~RC(" + old_rgb + ">" + new_rgb + ")";
if(flag_icon.empty()) {
flag_icon = game_config::flag_icon_image;
flag_icon = game_config::images::flag_icon;
}
image::locator flag_icon_img(flag_icon, mods);
@ -678,7 +678,7 @@ report generate_report(TYPE type,
std::string mods = "~RC(" + old_rgb + ">" + new_rgb + ")";
if(flag_icon.empty()) {
flag_icon = game_config::flag_icon_image;
flag_icon = game_config::images::flag_icon;
}
image::locator flag_icon_img(flag_icon, mods);
@ -696,7 +696,7 @@ report generate_report(TYPE type,
str << *i << "\n";
}
return report("",game_config::observer_image,str.str());
return report("",game_config::images::observer,str.str());
}
#ifdef DISABLE_EDITOR
case EDITOR_SELECTED_TERRAIN:

View file

@ -209,7 +209,7 @@ void ttitle_screen::pre_show(CVideo& video, twindow& window)
/***** Select a random game_title *****/
std::vector<std::string> game_title_list =
utils::split(game_config::game_title
utils::split(game_config::images::game_title
, ','
, utils::STRIP_SPACES | utils::REMOVE_EMPTY);

View file

@ -994,8 +994,8 @@ void command_executor::show_menu(const std::vector<std::string>& items_arg, int
std::string command_executor::get_menu_image(hotkey::HOTKEY_COMMAND command, int index) const {
switch(get_action_state(command, index)) {
case ACTION_ON: return game_config::checked_menu_image;
case ACTION_OFF: return game_config::unchecked_menu_image;
case ACTION_ON: return game_config::images::checked_menu;
case ACTION_OFF: return game_config::images::unchecked_menu;
default: return get_action_image(command, index);
}
}

View file

@ -477,7 +477,7 @@ surface locator::load_image_file() const
surface locator::load_image_sub_file() const
{
const surface mother_surface(get_image(val_.filename_, UNSCALED));
const surface mask(get_image(game_config::terrain_mask_image, UNSCALED));
const surface mask(get_image(game_config::images::terrain_mask, UNSCALED));
if(mother_surface == NULL)
return surface(NULL);
@ -881,7 +881,7 @@ manager::~manager()
void set_wm_icon()
{
#if !(defined(__APPLE__))
surface icon(get_image(game_config::game_icon,UNSCALED));
surface icon(get_image(game_config::images::game_icon,UNSCALED));
if(icon != NULL) {
::SDL_WM_SetIcon(icon,NULL);
}
@ -968,7 +968,7 @@ static surface get_hexed(const locator& i_locator)
{
surface image(get_image(i_locator, UNSCALED));
// Re-cut scaled tiles according to a mask.
const surface hex(get_image(game_config::terrain_mask_image,
const surface hex(get_image(game_config::images::terrain_mask,
UNSCALED));
return mask_surface(image, hex);
}
@ -1127,7 +1127,7 @@ bool is_in_hex(const locator& i_locator)
if(i_locator.in_cache(in_hex_info_)) {
return i_locator.locate_in_cache(in_hex_info_);
} else {
const surface mask(get_image(game_config::terrain_mask_image, UNSCALED));
const surface mask(get_image(game_config::images::terrain_mask, UNSCALED));
const surface image(get_image(i_locator, UNSCALED));
bool res = in_mask_surface(image, mask);

View file

@ -135,7 +135,7 @@ surface bl_function::operator()(const surface& src) const
surface brighten_function::operator()(const surface &src) const
{
surface ret = make_neutral_surface(src);
surface tod_bright(image::get_image(game_config:: tod_bright_image));
surface tod_bright(image::get_image(game_config::images:: tod_bright));
if (tod_bright)
blit_surface(tod_bright, NULL, ret, NULL);
return ret;
@ -144,7 +144,7 @@ surface brighten_function::operator()(const surface &src) const
surface darken_function::operator()(const surface &src) const
{
surface ret = make_neutral_surface(src);
surface tod_dark(image::get_image(game_config:: tod_dark_image));
surface tod_dark(image::get_image(game_config::images::tod_dark));
if (tod_dark)
blit_surface(tod_dark, NULL, ret, NULL);
return ret;

View file

@ -1185,7 +1185,7 @@ std::string play_controller::get_action_image(hotkey::HOTKEY_COMMAND command, in
if(index >= 0 && index < static_cast<int>(wml_commands_.size())) {
wml_menu_item* const& wmi = wml_commands_[index];
if(wmi != NULL) {
return wmi->image.empty() ? game_config::wml_menu_image : wmi->image;
return wmi->image.empty() ? game_config::images::wml_menu : wmi->image;
}
}
return command_executor::get_action_image(command, index);

View file

@ -79,7 +79,7 @@ static bool fade_logo(game_display& screen, int xcpos, int ycpos)
surface const fb = screen.video().getSurface();
if (!fb) return true;
surface logo = image::get_image(game_config::game_logo);
surface logo = image::get_image(game_config::images::game_logo);
if (!logo) {
ERR_DP << "Could not find game logo\n";
return true;
@ -322,7 +322,7 @@ static void draw_background(game_display& screen)
/*Select a random game_title*/
std::vector<std::string> game_title_list =
utils::split(game_config::game_title, ',', utils::STRIP_SPACES | utils::REMOVE_EMPTY);
utils::split(game_config::images::game_title, ',', utils::STRIP_SPACES | utils::REMOVE_EMPTY);
if(game_title_list.empty()) {
ERR_CF << "No title image defined\n";

View file

@ -1881,22 +1881,22 @@ void unit::redraw_unit()
if(draw_bars) {
const std::string* movement_file = NULL;
const std::string* energy_file = &game_config::energy_image;
const std::string* energy_file = &game_config::images::energy;
if(size_t(side()) != disp.viewing_team()+1) {
if(disp.team_valid() &&
disp.get_teams()[disp.viewing_team()].is_enemy(side())) {
movement_file = &game_config::enemy_ball_image;
movement_file = &game_config::images::enemy_ball;
} else {
movement_file = &game_config::ally_ball_image;
movement_file = &game_config::images::ally_ball;
}
} else {
movement_file = &game_config::moved_ball_image;
movement_file = &game_config::images::moved_ball;
if(disp.playing_team() == disp.viewing_team() && !user_end_turn()) {
if (movement_left() == total_movement()) {
movement_file = &game_config::unmoved_ball_image;
movement_file = &game_config::images::unmoved_ball;
} else if (unit_can_move(*this)) {
movement_file = &game_config::partmoved_ball_image;
movement_file = &game_config::images::partmoved_ball;
}
}
}
@ -2116,7 +2116,7 @@ std::map<std::string,std::string> unit::advancement_icons() const
if (!advances_to_.empty())
{
std::ostringstream tooltip;
const std::string &image = game_config::level_image;
const std::string &image = game_config::images::level;
foreach (const std::string &s, advances_to())
{
if (!s.empty())