Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding hotkey to go to notification event #1707

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions data/RTTR/texte/keyboardlayout.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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
------------------------------------------------------------------------
9 changes: 8 additions & 1 deletion libs/s25main/desktops/dskGameInterface.cpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -860,6 +860,13 @@ bool dskGameInterface::Msg_KeyDown(const KeyEvent& ke)
worldViewer.RecalcAllColors();
minimap.UpdateAll();
return true;
case 'g': // Go to the position of current/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();
Expand Down
9 changes: 8 additions & 1 deletion libs/s25main/ingameWindows/iwPostWindow.cpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -317,7 +321,10 @@ void iwPostWindow::DisplayPostMessage()
GetCtrl<Window>(ID_TEXT)->SetPos(textCenter);
// If message contains valid position, allow going to it
if(curMsg->GetPos().isValid())
{
GetCtrl<Window>(ID_GOTO)->SetVisible(true);
postBox.SetCurrentMsg(curMsgId);
}
}

void iwPostWindow::SetMessageText(const std::string& message)
Expand Down
3 changes: 2 additions & 1 deletion libs/s25main/ingameWindows/iwPostWindow.h
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion libs/s25main/postSystem/PostBox.cpp
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -63,6 +63,14 @@ const PostMsg* PostBox::GetMsg(unsigned idx) const
return messages[idx].get();
}

const PostMsg* PostBox::GetCurrentMsg() const
{
if(numMessages == 0 || currMsgIdx > static_cast<int>(numMessages) - 1)
return nullptr;
unsigned idx = currMsgIdx >= 0 ? currMsgIdx : numMessages - 1;
return GetMsg(idx);
}

void PostBox::SetCurrentMissionGoal(const std::string& goal)
{
currentMissionGoal = goal;
Expand Down
7 changes: 6 additions & 1 deletion libs/s25main/postSystem/PostBox.h
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand All @@ -47,6 +51,7 @@ class PostBox
bool DeleteMsg(unsigned idx, bool notify);
std::array<std::unique_ptr<const PostMsg>, MAX_MESSAGES> messages;
unsigned numMessages = 0;
int currMsgIdx = -1;
/// Current mission goal. Shown as a special message
std::string currentMissionGoal;
NewMsgCallback evNewMsg;
Expand Down
Loading