Skip to content

Commit

Permalink
Removed 'sunset' command. Deals with bug #25460
Browse files Browse the repository at this point in the history
Not really useful, this was. Better debug aids, we need.
  • Loading branch information
Vultraz committed Mar 9, 2017
1 parent a976d05 commit 64ebefb
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 61 deletions.
16 changes: 0 additions & 16 deletions src/display.cpp
Expand Up @@ -72,7 +72,6 @@ namespace {

const unsigned int MinZoom = zoom_levels.front();
const unsigned int MaxZoom = zoom_levels.back();
size_t sunset_delay = 0;

bool benchmark = false;

Expand Down Expand Up @@ -1312,12 +1311,6 @@ void display::drawing_buffer_clear()
drawing_buffer_.clear();
}

void display::sunset(const size_t delay)
{
// This allow both parametric and toggle use
sunset_delay = (sunset_delay == 0 && delay == 0) ? 3 : delay;
}

void display::toggle_benchmark()
{
benchmark = !benchmark;
Expand All @@ -1336,15 +1329,6 @@ void display::flip()

surface& frameBuffer = video().getSurface();

// This is just the debug function "sunset" to progressively darken the map area
static size_t sunset_timer = 0;
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,SDL_ALPHA_OPAQUE);
// Adjust the alpha if you want to balance cpu-cost / smooth sunset
sdl::fill_rect_alpha(r, color, 1, frameBuffer);
}
font::draw_floating_labels(frameBuffer);
events::raise_volatile_draw_event();

Expand Down
9 changes: 0 additions & 9 deletions src/display.hpp
Expand Up @@ -437,15 +437,6 @@ class display : public filter_context, public video2::draw_layering
void clear_mouseover_hex_overlay()
{ mouseover_hex_overlay_ = nullptr; }

/**
* Debug function to toggle the "sunset" mode.
* The map area become progressively darker,
* except where hexes are refreshed.
* delay is the number of frames between each darkening
* (0 to toggle).
*/
static void sunset(const size_t delay = 0);

/** Toggle to continuously redraw the screen. */
static void toggle_benchmark();

Expand Down
14 changes: 0 additions & 14 deletions src/gui/widgets/window.cpp
Expand Up @@ -103,8 +103,6 @@ class builder_window : public builder_styled_widget
} // namespace implementation
REGISTER_WIDGET(window)

unsigned window::sunset_ = 0;

namespace
{
#ifdef DEBUG_WINDOW_LAYOUT_GRAPHS
Expand Down Expand Up @@ -746,18 +744,6 @@ void window::draw()
}

if (dirty_list_.empty()) {
if (sunset_) {
/** @todo should probably be moved to event::sdl_event_handler::draw. */
static unsigned i = 0;
if (++i % sunset_ == 0) {
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, SDL_ALPHA_OPAQUE);

sdl::fill_rect_alpha(r, color, 1, frame_buffer);
}
}
return;
}

Expand Down
14 changes: 0 additions & 14 deletions src/gui/widgets/window.hpp
Expand Up @@ -440,11 +440,6 @@ class window : public panel, public cursor::setter
click_dismiss_ = click_dismiss;
}

static void set_sunset(const unsigned interval)
{
sunset_ = interval ? interval : 5;
}

bool get_need_layout() const
{
return need_layout_;
Expand Down Expand Up @@ -612,15 +607,6 @@ class window : public panel, public cursor::setter
/** Disable the escape key see our setter for more info. */
bool escape_disabled_;

/**
* Controls the sunset feature.
*
* If this value is not 0 it will darken the entire screen every
* sunset_th drawing request that nothing has been modified. It's a debug
* feature.
*/
static unsigned sunset_;

/**
* Helper struct to force widgets the have the same size.
*
Expand Down
9 changes: 1 addition & 8 deletions src/menu_events.cpp
Expand Up @@ -1008,7 +1008,6 @@ class console_handler : public map_command_handler<console_handler>, private cha
void do_control();
void do_controller();
void do_clear();
void do_sunset();
void do_foreground();
void do_layers();
void do_fps();
Expand Down Expand Up @@ -1094,8 +1093,6 @@ class console_handler : public map_command_handler<console_handler>, private cha
_("Query the controller status of a side."), _("<side>"));
register_command("clear", &console_handler::do_clear,
_("Clear chat history."));
register_command("sunset", &console_handler::do_sunset,
_("Visualize the screen refresh procedure."), "", "D");
register_command("foreground", &console_handler::do_foreground,
_("Debug foreground terrain."), "", "D");
register_command("layers", &console_handler::do_layers,
Expand Down Expand Up @@ -1489,11 +1486,7 @@ void console_handler::do_controller()
void console_handler::do_clear() {
menu_handler_.gui_->get_chat_manager().clear_chat_messages();
}
void console_handler::do_sunset() {
int delay = lexical_cast_default<int>(get_data());
menu_handler_.gui_->sunset(delay);
gui2::window::set_sunset(delay);
}

void console_handler::do_foreground() {
menu_handler_.gui_->toggle_debug_foreground();
}
Expand Down

0 comments on commit 64ebefb

Please sign in to comment.