summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/NetPlayGolfUI.cpp
diff options
context:
space:
mode:
authorTechjar <tecknojar@gmail.com>2019-04-02 17:13:42 -0400
committerTechjar <tecknojar@gmail.com>2019-04-05 07:01:03 -0400
commit6c393f9ff420c2a4185122cfb1bed0fbb2bcfad9 (patch)
tree1effd674b2f64fc0198a333bb4856e48be84cc8e /Source/Core/VideoCommon/NetPlayGolfUI.cpp
parent1a128763305489df3d691a990bbd6033792dd1e1 (diff)
Add imgui golf mode overlay
Diffstat (limited to 'Source/Core/VideoCommon/NetPlayGolfUI.cpp')
-rw-r--r--Source/Core/VideoCommon/NetPlayGolfUI.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/Source/Core/VideoCommon/NetPlayGolfUI.cpp b/Source/Core/VideoCommon/NetPlayGolfUI.cpp
new file mode 100644
index 0000000000..3a831b1cf1
--- /dev/null
+++ b/Source/Core/VideoCommon/NetPlayGolfUI.cpp
@@ -0,0 +1,66 @@
+// Copyright 2019 Dolphin Emulator Project
+// Licensed under GPLv2+
+// Refer to the license.txt file included.
+
+#include "Common/StringUtil.h"
+
+#include "Core/NetPlayClient.h"
+
+#include "VideoCommon/NetPlayGolfUI.h"
+
+#include <imgui.h>
+
+constexpr float DEFAULT_WINDOW_WIDTH = 220.0f;
+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;
+}
+
+void NetPlayGolfUI::Display()
+{
+ auto client = m_netplay_client.lock();
+ if (!client)
+ return;
+
+ const float scale = ImGui::GetIO().DisplayFramebufferScale.x;
+
+ ImGui::SetNextWindowPos(ImVec2((20.0f + DEFAULT_WINDOW_WIDTH) * scale, 10.0f * scale),
+ ImGuiCond_FirstUseEver);
+ ImGui::SetNextWindowSizeConstraints(
+ ImVec2(DEFAULT_WINDOW_WIDTH * scale, DEFAULT_WINDOW_HEIGHT * scale),
+ ImGui::GetIO().DisplaySize);
+
+ // TODO: Translate these strings once imgui has multilingual fonts
+ if (!ImGui::Begin("Golf Mode", nullptr, ImGuiWindowFlags_None))
+ {
+ ImGui::End();
+ return;
+ }
+
+ ImGui::Text("Current Golfer: %s", client->GetCurrentGolfer().c_str());
+
+ if (client->LocalPlayerHasControllerMapped())
+ {
+ if (ImGui::Button("Take Control"))
+ {
+ client->RequestGolfControl();
+ }
+
+ for (auto player : client->GetPlayers())
+ {
+ if (client->IsLocalPlayer(player->pid) || !client->PlayerHasControllerMapped(player->pid))
+ continue;
+
+ if (ImGui::Button(StringFromFormat("Give Control to %s", player->name.c_str()).c_str()))
+ {
+ client->RequestGolfControl(player->pid);
+ }
+ }
+ }
+
+ ImGui::End();
+}