From dacd307663735d34aa4197c7e6610ddd1ba04686 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Tue, 24 May 2022 02:23:37 +0200 Subject: [PATCH] See description * Finished designer code for launcher gui. * Basic implementation of setting flags for host launch option. * Check in 'CHostState::LoadConfig' if -launcher is below 1.. if condition is met the cfg's will be executed from 'CHostState::LoadConfig'. * Added 'StringIsDigit' utility. --- r5dev/core/stdafx.h | 18 +- r5dev/engine/host_state.cpp | 33 +-- r5dev/public/include/utility.h | 1 + r5dev/public/utility.cpp | 14 ++ r5dev/sdklauncher/basepanel.cpp | 212 +++++++++++++++---- r5dev/sdklauncher/basepanel.h | 41 ++-- r5dev/sdklauncher/sdklauncher.cpp | 123 ++++++++--- r5dev/sdklauncher/sdklauncher.h | 34 +-- r5dev/sdklauncher/sdklauncher_const.h | 36 ++++ r5dev/thirdparty/cppnet/cppkore/StringBase.h | 31 +++ r5dev/tier1/cmd.cpp | 2 +- r5dev/vproj/sdklauncher.vcxproj | 1 + r5dev/vproj/sdklauncher.vcxproj.filters | 74 ++++--- 13 files changed, 459 insertions(+), 161 deletions(-) create mode 100644 r5dev/sdklauncher/sdklauncher_const.h diff --git a/r5dev/core/stdafx.h b/r5dev/core/stdafx.h index f724e1e9..fbea967e 100644 --- a/r5dev/core/stdafx.h +++ b/r5dev/core/stdafx.h @@ -5,10 +5,12 @@ #include #include #include +#include +#include +#include #include #include #include -#include #include #include #include @@ -34,6 +36,20 @@ #include "thirdparty/detours/include/detours.h" #include "thirdparty/detours/include/idetour.h" +#if defined(SDKLAUNCHER) +#include "thirdparty/cppnet/cppkore/Kore.h" +#include "thirdparty/cppnet/cppkore/UIXTheme.h" +#include "thirdparty/cppnet/cppkore/UIXLabel.h" +#include "thirdparty/cppnet/cppkore/UIXListView.h" +#include "thirdparty/cppnet/cppkore/UIXCheckBox.h" +#include "thirdparty/cppnet/cppkore/UIXComboBox.h" +#include "thirdparty/cppnet/cppkore/UIXTextBox.h" +#include "thirdparty/cppnet/cppkore/UIXGroupBox.h" +#include "thirdparty/cppnet/cppkore/UIXButton.h" +#include "thirdparty/cppnet/cppkore/UIXRadioButton.h" +#include "thirdparty/cppnet/cppkore/KoreTheme.h" +#endif // SDKLAUNCHER + #if !defined(DEDICATED) && !defined(SDKLAUNCHER) && !defined (NETCONSOLE) #include "thirdparty/imgui/include/imgui.h" #include "thirdparty/imgui/include/imgui_stdlib.h" diff --git a/r5dev/engine/host_state.cpp b/r5dev/engine/host_state.cpp index 1c25e301..4f560944 100644 --- a/r5dev/engine/host_state.cpp +++ b/r5dev/engine/host_state.cpp @@ -252,31 +252,34 @@ FORCEINLINE void CHostState::Think(void) const //----------------------------------------------------------------------------- FORCEINLINE void CHostState::LoadConfig(void) const { - if (!CommandLine()->CheckParm("-devsdk")) + if (CommandLine()->ParmValue("-launcher", 0) < 1) // Launcher level 1 indicates everything is set from the sdk launcher. { + if (!CommandLine()->CheckParm("-devsdk")) + { #ifndef CLIENT_DLL - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server.cfg\"", cmd_source_t::kCommandSrcCode); - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server.cfg\"", cmd_source_t::kCommandSrcCode); #endif //!CLIENT_DLL #ifndef DEDICATED - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_client.cfg\"", cmd_source_t::kCommandSrcCode); - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_client.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_client.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_client.cfg\"", cmd_source_t::kCommandSrcCode); #endif // !DEDICATED - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec.cfg\"", cmd_source_t::kCommandSrcCode); - } - else // Development configs. - { + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec.cfg\"", cmd_source_t::kCommandSrcCode); + } + else // Development configs. + { #ifndef CLIENT_DLL - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server_dev.cfg\"", cmd_source_t::kCommandSrcCode); - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server_dev.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_server_dev.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_server_dev.cfg\"", cmd_source_t::kCommandSrcCode); #endif //!CLIENT_DLL #ifndef DEDICATED - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_client_dev.cfg\"", cmd_source_t::kCommandSrcCode); - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_client_dev.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_client_dev.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"rcon_client_dev.cfg\"", cmd_source_t::kCommandSrcCode); #endif // !DEDICATED - Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_dev.cfg\"", cmd_source_t::kCommandSrcCode); + Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec \"autoexec_dev.cfg\"", cmd_source_t::kCommandSrcCode); + } + Cbuf_Execute(); } - Cbuf_Execute(); } //----------------------------------------------------------------------------- diff --git a/r5dev/public/include/utility.h b/r5dev/public/include/utility.h index a5fc974b..b0423a50 100644 --- a/r5dev/public/include/utility.h +++ b/r5dev/public/include/utility.h @@ -21,6 +21,7 @@ string ConvertToUnixPath(const string& svInput); string Base64Encode(const string& svInput); string Base64Decode(const string& svInput); +bool StringIsDigit(const string& svInput); bool CompareStringAlphabetically(const string& svA, const string& svB); bool CompareStringLexicographically(const string& svA, const string& svB); diff --git a/r5dev/public/utility.cpp b/r5dev/public/utility.cpp index 987710ad..b2d06093 100644 --- a/r5dev/public/utility.cpp +++ b/r5dev/public/utility.cpp @@ -343,6 +343,20 @@ string Base64Decode(const string& svInput) return results; } +/////////////////////////////////////////////////////////////////////////////// +// For checking if a string is a number. +bool StringIsDigit(const string& svInput) +{ + for (char const& c : svInput) + { + if (std::isdigit(c) == 0) + { + return false; + } + } + return true; +} + /////////////////////////////////////////////////////////////////////////////// // For comparing input strings alphabetically. bool CompareStringAlphabetically(const string& svA, const string& svB) diff --git a/r5dev/sdklauncher/basepanel.cpp b/r5dev/sdklauncher/basepanel.cpp index 650ef680..a93014a4 100644 --- a/r5dev/sdklauncher/basepanel.cpp +++ b/r5dev/sdklauncher/basepanel.cpp @@ -1,12 +1,11 @@ #include "core/stdafx.h" +#include "sdklauncher.h" #include "basepanel.h" -#include -#include "gdiplus.h" -#include "shellapi.h" void CUIBasePanel::Init() { + // START DESIGNER CODE const INT WindowX = 800; const INT WindowY = 350; @@ -52,6 +51,7 @@ void CUIBasePanel::Init() this->m_MapCombo->SetSize({ 347, 25 }); this->m_MapCombo->SetLocation({ 15, 25 }); this->m_MapCombo->SetTabIndex(0); + this->m_MapCombo->SetSelectedIndex(0); this->m_MapCombo->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); this->m_MapCombo->SetDropDownStyle(Forms::ComboBoxStyle::DropDownList); std::regex rgArchiveRegex{ R"([^_]*_(.*)(.bsp.pak000_dir).*)" }; @@ -92,6 +92,7 @@ void CUIBasePanel::Init() this->m_PlaylistCombo->SetSize({ 347, 25 }); this->m_PlaylistCombo->SetLocation({ 15, 50 }); this->m_PlaylistCombo->SetTabIndex(0); + this->m_PlaylistCombo->SetSelectedIndex(0); this->m_PlaylistCombo->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); this->m_PlaylistCombo->SetDropDownStyle(Forms::ComboBoxStyle::DropDownList); this->m_GameGroup->AddControl(this->m_PlaylistCombo); @@ -168,6 +169,7 @@ void CUIBasePanel::Init() this->m_ModeCombo->SetSize({ 82, 25 }); this->m_ModeCombo->SetLocation({ 15, 25 }); this->m_ModeCombo->SetTabIndex(0); + this->m_ModeCombo->SetSelectedIndex(0); this->m_ModeCombo->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); this->m_ModeCombo->SetDropDownStyle(Forms::ComboBoxStyle::DropDownList); this->m_ModeCombo->Items.Add("Host"); @@ -184,21 +186,21 @@ void CUIBasePanel::Init() this->m_ModeLabel->SetTextAlign(Drawing::ContentAlignment::TopLeft); this->m_MainGroup->AddControl(this->m_ModeLabel); - this->m_CustomDllTextBox = new UIX::UIXTextBox(); - this->m_CustomDllTextBox->SetSize({ 80, 21 }); - this->m_CustomDllTextBox->SetLocation({ 150, 25 }); - this->m_CustomDllTextBox->SetTabIndex(0); - this->m_CustomDllTextBox->SetText(""); - this->m_CustomDllTextBox->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); - this->m_MainGroup->AddControl(this->m_CustomDllTextBox); + this->m_HostNameTextBox = new UIX::UIXTextBox(); + this->m_HostNameTextBox->SetSize({ 80, 21 }); + this->m_HostNameTextBox->SetLocation({ 150, 25 }); + this->m_HostNameTextBox->SetTabIndex(0); + this->m_HostNameTextBox->SetText(""); + this->m_HostNameTextBox->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_MainGroup->AddControl(this->m_HostNameTextBox); - this->m_CustomDllLabel = new UIX::UIXLabel(); - this->m_CustomDllLabel->SetSize({ 70, 21 }); - this->m_CustomDllLabel->SetLocation({ 233, 28 }); - this->m_CustomDllLabel->SetTabIndex(0); - this->m_CustomDllLabel->SetText("Additional dll's"); - this->m_CustomDllLabel->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); - this->m_MainGroup->AddControl(this->m_CustomDllLabel); + this->m_HostNameLabel = new UIX::UIXLabel(); + this->m_HostNameLabel->SetSize({ 70, 21 }); + this->m_HostNameLabel->SetLocation({ 233, 28 }); + this->m_HostNameLabel->SetTabIndex(0); + this->m_HostNameLabel->SetText("Host name"); + this->m_HostNameLabel->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_MainGroup->AddControl(this->m_HostNameLabel); this->m_LaunchArgsTextBox = new UIX::UIXTextBox(); this->m_LaunchArgsTextBox->SetSize({ 215, 21 }); @@ -212,7 +214,7 @@ void CUIBasePanel::Init() this->m_LaunchArgsLabel->SetSize({ 70, 21 }); this->m_LaunchArgsLabel->SetLocation({ 233, 53 }); this->m_LaunchArgsLabel->SetTabIndex(0); - this->m_LaunchArgsLabel->SetText("Launch flags"); + this->m_LaunchArgsLabel->SetText("Command line"); this->m_LaunchArgsLabel->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); this->m_MainGroup->AddControl(this->m_LaunchArgsLabel); @@ -228,6 +230,7 @@ void CUIBasePanel::Init() this->m_UpdateSDK->SetSize({ 110, 18 }); this->m_UpdateSDK->SetLocation({ 15, 30 }); this->m_UpdateSDK->SetTabIndex(0); + this->m_UpdateSDK->SetEnabled(false); this->m_UpdateSDK->SetText("Update SDK"); this->m_UpdateSDK->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); this->m_MainGroupExt->AddControl(this->m_UpdateSDK); @@ -239,6 +242,7 @@ void CUIBasePanel::Init() this->m_LaunchSDK->SetText("Launch game"); this->m_LaunchSDK->SetBackColor(Drawing::Color(3, 102, 214)); this->m_LaunchSDK->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_LaunchSDK->Click += &LaunchGame; this->m_MainGroupExt->AddControl(this->m_LaunchSDK); // ################################################################################################# @@ -339,21 +343,21 @@ void CUIBasePanel::Init() this->m_EngineNetworkGroup->AddControl(this->m_NetRandomKeyToggle); - this->m_QueuedPacketThread = new UIX::UIXCheckBox(); - this->m_QueuedPacketThread->SetSize({ 125, 18 }); - this->m_QueuedPacketThread->SetLocation({ 15, 30 }); - this->m_QueuedPacketThread->SetTabIndex(2); - this->m_QueuedPacketThread->SetText("No queued packets"); - this->m_QueuedPacketThread->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); - this->m_EngineNetworkGroup->AddControl(this->m_QueuedPacketThread); + this->m_NoQueuedPacketThread = new UIX::UIXCheckBox(); + this->m_NoQueuedPacketThread->SetSize({ 125, 18 }); + this->m_NoQueuedPacketThread->SetLocation({ 15, 30 }); + this->m_NoQueuedPacketThread->SetTabIndex(2); + this->m_NoQueuedPacketThread->SetText("No queued packets"); + this->m_NoQueuedPacketThread->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_EngineNetworkGroup->AddControl(this->m_NoQueuedPacketThread); - this->m_NoTimeOut = new UIX::UIXCheckBox(); - this->m_NoTimeOut->SetSize({ 125, 18 }); - this->m_NoTimeOut->SetLocation({ 155, 30 }); - this->m_NoTimeOut->SetTabIndex(0); - this->m_NoTimeOut->SetText("No time out"); - this->m_NoTimeOut->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); - this->m_EngineNetworkGroup->AddControl(this->m_NoTimeOut); + this->m_NoTimeOutToggle = new UIX::UIXCheckBox(); + this->m_NoTimeOutToggle->SetSize({ 125, 18 }); + this->m_NoTimeOutToggle->SetLocation({ 155, 30 }); + this->m_NoTimeOutToggle->SetTabIndex(0); + this->m_NoTimeOutToggle->SetText("No time out"); + this->m_NoTimeOutToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_EngineNetworkGroup->AddControl(this->m_NoTimeOutToggle); this->m_WindowedToggle = new UIX::UIXCheckBox(); @@ -365,13 +369,13 @@ void CUIBasePanel::Init() this->m_WindowedToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); this->m_EngineVideoGroup->AddControl(this->m_WindowedToggle); - this->m_BorderlessToggle = new UIX::UIXCheckBox(); - this->m_BorderlessToggle->SetSize({ 150, 18 }); - this->m_BorderlessToggle->SetLocation({ 155, 7 }); - this->m_BorderlessToggle->SetTabIndex(0); - this->m_BorderlessToggle->SetText("No border"); - this->m_BorderlessToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); - this->m_EngineVideoGroup->AddControl(this->m_BorderlessToggle); + this->m_NoBorderToggle = new UIX::UIXCheckBox(); + this->m_NoBorderToggle->SetSize({ 150, 18 }); + this->m_NoBorderToggle->SetLocation({ 155, 7 }); + this->m_NoBorderToggle->SetTabIndex(0); + this->m_NoBorderToggle->SetText("No border"); + this->m_NoBorderToggle->SetAnchor(Forms::AnchorStyles::Top | Forms::AnchorStyles::Left); + this->m_EngineVideoGroup->AddControl(this->m_NoBorderToggle); this->m_FpsTextBox = new UIX::UIXTextBox(); this->m_FpsTextBox->SetSize({ 25, 18 }); @@ -443,12 +447,138 @@ void CUIBasePanel::Init() this->PerformLayout(); // END DESIGNER CODE - this->SetBackColor({ 47, 54, 61 }); + this->SetBackColor(Drawing::Color(47, 54, 61)); +} + +void CUIBasePanel::LaunchGame(Forms::Control* pSender) +{ + string svParameter = "-launcher \"1\" -dev "; + eLaunchMode launchMode = eLaunchMode::LM_NULL; + + launchMode = g_pLauncher->GetMainSurface()->BuildParameter(svParameter); + + printf("%s\n", svParameter.c_str()); + printf("launchMode %d\n", launchMode); + + g_pLauncher->Setup(launchMode, svParameter); + g_pLauncher->Launch(); +} + +eLaunchMode CUIBasePanel::BuildParameter(string& svParameter) +{ + eLaunchMode results = eLaunchMode::LM_NULL; + + switch (static_cast(this->m_ModeCombo->SelectedIndex())) + { + case eMode::HOST: + { + // GAME ############################################################################################ + if (this->m_DevelopmentToggle->Checked()) + { + svParameter.append("+exec \"autoexec_server_dev.cfg\" "); + svParameter.append("+exec \"autoexec_client_dev.cfg\" "); + svParameter.append("+exec \"autoexec_dev.cfg\" "); + svParameter.append("+exec \"rcon_server_dev.cfg\" "); + svParameter.append("+exec \"rcon_client_dev.cfg\" "); + results = eLaunchMode::LM_HOST_DEBUG; + } + else + { + svParameter.append("+exec \"autoexec_server.cfg\" "); + svParameter.append("+exec \"autoexec_client.cfg\" "); + svParameter.append("+exec \"autoexec.cfg\" "); + svParameter.append("+exec \"rcon_server.cfg\" "); + svParameter.append("+exec \"rcon_client.cfg\" "); + results = eLaunchMode::LM_HOST; + } + + if (this->m_CheatsToggle->Checked()) + svParameter.append("+sv_cheats \"1\" "); + + if (this->m_ConsoleToggle->Checked()) + svParameter.append("-wconsole "); + + if (this->m_ColorConsoleToggle->Checked()) + svParameter.append("-ansiclr "); + + if (!String::IsNullOrEmpty(this->m_PlaylistFileTextBox->Text())) + svParameter.append("-playlistfile \"" + this->m_PlaylistFileTextBox->Text() + "\" "); + + // ENGINE ########################################################################################## + if (StringIsDigit(this->m_ReservedCoresTextBox->Text().ToCString())) + svParameter.append("-numreservedcores \"" + this->m_ReservedCoresTextBox->Text() + "\" "); + //else error; + + if (StringIsDigit(this->m_WorkerThreadsTextBox->Text().ToCString())) + svParameter.append("-numworkerthreads \"" + this->m_WorkerThreadsTextBox->Text() + "\" "); + //else error; + + if (this->m_SingleCoreDediToggle->Checked()) + svParameter.append("+sv_single_core_dedi \"1\" "); + + if (this->m_NoAsyncJobsToggle->Checked()) + { + svParameter.append("-noasync "); + svParameter.append("async_serialize \"0\" "); + svParameter.append("buildcubemaps_async \"0\" "); + svParameter.append("sv_asyncAIInit \"0\" "); + svParameter.append("sv_asyncSendSnapshot \"0\" "); + svParameter.append("sv_scriptCompileAsync \"0\" "); + svParameter.append("cl_async_bone_setup \"0\" "); + svParameter.append("cl_updatedirty_async \"0\" "); + svParameter.append("mat_syncGPU \"1\" "); + svParameter.append("mat_sync_rt \"1\" "); + svParameter.append("mat_sync_rt_flushes_gpu \"1\" "); + svParameter.append("net_async_sendto \"0\" "); + svParameter.append("physics_async_sv \"0\" "); + svParameter.append("physics_async_cl \"0\" "); + } + + if (this->m_NetEncryptionToggle->Checked()) + svParameter.append("net_encryptionEnable \"1\" "); + + if (this->m_NetRandomKeyToggle->Checked()) + svParameter.append("net_useRandomKey \"1\" "); + + if (this->m_NoQueuedPacketThread->Checked()) + svParameter.append("net_queued_packet_thread \"0\" "); + + if (this->m_NoTimeOutToggle->Checked()) + svParameter.append("-notimeout "); + + if (this->m_WindowedToggle->Checked()) + svParameter.append("-windowed "); + + if (this->m_NoBorderToggle->Checked()) + svParameter.append("-noborder "); + + if (StringIsDigit(this->m_FpsTextBox->Text().ToCString())) + svParameter.append("+fps_max \"" + this->m_FpsTextBox->Text() + "\" "); + + if (!String::IsNullOrEmpty(this->m_WidthTextBox->Text())) + svParameter.append("-w \"" + this->m_WidthTextBox->Text() + "\" "); + + if (!String::IsNullOrEmpty(this->m_HeightTextBox->Text())) + svParameter.append("-h \"" + this->m_HeightTextBox->Text() + "\" "); + + // MAIN ############################################################################################ + if (!String::IsNullOrEmpty(this->m_HostNameTextBox->Text())) + { + svParameter.append("+sv_pylonVisibility \"1\" "); + svParameter.append("+sv_pylonHostName \"" + this->m_HostNameTextBox->Text() + "\" "); + } + if (!String::IsNullOrEmpty(this->m_LaunchArgsTextBox->Text())) + svParameter.append(this->m_LaunchArgsTextBox->Text()); + + return results; + } + default: + return results; + } } CUIBasePanel::CUIBasePanel() : Forms::Form() { - g_pMainUI = this; this->Init(); } CUIBasePanel* g_pMainUI; \ No newline at end of file diff --git a/r5dev/sdklauncher/basepanel.h b/r5dev/sdklauncher/basepanel.h index 284e55c4..0ee3aa6a 100644 --- a/r5dev/sdklauncher/basepanel.h +++ b/r5dev/sdklauncher/basepanel.h @@ -1,16 +1,5 @@ #pragma once - -#include "thirdparty/cppnet/cppkore/Kore.h" -#include "thirdparty/cppnet/cppkore/UIXTheme.h" -#include "thirdparty/cppnet/cppkore/UIXLabel.h" -#include "thirdparty/cppnet/cppkore/UIXListView.h" -#include "thirdparty/cppnet/cppkore/UIXCheckBox.h" -#include "thirdparty/cppnet/cppkore/UIXComboBox.h" -#include "thirdparty/cppnet/cppkore/UIXTextBox.h" -#include "thirdparty/cppnet/cppkore/UIXGroupBox.h" -#include "thirdparty/cppnet/cppkore/UIXButton.h" -#include "thirdparty/cppnet/cppkore/UIXRadioButton.h" -#include "thirdparty/cppnet/cppkore/KoreTheme.h" +#include "sdklauncher_const.h" class CUIBasePanel : public Forms::Form { @@ -21,13 +10,26 @@ public: private: void Init(); - UIX::UIXTextBox* m_HeightTextBox; + + static void LaunchGame(Forms::Control* pSender); + eLaunchMode BuildParameter(string& svParameter); + + + enum class eMode + { + NONE = -1, + HOST, + SERVER, + CLIENT, + }; + UIX::UIXTextBox* m_WidthTextBox; + UIX::UIXTextBox* m_HeightTextBox; UIX::UIXTextBox* m_WorkerThreadsTextBox; UIX::UIXTextBox* m_ReservedCoresTextBox; UIX::UIXTextBox* m_FpsTextBox; UIX::UIXTextBox* m_PlaylistFileTextBox; - UIX::UIXTextBox* m_CustomDllTextBox; + UIX::UIXTextBox* m_HostNameTextBox; UIX::UIXTextBox* m_LaunchArgsTextBox; // Labels UIX::UIXLabel* m_WorkerThreadsLabel; @@ -38,7 +40,7 @@ private: UIX::UIXLabel* m_FpsLabel; UIX::UIXLabel* m_ResolutionLabel; UIX::UIXLabel* m_PlaylistFileLabel; - UIX::UIXLabel* m_CustomDllLabel; + UIX::UIXLabel* m_HostNameLabel; UIX::UIXLabel* m_LaunchArgsLabel; // Boxes UIX::UIXGroupBox* m_GameGroup; @@ -54,25 +56,22 @@ private: UIX::UIXCheckBox* m_DevelopmentToggle; UIX::UIXCheckBox* m_ConsoleToggle; UIX::UIXCheckBox* m_WindowedToggle; - UIX::UIXCheckBox* m_BorderlessToggle; + UIX::UIXCheckBox* m_NoBorderToggle; UIX::UIXCheckBox* m_SingleCoreDediToggle; UIX::UIXCheckBox* m_NoAsyncJobsToggle; UIX::UIXCheckBox* m_NetEncryptionToggle; UIX::UIXCheckBox* m_NetRandomKeyToggle; - UIX::UIXCheckBox* m_QueuedPacketThread; - UIX::UIXCheckBox* m_NoTimeOut; + UIX::UIXCheckBox* m_NoQueuedPacketThread; + UIX::UIXCheckBox* m_NoTimeOutToggle; UIX::UIXCheckBox* m_ColorConsoleToggle; // Combo UIX::UIXComboBox* m_MapCombo; UIX::UIXComboBox* m_PlaylistCombo; UIX::UIXComboBox* m_ModeCombo; // Buttons - UIX::UIXButton* m_LaunchGame; UIX::UIXButton* m_CleanSDK; UIX::UIXButton* m_UpdateSDK; UIX::UIXButton* m_LaunchSDK; UIX::UIXListView* m_ConsoleListView; }; - -extern CUIBasePanel* g_pMainUI; diff --git a/r5dev/sdklauncher/sdklauncher.cpp b/r5dev/sdklauncher/sdklauncher.cpp index 1626720f..6bbb68d5 100644 --- a/r5dev/sdklauncher/sdklauncher.cpp +++ b/r5dev/sdklauncher/sdklauncher.cpp @@ -1,6 +1,7 @@ #include "core/stdafx.h" -#include "sdklauncher.h" #include "basepanel.h" +#include "sdklauncher_const.h" +#include "sdklauncher.h" #include #include "gdiplus.h" #include "shellapi.h" @@ -12,6 +13,8 @@ using namespace Gdiplus; #pragma comment (lib,"Gdiplus.lib") #pragma comment (lib,"Advapi32.lib") +#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") + //----------------------------------------------------------------------------- // Purpose switch case: // * Launch the game in user specified mode and state. @@ -26,7 +29,7 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState) /////////////////////////////////////////////////////////////////////////// switch (lMode) { - case eLaunchMode::LM_DEBUG_GAME: + case eLaunchMode::LM_HOST_DEBUG: { fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_debug.cfg"; std::ifstream cfgFile(cfgPath); @@ -51,7 +54,7 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState) spdlog::info("*** LAUNCHING GAME [DEBUG] ***\n"); break; } - case eLaunchMode::LM_RELEASE_GAME: + case eLaunchMode::LM_HOST: { fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_retail.cfg"; std::ifstream cfgFile(cfgPath); @@ -76,7 +79,7 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState) spdlog::info("*** LAUNCHING GAME [RELEASE] ***\n"); break; } - case eLaunchMode::LM_DEBUG_DEDI: + case eLaunchMode::LM_SERVER_DEBUG: { fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_dedi_debug.cfg"; std::ifstream cfgFile(cfgPath); @@ -101,7 +104,7 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState) spdlog::info("*** LAUNCHING DEDICATED [DEBUG] ***\n"); break; } - case eLaunchMode::LM_RELEASE_DEDI: + case eLaunchMode::LM_SERVER: { fs::path cfgPath = fs::current_path() /= "platform\\cfg\\startup_dedi_retail.cfg"; std::ifstream cfgFile(cfgPath); @@ -145,6 +148,68 @@ bool CLauncher::Setup(eLaunchMode lMode, eLaunchState lState) return true; } +bool CLauncher::Setup(eLaunchMode lMode, const string& svCommandLine) +{ + /////////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////////// + switch (lMode) + { + case eLaunchMode::LM_HOST_DEBUG: + { + m_svWorkerDll = m_svCurrentDir + "\\gamesdk.dll"; + m_svGameExe = m_svCurrentDir + "\\r5apex.exe"; + m_svCmdLine = m_svCurrentDir + "\\r5apex.exe " + svCommandLine; + + spdlog::info("*** LAUNCHER SETUP FOR HOST [DEBUG] ***\n"); + break; + } + case eLaunchMode::LM_HOST: + { + m_svWorkerDll = m_svCurrentDir + "\\gamesdk.dll"; + m_svGameExe = m_svCurrentDir + "\\r5apex.exe"; + m_svCmdLine = m_svCurrentDir + "\\r5apex.exe " + svCommandLine; + + spdlog::info("*** LAUNCHER SETUP FOR HOST [RELEASE] ***\n"); + break; + } + case eLaunchMode::LM_SERVER_DEBUG: + { + m_svWorkerDll = m_svCurrentDir + "\\dedicated.dll"; + m_svGameExe = m_svCurrentDir + "\\r5apex_ds.exe"; + m_svCmdLine = m_svCurrentDir + "\\r5apex_ds.exe " + svCommandLine; + + spdlog::info("*** LAUNCHER SETUP FOR DEDICATED [DEBUG] ***\n"); + break; + } + case eLaunchMode::LM_SERVER: + { + m_svWorkerDll = m_svCurrentDir + "\\dedicated.dll"; + m_svGameExe = m_svCurrentDir + "\\r5apex_ds.exe"; + m_svCmdLine = m_svCurrentDir + "\\r5apex_ds.exe " + svCommandLine; + + spdlog::info("*** LAUNCHER SETUP FOR DEDICATED [RELEASE] ***\n"); + break; + } + default: + { + spdlog::error("*** INVALID LAUNCH MODE SPECIFIED ***\n"); + return false; + } + } + + /////////////////////////////////////////////////////////////////////////// + // Print the file paths and arguments. + std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl; + spdlog::debug("- CWD: {}\n", m_svCurrentDir); + spdlog::debug("- EXE: {}\n", m_svGameExe); + spdlog::debug("- DLL: {}\n", m_svWorkerDll); + spdlog::debug("- CLI: {}\n", svCommandLine); + std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl; + + return true; +} + bool CLauncher::Launch() { /////////////////////////////////////////////////////////////////////////// @@ -212,8 +277,8 @@ int main(int argc, char* argv[], char* envp[]) Forms::Application::EnableVisualStyles(); UIX::UIXTheme::InitializeRenderer(new Themes::KoreTheme()); - CUIBasePanel* mainUI = new CUIBasePanel(); - Forms::Application::Run(mainUI); + g_pLauncher->m_pMainUI = new CUIBasePanel(); + Forms::Application::Run(g_pLauncher->m_pMainUI); UIX::UIXTheme::ShutdownRenderer(); } else @@ -223,7 +288,7 @@ int main(int argc, char* argv[], char* envp[]) std::string arg = argv[i]; if ((arg == "-debug") || (arg == "-dbg")) { - if (g_pLauncher->Setup(eLaunchMode::LM_DEBUG_GAME, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_HOST_DEBUG, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -237,7 +302,7 @@ int main(int argc, char* argv[], char* envp[]) } if ((arg == "-release") || (arg == "-rel")) { - if (g_pLauncher->Setup(eLaunchMode::LM_RELEASE_GAME, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_HOST, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -251,7 +316,7 @@ int main(int argc, char* argv[], char* envp[]) } if ((arg == "-dedicated_dev") || (arg == "-dedid")) { - if (g_pLauncher->Setup(eLaunchMode::LM_DEBUG_DEDI, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_SERVER_DEBUG, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -265,7 +330,7 @@ int main(int argc, char* argv[], char* envp[]) } if ((arg == "-dedicated") || (arg == "-dedi")) { - if (g_pLauncher->Setup(eLaunchMode::LM_RELEASE_DEDI, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_SERVER, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -284,15 +349,19 @@ int main(int argc, char* argv[], char* envp[]) spdlog::warn("All FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY ConVar's/ConCommand's will be enabled.\n"); spdlog::warn("Connected clients will be able to set and execute anything flagged FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY.\n"); std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl; - spdlog::warn("Use DEBUG GAME [1] for research and development purposes.\n"); - spdlog::warn("Use RELEASE GAME [2] for playing the game and creating servers.\n"); - spdlog::warn("Use DEBUG DEDICATED [3] for research and development purposes.\n"); - spdlog::warn("Use RELEASE DEDICATED [4] for running and hosting dedicated servers.\n"); + spdlog::warn("Use DEBUG HOST [1] for research and development purposes.\n"); + spdlog::warn("Use RELEASE HOST [2] for playing the game and creating servers.\n"); + spdlog::warn("Use DEBUG SERVER [3] for research and development purposes.\n"); + spdlog::warn("Use RELEASE SERVER [4] for running and hosting dedicated servers.\n"); + spdlog::warn("Use DEBUG CLIENT [5] for research and development purposes.\n"); + spdlog::warn("Use RELEASE CLIENT [6] for running client only builds against remote servers.\n"); std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl; - spdlog::info("Enter '1' for 'DEBUG GAME'.\n"); - spdlog::info("Enter '2' for 'RELEASE GAME'.\n"); - spdlog::info("Enter '3' for 'DEBUG DEDICATED'.\n"); - spdlog::info("Enter '4' for 'RELEASE DEDICATED'.\n"); + spdlog::info("Enter '1' for 'DEBUG HOST'.\n"); + spdlog::info("Enter '2' for 'RELEASE HOST'.\n"); + spdlog::info("Enter '3' for 'DEBUG SERVER'.\n"); + spdlog::info("Enter '4' for 'RELEASE SERVER'.\n"); + spdlog::info("Enter '5' for 'DEBUG CLIENT'.\n"); + spdlog::info("Enter '6' for 'RELEASE CLIENT'.\n"); std::cout << "----------------------------------------------------------------------------------------------------------------------" << std::endl; std::cout << "User input: "; @@ -304,9 +373,9 @@ int main(int argc, char* argv[], char* envp[]) eLaunchMode mode = (eLaunchMode)std::stoi(input); switch (mode) { - case eLaunchMode::LM_DEBUG_GAME: + case eLaunchMode::LM_HOST_DEBUG: { - if (g_pLauncher->Setup(eLaunchMode::LM_DEBUG_GAME, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_HOST_DEBUG, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -318,9 +387,9 @@ int main(int argc, char* argv[], char* envp[]) Sleep(2000); return EXIT_FAILURE; } - case eLaunchMode::LM_RELEASE_GAME: + case eLaunchMode::LM_HOST: { - if (g_pLauncher->Setup(eLaunchMode::LM_RELEASE_GAME, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_HOST, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -332,9 +401,9 @@ int main(int argc, char* argv[], char* envp[]) Sleep(2000); return EXIT_FAILURE; } - case eLaunchMode::LM_DEBUG_DEDI: + case eLaunchMode::LM_SERVER_DEBUG: { - if (g_pLauncher->Setup(eLaunchMode::LM_DEBUG_DEDI, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_SERVER_DEBUG, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { @@ -346,9 +415,9 @@ int main(int argc, char* argv[], char* envp[]) Sleep(2000); return EXIT_FAILURE; } - case eLaunchMode::LM_RELEASE_DEDI: + case eLaunchMode::LM_SERVER: { - if (g_pLauncher->Setup(eLaunchMode::LM_RELEASE_DEDI, eLaunchState::LS_CHEATS)) + if (g_pLauncher->Setup(eLaunchMode::LM_SERVER, eLaunchState::LS_CHEATS)) { if (g_pLauncher->Launch()) { diff --git a/r5dev/sdklauncher/sdklauncher.h b/r5dev/sdklauncher/sdklauncher.h index 4cd8d994..e2503a11 100644 --- a/r5dev/sdklauncher/sdklauncher.h +++ b/r5dev/sdklauncher/sdklauncher.h @@ -1,27 +1,5 @@ #pragma once - -//----------------------------------------------------------------------------- -// Launch and inject specified dll based on launchmode -//----------------------------------------------------------------------------- -enum class eLaunchMode : int -{ - LM_NULL, - LM_DEBUG_GAME, // Debug worker DLL. - LM_RELEASE_GAME, // Release worker DLL. - LM_DEBUG_DEDI, // Debug dedicated DLL. - LM_RELEASE_DEDI // Release dedicated DLL. -}; - -//----------------------------------------------------------------------------- -// [TODO] Launch with FCVAR_DEVELOPMENTONLY and FCVAR_CHEATS disabled/enabled -//----------------------------------------------------------------------------- -enum class eLaunchState : int -{ - LS_NULL, - LS_NOCHEATS, // Disabled cheats - LS_CHEATS, // Enable cheats - LS_DEBUG // Enable debug -}; +#include "basepanel.h" class CLauncher { @@ -29,12 +7,22 @@ public: CLauncher() { m_svCurrentDir = fs::current_path().u8string(); + //m_pMainUI = new CUIBasePanel(); + } + ~CLauncher() + { + delete[] m_pMainUI; } bool Setup(eLaunchMode lMode, eLaunchState lState); + bool Setup(eLaunchMode lMode, const string& svCommandLine); bool Launch(); + CUIBasePanel* GetMainSurface() const { return m_pMainUI; } + + CUIBasePanel* m_pMainUI; private: + string m_svWorkerDll; string m_svGameExe; string m_svCmdLine; diff --git a/r5dev/sdklauncher/sdklauncher_const.h b/r5dev/sdklauncher/sdklauncher_const.h new file mode 100644 index 00000000..cd8bff09 --- /dev/null +++ b/r5dev/sdklauncher/sdklauncher_const.h @@ -0,0 +1,36 @@ +#pragma once + +//----------------------------------------------------------------------------- +// Launch and inject specified dll based on launchmode +//----------------------------------------------------------------------------- +//enum class eLaunchMode : int +//{ +// LM_NULL, +// LM_DEBUG_GAME, // Debug worker DLL. +// LM_RELEASE_GAME, // Release worker DLL. +// LM_DEBUG_DEDI, // Debug dedicated DLL. +// LM_RELEASE_DEDI // Release dedicated DLL. +//}; + + +enum class eLaunchMode : int +{ + LM_NULL = -1, + LM_HOST_DEBUG, + LM_HOST, + LM_SERVER_DEBUG, + LM_SERVER, + LM_CLIENT_DEBUG, + LM_CLIENT, +}; + +//----------------------------------------------------------------------------- +// [TODO] Launch with FCVAR_DEVELOPMENTONLY and FCVAR_CHEATS disabled/enabled +//----------------------------------------------------------------------------- +enum class eLaunchState : int +{ + LS_NULL, + LS_NOCHEATS, // Disabled cheats + LS_CHEATS, // Enable cheats + LS_DEBUG // Enable debug +}; \ No newline at end of file diff --git a/r5dev/thirdparty/cppnet/cppkore/StringBase.h b/r5dev/thirdparty/cppnet/cppkore/StringBase.h index 1c67e900..feaf7227 100644 --- a/r5dev/thirdparty/cppnet/cppkore/StringBase.h +++ b/r5dev/thirdparty/cppnet/cppkore/StringBase.h @@ -213,8 +213,10 @@ public: // // Whether or not the string is initialized and not blank + constexpr bool IsNullOrEmpty(); static constexpr bool IsNullOrEmpty(const StringBase& Rhs); // Whether or not the string is initialized and not whitespace + constexpr bool IsNullOrWhiteSpace(); static constexpr bool IsNullOrWhiteSpace(const StringBase& Rhs); // Formats a string based on the provided input @@ -1533,12 +1535,41 @@ inline constexpr bool StringBase::operator!=(std::basic_string_view +inline constexpr bool StringBase::IsNullOrEmpty() +{ + return (_Buffer == nullptr || _StoreSize == 0); +} + template inline constexpr bool StringBase::IsNullOrEmpty(const StringBase& Rhs) { return (Rhs._Buffer == nullptr || Rhs._StoreSize == 0); } +template +inline constexpr bool StringBase::IsNullOrWhiteSpace() +{ + if (_Buffer == nullptr) + return true; + + for (uint32_t i = 0; i < _StoreSize; i++) + { + if constexpr (sizeof(Tchar) == sizeof(char)) + { + if (!::isspace(_Buffer[i])) + return false; + } + else if constexpr (sizeof(Tchar) == sizeof(wchar_t)) + { + if (!::iswspace(_Buffer[i])) + return false; + } + } + + return true; +} + template inline constexpr bool StringBase::IsNullOrWhiteSpace(const StringBase& Rhs) { diff --git a/r5dev/tier1/cmd.cpp b/r5dev/tier1/cmd.cpp index d02a5858..4446aed0 100644 --- a/r5dev/tier1/cmd.cpp +++ b/r5dev/tier1/cmd.cpp @@ -82,7 +82,7 @@ const char* CCommand::operator[](int nIndex) const //----------------------------------------------------------------------------- bool CCommand::HasOnlyDigits(int nIndex) const { - std::string svString = Arg(nIndex); + string svString = Arg(nIndex); for (const char& character : svString) { if (std::isdigit(character) == 0) diff --git a/r5dev/vproj/sdklauncher.vcxproj b/r5dev/vproj/sdklauncher.vcxproj index 7a05433b..dfd7be39 100644 --- a/r5dev/vproj/sdklauncher.vcxproj +++ b/r5dev/vproj/sdklauncher.vcxproj @@ -142,6 +142,7 @@ + diff --git a/r5dev/vproj/sdklauncher.vcxproj.filters b/r5dev/vproj/sdklauncher.vcxproj.filters index 677fe4b3..0871ceb3 100644 --- a/r5dev/vproj/sdklauncher.vcxproj.filters +++ b/r5dev/vproj/sdklauncher.vcxproj.filters @@ -1,76 +1,86 @@  - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + {ce3f4cd9-6eb2-4133-b109-869c24225000} - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + {9dcfc3ae-597b-4e7a-8e51-11e438faa7f6} - + + {ba246dd9-0473-49d6-8cc0-64330570b81f} + + + {c593f57d-6b04-46e8-8778-02dcafaf969c} + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - + + {b9c3ead5-38a0-4e31-8446-df55ebcbdb66} + + {82b18787-373d-42ce-8d8d-1e3adba8d3a0} - + {dc968871-7ca2-452b-a5b1-350a12dd54aa} - - Source Files - - Source Files + core - Source Files + public - Source Files + ui + + + launcher - Resource Files + resource - - Header Files - - - Header Files - - - Header Files - - Detours Files\include + thirdparty\detours\include - Detours Files\include + thirdparty\detours\include - Detours Files\include + thirdparty\detours\include + + + core - Header Files + public - Header Files + ui + + + launcher + + + launcher + + + launcher - Resource Files + resource - Resource Files + resource \ No newline at end of file