mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Add imgui golf mode overlay
This commit is contained in:
@ -23,6 +23,7 @@ add_library(videocommon
|
||||
IndexGenerator.cpp
|
||||
LightingShaderGen.cpp
|
||||
NetPlayChatUI.cpp
|
||||
NetPlayGolfUI.cpp
|
||||
OnScreenDisplay.cpp
|
||||
OpcodeDecoding.cpp
|
||||
PerfQueryBase.cpp
|
||||
|
66
Source/Core/VideoCommon/NetPlayGolfUI.cpp
Normal file
66
Source/Core/VideoCommon/NetPlayGolfUI.cpp
Normal file
@ -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();
|
||||
}
|
27
Source/Core/VideoCommon/NetPlayGolfUI.h
Normal file
27
Source/Core/VideoCommon/NetPlayGolfUI.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2019 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace NetPlay
|
||||
{
|
||||
class NetPlayClient;
|
||||
}
|
||||
|
||||
class NetPlayGolfUI
|
||||
{
|
||||
public:
|
||||
explicit NetPlayGolfUI(std::shared_ptr<NetPlay::NetPlayClient> netplay_client);
|
||||
~NetPlayGolfUI() = default;
|
||||
|
||||
void Display();
|
||||
|
||||
private:
|
||||
std::weak_ptr<NetPlay::NetPlayClient> m_netplay_client;
|
||||
};
|
||||
|
||||
extern std::unique_ptr<NetPlayGolfUI> g_netplay_golf_ui;
|
@ -37,6 +37,7 @@
|
||||
#include "Common/Timer.h"
|
||||
|
||||
#include "Core/Analytics.h"
|
||||
#include "Core/Config/NetplaySettings.h"
|
||||
#include "Core/Config/SYSCONFSettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
@ -58,6 +59,7 @@
|
||||
#include "VideoCommon/FramebufferManager.h"
|
||||
#include "VideoCommon/ImageWrite.h"
|
||||
#include "VideoCommon/NetPlayChatUI.h"
|
||||
#include "VideoCommon/NetPlayGolfUI.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/PixelEngine.h"
|
||||
#include "VideoCommon/PixelShaderManager.h"
|
||||
@ -532,6 +534,9 @@ void Renderer::DrawDebugText()
|
||||
if (g_ActiveConfig.bShowNetPlayMessages && g_netplay_chat_ui)
|
||||
g_netplay_chat_ui->Display();
|
||||
|
||||
if (Config::Get(Config::NETPLAY_GOLF_MODE_OVERLAY) && g_netplay_golf_ui)
|
||||
g_netplay_golf_ui->Display();
|
||||
|
||||
if (g_ActiveConfig.bOverlayProjStats)
|
||||
Statistics::DisplayProj();
|
||||
}
|
||||
|
@ -58,6 +58,7 @@
|
||||
<ClCompile Include="ImageWrite.cpp" />
|
||||
<ClCompile Include="IndexGenerator.cpp" />
|
||||
<ClCompile Include="NetPlayChatUI.cpp" />
|
||||
<ClCompile Include="NetPlayGolfUI.cpp" />
|
||||
<ClCompile Include="OnScreenDisplay.cpp" />
|
||||
<ClCompile Include="OpcodeDecoding.cpp" />
|
||||
<ClCompile Include="PerfQueryBase.cpp" />
|
||||
@ -122,6 +123,7 @@
|
||||
<ClInclude Include="FramebufferShaderGen.h" />
|
||||
<ClInclude Include="GXPipelineTypes.h" />
|
||||
<ClInclude Include="NetPlayChatUI.h" />
|
||||
<ClInclude Include="NetPlayGolfUI.h" />
|
||||
<ClInclude Include="ShaderCache.h" />
|
||||
<ClInclude Include="UberShaderCommon.h" />
|
||||
<ClInclude Include="UberShaderPixel.h" />
|
||||
@ -192,4 +194,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -200,6 +200,9 @@
|
||||
<ClCompile Include="NetPlayChatUI.cpp">
|
||||
<Filter>Util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NetPlayGolfUI.cpp">
|
||||
<Filter>Util</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CommandProcessor.h" />
|
||||
@ -392,8 +395,11 @@
|
||||
<ClInclude Include="NetPlayChatUI.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NetPlayGolfUI.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user