mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fixed several bugs in the GameConsole class
Fixed several bugs in the GameConsole class caused by a single variable that shouldn't be initialized where it was. Fixed GameConsole glitch on right mouse click event
This commit is contained in:
parent
7495f1b4fa
commit
5d92c8c226
@ -9,6 +9,6 @@ void ToggleNetHooks();
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Globals
|
// Globals
|
||||||
inline bool g_bDebugLog = false;
|
inline bool g_bDebugLoading = false;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -141,7 +141,7 @@ DWORD __stdcall ProcessConsoleWorker(LPVOID)
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Exec toggles
|
// Exec toggles
|
||||||
if (sCommand == "1") { ToggleDevCommands(); CommandExecute(NULL, "exec autoexec_dev"); }
|
if (sCommand == "1") { ToggleDevCommands(); CommandExecute(NULL, "exec autoexec_dev"); }
|
||||||
if (sCommand == "2") { g_bDebugLog = !g_bDebugLog; continue; }
|
if (sCommand == "2") { g_bDebugLoading = !g_bDebugLoading; continue; }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Execute the command in the r5 SQVM
|
// Execute the command in the r5 SQVM
|
||||||
|
@ -88,7 +88,7 @@ bool HSQVM_LoadScript(void* sqvm, const char* script_path, const char* script_na
|
|||||||
filepath[i] = '\\';
|
filepath[i] = '\\';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (g_bDebugLog)
|
if (g_bDebugLoading)
|
||||||
{
|
{
|
||||||
printf(" [+] Loading SQVM Script '%s' ...\n", filepath);
|
printf(" [+] Loading SQVM Script '%s' ...\n", filepath);
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ bool HSQVM_LoadScript(void* sqvm, const char* script_path, const char* script_na
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (g_bDebugLog)
|
if (g_bDebugLoading)
|
||||||
{
|
{
|
||||||
printf(" [!] FAILED. Try SP / VPK for '%s'\n", filepath);
|
printf(" [!] FAILED. Try SP / VPK for '%s'\n", filepath);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "id3dx.h"
|
#include "id3dx.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
|
#include "console.h"
|
||||||
#include "detours.h"
|
#include "detours.h"
|
||||||
#include "overlay.h"
|
#include "overlay.h"
|
||||||
#include "patterns.h"
|
#include "patterns.h"
|
||||||
@ -32,6 +33,7 @@ typedef BOOL(WINAPI* IPostMessageW)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM l
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
extern BOOL g_bShowMenu = false;
|
extern BOOL g_bShowMenu = false;
|
||||||
|
static BOOL g_bInitMenu = false;
|
||||||
static BOOL g_bInitialized = false;
|
static BOOL g_bInitialized = false;
|
||||||
static BOOL g_bPresentHooked = false;
|
static BOOL g_bPresentHooked = false;
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ LRESULT CALLBACK DXGIMsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK HWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK HwndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (uMsg == WM_KEYDOWN)
|
if (uMsg == WM_KEYDOWN)
|
||||||
{
|
{
|
||||||
@ -72,7 +74,6 @@ LRESULT CALLBACK HWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
if (g_bShowMenu)
|
if (g_bShowMenu)
|
||||||
{//////////////////////////////////////////////////////////////////////////////
|
{//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
|
ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam);
|
||||||
g_bBlockInput = true;
|
g_bBlockInput = true;
|
||||||
|
|
||||||
@ -169,7 +170,7 @@ void GetPresent()
|
|||||||
RegisterClassExA(&wc);
|
RegisterClassExA(&wc);
|
||||||
|
|
||||||
HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL);
|
HWND hWnd = CreateWindowA("DX", NULL, WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, NULL, NULL, wc.hInstance, NULL);
|
||||||
DXGI_SWAP_CHAIN_DESC sd;
|
DXGI_SWAP_CHAIN_DESC sd = { 0 };
|
||||||
D3D_FEATURE_LEVEL nFeatureLevelsSet = D3D_FEATURE_LEVEL_11_0;
|
D3D_FEATURE_LEVEL nFeatureLevelsSet = D3D_FEATURE_LEVEL_11_0;
|
||||||
D3D_FEATURE_LEVEL nFeatureLevelsSupported;
|
D3D_FEATURE_LEVEL nFeatureLevelsSupported;
|
||||||
|
|
||||||
@ -272,8 +273,21 @@ void DrawImGui()
|
|||||||
if (g_bShowMenu)
|
if (g_bShowMenu)
|
||||||
{
|
{
|
||||||
bool bShowMenu = true;
|
bool bShowMenu = true;
|
||||||
|
if (!g_bInitMenu)
|
||||||
|
{
|
||||||
|
CommandExecute(NULL, "gameui_activate");
|
||||||
|
g_bInitMenu = true;
|
||||||
|
}
|
||||||
ShowGameConsole(&bShowMenu);
|
ShowGameConsole(&bShowMenu);
|
||||||
}
|
}
|
||||||
|
else if(!g_bShowMenu)
|
||||||
|
{
|
||||||
|
if (g_bInitMenu)
|
||||||
|
{
|
||||||
|
CommandExecute(NULL, "gameui_hide");
|
||||||
|
g_bInitMenu = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::EndFrame();
|
ImGui::EndFrame();
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
@ -370,7 +384,7 @@ HRESULT __stdcall Present(IDXGISwapChain* pSwapChain, UINT nSyncInterval, UINT n
|
|||||||
|
|
||||||
if (g_oWndProc == nullptr)
|
if (g_oWndProc == nullptr)
|
||||||
{ // Only initialize hWndProc pointer once to avoid stack overflow during ResizeBuffers(..)
|
{ // Only initialize hWndProc pointer once to avoid stack overflow during ResizeBuffers(..)
|
||||||
g_oWndProc = (WNDPROC)SetWindowLongPtr(g_hGameWindow, GWLP_WNDPROC, (LONG_PTR)HWndProc);
|
g_oWndProc = (WNDPROC)SetWindowLongPtr(g_hGameWindow, GWLP_WNDPROC, (LONG_PTR)HwndProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_bInitialized = true;
|
g_bInitialized = true;
|
||||||
|
@ -22,7 +22,7 @@ static IClipCursor g_oClipCursor = nullptr;
|
|||||||
static IShowCursor g_oShowCursor = nullptr;
|
static IShowCursor g_oShowCursor = nullptr;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
static POINT g_pLastCursorPos = { 0 };
|
static POINT g_pLastCursorPos { 0 };
|
||||||
extern BOOL g_bBlockInput = false;
|
extern BOOL g_bBlockInput = false;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -113,15 +113,12 @@ public:
|
|||||||
ImGui::SetWindowPos(ImVec2(-1000, 50), ImGuiCond_FirstUseEver);
|
ImGui::SetWindowPos(ImVec2(-1000, 50), ImGuiCond_FirstUseEver);
|
||||||
if (!ImGui::Begin(title, p_open))
|
if (!ImGui::Begin(title, p_open))
|
||||||
{
|
{
|
||||||
g_bShowMenu = false;
|
|
||||||
ImGui::End(); return;
|
ImGui::End(); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p_open == NULL)
|
if (*p_open == NULL)
|
||||||
{
|
{
|
||||||
g_bShowMenu = false;
|
g_bShowMenu = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
if (ImGui::SmallButton("Developer mode"))
|
if (ImGui::SmallButton("Developer mode"))
|
||||||
{
|
{
|
||||||
@ -140,7 +137,6 @@ public:
|
|||||||
AddLog("+--------------------------------------------------------+\n");
|
AddLog("+--------------------------------------------------------+\n");
|
||||||
ExecCommand("exec netchan");
|
ExecCommand("exec netchan");
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::SmallButton("Clear"))
|
if (ImGui::SmallButton("Clear"))
|
||||||
@ -159,7 +155,7 @@ public:
|
|||||||
ImGui::OpenPopup("Options");
|
ImGui::OpenPopup("Options");
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
Filter.Draw("Filter [\"-incl,-excl\"] [\"error\"]", 180);
|
Filter.Draw("Filter [\"-incl,-excl\"] [\"error\"]", 265);
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// Reserve enough left-over height for 1 separator + 1 input text
|
// Reserve enough left-over height for 1 separator + 1 input text
|
||||||
@ -168,20 +164,17 @@ public:
|
|||||||
///////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////
|
||||||
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), true, ImGuiWindowFlags_AlwaysVerticalScrollbar);
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 4.f, 6.f });
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 4.f, 6.f });
|
||||||
if (ImGui::BeginPopupContextWindow())
|
if (copy_to_clipboard)
|
||||||
{
|
{
|
||||||
if (ImGui::Selectable("Clear"))
|
ImGui::LogToClipboard();
|
||||||
{
|
|
||||||
ClearLog();
|
|
||||||
ImGui::EndPopup();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (copy_to_clipboard) { ImGui::LogToClipboard(); }
|
|
||||||
for (int i = 0; i < Items.Size; i++)
|
for (int i = 0; i < Items.Size; i++)
|
||||||
{
|
{
|
||||||
const char* item = Items[i];
|
const char* item = Items[i];
|
||||||
if (!Filter.PassFilter(item)) { continue; }
|
if (!Filter.PassFilter(item))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
ImVec4 color;
|
ImVec4 color;
|
||||||
bool has_color = false;
|
bool has_color = false;
|
||||||
@ -249,7 +242,7 @@ public:
|
|||||||
colors[ImGuiCol_FrameBgActive] = ImVec4(0.21f, 0.21f, 0.21f, 1.00f);
|
colors[ImGuiCol_FrameBgActive] = ImVec4(0.21f, 0.21f, 0.21f, 1.00f);
|
||||||
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
|
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
|
||||||
colors[ImGuiCol_TitleBgActive] = ImVec4(0.06f, 0.06f, 0.06f, 1.00f);
|
colors[ImGuiCol_TitleBgActive] = ImVec4(0.06f, 0.06f, 0.06f, 1.00f);
|
||||||
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
|
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
|
||||||
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
|
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
|
||||||
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
|
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
|
||||||
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
|
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
|
||||||
@ -369,6 +362,7 @@ public:
|
|||||||
for (int i = first > 0 ? first : 0; i < History.Size; i++) { AddLog("%3d: %s\n", i, History[i]); }
|
for (int i = first > 0 ? first : 0; i < History.Size; i++) { AddLog("%3d: %s\n", i, History[i]); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// On command input, we scroll to bottom even if AutoScroll==false
|
||||||
ScrollToBottom = true;
|
ScrollToBottom = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user