Merge pull request #503 from Wedge009/sdl2_minor_changes
SDL2 Minor Changes
This commit is contained in:
commit
1181a401ed
16 changed files with 40 additions and 40 deletions
|
@ -435,9 +435,9 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
|
|||
SDL_SetAlpha(surf, 0, SDL_ALPHA_OPAQUE);
|
||||
|
||||
SDL_Rect clip_rect = sdl::create_rect(0, 0, width, height);
|
||||
Uint32 grey_color = SDL_MapRGBA(surf->format, 0xb7, 0xc1, 0xc1, 255);
|
||||
Uint32 grey_color = SDL_MapRGBA(surf->format, 0xb7, 0xc1, 0xc1, SDL_ALPHA_OPAQUE);
|
||||
|
||||
Uint32 background_color = SDL_MapRGBA(surf->format, 25, 25, 25, 255);
|
||||
Uint32 background_color = SDL_MapRGBA(surf->format, 25, 25, 25, SDL_ALPHA_OPAQUE);
|
||||
sdl::fill_rect(surf, &clip_rect, background_color);
|
||||
|
||||
// Draw the surrounding borders and separators.
|
||||
|
@ -471,7 +471,7 @@ void battle_prediction_pane::get_hp_distrib_surface(const std::vector<std::pair<
|
|||
|
||||
// Death line is red.
|
||||
if(hp == 0) {
|
||||
SDL_Color color = {0xe5, 0, 0, 255};
|
||||
SDL_Color color = {0xe5, 0, 0, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
}
|
||||
|
||||
|
@ -479,17 +479,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, 255};
|
||||
SDL_Color color = {0x9a, 0x9a, 0x9a, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
} else {
|
||||
SDL_Color color = {0xf4, 0xc9, 0, 255};
|
||||
SDL_Color color = {0xf4, 0xc9, 0, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
}
|
||||
}
|
||||
|
||||
// Current hitpoints value and above is green.
|
||||
else {
|
||||
SDL_Color color = {0x08, 0xca, 0, 255};
|
||||
SDL_Color color = {0x08, 0xca, 0, SDL_ALPHA_OPAQUE};
|
||||
row_color = color;
|
||||
}
|
||||
|
||||
|
|
|
@ -1403,7 +1403,7 @@ void display::flip()
|
|||
if (sunset_delay && ++sunset_timer > sunset_delay) {
|
||||
sunset_timer = 0;
|
||||
SDL_Rect r = map_outside_area(); // Use frameBuffer to also test the UI
|
||||
const Uint32 color = SDL_MapRGBA(video().getSurface()->format,0,0,0,255);
|
||||
const Uint32 color = SDL_MapRGBA(video().getSurface()->format,0,0,0,SDL_ALPHA_OPAQUE);
|
||||
// Adjust the alpha if you want to balance cpu-cost / smooth sunset
|
||||
sdl::fill_rect_alpha(r, color, 1, frameBuffer);
|
||||
update_rect(r);
|
||||
|
@ -2104,7 +2104,7 @@ void display::draw_minimap()
|
|||
const surface& screen(screen_.getSurface());
|
||||
clip_rect_setter clip_setter(screen, &area);
|
||||
|
||||
SDL_Color back_color = {31,31,23,255};
|
||||
SDL_Color 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
|
||||
|
|
|
@ -38,7 +38,7 @@ using boost::uint32_t;
|
|||
namespace {
|
||||
const int chat_message_border = 5;
|
||||
const int chat_message_x = 10;
|
||||
const SDL_Color chat_message_color = {255,255,255,255};
|
||||
const SDL_Color chat_message_color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
const SDL_Color chat_message_bg = {0,0,0,140};
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ 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,255};
|
||||
SDL_Color speaker_color = {255,255,255,SDL_ALPHA_OPAQUE};
|
||||
if(side >= 1) {
|
||||
speaker_color = int_to_color(team::get_side_color_range(side).mid());
|
||||
}
|
||||
|
|
|
@ -671,7 +671,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config,
|
|||
, 0
|
||||
, 0
|
||||
, 0
|
||||
, 255);
|
||||
, SDL_ALPHA_OPAQUE);
|
||||
|
||||
sdl::fill_rect(disp.video().getSurface(), NULL, color);
|
||||
|
||||
|
|
|
@ -553,7 +553,7 @@ void create::draw_level_image()
|
|||
engine_.current_level().create_image_surface(image_rect_));
|
||||
|
||||
if (!image.null()) {
|
||||
SDL_Color back_color = {0,0,0,255};
|
||||
SDL_Color back_color = {0,0,0,SDL_ALPHA_OPAQUE};
|
||||
draw_centered_on_background(image, image_rect_, back_color,
|
||||
video().getSurface());
|
||||
} else {
|
||||
|
|
|
@ -798,7 +798,7 @@ void twindow::draw()
|
|||
SDL_Rect r = sdl::create_rect(
|
||||
0, 0, frame_buffer->w, frame_buffer->h);
|
||||
const Uint32 color
|
||||
= SDL_MapRGBA(frame_buffer->format, 0, 0, 0, 255);
|
||||
= SDL_MapRGBA(frame_buffer->format, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
|
||||
sdl::fill_rect_alpha(r, color, 1, frame_buffer);
|
||||
update_rect(r);
|
||||
|
|
|
@ -1179,7 +1179,7 @@ REGISTER_MOD_PARSER(DARKEN, )
|
|||
// Add a background color.
|
||||
REGISTER_MOD_PARSER(BG, args)
|
||||
{
|
||||
int c[4] = { 0, 0, 0, 255 };
|
||||
int c[4] = { 0, 0, 0, SDL_ALPHA_OPAQUE };
|
||||
std::vector<std::string> factors = utils::split(args, ',');
|
||||
|
||||
for (int i = 0; i < std::min<int>(factors.size(), 4); ++i) {
|
||||
|
|
|
@ -41,7 +41,7 @@ static bool attached(
|
|||
const std::vector<SDL_Joystick*>& joysticks
|
||||
, const size_t index)
|
||||
{
|
||||
return SDL_JoystickGetAttached(joysticks[index]);
|
||||
return SDL_JoystickGetAttached(joysticks[index]) == SDL_TRUE;
|
||||
}
|
||||
|
||||
static const char* name(
|
||||
|
|
|
@ -50,14 +50,14 @@ const std::string weapon = "<245,230,193>",
|
|||
race = "<166,146,117>";
|
||||
|
||||
const SDL_Color
|
||||
weapon_color = { 245, 230, 193, 255 },
|
||||
good_dmg_color = { 130, 240, 50, 255 },
|
||||
bad_dmg_color = { 250, 140, 80, 255 },
|
||||
weapon_details_color = { 166, 146, 117, 255 },
|
||||
inactive_details_color = { 146, 146, 146, 255 },
|
||||
inactive_ability_color = { 146, 146, 146, 255 },
|
||||
unit_type_color = { 245, 230, 193, 255 },
|
||||
race_color = { 166, 146, 117, 255 };
|
||||
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 },
|
||||
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 },
|
||||
unit_type_color = { 245, 230, 193, SDL_ALPHA_OPAQUE },
|
||||
race_color = { 166, 146, 117, SDL_ALPHA_OPAQUE };
|
||||
|
||||
const std::string weapon_numbers_sep = "–", weapon_details_sep = "–";
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ SDL_Rect draw_minimap(CVideo &video, const SDL_Rect &area, const gamemap &map, c
|
|||
SDL_Color 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 = create_color(0,0,0,255);
|
||||
col = create_color(0,0,0,SDL_ALPHA_OPAQUE);
|
||||
} else
|
||||
col = int_to_color(it->second.rep());
|
||||
|
||||
|
|
|
@ -158,7 +158,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,255};
|
||||
SDL_Color 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);
|
||||
|
|
|
@ -153,12 +153,12 @@ inline void fill_rect(surface& dst, SDL_Rect* dst_rect, const Uint32 color)
|
|||
void fill_rect(CVideo &video, const SDL_Rect &rect, SDL_Color color);
|
||||
|
||||
void fill_rect(CVideo &video, const SDL_Rect &rect, Uint8 r, Uint8 g,
|
||||
Uint8 b, Uint8 a = 255);
|
||||
Uint8 b, Uint8 a = SDL_ALPHA_OPAQUE);
|
||||
|
||||
void draw_rect(CVideo &video, const SDL_Rect &rect, SDL_Color color);
|
||||
|
||||
void draw_rect(CVideo &video, const SDL_Rect &rect, Uint8 r, Uint8 g,
|
||||
Uint8 b, Uint8 a = 255);
|
||||
Uint8 b, Uint8 a = SDL_ALPHA_OPAQUE);
|
||||
#endif
|
||||
} // namespace sdl
|
||||
|
||||
|
|
|
@ -66,11 +66,11 @@ SDL_Color int_to_color(const Uint32 rgb)
|
|||
result.g = (0x0000FF00 & rgb) >> 8;
|
||||
result.b = (0x000000FF & rgb);
|
||||
#ifdef SDL_GPU
|
||||
result.unused = 255;
|
||||
result.unused = SDL_ALPHA_OPAQUE;
|
||||
#elif SDL_VERSION_ATLEAST(2,0,0)
|
||||
result.a = 0;
|
||||
result.a = SDL_ALPHA_OPAQUE;
|
||||
#else
|
||||
result.unused = 0;
|
||||
result.unused = SDL_ALPHA_OPAQUE;
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -449,7 +449,7 @@ SDL_Color int_to_color(const Uint32 rgb);
|
|||
SDL_Color create_color(const unsigned char red
|
||||
, unsigned char green
|
||||
, unsigned char blue
|
||||
, unsigned char alpha = 255);
|
||||
, unsigned char alpha = SDL_ALPHA_OPAQUE);
|
||||
|
||||
/**
|
||||
* Helper class for pinning SDL surfaces into memory.
|
||||
|
|
|
@ -741,7 +741,7 @@ void part_ui::render_story_box()
|
|||
}
|
||||
|
||||
const SDL_Rect rect = sdl::create_rect(0, 0, video_.getx(), video_.gety());
|
||||
sdl::fill_rect(video_, rect, 0, 0, 0, 255);
|
||||
sdl::fill_rect(video_, rect, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
#else
|
||||
LOG_NG << "ENTER part_ui()::render_story_box()\n";
|
||||
|
||||
|
|
|
@ -899,9 +899,9 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_no_args)
|
|||
BOOST_CHECK_EQUAL(mod->get_color().g, 0);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().b, 0);
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, SDL_ALPHA_OPAQUE);
|
||||
#else
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, SDL_ALPHA_OPAQUE);
|
||||
#endif
|
||||
|
||||
delete mod;
|
||||
|
@ -925,9 +925,9 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_1_arg)
|
|||
BOOST_CHECK_EQUAL(mod->get_color().g, 0);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().b, 0);
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, SDL_ALPHA_OPAQUE);
|
||||
#else
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, SDL_ALPHA_OPAQUE);
|
||||
#endif
|
||||
|
||||
delete mod;
|
||||
|
@ -951,9 +951,9 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_2_args)
|
|||
BOOST_CHECK_EQUAL(mod->get_color().g, 2);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().b, 0);
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, SDL_ALPHA_OPAQUE);
|
||||
#else
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, SDL_ALPHA_OPAQUE);
|
||||
#endif
|
||||
|
||||
delete mod;
|
||||
|
@ -977,9 +977,9 @@ BOOST_AUTO_TEST_CASE(test_bg_modification_decoding_3_args)
|
|||
BOOST_CHECK_EQUAL(mod->get_color().g, 2);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().b, 3);
|
||||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().a, SDL_ALPHA_OPAQUE);
|
||||
#else
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, 255);
|
||||
BOOST_CHECK_EQUAL(mod->get_color().unused, SDL_ALPHA_OPAQUE);
|
||||
#endif
|
||||
|
||||
delete mod;
|
||||
|
|
Loading…
Add table
Reference in a new issue