mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r13114) -Codechange: use InvalidateData instead of direct window access to modify the state of the statusbar from outside the statusbar.
This commit is contained in:
parent
7c7a4de3e5
commit
7491b792e2
@ -1439,6 +1439,10 @@
|
||||
RelativePath=".\..\src\station_type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\statusbar_gui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\stdafx.h"
|
||||
>
|
||||
|
@ -1436,6 +1436,10 @@
|
||||
RelativePath=".\..\src\station_type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\statusbar_gui.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\src\stdafx.h"
|
||||
>
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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 *ni)
|
||||
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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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, WindowEvent *e)
|
||||
} 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;
|
||||
|
20
src/statusbar_gui.h
Normal file
20
src/statusbar_gui.h
Normal file
@ -0,0 +1,20 @@
|
||||
/* $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 */
|
Loading…
Reference in New Issue
Block a user