User:Maven/sandbox
This is my personal sandbox area.
Adding a VGUI screen to a map
Create a vgui_screen with the following properties:
- Panel Name = vgui_test_screen
- Panel Width in World = 64
- Panel Height in World = 32
Height and width can be changed to whatever you need. Those values define the actual size of the screen in the world.
Creating a VGUI screen
TODO: Can .res files be zipped into a BSP? If so, much of this section needs adjusted.
VGUI screen files have a .res extension and should be placed in steamdir\SourceMods\yourmod\scripts\screens\
.
vgui_test_screen.res
is a good starting point for creating a VGUI screen file; it can be extracted fromsource engine.gcf
at pathhl2/scripts/screens/
using GCFScape.
- The materials used in the .res file can be found in
source materials.gfc
. Extract the material files mentioned in the .res file tosteamdir\SourceMods\moddir\materials\vgui\screens
.
In steamdir\SourceMods\moddir\scripts
create or open the text filevgui_screens.txt
and add a new entry. An example would be:
"VGUI_Screens" { "vgui_test_screen" { // This is our example screen "type" "vgui_screen_panel" "pixelswide" 480 "pixelshigh" 240 // This must be the file you created in step 1 "resfile" "scripts/screens/vgui_test_screen.res" } "teleport_countdown_screen" { "type" "teleport_countdown_screen" "pixelswide" 480 "pixelshigh" 240 "resfile" "scripts/screens/teleport_countdown_screen.res" } }
VGUI code modifications
There is a problem with VGUI screens receiving input.
TODO: what are the effects? Is it a crash bug?
CInput::ExtraMouseSample
calls g_pClientMode->CreateMove()
without initializing the button flags, thus the VGui screen is updated with bad button input. Since IN_VALIDVGUIINPUT
is only set from within CInput::CreateMove
, the VGui screens only update when the button flags are valid.
There are two known fixes. They both involve code changes and therefore are only applicable to mods.
Fix 1
In in_buttons.h, where the other flags are defined add:
#define IN_VALIDVGUIINPUT (1 << 23) //bitflag for vgui fix
next, in in_main.cpp inside method CInput::CreateMove( ... )
add:
cmd->buttons |= IN_VALIDVGUIINPUT;
right above:
g_pClientMode->CreateMove( input_sample_frametime, cmd );
next, in c_baseplayer.cpp inside method C_BasePlayer::CreateMove( ... )
add:
if(pCmd->buttons & IN_VALIDVGUIINPUT)
right above:
DetermineVguiInputMode( pCmd );
(So it only calls DetermineVguiInputMode
if the buttons include our flag)
and finally, inside method C_BasePlayer::DetermineVguiInputMode( ... )
change both instances of:
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2);
to read:
pCmd->buttons &= ~(IN_ATTACK | IN_ATTACK2 | IN_VALIDVGUIINPUT);
Fix 2
An alternative fix would be to add a new boolean variable to CUserCmd
such as bButtonFlagsValid
that can be set depending on the validity of the button flags. This would allow the structure to internally store this information for its whole lifetime while freeing up that extra button bit.