From 3154ab419f0c38b6e9e40607a5a7614a20f1223d Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Wed, 21 Jun 2017 16:46:44 +1100 Subject: [PATCH] Restored alpha handling of unit frames Still need to figure out the blending effects or submerge alpha. --- src/units/frame.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/units/frame.cpp b/src/units/frame.cpp index b961fc4de933..1d82e797ccc7 100644 --- a/src/units/frame.cpp +++ b/src/units/frame.cpp @@ -17,6 +17,7 @@ #include "color.hpp" #include "game_display.hpp" #include "log.hpp" +#include "sdl/render_utils.hpp" #include "sound.hpp" static lg::log_domain log_engine("engine"); @@ -537,7 +538,7 @@ void unit_frame::redraw(const int frame_time, bool on_start_time, bool in_scope_ if(!current_data.auto_vflip) { facing_north = true; } const texture::info info = image.get_info(); - + int my_x = x + current_data.x - info.w / 2; int my_y = y + current_data.y - info.h / 2; @@ -557,9 +558,15 @@ void unit_frame::redraw(const int frame_time, bool on_start_time, bool in_scope_ // Begin unit drawing routine. // -#if 0 fixed_t alpha = ftofxp(current_data.highlight_ratio); + // FIXME: this has a problem where multiple units of the same type (so, same texture) + // all get this applied to them. Not sure how to fix... + if(alpha < ftofxp(1.0)) { + set_texture_alpha(image, alpha); + } + +#if 0 surface surf(image); color_t blend_to = current_data.blend_with ? *current_data.blend_with : color_t(); @@ -567,7 +574,7 @@ void unit_frame::redraw(const int frame_time, bool on_start_time, bool in_scope_ if(current_data.blend_ratio != 0) { surf = blend_surface(surf, current_data.blend_ratio, blend_to); } - + if(alpha > ftofxp(1.0)) { surf = brighten_image(surf, alpha); //} else if(alpha != 1.0 && blendto != 0) { @@ -587,9 +594,9 @@ void unit_frame::redraw(const int frame_time, bool on_start_time, bool in_scope_ // Divide the surface into 2 parts const int submerge_height = std::max(0, surf->h*(1.0-current_data.submerge)); const int depth = surf->h - submerge_height; - + SDL_Rect srcrect {0, 0, surf->w, submerge_height}; - + //drawing_buffer_add(drawing_layer, loc, x, y, surf, srcrect); if(submerge_height != surf->h) {