Moved implementation to dedicated class 'CImguiSystem' with the following changes:
* Added mutex for ImGui_ImplWin32_WndProcHandler(), the window proc is ran from a different thread than CImguiSystem::SampleFrame() is being called from. Needs a mutex as both functions interact with the input queue list.
* Added init stages for debugging and preventing the system from running certain parts of the code if a certain stage hasn't been reached yet.
* NULL out ImGuiContext::ConfigNavWindowingKeyNext , we don't need any nav window shortcuts as users don't need then in-game, and it also interferes with certain key binds some users have.
* CImguiSystem::SampleFrame() (previously ImguiSystem_SampleFrame()), is now being called from CMaterialSystem::SwapBuffers(), as that function is called from the main thread while also getting updated during level loads/etc, so instead of switching between 2 static buffers for as long as the levels are being loaded, we imgui updates properly too and directly swap afterwards.
* Removed hack in CGame::WindowProc() where we would only run windowproc if we aren't shutting the game down. This was needed as there was a chance of a crash at some rare cases, but this was simply due to a missing mutex which has been addressed and fixed as of this commit.
* Lock mutex during init and shutdown.
ImGui drawing code now takes place in the main thread, a snapshot of the render data is created in CMaterialSystem::SwapBuffers(), and is being rendered in the render thread right before SpinPresent().
The reason why this was necessary, is because ConVar::GetString() isn't thread safe if its not marked FCVAR_MATERIAL_SYSTEM_THREAD or FCVAR_ACCESSIBLE_FROM_THREADS, and we used it for the console suggestions window, which iterates over every ConVar, accessible from threads or not.
Avoid heap memory allocation and a level of indirection. This allows the compiler to optimize the program even more. No logic has been changed in this patch.
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
These are hardcoded delay values for if you want to pick and swap an item from the ground. Perhaps nice to make a cvar and an in-game UI setting for adjusting them.
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
Don't run the 'ImGui_ImplWin32_WndProcHandler' if we are shutting down. During rare occasions when closing the game while hovering over the game window, 'ImGui_ImplWin32_WndProcHandler' is getting called while parts or all of the ImGui systems have been shut down, leading to a crash. The fix is to check if the engine is restarting or shutting down before running the ImGui window procedure logic.
When and after 'Host_Shutdown()' is called, the window handle is still valid, thus the handler still gets called. This gets destroyed in 'OnShutdown()' called from 'CEngineAPI::RunListenServer()'. But we do shutdown the ImGui implementation in 'Host_Shutdown()'... Therefore, we should check if the implementation is initialized or not before running the window procedure handler.
Refactored code to only feature game pointers, this avoids the unnecessary overhead that was previously caused by creating our own device pointers, swapchain, etc.. This commit also fixes the classic 'black screen' problem when the aspect ratio is set to 4:3 - 5:4, however, a similar bug returned for this causing Dear ImGui to not draw at all when the aspect ratio is set to 4:3 - 5:4. This commit also moves the old HwndProc hook to 'CGame::WindowProc'.
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.
TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
the parameter check for '-novid' has been removed from S2 onwards, but later added back in. Our S3 build doesn't have it as well. This commit adds it back in and allows user to launch the game without the startup video's by adding '-novid' to the launch arguments. ('-dev' also works, but this enables developer and sv_cheats..).