[[Graphics fixes]]
- made it so labels on light coloured terrain are black. - made it so that ellipses fade when a unit dies - tried to fix bug where labels slowly move
This commit is contained in:
parent
fbbd7766b0
commit
6245f0c421
8 changed files with 45 additions and 39 deletions
|
@ -33,6 +33,7 @@ name=ice
|
|||
char=i
|
||||
unit_height_adjust=-2
|
||||
aliasof=S
|
||||
light=true
|
||||
[/terrain]
|
||||
|
||||
[terrain]
|
||||
|
|
|
@ -10,7 +10,7 @@ experience=52
|
|||
level=2
|
||||
alignment=chaotic
|
||||
advanceto=Troll Warrior
|
||||
cost=19
|
||||
cost=25
|
||||
unit_description="Trolls are strong and brutal humanoid monsters. Like Whelps of the same race, they have the amazing ability of regeneration, so that they can recover from wounds on their own, even during battle."
|
||||
get_hit_sound=ugg.wav
|
||||
usage=fighter
|
||||
|
|
|
@ -60,7 +60,7 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
|||
currentTeam_(0), activeTeam_(0), hideEnergy_(false),
|
||||
deadAmount_(0.0), advancingAmount_(0.0), updatesLocked_(0),
|
||||
turbo_(false), grid_(false), sidebarScaling_(1.0),
|
||||
theme_(theme_cfg,screen_area()), firstTurn_(true), map_labels_(*this)
|
||||
theme_(theme_cfg,screen_area()), firstTurn_(true), map_labels_(*this,map)
|
||||
{
|
||||
if(non_interactive())
|
||||
updatesLocked_++;
|
||||
|
@ -267,7 +267,7 @@ void display::scroll(double xmove, double ymove)
|
|||
|
||||
//only invalidate if we've actually moved
|
||||
if(orig_x != xpos_ || orig_y != ypos_) {
|
||||
map_labels_.scroll(orig_x - xpos_, orig_y - ypos_);
|
||||
map_labels_.scroll(int(util::round(orig_x - xpos_)), int(util::round(orig_y - ypos_)));
|
||||
invalidate_all();
|
||||
}
|
||||
}
|
||||
|
@ -1186,26 +1186,19 @@ void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
|
|||
const bool energy_uses_alpha = highlight_ratio < 1.0 && blend_with == 0;
|
||||
|
||||
if(loc != hiddenUnit_) {
|
||||
//the circle around the base of the unit
|
||||
if(preferences::show_side_colours() && !fogged(x,y) && it != units_.end()) {
|
||||
scoped_sdl_surface ellipse_front(NULL);
|
||||
scoped_sdl_surface ellipse_back(NULL);
|
||||
|
||||
if(preferences::show_side_colours()) {
|
||||
char buf[50];
|
||||
sprintf(buf,"misc/ellipse-%d-top.png",it->second.side());
|
||||
const scoped_sdl_surface surf(image::get_image(buf));
|
||||
|
||||
if(surf == NULL) {
|
||||
std::cerr << "could not open ellipse: '" << buf << "'\n";
|
||||
}
|
||||
|
||||
if(surf != NULL) {
|
||||
SDL_Surface* const dst = screen_.getSurface();
|
||||
SDL_Rect rect = {xpos,ypos - height_adjust,surf->w,surf->h};
|
||||
|
||||
SDL_BlitSurface(surf,NULL,dst,&rect);
|
||||
}
|
||||
ellipse_back.assign(image::get_image(buf));
|
||||
sprintf(buf,"misc/ellipse-%d-bottom.png",it->second.side());
|
||||
ellipse_front.assign(image::get_image(buf));
|
||||
}
|
||||
|
||||
draw_unit(xpos,ypos - height_adjust,unit_image,face_left,false,
|
||||
highlight_ratio,blend_with,submerge);
|
||||
highlight_ratio,blend_with,submerge,ellipse_back,ellipse_front);
|
||||
}
|
||||
|
||||
const SDL_Rect& energy_bar_loc = calculate_energy_bar();
|
||||
|
@ -1233,21 +1226,6 @@ void display::draw_unit_on_tile(int x, int y, SDL_Surface* unit_image_override,
|
|||
energy_bar_loc.w, energy_bar_loc.h - skip_energy_rows - lost_energy };
|
||||
SDL_FillRect(dst,&filled_energy_area,energy_colour);
|
||||
}
|
||||
|
||||
//the bottom half of the circle around the base of the unit
|
||||
if(loc != hiddenUnit_ && preferences::show_side_colours() && !fogged(x,y) && it != units_.end()) {
|
||||
|
||||
char buf[50];
|
||||
sprintf(buf,"misc/ellipse-%d-bottom.png",it->second.side());
|
||||
const scoped_sdl_surface surf(image::get_image(buf));
|
||||
|
||||
if(surf != NULL) {
|
||||
SDL_Surface* const dst = screen_.getSurface();
|
||||
SDL_Rect rect = {xpos,ypos - height_adjust,surf->w,surf->h};
|
||||
|
||||
SDL_BlitSurface(surf,NULL,dst,&rect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void display::draw_tile_adjacent(int x, int y, image::TYPE image_type, ADJACENT_TERRAIN_TYPE type)
|
||||
|
@ -2304,8 +2282,13 @@ void display::move_unit_between(const gamemap::location& a,
|
|||
|
||||
void display::draw_unit(int x, int y, SDL_Surface* image,
|
||||
bool reverse, bool upside_down,
|
||||
double alpha, Uint32 blendto, double submerged)
|
||||
double alpha, Uint32 blendto, double submerged,
|
||||
SDL_Surface* ellipse_back, SDL_Surface* ellipse_front)
|
||||
{
|
||||
if(ellipse_back != NULL) {
|
||||
draw_unit(x,y,ellipse_back,false,false,blendto == 0 ? alpha : 1.0,0,submerged);
|
||||
}
|
||||
|
||||
sdl_add_ref(image);
|
||||
scoped_sdl_surface surf(image);
|
||||
|
||||
|
@ -2345,6 +2328,10 @@ void display::draw_unit(int x, int y, SDL_Surface* image,
|
|||
|
||||
blit_surface(x,y,surf,&srcrect,&clip_rect);
|
||||
}
|
||||
|
||||
if(ellipse_front != NULL) {
|
||||
draw_unit(x,y,ellipse_front,false,false,blendto == 0 ? alpha : 1.0,0,submerged);
|
||||
}
|
||||
}
|
||||
|
||||
struct is_energy_colour {
|
||||
|
|
|
@ -312,7 +312,8 @@ private:
|
|||
// (presumably under water) and thus shouldn't be drawn
|
||||
void draw_unit(int x, int y, SDL_Surface* image,
|
||||
bool reverse, bool upside_down=false,
|
||||
double alpha=1.0, Uint32 blendto=0, double submerged=0.0);
|
||||
double alpha=1.0, Uint32 blendto=0, double submerged=0.0,
|
||||
SDL_Surface* ellipse_back=NULL, SDL_Surface* ellipse_front=NULL);
|
||||
|
||||
bool unit_attack_ranged(const gamemap::location& a,
|
||||
const gamemap::location& b,
|
||||
|
|
|
@ -377,6 +377,11 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
|
|||
break;
|
||||
}
|
||||
|
||||
case HOTKEY_EDIT_SET_TERRAIN:
|
||||
if(executor)
|
||||
executor->edit_set_terrain();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -34,6 +34,9 @@ enum HOTKEY_COMMAND { HOTKEY_CYCLE_UNITS, HOTKEY_END_UNIT_TURN, HOTKEY_LEADER,
|
|||
HOTKEY_SPEAK, HOTKEY_CREATE_UNIT, HOTKEY_PREFERENCES,
|
||||
HOTKEY_OBJECTIVES, HOTKEY_UNIT_LIST, HOTKEY_STATISTICS, HOTKEY_QUIT_GAME,
|
||||
HOTKEY_LABEL_TERRAIN, HOTKEY_SHOW_ENEMY_MOVES, HOTKEY_BEST_ENEMY_MOVES,
|
||||
|
||||
//editing specific commands
|
||||
HOTKEY_EDIT_SET_TERRAIN,
|
||||
HOTKEY_NULL };
|
||||
|
||||
struct hotkey_item {
|
||||
|
@ -101,6 +104,8 @@ public:
|
|||
virtual void label_terrain() = 0;
|
||||
virtual void show_enemy_moves(bool ignore_units) = 0;
|
||||
|
||||
virtual void edit_set_terrain() {}
|
||||
|
||||
virtual bool can_execute_command(HOTKEY_COMMAND command) const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
#include "font.hpp"
|
||||
#include "map_label.hpp"
|
||||
|
||||
map_labels::map_labels(const display& disp) : disp_(disp)
|
||||
map_labels::map_labels(const display& disp, const gamemap& map) : disp_(disp), map_(map)
|
||||
{}
|
||||
|
||||
map_labels::map_labels(const display& disp, const config& cfg) : disp_(disp)
|
||||
map_labels::map_labels(const display& disp, const config& cfg, const gamemap& map) : disp_(disp), map_(map)
|
||||
{
|
||||
read(cfg);
|
||||
}
|
||||
|
@ -62,6 +62,12 @@ void map_labels::set_label(const gamemap::location& loc, const std::string& text
|
|||
|
||||
SDL_Color colour = font::NORMAL_COLOUR;
|
||||
|
||||
if(map_.get_terrain_info(map_.get_terrain(loc)).is_light()) {
|
||||
colour.r = 0;
|
||||
colour.g = 0;
|
||||
colour.b = 0;
|
||||
}
|
||||
|
||||
const gamemap::location loc_nextx(loc.x+1,loc.y);
|
||||
const gamemap::location loc_nexty(loc.x,loc.y+1);
|
||||
const int xloc = (disp_.get_location_x(loc) + disp_.get_location_x(loc_nextx)*2)/3;
|
||||
|
|
|
@ -13,8 +13,8 @@ class team;
|
|||
class map_labels
|
||||
{
|
||||
public:
|
||||
map_labels(const display& disp);
|
||||
map_labels(const display& disp, const config& cfg);
|
||||
map_labels(const display& disp, const gamemap& map);
|
||||
map_labels(const display& disp, const config& cfg, const gamemap& map);
|
||||
~map_labels();
|
||||
|
||||
void write(config& res) const;
|
||||
|
@ -36,6 +36,7 @@ private:
|
|||
|
||||
const display& disp_;
|
||||
const team* team_;
|
||||
const gamemap& map_;
|
||||
|
||||
typedef std::map<gamemap::location,int> label_map;
|
||||
label_map labels_;
|
||||
|
|
Loading…
Add table
Reference in a new issue