User:Maven/sandbox: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(more)
No edit summary
 
(107 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Image:Sandbox.jpg|thumb|250px|right|Look! [[User:Mark WiseCarver|wisemx]] gave me a shovel and a pail! Now I have a shovel and a pail! And some sand!]]
This is my personal sandbox area.
This is my personal sandbox area.
<br clear="all" />
----
----
{{unreleased|engine=Source|website=}}


[[Category:Programming]][[Category:Tutorials]][[Category:VGUI]]
{{unreleased|engine=Source|website=http://google.com}}
 
==Adding a VGUI screen to a map==
 
# Create a [[vgui_screen]]. This is a point entity.
# Set its '''Panel Name''' to the name of the screen that should be shown. (This is not the filename of the screen.) The available screens are listed in <code>vgui_screens.txt</code> (which can be [[GFCScape|extracted]] from '''???''' at <code>''steamdir''\SourceMods\''moddir''\scripts</code>). An example that comes with HL2 is <code>vgui_test_screen</code>.
# Set '''Panel Width in World''' and '''Panel Height in World''' to match the size of the brush. 64 wide by 32 tall would be a reasonable starting size.
# Compile the map and test.
 
==Creating a VGUI screen==
 
'''TODO:''' Can .res files be zipped into a BSP? If so, much of this section needs adjusted for HL2-singleplayer mappers.
 
VGUI screen files have a ''.res'' extension and should be placed in <code>''steamdir''\SourceMods\''yourmod''\scripts\screens\</code>.
 
# <code>vgui_test_screen.res</code> is a good starting point for creating a VGUI screen file; it can be extracted from <code>source engine.gcf</code> at path <code>hl2/scripts/screens/</code> using [[GCFScape]].
 
# The materials used in the ''.res'' file can be found in <code>source materials.gfc</code>. Extract the material files mentioned in the ''.res'' file to <code>''steamdir''\SourceMods\''moddir''\materials\vgui\screens</code>.
 
# Add the screen to <code>''steamdir''\SourceMods\''moddir''\scripts\vgui_screens.txt</code>. Here is an example which describes screen <code>vgui_test_screen</code> at <code>scripts/screens/vgui_test_screen.res</code> and <code>teleport_countdown_screen</code>. Adjust it for your screen.
 
"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"
    }
}
 
==VGUI code modifications==
 
There is a problem with VGUI screens receiving input.
 
'''TODO''': what are the effects? Is it a crash bug?
 
<code>CInput::ExtraMouseSample</code> calls <code>g_pClientMode->CreateMove()</code> without initializing the button flags, thus the VGui screen is updated with bad button input.  Since <code>IN_VALIDVGUIINPUT</code> is only set from within <code>CInput::CreateMove</code>, 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 <code>CInput::CreateMove( ''...'' )</code>
add:
    cmd->buttons |= IN_VALIDVGUIINPUT;
right above:
    g_pClientMode->CreateMove( input_sample_frametime, cmd );
 
 
next, in '''c_baseplayer.cpp''' inside method <code>C_BasePlayer::CreateMove( ''...'' )</code>
add:
    if(pCmd->buttons & IN_VALIDVGUIINPUT)
right above:
    DetermineVguiInputMode( pCmd );
''(So it only calls <code>DetermineVguiInputMode</code> if the buttons include our flag)''
 
and finally, inside method <code>C_BasePlayer::DetermineVguiInputMode( ''...'' )</code>
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 <code>CUserCmd</code> such as <code>bButtonFlagsValid</code> 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.
 
== External links ==
* [http://www.jakoavain.net/helk/granted.jpg Screenshot of working panels in the mod Hostile Planet]

Latest revision as of 21:17, 26 November 2005

Look! wisemx gave me a shovel and a pail! Now I have a shovel and a pail! And some sand!

This is my personal sandbox area.


This third-party game for the Source engine is currently in development.

It is not yet available to the public. Watch this page or the game's website for new information.

This third-party game for the Source engine is currently in development.

It is not yet available to the public. Watch this page or the game's website for new information.