Changeset - r9248:afa00db99401
[Not reviewed]
master
0 7 1
rubidium - 16 years ago 2008-05-16 07:08:04
rubidium@openttd.org
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
8 files changed with 55 insertions and 17 deletions:
0 comments (0 inline, 0 general)
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -1440,6 +1440,10 @@
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\statusbar_gui.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\stdafx.h"
 
				>
 
			</File>
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -1437,6 +1437,10 @@
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\statusbar_gui.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\stdafx.h"
 
				>
 
			</File>
source.list
Show inline comments
 
@@ -285,6 +285,7 @@ station_base.h
 
station_func.h
 
station_gui.h
 
station_type.h
 
statusbar_gui.h
 
stdafx.h
 
string_func.h
 
string_type.h
src/main_gui.cpp
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include "player_gui.h"
 
#include "settings_type.h"
 
#include "toolbar_gui.h"
 
#include "statusbar_gui.h"
 
#include "variables.h"
 
#include "tilehighlight_func.h"
 

	
 
@@ -431,8 +432,6 @@ void SetupColorsAndInitialWindow()
 
	}
 
}
 

	
 
extern void ShowStatusBar();
 

	
 
void ShowVitalWindows()
 
{
 
	AllocateToolbar();
src/news_gui.cpp
Show inline comments
 
@@ -18,6 +18,7 @@
 
#include "string_func.h"
 
#include "widgets/dropdown_func.h"
 
#include "map_func.h"
 
#include "statusbar_gui.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
@@ -472,8 +473,7 @@ static void ShowTicker(const NewsItem *n
 
	if (_news_ticker_sound) SndPlayFx(SND_16_MORSE);
 

	
 
	_statusbar_news_item = *ni;
 
	Window *w = FindWindowById(WC_STATUS_BAR, 0);
 
	if (w != NULL) WP(w, def_d).data_1 = 360;
 
	InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_TICKER);
 
}
 

	
 

	
 
@@ -490,8 +490,7 @@ static bool ReadyForNextItem()
 

	
 
	/* Ticker message
 
	 * Check if the status bar message is still being displayed? */
 
	const Window *w = FindWindowById(WC_STATUS_BAR, 0);
 
	if (w != NULL && WP(w, const def_d).data_1 > -1280) return false;
 
	if (IsNewsTickerShown()) return false;
 

	
 
	/* Newspaper message, decrement duration counter */
 
	if (ni->duration != 0) ni->duration--;
 
@@ -517,15 +516,9 @@ static void MoveToNextItem()
 

	
 
		switch (_news_type_data[type].display) {
 
			default: NOT_REACHED();
 
			case ND_OFF: { // Off - show nothing only a small reminder in the status bar
 
				Window *w = FindWindowById(WC_STATUS_BAR, 0);
 

	
 
				if (w != NULL) {
 
					WP(w, def_d).data_2 = 91;
 
					w->SetDirty();
 
				}
 
			case ND_OFF: // Off - show nothing only a small reminder in the status bar
 
				InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SHOW_REMINDER);
 
				break;
 
			}
 

	
 
			case ND_SUMMARY: // Summary - show ticker, but if forced big, cascade to full
 
				if (!(ni->flags & NF_FORCE_BIG)) {
src/saveload.cpp
Show inline comments
 
@@ -30,6 +30,7 @@
 
#include "core/endian_func.hpp"
 
#include "vehicle_base.h"
 
#include "autoreplace_base.h"
 
#include "statusbar_gui.h"
 
#include <list>
 

	
 
#include "table/strings.h"
 
@@ -1493,7 +1494,7 @@ static void SaveFileStart()
 
	_fast_forward = 0;
 
	if (_cursor.sprite == SPR_CURSOR_MOUSE) SetMouseCursor(SPR_CURSOR_ZZZ, PAL_NONE);
 

	
 
	InvalidateWindowData(WC_STATUS_BAR, 0, true);
 
	InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_START);
 
	_ts.saveinprogress = true;
 
}
 

	
 
@@ -1504,7 +1505,7 @@ static void SaveFileDone()
 
	_fast_forward = _ts.ff_state;
 
	if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
 

	
 
	InvalidateWindowData(WC_STATUS_BAR, 0, false);
 
	InvalidateWindowData(WC_STATUS_BAR, 0, SBI_SAVELOAD_FINISH);
 
	_ts.saveinprogress = false;
 
}
 

	
src/statusbar_gui.cpp
Show inline comments
 
@@ -18,6 +18,7 @@
 
#include "window_gui.h"
 
#include "variables.h"
 
#include "window_func.h"
 
#include "statusbar_gui.h"
 

	
 
#include "table/strings.h"
 
#include "table/sprites.h"
 
@@ -107,7 +108,13 @@ static void StatusBarWndProc(Window *w, 
 
		} break;
 

	
 
		case WE_INVALIDATE_DATA:
 
			WP(w, def_d).data_3 = e->we.invalidate.data;
 
			switch (e->we.invalidate.data) {
 
				default: NOT_REACHED();
 
				case SBI_SAVELOAD_START:  WP(w, def_d).data_3 = true;  break;
 
				case SBI_SAVELOAD_FINISH: WP(w, def_d).data_3 = false; break;
 
				case SBI_SHOW_TICKER:     WP(w, def_d).data_1 = 360;   break;
 
				case SBI_SHOW_REMINDER:   WP(w, def_d).data_2 = 91;    break;
 
			}
 
			break;
 

	
 
		case WE_CLICK:
 
@@ -152,6 +159,15 @@ static WindowDesc _main_status_desc = {
 
	StatusBarWndProc
 
};
 

	
 
/**
 
 * Checks whether the news ticker is currently being used.
 
 */
 
bool IsNewsTickerShown()
 
{
 
	const Window *w = FindWindowById(WC_STATUS_BAR, 0);
 
	return w != NULL && WP(w, const def_d).data_1 > -1280;
 
}
 

	
 
void ShowStatusBar()
 
{
 
	_main_status_desc.top = _screen.height - 12;
src/statusbar_gui.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file statusbar_gui.h Functions, definitions and such used only by the GUI. */
 

	
 
#ifndef STATUSBAR_GUI_H
 
#define STATUSBAR_GUI_H
 

	
 
enum StatusBarInvalidate
 
{
 
	SBI_SAVELOAD_START,
 
	SBI_SAVELOAD_FINISH,
 
	SBI_SHOW_TICKER,
 
	SBI_SHOW_REMINDER,
 
	SBI_END
 
};
 

	
 
bool IsNewsTickerShown();
 
void ShowStatusBar();
 

	
 
#endif /* STATUSBAR_GUI_H */
0 comments (0 inline, 0 general)