Changeset - r23139:92b491888865
[Not reviewed]
master
0 5 0
PeterN - 5 years ago 2019-01-12 23:23:23
peter@fuzzle.org
Fix #6780: Some windows didn't get updated from OnTick() (#7048)
5 files changed with 35 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_gui.cpp
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include "../widgets/dropdown_func.h"
 
#include "../hotkeys.h"
 
#include "../core/geometry_func.hpp"
 
#include "../guitimer_func.h"
 

	
 
#include "ai.hpp"
 
#include "ai_gui.hpp"
 
@@ -286,7 +287,7 @@ struct AISettingsWindow : public Window 
 
	bool clicked_increase;                ///< Whether we clicked the increase or decrease button.
 
	bool clicked_dropdown;                ///< Whether the dropdown is open.
 
	bool closing_dropdown;                ///< True, if the dropdown list is currently closing.
 
	int timeout;                          ///< Timeout for unclicking the button.
 
	GUITimer timeout;                     ///< Timeout for unclicking the button.
 
	int clicked_row;                      ///< The clicked row of settings.
 
	int line_height;                      ///< Height of a row in the matrix widget.
 
	Scrollbar *vscroll;                   ///< Cache of the vertical scrollbar.
 
@@ -505,7 +506,7 @@ struct AISettingsWindow : public Window 
 
					if (new_val != old_val) {
 
						this->ai_config->SetSetting(config_item.name, new_val);
 
						this->clicked_button = num;
 
						this->timeout = 5;
 
						this->timeout.SetInterval(150);
 
					}
 
				} else if (!bool_item && !config_item.complete_labels) {
 
					/* Display a query box so users can enter a custom value. */
 
@@ -568,9 +569,9 @@ struct AISettingsWindow : public Window 
 
		this->vscroll->SetCapacityFromWidget(this, WID_AIS_BACKGROUND);
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		if (--this->timeout == 0) {
 
		if (this->timeout.Elapsed(delta_ms)) {
 
			this->clicked_button = -1;
 
			this->SetDirty();
 
		}
src/framerate_gui.cpp
Show inline comments
 
@@ -15,9 +15,9 @@
 
#include "window_gui.h"
 
#include "table/sprites.h"
 
#include "strings_func.h"
 
#include "debug.h"
 
#include "console_func.h"
 
#include "console_type.h"
 
#include "guitimer_func.h"
 

	
 
#include "widgets/framerate_widget.h"
 

	
 
@@ -295,7 +295,7 @@ static const NWidgetPart _framerate_wind
 

	
 
struct FramerateWindow : Window {
 
	bool small;
 
	uint32 next_update;
 
	GUITimer next_update;
 

	
 
	struct CachedDecimal {
 
		StringID strid;
 
@@ -339,21 +339,24 @@ struct FramerateWindow : Window {
 
		this->InitNested(number);
 
		this->small = this->IsShaded();
 
		this->UpdateData();
 
		this->next_update.SetInterval(100);
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		bool elapsed = this->next_update.Elapsed(delta_ms);
 

	
 
		/* Check if the shaded state has changed, switch caption text if it has */
 
		if (this->small != this->IsShaded()) {
 
			this->small = this->IsShaded();
 
			this->GetWidget<NWidgetLeaf>(WID_FRW_CAPTION)->SetDataTip(this->small ? STR_FRAMERATE_CAPTION_SMALL : STR_FRAMERATE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS);
 
			this->next_update = 0;
 
			elapsed = true;
 
		}
 

	
 
		if (_realtime_tick >= this->next_update) {
 
		if (elapsed) {
 
			this->UpdateData();
 
			this->SetDirty();
 
			this->next_update = _realtime_tick + 100;
 
			this->next_update.SetInterval(100);
 
		}
 
	}
 

	
 
@@ -527,7 +530,7 @@ static const NWidgetPart _frametime_grap
 
struct FrametimeGraphWindow : Window {
 
	int vertical_scale;       ///< number of TIMESTAMP_PRECISION units vertically
 
	int horizontal_scale;     ///< number of half-second units horizontally
 
	uint32 next_scale_update; ///< realtime tick for next scale update
 
	GUITimer next_scale_update; ///< interval for next scale update
 

	
 
	PerformanceElement element; ///< what element this window renders graph for
 
	Dimension graph_size;       ///< size of the main graph area (excluding axis labels)
 
@@ -537,7 +540,7 @@ struct FrametimeGraphWindow : Window {
 
		this->element = (PerformanceElement)number;
 
		this->horizontal_scale = 4;
 
		this->vertical_scale = TIMESTAMP_PRECISION / 10;
 
		this->next_scale_update = 0;
 
		this->next_scale_update.SetInterval(1);
 

	
 
		this->InitNested(number);
 
	}
 
@@ -649,12 +652,12 @@ struct FrametimeGraphWindow : Window {
 
		this->SelectVerticalScale(peak_value);
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		this->SetDirty();
 

	
 
		if (this->next_scale_update < _realtime_tick) {
 
			this->next_scale_update = _realtime_tick + 500;
 
		if (this->next_scale_update.Elapsed(delta_ms)) {
 
			this->next_scale_update.SetInterval(500);
 
			this->UpdateScale();
 
		}
 
	}
src/network/network_gui.cpp
Show inline comments
 
@@ -31,6 +31,7 @@
 
#include "../core/geometry_func.hpp"
 
#include "../genworld.h"
 
#include "../map_type.h"
 
#include "../guitimer_func.h"
 

	
 
#include "../widgets/network_widget.h"
 

	
 
@@ -234,6 +235,7 @@ protected:
 
	Scrollbar *vscroll;           ///< vertical scrollbar of the list of servers
 
	QueryString name_editbox;     ///< Client name editbox.
 
	QueryString filter_editbox;   ///< Editbox for filter on servers
 
	GUITimer requery_timer;       ///< Timer for network requery
 

	
 
	int lock_offset; ///< Left offset for lock icon.
 
	int blot_offset; ///< Left offset for green/yellow/red compatibility icon.
 
@@ -480,6 +482,8 @@ public:
 
		this->server = this->last_joined;
 
		if (this->last_joined != NULL) NetworkUDPQueryServer(this->last_joined->address);
 

	
 
		this->requery_timer.SetInterval(MILLISECONDS_PER_TICK);
 

	
 
		this->servers.SetListing(this->last_sorting);
 
		this->servers.SetSortFuncs(this->sorter_funcs);
 
		this->servers.SetFilterFuncs(this->filter_funcs);
 
@@ -903,8 +907,11 @@ public:
 
		this->vscroll->SetCapacityFromWidget(this, WID_NG_MATRIX);
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		if (!this->requery_timer.Elapsed(delta_ms)) return;
 
		this->requery_timer.SetInterval(MILLISECONDS_PER_TICK);
 

	
 
		NetworkGameListRequery();
 
	}
 
};
src/widgets/dropdown.cpp
Show inline comments
 
@@ -14,6 +14,7 @@
 
#include "../string_func.h"
 
#include "../strings_func.h"
 
#include "../window_func.h"
 
#include "../guitimer_func.h"
 
#include "dropdown_type.h"
 

	
 
#include "dropdown_widget.h"
 
@@ -97,6 +98,7 @@ struct DropdownWindow : Window {
 
	bool drag_mode;
 
	bool instant_close;           ///< Close the window when the mouse button is raised.
 
	int scrolling;                ///< If non-zero, auto-scroll the item list (one time).
 
	GUITimer scrolling_timer;     ///< Timer for auto-scroll of the item list.
 
	Point position;               ///< Position of the topleft corner of the window.
 
	Scrollbar *vscroll;
 

	
 
@@ -155,6 +157,7 @@ struct DropdownWindow : Window {
 
		this->click_delay      = 0;
 
		this->drag_mode        = true;
 
		this->instant_close    = instant_close;
 
		this->scrolling_timer  = GUITimer(MILLISECONDS_PER_TICK);
 
	}
 

	
 
	~DropdownWindow()
 
@@ -254,8 +257,11 @@ struct DropdownWindow : Window {
 
		}
 
	}
 

	
 
	virtual void OnTick()
 
	virtual void OnRealtimeTick(uint delta_ms)
 
	{
 
		if (!this->scrolling_timer.Elapsed(delta_ms)) return;
 
		this->scrolling_timer.SetInterval(MILLISECONDS_PER_TICK);
 

	
 
		if (this->scrolling != 0) {
 
			int pos = this->vscroll->GetPosition();
 

	
src/window.cpp
Show inline comments
 
@@ -3304,7 +3304,7 @@ void InvalidateWindowClassesData(WindowC
 
}
 

	
 
/**
 
 * Dispatch OnTick event over all windows
 
 * Dispatch OnGameTick event over all windows
 
 */
 
void CallWindowGameTickEvent()
 
{
0 comments (0 inline, 0 general)