3433 Commits

Author SHA1 Message Date
Kawe Mazidjatari
bfc985ea79 Engine: fix return value for game wndproc
Should return LRESULT, not int.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
7dbf4133ee ImGui: remove extraneous window flag
No flags needed here, just pass ImGuiWindowFlags_None.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
a0c995c08a ImGui: make imgui flags constants instead 2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
b2481247c0 ImGui: fix server browser list clipper and pass filter bug
Filter results first before clipping them.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
5de3738d0c ImGui: always rebuild summary text on input text change
This fixes corner case bugs like selecting currently entered text, and deleting it at once. If we happen to show a ConVar's value, and do the mentioned action, it wouldn't clear it as "if (iData->BufTextLen)" won't satisfy.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
6d3bd818e1 ImGui: move summary text above input text
The pass filter has some features (including, or excluding with the '-' prefix), but this isn't very clear. Added the original 'usage' text back, which caused the following issue: the summary text (showing how many history items, or the currently selected convar's current value/default value) would clip outside the console window on ConVar's that had larger string values, like URL's. The summary text has been moved to just above the input text field to fix this issue. This patch also contains some slight improvement to styling of the console.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
ea7a377814 ImGui: pad last button in server browser correctly
Previously, it would clip with the resize handle due to commit eda8048a982f88611710bcded1d2245e9d42d95e
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
56feb56998 ImGui: clip server listings if they exceed rect
Use ImGuiListClipper to clip anything not visible.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
fda018785e ImGui: upgrade backend to 1.90.4 as well
This wasn't committed, but was supposed to be part of commit 7f6846a3
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
a59b704384 ImGui: don't use textures for autocomplete if the loading failed
Otherwise the indices will be incorrect and will cause undefined behavior.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
c6edc47c18 ImGui: console and browser code style refactor
Made the style of the code more consistent. Not much logic-wise had changed during the refactor, but there are some.

Console:
* Removed m_bSuggestUpdate and the logic bound to it, this var was never set and the logic was never used. This was the initial workaround for resetting the autocomplete selection pos to kPark (-1), but this is currently done in a more mature way, but the old code was never removed
* CreateSuggestionsFromPartial() (previously, FindFromPartial()) would break if a ConCommand/ConVar was found that was already added in the list. Although this is an engine/sdk level bug, we shouldn't stop iterating there. Added an assert instead and made the loop continue.
* Removed member m_bCopyToClipBoard, this was used to check if the copy button was pressed, to copy the text the next frame. The copy now happens directly in the site of the Copy button which is a better approach.
* Due to the changes with removing m_bCopyToClipBoard, the mutex for m_colorTextLogger is now released right after rendering the color text to fully minimize blocking time between other threads.

Browser:
* Moved ImGui::Begin() call from RunFrame() to DrawSurface(), it fits better there and we can now also return false if the frame didn't render.
* Improved the "Broadcasting" text formatting when server browser is hosting and broadcasting without a server token (public server).

Both:
* Added virtual Shutdown() method.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
264c104b09 ImGui: properly implement shift select
The new method wraps around perfectly when the new selection positions overlap each other. This patch also fixes the shift selection drifting when lines are getting deleted.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
6f158811e6 ImGui: fix logger not moving end interactive + reduce duplicate code
Only the start interactive was moved if lines were deleted to clamp the vector size. Also fixed the code so the interactives always move if lines get deleted from before their positions, instead of "if" only the mouse is held down.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
1f8cd45626 ImGui: make config singleton static
Avoid indirection, also deduplicate common style var assignments.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
828e96a74a ImGui: improve autocomplete window size
Use convars to determine the size, by default the width is the same size as the input text bar. The height has also been increased with 90f (shows 12 elements now, this fits perfectly when the game is launched with default options). Also properly clamp the autocomplete window
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
ead3634a01 ImGui:: correctly calculate item width
Fixed bug where changing the server browser causes the alignment of the buttons with the right side border to mess up.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
26b99359d6 ImGui: fix console input suggestions bug
Don't draw the suggestions window if the console has been collapsed.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
44d663bf1c ImGui: cleanup and improvement to surface implementation
* Properly run fade in-out animations
* Make common methods/members shared
* Remove extraneous SDK thread
2024-04-05 18:22:56 +02:00
Kawe Mazidjatari
bddde13b06 ImGui: use Dear ImGui API for the cursor render blinker 2024-04-05 18:19:41 +02:00
Kawe Mazidjatari
405a16d982 ImGui: fix regression in logger after improving cursor selections
If you triple click a line in the logger, the selection mode will be set to SelectionMode::Line, however, when we drag with the mouse, the selection remain on SelectionMode::Line, causing the cursor to be stuck, which breaks the ability to scroll select. Mode must be set to normal during dragging.
2024-04-05 18:19:41 +02:00
Kawe Mazidjatari
71f151397a ImGui: initialize newly added member vars and fix scrolling regression
The types should be floats instead of ints, the compiler actually compiled it as ints after changing to ImCeil. Made vars of correct type and removed extraneous casts.
2024-04-05 18:19:41 +02:00
Kawe Mazidjatari
aa54b17385 ImGui: reset horizontal scroll position when command has been submitted
Small UX improvement.
2024-04-05 18:19:41 +02:00
Kawe Mazidjatari
ef6cd5e444 ImGui: add ability to reset horizontal scroll position
This allows us to reset the horizontal position only when an user submitted a console command in the text box. We don't want to reset the horizontal position if new lines are added since user could still be reading text that is otherwise clipped away.
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
c80d6eb0d2 ImGui: fix bug in CTextEditor::IsHandleMouseInputsEnabled
Returned the incorrect value, should've returned m_bHandleMouseInputs.
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
17a735d876 ImGui: add 'ImGuiWindowFlags_NoNavInputs' to console logger
Prevent the logging view area from moving within the console window.
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
56b73af57d ImGui: add multiple fixes and improvements
Add some selection improvements from maintained version at https://github.com/santaclose/ImGuiColorTextEdit.

patch contains:
* advance cursor to end of selection
* add shift + mouse select
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
dac0ab4d99 ImGui: fix right move
Ctrl + arrow should move to word end, not next word. This also fixes a bug where it would index into into the second character when the line end gets reached.
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
197772e5f7 ImGui: fix logger not showing horizontal scrollbar when text clips 2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
db2b42cb03 ImGui: heavy optimizations to text logger (WIP)
This code originated from an imgui code editor, where it would make sense to have per-character colors. But for the console, we only ever do 1 color per line. Just store the string and one color instance, this also allows us to just take the string instead of manually reconstructing it which is very slow. The code now also only stores 32bits for color (per line) instead of 128 bits (ImVec4) as we only ever need to convert it once.

As a result, a bunch of rendering code could be dropped, and the pass filter is now also very fast as we don't need to reconstruct the string to check for the filter, we just pass a char* in which doesn't cost any perf.
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
23a3c8fc00 Engine: make task queue singleton static
Compile it as static object & renamed to more correct names. Also made the integral type for frame delay an unsigned int instead
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
85c7db410d ImguiSystem: properly implement ImGui and fix several bugs
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.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
bd71f4b221 Loader: link to Tier1
Needed for strtools.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
32c2c903e5 Pylon: mark convars 'FCVAR_ACCESSIBLE_FROM_THREADS' 2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
838b114afb Update basefilesystem.cpp
Mark 'fs_showWarnings' FCVAR_ACCESSIBLE_FROM_THREADS.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
a5e6859f4b Update sdk_dll.cpp
Mark 'sdk_fixedframe_tickinterval' FCVAR_ACCESSIBLE_FROM_THREADS.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
0255157a41 VGUI: CTextOverlay cleanup
- Mark 'con_drawnotify' FCVAR_MATERIAL_SYSTEM_THREAD
- Add assert for char* in CTextOverlay::AddLog()
- Make buffer stack based in CTextOverlay::DrawFormat()
- Make color var struct const in CTextOverlay::DrawCrosshairMaterial()
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
9e6559a244 ImGui: set X scroll in console window as well
Previously only the Y would reset, making you not see the end if you were scrolled too far in the X.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
4fa745af85 Mathlib: enable SIMD quaternions
Should match output code with the code in the game executable, as that has been compiled with SIMD enabled.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
e141c529ac RTech: mark cvars FCVAR_ACCESSIBLE_FROM_THREADS
Must be FCVAR_ACCESSIBLE_FROM_THREADS since they are used from different threads.
2024-04-05 18:19:38 +02:00
Kawe Mazidjatari
b9c7cabda9 ImGui: move initialization code to DX hook setups
Also removed unused global declaration 'g_bImGuiInitialized'.
2024-04-05 18:19:38 +02:00
Kawe Mazidjatari
c3b0034478 Console: fix max console lines bug
We must check on con_max_lines + 1 since the first line is a dummy.
2024-04-05 18:19:38 +02:00
Kawe Mazidjatari
6cf88dc16c Engine: render ImGui in main thread and fix many threading bugs
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.
2024-04-05 18:17:12 +02:00
Kawe Mazidjatari
6e7f9d2ae2 Engine: reject connection is session ID hashing failed
If hashing failed, the other checks will fail regardless, return out early.
2024-04-05 18:13:33 +02:00
Kawe Mazidjatari
eb04bc2fea Engine: close RCON socket on password hashing failure
Must also be closed here
2024-04-05 18:13:33 +02:00
Kawe Mazidjatari
1ac38516d8 Upgrade Dear ImGui to 1.90.4 2024-04-05 18:13:33 +02:00
Kawe Mazidjatari
c17c11fbaa Tier1: fix crashes on some commands & fix assert
The supplemental callback always seems to be linked to a nullsub, probably a debug only feature. Linked all registered concommands to this as well.
2024-04-05 18:13:33 +02:00
Kawe Mazidjatari
a89ab882af Tier1: fix ConCommand::Dispatch()
Fix incorrect function prototype and add additional logic implemented in the engine. The code was crashing as the first parameter is the command target, but appears unused, the second parameter was actually the parameter that contained a pointer to the CCommand object which we needed.
2024-04-05 18:13:32 +02:00
Kawe Mazidjatari
609d705a0c Tier1: static construction of ConVar objects during link time
Fully implemented ConVar class so we could statically construct all SDK convars, this avoids a level of indirection, and allows for creating ConVar's everywhere in the project.

This patch also removed the settings tab of the ImGui server browser, as it has threading issues, while it technically never caused a crash yet, it has been removed as there was no point keeping it vs the work required to make it thread save (it only managed 2 convars which are perfectly manageable through cfg's or the in-game console).

Also temporarily disabled the creation of ConVar's in the mod system due to a memory leak, we would allocate and register a convar based on details parsed out of a mod file definition, but never unregister and free it.
2024-04-05 18:13:32 +02:00
Kawe Mazidjatari
d6b14fa12c Statically construct all ConCommand
Properly implement the ConCommandBase and ConCommand classes so we could statically construct all ConCommand objects in the global scope of each translation unit, this way we don't need to put them in a global file and deal with preprocessor directives to compile then in/out for certain projects.
2024-04-05 18:13:31 +02:00
Kawe Mazidjatari
a4a1d6fc68 Engine: reduce reason buffer stack size
64 chars will cover all reasons returned by l8w8jwt_get_validation_result_desc.
2024-04-05 18:13:31 +02:00