mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 22:44:33 +00:00
made new time of day image masks ...
...which get laid over hexes when it's that time of day
This commit is contained in:
parent
d7958d4fe9
commit
804d114fad
@ -3,6 +3,7 @@
|
||||
id=dawn
|
||||
name=Dawn
|
||||
image=Dawn.png
|
||||
mask=terrain/dawn.png
|
||||
[/time]
|
||||
[illuminated_time]
|
||||
id=morning
|
||||
@ -47,6 +48,7 @@ lawful_bonus=25
|
||||
id=dusk
|
||||
name=Dusk
|
||||
image=Dusk.png
|
||||
mask=terrain/dusk.png
|
||||
[/time]
|
||||
[illuminated_time]
|
||||
id=afternoon
|
||||
@ -62,11 +64,13 @@ id=first_watch
|
||||
name=First Watch
|
||||
image=FirstWatch.png
|
||||
lawful_bonus=-25
|
||||
mask=terrain/night.png
|
||||
[/time]
|
||||
[illuminated_time]
|
||||
id=dusk
|
||||
name=Dusk
|
||||
image=Dusk.png
|
||||
mask=terrain/dusk.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
||||
@ -76,11 +80,13 @@ id=second_watch
|
||||
name=Second Watch
|
||||
image=SecondWatch.png
|
||||
lawful_bonus=-25
|
||||
mask=terrain/night.png
|
||||
[/time]
|
||||
[illuminated_time]
|
||||
id=dusk
|
||||
name=Dusk
|
||||
image=Dusk.png
|
||||
mask=terrain/dusk.png
|
||||
[/illuminated_time]
|
||||
#enddef
|
||||
|
||||
|
BIN
images/terrain/dawn.png
Normal file
BIN
images/terrain/dawn.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 778 B |
BIN
images/terrain/dusk.png
Normal file
BIN
images/terrain/dusk.png
Normal file
Binary file not shown.
BIN
images/terrain/night.png
Normal file
BIN
images/terrain/night.png
Normal file
Binary file not shown.
@ -60,7 +60,8 @@ 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,map)
|
||||
theme_(theme_cfg,screen_area()), firstTurn_(true), map_labels_(*this,map),
|
||||
tod_hex_mask1(NULL), tod_hex_mask2(NULL)
|
||||
{
|
||||
if(non_interactive())
|
||||
updatesLocked_++;
|
||||
@ -71,8 +72,6 @@ display::display(unit_map& units, CVideo& video, const gamemap& map,
|
||||
|
||||
std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
|
||||
|
||||
new_turn();
|
||||
|
||||
image::set_zoom(zoom_);
|
||||
|
||||
gameStatusRect_.w = 0;
|
||||
@ -116,32 +115,49 @@ Uint32 display::rgb(Uint8 red, Uint8 green, Uint8 blue)
|
||||
|
||||
void display::new_turn()
|
||||
{
|
||||
/* int r,g,b;
|
||||
image::get_colour_adjustment(&r,&g,&b);
|
||||
|
||||
const time_of_day& tod = status_.get_time_of_day();
|
||||
const int red = tod.red - r;
|
||||
const int green = tod.green - g;
|
||||
const int blue = tod.blue - b;
|
||||
|
||||
const int niterations = turbo() || firstTurn_ || (!red && !green && !blue) ? 0 : 10;
|
||||
if(!turbo() && !firstTurn_) {
|
||||
image::set_image_mask("");
|
||||
|
||||
const time_of_day& old_tod = status_.get_previous_time_of_day();
|
||||
|
||||
if(old_tod.image_mask != tod.image_mask) {
|
||||
const scoped_sdl_surface old_mask(image::get_image(old_tod.image_mask,image::UNMASKED));
|
||||
const scoped_sdl_surface new_mask(image::get_image(tod.image_mask,image::UNMASKED));
|
||||
|
||||
const int niterations = 10;
|
||||
const int frame_time = 30;
|
||||
const int starting_ticks = SDL_GetTicks();
|
||||
for(int i = 0; i != niterations; ++i) {
|
||||
|
||||
if(old_mask != NULL) {
|
||||
const double proportion = 1.0 - double(i)/double(niterations);
|
||||
tod_hex_mask1.assign(adjust_surface_alpha(old_mask,proportion));
|
||||
}
|
||||
|
||||
if(new_mask != NULL) {
|
||||
const double proportion = double(i)/double(niterations);
|
||||
tod_hex_mask2.assign(adjust_surface_alpha(new_mask,proportion));
|
||||
}
|
||||
|
||||
invalidate_all();
|
||||
draw();
|
||||
|
||||
const int cur_ticks = SDL_GetTicks();
|
||||
const int wanted_ticks = starting_ticks + i*frame_time;
|
||||
if(cur_ticks < wanted_ticks) {
|
||||
SDL_Delay(wanted_ticks - cur_ticks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tod_hex_mask1.assign(NULL);
|
||||
tod_hex_mask2.assign(NULL);
|
||||
}
|
||||
|
||||
firstTurn_ = false;
|
||||
|
||||
const int frame_time = 30;
|
||||
const int starting_ticks = SDL_GetTicks();
|
||||
for(int i = 0; i != niterations; ++i) {
|
||||
image::set_colour_adjustment(r+(i*red)/niterations,g+(i*green)/niterations,b+(i*blue)/niterations);
|
||||
invalidate_all();
|
||||
draw();
|
||||
|
||||
const int cur_ticks = SDL_GetTicks();
|
||||
const int wanted_ticks = starting_ticks + i*frame_time;
|
||||
if(cur_ticks < wanted_ticks) {
|
||||
SDL_Delay(wanted_ticks - cur_ticks);
|
||||
}
|
||||
}
|
||||
*/
|
||||
const time_of_day& tod = status_.get_time_of_day();
|
||||
image::set_colour_adjustment(tod.red,tod.green,tod.blue);
|
||||
image::set_image_mask(tod.image_mask);
|
||||
}
|
||||
@ -1294,9 +1310,8 @@ void display::draw_tile(int x, int y, SDL_Surface* unit_image, double alpha, Uin
|
||||
|
||||
const time_of_day& tod = status_.get_time_of_day();
|
||||
const time_of_day& tod_at = timeofday_at(status_,units_,loc);
|
||||
std::string mask;
|
||||
if(tod.image_mask != tod_at.image_mask) {
|
||||
std::cerr << "drawing unmasked image at " << (x+1) << "," << (y+1) << "\n";
|
||||
std::string mask = tod_at.image_mask;
|
||||
if(tod_hex_mask1 != NULL || tod_hex_mask2 != NULL || tod.image_mask != tod_at.image_mask) {
|
||||
image_type = image::UNMASKED;
|
||||
mask = tod_at.image_mask;
|
||||
}
|
||||
@ -1352,12 +1367,6 @@ void display::draw_tile(int x, int y, SDL_Surface* unit_image, double alpha, Uin
|
||||
}
|
||||
}
|
||||
|
||||
if(mask != "") {
|
||||
scoped_sdl_surface img(image::get_image(mask,image::UNMASKED,image::NO_ADJUST_COLOUR));
|
||||
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
|
||||
SDL_BlitSurface(img,NULL,dst,&dstrect);
|
||||
}
|
||||
|
||||
if(!is_shrouded) {
|
||||
draw_footstep(loc,xpos,ypos);
|
||||
}
|
||||
@ -1376,6 +1385,23 @@ void display::draw_tile(int x, int y, SDL_Surface* unit_image, double alpha, Uin
|
||||
draw_tile_adjacent(x,y,image_type,ADJACENT_FOREGROUND);
|
||||
}
|
||||
|
||||
//draw the time-of-day mask on top of the hex
|
||||
if(tod_hex_mask1 != NULL || tod_hex_mask2 != NULL) {
|
||||
if(tod_hex_mask1 != NULL) {
|
||||
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
|
||||
SDL_BlitSurface(tod_hex_mask1,NULL,dst,&dstrect);
|
||||
}
|
||||
|
||||
if(tod_hex_mask2 != NULL) {
|
||||
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
|
||||
SDL_BlitSurface(tod_hex_mask2,NULL,dst,&dstrect);
|
||||
}
|
||||
} else if(mask != "") {
|
||||
scoped_sdl_surface img(image::get_image(mask,image::UNMASKED,image::NO_ADJUST_COLOUR));
|
||||
SDL_Rect dstrect = { xpos, ypos, 0, 0 };
|
||||
SDL_BlitSurface(img,NULL,dst,&dstrect);
|
||||
}
|
||||
|
||||
if(grid_) {
|
||||
scoped_sdl_surface grid_surface(image::get_image("terrain/grid.png"));
|
||||
if(grid_surface != NULL) {
|
||||
|
@ -436,6 +436,10 @@ private:
|
||||
|
||||
std::vector<chat_message> chat_messages_;
|
||||
|
||||
//if we're transitioning from one time of day to the next,
|
||||
//then we will use these two masks on top of all hexes when we blit
|
||||
shared_sdl_surface tod_hex_mask1, tod_hex_mask2;
|
||||
|
||||
//for debug mode
|
||||
static std::map<gamemap::location,double> debugHighlights_;
|
||||
};
|
||||
|
@ -131,10 +131,10 @@ void gamestatus::write(config& cfg) const
|
||||
}
|
||||
}
|
||||
|
||||
const time_of_day& gamestatus::get_time_of_day() const
|
||||
const time_of_day& gamestatus::get_time_of_day_turn(int nturn) const
|
||||
{
|
||||
if(times_.empty() == false) {
|
||||
return times_[(turn()-1)%times_.size()];
|
||||
return times_[(nturn-1)%times_.size()];
|
||||
} else {
|
||||
config dummy_cfg;
|
||||
const static time_of_day default_time(dummy_cfg);
|
||||
@ -142,6 +142,16 @@ const time_of_day& gamestatus::get_time_of_day() const
|
||||
}
|
||||
}
|
||||
|
||||
const time_of_day& gamestatus::get_time_of_day() const
|
||||
{
|
||||
return get_time_of_day_turn(turn());
|
||||
}
|
||||
|
||||
const time_of_day& gamestatus::get_previous_time_of_day() const
|
||||
{
|
||||
return get_time_of_day_turn(turn()-1);
|
||||
}
|
||||
|
||||
const time_of_day& gamestatus::get_time_of_day(bool illuminated, const gamemap::location& loc) const
|
||||
{
|
||||
for(std::vector<area_time_of_day>::const_iterator i = areas_.begin(); i != areas_.end(); ++i) {
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
void write(config& cfg) const;
|
||||
|
||||
const time_of_day& get_time_of_day() const;
|
||||
const time_of_day& get_previous_time_of_day() const;
|
||||
const time_of_day& get_time_of_day(bool illuminated, const gamemap::location& loc) const;
|
||||
size_t turn() const;
|
||||
size_t number_of_turns() const;
|
||||
@ -86,6 +87,8 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
const time_of_day& get_time_of_day_turn(int nturn) const;
|
||||
|
||||
std::vector<time_of_day> times_, illuminatedTimes_;
|
||||
|
||||
struct area_time_of_day {
|
||||
|
@ -50,6 +50,8 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data)
|
||||
|
||||
bool last_escape = true;
|
||||
|
||||
int game_selection = 0, user_selection = 0;
|
||||
|
||||
for(;;) {
|
||||
SDL_BlitSurface(background, NULL, disp.video().getSurface(), NULL);
|
||||
|
||||
@ -81,6 +83,11 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data)
|
||||
|
||||
std::stringstream str;
|
||||
|
||||
//if this is the item that should be selected, make it selected by default
|
||||
if(game_selection-- == 0) {
|
||||
str << "*";
|
||||
}
|
||||
|
||||
std::string map_data = (**i.first)["map_data"];
|
||||
if(map_data == "") {
|
||||
map_data = read_file("data/maps/" + (**i.first)["map"]);
|
||||
@ -145,6 +152,11 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data)
|
||||
name.insert(name.begin(),'#');
|
||||
}
|
||||
|
||||
//if this user should be selected
|
||||
if(user_selection-- == 0) {
|
||||
name.insert(name.begin(),'*');
|
||||
}
|
||||
|
||||
users.push_back(name);
|
||||
}
|
||||
|
||||
@ -228,6 +240,9 @@ RESULT enter(display& disp, config& game_data, const config& terrain_data)
|
||||
events::raise_process_event();
|
||||
events::raise_draw_event();
|
||||
|
||||
user_selection = users_menu.selection();
|
||||
game_selection = games_menu.selection();
|
||||
|
||||
config data;
|
||||
|
||||
//if the list is refreshed, we want to redraw the entire screen
|
||||
|
@ -564,7 +564,7 @@ void process_send_queue(connection connection_num, size_t max_size)
|
||||
std::cerr << "sending " << bytes_to_send << " from send queue\n";
|
||||
|
||||
const int res = SDLNet_TCP_Send(sock,&buf[upto],bytes_to_send);
|
||||
if(res < int(bytes_to_send)) {
|
||||
if(res != int(bytes_to_send)) {
|
||||
std::cerr << "sending data failed: " << res << "/" << bytes_to_send << "\n";
|
||||
throw error("Sending queued data failed",connection_num);
|
||||
}
|
||||
@ -575,6 +575,8 @@ void process_send_queue(connection connection_num, size_t max_size)
|
||||
if(upto == buf.size()) {
|
||||
std::cerr << "erasing item from the send queue\n";
|
||||
send_queue.erase(itor.first);
|
||||
} else if(upto > buf.size()) {
|
||||
std::cerr << "ERROR: buffer overrun sending data\n";
|
||||
}
|
||||
|
||||
//if we haven't sent 'max_size' bytes yet, try to go onto the next item in
|
||||
|
@ -299,7 +299,9 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
|
||||
case SIDE_PLAYING: {
|
||||
char buf[50];
|
||||
sprintf(buf,"terrain/flag-team%d.png",playing_side);
|
||||
return report("",buf,"");
|
||||
|
||||
u = find_leader(units,playing_side);
|
||||
return report("",buf,u != units.end() ? u->second.description() : "");
|
||||
}
|
||||
|
||||
case OBSERVERS: {
|
||||
@ -307,6 +309,8 @@ report generate_report(TYPE type, const gamemap& map, const unit_map& units,
|
||||
return report();
|
||||
}
|
||||
|
||||
str << translate_string("observers") << ":\n";
|
||||
|
||||
for(std::set<std::string>::const_iterator i = observers.begin(); i != observers.end(); ++i) {
|
||||
str << *i << "\n";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user