MENU
Home
Code
Contact Me
Development log
Donate
issues...
Progress
Thankyous


this is the first modification i made to my mod
can be downloaded below

hud_devils_trap.h
#include "hudelement.h"
#include <vgui_controls/Panel.h>
 
using namespace vgui;
 
class CHudImport : public CHudElement, public Panel
{
   DECLARE_CLASS_SIMPLE( CHudImport, Panel );
 
   public:
   CHudImport( const char *pElementName );
   void togglePrint();
   virtual void OnThink();
 
   protected:
   virtual void Paint();
   int m_nImport;
};
hud_devils_trap.cpp
#include "hud.h"
#include "cbase.h"
#include "hud_devils_trap.h"
#include "iclientmode.h"
#include "hud_macros.h"
#include "vgui_controls/controls.h"
#include "vgui/ISurface.h"
 
#include "tier0/memdbgon.h"
 
using namespace vgui;
 
DECLARE_HUDELEMENT( CHudImport );
 
static ConVar show_beta("show_devilsTrap", "0", 0, "toggles my first edit on this mod, useless but cool to look at in upper right corner");
 
CHudImport::CHudImport( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudImport" )
{
   Panel *pParent = g_pClientMode->GetViewport();
   SetParent( pParent );
 
   SetVisible( false );
   SetAlpha( 255 );
 
   //AW Create Texture for Looking around
   m_nImport = surface()->CreateNewTextureID();
   surface()->DrawSetTextureFile( m_nImport, "Hud/devilsTrap" , true, true);
 
   SetHiddenBits( HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
}
void CHudImport::Paint()
{
   SetPaintBorderEnabled(false);
    surface()->DrawSetTexture( m_nImport );
   surface()->DrawTexturedRect( 2, 2, 128, 128 );
}
void CHudImport::togglePrint()
{
   if (!show_beta.GetBool())
      this->SetVisible(false);
   else
      this->SetVisible(true);
}
void CHudImport::OnThink()
{
   togglePrint();
 
   BaseClass::OnThink();
}
 
This is what you add to the hulayout.res file in the scripts folder
       HudImport [$WIN32]
       {
               "fieldName"             "HudImport"
               "xpos" "r100"
               "ypos" "10"
               "wide" "86"
               "tall" "86"
               "visible" "0"
               "enabled" "1"
 
               "PaintBackgroundType"   "2"
        }