Merge pull request #7929 from spycrab/np_chat_toggle
NetPlayChatUI: Add activate chat hotkey
This commit is contained in:
commit
e222b91953
|
@ -20,7 +20,7 @@
|
|||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
// clang-format off
|
||||
constexpr std::array<const char*, 131> s_hotkey_labels{{
|
||||
constexpr std::array<const char*, 132> s_hotkey_labels{{
|
||||
_trans("Open"),
|
||||
_trans("Change Disc"),
|
||||
_trans("Eject Disc"),
|
||||
|
@ -31,6 +31,7 @@ constexpr std::array<const char*, 131> s_hotkey_labels{{
|
|||
_trans("Toggle Fullscreen"),
|
||||
_trans("Take Screenshot"),
|
||||
_trans("Exit"),
|
||||
_trans("Activate NetPlay Chat"),
|
||||
|
||||
_trans("Volume Down"),
|
||||
_trans("Volume Up"),
|
||||
|
@ -274,7 +275,7 @@ struct HotkeyGroupInfo
|
|||
};
|
||||
|
||||
constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
|
||||
{{_trans("General"), HK_OPEN, HK_EXIT},
|
||||
{{_trans("General"), HK_OPEN, HK_ACTIVATE_CHAT},
|
||||
{_trans("Volume"), HK_VOLUME_DOWN, HK_VOLUME_TOGGLE_MUTE},
|
||||
{_trans("Emulation Speed"), HK_DECREASE_EMULATION_SPEED, HK_TOGGLE_THROTTLE},
|
||||
{_trans("Frame Advance"), HK_FRAME_ADVANCE, HK_FRAME_ADVANCE_RESET_SPEED},
|
||||
|
|
|
@ -29,6 +29,7 @@ enum Hotkey
|
|||
HK_FULLSCREEN,
|
||||
HK_SCREENSHOT,
|
||||
HK_EXIT,
|
||||
HK_ACTIVATE_CHAT,
|
||||
|
||||
HK_VOLUME_DOWN,
|
||||
HK_VOLUME_UP,
|
||||
|
|
|
@ -196,6 +196,10 @@ void HotkeyScheduler::Run()
|
|||
|
||||
auto& settings = Settings::Instance();
|
||||
|
||||
// Toggle Chat
|
||||
if (IsHotkey(HK_ACTIVATE_CHAT))
|
||||
emit ActivateChat();
|
||||
|
||||
// Recording
|
||||
if (IsHotkey(HK_START_RECORDING))
|
||||
emit StartRecording();
|
||||
|
|
|
@ -26,6 +26,7 @@ signals:
|
|||
void ChangeDisc();
|
||||
|
||||
void ExitHotkey();
|
||||
void ActivateChat();
|
||||
void FullScreenHotkey();
|
||||
void StopHotkey();
|
||||
void ResetHotkey();
|
||||
|
|
|
@ -106,6 +106,7 @@
|
|||
|
||||
#include "UICommon/UICommon.h"
|
||||
|
||||
#include "VideoCommon/NetPlayChatUI.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
|
@ -482,6 +483,7 @@ void MainWindow::ConnectHotkeys()
|
|||
connect(m_hotkey_scheduler, &HotkeyScheduler::EjectDisc, this, &MainWindow::EjectDisc);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ExitHotkey, this, &MainWindow::close);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::TogglePauseHotkey, this, &MainWindow::TogglePause);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::ActivateChat, this, &MainWindow::OnActivateChat);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::RefreshGameListHotkey, this,
|
||||
&MainWindow::RefreshGameList);
|
||||
connect(m_hotkey_scheduler, &HotkeyScheduler::StopHotkey, this, &MainWindow::RequestStop);
|
||||
|
@ -1587,6 +1589,12 @@ void MainWindow::OnExportRecording()
|
|||
Core::SetState(Core::State::Running);
|
||||
}
|
||||
|
||||
void MainWindow::OnActivateChat()
|
||||
{
|
||||
if (g_netplay_chat_ui)
|
||||
g_netplay_chat_ui->Activate();
|
||||
}
|
||||
|
||||
void MainWindow::ShowTASInput()
|
||||
{
|
||||
for (int i = 0; i < num_gc_controllers; i++)
|
||||
|
|
|
@ -168,6 +168,7 @@ private:
|
|||
void OnStartRecording();
|
||||
void OnStopRecording();
|
||||
void OnExportRecording();
|
||||
void OnActivateChat();
|
||||
void ShowTASInput();
|
||||
|
||||
void ChangeDisc();
|
||||
|
|
|
@ -60,7 +60,12 @@ void NetPlayChatUI::Display()
|
|||
ImGuiInputTextFlags_EnterReturnsTrue))
|
||||
{
|
||||
SendMessage();
|
||||
}
|
||||
|
||||
if (m_activate)
|
||||
{
|
||||
ImGui::SetKeyboardFocusHere(-1);
|
||||
m_activate = false;
|
||||
}
|
||||
|
||||
ImGui::PopItemWidth();
|
||||
|
@ -97,3 +102,11 @@ void NetPlayChatUI::SendMessage()
|
|||
m_message_buf[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void NetPlayChatUI::Activate()
|
||||
{
|
||||
if (ImGui::IsItemFocused())
|
||||
ImGui::SetWindowFocus(NULL);
|
||||
else
|
||||
m_activate = true;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,12 @@ public:
|
|||
void Display();
|
||||
void AppendChat(const std::string& message, Color color);
|
||||
void SendMessage();
|
||||
void Activate();
|
||||
|
||||
private:
|
||||
char m_message_buf[256] = {};
|
||||
bool m_scroll_to_bottom = false;
|
||||
bool m_activate = false;
|
||||
bool m_is_scrolled_to_bottom = true;
|
||||
|
||||
std::deque<std::pair<std::string, Color>> m_messages;
|
||||
|
|
Loading…
Reference in New Issue