From d903761dbb5668e71521ee8cf8f71b29faa44f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Sj=C3=B6blom?= Date: Tue, 15 Oct 2024 18:28:14 +0200 Subject: [PATCH] Adding hotkey to go to notification event --- data/RTTR/texte/keyboardlayout.txt | 13 +++++-------- libs/s25main/desktops/dskGameInterface.cpp | 9 ++++++++- libs/s25main/ingameWindows/iwPostWindow.cpp | 9 ++++++++- libs/s25main/ingameWindows/iwPostWindow.h | 3 ++- libs/s25main/postSystem/PostBox.cpp | 8 +++++++- libs/s25main/postSystem/PostBox.h | 7 ++++++- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/data/RTTR/texte/keyboardlayout.txt b/data/RTTR/texte/keyboardlayout.txt index d1632af3f..1659705e4 100644 --- a/data/RTTR/texte/keyboardlayout.txt +++ b/data/RTTR/texte/keyboardlayout.txt @@ -2,19 +2,17 @@ ------------------------------------------------------------------------ Global keyboard layout in game: -Bracketed keys do not work yet. - P:.................... Pause H:.................... Go to headquarters -B:.................... Go back to start position +B:.................... Go back to previous position N:.................... Open post office L:.................... Show map M:.................... Main selection I:.................... Open inventory -SPACE:................ Switch contruction aid function +SPACE:................ Switch construction aid function C:.................... Check information about houses S:.................... Show status of houses @@ -24,11 +22,10 @@ V:.................... Game acceleration Alt-W, Esc:........... Close active window Alt-Q:................ Exit from game -F1:................... (Load game) F2:................... Save game F8:................... Readme "Keyboard layout" F9:................... Readme -F11:.................. Musicplayer +F11:.................. Music player F12:.................. Options window Post office: @@ -39,12 +36,12 @@ G:.................... Go to site of event Arrow keys: Scroll the main map -Additionally when in Replay-mode: +Additionally, when in Replay-mode: D:.................... Discover/hide unexplored land J:.................... Go to specific GF P:.................... Pause/Resume (also after GF jump) 1-7:.................. Change to other player ------------------------------------------------------------------------ -https://www.siedler25.org Copyright (C) 2005-2022 Settlers Freaks +https://www.siedler25.org Copyright (C) 2005-2024 Settlers Freaks ------------------------------------------------------------------------ diff --git a/libs/s25main/desktops/dskGameInterface.cpp b/libs/s25main/desktops/dskGameInterface.cpp index 236ee7cdc..ffb7a2bce 100644 --- a/libs/s25main/desktops/dskGameInterface.cpp +++ b/libs/s25main/desktops/dskGameInterface.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -860,6 +860,13 @@ bool dskGameInterface::Msg_KeyDown(const KeyEvent& ke) worldViewer.RecalcAllColors(); minimap.UpdateAll(); return true; + case 'g': // Go to the position of last message + { + const PostMsg* msg = GetPostBox().GetCurrentMsg(); + if(msg && msg->GetPos().isValid()) + gwv.MoveToMapPt(msg->GetPos()); + } + return true; case 'h': // Zum HQ springen { const GamePlayer& player = worldViewer.GetPlayer(); diff --git a/libs/s25main/ingameWindows/iwPostWindow.cpp b/libs/s25main/ingameWindows/iwPostWindow.cpp index 3df0d500c..2bbeba98a 100644 --- a/libs/s25main/ingameWindows/iwPostWindow.cpp +++ b/libs/s25main/ingameWindows/iwPostWindow.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -109,6 +109,10 @@ iwPostWindow::iwPostWindow(GameWorldView& gwv, PostBox& postBox) DisplayPostMessage(); } +iwPostWindow::~iwPostWindow() { + postBox.SetCurrentMsg(-1); +} + void iwPostWindow::Msg_ButtonClick(const unsigned ctrl_id) { switch(ctrl_id) @@ -317,7 +321,10 @@ void iwPostWindow::DisplayPostMessage() GetCtrl(ID_TEXT)->SetPos(textCenter); // If message contains valid position, allow going to it if(curMsg->GetPos().isValid()) + { GetCtrl(ID_GOTO)->SetVisible(true); + postBox.SetCurrentMsg(curMsgId); + } } void iwPostWindow::SetMessageText(const std::string& message) diff --git a/libs/s25main/ingameWindows/iwPostWindow.h b/libs/s25main/ingameWindows/iwPostWindow.h index 45b10f0a0..a979c81d7 100644 --- a/libs/s25main/ingameWindows/iwPostWindow.h +++ b/libs/s25main/ingameWindows/iwPostWindow.h @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -17,6 +17,7 @@ class iwPostWindow : public IngameWindow { public: iwPostWindow(GameWorldView& gwv, PostBox& postBox); + ~iwPostWindow(); void Msg_PaintBefore() override; void Msg_ButtonClick(unsigned ctrl_id) override; bool Msg_KeyDown(const KeyEvent& ke) override; diff --git a/libs/s25main/postSystem/PostBox.cpp b/libs/s25main/postSystem/PostBox.cpp index 042269f98..40811d039 100644 --- a/libs/s25main/postSystem/PostBox.cpp +++ b/libs/s25main/postSystem/PostBox.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -63,6 +63,12 @@ const PostMsg* PostBox::GetMsg(unsigned idx) const return messages[idx].get(); } +const PostMsg* PostBox::GetCurrentMsg() const +{ + unsigned idx = currMsgIdx >= 0 && currMsgIdx < (int) numMessages ? currMsgIdx : numMessages - 1; + return GetMsg(idx); +} + void PostBox::SetCurrentMissionGoal(const std::string& goal) { currentMissionGoal = goal; diff --git a/libs/s25main/postSystem/PostBox.h b/libs/s25main/postSystem/PostBox.h index e5c1aa846..58347175b 100644 --- a/libs/s25main/postSystem/PostBox.h +++ b/libs/s25main/postSystem/PostBox.h @@ -1,4 +1,4 @@ -// Copyright (C) 2005 - 2021 Settlers Freaks (sf-team at siedler25.org) +// Copyright (C) 2005 - 2024 Settlers Freaks (sf-team at siedler25.org) // // SPDX-License-Identifier: GPL-2.0-or-later @@ -33,6 +33,10 @@ class PostBox /// Get message by index or nullptr if invalid index /// Oldest message is at index 0 const PostMsg* GetMsg(unsigned idx) const; + /// Set the currently/last opened message + void SetCurrentMsg(int idx) { currMsgIdx = idx; } + /// Get the currently/last opened message + const PostMsg* GetCurrentMsg() const; /// Set callback that receives new message and message count everytime a message is added void ObserveNewMsg(const NewMsgCallback& callback) { evNewMsg = callback; } /// Set callback that receives new message count everytime a message is deleted @@ -47,6 +51,7 @@ class PostBox bool DeleteMsg(unsigned idx, bool notify); std::array, MAX_MESSAGES> messages; unsigned numMessages = 0; + int currMsgIdx = -1; /// Current mission goal. Shown as a special message std::string currentMissionGoal; NewMsgCallback evNewMsg;