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
commit 0cfdcf436d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
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()
{
const float scale = ImGui::GetIO().DisplayFramebufferScale.x;
@ -78,12 +80,12 @@ void NetPlayChatUI::Display()
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)
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
if (m_is_scrolled_to_bottom)
@ -106,7 +108,7 @@ void NetPlayChatUI::SendMessage()
void NetPlayChatUI::Activate()
{
if (ImGui::IsItemFocused())
ImGui::SetWindowFocus(NULL);
ImGui::SetWindowFocus(nullptr);
else
m_activate = true;
}

View File

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

View File

@ -16,10 +16,12 @@ constexpr float DEFAULT_WINDOW_HEIGHT = 45.0f;
std::unique_ptr<NetPlayGolfUI> g_netplay_golf_ui;
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()
{
auto client = m_netplay_client.lock();

View File

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