Skip to content
Permalink
Browse files

Merge pull request #8136 from lioncash/arglist

VideoCommon/{NetPlayChatUI/NetPlayGolfUI}: Minor changes
  • Loading branch information...
leoetlino committed May 29, 2019
2 parents 4aaa00d + 778623c commit 0cfdcf436dcec26a4ba2ad1f5733687694f5691f
@@ -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;
}
@@ -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();

@@ -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();
@@ -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();

0 comments on commit 0cfdcf4

Please sign in to comment.
You can’t perform that action at this time.