Convert all usecases of SDL_Color to color_t
This commit is contained in:
parent
a8517a234d
commit
4b3862493f
63 changed files with 203 additions and 210 deletions
|
@ -1148,7 +1148,7 @@ namespace { // Private helpers for move_unit()
|
|||
symbols["enemies"] = std::to_string(enemy_count_);
|
||||
symbols["friends"] = std::to_string(friend_count_);
|
||||
std::string message;
|
||||
SDL_Color msg_color;
|
||||
color_t msg_color;
|
||||
if ( friend_count_ != 0 && enemy_count_ != 0 ) {
|
||||
// Both friends and enemies sighted -- neutral message.
|
||||
symbols["friendphrase"] = vngettext("Part of 'Units sighted! (...)' sentence^1 friendly", "$friends friendly", friend_count_, symbols);
|
||||
|
|
|
@ -1235,7 +1235,7 @@ private:
|
|||
display* gui = display::get_singleton();
|
||||
std::string team_name;
|
||||
|
||||
SDL_Color color = color_t::from_argb_bytes(team::get_side_rgb(ai_.get_side())).to_sdl();
|
||||
color_t color = color_t::from_argb_bytes(team::get_side_rgb(ai_.get_side()));
|
||||
|
||||
const terrain_label *res;
|
||||
res = gui->labels().set_label(location, text, ai_.get_side() - 1, team_name, color);
|
||||
|
|
|
@ -466,11 +466,11 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
|
|||
int hp = hp_prob_vector[hp_prob_vector.size() - i - 1].first;
|
||||
double prob = hp_prob_vector[hp_prob_vector.size() - i - 1].second;
|
||||
|
||||
SDL_Color row_color;
|
||||
color_t row_color;
|
||||
|
||||
// Death line is red.
|
||||
if(hp == 0) {
|
||||
SDL_Color color = {0xe5, 0, 0, SDL_ALPHA_OPAQUE};
|
||||
color_t color = {0xe5, 0, 0, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
}
|
||||
|
||||
|
@ -478,17 +478,17 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
|
|||
else if(hp < static_cast<int>(stats.hp)) {
|
||||
// Stone is grey.
|
||||
if(opp_stats.petrifies) {
|
||||
SDL_Color color = {0x9a, 0x9a, 0x9a, SDL_ALPHA_OPAQUE};
|
||||
color_t color = {0x9a, 0x9a, 0x9a, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
} else {
|
||||
SDL_Color color = {0xf4, 0xc9, 0, SDL_ALPHA_OPAQUE};
|
||||
color_t color = {0xf4, 0xc9, 0, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
}
|
||||
}
|
||||
|
||||
// Current hitpoints value and above is green.
|
||||
else {
|
||||
SDL_Color color = {0x08, 0xca, 0, SDL_ALPHA_OPAQUE};
|
||||
color_t color = {0x08, 0xca, 0, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
}
|
||||
|
||||
|
|
|
@ -1496,7 +1496,7 @@ static void draw_background(surface screen, const SDL_Rect& area, const std::str
|
|||
|
||||
void display::draw_text_in_hex(const map_location& loc,
|
||||
const drawing_layer layer, const std::string& text,
|
||||
size_t font_size, SDL_Color color, double x_in_hex, double y_in_hex)
|
||||
size_t font_size, color_t color, double x_in_hex, double y_in_hex)
|
||||
{
|
||||
if (text.empty()) return;
|
||||
|
||||
|
@ -1742,7 +1742,7 @@ void display::enable_menu(const std::string& item, bool enable)
|
|||
}
|
||||
}
|
||||
|
||||
void display::announce(const std::string& message, const SDL_Color& color, int lifetime)
|
||||
void display::announce(const std::string& message, const color_t& color, int lifetime)
|
||||
{
|
||||
font::floating_label flabel(message);
|
||||
flabel.set_font_size(font::SIZE_XLARGE);
|
||||
|
@ -1838,7 +1838,7 @@ void display::draw_minimap()
|
|||
const surface& screen(screen_.getSurface());
|
||||
clip_rect_setter clip_setter(screen, &area);
|
||||
|
||||
SDL_Color back_color = {31,31,23,SDL_ALPHA_OPAQUE};
|
||||
color_t back_color = {31,31,23,SDL_ALPHA_OPAQUE};
|
||||
draw_centered_on_background(minimap_, area, back_color, screen);
|
||||
|
||||
//update the minimap location for mouse and units functions
|
||||
|
@ -1891,25 +1891,25 @@ void display::draw_minimap_units()
|
|||
}
|
||||
|
||||
int side = u->side();
|
||||
SDL_Color col = team::get_minimap_color(side);
|
||||
color_t col = team::get_minimap_color(side);
|
||||
|
||||
if (!preferences::minimap_movement_coding()) {
|
||||
|
||||
if (dc_->teams()[currentTeam_].is_enemy(side)) {
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::enemy_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::enemy_color()).rep());
|
||||
} else {
|
||||
|
||||
if (currentTeam_ +1 == static_cast<unsigned>(side)) {
|
||||
|
||||
if (u->movement_left() == u->total_movement())
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::unmoved_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::unmoved_color()).rep());
|
||||
else if (u->movement_left() == 0)
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::moved_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::moved_color()).rep());
|
||||
else
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::partial_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::partial_color()).rep());
|
||||
|
||||
} else
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::allied_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::allied_color()).rep());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ public:
|
|||
|
||||
/** Announce a message prominently. */
|
||||
void announce(const std::string& msg,
|
||||
const SDL_Color& color = font::GOOD_COLOR, int lifetime = 100);
|
||||
const color_t& color = font::GOOD_COLOR, int lifetime = 100);
|
||||
|
||||
/**
|
||||
* Schedule the minimap for recalculation.
|
||||
|
@ -882,7 +882,7 @@ public:
|
|||
*/
|
||||
void draw_text_in_hex(const map_location& loc,
|
||||
const drawing_layer layer, const std::string& text, size_t font_size,
|
||||
SDL_Color color, double x_in_hex=0.5, double y_in_hex=0.5);
|
||||
color_t color, double x_in_hex=0.5, double y_in_hex=0.5);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ static lg::log_domain log_engine("engine");
|
|||
namespace {
|
||||
const int chat_message_border = 5;
|
||||
const int chat_message_x = 10;
|
||||
const SDL_Color chat_message_color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
const SDL_Color chat_message_bg = {0,0,0,140};
|
||||
const color_t chat_message_color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
const color_t chat_message_bg = {0,0,0,140};
|
||||
}
|
||||
|
||||
display_chat_manager::chat_message::chat_message(int speaker, int h)
|
||||
|
@ -115,12 +115,12 @@ void display_chat_manager::add_chat_message(const time_t& time, const std::strin
|
|||
ypos += std::max(font::get_floating_label_rect(m->handle).h,
|
||||
font::get_floating_label_rect(m->speaker_handle).h);
|
||||
}
|
||||
SDL_Color speaker_color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
color_t speaker_color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
if(side >= 1) {
|
||||
speaker_color = color_t::from_argb_bytes(team::get_side_color_range(side).mid()).to_sdl();
|
||||
speaker_color = color_t::from_argb_bytes(team::get_side_color_range(side).mid());
|
||||
}
|
||||
|
||||
SDL_Color message_color = chat_message_color;
|
||||
color_t message_color = chat_message_color;
|
||||
std::stringstream str;
|
||||
std::stringstream message_str;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class editor_action_label : public editor_action_location
|
|||
{
|
||||
public:
|
||||
editor_action_label(map_location loc, const std::string& text, const std::string& team_name,
|
||||
SDL_Color color, bool visible_fog, bool visible_shroud, bool immutable, std::string category)
|
||||
color_t color, bool visible_fog, bool visible_shroud, bool immutable, std::string category)
|
||||
: editor_action_location(loc), text_(text) , team_name_(team_name), category_(category), color_(color)
|
||||
, visible_fog_(visible_fog), visible_shroud_(visible_shroud), immutable_(immutable)
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ class editor_action_label : public editor_action_location
|
|||
const std::string text_;
|
||||
const std::string team_name_;
|
||||
const std::string category_;
|
||||
SDL_Color color_;
|
||||
color_t color_;
|
||||
bool visible_fog_;
|
||||
bool visible_shroud_;
|
||||
bool immutable_;
|
||||
|
|
|
@ -79,7 +79,7 @@ editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int
|
|||
bool visible_shroud = old_label ? old_label->visible_in_shroud() : false;
|
||||
bool visible_fog = old_label ? old_label->visible_in_fog() : true;
|
||||
bool immutable = old_label ? old_label->immutable() : true;
|
||||
SDL_Color color = old_label ? old_label->color() : font::NORMAL_COLOR;
|
||||
color_t color = old_label ? old_label->color() : font::NORMAL_COLOR;
|
||||
|
||||
// TODO: remove once color_t is used everywhere
|
||||
color_t c(color);
|
||||
|
|
|
@ -234,7 +234,7 @@ void tristate_button::draw_contents() {
|
|||
clipArea.w += image_w + checkbox_horizontal_padding;
|
||||
textx = loc.x + image_w + checkbox_horizontal_padding / 2;
|
||||
|
||||
SDL_Color button_color = font::BUTTON_COLOR;
|
||||
color_t button_color = font::BUTTON_COLOR;
|
||||
|
||||
surface scalled_item;
|
||||
scalled_item.assign(scale_surface(itemImage_,
|
||||
|
|
|
@ -81,7 +81,7 @@ surface floating_label::create_surface()
|
|||
{
|
||||
if (surf_.null()) {
|
||||
font::pango_text text;
|
||||
text.set_foreground_color(color_t(color_));
|
||||
text.set_foreground_color(color_);
|
||||
text.set_font_size(font_size_);
|
||||
text.set_maximum_width(width_ < 0 ? clip_rect_.w : width_);
|
||||
text.set_maximum_height(height_ < 0 ? clip_rect_.h : height_, true);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "sdl/color.hpp"
|
||||
#include "sdl/utils.hpp"
|
||||
#include <string>
|
||||
|
||||
|
@ -53,8 +54,8 @@ public:
|
|||
lifetime_ = lifetime;
|
||||
alpha_change_ = -255 / lifetime_;
|
||||
}
|
||||
void set_color(const SDL_Color& color) {color_ = color;}
|
||||
void set_bg_color(const SDL_Color& bg_color) {
|
||||
void set_color(const color_t& color) {color_ = color;}
|
||||
void set_bg_color(const color_t& bg_color) {
|
||||
bgcolor_ = bg_color;
|
||||
bgalpha_ = bg_color.a;
|
||||
}
|
||||
|
@ -85,7 +86,7 @@ private:
|
|||
surface surf_, buf_;
|
||||
std::string text_;
|
||||
int font_size_;
|
||||
SDL_Color color_, bgcolor_;
|
||||
color_t color_, bgcolor_;
|
||||
int bgalpha_;
|
||||
double xpos_, ypos_, xmove_, ymove_;
|
||||
int lifetime_;
|
||||
|
|
|
@ -50,7 +50,7 @@ const char LARGE_TEXT='*', SMALL_TEXT='`',
|
|||
std::string::const_iterator parse_markup(std::string::const_iterator i1,
|
||||
std::string::const_iterator i2,
|
||||
int* font_size,
|
||||
SDL_Color* color, int* style)
|
||||
color_t* color, int* style)
|
||||
{
|
||||
while(i1 != i2) {
|
||||
switch(*i1) {
|
||||
|
@ -118,7 +118,7 @@ std::string::const_iterator parse_markup(std::string::const_iterator i1,
|
|||
}
|
||||
blue=temp;
|
||||
if (i1 != i2 && '>' == (*i1)) {
|
||||
SDL_Color temp_color = {red, green, blue, 0};
|
||||
color_t temp_color = {red, green, blue, 0};
|
||||
if (color) *color = temp_color;
|
||||
} else {
|
||||
// stop parsing and do not consume any chars
|
||||
|
@ -146,10 +146,10 @@ std::string del_tags(const std::string& text){
|
|||
return utils::join(lines, "\n");
|
||||
}
|
||||
|
||||
std::string color2markup(const SDL_Color &color)
|
||||
std::string color2markup(const color_t &color)
|
||||
{
|
||||
std::stringstream markup;
|
||||
// The RGB of SDL_Color are Uint8, we need to cast them to int.
|
||||
// The RGB of color_t are Uint8, we need to cast them to int.
|
||||
// Without cast, it gives their char equivalent.
|
||||
markup << "<"
|
||||
<< static_cast<int>(color.r) << ","
|
||||
|
@ -165,7 +165,7 @@ SDL_Rect text_area(const std::string& text, int size, int style)
|
|||
}
|
||||
|
||||
SDL_Rect draw_text(surface& dst, const SDL_Rect& area, int size,
|
||||
const SDL_Color& color, const std::string& txt,
|
||||
const color_t& color, const std::string& txt,
|
||||
int x, int y, bool use_tooltips, int style)
|
||||
{
|
||||
// Make sure there's always at least a space,
|
||||
|
@ -182,7 +182,7 @@ SDL_Rect draw_text(surface& dst, const SDL_Rect& area, int size,
|
|||
std::string::const_iterator i1 = text.begin();
|
||||
std::string::const_iterator i2 = std::find(i1,text.end(),'\n');
|
||||
for(;;) {
|
||||
SDL_Color col = color;
|
||||
color_t col = color;
|
||||
int sz = size;
|
||||
int text_style = style;
|
||||
|
||||
|
@ -212,7 +212,7 @@ SDL_Rect draw_text(surface& dst, const SDL_Rect& area, int size,
|
|||
}
|
||||
|
||||
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
|
||||
const SDL_Color& color, const std::string& txt,
|
||||
const color_t& color, const std::string& txt,
|
||||
int x, int y, bool use_tooltips, int style)
|
||||
{
|
||||
surface null_surf = surface(nullptr);
|
||||
|
@ -425,7 +425,7 @@ std::string word_wrap_text(const std::string& unwrapped_text, int font_size,
|
|||
bool start_of_line = true;
|
||||
std::string wrapped_text;
|
||||
std::string format_string;
|
||||
SDL_Color color;
|
||||
color_t color;
|
||||
int font_sz = font_size;
|
||||
int style = TTF_STYLE_NORMAL;
|
||||
utf8::iterator end = utf8::iterator::end(unwrapped_text);
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
#ifndef MARKED_UP_TEXT_HPP_INCLUDED
|
||||
#define MARKED_UP_TEXT_HPP_INCLUDED
|
||||
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
class CVideo;
|
||||
class surface;
|
||||
#include <SDL_video.h>
|
||||
|
||||
#include <string>
|
||||
#include "serialization/unicode_types.hpp"
|
||||
|
||||
|
||||
namespace font {
|
||||
|
||||
/** Standard markups for color, size, font, images. */
|
||||
|
@ -35,7 +35,7 @@ extern const char LARGE_TEXT, SMALL_TEXT, BOLD_TEXT, NORMAL_TEXT, NULL_MARKUP, B
|
|||
std::string::const_iterator parse_markup(std::string::const_iterator i1,
|
||||
std::string::const_iterator i2,
|
||||
int* font_size,
|
||||
SDL_Color* color, int* style);
|
||||
color_t* color, int* style);
|
||||
|
||||
/**
|
||||
* Function to draw text on a surface.
|
||||
|
@ -59,12 +59,12 @@ std::string::const_iterator parse_markup(std::string::const_iterator i1,
|
|||
* text will not be drawn, and a bounding rectangle only will be returned.
|
||||
*/
|
||||
SDL_Rect draw_text(surface& dst, const SDL_Rect& area, int size,
|
||||
const SDL_Color& color, const std::string& text,
|
||||
const color_t& color, const std::string& text,
|
||||
int x, int y, bool use_tooltips = false, int style = 0);
|
||||
|
||||
/** wrapper of the previous function, gui can also be nullptr */
|
||||
SDL_Rect draw_text(CVideo* gui, const SDL_Rect& area, int size,
|
||||
const SDL_Color& color, const std::string& text,
|
||||
const color_t& color, const std::string& text,
|
||||
int x, int y, bool use_tooltips = false, int style = 0);
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ bool is_format_char(char c);
|
|||
bool is_cjk_char(const ucs4::char_t ch);
|
||||
|
||||
/** Create string of color-markup, such as "<255,255,0>" for yellow. */
|
||||
std::string color2markup(const SDL_Color &color);
|
||||
std::string color2markup(const color_t &color);
|
||||
|
||||
/**
|
||||
* Wrap text.
|
||||
|
|
|
@ -260,7 +260,7 @@ TTF_Font* sdl_ttf::get_font(font_id id)
|
|||
* Interface to SDL_TTF
|
||||
*/
|
||||
|
||||
static surface render_text(const std::string& text, int fontsize, const SDL_Color& color, int style, bool use_markup)
|
||||
static surface render_text(const std::string& text, int fontsize, const color_t& color, int style, bool use_markup)
|
||||
{
|
||||
// we keep blank lines and spaces (may be wanted for indentation)
|
||||
const std::vector<std::string> lines = utils::split(text, '\n', 0);
|
||||
|
@ -333,14 +333,14 @@ static surface render_text(const std::string& text, int fontsize, const SDL_Colo
|
|||
}
|
||||
|
||||
|
||||
surface get_rendered_text(const std::string& str, int size, const SDL_Color& color, int style)
|
||||
surface get_rendered_text(const std::string& str, int size, const color_t& color, int style)
|
||||
{
|
||||
// TODO maybe later also to parse markup here, but a lot to check
|
||||
return render_text(str, size, color, style, false);
|
||||
}
|
||||
|
||||
SDL_Rect draw_text_line(surface& gui_surface, const SDL_Rect& area, int size,
|
||||
const SDL_Color& color, const std::string& text,
|
||||
const color_t& color, const std::string& text,
|
||||
int x, int y, bool use_tooltips, int style)
|
||||
{
|
||||
size = preferences::font_scaled(size);
|
||||
|
@ -432,7 +432,7 @@ SDL_Rect line_size(const std::string& line, int font_size, int style)
|
|||
|
||||
SDL_Rect res;
|
||||
|
||||
const SDL_Color col = { 0, 0, 0, 0 };
|
||||
const color_t col = { 0, 0, 0, 0 };
|
||||
text_surface s(line, font_size, col, style);
|
||||
|
||||
res.w = s.width();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "constants.hpp"
|
||||
#include "font_id.hpp"
|
||||
#include "font_description.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -28,10 +29,10 @@ class surface;
|
|||
namespace font {
|
||||
|
||||
// Returns a SDL surface containing the text rendered in a given color.
|
||||
surface get_rendered_text(const std::string& text, int size, const SDL_Color& color, int style=0);
|
||||
surface get_rendered_text(const std::string& text, int size, const color_t& color, int style=0);
|
||||
|
||||
SDL_Rect draw_text_line(surface& gui_surface, const SDL_Rect& area, int size,
|
||||
const SDL_Color& color, const std::string& text,
|
||||
const color_t& color, const std::string& text,
|
||||
int x, int y, bool use_tooltips, int style);
|
||||
|
||||
// Returns the maximum height of a font, in pixels
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
namespace font {
|
||||
|
||||
const SDL_Color
|
||||
const color_t
|
||||
NORMAL_COLOR {0xDD,0xDD,0xDD,0},
|
||||
GRAY_COLOR {0x77,0x77,0x77,0},
|
||||
LOBBY_COLOR {0xBB,0xBB,0xBB,0},
|
||||
|
@ -32,12 +32,12 @@ const SDL_Color
|
|||
LABEL_COLOR {0x6B,0x8C,0xFF,0},
|
||||
BIGMAP_COLOR {0xFF,0xFF,0xFF,0};
|
||||
|
||||
const SDL_Color DISABLED_COLOR = inverse(PETRIFIED_COLOR);
|
||||
const color_t DISABLED_COLOR = inverse(PETRIFIED_COLOR);
|
||||
|
||||
const SDL_Color
|
||||
const color_t
|
||||
weapon_color { 245, 230, 193, SDL_ALPHA_OPAQUE },
|
||||
good_dmg_color { 130, 240, 50, SDL_ALPHA_OPAQUE },
|
||||
bad_dmg_color { 250, 140, 80, SDL_ALPHA_OPAQUE },
|
||||
good_dmg_color { 130, 240, 50, SDL_ALPHA_OPAQUE },
|
||||
bad_dmg_color { 250, 140, 80, SDL_ALPHA_OPAQUE },
|
||||
weapon_details_color { 166, 146, 117, SDL_ALPHA_OPAQUE },
|
||||
inactive_details_color { 146, 146, 146, SDL_ALPHA_OPAQUE },
|
||||
inactive_ability_color { 146, 146, 146, SDL_ALPHA_OPAQUE },
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#ifndef FONT_STANDARD_COLORS_HPP
|
||||
#define FONT_STANDARD_COLORS_HPP
|
||||
|
||||
#include <SDL.h>
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
namespace font {
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace font {
|
|||
// TODO: these should probably all be constexpr
|
||||
//
|
||||
|
||||
extern const SDL_Color
|
||||
extern const color_t
|
||||
// These are GUI1 formatting colors and should be removed when GUI1 is
|
||||
NORMAL_COLOR,
|
||||
GRAY_COLOR,
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
namespace font {
|
||||
|
||||
std::string span_color(const SDL_Color& color)
|
||||
std::string span_color(const color_t& color)
|
||||
{
|
||||
return formatter() << "<span color='" << color_t(color).to_hex_string() << "'>";
|
||||
return formatter() << "<span color='" << color.to_hex_string() << "'>";
|
||||
}
|
||||
|
||||
std::string get_pango_color_from_id(const std::string& id)
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#ifndef TEXT_FORMATTING_HPP_INCLUDED
|
||||
#define TEXT_FORMATTING_HPP_INCLUDED
|
||||
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -24,14 +26,14 @@
|
|||
namespace font {
|
||||
|
||||
/**
|
||||
* Retuns a Pango formatting string using the provided SDL_Color object.
|
||||
* Retuns a Pango formatting string using the provided color_t object.
|
||||
*
|
||||
* The string returned will be in format: '<span foreground=#color>'
|
||||
* Callers will need to manually append the closing</span>' tag.
|
||||
*
|
||||
* @param color The SDL_Color object from which to retrieve the color.
|
||||
* @param color The color_t object from which to retrieve the color.
|
||||
*/
|
||||
std::string span_color(const SDL_Color& color);
|
||||
std::string span_color(const color_t& color);
|
||||
|
||||
/**
|
||||
* Returns a hex color string from a color range.
|
||||
|
|
|
@ -70,7 +70,7 @@ void text_surface::bidi_cvt()
|
|||
#endif
|
||||
|
||||
text_surface::text_surface(const std::string& str, int size,
|
||||
SDL_Color color, int style)
|
||||
color_t color, int style)
|
||||
: hash_(0)
|
||||
, font_size_(size)
|
||||
, color_(color)
|
||||
|
@ -91,7 +91,7 @@ text_surface::text_surface(const std::string& str, int size,
|
|||
hash();
|
||||
}
|
||||
|
||||
text_surface::text_surface(int size, SDL_Color color, int style) :
|
||||
text_surface::text_surface(int size, color_t color, int style) :
|
||||
hash_(0),
|
||||
font_size_(size),
|
||||
color_(color),
|
||||
|
@ -184,7 +184,7 @@ std::vector<surface> const &text_surface::get_surfaces() const
|
|||
{
|
||||
TTF_Font* ttfont = sdl_ttf::get_font(font_id(chunk.subset, font_size_, style_));
|
||||
|
||||
surface s = surface(TTF_RenderUTF8_Blended(ttfont, chunk.text.c_str(), color_));
|
||||
surface s = surface(TTF_RenderUTF8_Blended(ttfont, chunk.text.c_str(), color_.to_sdl()));
|
||||
if(!s.null())
|
||||
surfs_.push_back(s);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define FONT_TEXT_SURFACE_HPP
|
||||
|
||||
#include "font_id.hpp" // for text_chunk
|
||||
#include "sdl/color.hpp"
|
||||
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
|
@ -32,8 +33,8 @@ namespace font {
|
|||
class text_surface
|
||||
{
|
||||
public:
|
||||
text_surface(const std::string& str, int size, SDL_Color color, int style);
|
||||
text_surface(int size, SDL_Color color, int style);
|
||||
text_surface(const std::string& str, int size, color_t color, int style);
|
||||
text_surface(int size, color_t color, int style);
|
||||
void set_text(const std::string& str);
|
||||
|
||||
void measure() const;
|
||||
|
@ -49,7 +50,7 @@ public:
|
|||
private:
|
||||
int hash_;
|
||||
int font_size_;
|
||||
SDL_Color color_;
|
||||
color_t color_;
|
||||
int style_;
|
||||
mutable int w_, h_;
|
||||
std::string str_;
|
||||
|
|
|
@ -267,7 +267,7 @@ private:
|
|||
}
|
||||
|
||||
void display_float(const map_location& location, const std::string& text) const{
|
||||
game_display::get_singleton()->float_label(location, text, color_t(255,0,0).to_sdl());
|
||||
game_display::get_singleton()->float_label(location, text, color_t(255,0,0));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -436,7 +436,7 @@ void game_display::draw_movement_info(const map_location& loc)
|
|||
std::stringstream def_text;
|
||||
def_text << def << "%";
|
||||
|
||||
SDL_Color color = color_t::from_argb_bytes(game_config::red_to_green(def, false)).to_sdl();
|
||||
color_t color = color_t::from_argb_bytes(game_config::red_to_green(def, false));
|
||||
|
||||
// simple mark (no turn point) use smaller font
|
||||
int def_font = w->second.turns > 0 ? 18 : 16;
|
||||
|
@ -481,7 +481,7 @@ void game_display::draw_movement_info(const map_location& loc)
|
|||
std::stringstream def_text;
|
||||
def_text << def << "%";
|
||||
|
||||
SDL_Color color = color_t::from_argb_bytes(game_config::red_to_green(def, false)).to_sdl();
|
||||
color_t color = color_t::from_argb_bytes(game_config::red_to_green(def, false));
|
||||
|
||||
// use small font
|
||||
int def_font = 16;
|
||||
|
@ -613,7 +613,7 @@ void game_display::set_route(const pathfind::marked_route *route)
|
|||
invalidate_route();
|
||||
}
|
||||
|
||||
void game_display::float_label(const map_location& loc, const std::string& text, const SDL_Color& color)
|
||||
void game_display::float_label(const map_location& loc, const std::string& text, const color_t& color)
|
||||
{
|
||||
if(preferences::show_floating_labels() == false || fogged(loc)) {
|
||||
return;
|
||||
|
|
|
@ -117,7 +117,7 @@ public:
|
|||
void set_route(const pathfind::marked_route *route);
|
||||
|
||||
/** Function to float a label above a tile */
|
||||
void float_label(const map_location& loc, const std::string& text, const SDL_Color& color);
|
||||
void float_label(const map_location& loc, const std::string& text, const color_t& color);
|
||||
|
||||
/** Draws the movement info (turns available) for a given location. */
|
||||
void draw_movement_info(const map_location& loc);
|
||||
|
|
|
@ -134,10 +134,10 @@ void unit_attack::pre_show(window& window)
|
|||
continue;
|
||||
}
|
||||
|
||||
const SDL_Color a_cth_color =
|
||||
color_t::from_argb_bytes(game_config::red_to_green(attacker.chance_to_hit)).to_sdl();
|
||||
const SDL_Color d_cth_color =
|
||||
color_t::from_argb_bytes(game_config::red_to_green(defender.chance_to_hit)).to_sdl();
|
||||
const color_t a_cth_color =
|
||||
color_t::from_argb_bytes(game_config::red_to_green(attacker.chance_to_hit));
|
||||
const color_t d_cth_color =
|
||||
color_t::from_argb_bytes(game_config::red_to_green(defender.chance_to_hit));
|
||||
|
||||
const std::string attw_name = !attacker_weapon.name().empty() ? attacker_weapon.name() : " ";
|
||||
const std::string defw_name = !defender_weapon.name().empty() ? defender_weapon.name() : " ";
|
||||
|
|
|
@ -1303,7 +1303,7 @@ std::string convert_to_wml(const std::string &element_name, const std::string &c
|
|||
return ss.str();
|
||||
}
|
||||
|
||||
SDL_Color string_to_color(const std::string &cmp_str)
|
||||
color_t string_to_color(const std::string &cmp_str)
|
||||
{
|
||||
if (cmp_str == "green") {
|
||||
return font::GOOD_COLOR;
|
||||
|
@ -1322,7 +1322,7 @@ SDL_Color string_to_color(const std::string &cmp_str)
|
|||
}
|
||||
// a #rrggbb color in pango format.
|
||||
if (*cmp_str.c_str() == '#' && cmp_str.size() == 7) {
|
||||
return color_t::from_argb_bytes(strtoul(cmp_str.c_str() + 1, nullptr, 16)).to_sdl();
|
||||
return color_t::from_argb_bytes(strtoul(cmp_str.c_str() + 1, nullptr, 16));
|
||||
}
|
||||
return font::NORMAL_COLOR;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
#include <string> // for string, allocator, etc
|
||||
#include <utility> // for pair, make_pair
|
||||
#include <vector> // for vector, etc
|
||||
#include <SDL.h> // for SDL_Color, SDL_Surface
|
||||
#include <SDL.h> // for SDL_Surface
|
||||
|
||||
class config;
|
||||
class unit_type;
|
||||
|
@ -297,7 +297,7 @@ std::string convert_to_wml(const std::string &element_name, const std::string &c
|
|||
|
||||
/// Return the color the string represents. Return font::NORMAL_COLOR if
|
||||
/// the string is empty or can't be matched against any other color.
|
||||
SDL_Color string_to_color(const std::string &s);
|
||||
color_t string_to_color(const std::string &s);
|
||||
|
||||
/// Make a best effort to word wrap s. All parts are less than width.
|
||||
std::vector<std::string> split_in_width(const std::string &s, const int font_size, const unsigned width);
|
||||
|
|
|
@ -287,13 +287,13 @@ void help_text_area::handle_format_cfg(const config &cfg)
|
|||
bool bold = cfg["bold"].to_bool();
|
||||
bool italic = cfg["italic"].to_bool();
|
||||
int font_size = cfg["font_size"].to_int(normal_font_size);
|
||||
SDL_Color color = help::string_to_color(cfg["color"]);
|
||||
color_t color = help::string_to_color(cfg["color"]);
|
||||
add_text_item(text, "", false, font_size, bold, italic, color);
|
||||
}
|
||||
|
||||
void help_text_area::add_text_item(const std::string& text, const std::string& ref_dst,
|
||||
bool broken_link, int _font_size, bool bold, bool italic,
|
||||
SDL_Color text_color
|
||||
color_t text_color
|
||||
)
|
||||
{
|
||||
const int font_size = _font_size < 0 ? normal_font_size : _font_size;
|
||||
|
@ -327,7 +327,7 @@ void help_text_area::add_text_item(const std::string& text, const std::string& r
|
|||
std::vector<std::string> parts = split_in_width(text, font_size, remaining_width);
|
||||
std::string first_part = parts.front();
|
||||
// Always override the color if we have a cross reference.
|
||||
SDL_Color color;
|
||||
color_t color;
|
||||
if(ref_dst.empty())
|
||||
color = text_color;
|
||||
else if(broken_link)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <list> // for list
|
||||
#include <string> // for string
|
||||
#include <utility> // for pair
|
||||
#include <SDL_video.h> // for SDL_Color (ptr only), etc
|
||||
#include "font/standard_colors.hpp" // for NORMAL_COLOR
|
||||
#include "sdl/utils.hpp" // for surface
|
||||
#include "widgets/scrollarea.hpp" // for scrollarea
|
||||
|
@ -117,7 +116,7 @@ private:
|
|||
void add_text_item(const std::string& text, const std::string& ref_dst="",
|
||||
bool broken_link = false,
|
||||
int font_size=-1, bool bold=false, bool italic=false,
|
||||
SDL_Color color=font::NORMAL_COLOR);
|
||||
color_t color=font::NORMAL_COLOR);
|
||||
|
||||
/// Add an image item with the specified attributes.
|
||||
void add_img_item(const std::string& path, const std::string& alignment, const bool floating,
|
||||
|
|
|
@ -569,7 +569,7 @@ surface background_modification::operator()(const surface &src) const
|
|||
return ret;
|
||||
}
|
||||
|
||||
const SDL_Color& background_modification::get_color() const
|
||||
const color_t& background_modification::get_color() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
@ -1251,7 +1251,7 @@ REGISTER_MOD_PARSER(BG, args)
|
|||
c[i] = lexical_cast_default<int>(factors[i]);
|
||||
}
|
||||
|
||||
return new background_modification(color_t(c[0], c[1], c[2], c[3]).to_sdl());
|
||||
return new background_modification(color_t(c[0], c[1], c[2], c[3]));
|
||||
}
|
||||
|
||||
// Channel swap
|
||||
|
|
|
@ -520,12 +520,12 @@ struct darken_modification : modification
|
|||
*/
|
||||
struct background_modification : modification
|
||||
{
|
||||
background_modification(SDL_Color const &c): color_(c) {}
|
||||
background_modification(color_t const &c): color_(c) {}
|
||||
virtual surface operator()(const surface &src) const;
|
||||
const SDL_Color& get_color() const;
|
||||
const color_t& get_color() const;
|
||||
|
||||
private:
|
||||
SDL_Color color_;
|
||||
color_t color_;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@ void the_end(CVideo &video, std::string text, unsigned int duration)
|
|||
if(n)
|
||||
sdl::fill_rect(video.getSurface(),&area,0);
|
||||
|
||||
const SDL_Color col = color_t(uint8_t(n), uint8_t(n), uint8_t(n), uint8_t(n)).to_sdl();
|
||||
const color_t col = color_t(uint8_t(n), uint8_t(n), uint8_t(n), uint8_t(n));
|
||||
font::draw_text(&video,area,font_size,col,text,area.x,area.y);
|
||||
update_rect(area);
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ const terrain_label* map_labels::set_label(const map_location& loc,
|
|||
const t_string& text,
|
||||
const int creator,
|
||||
const std::string& team_name,
|
||||
const SDL_Color color,
|
||||
const color_t color,
|
||||
const bool visible_in_fog,
|
||||
const bool visible_in_shroud,
|
||||
const bool immutable,
|
||||
|
@ -321,7 +321,7 @@ terrain_label::terrain_label(const t_string& text,
|
|||
const std::string& team_name,
|
||||
const map_location& loc,
|
||||
const map_labels& parent,
|
||||
const SDL_Color color,
|
||||
const color_t color,
|
||||
const bool visible_in_fog,
|
||||
const bool visible_in_shroud,
|
||||
const bool immutable,
|
||||
|
@ -370,7 +370,7 @@ void terrain_label::read(const config &cfg)
|
|||
{
|
||||
const variable_set &vs = *resources::gamedata;
|
||||
loc_ = map_location(cfg, &vs);
|
||||
SDL_Color color = font::LABEL_COLOR;
|
||||
color_t color = font::LABEL_COLOR;
|
||||
|
||||
std::string tmp_color = cfg["color"];
|
||||
|
||||
|
@ -397,7 +397,7 @@ void terrain_label::read(const config &cfg)
|
|||
tmp_color = utils::interpolate_variables_into_string(tmp_color, vs);
|
||||
|
||||
if(!tmp_color.empty()) {
|
||||
color = color_t::from_rgb_string(tmp_color).to_sdl();
|
||||
color = color_t::from_rgb_string(tmp_color);
|
||||
}
|
||||
|
||||
color_ = color;
|
||||
|
@ -462,7 +462,7 @@ const map_location& terrain_label::location() const
|
|||
return loc_;
|
||||
}
|
||||
|
||||
const SDL_Color& terrain_label::color() const
|
||||
const color_t& terrain_label::color() const
|
||||
{
|
||||
return color_;
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ void terrain_label::update_info(const t_string& text,
|
|||
const int creator,
|
||||
const t_string& tooltip,
|
||||
const std::string& team_name,
|
||||
const SDL_Color color)
|
||||
const color_t color)
|
||||
{
|
||||
color_ = color;
|
||||
text_ = text;
|
||||
|
@ -501,7 +501,7 @@ void terrain_label::update_info(const t_string& text,
|
|||
const int creator,
|
||||
const t_string& tooltip,
|
||||
const std::string& team_name,
|
||||
const SDL_Color color,
|
||||
const color_t color,
|
||||
const bool visible_in_fog,
|
||||
const bool visible_in_shroud,
|
||||
const bool immutable,
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "font/standard_colors.hpp"
|
||||
#include "map/location.hpp"
|
||||
#include "sdl/color.hpp"
|
||||
#include "tstring.hpp"
|
||||
|
||||
#include <map>
|
||||
|
@ -53,7 +54,7 @@ public:
|
|||
const t_string& text,
|
||||
const int creator = -1,
|
||||
const std::string& team = "",
|
||||
const SDL_Color color = font::NORMAL_COLOR,
|
||||
const color_t color = font::NORMAL_COLOR,
|
||||
const bool visible_in_fog = true,
|
||||
const bool visible_in_shroud = false,
|
||||
const bool immutable = false,
|
||||
|
@ -110,7 +111,7 @@ public:
|
|||
const std::string& team_name,
|
||||
const map_location& loc,
|
||||
const map_labels& parent,
|
||||
const SDL_Color color = font::NORMAL_COLOR,
|
||||
const color_t color = font::NORMAL_COLOR,
|
||||
const bool visible_in_fog = true,
|
||||
const bool visible_in_shroud = false,
|
||||
const bool immutable = false,
|
||||
|
@ -133,7 +134,7 @@ public:
|
|||
bool visible_in_shroud() const;
|
||||
bool immutable() const;
|
||||
const map_location& location() const;
|
||||
const SDL_Color& color() const;
|
||||
const color_t& color() const;
|
||||
|
||||
void set_text(const t_string&);
|
||||
|
||||
|
@ -141,13 +142,13 @@ public:
|
|||
const int creator,
|
||||
const t_string&,
|
||||
const std::string&,
|
||||
const SDL_Color);
|
||||
const color_t);
|
||||
|
||||
void update_info(const t_string& text,
|
||||
const int creator,
|
||||
const t_string& tooltip,
|
||||
const std::string& team_name,
|
||||
const SDL_Color color,
|
||||
const color_t color,
|
||||
const bool visible_in_fog,
|
||||
const bool visible_in_shroud,
|
||||
const bool immutable,
|
||||
|
@ -177,7 +178,7 @@ private:
|
|||
bool immutable_;
|
||||
int creator_;
|
||||
|
||||
SDL_Color color_;
|
||||
color_t color_;
|
||||
|
||||
const map_labels* parent_;
|
||||
map_location loc_;
|
||||
|
|
|
@ -728,12 +728,12 @@ void menu_handler::label_terrain(mouse_handler& mousehandler, bool team_only)
|
|||
|
||||
if(gui2::dialogs::edit_label::execute(label, team_only, gui_->video())) {
|
||||
std::string team_name;
|
||||
SDL_Color color = font::LABEL_COLOR;
|
||||
color_t color = font::LABEL_COLOR;
|
||||
|
||||
if (team_only) {
|
||||
team_name = gui_->labels().team_name();
|
||||
} else {
|
||||
color = color_t::from_argb_bytes(team::get_side_rgb(gui_->viewing_side())).to_sdl();
|
||||
color = color_t::from_argb_bytes(team::get_side_rgb(gui_->viewing_side()));
|
||||
}
|
||||
const terrain_label* res = gui_->labels().set_label(loc, label, gui_->viewing_team(), team_name, color);
|
||||
if (res)
|
||||
|
|
|
@ -184,12 +184,12 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
|
||||
} else {
|
||||
|
||||
SDL_Color col;
|
||||
color_t col;
|
||||
std::map<std::string, color_range>::const_iterator it = game_config::team_rgb_range.find(terrain_info.id());
|
||||
if (it == game_config::team_rgb_range.end()) {
|
||||
col = color_t(0,0,0,0).to_sdl();
|
||||
col = color_t(0,0,0,0);
|
||||
} else
|
||||
col = color_t::from_argb_bytes(it->second.rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(it->second.rep());
|
||||
|
||||
bool first = true;
|
||||
const t_translation::ter_list& underlying_terrains = tdata.underlying_union_terrain(terrain);
|
||||
|
@ -200,7 +200,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
if (it == game_config::team_rgb_range.end())
|
||||
continue;
|
||||
|
||||
SDL_Color tmp = color_t::from_argb_bytes(it->second.rep()).to_sdl();
|
||||
color_t tmp = color_t::from_argb_bytes(it->second.rep());
|
||||
|
||||
if (fogged) {
|
||||
if (tmp.b < 50) tmp.b = 0;
|
||||
|
@ -239,7 +239,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
|
||||
int side = (resources::gameboard ? resources::gameboard->village_owner(loc) : -1); //check needed for mp create dialog
|
||||
|
||||
SDL_Color col = color_t::from_argb_bytes(game_config::team_rgb_range.find("white")->second.min()).to_sdl();
|
||||
color_t col = color_t::from_argb_bytes(game_config::team_rgb_range.find("white")->second.min());
|
||||
|
||||
if (!fogged) {
|
||||
if (side > -1) {
|
||||
|
@ -249,11 +249,11 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
} else {
|
||||
|
||||
if (vw->owns_village(loc))
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::unmoved_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::unmoved_color()).rep());
|
||||
else if (vw->is_enemy(side + 1))
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::enemy_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::enemy_color()).rep());
|
||||
else
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::allied_color()).rep()).to_sdl();
|
||||
col = color_t::from_argb_bytes(game_config::color_info(preferences::allied_color()).rep());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
#include <ostream> // for operator<<, basic_ostream, etc
|
||||
#include <string> // for string, operator<<, etc
|
||||
#include <SDL_mouse.h> // for SDL_GetMouseState
|
||||
#include <SDL_video.h> // for SDL_Color
|
||||
|
||||
namespace gui { class slider; }
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ void playmp_controller::play_human_turn()
|
|||
{
|
||||
font::floating_label flabel(_("Undoing moves not yet transmitted to the server."));
|
||||
|
||||
SDL_Color color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
color_t color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
flabel.set_color(color);
|
||||
SDL_Rect rect = gui_->map_area();
|
||||
flabel.set_position(rect.w/2, rect.h/2);
|
||||
|
|
|
@ -340,7 +340,7 @@ static config unit_alignment(reports::context & rc, const unit* u)
|
|||
int cm = combat_modifier(rc.units(), rc.map(), rc.screen().displayed_unit_hex(), u->alignment(),
|
||||
u->is_fearless());
|
||||
|
||||
SDL_Color color = font::weapon_color;
|
||||
color_t color = font::weapon_color;
|
||||
if (cm != 0)
|
||||
color = (cm > 0) ? font::good_dmg_color : font::bad_dmg_color;
|
||||
|
||||
|
@ -519,7 +519,7 @@ static config unit_defense(reports::context & rc, const unit* u, const map_locat
|
|||
|
||||
const t_translation::terrain_code &terrain = map[displayed_unit_hex];
|
||||
int def = 100 - u->defense_modifier(terrain);
|
||||
SDL_Color color = color_t::from_argb_bytes(game_config::red_to_green(def)).to_sdl();
|
||||
color_t color = color_t::from_argb_bytes(game_config::red_to_green(def));
|
||||
str << span_color(color) << def << '%' << naps;
|
||||
tooltip << _("Terrain: ") << "<b>" << map.get_terrain_info(terrain).description() << "</b>\n";
|
||||
|
||||
|
@ -535,7 +535,7 @@ static config unit_defense(reports::context & rc, const unit* u, const map_locat
|
|||
revert = false;
|
||||
} else {
|
||||
int t_def = 100 - u->defense_modifier(t);
|
||||
SDL_Color t_color = color_t::from_argb_bytes(game_config::red_to_green(t_def)).to_sdl();
|
||||
color_t t_color = color_t::from_argb_bytes(game_config::red_to_green(t_def));
|
||||
tooltip << '\t' << map.get_terrain_info(t).description() << ": "
|
||||
<< span_color(t_color) << t_def << '%' << naps
|
||||
<< (revert ? _("maximum^max.") : _("minimum^min.")) << '\n';
|
||||
|
@ -632,7 +632,7 @@ static config unit_moves(reports::context & rc, const unit* u)
|
|||
}
|
||||
|
||||
int grey = 128 + int((255 - 128) * movement_frac);
|
||||
SDL_Color c = color_t(grey, grey, grey).to_sdl();
|
||||
color_t c = color_t(grey, grey, grey);
|
||||
str << span_color(c) << u->movement_left() << '/' << u->total_movement() << naps;
|
||||
return text_report(str.str(), tooltip.str());
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ static int attack_info(reports::context & rc, const attack_type &at, config &res
|
|||
at.modified_attacks(false, min_attacks, max_attacks);
|
||||
unsigned num_attacks = swarm_blows(min_attacks, max_attacks, cur_hp, max_hp);
|
||||
|
||||
SDL_Color dmg_color = font::weapon_color;
|
||||
color_t dmg_color = font::weapon_color;
|
||||
if ( damage > specials_damage )
|
||||
dmg_color = font::good_dmg_color;
|
||||
else if ( damage < specials_damage )
|
||||
|
@ -810,7 +810,7 @@ static int attack_info(reports::context & rc, const attack_type &at, config &res
|
|||
// Aliases for readability:
|
||||
const t_string &name = specials[i].first;
|
||||
const t_string &description = specials[i].second;
|
||||
const SDL_Color &details_color = active[i] ? font::weapon_details_color :
|
||||
const color_t &details_color = active[i] ? font::weapon_details_color :
|
||||
font::inactive_details_color;
|
||||
|
||||
str << span_color(details_color) << " " << " " << name << naps << '\n';
|
||||
|
@ -888,7 +888,7 @@ static config unit_weapons(reports::context & rc, const unit *attacker, const ma
|
|||
int chance_to_hit = 0;
|
||||
t_string weapon_name = _("None");
|
||||
|
||||
SDL_Color dmg_color = font::weapon_color;
|
||||
color_t dmg_color = font::weapon_color;
|
||||
if (context_unit_stats.weapon) {
|
||||
base_damage = attack_info(rc, *context_unit_stats.weapon, res, *u, unit_loc);
|
||||
total_damage = context_unit_stats.damage;
|
||||
|
@ -906,7 +906,7 @@ static config unit_weapons(reports::context & rc, const unit *attacker, const ma
|
|||
<< _("Damage: ") << "<b>" << "0" << "</b>\n";
|
||||
}
|
||||
|
||||
SDL_Color chance_color = color_t::from_argb_bytes(game_config::red_to_green(chance_to_hit)).to_sdl();
|
||||
color_t chance_color = color_t::from_argb_bytes(game_config::red_to_green(chance_to_hit));
|
||||
|
||||
// Total damage.
|
||||
str << " " << span_color(dmg_color) << total_damage << naps << span_color(font::weapon_color)
|
||||
|
@ -965,7 +965,7 @@ static config unit_weapons(reports::context & rc, const unit *attacker, const ma
|
|||
char hp_buf[10];
|
||||
format_hp(hp_buf, hp);
|
||||
|
||||
SDL_Color prob_color = color_t::from_argb_bytes(game_config::blue_to_white(prob * 100.0, true)).to_sdl();
|
||||
color_t prob_color = color_t::from_argb_bytes(game_config::blue_to_white(prob * 100.0, true));
|
||||
|
||||
str << span_color(font::weapon_details_color) << " " << " "
|
||||
<< span_color(u->hp_color(hp)) << hp_buf << naps
|
||||
|
|
|
@ -123,7 +123,7 @@
|
|||
#include <algorithm>
|
||||
#include <vector> // for vector, etc
|
||||
#include <SDL_timer.h> // for SDL_GetTicks
|
||||
#include <SDL_video.h> // for SDL_Color, SDL_Surface
|
||||
#include <SDL_video.h> // for SDL_Surface
|
||||
#include "lua/lauxlib.h" // for luaL_checkinteger, etc
|
||||
#include "lua/lua.h" // for lua_setfield, etc
|
||||
|
||||
|
@ -1879,13 +1879,13 @@ int game_lua_kernel::intf_print(lua_State *L) {
|
|||
int size = cfg["size"].to_int(font::SIZE_SMALL);
|
||||
int lifetime = cfg["duration"].to_int(50);
|
||||
|
||||
SDL_Color color = font::LABEL_COLOR;
|
||||
color_t color = font::LABEL_COLOR;
|
||||
|
||||
if(!cfg["color"].empty()) {
|
||||
color = color_t::from_rgb_string(cfg["color"]).to_sdl();
|
||||
color = color_t::from_rgb_string(cfg["color"]);
|
||||
} else if(cfg.has_attribute("red") || cfg.has_attribute("green") || cfg.has_attribute("blue")) {
|
||||
lg::wml_error() << "[print] red=, green=, blue= is deprecated. Use color= instead." << std::endl;
|
||||
color = color_t(cfg["red"], cfg["green"], cfg["blue"]).to_sdl();
|
||||
color = color_t(cfg["red"], cfg["green"], cfg["blue"]);
|
||||
}
|
||||
|
||||
const SDL_Rect& rect = game_display_->map_outside_area();
|
||||
|
@ -2143,11 +2143,11 @@ int game_lua_kernel::intf_find_vacant_tile(lua_State *L)
|
|||
int game_lua_kernel::intf_float_label(lua_State *L)
|
||||
{
|
||||
map_location loc = luaW_checklocation(L, 1);
|
||||
SDL_Color color = font::LABEL_COLOR;
|
||||
color_t color = font::LABEL_COLOR;
|
||||
|
||||
t_string text = luaW_checktstring(L, 2);
|
||||
if (!lua_isnoneornil(L, 3)) {
|
||||
color = color_t::from_rgb_string(luaL_checkstring(L, 3)).to_sdl();
|
||||
color = color_t::from_rgb_string(luaL_checkstring(L, 3));
|
||||
}
|
||||
|
||||
if (game_display_) {
|
||||
|
|
|
@ -167,9 +167,9 @@ struct color_t
|
|||
std::string to_rgb_string() const;
|
||||
|
||||
/**
|
||||
* Returns the stored color as an SDL_Color object.
|
||||
* Returns the stored color as an color_t object.
|
||||
*
|
||||
* @return The new SDL_Color object.
|
||||
* @return The new color_t object.
|
||||
*/
|
||||
SDL_Color to_sdl() const
|
||||
{
|
||||
|
|
|
@ -1147,7 +1147,7 @@ void adjust_surface_alpha(surface& surf, fixed_t amount)
|
|||
|
||||
class pixel_callable : public game_logic::formula_callable {
|
||||
public:
|
||||
pixel_callable(SDL_Point p, SDL_Color clr, Uint32 w, Uint32 h) : p(p), clr(clr), w(w), h(h) {}
|
||||
pixel_callable(SDL_Point p, color_t clr, Uint32 w, Uint32 h) : p(p), clr(clr), w(w), h(h) {}
|
||||
void get_inputs(std::vector<game_logic::formula_input>* inputs) const override
|
||||
{
|
||||
inputs->push_back(game_logic::formula_input("x", game_logic::FORMULA_READ_ONLY));
|
||||
|
@ -1182,7 +1182,7 @@ public:
|
|||
}
|
||||
private:
|
||||
SDL_Point p;
|
||||
SDL_Color clr;
|
||||
color_t clr;
|
||||
Uint32 w, h;
|
||||
};
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ surface adjust_surface_alpha_formula(const surface &surf, const std::string& for
|
|||
Uint32*const beg = cur;
|
||||
|
||||
while(cur != end) {
|
||||
SDL_Color pixel;
|
||||
color_t pixel;
|
||||
pixel.a = (*cur) >> 24;
|
||||
pixel.r = (*cur) >> 16;
|
||||
pixel.g = (*cur) >> 8;
|
||||
|
@ -2458,15 +2458,7 @@ SDL_Rect get_non_transparent_portion(const surface &surf)
|
|||
return res;
|
||||
}
|
||||
|
||||
bool operator==(const SDL_Color& a, const SDL_Color& b) {
|
||||
return a.r == b.r && a.g == b.g && a.b == b.b;
|
||||
}
|
||||
|
||||
bool operator!=(const SDL_Color& a, const SDL_Color& b) {
|
||||
return !operator==(a,b);
|
||||
}
|
||||
|
||||
SDL_Color inverse(const SDL_Color& color) {
|
||||
color_t inverse(const color_t& color) {
|
||||
return {
|
||||
static_cast<Uint8>(255 - color.r),
|
||||
static_cast<Uint8>(255 - color.g),
|
||||
|
@ -2526,7 +2518,7 @@ void surface_restorer::cancel()
|
|||
surface_.assign(nullptr);
|
||||
}
|
||||
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect, const SDL_Color& color, surface target)
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect, const color_t& color, surface target)
|
||||
{
|
||||
clip_rect_setter clip_setter(target, &rect);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#ifndef SDL_UTILS_INCLUDED
|
||||
#define SDL_UTILS_INCLUDED
|
||||
|
||||
#include "sdl/color.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
|
@ -408,10 +409,7 @@ void blit_surface(const surface& src,
|
|||
|
||||
SDL_Rect get_non_transparent_portion(const surface &surf);
|
||||
|
||||
bool operator==(const SDL_Color& a, const SDL_Color& b);
|
||||
bool operator!=(const SDL_Color& a, const SDL_Color& b);
|
||||
|
||||
SDL_Color inverse(const SDL_Color& color);
|
||||
color_t inverse(const color_t& color);
|
||||
|
||||
/**
|
||||
* Helper class for pinning SDL surfaces into memory.
|
||||
|
@ -496,7 +494,7 @@ private:
|
|||
// blit the image on the center of the rectangle
|
||||
// and a add a colored background
|
||||
void draw_centered_on_background(surface surf, const SDL_Rect& rect,
|
||||
const SDL_Color& color, surface target);
|
||||
const color_t& color, surface target);
|
||||
|
||||
std::ostream& operator<<(std::ostream& s, const SDL_Rect& rect);
|
||||
|
||||
|
|
|
@ -823,16 +823,16 @@ const color_range team::get_side_color_range(int side)
|
|||
return(color_range(0x00FF0000,0x00FFFFFF,0x00000000,0x00FF0000));
|
||||
}
|
||||
|
||||
SDL_Color team::get_side_color(int side)
|
||||
color_t team::get_side_color(int side)
|
||||
{
|
||||
return color_t::from_argb_bytes(get_side_color_range(side).mid()).to_sdl();
|
||||
return color_t::from_argb_bytes(get_side_color_range(side).mid());
|
||||
}
|
||||
|
||||
SDL_Color team::get_minimap_color(int side)
|
||||
color_t team::get_minimap_color(int side)
|
||||
{
|
||||
// Note: use mid() instead of rep() unless
|
||||
// high contrast is needed over a map or minimap!
|
||||
return color_t::from_argb_bytes(get_side_color_range(side).rep()).to_sdl();
|
||||
return color_t::from_argb_bytes(get_side_color_range(side).rep());
|
||||
}
|
||||
|
||||
std::string team::get_side_color_index(int side)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
class game_data;
|
||||
class gamemap;
|
||||
struct SDL_Color;
|
||||
struct color_t;
|
||||
|
||||
|
||||
namespace wb {
|
||||
|
@ -364,8 +364,8 @@ public:
|
|||
static uint32_t get_side_rgb(int side) { return(get_side_color_range(side).mid()); }
|
||||
static uint32_t get_side_rgb_max(int side) { return(get_side_color_range(side).max()); }
|
||||
static uint32_t get_side_rgb_min(int side) { return(get_side_color_range(side).min()); }
|
||||
static SDL_Color get_side_color(int side);
|
||||
static SDL_Color get_minimap_color(int side);
|
||||
static color_t get_side_color(int side);
|
||||
static color_t get_minimap_color(int side);
|
||||
static std::string get_side_color_index(int side);
|
||||
static std::string get_side_highlight_pango(int side);
|
||||
|
||||
|
|
|
@ -665,7 +665,7 @@ struct dialog_tester<editor_edit_label>
|
|||
std::string label = "Label text to modify";
|
||||
std::string category = "test";
|
||||
bool immutable = false, fog = false, shroud = false;
|
||||
SDL_Color color;
|
||||
color_t color;
|
||||
editor_edit_label* create()
|
||||
{
|
||||
return new editor_edit_label(label, immutable, fog, shroud, color, category);
|
||||
|
|
|
@ -71,7 +71,7 @@ static void show_tooltip(const tooltip& tip)
|
|||
|
||||
clear_tooltip();
|
||||
|
||||
const SDL_Color bgcolor = {0,0,0,160};
|
||||
const color_t bgcolor = {0,0,0,160};
|
||||
SDL_Rect area = screen_area();
|
||||
|
||||
unsigned int border = 10;
|
||||
|
|
|
@ -72,8 +72,8 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
|
||||
bool emit_zoc = u.emits_zoc();
|
||||
|
||||
SDL_Color hp_color=u.hp_color();
|
||||
SDL_Color xp_color=u.xp_color();
|
||||
color_t hp_color=u.hp_color();
|
||||
color_t xp_color=u.xp_color();
|
||||
|
||||
std::string ellipse=u.image_ellipse();
|
||||
|
||||
|
@ -336,7 +336,7 @@ void unit_drawer::redraw_unit (const unit & u) const
|
|||
|
||||
void unit_drawer::draw_bar(const std::string& image, int xpos, int ypos,
|
||||
const map_location& loc, size_t height, double filled,
|
||||
const SDL_Color& col, fixed_t alpha) const
|
||||
const color_t& col, fixed_t alpha) const
|
||||
{
|
||||
|
||||
filled = std::min<double>(std::max<double>(filled,0.0),1.0);
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace halo { class manager; }
|
|||
class team;
|
||||
class unit;
|
||||
|
||||
struct SDL_Color;
|
||||
struct color_t;
|
||||
struct SDL_Rect;
|
||||
class surface;
|
||||
|
||||
|
@ -75,7 +75,7 @@ private:
|
|||
/** draw a health/xp bar of a unit */
|
||||
void draw_bar(const std::string& image, int xpos, int ypos,
|
||||
const map_location& loc, size_t height, double filled,
|
||||
const SDL_Color& col, fixed_t alpha) const;
|
||||
const color_t& col, fixed_t alpha) const;
|
||||
|
||||
/**
|
||||
* Finds the start and end rows on the energy bar image.
|
||||
|
|
|
@ -681,7 +681,7 @@ void unit_frame::redraw(const int frame_time,bool on_start_time,bool in_scope_of
|
|||
}
|
||||
if(!current_data.text.empty() ) {
|
||||
game_display::get_singleton()->float_label(src, current_data.text,
|
||||
color_t::from_argb_bytes(current_data.text_color).to_sdl());
|
||||
color_t::from_argb_bytes(current_data.text_color));
|
||||
}
|
||||
}
|
||||
image::locator image_loc;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "random_new.hpp" // for generator, rng
|
||||
#include "resources.hpp" // for units, gameboard, teams, etc
|
||||
#include "scripting/game_lua_kernel.hpp" // for game_lua_kernel
|
||||
#include "sdl/color.hpp"
|
||||
#include "synced_context.hpp"
|
||||
#include "side_filter.hpp" // for side_filter
|
||||
#include "team.hpp" // for team, get_teams, etc
|
||||
|
@ -67,8 +68,6 @@
|
|||
#include <iterator> // for back_insert_iterator, etc
|
||||
#include <new> // for operator new
|
||||
#include <ostream> // for operator<<, basic_ostream, etc
|
||||
#include <SDL_video.h> // for SDL_Color
|
||||
|
||||
|
||||
namespace t_translation { struct terrain_code; }
|
||||
|
||||
|
@ -1037,10 +1036,10 @@ const std::string& unit::team_color() const {
|
|||
return flag_rgb_.empty() ? game_config::unit_rgb : flag_rgb_;
|
||||
}
|
||||
|
||||
static SDL_Color hp_color_(int hitpoints, int max_hitpoints)
|
||||
static color_t hp_color_(int hitpoints, int max_hitpoints)
|
||||
{
|
||||
double unit_energy = 0.0;
|
||||
SDL_Color energy_color = {0,0,0,0};
|
||||
color_t energy_color = {0,0,0,0};
|
||||
|
||||
if(max_hitpoints > 0) {
|
||||
unit_energy = double(hitpoints)/double(max_hitpoints);
|
||||
|
@ -1074,31 +1073,31 @@ static SDL_Color hp_color_(int hitpoints, int max_hitpoints)
|
|||
return energy_color;
|
||||
}
|
||||
|
||||
SDL_Color unit::hp_color() const
|
||||
color_t unit::hp_color() const
|
||||
{
|
||||
return hp_color_(hitpoints(), max_hitpoints());
|
||||
}
|
||||
|
||||
SDL_Color unit::hp_color(int new_hitpoints) const
|
||||
color_t unit::hp_color(int new_hitpoints) const
|
||||
{
|
||||
return hp_color_(new_hitpoints, hitpoints());
|
||||
}
|
||||
|
||||
SDL_Color unit::xp_color() const
|
||||
color_t unit::xp_color() const
|
||||
{
|
||||
const SDL_Color near_advance_color = {255,255,255,0};
|
||||
const SDL_Color mid_advance_color = {150,255,255,0};
|
||||
const SDL_Color far_advance_color = {0,205,205,0};
|
||||
const SDL_Color normal_color = {0,160,225,0};
|
||||
const SDL_Color near_amla_color = {225,0,255,0};
|
||||
const SDL_Color mid_amla_color = {169,30,255,0};
|
||||
const SDL_Color far_amla_color = {139,0,237,0};
|
||||
const SDL_Color amla_color = {170,0,255,0};
|
||||
const color_t near_advance_color = {255,255,255,0};
|
||||
const color_t mid_advance_color = {150,255,255,0};
|
||||
const color_t far_advance_color = {0,205,205,0};
|
||||
const color_t normal_color = {0,160,225,0};
|
||||
const color_t near_amla_color = {225,0,255,0};
|
||||
const color_t mid_amla_color = {169,30,255,0};
|
||||
const color_t far_amla_color = {139,0,237,0};
|
||||
const color_t amla_color = {170,0,255,0};
|
||||
const bool near_advance = max_experience() - experience() <= game_config::kill_experience;
|
||||
const bool mid_advance = max_experience() - experience() <= game_config::kill_experience*2;
|
||||
const bool far_advance = max_experience() - experience() <= game_config::kill_experience*3;
|
||||
|
||||
SDL_Color color=normal_color;
|
||||
color_t color=normal_color;
|
||||
if(advances_to().size()){
|
||||
if(near_advance){
|
||||
color=near_advance_color;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
class display;
|
||||
class display_context;
|
||||
class gamemap;
|
||||
struct SDL_Color;
|
||||
struct color_t;
|
||||
class team;
|
||||
class unit_animation_component;
|
||||
class unit_formula_manager;
|
||||
|
@ -172,14 +172,14 @@ public:
|
|||
* how wounded the unit is.
|
||||
* The maximum_hitpoints are considered as base.
|
||||
*/
|
||||
SDL_Color hp_color() const;
|
||||
color_t hp_color() const;
|
||||
/** Colors for the unit's hitpoints.
|
||||
* @param hitpoints the amount of hitpoints the color represents.
|
||||
* @returns the color considering the current hitpoints as base.
|
||||
*/
|
||||
SDL_Color hp_color(int hitpoints) const;
|
||||
color_t hp_color(int hitpoints) const;
|
||||
/** Colors for the unit's XP. */
|
||||
SDL_Color xp_color() const;
|
||||
color_t xp_color() const;
|
||||
|
||||
double hp_bar_scaling() const { return hp_bar_scaling_; }
|
||||
double xp_bar_scaling() const { return xp_bar_scaling_; }
|
||||
|
|
|
@ -511,7 +511,7 @@ int CVideo::set_help_string(const std::string& str)
|
|||
{
|
||||
font::remove_floating_label(help_string_);
|
||||
|
||||
const SDL_Color color = { 0, 0, 0, 0xbb };
|
||||
const color_t color = { 0, 0, 0, 0xbb };
|
||||
|
||||
int size = font::SIZE_LARGE;
|
||||
|
||||
|
|
|
@ -459,7 +459,7 @@ static void draw_numbers(map_location const& hex, side_actions::numbers_t number
|
|||
else if (secondary_numbers.find(i)!=secondary_numbers.end()) font_size = 17;
|
||||
else font_size = 15;
|
||||
|
||||
SDL_Color color = team::get_side_color(static_cast<int>(team_numbers[i]+1));
|
||||
color_t color = team::get_side_color(static_cast<int>(team_numbers[i]+1));
|
||||
const double x_in_hex = x_origin + x_offset;
|
||||
const double y_in_hex = y_origin + y_offset;
|
||||
resources::screen->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
|
||||
|
|
|
@ -190,7 +190,7 @@ void recall::draw_hex(map_location const& hex)
|
|||
number_text << font::unicode_minus << cost;
|
||||
}
|
||||
size_t font_size = 16;
|
||||
SDL_Color color; color.r = 255; color.g = 0; color.b = 0; //red
|
||||
color_t color; color.r = 255; color.g = 0; color.b = 0; //red
|
||||
resources::screen->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
|
||||
number_text.str(), font_size, color, x_offset, y_offset);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ void recruit::draw_hex(map_location const& hex)
|
|||
std::stringstream number_text;
|
||||
number_text << font::unicode_minus << cost_;
|
||||
size_t font_size = 16;
|
||||
SDL_Color color; color.r = 255; color.g = 0; color.b = 0; //red
|
||||
color_t color; color.r = 255; color.g = 0; color.b = 0; //red
|
||||
resources::screen->draw_text_in_hex(hex, display::LAYER_ACTIONS_NUMBERING,
|
||||
number_text.str(), font_size, color, x_offset, y_offset);
|
||||
}
|
||||
|
|
|
@ -342,7 +342,7 @@ void button::draw_contents()
|
|||
textx = loc.x + image_w + checkbox_horizontal_padding / 2;
|
||||
}
|
||||
|
||||
SDL_Color button_color = font::BUTTON_COLOR;
|
||||
color_t button_color = font::BUTTON_COLOR;
|
||||
|
||||
if (!enabled()) {
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace gui {
|
||||
|
||||
label::label(CVideo& video, const std::string& text, int size, const SDL_Color& color, const bool auto_join) : widget(video, auto_join), text_(text), size_(size), color_(color)
|
||||
label::label(CVideo& video, const std::string& text, int size, const color_t& color, const bool auto_join) : widget(video, auto_join), text_(text), size_(size), color_(color)
|
||||
{
|
||||
update_label_size();
|
||||
}
|
||||
|
@ -44,14 +44,14 @@ const std::string& label::get_text() const
|
|||
return text_;
|
||||
}
|
||||
|
||||
const SDL_Color& label::set_color(const SDL_Color& color)
|
||||
const color_t& label::set_color(const color_t& color)
|
||||
{
|
||||
color_ = color;
|
||||
set_dirty();
|
||||
return get_color();
|
||||
}
|
||||
|
||||
const SDL_Color& label::get_color() const
|
||||
const color_t& label::get_color() const
|
||||
{
|
||||
return (enabled()) ? color_ : font::DISABLED_COLOR;
|
||||
}
|
||||
|
|
|
@ -26,19 +26,19 @@ class label : public widget
|
|||
{
|
||||
public:
|
||||
label(CVideo& video, const std::string& text, int size=font::SIZE_NORMAL,
|
||||
const SDL_Color& color=font::NORMAL_COLOR, const bool auto_join=true);
|
||||
const color_t& color=font::NORMAL_COLOR, const bool auto_join=true);
|
||||
const std::string& set_text(const std::string& text);
|
||||
const std::string& get_text() const;
|
||||
|
||||
const SDL_Color& set_color(const SDL_Color& color);
|
||||
const SDL_Color& get_color() const;
|
||||
const color_t& set_color(const color_t& color);
|
||||
const color_t& get_color() const;
|
||||
|
||||
virtual void draw_contents();
|
||||
private:
|
||||
void update_label_size();
|
||||
std::string text_;
|
||||
int size_;
|
||||
SDL_Color color_;
|
||||
color_t color_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ void slider::draw_contents()
|
|||
|
||||
assert(image != nullptr);
|
||||
|
||||
SDL_Color line_color = line_color_;
|
||||
color_t line_color = line_color_;
|
||||
if (!enabled()) {
|
||||
image.assign(disabledImage_);
|
||||
line_color = font::DISABLED_COLOR;
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
void set_slider_position(int x);
|
||||
SDL_Rect slider_area() const;
|
||||
surface image_, pressedImage_, activeImage_, disabledImage_;
|
||||
SDL_Color line_color_;
|
||||
color_t line_color_;
|
||||
|
||||
int min_;
|
||||
int max_;
|
||||
|
|
|
@ -74,7 +74,7 @@ const std::string textbox::text() const
|
|||
}
|
||||
|
||||
// set_text does not respect max_size_
|
||||
void textbox::set_text(const std::string& text, const SDL_Color& color)
|
||||
void textbox::set_text(const std::string& text, const color_t& color)
|
||||
{
|
||||
text_ = unicode_cast<ucs4::string>(text);
|
||||
cursor_ = text_.size();
|
||||
|
@ -86,7 +86,7 @@ void textbox::set_text(const std::string& text, const SDL_Color& color)
|
|||
handle_text_changed(text_);
|
||||
}
|
||||
|
||||
void textbox::append_text(const std::string& text, bool auto_scroll, const SDL_Color& color)
|
||||
void textbox::append_text(const std::string& text, bool auto_scroll, const color_t& color)
|
||||
{
|
||||
if(text_image_.get() == nullptr) {
|
||||
set_text(text, color);
|
||||
|
@ -291,7 +291,7 @@ void textbox::scroll(unsigned int pos)
|
|||
set_dirty(true);
|
||||
}
|
||||
|
||||
surface textbox::add_text_line(const ucs4::string& text, const SDL_Color& color)
|
||||
surface textbox::add_text_line(const ucs4::string& text, const color_t& color)
|
||||
{
|
||||
line_height_ = font::get_max_height(font_size_);
|
||||
|
||||
|
@ -361,7 +361,7 @@ surface textbox::add_text_line(const ucs4::string& text, const SDL_Color& color)
|
|||
}
|
||||
|
||||
|
||||
void textbox::update_text_cache(bool changed, const SDL_Color& color)
|
||||
void textbox::update_text_cache(bool changed, const color_t& color)
|
||||
{
|
||||
if(changed) {
|
||||
char_x_.clear();
|
||||
|
|
|
@ -30,8 +30,8 @@ public:
|
|||
virtual ~textbox();
|
||||
|
||||
const std::string text() const;
|
||||
void set_text(const std::string& text, const SDL_Color& color =font::NORMAL_COLOR);
|
||||
void append_text(const std::string& text,bool auto_scroll = false, const SDL_Color& color =font::NORMAL_COLOR);
|
||||
void set_text(const std::string& text, const color_t& color =font::NORMAL_COLOR);
|
||||
void append_text(const std::string& text,bool auto_scroll = false, const color_t& color =font::NORMAL_COLOR);
|
||||
void clear();
|
||||
|
||||
void set_selection(const int selstart, const int selend);
|
||||
|
@ -106,8 +106,8 @@ private:
|
|||
void pass_event_to_target(const SDL_Event& event);
|
||||
|
||||
void draw_cursor(int pos, CVideo &video) const;
|
||||
void update_text_cache(bool reset = false, const SDL_Color& color =font::NORMAL_COLOR);
|
||||
surface add_text_line(const ucs4::string& text, const SDL_Color& color =font::NORMAL_COLOR);
|
||||
void update_text_cache(bool reset = false, const color_t& color =font::NORMAL_COLOR);
|
||||
surface add_text_line(const ucs4::string& text, const color_t& color =font::NORMAL_COLOR);
|
||||
bool is_selection();
|
||||
void erase_selection();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue