Merge pull request #8136 from lioncash/arglist

VideoCommon/{NetPlayChatUI/NetPlayGolfUI}: Minor changes
This commit is contained in:
Léo Lam
2019-05-29 13:18:03 +02:00
committed by GitHub
4 changed files with 12 additions and 9 deletions

View File

@ -14,10 +14,12 @@ constexpr size_t MAX_BACKLOG_SIZE = 100;
std::unique_ptr<NetPlayChatUI> g_netplay_chat_ui; std::unique_ptr<NetPlayChatUI> g_netplay_chat_ui;
NetPlayChatUI::NetPlayChatUI(std::function<void(const std::string&)> callback) NetPlayChatUI::NetPlayChatUI(std::function<void(const std::string&)> callback)
: m_message_callback{std::move(callback)}
{ {
m_message_callback = std::move(callback);
} }
NetPlayChatUI::~NetPlayChatUI() = default;
void NetPlayChatUI::Display() void NetPlayChatUI::Display()
{ {
const float scale = ImGui::GetIO().DisplayFramebufferScale.x; const float scale = ImGui::GetIO().DisplayFramebufferScale.x;
@ -78,12 +80,12 @@ void NetPlayChatUI::Display()
ImGui::End(); ImGui::End();
} }
void NetPlayChatUI::AppendChat(const std::string& message, NetPlayChatUI::Color color) void NetPlayChatUI::AppendChat(std::string message, Color color)
{ {
if (m_messages.size() > MAX_BACKLOG_SIZE) if (m_messages.size() > MAX_BACKLOG_SIZE)
m_messages.pop_front(); m_messages.pop_front();
m_messages.push_back({message, color}); m_messages.emplace_back(std::move(message), color);
// Only scroll to bottom, if we were at the bottom previously // Only scroll to bottom, if we were at the bottom previously
if (m_is_scrolled_to_bottom) if (m_is_scrolled_to_bottom)
@ -106,7 +108,7 @@ void NetPlayChatUI::SendMessage()
void NetPlayChatUI::Activate() void NetPlayChatUI::Activate()
{ {
if (ImGui::IsItemFocused()) if (ImGui::IsItemFocused())
ImGui::SetWindowFocus(NULL); ImGui::SetWindowFocus(nullptr);
else else
m_activate = true; m_activate = true;
} }

View File

@ -15,12 +15,12 @@ class NetPlayChatUI
{ {
public: public:
explicit NetPlayChatUI(std::function<void(const std::string&)> callback); explicit NetPlayChatUI(std::function<void(const std::string&)> callback);
~NetPlayChatUI() = default; ~NetPlayChatUI();
using Color = std::array<float, 3>; using Color = std::array<float, 3>;
void Display(); void Display();
void AppendChat(const std::string& message, Color color); void AppendChat(std::string message, Color color);
void SendMessage(); void SendMessage();
void Activate(); void Activate();

View File

@ -16,10 +16,12 @@ constexpr float DEFAULT_WINDOW_HEIGHT = 45.0f;
std::unique_ptr<NetPlayGolfUI> g_netplay_golf_ui; std::unique_ptr<NetPlayGolfUI> g_netplay_golf_ui;
NetPlayGolfUI::NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client) NetPlayGolfUI::NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client)
: m_netplay_client{netplay_client}
{ {
m_netplay_client = netplay_client;
} }
NetPlayGolfUI::~NetPlayGolfUI() = default;
void NetPlayGolfUI::Display() void NetPlayGolfUI::Display()
{ {
auto client = m_netplay_client.lock(); auto client = m_netplay_client.lock();

View File

@ -5,7 +5,6 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <string>
namespace NetPlay namespace NetPlay
{ {
@ -16,7 +15,7 @@ class NetPlayGolfUI
{ {
public: public:
explicit NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client); explicit NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client);
~NetPlayGolfUI() = default; ~NetPlayGolfUI();
void Display(); void Display();