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.
This commit is contained in:
Kawe Mazidjatari 2022-05-24 02:23:37 +02:00
parent 7225de1bd4
commit dacd307663
13 changed files with 459 additions and 161 deletions

View File

@ -5,10 +5,12 @@
#include <windows.h>
#include <WinSock2.h>
#include <comdef.h>
#include <gdiplus.h>
#include <shellapi.h>
#include <Psapi.h>
#include <setjmp.h>
#include <tchar.h>
#include <stdio.h>
#include <Psapi.h>
#include <shlobj.h>
#include <objbase.h>
#include <intrin.h>
@ -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"

View File

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

View File

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

View File

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

View File

@ -1,12 +1,11 @@
#include "core/stdafx.h"
#include "sdklauncher.h"
#include "basepanel.h"
#include <objidl.h>
#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<eMode>(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;

View File

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

View File

@ -1,6 +1,7 @@
#include "core/stdafx.h"
#include "sdklauncher.h"
#include "basepanel.h"
#include "sdklauncher_const.h"
#include "sdklauncher.h"
#include <objidl.h>
#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())
{

View File

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

View File

@ -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
};

View File

@ -213,8 +213,10 @@ public:
//
// Whether or not the string is initialized and not blank
constexpr bool IsNullOrEmpty();
static constexpr bool IsNullOrEmpty(const StringBase<Tchar>& Rhs);
// Whether or not the string is initialized and not whitespace
constexpr bool IsNullOrWhiteSpace();
static constexpr bool IsNullOrWhiteSpace(const StringBase<Tchar>& Rhs);
// Formats a string based on the provided input
@ -1533,12 +1535,41 @@ inline constexpr bool StringBase<Tchar>::operator!=(std::basic_string_view<Tchar
return !(*this == Rhs);
}
template<class Tchar>
inline constexpr bool StringBase<Tchar>::IsNullOrEmpty()
{
return (_Buffer == nullptr || _StoreSize == 0);
}
template<class Tchar>
inline constexpr bool StringBase<Tchar>::IsNullOrEmpty(const StringBase<Tchar>& Rhs)
{
return (Rhs._Buffer == nullptr || Rhs._StoreSize == 0);
}
template<class Tchar>
inline constexpr bool StringBase<Tchar>::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<class Tchar>
inline constexpr bool StringBase<Tchar>::IsNullOrWhiteSpace(const StringBase<Tchar>& Rhs)
{

View File

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

View File

@ -142,6 +142,7 @@
<ClInclude Include="..\public\include\utility.h" />
<ClInclude Include="..\sdklauncher\basepanel.h" />
<ClInclude Include="..\sdklauncher\sdklauncher.h" />
<ClInclude Include="..\sdklauncher\sdklauncher_const.h" />
<ClInclude Include="..\sdklauncher\sdklauncher_res.h" />
<ClInclude Include="..\thirdparty\detours\include\detours.h" />
<ClInclude Include="..\thirdparty\detours\include\detver.h" />

View File

@ -1,76 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
<Filter Include="ui">
<UniqueIdentifier>{ce3f4cd9-6eb2-4133-b109-869c24225000}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
<Filter Include="core">
<UniqueIdentifier>{9dcfc3ae-597b-4e7a-8e51-11e438faa7f6}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<Filter Include="public">
<UniqueIdentifier>{ba246dd9-0473-49d6-8cc0-64330570b81f}</UniqueIdentifier>
</Filter>
<Filter Include="launcher">
<UniqueIdentifier>{c593f57d-6b04-46e8-8778-02dcafaf969c}</UniqueIdentifier>
</Filter>
<Filter Include="resource">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Detours Files">
<Filter Include="thirdparty">
<UniqueIdentifier>{b9c3ead5-38a0-4e31-8446-df55ebcbdb66}</UniqueIdentifier>
</Filter>
<Filter Include="thirdparty\detours">
<UniqueIdentifier>{82b18787-373d-42ce-8d8d-1e3adba8d3a0}</UniqueIdentifier>
</Filter>
<Filter Include="Detours Files\include">
<Filter Include="thirdparty\detours\include">
<UniqueIdentifier>{dc968871-7ca2-452b-a5b1-350a12dd54aa}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\sdklauncher\sdklauncher.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\core\stdafx.cpp">
<Filter>Source Files</Filter>
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="..\public\utility.cpp">
<Filter>Source Files</Filter>
<Filter>public</Filter>
</ClCompile>
<ClCompile Include="..\sdklauncher\basepanel.cpp">
<Filter>Source Files</Filter>
<Filter>ui</Filter>
</ClCompile>
<ClCompile Include="..\sdklauncher\sdklauncher.cpp">
<Filter>launcher</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\resource\sdklauncher.rc">
<Filter>Resource Files</Filter>
<Filter>resource</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\core\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sdklauncher\sdklauncher.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\sdklauncher\sdklauncher_res.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\thirdparty\detours\include\detver.h">
<Filter>Detours Files\include</Filter>
<Filter>thirdparty\detours\include</Filter>
</ClInclude>
<ClInclude Include="..\thirdparty\detours\include\syelog.h">
<Filter>Detours Files\include</Filter>
<Filter>thirdparty\detours\include</Filter>
</ClInclude>
<ClInclude Include="..\thirdparty\detours\include\detours.h">
<Filter>Detours Files\include</Filter>
<Filter>thirdparty\detours\include</Filter>
</ClInclude>
<ClInclude Include="..\core\stdafx.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="..\public\include\utility.h">
<Filter>Header Files</Filter>
<Filter>public</Filter>
</ClInclude>
<ClInclude Include="..\sdklauncher\basepanel.h">
<Filter>Header Files</Filter>
<Filter>ui</Filter>
</ClInclude>
<ClInclude Include="..\sdklauncher\sdklauncher.h">
<Filter>launcher</Filter>
</ClInclude>
<ClInclude Include="..\sdklauncher\sdklauncher_res.h">
<Filter>launcher</Filter>
</ClInclude>
<ClInclude Include="..\sdklauncher\sdklauncher_const.h">
<Filter>launcher</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="..\resource\ico\sdklauncher_rel.ico">
<Filter>Resource Files</Filter>
<Filter>resource</Filter>
</Image>
<Image Include="..\resource\ico\sdklauncher_dbg.ico">
<Filter>Resource Files</Filter>
<Filter>resource</Filter>
</Image>
</ItemGroup>
</Project>