summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoan Josep <juanjo.ng.83@gmail.com>2019-02-17 00:15:58 +0100
committerPeterN <peter@fuzzle.org>2019-02-16 23:15:58 +0000
commit548ec05a48ba28b65e779fa27fa5985a4ee2901b (patch)
tree518372f8dba71cc9caf79f2d5974a917ceb2802f /src
parentebe84b9d4c747d516fd779c711788da5d4dcd1d0 (diff)
downloadopenttd-548ec05a48ba28b65e779fa27fa5985a4ee2901b.tar.xz
Add: News menu entry and shortcut for deleting all messages. (#7240)
Diffstat (limited to 'src')
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/main_gui.cpp3
-rw-r--r--src/toolbar_gui.cpp3
-rw-r--r--src/window.cpp12
-rw-r--r--src/window_func.h1
5 files changed, 19 insertions, 1 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 949851723..ceb42a5c6 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -466,6 +466,7 @@ STR_TOOLBAR_SOUND_MUSIC :Sound/music
############ range for message menu starts
STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT :Last message/news report
STR_NEWS_MENU_MESSAGE_HISTORY_MENU :Message history
+STR_NEWS_MENU_DELETE_ALL_MESSAGES :Delete all messages
############ range ends here
############ range for about menu starts
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 2eb24c8dc..43a73f6de 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -220,6 +220,7 @@ enum {
GHK_RESET_OBJECT_TO_PLACE,
GHK_DELETE_WINDOWS,
GHK_DELETE_NONVITAL_WINDOWS,
+ GHK_DELETE_ALL_MESSAGES,
GHK_REFRESH_SCREEN,
GHK_CRASH,
GHK_MONEY,
@@ -345,6 +346,7 @@ struct MainWindow : Window
case GHK_RESET_OBJECT_TO_PLACE: ResetObjectToPlace(); break;
case GHK_DELETE_WINDOWS: DeleteNonVitalWindows(); break;
case GHK_DELETE_NONVITAL_WINDOWS: DeleteAllNonVitalWindows(); break;
+ case GHK_DELETE_ALL_MESSAGES: DeleteAllMessages(); break;
case GHK_REFRESH_SCREEN: MarkWholeScreenDirty(); break;
case GHK_CRASH: // Crash the game
@@ -488,6 +490,7 @@ static Hotkey global_hotkeys[] = {
Hotkey(WKC_ESC, "reset_object_to_place", GHK_RESET_OBJECT_TO_PLACE),
Hotkey(WKC_DELETE, "delete_windows", GHK_DELETE_WINDOWS),
Hotkey(WKC_DELETE | WKC_SHIFT, "delete_all_windows", GHK_DELETE_NONVITAL_WINDOWS),
+ Hotkey(WKC_DELETE | WKC_CTRL, "delete_all_messages", GHK_DELETE_ALL_MESSAGES),
Hotkey('R' | WKC_CTRL, "refresh_screen", GHK_REFRESH_SCREEN),
#if defined(_DEBUG)
Hotkey('0' | WKC_ALT, "crash_game", GHK_CRASH),
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index a5bccd41f..9b84268ef 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1023,7 +1023,7 @@ static CallBackFunction MenuClickMusicWindow(int index)
static CallBackFunction ToolbarNewspaperClick(Window *w)
{
- PopupMainToolbMenu(w, WID_TN_MESSAGES, STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, 2);
+ PopupMainToolbMenu(w, WID_TN_MESSAGES, STR_NEWS_MENU_LAST_MESSAGE_NEWS_REPORT, 3);
return CBF_NONE;
}
@@ -1038,6 +1038,7 @@ static CallBackFunction MenuClickNewspaper(int index)
switch (index) {
case 0: ShowLastNewsMessage(); break;
case 1: ShowMessageHistory(); break;
+ case 2: DeleteAllMessages(); break;
}
return CBF_NONE;
}
diff --git a/src/window.cpp b/src/window.cpp
index 3f4adf5e9..e8c4fe74d 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -39,6 +39,7 @@
#include "framerate_type.h"
#include "network/network_func.h"
#include "guitimer_func.h"
+#include "news_func.h"
#include "safeguards.h"
@@ -3371,6 +3372,17 @@ restart_search:
}
/**
+ * Delete all messages and their corresponding window (if any).
+ */
+void DeleteAllMessages()
+{
+ InitNewsItemStructs();
+ InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); // invalidate the statusbar
+ InvalidateWindowData(WC_MESSAGE_HISTORY, 0); // invalidate the message history
+ DeleteWindowById(WC_NEWS_WINDOW, 0); // close newspaper or general message window if shown
+}
+
+/**
* Delete all windows that are used for construction of vehicle etc.
* Once done with that invalidate the others to ensure they get refreshed too.
*/
diff --git a/src/window_func.h b/src/window_func.h
index 453b88978..45e2d71ec 100644
--- a/src/window_func.h
+++ b/src/window_func.h
@@ -40,6 +40,7 @@ void InvalidateWindowClassesData(WindowClass cls, int data = 0, bool gui_scope =
void DeleteNonVitalWindows();
void DeleteAllNonVitalWindows();
+void DeleteAllMessages();
void DeleteConstructionWindows();
void HideVitalWindows();
void ShowVitalWindows();