1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 07:43:01 +01:00

Fix display of chat shortcut on network games (#5593)

This commit is contained in:
Ted John
2017-06-11 18:19:15 +01:00
committed by GitHub
parent a6bd541445
commit 3988b7797e
4 changed files with 20 additions and 5 deletions

View File

@@ -49,6 +49,13 @@ public:
{ {
get_keyboard_map_scroll(keysState, x, y); get_keyboard_map_scroll(keysState, x, y);
} }
std::string GetKeyboardShortcutString(sint32 shortcut) override
{
utf8 buffer[256];
keyboard_shortcuts_format_string(buffer, sizeof(buffer), shortcut);
return std::string(buffer);
}
}; };
IWindowManager * OpenRCT2::Ui::CreateWindowManager() IWindowManager * OpenRCT2::Ui::CreateWindowManager()

View File

@@ -14,9 +14,12 @@
*****************************************************************************/ *****************************************************************************/
#pragma endregion #pragma endregion
#include "../Context.h"
#include "../core/Guard.hpp" #include "../core/Guard.hpp"
#include "../OpenRCT2.h" #include "../OpenRCT2.h"
#include "../PlatformEnvironment.h" #include "../PlatformEnvironment.h"
#include "../ui/UiContext.h"
#include "../ui/WindowManager.h"
extern "C" { extern "C" {
#include "../platform/platform.h" #include "../platform/platform.h"
@@ -2361,14 +2364,16 @@ const char* network_get_group_name(uint32 index)
void network_chat_show_connected_message() void network_chat_show_connected_message()
{ {
char templateBuffer[128]; auto windowManager = GetContext()->GetUiContext()->GetWindowManager();
char *templateString = templateBuffer; std::string s = windowManager->GetKeyboardShortcutString(41 /* SHORTCUT_OPEN_CHAT_WINDOW */);
// keyboard_shortcuts_format_string(templateBuffer, sizeof(templateBuffer), SHORTCUT_OPEN_CHAT_WINDOW); const char * sptr = s.c_str();
utf8 buffer[256]; utf8 buffer[256];
format_string(buffer, sizeof(buffer), STR_MULTIPLAYER_CONNECTED_CHAT_HINT, &sptr);
NetworkPlayer server; NetworkPlayer server;
server.Name = "Server"; server.Name = "Server";
format_string(buffer, 256, STR_MULTIPLAYER_CONNECTED_CHAT_HINT, &templateString); const char * formatted = Network::FormatChat(&server, buffer);
const char *formatted = Network::FormatChat(&server, buffer);
chat_history_add(formatted); chat_history_add(formatted);
} }

View File

@@ -23,6 +23,7 @@ namespace OpenRCT2 { namespace Ui
rct_window * OpenWindow(rct_windowclass wc) override { return nullptr; } rct_window * OpenWindow(rct_windowclass wc) override { return nullptr; }
void HandleKeyboardShortcut(sint32 key) override { } void HandleKeyboardShortcut(sint32 key) override { }
void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) override { } void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) override { }
std::string GetKeyboardShortcutString(sint32 shortcut) override { return std::string(); }
}; };
IWindowManager * CreateDummyWindowManager() IWindowManager * CreateDummyWindowManager()

View File

@@ -16,6 +16,7 @@
#pragma once #pragma once
#include <string>
#include "../common.h" #include "../common.h"
extern "C" extern "C"
@@ -37,6 +38,7 @@ namespace OpenRCT2
virtual void HandleKeyboardShortcut(sint32 key) abstract; virtual void HandleKeyboardShortcut(sint32 key) abstract;
virtual void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) abstract; virtual void GetKeyboardMapScroll(const uint8 * keysState, sint32 * x, sint32 * y) abstract;
virtual std::string GetKeyboardShortcutString(sint32 shortcut) abstract;
}; };
IWindowManager * CreateDummyWindowManager(); IWindowManager * CreateDummyWindowManager();