mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Initial UI design for private servers connect
This commit is contained in:
parent
b473d23f7d
commit
a6e88f62d5
7890
external/stb/include/stb_image.h
vendored
Normal file
7890
external/stb/include/stb_image.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -25,3 +25,8 @@ extern BOOL g_bShowConsole;
|
||||
extern BOOL g_bShowBrowser;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//#################################################################################
|
||||
// UTILS
|
||||
//#################################################################################
|
||||
bool LoadTextureFromFile(const char* filename, ID3D11ShaderResourceView** out_srv, int* out_width, int* out_height);
|
@ -263,6 +263,7 @@ public:
|
||||
void UpdateHostingStatus();
|
||||
void ProcessCommand(const char* command_line);
|
||||
void ExecCommand(const char* command_line);
|
||||
|
||||
};
|
||||
|
||||
extern CCompanion* g_ServerBrowser;
|
@ -87,7 +87,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(SolutionDir)external\detours\include;$(SolutionDir)external\imgui\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)r5dev\include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(SolutionDir)external\detours\include;$(SolutionDir)external\imgui\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)external\stb\include;$(SolutionDir)r5dev\include;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>$(SolutionDir)external\detours\libs;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
@ -286,6 +286,7 @@
|
||||
<ClInclude Include="..\external\spdlog\include\stopwatch.h" />
|
||||
<ClInclude Include="..\external\spdlog\include\tweakme.h" />
|
||||
<ClInclude Include="..\external\spdlog\include\version.h" />
|
||||
<ClInclude Include="..\external\stb\include\stb_image.h" />
|
||||
<ClInclude Include="include\address.h" />
|
||||
<ClInclude Include="include\console.h" />
|
||||
<ClInclude Include="include\enums.h" />
|
||||
|
@ -52,6 +52,12 @@
|
||||
<Filter Include="External Libraries\spdlog\Header Files\fmt\bundled">
|
||||
<UniqueIdentifier>{6faf53e7-9be1-439f-92f9-16ab96c005b7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="External Libraries\stb">
|
||||
<UniqueIdentifier>{10c4f432-81f6-46f2-9ab0-ac70ee08bff7}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="External Libraries\stb\Header Files">
|
||||
<UniqueIdentifier>{558c4758-4b1c-4480-946d-ff6c9df375ee}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\dllmain.cpp">
|
||||
@ -482,6 +488,9 @@
|
||||
<ClInclude Include="include\imgui_stdlib.h">
|
||||
<Filter>External Libraries\imgui\Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\external\stb\include\stb_image.h">
|
||||
<Filter>External Libraries\stb\Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="r5dev.def">
|
||||
|
@ -1,4 +1,8 @@
|
||||
#include "pch.h"
|
||||
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#include "stb_image.h"
|
||||
|
||||
#include "id3dx.h"
|
||||
#include "input.h"
|
||||
#include "enums.h"
|
||||
@ -8,6 +12,7 @@
|
||||
#include "patterns.h"
|
||||
#include "gameclasses.h"
|
||||
|
||||
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
|
||||
/*---------------------------------------------------------------------------------
|
||||
@ -484,3 +489,54 @@ void SetupDXSwapChain()
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#################################################################################
|
||||
// UTILS
|
||||
//#################################################################################
|
||||
bool LoadTextureFromFile(const char* filename, ID3D11ShaderResourceView** out_srv, int* out_width, int* out_height)
|
||||
{
|
||||
// Load from disk into a raw RGBA buffer
|
||||
int image_width = 0;
|
||||
int image_height = 0;
|
||||
unsigned char* image_data = stbi_load(filename, &image_width, &image_height, NULL, 4);
|
||||
if (image_data == NULL)
|
||||
return false;
|
||||
|
||||
// Create texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.Width = image_width;
|
||||
desc.Height = image_height;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
desc.CPUAccessFlags = 0;
|
||||
|
||||
ID3D11Texture2D* pTexture = NULL;
|
||||
D3D11_SUBRESOURCE_DATA subResource;
|
||||
subResource.pSysMem = image_data;
|
||||
subResource.SysMemPitch = desc.Width * 4;
|
||||
subResource.SysMemSlicePitch = 0;
|
||||
g_pDevice->CreateTexture2D(&desc, &subResource, &pTexture);
|
||||
|
||||
// Create texture view
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
|
||||
ZeroMemory(&srvDesc, sizeof(srvDesc));
|
||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = desc.MipLevels;
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
g_pDevice->CreateShaderResourceView(pTexture, &srvDesc, out_srv);
|
||||
pTexture->Release();
|
||||
|
||||
*out_width = image_width;
|
||||
*out_height = image_height;
|
||||
stbi_image_free(image_data);
|
||||
|
||||
return true;
|
||||
}
|
@ -454,7 +454,13 @@ void CCompanion::SendHostingPostRequest()
|
||||
}
|
||||
else if(res["success"] == true)
|
||||
{
|
||||
HostRequestMessage = "Hosting!";
|
||||
std::stringstream msg;
|
||||
msg << "Broadcasting! ";
|
||||
if (res["token"].is_string())
|
||||
{
|
||||
msg << "Share this token: " << res["token"] << ", and the password you set";
|
||||
}
|
||||
HostRequestMessage = msg.str().c_str();
|
||||
HostRequestMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
|
||||
}
|
||||
else
|
||||
@ -546,15 +552,68 @@ void CCompanion::ServerBrowserSection()
|
||||
ImGui::InputTextWithHint("##ServerBrowser_ServerConnString", "Enter an ip address or \"localhost\"", ServerConnStringBuffer, IM_ARRAYSIZE(ServerConnStringBuffer));
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Connect to the server", ImVec2(ImGui::GetWindowSize().x * (1.f / 3.f), 19)))
|
||||
if (ImGui::Button("Connect", ImVec2(ImGui::GetWindowContentRegionWidth() * (1.f / 3.f /2.f), 19)))
|
||||
{
|
||||
//const char* replace = ""; // For history pos soon
|
||||
std::stringstream cmd;
|
||||
cmd << "connect " << ServerConnStringBuffer;
|
||||
//strcpy_s(ServerConnStringBuffer, sizeof(replace), replace); // For history pos soon
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("Private Servers##ServerBrowser_PrivateServersButton", ImVec2(ImGui::GetWindowContentRegionWidth() * (1.f / 3.f / 2.f), 19)))
|
||||
ImGui::OpenPopup("Connect to a Private Server##PrivateServersConnectModal");
|
||||
|
||||
bool open = true;
|
||||
if (ImGui::BeginPopupModal("Connect to a Private Server##PrivateServersConnectModal", &open))
|
||||
{
|
||||
// I *WILL* move this in a separate class
|
||||
|
||||
ImGui::SetWindowSize(ImVec2(400.f, 200.f));
|
||||
|
||||
int imgWidth = 0;
|
||||
int imgHeight = 0;
|
||||
static ID3D11ShaderResourceView* apex_private_servers_icon = NULL;
|
||||
bool ret = LoadTextureFromFile("lockedserver.png", &apex_private_servers_icon, &imgWidth, &imgHeight);
|
||||
IM_ASSERT(ret);
|
||||
|
||||
//
|
||||
|
||||
|
||||
static std::string token;
|
||||
static std::string password;
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.00f, 0.00f, 0.00f, 0.00f)); // transparent bg
|
||||
ImGui::BeginChild("##PrivateServersConnectModal_IconParent", ImVec2(imgWidth, imgHeight));
|
||||
ImGui::Image((void*)apex_private_servers_icon, ImVec2(imgWidth, imgHeight));
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
ImGui::Text("Enter the following details to continue");
|
||||
|
||||
ImGui::PushItemWidth(ImGui::GetWindowContentRegionWidth());
|
||||
ImGui::InputTextWithHint("##PrivateServersConnectModal_TokenInput", "Token", &token);
|
||||
ImGui::InputTextWithHint("##PrivateServersConnectModal_PasswordInput", "Password", &password);
|
||||
ImGui::PopItemWidth();
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Separator();
|
||||
|
||||
if(ImGui::Button("Connect##PrivateServersConnectModal_ConnectButton"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Close##PrivateServersConnectModal_CloseButton"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCompanion::HostServerSection()
|
||||
{
|
||||
static std::string ServerNameErr = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user