whitespace cleanup
This commit is contained in:
parent
3114104345
commit
99bbbd6a51
38 changed files with 441 additions and 441 deletions
|
@ -309,7 +309,7 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
|
||||
res.attacker_hp = a->second.hitpoints();
|
||||
res.defender_hp = d->second.hitpoints();
|
||||
|
||||
|
||||
res.chance_to_hit_attacker = a->second.defense_modifier(map,attacker_terrain);
|
||||
res.chance_to_hit_defender = d->second.defense_modifier(map,defender_terrain);
|
||||
|
||||
|
@ -539,7 +539,7 @@ battle_stats evaluate_battle_stats(const gamemap& map,
|
|||
resistance_modifier -= diff*steadfast_bonus/100;
|
||||
} else {
|
||||
resistance_modifier -= steadfast_bonus;
|
||||
}
|
||||
}
|
||||
if(resistance_modifier < steadfast_max) {
|
||||
resistance_modifier = steadfast_max;
|
||||
}
|
||||
|
@ -1239,7 +1239,7 @@ void calculate_healing(display& disp, const gamestatus& status, const gamemap& m
|
|||
if(i->second.side() == side) {
|
||||
if(i->second.hitpoints() < i->second.max_hitpoints() || i->second.poisoned()){
|
||||
if(map.gives_healing(i->first)) {
|
||||
amount_healed = game_config::cure_amount;
|
||||
amount_healed = game_config::cure_amount;
|
||||
} else if(i->second.type().regenerates()) {
|
||||
amount_healed = i->second.type().regenerate_amount();
|
||||
}
|
||||
|
|
|
@ -109,9 +109,9 @@ protected:
|
|||
const double attack_rating = stats.damage_defender_takes
|
||||
*stats.nattacks*stats.chance_to_hit_defender*attacks[n].attack_weight();
|
||||
if(best_attack == -1 || attack_rating > best_attack_rating) {
|
||||
best_attack = n;
|
||||
best_attack_rating = attack_rating;
|
||||
}
|
||||
best_attack = n;
|
||||
best_attack_rating = attack_rating;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -332,7 +332,7 @@ int ai::choose_weapon(const location& att, const location& def,
|
|||
//TODO: improve this rating formula!
|
||||
const double rating =
|
||||
(double(stats.chance_to_hit_defender)/100.0)*
|
||||
minimum<int>(stats.damage_defender_takes,d_hitpoints)*stats.nattacks *
|
||||
minimum<int>(stats.damage_defender_takes,d_hitpoints)*stats.nattacks *
|
||||
attacks[a].attack_weight() -
|
||||
(double(stats.chance_to_hit_attacker)/100.0)*
|
||||
minimum<int>(stats.damage_attacker_takes,a_hitpoints)*stats.ndefends;
|
||||
|
@ -456,8 +456,8 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_s
|
|||
atthp = hitpoints[i];
|
||||
}
|
||||
|
||||
if(stat.attacker_slows && !defender_slowed) {
|
||||
defender_slowed = true;
|
||||
if(stat.attacker_slows && !defender_slowed) {
|
||||
defender_slowed = true;
|
||||
stat.damage_defender_takes = round_damage(stat.damage_defender_takes,1,2);
|
||||
stat.amount_attacker_drains = round_damage(stat.amount_attacker_drains,1,2);
|
||||
}
|
||||
|
@ -487,8 +487,8 @@ void ai::attack_analysis::analyze(const gamemap& map, unit_map& units, int num_s
|
|||
if(defhp > target_max_hp) {
|
||||
defhp = target_max_hp;
|
||||
}
|
||||
if(stat.defender_slows && !attacker_slowed) {
|
||||
attacker_slowed = true;
|
||||
if(stat.defender_slows && !attacker_slowed) {
|
||||
attacker_slowed = true;
|
||||
stat.damage_attacker_takes = round_damage(stat.damage_attacker_takes,1,2);
|
||||
stat.amount_defender_drains = round_damage(stat.amount_defender_drains,1,2);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef AI_DFOOL_HPP_INCLUDED
|
||||
#define AI_DFOOL_HPP_INCLUDED
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "ai_interface.hpp"
|
||||
#include "map.hpp"
|
||||
#include <vector>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
be exposed.
|
||||
- turn_info, does not need to be exposed.
|
||||
|
||||
Additionally, useful utility functions such as those found in pathutils.hpp should be exposed.
|
||||
Additionally, useful utility functions such as those found in pathutils.hpp should be exposed.
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ std::string get_unique_saveid(const config& cfg, std::set<std::string>& seen_sav
|
|||
|
||||
void get_player_info(const config& cfg, game_state& gamestate, std::string save_id, std::vector<team>& teams, const config& level, const game_data& gameinfo, gamemap& map, unit_map& units){
|
||||
player_info *player = NULL;
|
||||
|
||||
|
||||
if(cfg["controller"] == "human" ||
|
||||
cfg["controller"] == "network" ||
|
||||
cfg["persistent"] == "1") {
|
||||
|
|
|
@ -119,7 +119,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
|
||||
//must recolor flag image
|
||||
animated<image::locator> temp_anim;
|
||||
|
||||
|
||||
std::vector<std::string> items = utils::split(flag);
|
||||
int current_time = 0;
|
||||
std::vector<std::string>::const_iterator itor = items.begin();
|
||||
|
@ -2320,12 +2320,12 @@ void display::set_grid(bool grid)
|
|||
// Uses preferences::clock_format() for formatting.
|
||||
char *timestring ( void )
|
||||
{
|
||||
#define TIME_SIZE 10
|
||||
#define TIME_SIZE 10
|
||||
|
||||
time_t now = time ( NULL );
|
||||
struct tm *lt = localtime( &now );
|
||||
|
||||
char *tstring;
|
||||
char *tstring;
|
||||
tstring = new char[TIME_SIZE];
|
||||
strftime(tstring,TIME_SIZE,preferences::clock_format().c_str(),lt);
|
||||
return tstring;
|
||||
|
|
|
@ -401,7 +401,7 @@ void map_editor::change_language() {
|
|||
gamemap new_map(game_config_, map_.write());
|
||||
map_ = new_map;
|
||||
|
||||
// Update the selected terrain strings
|
||||
// Update the selected terrain strings
|
||||
palette_.update_selected_terrains();
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ int main(int argc, char** argv)
|
|||
++arg;
|
||||
choosen_bpp = lexical_cast_default<int>(argv[arg]);
|
||||
}
|
||||
|
||||
|
||||
else if(val == "--resolution" || val == "-r") {
|
||||
if(arg+1 != argc) {
|
||||
++arg;
|
||||
|
@ -165,7 +165,7 @@ int main(int argc, char** argv)
|
|||
image::set_wm_icon();
|
||||
int video_flags = preferences::fullscreen() ? FULL_SCREEN : 0;
|
||||
std::pair<int,int> resolution = preferences::resolution();
|
||||
|
||||
|
||||
std::cerr << "checking mode possible...\n";
|
||||
const int default_bpp = 24;
|
||||
int bpp = default_bpp;
|
||||
|
@ -212,7 +212,7 @@ int main(int argc, char** argv)
|
|||
} else {
|
||||
bpp = choosen_bpp;
|
||||
}
|
||||
|
||||
|
||||
std::cerr << "setting mode to " << resolution.first << "x" << resolution.second << "\n";
|
||||
const int res = video.setMode(resolution.first,resolution.second,bpp,video_flags);
|
||||
video.setBpp(bpp);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace game_config
|
|||
const std::string version = VERSION;
|
||||
bool debug = false, editor = false, ignore_replay_errors = false;
|
||||
|
||||
std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music, anonymous_music,
|
||||
std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music, anonymous_music,
|
||||
victory_music, defeat_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_y = 0, title_tip_width = 0, title_tip_padding = 0;
|
||||
|
@ -162,7 +162,7 @@ namespace game_config
|
|||
download_campaign_image = v["download_campaign_image"];
|
||||
level_image = v["level_image"];
|
||||
ellipsis_image = v["ellipsis_image"];
|
||||
|
||||
|
||||
const config::child_list& team_colors = v.get_children("team_color");
|
||||
for(config::child_list::const_iterator teamC = team_colors.begin(); teamC != team_colors.end(); ++teamC) {
|
||||
if(!(**teamC)["side"].empty() && !(**teamC)["team_rgb"].empty()){
|
||||
|
|
|
@ -40,12 +40,12 @@ namespace game_config
|
|||
|
||||
extern std::string path;
|
||||
|
||||
extern std::string game_icon, game_title, game_logo, title_music, map_image, rightside_image, rightside_image_bot,
|
||||
extern std::string game_icon, game_title, game_logo, title_music, map_image, rightside_image, rightside_image_bot,
|
||||
anonymous_music, victory_music, defeat_music,
|
||||
moved_ball_image, unmoved_ball_image, partmoved_ball_image,
|
||||
enemy_ball_image, ally_ball_image, energy_image,
|
||||
flag_image, dot_image, cross_image,
|
||||
missile_n_image, missile_ne_image,
|
||||
moved_ball_image, unmoved_ball_image, partmoved_ball_image,
|
||||
enemy_ball_image, ally_ball_image, energy_image,
|
||||
flag_image, dot_image, cross_image,
|
||||
missile_n_image, missile_ne_image,
|
||||
terrain_mask_image, observer_image, download_campaign_image,
|
||||
checked_menu_image, unchecked_menu_image, level_image,ellipsis_image;
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ surface locator::load_image_file() const
|
|||
surface res;
|
||||
|
||||
std::string location = get_binary_file_location("images", val_.filename_);
|
||||
|
||||
|
||||
bool try_units = false;
|
||||
|
||||
do {
|
||||
|
|
|
@ -204,7 +204,7 @@ gamemap::location::DIRECTION gamemap::location::get_relative_dir(gamemap::locati
|
|||
if( diff.y >= 0 && diff.x >= 0 && abs(diff.x) >= abs(diff.y)) return SOUTH_EAST;
|
||||
if( diff.y >= 0 && diff.x < 0 && abs(diff.x) >= abs(diff.y)) return SOUTH_WEST;
|
||||
if( diff.y >= 0 && abs(diff.x) < abs(diff.y)) return SOUTH;
|
||||
|
||||
|
||||
//impossible
|
||||
wassert(false);
|
||||
return NDIRECTIONS;
|
||||
|
|
|
@ -324,7 +324,7 @@ namespace events{
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void menu_handler::write_game_snapshot(config& start, const config& level, display& gui,
|
||||
std::vector<team>& teams, const unit_map& units, const gamestatus& status,
|
||||
const game_state& gamestate, const gamemap& map) const
|
||||
|
|
|
@ -344,12 +344,12 @@ config connect::side::get_config() const
|
|||
if(!parent_->params_.use_map_settings || res["shroud"].empty() || (res["shroud"] != "yes" && res["shroud"] != "no")) {
|
||||
res["shroud"] = parent_->params_.shroud_game ? "yes" : "no";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!parent_->params_.use_map_settings || res["mp_countdown"].empty() || (res["mp_countdown"] != "yes" && res["mp_countdown"] != "no")) {
|
||||
res["mp_countdown"] = parent_->params_.mp_countdown ? "yes" : "no";;
|
||||
}
|
||||
|
||||
|
||||
if(!parent_->params_.use_map_settings || res["mp_countdown_init_time"].empty()) {
|
||||
res["mp_countdown_init_time"] = lexical_cast<std::string>(parent_->params_.mp_countdown_init_time);
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ config connect::side::get_config() const
|
|||
res["mp_countdown_turn_bonus"] = lexical_cast<std::string>(parent_->params_.mp_countdown_turn_bonus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
res["share_maps"] = parent_->params_.share_maps ? "yes" : "no";
|
||||
res["share_view"] = parent_->params_.share_view ? "yes" : "no";
|
||||
if(!parent_->params_.use_map_settings || res["village_gold"].empty())
|
||||
|
@ -1007,9 +1007,9 @@ void connect::load_game()
|
|||
level_["mp_countdown"] = params_.mp_countdown ? "yes" : "no";
|
||||
level_["mp_countdown_init_time"] = lexical_cast_default<std::string>(params_.mp_countdown_init_time, "600");
|
||||
level_["mp_countdown_turn_bonus"] = lexical_cast_default<std::string>(params_.mp_countdown_turn_bonus, "100");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const std::string& era = params_.era;
|
||||
|
||||
// Initialize the list of sides available for the current era.
|
||||
|
|
|
@ -101,7 +101,7 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
|
|||
|
||||
countdown_game_.set_check(preferences::countdown());
|
||||
countdown_game_.set_help_string(_("Enables user time limit"));
|
||||
|
||||
|
||||
countdown_init_time_slider_.set_min(0);
|
||||
countdown_init_time_slider_.set_max(7200);
|
||||
countdown_init_time_slider_.set_increment(30);
|
||||
|
@ -112,8 +112,8 @@ create::create(display& disp, const config &cfg, chat& c, config& gamelist) :
|
|||
countdown_turn_bonus_slider_.set_max(1000);
|
||||
countdown_turn_bonus_slider_.set_increment(10);
|
||||
countdown_turn_bonus_slider_.set_value(preferences::countdown_turn_bonus());
|
||||
countdown_turn_bonus_slider_.set_help_string(_("Time added to user's clock at the end of each turn"));
|
||||
|
||||
countdown_turn_bonus_slider_.set_help_string(_("Time added to user's clock at the end of each turn"));
|
||||
|
||||
village_gold_slider_.set_min(1);
|
||||
village_gold_slider_.set_max(5);
|
||||
village_gold_slider_.set_value(preferences::village_gold());
|
||||
|
@ -183,7 +183,7 @@ create::~create()
|
|||
preferences::set_turns(parameters_.num_turns);
|
||||
preferences::set_countdown(parameters_.mp_countdown);
|
||||
preferences::set_countdown_init_time(parameters_.mp_countdown_init_time);
|
||||
preferences::set_countdown_turn_bonus(parameters_.mp_countdown_turn_bonus);
|
||||
preferences::set_countdown_turn_bonus(parameters_.mp_countdown_turn_bonus);
|
||||
preferences::set_village_gold(parameters_.village_gold);
|
||||
preferences::set_xp_modifier(parameters_.xp_modifier);
|
||||
preferences::set_era(era_combo_.selected()); // FIXME: may be broken if new eras are added
|
||||
|
@ -211,7 +211,7 @@ create::parameters& create::get_parameters()
|
|||
parameters_.era = (*era_list[era_combo_.selected()])["id"];
|
||||
parameters_.num_turns = turns;
|
||||
parameters_.mp_countdown_init_time = mp_countdown_init_time_val;
|
||||
parameters_.mp_countdown_turn_bonus = mp_countdown_turn_bonus_val;
|
||||
parameters_.mp_countdown_turn_bonus = mp_countdown_turn_bonus_val;
|
||||
parameters_.mp_countdown = countdown_game_.checked();
|
||||
parameters_.village_gold = village_gold_slider_.value();
|
||||
parameters_.xp_modifier = xp_modifier_slider_.value();
|
||||
|
@ -255,22 +255,22 @@ void create::process_event()
|
|||
buf << _("Unlimited Turns");
|
||||
}
|
||||
turns_label_.set_text(buf.str());
|
||||
|
||||
|
||||
countdown_init_time_label_.hide(!countdown_game_.checked());
|
||||
countdown_init_time_slider_.hide(!countdown_game_.checked());
|
||||
countdown_turn_bonus_label_.hide(!countdown_game_.checked());
|
||||
countdown_turn_bonus_slider_.hide(!countdown_game_.checked());
|
||||
|
||||
|
||||
const int mp_countdown_init_time_val = countdown_init_time_slider_.value();
|
||||
buf.str("");
|
||||
buf << _("Initial Time: ") << mp_countdown_init_time_val;
|
||||
countdown_init_time_label_.set_text(buf.str());
|
||||
|
||||
|
||||
const int mp_countdown_turn_bonus_val = countdown_turn_bonus_slider_.value();
|
||||
buf.str("");
|
||||
buf << _("Turn time: ") << mp_countdown_turn_bonus_val;
|
||||
countdown_turn_bonus_label_.set_text(buf.str());
|
||||
|
||||
|
||||
//Villages can produce between 1 and 10 gold a turn
|
||||
const int village_gold = village_gold_slider_.value();
|
||||
buf.str("");
|
||||
|
@ -421,13 +421,13 @@ void create::hide_children(bool hide)
|
|||
maps_menu_.hide(hide);
|
||||
turns_slider_.hide(hide);
|
||||
turns_label_.hide(hide);
|
||||
|
||||
|
||||
countdown_init_time_slider_.hide(hide);
|
||||
countdown_init_time_label_.hide(hide);
|
||||
countdown_turn_bonus_slider_.hide(hide);
|
||||
countdown_turn_bonus_label_.hide(hide);
|
||||
countdown_game_.hide(hide);
|
||||
|
||||
|
||||
village_gold_slider_.hide(hide);
|
||||
village_gold_label_.hide(hide);
|
||||
xp_modifier_slider_.hide(hide);
|
||||
|
@ -536,7 +536,7 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
turns_slider_.set_location(xpos, ypos);
|
||||
ypos += turns_slider_.height() + border_size;
|
||||
|
||||
|
||||
|
||||
village_gold_label_.set_location(xpos, ypos);
|
||||
ypos += village_gold_label_.height() + border_size;
|
||||
village_gold_slider_.set_width(ca.w - xpos);
|
||||
|
@ -550,7 +550,7 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
ypos += xp_modifier_slider_.height() + border_size;
|
||||
|
||||
use_map_settings_.set_location(xpos, ypos);
|
||||
ypos += use_map_settings_.height() + border_size;
|
||||
ypos += use_map_settings_.height() + border_size;
|
||||
|
||||
countdown_init_time_label_.set_location(xpos, ypos);
|
||||
countdown_turn_bonus_label_.set_location(xpos + (ca.w - xpos)/2 + 5 , ypos);
|
||||
|
@ -560,9 +560,9 @@ void create::layout_children(const SDL_Rect& rect)
|
|||
countdown_init_time_slider_.set_location(xpos, ypos);
|
||||
countdown_turn_bonus_slider_.set_location(xpos + (ca.w - xpos)/2 + 5, ypos);
|
||||
ypos += countdown_init_time_slider_.height() + border_size;
|
||||
|
||||
|
||||
countdown_game_.set_location(xpos, ypos);
|
||||
// ypos += countdown_game_.height() + border_size;
|
||||
// ypos += countdown_game_.height() + border_size;
|
||||
|
||||
fog_game_.set_location(xpos + (ca.w - xpos)/2 + 5, ypos);
|
||||
ypos += fog_game_.height() + border_size;
|
||||
|
|
|
@ -294,7 +294,7 @@ void gamebrowser::set_game_items(const config& cfg, const config& game_config)
|
|||
if((**game)["mp_era"] != "") {
|
||||
const config* const era_cfg = game_config.find_child("era", "id", (**game)["mp_era"]);
|
||||
games_.back().map_info = era_cfg != NULL ? era_cfg->get_attribute("name") : _("Unknown era");
|
||||
|
||||
|
||||
} else {
|
||||
games_.back().map_info = _("Unknown era");
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ void gamebrowser::set_game_items(const config& cfg, const config& game_config)
|
|||
} else {
|
||||
games_.back().time_limit = "";
|
||||
}
|
||||
|
||||
|
||||
games_.back().xp = (**game)["experience_modifier"] + "%";
|
||||
games_.back().observers = (**game)["observer"] != "no" ? true : false;
|
||||
}
|
||||
|
|
|
@ -143,8 +143,8 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
if(map_data == "" && (*level)["map"] != "") {
|
||||
map_data = read_map((*level)["map"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//if the map should be randomly generated
|
||||
if(map_data == "" && (*level)["map_generation"] != "") {
|
||||
|
@ -168,8 +168,8 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
const statistics::scenario_context statistics_context(lvl["name"]);
|
||||
|
||||
const int num_turns = atoi(lvl["turns"].c_str());
|
||||
|
||||
|
||||
|
||||
|
||||
gamestatus status(*level,num_turns);
|
||||
|
||||
gamemap map(game_config,map_data);
|
||||
|
@ -350,18 +350,18 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
for(t = teams.begin(); t != teams.end(); ++t) {
|
||||
clear_shroud(gui,status,map,gameinfo,units,teams,(t-teams.begin()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(!loading_game) {
|
||||
game_events::fire("start");
|
||||
state_of_game.set_variable("turn_number", "1");
|
||||
}
|
||||
|
||||
// Initialize countdown clock.
|
||||
// Initialize countdown clock.
|
||||
for(t = teams.begin(); t != teams.end(); ++t) {
|
||||
std::string countd_enabled = lvl["mp_countdown"].c_str();
|
||||
if ( countd_enabled == "yes" && !loading_game ){
|
||||
t->set_countdown_time(1000 * lexical_cast_default<int>(lvl["mp_countdown_init_time"],0));
|
||||
t->set_countdown_time(1000 * lexical_cast_default<int>(lvl["mp_countdown_init_time"],0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,7 +445,7 @@ LEVEL_RESULT play_level(const game_data& gameinfo, const config& game_config,
|
|||
LOG_NG << "result of replay: " << (replaying?"true":"false") << "\n";
|
||||
}
|
||||
|
||||
if(!replaying && team_it->music().empty() == false &&
|
||||
if(!replaying && team_it->music().empty() == false &&
|
||||
(teams[gui.viewing_team()].knows_about_team(player_number-1) || teams[gui.viewing_team()].has_seen(player_number-1))) {
|
||||
LOG_NG << "playing music: '" << team_it->music() << "'\n";
|
||||
sound::play_music(team_it->music());
|
||||
|
@ -460,7 +460,7 @@ redo_turn:
|
|||
|
||||
if(!replaying && team_it->is_human()) {
|
||||
LOG_NG << "is human...\n";
|
||||
|
||||
|
||||
try {
|
||||
play_turn(gameinfo,state_of_game,status,game_config,
|
||||
*level, key, gui, map, teams, player_number,
|
||||
|
@ -469,10 +469,10 @@ redo_turn:
|
|||
if (end_turn.redo == player_number)
|
||||
goto redo_turn;
|
||||
}
|
||||
|
||||
|
||||
if(game_config::debug)
|
||||
display::clear_debug_highlights();
|
||||
|
||||
|
||||
LOG_NG << "human finished turn...\n";
|
||||
|
||||
} else if(!replaying && team_it->is_ai()) {
|
||||
|
|
|
@ -111,16 +111,16 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
unit_map::const_iterator ui = units.find(*g);
|
||||
turn_data.move_unit_to_loc(ui,ui->second.get_goto(),false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cur_ticks = SDL_GetTicks();
|
||||
int beep_warning_time = 10000; //Starts beeping each second when time is less than this (millisec)
|
||||
|
||||
turn_data.start_interactive_turn();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while(!turn_data.turn_over()) {
|
||||
|
||||
try {
|
||||
|
@ -137,7 +137,7 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
turn_data.send_data();
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (teams[team_num -1].countdown_time() > 0 && ( level["mp_countdown"] == "yes" ) ){
|
||||
SDL_Delay(1);
|
||||
|
@ -169,10 +169,10 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
turn_data.send_data();
|
||||
throw end_turn_exception();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// gui.invalidate_animations();
|
||||
gui.draw();
|
||||
|
||||
|
@ -180,7 +180,7 @@ void play_turn(const game_data& gameinfo, game_state& state_of_game,
|
|||
}
|
||||
if ( level["mp_countdown"] == "yes" ){
|
||||
teams[team_num -1].set_countdown_time(teams[team_num -1].countdown_time() + 1000 * lexical_cast_default<int>(level["mp_countdown_turn_bonus"],0));
|
||||
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
|
||||
recorder.add_countdown_update(teams[team_num -1].countdown_time(),team_num);
|
||||
}
|
||||
|
||||
//send one more time to make sure network is up-to-date.
|
||||
|
@ -497,22 +497,22 @@ public:
|
|||
//if our weapon can kill the enemy in one blow, the enemy does not
|
||||
//drain back and our weapon has more blows, prefer our weapon
|
||||
if(stats_.damage_defender_takes >= stats_.defender_hp &&
|
||||
stats_.amount_defender_drains == 0 &&
|
||||
stats_.amount_defender_drains == 0 &&
|
||||
stats_.nattacks > a.stats_.nattacks)
|
||||
{
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int this_avg_damage_dealt = stats_.chance_to_hit_defender *
|
||||
stats_.damage_defender_takes * stats_.nattacks;
|
||||
int this_avg_damage_taken = stats_.chance_to_hit_attacker *
|
||||
stats_.damage_attacker_takes * stats_.ndefends;
|
||||
|
||||
|
||||
int other_avg_damage_dealt = a.stats_.chance_to_hit_defender *
|
||||
a.stats_.damage_defender_takes * a.stats_.nattacks;
|
||||
int other_avg_damage_taken = a.stats_.chance_to_hit_attacker *
|
||||
a.stats_.damage_attacker_takes * a.stats_.ndefends;
|
||||
|
||||
|
||||
//if our weapon does less damage, it's worse
|
||||
if(this_avg_damage_dealt < other_avg_damage_dealt)
|
||||
return true;
|
||||
|
|
|
@ -101,8 +101,8 @@ public:
|
|||
//data will be forwarded to all peers other than 'from', unless 'from' is null, in
|
||||
//which case data will not be forwarded
|
||||
PROCESS_DATA_RESULT process_network_data(const config& cfg,network::connection from,std::deque<config>& backlog);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -271,7 +271,7 @@ void replay::add_countdown_update(int value, int team)
|
|||
|
||||
val["value"] = lexical_cast_default<std::string>(value);
|
||||
val["team"] = lexical_cast_default<std::string>(team);
|
||||
|
||||
|
||||
cmd->add_child("countdown_update",val);
|
||||
}
|
||||
|
||||
|
@ -609,9 +609,9 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
} else if((child = cfg->child("speak")) != NULL) {
|
||||
const std::string& team_name = (*child)["team_name"];
|
||||
if(team_name == "" || teams[disp.viewing_team()].team_name() == team_name) {
|
||||
bool is_lobby_join = ((*child)["description"] == "server"
|
||||
bool is_lobby_join = ((*child)["description"] == "server"
|
||||
&& (*child)["message"].value().find("has logged into the lobby") != -1);
|
||||
|
||||
|
||||
if(!replayer.is_skipping() && (!is_lobby_join || preferences::lobby_joins())) {
|
||||
if(preferences::message_bell()) {
|
||||
sound::play_sound(game_config::sounds::receive_message);
|
||||
|
|
|
@ -100,7 +100,7 @@ void replay_controller::init(CVideo& video, const std::vector<config*>& story){
|
|||
|
||||
const unit_type::experience_accelerator xp_mod(xp_modifier_ > 0 ? xp_modifier_ : 100);
|
||||
|
||||
const config::child_list& unit_cfg = level_.get_children("side");
|
||||
const config::child_list& unit_cfg = level_.get_children("side");
|
||||
|
||||
if(level_["modify_placing"] == "true") {
|
||||
LOG_NG << "modifying placing...\n";
|
||||
|
@ -344,7 +344,7 @@ void replay_controller::play_replay(){
|
|||
} //end for loop
|
||||
is_playing_ = false;
|
||||
}
|
||||
catch(end_level_exception& e){
|
||||
catch(end_level_exception& e){
|
||||
if (e.result == QUIT) { throw e; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
|
|||
unit_map::const_iterator u = units.end();
|
||||
SDL_Color HPC;
|
||||
SDL_Color XPC;
|
||||
|
||||
|
||||
|
||||
if(int(type) >= int(UNIT_REPORTS_BEGIN) && int(type) < int(UNIT_REPORTS_END) || type == POSITION) {
|
||||
|
||||
|
@ -180,13 +180,13 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
|
|||
}
|
||||
case UNIT_HP: {
|
||||
HPC=u->second.hp_color();
|
||||
str << "<" << (int) HPC.r << "," << (int) HPC.g << "," << (int) HPC.b << ">"
|
||||
str << "<" << (int) HPC.r << "," << (int) HPC.g << "," << (int) HPC.b << ">"
|
||||
<< u->second.hitpoints() << "/" << u->second.max_hitpoints();
|
||||
break;
|
||||
}
|
||||
case UNIT_XP: {
|
||||
XPC=u->second.xp_color();
|
||||
str << "<" << (int) XPC.r << "," << (int) XPC.g << "," << (int) XPC.b << ">"
|
||||
str << "<" << (int) XPC.r << "," << (int) XPC.g << "," << (int) XPC.b << ">"
|
||||
<< u->second.experience() << "/" << u->second.max_experience();
|
||||
break;
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
|
|||
//check if we use special(argument)
|
||||
const std::string::size_type parindex = special.find('(',0);
|
||||
if (parindex != std::string::npos) {
|
||||
// If there is an argument, we use weapon_special_specialname_arg_description instead
|
||||
// If there is an argument, we use weapon_special_specialname_arg_description instead
|
||||
tooltip << string_table["weapon_special_" + special.substr(0,parindex) + "_arg_description"];
|
||||
} else {
|
||||
tooltip << string_table["weapon_special_" + special + "_description"];
|
||||
|
@ -472,10 +472,10 @@ Units cannot be killed by poison alone. The poison will not reduce it below 1 HP
|
|||
sec = current_team.countdown_time() / 1000;
|
||||
|
||||
if(sec < 60)
|
||||
str << "<200,0,0>";
|
||||
str << "<200,0,0>";
|
||||
else if(sec < 120)
|
||||
str << "<200,200,0>";
|
||||
|
||||
str << "<200,200,0>";
|
||||
|
||||
min = sec / 60;
|
||||
str << min << ":";
|
||||
sec = sec % 60;
|
||||
|
|
|
@ -129,8 +129,8 @@ surface create_optimized_surface(surface const &surf)
|
|||
// don't pass this function 0 scaling arguments
|
||||
surface scale_surface(surface const &surf, int w, int h)
|
||||
{
|
||||
assert(SDL_ALPHA_TRANSPARENT==0);
|
||||
|
||||
assert(SDL_ALPHA_TRANSPARENT==0);
|
||||
|
||||
if(surf == NULL)
|
||||
return NULL;
|
||||
|
||||
|
@ -196,7 +196,7 @@ surface scale_surface(surface const &surf, int w, int h)
|
|||
pix[1] = *(src_word + dx); // northeast
|
||||
pix[2] = *(src_word + dy); // southwest
|
||||
pix[3] = *(src_word + dx + dy); // southeast
|
||||
|
||||
|
||||
bilin[0] = n*w;
|
||||
bilin[1] = n*e;
|
||||
bilin[2] = s*w;
|
||||
|
@ -484,20 +484,20 @@ surface recolor_image(surface surf, const color_range& new_rgb, const std::vecto
|
|||
Uint16 new_blue = (new_rgb.mid() & 0x000000FF);
|
||||
Uint16 max_red = (new_rgb.max() & 0x00FF0000)>>16;
|
||||
Uint16 max_green= (new_rgb.max() & 0x0000FF00)>>8 ;
|
||||
Uint16 max_blue = (new_rgb.max() & 0x000000FF) ;
|
||||
Uint16 max_blue = (new_rgb.max() & 0x000000FF) ;
|
||||
Uint16 min_red = (new_rgb.min() & 0x00FF0000)>>16;
|
||||
Uint16 min_green= (new_rgb.min() & 0x0000FF00)>>8 ;
|
||||
Uint16 min_green= (new_rgb.min() & 0x0000FF00)>>8 ;
|
||||
Uint16 min_blue = (new_rgb.min() & 0x000000FF) ;
|
||||
|
||||
|
||||
if(surf == NULL)
|
||||
return NULL;
|
||||
|
||||
|
||||
surface nsurf(make_neutral_surface(surf));
|
||||
if(nsurf == NULL) {
|
||||
std::cerr << "failed to make neutral surface\n";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Uint16 reference_avg=0;
|
||||
const Uint16 new_grey = (Uint16)((77*(Uint16) new_red +
|
||||
150*(Uint16)new_green +
|
||||
|
@ -511,9 +511,9 @@ surface recolor_image(surface surf, const color_range& new_rgb, const std::vecto
|
|||
int old_r=(temp_rgb & 0X00FF0000)>>16;
|
||||
int old_g=(temp_rgb & 0X0000FF00)>>8;
|
||||
int old_b=(temp_rgb & 0X000000FF);
|
||||
reference_avg = (Uint16)(((Uint16) old_r + (Uint16)old_g + (Uint16)old_b)
|
||||
reference_avg = (Uint16)(((Uint16) old_r + (Uint16)old_g + (Uint16)old_b)
|
||||
/ 3);
|
||||
|
||||
|
||||
{
|
||||
for(std::vector<Uint32>::const_iterator temp_rgb = old_rgb.begin();
|
||||
temp_rgb!=old_rgb.end();temp_rgb++)
|
||||
|
@ -521,12 +521,12 @@ surface recolor_image(surface surf, const color_range& new_rgb, const std::vecto
|
|||
int old_r=((*temp_rgb) & 0X00FF0000)>>16;
|
||||
int old_g=((*temp_rgb) & 0X0000FF00)>>8;
|
||||
int old_b=((*temp_rgb) & 0X000000FF);
|
||||
|
||||
|
||||
// std::cout<<"recolor:"<<old_r<<","<<old_g<<","<<old_b<<"\n";
|
||||
surface_lock lock(nsurf);
|
||||
Uint32* beg = lock.pixels();
|
||||
Uint32* end = beg + nsurf->w*surf->h;
|
||||
|
||||
|
||||
//const Uint16 old_grey = (Uint16)((77*(Uint16) old_r +
|
||||
// 150*(Uint16)old_g +
|
||||
// 29*(Uint16)old_b) / 256);
|
||||
|
@ -538,19 +538,19 @@ surface recolor_image(surface surf, const color_range& new_rgb, const std::vecto
|
|||
Uint8 new_r, new_g, new_b;
|
||||
|
||||
if(reference_avg && old_avg <= reference_avg){
|
||||
float old_rat = ((float)old_avg)/reference_avg;
|
||||
float old_rat = ((float)old_avg)/reference_avg;
|
||||
new_r=(Uint8)( old_rat * new_red + (1 - old_rat) * min_red);
|
||||
new_g=(Uint8)( old_rat * new_green + (1 - old_rat) * min_green);
|
||||
new_b=(Uint8)( old_rat * new_blue + (1 - old_rat) * min_blue);
|
||||
}else if(255 - reference_avg){
|
||||
float old_rat = ((float) 255 - old_avg) / (255 - reference_avg);
|
||||
float old_rat = ((float) 255 - old_avg) / (255 - reference_avg);
|
||||
new_r=(Uint8)( old_rat * new_red + (1 - old_rat) * max_red);
|
||||
new_g=(Uint8)( old_rat * new_green + (1 - old_rat) * max_green);
|
||||
new_b=(Uint8)( old_rat * new_blue + (1 - old_rat) * max_blue);
|
||||
}else{
|
||||
//should never get here
|
||||
//would imply old_avg > reference_avg = 255
|
||||
}
|
||||
//would imply old_avg > reference_avg = 255
|
||||
}
|
||||
|
||||
while(beg != end) {
|
||||
Uint8 red, green, blue, alpha;
|
||||
|
|
|
@ -187,7 +187,7 @@ class preprocessor_data: preprocessor
|
|||
void put(std::string const &);
|
||||
public:
|
||||
preprocessor_data(preprocessor_streambuf &, std::istream *,
|
||||
std::string const &history,
|
||||
std::string const &history,
|
||||
std::string const &name, int line,
|
||||
std::string const &dir, std::string const &domain);
|
||||
virtual bool get_chunk();
|
||||
|
@ -625,7 +625,7 @@ bool preprocessor_data::get_chunk()
|
|||
std::string const &dir = directory_name(val.location.substr(0, val.location.find(' ')));
|
||||
if (!slowpath_) {
|
||||
LOG_CF << "substituting macro " << symbol << '\n';
|
||||
new preprocessor_data(target_, buffer, val.location, "",
|
||||
new preprocessor_data(target_, buffer, val.location, "",
|
||||
val.linenum, dir, val.textdomain);
|
||||
} else {
|
||||
LOG_CF << "substituting (slow) macro " << symbol << '\n';
|
||||
|
|
|
@ -66,4 +66,4 @@ bool player::is_message_flooding()
|
|||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ std::string server::process_command(const std::string& cmd)
|
|||
const std::string motd(i+1,cmd.end());
|
||||
motd_ = motd;
|
||||
out << "message of the day set: " << motd_;
|
||||
|
||||
|
||||
} else {
|
||||
out << "command '" << command << "' is not recognized";
|
||||
out << "available commands are: msg <message>, status, metrics, ban [<nick>], unban <nick>, kick <nick>";
|
||||
|
@ -853,7 +853,7 @@ void server::process_data_from_player_in_game(const network::connection sock, co
|
|||
g->level().values["map_data"] = data["map_data"];
|
||||
g->level().values["map"] = data["map"];
|
||||
}
|
||||
|
||||
|
||||
g->level().values["mp_era"] = data.child("era") != NULL ? data.child("era")->get_attribute("id") : "";
|
||||
g->level().values["mp_scenario"] = data["id"];
|
||||
g->level().values["mp_use_map_settings"] = data["mp_use_map_settings"];
|
||||
|
|
|
@ -110,7 +110,7 @@ team::team_info::team_info(const config& cfg)
|
|||
colour = lexical_cast_default<int>(cfg["side"],-1);
|
||||
|
||||
int side = atoi(cfg["side"].c_str());
|
||||
|
||||
|
||||
std::vector<Uint32> temp_rgb = string2rgb(cfg["team_rgb"]);
|
||||
std::map<int, color_range>::iterator global_rgb = game_config::team_rgb_range.find(side);
|
||||
|
||||
|
@ -356,7 +356,7 @@ void team::write(config& cfg) const
|
|||
}
|
||||
|
||||
cfg["shroud_data"] = shroud_.write();
|
||||
|
||||
|
||||
cfg["countdown_time"] = lexical_cast_default<std::string>(countdown_time_);
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ int team::countdown_time() const
|
|||
}
|
||||
void team::set_countdown_time(int amount)
|
||||
{
|
||||
countdown_time_=amount;
|
||||
countdown_time_=amount;
|
||||
}
|
||||
|
||||
const std::set<std::string>& team::recruits() const
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
std::string team_name;
|
||||
std::string save_id;
|
||||
std::string countdown_time;
|
||||
|
||||
|
||||
std::string flag;
|
||||
|
||||
std::string description;
|
||||
|
@ -249,7 +249,7 @@ private:
|
|||
team_info info_;
|
||||
|
||||
int countdown_time_;
|
||||
|
||||
|
||||
config aiparams_;
|
||||
|
||||
//cached values for ai parameters
|
||||
|
|
|
@ -263,7 +263,7 @@ theme::object::object() : loc_(empty_rect), relative_loc_(empty_rect),
|
|||
{}
|
||||
|
||||
theme::object::object(const config& cfg)
|
||||
: id_(cfg["id"]),
|
||||
: id_(cfg["id"]),
|
||||
loc_(read_sdl_rect(cfg)), relative_loc_(empty_rect),
|
||||
last_screen_(empty_rect),
|
||||
xanchor_(read_anchor(cfg["xanchor"])),
|
||||
|
@ -650,7 +650,7 @@ theme::object& theme::add_object(const config& cfg){
|
|||
LOG_DP << "done adding menu...\n";
|
||||
result = new_menu;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -677,9 +677,9 @@ void theme::remove_object(std::string id){
|
|||
|
||||
void theme::set_object_location(theme::object& element, std::string rect_str, std::string ref_id){
|
||||
theme::object& ref_element = *(new object());
|
||||
if (ref_id.empty()) {
|
||||
if (ref_id.empty()) {
|
||||
ref_id = element.get_id();
|
||||
ref_element = element;
|
||||
ref_element = element;
|
||||
}
|
||||
else {
|
||||
ref_element = find_element(ref_id);
|
||||
|
|
|
@ -420,7 +420,7 @@ SDL_Colour unit::hp_color() const{
|
|||
if(max_hitpoints() > 0) {
|
||||
unit_energy = double(hitpoints())/double(max_hitpoints());
|
||||
}
|
||||
|
||||
|
||||
if(1.0 == unit_energy){
|
||||
energy_colour.r = 33;
|
||||
energy_colour.g = 225;
|
||||
|
|
|
@ -158,7 +158,7 @@ attack_type::attack_type(const config& cfg,const unit_type& unit)
|
|||
icon_ = cfg["icon"];
|
||||
if(icon_.empty())
|
||||
icon_ = "attacks/" + id_ + ".png";
|
||||
|
||||
|
||||
range_ = cfg["range"];
|
||||
damage_ = atol(cfg["damage"].c_str());
|
||||
num_attacks_ = atol(cfg["number"].c_str());
|
||||
|
@ -308,7 +308,7 @@ bool attack_type::matches_filter(const config& cfg) const
|
|||
const std::string& filter_type = cfg["type"];
|
||||
const std::string& filter_special = cfg["special"];
|
||||
|
||||
if(filter_range.empty() == false && filter_range != range())
|
||||
if(filter_range.empty() == false && filter_range != range())
|
||||
return false;
|
||||
|
||||
if(filter_name.empty() == false && filter_name != name())
|
||||
|
@ -650,11 +650,11 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
|
|||
leadership_ = false;
|
||||
|
||||
/* handle deprecated ability=x,y,... */
|
||||
|
||||
|
||||
std::vector<std::string> deprecated_abilities = utils::split(cfg_["ability"]);
|
||||
|
||||
//if the string was empty, split will give us one empty string in the list,
|
||||
//remove it.
|
||||
|
||||
//if the string was empty, split will give us one empty string in the list,
|
||||
//remove it.
|
||||
if(!deprecated_abilities.empty() && deprecated_abilities.back() == "") {
|
||||
deprecated_abilities.pop_back();
|
||||
} else {
|
||||
|
@ -718,7 +718,7 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
|
|||
ability_tooltips_.push_back("nightstalk");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const config* abil_cfg = cfg.child("abilities");
|
||||
if(abil_cfg) {
|
||||
const config* heal_ability = abil_cfg->child("heals");
|
||||
|
@ -730,7 +730,7 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
|
|||
const config* teleport_ability = abil_cfg->child("teleport");
|
||||
const config* ambush_ability = abil_cfg->child("ambush");
|
||||
const config* nightstalk_ability = abil_cfg->child("nightstalk");
|
||||
|
||||
|
||||
if(heal_ability) {
|
||||
abilities_.push_back("heals");
|
||||
if((*heal_ability)["description"] != "") {
|
||||
|
@ -877,7 +877,7 @@ unit_type::unit_type(const config& cfg, const movement_type_map& mv_types,
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const config::child_list& teleports = cfg_.get_children("teleport_anim");
|
||||
for(config::child_list::const_iterator t = teleports.begin(); t != teleports.end(); ++t) {
|
||||
teleport_animations_.push_back(unit_animation(**t));
|
||||
|
@ -1288,7 +1288,7 @@ const std::string& unit_type::race() const
|
|||
return race_->name();
|
||||
}
|
||||
|
||||
unit_type::defensive_animation::defensive_animation(const config& cfg) : hits(HIT_OR_MISS), range(utils::split(cfg["range"])),animation(cfg)
|
||||
unit_type::defensive_animation::defensive_animation(const config& cfg) : hits(HIT_OR_MISS), range(utils::split(cfg["range"])),animation(cfg)
|
||||
{
|
||||
const std::string& hits_str = cfg["hits"];
|
||||
if(hits_str.empty() == false) {
|
||||
|
|
|
@ -114,7 +114,7 @@ static int upload_logs(void *_ti)
|
|||
// Currently only enabled when playing campaigns.
|
||||
upload_log::upload_log(bool enable) : game_(NULL), enabled_(enable)
|
||||
{
|
||||
filename_ = next_filename(get_upload_dir());
|
||||
filename_ = next_filename(get_upload_dir());
|
||||
if (preferences::upload_log() && !thread_.t) {
|
||||
// Thread can outlive us; it uploads everything up to the next
|
||||
// filename, and unsets thread_.t when it's finished.
|
||||
|
@ -149,7 +149,7 @@ bool upload_log::game_finished(config *game)
|
|||
{
|
||||
if (!game)
|
||||
return false;
|
||||
|
||||
|
||||
return game->child("victory") || game->child("defeat") || game->child("quit");
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ void upload_log_dialog::show_beg_dialog(display& disp)
|
|||
+ get_upload_dir() + "\n"
|
||||
+ _("You can view the results at ")
|
||||
+ "http://stats.wesnoth.org/?" + preferences::upload_id() + "\n";
|
||||
|
||||
|
||||
|
||||
gui::show_dialog(disp, NULL,
|
||||
_("Help us make Wesnoth better for you!"),
|
||||
|
|
|
@ -47,13 +47,13 @@ struct upload_log
|
|||
threading::thread *t;
|
||||
std::string lastfile;
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
config &add_game_result(const std::string &str, int turn);
|
||||
bool game_finished(config *game);
|
||||
|
||||
static struct thread_info thread_;
|
||||
friend struct manager;
|
||||
|
||||
static struct thread_info thread_;
|
||||
friend struct manager;
|
||||
|
||||
config config_;
|
||||
config *game_;
|
||||
|
|
|
@ -91,8 +91,8 @@ void file_chooser::display_current_files() {
|
|||
// and shorten the rest of the dir:
|
||||
// /home/.../rest_of_the_dir
|
||||
// Note that this is a dirty hack and fundemental changes in the widget subdir
|
||||
// needs to be made...
|
||||
if(font::line_width(current_path_label_.get_text(), menu_font_size) > 390)
|
||||
// needs to be made...
|
||||
if(font::line_width(current_path_label_.get_text(), menu_font_size) > 390)
|
||||
{
|
||||
std::string tmp = current_path_label_.get_text();
|
||||
static const int filler_width = font::line_width("...", menu_font_size);
|
||||
|
@ -107,7 +107,7 @@ void file_chooser::display_current_files() {
|
|||
}
|
||||
|
||||
static const int prefix_width = font::line_width(dir_prefix, menu_font_size);
|
||||
|
||||
|
||||
// Try to cut off text at the '/' or '\' tokens
|
||||
while(font::line_width(tmp, menu_font_size) + filler_width + prefix_width > 390 && tmp.length() != 0)
|
||||
{
|
||||
|
|
|
@ -1,216 +1,216 @@
|
|||
/* $Id: button.cpp 7396 2005-07-02 21:37:20Z ott $ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "widgets/image_button.hpp"
|
||||
#include "font.hpp"
|
||||
#include "image.hpp"
|
||||
#include "log.hpp"
|
||||
#include "util.hpp"
|
||||
#include "video.hpp"
|
||||
#include "wml_separators.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
||||
namespace gui {
|
||||
|
||||
const int font_size = font::SIZE_SMALL;
|
||||
const int horizontal_padding = font::SIZE_SMALL;
|
||||
const int checkbox_horizontal_padding = font::SIZE_SMALL / 2;
|
||||
const int vertical_padding = font::SIZE_SMALL / 2;
|
||||
|
||||
image_button::image_button(CVideo& video, std::string button_image_name, SPACE_CONSUMPTION spacing)
|
||||
: widget(video), image_(NULL), pressedImage_(NULL), activeImage_(NULL), pressedActiveImage_(NULL),
|
||||
button_(true), state_(NORMAL), enabled_(true), pressed_(false),
|
||||
spacing_(spacing), base_height_(0), base_width_(0)
|
||||
{
|
||||
if(button_image_name.empty()) {
|
||||
button_image_name = "button";
|
||||
}
|
||||
|
||||
const std::string button_image_file = "buttons/" + button_image_name + ".png";
|
||||
surface button_image(image::get_image(button_image_file,image::UNSCALED));
|
||||
surface pressed_image(image::get_image("buttons/" + button_image_name + "-pressed.png", image::UNSCALED));
|
||||
surface active_image(image::get_image("buttons/" + button_image_name + "-active.png", image::UNSCALED));
|
||||
surface pressed_active_image;
|
||||
|
||||
if (pressed_image.null())
|
||||
pressed_image.assign(button_image);
|
||||
|
||||
if (active_image.null())
|
||||
active_image.assign(button_image);
|
||||
|
||||
if (button_image.null())
|
||||
throw error();
|
||||
|
||||
base_height_ = button_image->h;
|
||||
base_width_ = button_image->w;
|
||||
|
||||
image_.assign(scale_surface(button_image,location().w,location().h));
|
||||
pressedImage_.assign(scale_surface(pressed_image,location().w,location().h));
|
||||
activeImage_.assign(scale_surface(active_image,location().w,location().h));
|
||||
}
|
||||
|
||||
void image_button::calculate_size()
|
||||
{
|
||||
SDL_Rect const &loc = location();
|
||||
bool change_size = loc.h == 0 || loc.w == 0;
|
||||
|
||||
if (!change_size) {
|
||||
unsigned w = loc.w - horizontal_padding;
|
||||
}
|
||||
|
||||
if (!change_size)
|
||||
return;
|
||||
|
||||
#ifdef USE_TINY_GUI
|
||||
set_height(textRect_.h+vertical_padding);
|
||||
#else
|
||||
set_height(maximum(textRect_.h+vertical_padding,base_height_));
|
||||
#endif
|
||||
#ifdef USE_TINY_GUI
|
||||
set_width(textRect_.w + horizontal_padding);
|
||||
#else
|
||||
if(spacing_ == MINIMUM_SPACE) {
|
||||
set_width(textRect_.w + horizontal_padding);
|
||||
} else {
|
||||
set_width(maximum(textRect_.w+horizontal_padding,base_width_));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void image_button::enable(bool new_val)
|
||||
{
|
||||
if (enabled_ != new_val) {
|
||||
enabled_ = new_val;
|
||||
state_ = NORMAL;
|
||||
pressed_ = false;
|
||||
set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
bool image_button::enabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
void image_button::draw_contents()
|
||||
{
|
||||
surface image = image_;
|
||||
const int image_w = image_->w;
|
||||
|
||||
int offset = 0;
|
||||
switch(state_) {
|
||||
case ACTIVE:
|
||||
image = activeImage_;
|
||||
break;
|
||||
case PRESSED:
|
||||
image = pressedImage_;
|
||||
offset = 1;
|
||||
break;
|
||||
case PRESSED_ACTIVE:
|
||||
image = pressedActiveImage_;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_Rect const &clipArea = screen_area();
|
||||
SDL_Rect const &loc = location();
|
||||
const int texty = loc.y + loc.h / 2 - textRect_.h / 2 + offset;
|
||||
int textx;
|
||||
|
||||
textx = loc.x + image_w + checkbox_horizontal_padding / 2;
|
||||
|
||||
SDL_Color button_colour = font::BUTTON_COLOUR;
|
||||
|
||||
if (!enabled_) {
|
||||
image = greyscale_image(image);
|
||||
button_colour = font::STONED_COLOUR;
|
||||
}
|
||||
|
||||
video().blit_surface(loc.x, loc.y, image);
|
||||
|
||||
update_rect(loc);
|
||||
}
|
||||
|
||||
bool image_button::hit(int x, int y) const
|
||||
{
|
||||
return point_in_rect(x,y,location());
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool not_image(const std::string& str) { return !str.empty() && str[0] != IMAGE_PREFIX; }
|
||||
}
|
||||
|
||||
void image_button::mouse_motion(SDL_MouseMotionEvent const &event)
|
||||
{
|
||||
if (hit(event.x, event.y)) {
|
||||
// the cursor is over the widget
|
||||
if (state_ == NORMAL)
|
||||
state_ = ACTIVE;
|
||||
} else {
|
||||
// the cursor is not over the widget
|
||||
if (state_ != PRESSED)
|
||||
state_ = NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
void image_button::mouse_down(SDL_MouseButtonEvent const &event)
|
||||
{
|
||||
if (hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT)
|
||||
state_ = PRESSED;
|
||||
}
|
||||
|
||||
void image_button::mouse_up(SDL_MouseButtonEvent const &event)
|
||||
{
|
||||
if (!(hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT))
|
||||
return;
|
||||
// the user has stopped pressing the mouse left button while on the widget
|
||||
if (state_ == PRESSED) {
|
||||
state_ = ACTIVE;
|
||||
pressed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void image_button::handle_event(const SDL_Event& event)
|
||||
{
|
||||
if (hidden() || !enabled_)
|
||||
return;
|
||||
|
||||
STATE start_state = state_;
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
mouse_down(event.button);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
mouse_up(event.button);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
mouse_motion(event.motion);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (start_state != state_)
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
bool image_button::pressed()
|
||||
{
|
||||
return state_ == PRESSED || state_ == PRESSED_ACTIVE;
|
||||
}
|
||||
|
||||
}
|
||||
/* $Id: button.cpp 7396 2005-07-02 21:37:20Z ott $ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "global.hpp"
|
||||
|
||||
#include "widgets/image_button.hpp"
|
||||
#include "font.hpp"
|
||||
#include "image.hpp"
|
||||
#include "log.hpp"
|
||||
#include "util.hpp"
|
||||
#include "video.hpp"
|
||||
#include "wml_separators.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
||||
namespace gui {
|
||||
|
||||
const int font_size = font::SIZE_SMALL;
|
||||
const int horizontal_padding = font::SIZE_SMALL;
|
||||
const int checkbox_horizontal_padding = font::SIZE_SMALL / 2;
|
||||
const int vertical_padding = font::SIZE_SMALL / 2;
|
||||
|
||||
image_button::image_button(CVideo& video, std::string button_image_name, SPACE_CONSUMPTION spacing)
|
||||
: widget(video), image_(NULL), pressedImage_(NULL), activeImage_(NULL), pressedActiveImage_(NULL),
|
||||
button_(true), state_(NORMAL), enabled_(true), pressed_(false),
|
||||
spacing_(spacing), base_height_(0), base_width_(0)
|
||||
{
|
||||
if(button_image_name.empty()) {
|
||||
button_image_name = "button";
|
||||
}
|
||||
|
||||
const std::string button_image_file = "buttons/" + button_image_name + ".png";
|
||||
surface button_image(image::get_image(button_image_file,image::UNSCALED));
|
||||
surface pressed_image(image::get_image("buttons/" + button_image_name + "-pressed.png", image::UNSCALED));
|
||||
surface active_image(image::get_image("buttons/" + button_image_name + "-active.png", image::UNSCALED));
|
||||
surface pressed_active_image;
|
||||
|
||||
if (pressed_image.null())
|
||||
pressed_image.assign(button_image);
|
||||
|
||||
if (active_image.null())
|
||||
active_image.assign(button_image);
|
||||
|
||||
if (button_image.null())
|
||||
throw error();
|
||||
|
||||
base_height_ = button_image->h;
|
||||
base_width_ = button_image->w;
|
||||
|
||||
image_.assign(scale_surface(button_image,location().w,location().h));
|
||||
pressedImage_.assign(scale_surface(pressed_image,location().w,location().h));
|
||||
activeImage_.assign(scale_surface(active_image,location().w,location().h));
|
||||
}
|
||||
|
||||
void image_button::calculate_size()
|
||||
{
|
||||
SDL_Rect const &loc = location();
|
||||
bool change_size = loc.h == 0 || loc.w == 0;
|
||||
|
||||
if (!change_size) {
|
||||
unsigned w = loc.w - horizontal_padding;
|
||||
}
|
||||
|
||||
if (!change_size)
|
||||
return;
|
||||
|
||||
#ifdef USE_TINY_GUI
|
||||
set_height(textRect_.h+vertical_padding);
|
||||
#else
|
||||
set_height(maximum(textRect_.h+vertical_padding,base_height_));
|
||||
#endif
|
||||
#ifdef USE_TINY_GUI
|
||||
set_width(textRect_.w + horizontal_padding);
|
||||
#else
|
||||
if(spacing_ == MINIMUM_SPACE) {
|
||||
set_width(textRect_.w + horizontal_padding);
|
||||
} else {
|
||||
set_width(maximum(textRect_.w+horizontal_padding,base_width_));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void image_button::enable(bool new_val)
|
||||
{
|
||||
if (enabled_ != new_val) {
|
||||
enabled_ = new_val;
|
||||
state_ = NORMAL;
|
||||
pressed_ = false;
|
||||
set_dirty();
|
||||
}
|
||||
}
|
||||
|
||||
bool image_button::enabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
void image_button::draw_contents()
|
||||
{
|
||||
surface image = image_;
|
||||
const int image_w = image_->w;
|
||||
|
||||
int offset = 0;
|
||||
switch(state_) {
|
||||
case ACTIVE:
|
||||
image = activeImage_;
|
||||
break;
|
||||
case PRESSED:
|
||||
image = pressedImage_;
|
||||
offset = 1;
|
||||
break;
|
||||
case PRESSED_ACTIVE:
|
||||
image = pressedActiveImage_;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_Rect const &clipArea = screen_area();
|
||||
SDL_Rect const &loc = location();
|
||||
const int texty = loc.y + loc.h / 2 - textRect_.h / 2 + offset;
|
||||
int textx;
|
||||
|
||||
textx = loc.x + image_w + checkbox_horizontal_padding / 2;
|
||||
|
||||
SDL_Color button_colour = font::BUTTON_COLOUR;
|
||||
|
||||
if (!enabled_) {
|
||||
image = greyscale_image(image);
|
||||
button_colour = font::STONED_COLOUR;
|
||||
}
|
||||
|
||||
video().blit_surface(loc.x, loc.y, image);
|
||||
|
||||
update_rect(loc);
|
||||
}
|
||||
|
||||
bool image_button::hit(int x, int y) const
|
||||
{
|
||||
return point_in_rect(x,y,location());
|
||||
}
|
||||
|
||||
namespace {
|
||||
bool not_image(const std::string& str) { return !str.empty() && str[0] != IMAGE_PREFIX; }
|
||||
}
|
||||
|
||||
void image_button::mouse_motion(SDL_MouseMotionEvent const &event)
|
||||
{
|
||||
if (hit(event.x, event.y)) {
|
||||
// the cursor is over the widget
|
||||
if (state_ == NORMAL)
|
||||
state_ = ACTIVE;
|
||||
} else {
|
||||
// the cursor is not over the widget
|
||||
if (state_ != PRESSED)
|
||||
state_ = NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
void image_button::mouse_down(SDL_MouseButtonEvent const &event)
|
||||
{
|
||||
if (hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT)
|
||||
state_ = PRESSED;
|
||||
}
|
||||
|
||||
void image_button::mouse_up(SDL_MouseButtonEvent const &event)
|
||||
{
|
||||
if (!(hit(event.x, event.y) && event.button == SDL_BUTTON_LEFT))
|
||||
return;
|
||||
// the user has stopped pressing the mouse left button while on the widget
|
||||
if (state_ == PRESSED) {
|
||||
state_ = ACTIVE;
|
||||
pressed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void image_button::handle_event(const SDL_Event& event)
|
||||
{
|
||||
if (hidden() || !enabled_)
|
||||
return;
|
||||
|
||||
STATE start_state = state_;
|
||||
|
||||
switch(event.type) {
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
mouse_down(event.button);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
mouse_up(event.button);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
mouse_motion(event.motion);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (start_state != state_)
|
||||
set_dirty(true);
|
||||
}
|
||||
|
||||
bool image_button::pressed()
|
||||
{
|
||||
return state_ == PRESSED || state_ == PRESSED_ACTIVE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,76 +1,76 @@
|
|||
/* $Id: button.hpp 7396 2005-07-02 21:37:20Z ott $ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#ifndef IMAGE_BUTTON_H_INCLUDED
|
||||
#define IMAGE_BUTTON_H_INCLUDED
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "widget.hpp"
|
||||
|
||||
#include "../sdl_utils.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace gui {
|
||||
|
||||
class image_button : public widget
|
||||
{
|
||||
public:
|
||||
struct error {};
|
||||
|
||||
enum SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE };
|
||||
|
||||
image_button(CVideo& video, std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE);
|
||||
|
||||
virtual ~image_button() {}
|
||||
|
||||
bool pressed();
|
||||
|
||||
void enable(bool new_val);
|
||||
bool enabled() const;
|
||||
|
||||
protected:
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
virtual void mouse_motion(const SDL_MouseMotionEvent& event);
|
||||
virtual void mouse_down(const SDL_MouseButtonEvent& event);
|
||||
virtual void mouse_up(const SDL_MouseButtonEvent& event);
|
||||
virtual void draw_contents();
|
||||
|
||||
private:
|
||||
|
||||
void calculate_size();
|
||||
|
||||
surface image_, pressedImage_, activeImage_, pressedActiveImage_;
|
||||
SDL_Rect textRect_;
|
||||
|
||||
bool button_;
|
||||
|
||||
enum STATE { UNINIT, NORMAL, ACTIVE, PRESSED, PRESSED_ACTIVE };
|
||||
STATE state_;
|
||||
|
||||
bool enabled_;
|
||||
|
||||
bool pressed_;
|
||||
|
||||
SPACE_CONSUMPTION spacing_;
|
||||
|
||||
int base_height_, base_width_;
|
||||
|
||||
bool hit(int x, int y) const;
|
||||
}; //end class button
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
/* $Id: button.hpp 7396 2005-07-02 21:37:20Z ott $ */
|
||||
/*
|
||||
Copyright (C) 2003 by David White <davidnwhite@verizon.net>
|
||||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#ifndef IMAGE_BUTTON_H_INCLUDED
|
||||
#define IMAGE_BUTTON_H_INCLUDED
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "widget.hpp"
|
||||
|
||||
#include "../sdl_utils.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace gui {
|
||||
|
||||
class image_button : public widget
|
||||
{
|
||||
public:
|
||||
struct error {};
|
||||
|
||||
enum SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE };
|
||||
|
||||
image_button(CVideo& video, std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE);
|
||||
|
||||
virtual ~image_button() {}
|
||||
|
||||
bool pressed();
|
||||
|
||||
void enable(bool new_val);
|
||||
bool enabled() const;
|
||||
|
||||
protected:
|
||||
virtual void handle_event(const SDL_Event& event);
|
||||
virtual void mouse_motion(const SDL_MouseMotionEvent& event);
|
||||
virtual void mouse_down(const SDL_MouseButtonEvent& event);
|
||||
virtual void mouse_up(const SDL_MouseButtonEvent& event);
|
||||
virtual void draw_contents();
|
||||
|
||||
private:
|
||||
|
||||
void calculate_size();
|
||||
|
||||
surface image_, pressedImage_, activeImage_, pressedActiveImage_;
|
||||
SDL_Rect textRect_;
|
||||
|
||||
bool button_;
|
||||
|
||||
enum STATE { UNINIT, NORMAL, ACTIVE, PRESSED, PRESSED_ACTIVE };
|
||||
STATE state_;
|
||||
|
||||
bool enabled_;
|
||||
|
||||
bool pressed_;
|
||||
|
||||
SPACE_CONSUMPTION spacing_;
|
||||
|
||||
int base_height_, base_width_;
|
||||
|
||||
bool hit(int x, int y) const;
|
||||
}; //end class button
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -347,7 +347,7 @@ void textbox::erase_selection()
|
|||
}
|
||||
|
||||
namespace {
|
||||
const unsigned int copypaste_modifier =
|
||||
const unsigned int copypaste_modifier =
|
||||
#ifdef __APPLE__
|
||||
KMOD_LMETA | KMOD_RMETA
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue