merged conflicts in about.cpp and font.cpp

This commit is contained in:
uid68803 2004-01-29 17:05:16 +00:00
parent 6b21616d59
commit e86039e94f
12 changed files with 125 additions and 93 deletions

View file

@ -194,7 +194,7 @@ Defeat:
message="Very well. You may join us."
[command]
[message]
id=msg5_13
id=msg5_13a
description=Gamlel
message=We will serve you well, for we respect the help you are providing to our city. You shall find that there is honor, even among thieves.
[/message]
@ -212,7 +212,7 @@ Defeat:
message="We cannot trust your motives. We shall rescue the city on our own!"
[command]
[message]
id=msg5_14
id=msg5_14a
description=Gamlel
message="Very well, we shall begone then. You shall have to recapture the city without our help!"
[/message]
@ -227,7 +227,7 @@ Defeat:
[event]
name=victory
[message]
id=msg5_13
id=msg5_14b
description=Konrad
message=Finally, we have retaken the city! Let us rest here friends.
[/message]
@ -236,12 +236,12 @@ Defeat:
type=Rogue,Thief
[/role]
[message]
id=msg5_14
id=msg5_14c
role=Thief
message=Victory! The thieves of Elensefar will be in your service, my lord
[/message]
[message]
id=msg5_15
id=msg5_15b
speaker=narrator
message=The party rested for three days, after which an old friend returned
[/message]

View file

@ -101,40 +101,45 @@ height=600
[/panel]
# gold icon
[panel]
image=misc/gold.png
[label]
icon=misc/gold.png
text=gold
rect=135,3,151,19
xanchor=proportional
yanchor=fixed
[/panel]
[/label]
# villages icon
[panel]
image=misc/villages.png
[label]
icon=misc/villages.png
text=villages
rect=255,3,271,19
xanchor=proportional
yanchor=fixed
[/panel]
[/label]
# units icon
[panel]
image=misc/units.png
[label]
icon=misc/units.png
text=units
rect=375,3,391,19
xanchor=proportional
yanchor=fixed
[/panel]
[/label]
# upkeep icon
[panel]
image=misc/upkeep.png
[label]
icon=misc/upkeep.png
text=upkeep
rect=495,3,525,19
xanchor=proportional
yanchor=fixed
[/panel]
[/label]
# income icon
[panel]
image=misc/income.png
[label]
icon=misc/income.png
text=income
rect=615,3,645,19
xanchor=proportional
yanchor=fixed
[/panel]
[/label]
[status]
# the time of day image

View file

@ -12,6 +12,7 @@
*/
#include "dialogs.hpp"
#include "font.hpp"
#include "language.hpp"
#include "replay.hpp"
#include "show_dialog.hpp"
@ -100,7 +101,7 @@ void show_objectives(display& disp, config& level_info)
const std::string& objectives = lang_objectives.empty() ?
level_info["objectives"] : lang_objectives;
gui::show_dialog(disp, NULL, "", "+" + name + "\n" +
gui::show_dialog(disp, NULL, "", font::LARGE_TEXT + name + "\n" +
(objectives.empty() ? no_objectives : objectives), gui::OK_ONLY);
}

View file

@ -473,10 +473,6 @@ void draw_label(display& disp, SDL_Surface* target, const theme::label& label)
const std::string& text = label.text();
const std::string& icon = label.icon();
SDL_Rect& loc = label.location(disp.screen_area());
if(text.empty() == false) {
font::draw_text(&disp,loc,label.font_size(),font::NORMAL_COLOUR,text,loc.x,loc.y);
}
if(icon.empty() == false) {
scoped_sdl_surface surf(image::get_image(icon,image::UNSCALED));
@ -485,8 +481,15 @@ void draw_label(display& disp, SDL_Surface* target, const theme::label& label)
}
SDL_BlitSurface(surf.get(),NULL,target,&loc);
if(text.empty() == false) {
tooltips::add_tooltip(loc,text);
}
} else if(text.empty() == false) {
font::draw_text(&disp,loc,label.font_size(),font::NORMAL_COLOUR,text,loc.x,loc.y);
}
update_rect(loc);
}
@ -756,20 +759,20 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
if(map_.on_board(loc) &&
u.invisible(map_.underlying_terrain(map_[loc.x][loc.y]),
status_.get_time_of_day().lawful_bonus)) {
status = "@" + string_table["invisible"];
status = font::GOOD_TEXT + string_table["invisible"];
}
if(u.has_flag("slowed")) {
status = "#" + string_table["slowed"];
status = font::BAD_TEXT + string_table["slowed"];
}
if(u.has_flag("poisoned")) {
status = "#" + string_table["poisoned"];
status = font::BAD_TEXT + string_table["poisoned"];
}
std::stringstream details;
details << "+" << u.description() << "\n"
<< "+" << u.type().language_name()
details << font::LARGE_TEXT << u.description() << "\n"
<< font::LARGE_TEXT << u.type().language_name()
<< "\n-(" << string_table["level"] << " "
<< u.type().level() << ")\n"
<< status << "\n"
@ -784,9 +787,9 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
//display in green/white/red depending on hitpoints
if(u.hitpoints() <= u.max_hitpoints()/3)
details << "#";
details << font::BAD_TEXT;
else if(u.hitpoints() > 2*(u.max_hitpoints()/3))
details << "@";
details << font::GOOD_TEXT;
details << string_table["hp"] << ": " << u.hitpoints()
<< "/" << u.max_hitpoints() << "\n";
@ -797,7 +800,7 @@ void display::draw_unit_details(int x, int y, const gamemap::location& loc,
//if killing a unit the same level as us would level us up,
//then display in green
if(u.max_experience() - u.experience() < game_config::kill_experience) {
details << "@";
details << font::GOOD_TEXT;
}
details << string_table["xp"] << ": " << u.experience() << "/" << u.max_experience();

View file

@ -115,6 +115,10 @@ const SDL_Color NORMAL_COLOUR = {0xDD,0xDD,0xDD,0},
YELLOW_COLOUR = {0xFF,0xFF,0x00,0},
BUTTON_COLOUR = {0xBC,0xB0,0x88,0};
const char LARGE_TEXT='+', SMALL_TEXT='-', GOOD_TEXT='@', BAD_TEXT='#',
NORMAL_TEXT='{', BLACK_TEXT='}', IMAGE='&', NULL_MARKUP='^';
const SDL_Color& get_side_colour(int side)
{
side -= 1;
@ -244,46 +248,47 @@ SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
std::string::const_iterator i1 = text.begin();
std::string::const_iterator i2 = std::find(i1,text.end(),'\n');
SDL_Color col = colour;
int sz = size;
for(;;) {
if(i1 != i2) {
SDL_Color col = colour;
int sz = size;
if(use_markup == USE_MARKUP) {
if(*i1 == '\\') {
// this must either be a quoted special character or a
// quoted backslash - either way, we remove the leading backslash
++i1;
} else if(*i1 == '#') {
if(*i1 == BAD_TEXT) {
col = BAD_COLOUR;
++i1;
} else if(*i1 == '@') {
continue;
} else if(*i1 == GOOD_TEXT) {
col = GOOD_COLOUR;
++i1;
} else if(*i1 == '{') {
continue;
} else if(*i1 == NORMAL_TEXT) {
col = NORMAL_COLOUR;
++i1;
} else if(*i1 == '}') {
continue;
} else if(*i1 == BLACK_TEXT) {
col = BLACK_COLOUR;
++i1;
} else if(*i1 == '+') {
continue;
} else if(*i1 == LARGE_TEXT) {
sz += 2;
++i1;
} else if(*i1 == '-') {
continue;
} else if(*i1 == SMALL_TEXT) {
sz -= 2;
++i1;
}
if(i1 != i2 && *i1 >= 1 && *i1 <= 9) {
continue;
} else if(*i1 == NULL_MARKUP) {
++i1;
continue;
} else if(*i1 >= 1 && *i1 <= 9) {
col = get_side_colour(*i1);
++i1;
continue;
}
}
if(i1 != i2) {
std::string new_string(i1,i2);
config::unescape(new_string);
const std::string new_string(i1,i2);
const SDL_Rect rect =
draw_text_line(gui,area,sz,col,new_string,x,y,bg,
use_tooltips);
@ -294,6 +299,9 @@ SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
}
}
col = colour;
sz = size;
if(i2 == text.end()) {
break;
}
@ -308,8 +316,8 @@ SDL_Rect draw_text(display* gui, const SDL_Rect& area, int size,
bool is_format_char(char c)
{
switch(c) {
case '#':
case '@':
case GOOD_TEXT:
case BAD_TEXT:
return true;
default:
return false;

View file

@ -38,6 +38,9 @@ extern const SDL_Color NORMAL_COLOUR, GOOD_COLOUR, BAD_COLOUR, BLACK_COLOUR,
enum MARKUP { USE_MARKUP, NO_MARKUP };
//standard markups
extern const char LARGE_TEXT, SMALL_TEXT, GOOD_TEXT, BAD_TEXT, NORMAL_TEXT, BLACK_TEXT, IMAGE, NULL_MARKUP;
//function to draw text on the screen. The text will be clipped to area.
//If the text runs outside of area horizontally, an ellipsis will be displayed
//at the end of it. If use_tooltips is true, then text with an ellipsis will

View file

@ -1056,13 +1056,9 @@ void turn_info::attack_resistance()
int resistance = 100 - atoi(i->second.c_str());
//if resistance is less than 0, display in red
std::string prefix = "";
if(resistance < 0) {
prefix = "#";
}
const char prefix = resistance < 0 ? font::BAD_TEXT : font::NULL_MARKUP;
const std::string& lang_weapon =
string_table["weapon_type_" + i->first];
const std::string& lang_weapon = string_table["weapon_type_" + i->first];
const std::string& weap = lang_weapon.empty() ? i->first : lang_weapon;
std::stringstream str;
@ -1231,7 +1227,7 @@ void turn_info::status_table()
//cause it to be displayed in the correct colour
str << data.villages << ","
<< data.units << "," << data.upkeep << ","
<< (data.net_income < 0 ? "#":"") << data.net_income;
<< (data.net_income < 0 ? font::BAD_TEXT:font::NULL_MARKUP) << data.net_income;
if(game_config::debug)
str << "," << teams_[n].gold();
@ -1272,12 +1268,12 @@ void turn_info::recruit()
const unit_type& type = u_type->second;
//display units that we can't afford to recruit in red
const std::string prefix = (type.cost() > current_team.gold() ? "#" : "");
const char prefix = (type.cost() > current_team.gold() ? font::BAD_TEXT : font::NULL_MARKUP);
std::stringstream description;
description << "&" << type.image() << "," << prefix << type.language_name() << ","
<< prefix << type.cost() << " gold";
description << font::IMAGE << type.image() << "," << prefix << font::LARGE_TEXT << type.language_name() << "\n"
<< prefix << type.cost() << " " << string_table["gold"];
items.push_back(description.str());
sample_units.push_back(unit(&type,team_num_));
}

View file

@ -1,4 +1,5 @@
#include "actions.hpp"
#include "font.hpp"
#include "game_config.hpp"
#include "language.hpp"
#include "reports.hpp"
@ -70,13 +71,13 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
std::string unit_status = "healthy", prefix = "";
if(map.on_board(loc) && u->second.invisible(map.underlying_terrain(map[loc.x][loc.y]),status.get_time_of_day().lawful_bonus)) {
unit_status = "invisible";
prefix = "@";
prefix = font::GOOD_TEXT;
} else if(u->second.has_flag("slowed")) {
unit_status = "slowed";
prefix = "#";
prefix = font::BAD_TEXT;
} else if(u->second.has_flag("poisoned")) {
unit_status = "poisoned";
prefix = "#";
prefix = font::BAD_TEXT;
}
report res(prefix + string_table[unit_status]);
@ -106,9 +107,9 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
}
case UNIT_HP:
if(u->second.hitpoints() <= u->second.max_hitpoints()/3)
str << "#";
str << font::BAD_TEXT;
else if(u->second.hitpoints() > 2*(u->second.max_hitpoints()/3))
str << "@";
str << font::GOOD_TEXT;
str << u->second.hitpoints()
<< "/" << u->second.max_hitpoints() << "\n";
@ -120,7 +121,7 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
} else {
//if killing a unit of the same level as us lets us advance, display in 'good' colour
if(u->second.max_experience() - u->second.experience() <= game_config::kill_experience*u->second.type().level()) {
str << "@";
str << font::GOOD_TEXT;
}
str << u->second.experience() << "/" << u->second.max_experience();
@ -163,12 +164,12 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
report res("",tod.image);
std::stringstream tooltip;
tooltip << "+" << translate_string_default(tod.id,tod.name) << "\n"
tooltip << font::LARGE_TEXT << translate_string_default(tod.id,tod.name) << "\n"
<< translate_string("lawful") << " " << string_table["units"] << ": "
<< (tod.lawful_bonus > 0 ? "+" : "") << tod.lawful_bonus << "%\n"
<< (tod.lawful_bonus > 0 ? font::LARGE_TEXT : font::NULL_MARKUP) << tod.lawful_bonus << "%\n"
<< translate_string("neutral") << " " << string_table["units"] << ": " << "0%\n"
<< translate_string("chaotic") << " " << string_table["units"] << ": "
<< (tod.lawful_bonus < 0 ? "+" : "") << (tod.lawful_bonus*-1) << "%";
<< (tod.lawful_bonus < 0 ? font::LARGE_TEXT : font::NULL_MARKUP) << (tod.lawful_bonus*-1) << "%";
res.tooltip = tooltip.str();
return res;
}
@ -176,7 +177,7 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
str << status.turn() << "/" << status.number_of_turns() << "\n";
break;
case GOLD:
str << (current_team.gold() < 0 ? "#" : "") << current_team.gold();
str << (current_team.gold() < 0 ? font::BAD_TEXT : font::NULL_MARKUP) << current_team.gold();
break;
case VILLAGES: {
const team_data data = calculate_team_data(current_team,current_side,units);
@ -199,7 +200,7 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
}
case INCOME: {
const team_data data = calculate_team_data(current_team,current_side,units);
str << (data.net_income < 0 ? "#" : "") << data.net_income;
str << (data.net_income < 0 ? font::BAD_TEXT : font::NULL_MARKUP) << data.net_income;
break;
}
case TERRAIN: {

View file

@ -158,14 +158,21 @@ void adjust_surface_colour(SDL_Surface* surface, int r, int g, int b)
SDL_Surface* get_surface_portion(SDL_Surface* src, SDL_Rect& area)
{
if(area.x + area.w > src->w || area.y + area.h > src->h)
if(area.x + area.w > src->w || area.y + area.h > src->h) {
std::cerr << "illegal surface portion...\n";
return NULL;
}
const SDL_PixelFormat* const fmt = src->format;
SDL_Surface* const dst = SDL_CreateRGBSurface(0,area.w,area.h,
fmt->BitsPerPixel,fmt->Rmask,
fmt->Gmask,fmt->Bmask,
fmt->Amask);
if(dst == NULL) {
std::cerr << "Could not create a new surface in get_surface_portion()\n";
return NULL;
}
SDL_Rect dstarea = {0,0,0,0};
SDL_BlitSurface(src,&area,dst,&dstarea);

View file

@ -704,23 +704,29 @@ void fade_logo(display& screen, int xpos, int ypos)
return;
}
CKey key;
//only once, when the game is first started, the logo fades in
static bool faded_in = false;
bool last_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
if(!faded_in) {
faded_in = true;
CKey key;
for(int i = 0; i < 170; i += 5) {
const bool new_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
if(new_button && !last_button)
break;
bool last_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
last_button = new_button;
for(int i = 0; i < 170; i += 5) {
const bool new_button = key[SDLK_ESCAPE] || key[SDLK_SPACE];
if(new_button && !last_button)
break;
SDL_SetAlpha(logo,SDL_SRCALPHA,i);
screen.blit_surface(xpos,ypos,logo);
update_rect(xpos,ypos,logo->w,logo->h);
screen.video().flip();
SDL_Delay(20);
events::pump();
last_button = new_button;
SDL_SetAlpha(logo,SDL_SRCALPHA,i);
screen.blit_surface(xpos,ypos,logo);
update_rect(xpos,ypos,logo->w,logo->h);
screen.video().flip();
SDL_Delay(20);
events::pump();
}
}
SDL_SetAlpha(logo,SDL_SRCALPHA,255);

View file

@ -10,6 +10,8 @@
See the COPYING file for more details.
*/
#include "font.hpp"
#include "game_config.hpp"
#include "gamestatus.hpp"
#include "language.hpp"
@ -722,7 +724,7 @@ void unit::add_modification(const std::string& type,
const std::string& violate_max = (**i.first)["violate_maximum"];
if(increase_total.empty() == false) {
description << (increase_total[0] != '-' ? "+" : "") << increase_total << translate_string("hp");
description << (increase_total[0] != '-' ? font::LARGE_TEXT : font::NULL_MARKUP) << increase_total << translate_string("hp");
//a percentage on the end means increase by that many percent
if(increase_total[increase_total.size()-1] == '%') {
@ -755,7 +757,7 @@ void unit::add_modification(const std::string& type,
const std::string& set_to = (**i.first)["set"];
if(increase.empty() == false) {
description << (increase[0] != '-' ? "+" : "") << increase << translate_string("moves");
description << (increase[0] != '-' ? font::LARGE_TEXT : font::NULL_MARKUP) << increase << translate_string("moves");
if(increase[increase.size()-1] == '%') {
const std::string inc(increase.begin(),increase.end()-1);
@ -778,7 +780,7 @@ void unit::add_modification(const std::string& type,
const std::string& increase = (**i.first)["increase"];
if(increase.empty() == false) {
description << (increase[0] != '-' ? "+" : "") << increase << translate_string("xp");
description << (increase[0] != '-' ? font::LARGE_TEXT : font::NULL_MARKUP) << increase << translate_string("xp");
if(increase[increase.size()-1] == '%') {
const std::string inc(increase.begin(),increase.end()-1);
maxExperience_ += (maxExperience_*atoi(inc.c_str()))/100;

View file

@ -39,7 +39,7 @@ slider::slider(const slider& o) :
area_(o.area_), value_(o.value_), drawn_(o.drawn_), highlight_(o.highlight_),
clicked_(o.clicked_), dragging_(o.dragging_)
{
background_changed();
background_changed();
}
slider& slider::operator=(const slider& o)