45 Commits

Author SHA1 Message Date
Kawe Mazidjatari
a7158d0881 CConsole::AddLog optimizations
Use FormatV to format the string, and use the move constructor to move it into the conlog structure.
2023-04-01 21:42:34 +02:00
Kawe Mazidjatari
f9c5986245 Upgrade Dear ImGui to 1.89.4
Upgrade and light restructure of ImGui directory.
2023-03-29 00:19:19 +02:00
Kawe Mazidjatari
a8ef2b74cd Implement ConCommand completion logic
Implementation of the ConCommand completion logic for the Dear ImGui console panel.
2023-02-05 19:21:39 +01:00
Kawe Mazidjatari
5dd5f2ad11 Fix issue caused by iData->BufTextLen always being NULL in ImGuiInputTextFlags_CallbackCharFilter
iData->BufTextLen is always 0 in the ImGuiInputTextFlags_CallbackCharFilter event. ImGuiInputTextFlags_CallbackAlways is called before ImGuiInputTextFlags_CallbackCharFilter in the same frame, so we can obtain the lenght from there and perform the test to discard unwanted characters from the input field.
2022-11-10 22:01:34 +01:00
Kawe Mazidjatari
a8fd5a24f5 Add flag textures and logic for 3 or more flags
Only check if FCVAR_DEVELOPMENTONLY or FCVAR_CHEAT is set and return a blue/red colored checkered texture. Return a rainbow checkered if 3 or more flags are encountered which are not indexed. Return half texture if 2 flags are encountered, but the second bit is not indexed.
2022-11-10 01:17:53 +01:00
Kawe Mazidjatari
3b5428051c CConsole cleanup and optimizations
* Add const qualifier to method 'GetHistory'.
* Acquire mutex lock at the start of new method 'RemoveLog'.
2022-10-24 00:50:07 +02:00
Kawe Mazidjatari
5f84803ac6 ImGui and DirectX code improvements
* Fix history duplication by removing trailing white space characters from submitted commands in console.
* Fix out of range exception caused by caching svConVar.size() in CConsole::BuildSummary while we are modifying it.
* Fixed memory leak  caused by extraneous Strdup calls in CConsole.
* Renamed variables and structure members, static vars in id3dx.cpp are not prefixed with s_, IBrowser_Config is now m_BrowserConfig.
* Performed code cleanup in id3dx.cpp.
2022-10-20 12:29:50 +02:00
Kawe Mazidjatari
44f2f87460 CConsole: heavy cleanup
* Move all default assignments to constructor.
* Rename cvar 'con_max_size_logvector' to 'con_max_lines'.
* Rename cvar 'con_max_size_history' to 'con_max_history'.
* Use array indexes instead of hardcoding context prefixes.
* Added netcon context prefix to help legend.
* Added public method to obtain history as string vector.
* Added public method to clear history.
* Internal CConsole::AddLog no longer locks the mutex.
* CConsole::LoadFlagIcons accesses resource vector by reference.
* Implemented "HELP", "HISTORY" and "CLEAR" as real console commands: "con_help", "con_history", "con_clearlines".
* Added a new command "con_clearhistory" (clears the dev console submission history).
2022-10-20 12:29:50 +02:00
Kawe Mazidjatari
d113774a6d Console improvements and new command
* Commented "ImGui::SetItemDefaultFocus()", this seems to somewhat fix the issue where the input field does not claim focus on console invocation.
* Added command "con_removeline" (removes lines from start to end index).
2022-10-20 12:29:49 +02:00
Kawe Mazidjatari
900cc4dd9a CConsole: remove 'ImGuiInputTextFlags_NoUndoRedo' flag
The buffer desync defect has been fixed as of Dear ImGui v1.88.
You can now undo/redo console input.
2022-09-02 02:24:04 +02:00
Kawe Mazidjatari
54fc85e1d3 CConsole: modify input chars using the callback
Light preparation for when the lib gets updated to 1.88 to enable undo/redo again.
2022-09-02 01:18:36 +02:00
Kawe Mazidjatari
eca922d3df Fix console autocomplete window not padding elements correctly when size is between the clamped values 2022-08-31 13:00:02 +02:00
Kawe Mazidjatari
3414a2cd2c ImGui panel improvements
* Eliminated all forms of concurrency for CConsole logger.
* Used enum for determining which theme user loaded (DEFAULT, LEGACY, MODERN).
* Fixed issue where browser panel doesn't have the same frame padding as the console for the modern theme.
* Fixed issue where the history items count shows number higher than maximum until updated (updates vector before displaying, else this happens in g_pConsole->RunTask which is the operation that happens before we add new elements to the vector, thus showing the wrong count as this size is getting corrected the next frame after we painted, we don't update the summary each frame for performance reasons).
2022-08-22 01:10:18 +02:00
Kawe Mazidjatari
8476d22777 Fix concurrent access to several CConsole members
* Fix concurrent access to CConsole::m_Logger.
* Fix concurrent access to CConsole::m_vHistory.
* Additional DX system cleanup.
2022-08-21 19:35:06 +02:00
Kawe Mazidjatari
52e19e9ad6 Single-thread the game console
Run all task in the same thread used to run the browser/console frame and remove all mutexes.
2022-08-20 01:48:42 +02:00
Kawe Mazidjatari
bf3b7bdace Server browser cleanup
* Moved server utility to dedicated class shared by browser panel and UI script VM.
* Additional code improvements and optimizations.
2022-08-14 15:43:49 +02:00
Kawe Mazidjatari
3323c3fadb Small ImGui theme adjustments 2022-06-27 14:48:03 +02:00
Kawe Mazidjatari
98c43fd6c1 Rename CConLog to ConLog_t 2022-06-26 17:40:02 +02:00
Kawe Mazidjatari
2da11d2d32 Disable undo/redo in command input
Currently causes undefined behavior, though it rarely crashes (I couldn't reproduce the crash, but do get undefined behavior by having random memory end up in the input field, or similar)
Problem probably is because we don't store any undo/redo buffer.
For now disabled, will revisit in the future.
2022-06-26 17:14:32 +02:00
Kawe Mazidjatari
efe71fbe24 ImGui console UX improvements
* Fixed click-through parent window.
* Keep selection position when lines get cleared.
* Keep cursor position when lines get cleared.
* Ensure cursor visibility when dragging cursor outside rect.
* Falter free scrolling in autocomplete window.
* Falter free scrolling in logging window (window no longer stutters when lines get cleared).
2022-06-26 16:47:00 +02:00
Kawe Mazidjatari
add5c577ff Improve ImGui theme system
-imgui_theme "modern" = Respawn theme.
-imgui_theme "legacy" = Valve theme.
No args = default theme.
2022-06-24 12:22:04 +02:00
Kawe Mazidjatari
978c43250f Console cleanup and optimizations
Proper usage of callbacks, no longer use string comparisons to check if buffer changed.
Improved optimizations with avg 5000 clocks in release and avg 600000 clocks in debug (no filter).
2022-06-22 03:24:46 +02:00
Kawe Mazidjatari
76ec4b8f4a Improve console scrolling
Moved auto scrolling logic to CTextLogger.
Removed redundant code in CTextLogger.
Added bool param to CTextLogger::RemoveLine to determine whether or not to lock the mutex (internal operations should not lock).
Fixed issue where scrolling with cursor is not possible when auto-scroll is set or ScrollY is towards its max.
Fixed copy button (copy all text in console via GUI, ctrl + a - ctrl + v alternative).
2022-06-21 23:25:15 +02:00
Kawe Mazidjatari
da299a002c Reimplement text filter
Could be better at some point, currently removes anything not matching criteria resulting in gaps.
But on the other side it might be good as the location of all occurrences are known (should make it easier to see when it is logged during the process).

Revisit in the future.
2022-06-20 20:21:52 +02:00
Kawe Mazidjatari
1764f039cf CConsole improvements: Add selectable logger text
CConsole now uses a dedicated class for logging text (modified CTextEditor class (CTextLogger)). The class uses an ImDraw list with a character vector to draw the text.

Text could be selected by double click (word), triple click (line), a selection by dragging the cursor, or everything with 'ctrl + a'.
2022-06-20 10:31:09 +02:00
Kawe Mazidjatari
2c954da789 Light CConsole class cleanup 2022-06-18 18:11:05 +02:00
Kawe Mazidjatari
aaf6e46871 ImGui panel improvements
Slight optimizations and cleanup.
Added fade-in effect.
2022-06-09 02:22:01 +02:00
Kawe Mazidjatari
83c57fbd99 Fix compiler error 2022-05-27 22:31:12 +02:00
Kawe Mazidjatari
112f0a25b7 Update IConsole.h 2022-05-27 16:29:47 +02:00
Kawe Mazidjatari
bcd75b354a Fix suggest window drawing below server browser window 2022-05-27 16:28:37 +02:00
Kawe Mazidjatari
e6ef3d71f1 Rename variable 'g_pIConsole' to 'g_pConsole' 2022-05-27 02:46:13 +02:00
Amos
473db0e320 Finish game console optimizations
The console no longer should cause huge frame drops when the vector size increases around its max size
2022-05-10 13:26:03 +02:00
Kawe Mazidjatari
611ea6447a Console performance improvements and bug fixes
* Heavily reduced string compares for coloring logs (the left overs require a dedicated hook, this is for the future)
The new method uses a ImVec 4 constant containing the color obtained via a switch case by context, this is then out into the new CConLog structure where the loop in the console will now gather the colors directly from.
Error/Warning use a single constant.

* Fixed bugs in several log locations where the ostringstream was cleared before the emission causing double logs.

* Added global log mutex to log wrappers that lacked those.
2022-05-09 02:20:07 +02:00
Kawe Mazidjatari
c0511fa8e4 See description
* Add ConVar to allow user to set/unset FCVAR_DEVELOPMENTONLY ConVar's (default behavior would never be hit without this ConVar).
* Add icons to display the flags of a certain CommandBase.
* Fixed Dear ImGui not displaying images correctly (descriptor needs DXGI_FORMAT_R8G8B8A8_UNORM_SRGB due to the nature of this game).
* Dynamically obtain buffer sizes of resources taken from modules.
* Light SDK cleanup.
2022-04-26 20:24:51 +02:00
Kawe Mazidjatari
687446eade Cleanup CConsole 2022-03-25 13:31:31 +01:00
Amos
ae0b439a3c Additional cleanup + optimizations 2022-02-21 12:06:05 +01:00
Amos
6e3fb73a82 Update comment blocks 2022-02-14 02:31:42 +01:00
Amos
2e8cc3e7b1 Update ImGui default theme 2022-01-28 12:56:51 +01:00
Amos
a1f96797c0 Console and Browser UX improvements
* Log warnings
* Improve style
* Vector size is now controlled by ConVar instead
* Keep current item in view when console is cleaning up the vector. This doesn't work ideally as its hard to keep track of the current item, and the scroll is a float. In the future it might be better to grab the first vertex of the center line on the console and track that perhaps.
2022-01-22 15:51:09 +01:00
Amos
963c189f35 Reset scroll position when AutoSuggest has updated 2022-01-20 00:24:41 +01:00
Amos
540e219c22 Clamp Autocomplete window properly
* Fixed cases where the horizontal scrollbar would conceal the only item in the autocomplete window

* Add new ConVar to show help text next to ConVar in autocomplete. disabled by default to prevent it from being cluttered.
2022-01-19 19:03:04 +01:00
Amos
2bb02acd60 Implement autocomplete logic for in-game console.
Autocompletes based on user input.
Also shows ConVar's current value.
2022-01-17 23:21:43 +01:00
Amos
d182652211 Check and clear console vector even if console is not drawn
The vector could still overflow if user plays the game for a long time while not opening the console at least once.
2022-01-16 01:32:51 +01:00
Amos
de3b3f53bd Optimizations + QoL improvements/cleanup
* IConsole overlay now clears the oldest log entries to stay under the vector limit instead of clearing the whole vector.
* IConsole code cleanup.
* IBrowser code cleanup, reordered class methods.
* Use ConVar utilities to get/set values for strings in IBrowser and IConsole.
* New ConVar's for RUI console overlay to tweak colors.
2022-01-12 02:56:17 +01:00
Amos
d5b2e58dae Code base refactor + major performance and readability improvement. Read description for details.
* Codebase restructured to SourceSDK codebase style and .cpp/.h assertion paths in the game executable.
* Document most functions with valve style 'Purpose' blocks.
* Rename variables to match the rest of the codebase and Valve's naming convention.
* Dedicated DLL and the SDKLauncher now share the same codebase as the DevSDK.

* Obtain globals or pointers directly instead of waiting for runtime initialized data.
* Dynamically search for all functions and globals (this doesn't count for dedicated yet!).
* Initialize most in-SDK variables.

* Move certain prints and other utilities under ConVars to reduce verbosity and increase performance.
* Print all pattern scan results through a virtual function to make it easier to add and debug new patterns in the future.
* Type global var pointers appropriately if class or type is known and implemented.
* Forward declare 'CClient' class to avoid having 2 'g_pClient' copies.
* Add IDA's pseudo definitions for easier prototyping with decompiled assembly code.

* RPAK decompress Command callback implementation.
* Load decompressed RPaks from 'paks\Win32\' overriding the ones in 'paks\Win64\' (the decompress callback will automatically fix the header and write it to 'paks\Win32\').

* VPK decompress Command callback implementation.
* Move CRC32 ands Adler32 to implementation files.

* Server will print out more details about the connecting client.

* Upgrade ImGui lib to v1.86.
* Don't compile id3dx.h for dedicated.
* Don't compile id3dx.cpp for dedicated
* Implement DevMsg print function allowing to print information to the in-game VGUI/RUI console overlay, ImGui console overlay and the external windows console

* Fixed bug where the Error function would not properly terminate the process when an error is called. This caused access violations for critical/non-recoverable errors.
* Fixed bug where the game would crash if the console or server browser was enabled while the game was still starting up.
* Several bug fixes for the dedicated server (warning: dedicated is still considered work-in-progress!).
2021-12-25 22:36:38 +01:00