diff --git a/r5dev/sdklauncher/basepanel.cpp b/r5dev/sdklauncher/basepanel.cpp index ac221ad6..684a3bbc 100644 --- a/r5dev/sdklauncher/basepanel.cpp +++ b/r5dev/sdklauncher/basepanel.cpp @@ -441,7 +441,7 @@ void CUIBaseSurface::Init() this->AddControl(this->m_ConsoleGroupExt); this->m_ConsoleListView = new UIX::UIXListView(); - this->m_ConsoleListView->SetSize({ 427, 189 }); + this->m_ConsoleListView->SetSize({ 427, 172 }); this->m_ConsoleListView->SetLocation({ 1, -23 }); // Hide columns this->m_ConsoleListView->SetTabIndex(0); this->m_ConsoleListView->SetBackColor(Drawing::Color(29, 33, 37)); @@ -455,6 +455,26 @@ void CUIBaseSurface::Init() this->m_ConsoleListView->RetrieveVirtualItem += &GetVirtualItem; this->m_ConsoleGroupExt->AddControl(this->m_ConsoleListView); + + this->m_ConsoleCommandTextBox = new UIX::UIXTextBox(); + this->m_ConsoleCommandTextBox->SetSize({ 350, 18 }); + this->m_ConsoleCommandTextBox->SetLocation({ 0, 149 }); + this->m_ConsoleCommandTextBox->SetTabIndex(0); + this->m_ConsoleCommandTextBox->SetReadOnly(false); + this->m_ConsoleCommandTextBox->SetText(""); + this->m_ConsoleCommandTextBox->SetAnchor(Forms::AnchorStyles::Bottom | Forms::AnchorStyles::Left); + this->m_ConsoleGroupExt->AddControl(this->m_ConsoleCommandTextBox); + + this->m_ConsoleSendCommand = new UIX::UIXButton(); + this->m_ConsoleSendCommand->SetSize({ 79, 18 }); + this->m_ConsoleSendCommand->SetLocation({ 350, 149 }); + this->m_ConsoleSendCommand->SetTabIndex(0); + this->m_ConsoleSendCommand->SetText("Send"); + this->m_ConsoleSendCommand->SetBackColor(Drawing::Color(3, 102, 214)); + this->m_ConsoleSendCommand->SetAnchor(Forms::AnchorStyles::None); + this->m_ConsoleSendCommand->Click += &ForwardCommandToGame; + this->m_ConsoleGroupExt->AddControl(this->m_ConsoleSendCommand); + this->ResumeLayout(false); this->PerformLayout(); @@ -648,6 +668,32 @@ void CUIBaseSurface::GetVirtualItem(const std::unique_ptr(pSender->FindForm()); + + const HWND hWindow = FindWindowA("Respawn001", NULL); + if (hWindow) + { + String kzCommand = pSurface->m_ConsoleCommandTextBox->Text(); + const char* szCommand = kzCommand.ToCString(); + COPYDATASTRUCT cData = { 0, strnlen_s(szCommand, 259) + 1, (void*)szCommand }; + + bool bProcessingMessage = SendMessageA(hWindow, WM_COPYDATA, NULL, (LPARAM)&cData); // WM_COPYDATA will only return 0 or 1, that's why we use a boolean. + if (bProcessingMessage) + { + pSurface->m_ConsoleCommandTextBox->SetText(""); + pSurface->m_LogList.push_back(LogList_t((spdlog::level::level_enum)2, kzCommand)); + pSurface->m_ConsoleListView->SetVirtualListSize(static_cast(pSurface->m_LogList.size())); + pSurface->m_ConsoleListView->Refresh(); + } + } +} + //----------------------------------------------------------------------------- // Purpose: clears the form and reloads the playlist // Input : &svParameters - diff --git a/r5dev/sdklauncher/basepanel.h b/r5dev/sdklauncher/basepanel.h index 60479ca5..1dace68e 100644 --- a/r5dev/sdklauncher/basepanel.h +++ b/r5dev/sdklauncher/basepanel.h @@ -33,6 +33,7 @@ private: static void ReloadPlaylists(Forms::Control* pSender); static void VirtualItemToClipboard(const std::unique_ptr& pEventArgs, Forms::Control* pSender); static void GetVirtualItem(const std::unique_ptr& pEventArgs, Forms::Control* pSender); + static void ForwardCommandToGame(Forms::Control* pSender); eLaunchMode BuildParameter(string& svParameter); enum class eMode @@ -56,6 +57,7 @@ private: UIX::UIXTextBox* m_PlaylistFileTextBox; UIX::UIXTextBox* m_HostNameTextBox; UIX::UIXTextBox* m_LaunchArgsTextBox; + UIX::UIXTextBox* m_ConsoleCommandTextBox; // Labels UIX::UIXLabel* m_WorkerThreadsLabel; UIX::UIXLabel* m_ReservedCoresLabel; @@ -100,4 +102,5 @@ private: UIX::UIXButton* m_CleanSDK; UIX::UIXButton* m_UpdateSDK; UIX::UIXButton* m_LaunchSDK; + UIX::UIXButton* m_ConsoleSendCommand; };