summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--projects/openttd_vs80.vcproj4
-rw-r--r--projects/openttd_vs90.vcproj4
-rw-r--r--source.list1
-rw-r--r--src/main_gui.cpp3
-rw-r--r--src/news_gui.cpp17
-rw-r--r--src/saveload.cpp5
-rw-r--r--src/statusbar_gui.cpp18
-rw-r--r--src/statusbar_gui.h20
8 files changed, 55 insertions, 17 deletions
diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index ccf20523e..e73c5d269 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1440,6 +1440,10 @@
>
</File>
<File
+ RelativePath=".\..\src\statusbar_gui.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\stdafx.h"
>
</File>
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index d4b35c0c1..190d050ed 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1437,6 +1437,10 @@
>
</File>
<File
+ RelativePath=".\..\src\statusbar_gui.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\stdafx.h"
>
</File>
diff --git a/source.list b/source.list
index bbbd3d87c..12b4f427b 100644
--- a/source.list
+++ b/source.list
@@ -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
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index afd874643..56bac55db 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -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();
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 5fd782cfe..0c6928e37 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -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)) {
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 3178efdcf..b69fdbfe2 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -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;
}
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index 535636e4c..18d103918 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -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;
diff --git a/src/statusbar_gui.h b/src/statusbar_gui.h
new file mode 100644
index 000000000..8003bf6ea
--- /dev/null
+++ b/src/statusbar_gui.h
@@ -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 */