Get A Life

Get A life: Half-Life 2 Single Player adventure
 
HomeHome  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  

Share | 
 

 Question

View previous topic View next topic Go down 
AuthorMessage
Spitfire
Nouveau


Number of posts : 1
Registration date : 2007-02-13

PostSubject: Question   Tue 13 Feb - 3:40

Hi. I am in need of some help and I noticed that this MOD may be able to help me. I am currently developing a mod for a University Project and need help with creating a custom HUD for it. Can you please help me out? or point me towards a tutorial?
Back to top Go down
View user profile
detamic
Lead Coder
avatar

Number of posts : 1076
Registration date : 2006-02-25

PostSubject: Re: Question   Wed 21 Feb - 14:57

I can give you a few link :

For hud message server (ex from player.cpp to get player data) to client (where hud cpp are):
http://developer.valvesoftware.com/wiki/HUD_Elements

To add an icone :
http://www.hl2coding.com/forums/viewtopic.php?t=189&start=0
http://hl2coding.com/forums/viewtopic.php?t=359&view=next&sid=c7bcc796dff4715a976eddffc652aa5b

To add a text :
http://www.hl2coding.com/forums/viewtopic.php?t=758

My link to add a texture does not work anymore, so I give you the code of one cpp I have used in get a life, to draw background bottom left of our hud :

header (hud_left.h)

Code:
#include "hudelement.h"
  #include <vgui_controls/Panel.h>
#include "hud_numericdisplay.h"
  class CHudLeft : public CHudElement, public vgui::Panel
  {
 
    DECLARE_CLASS_SIMPLE( CHudLeft, vgui::Panel );
 
  public:
    CHudLeft( const char *pElementName );
     
  protected:
    virtual void Paint();
    int m_nTextureID;
 
  };

Cpp file :

Code:

#include "hud.h"
  #include "cbase.h"
  #include "hud_left.h"
  #include "iclientmode.h"
  #include "hud_macros.h"
  #include <vgui_controls/AnimationController.h>
  #include "vgui_controls/controls.h"
  #include "vgui/ISurface.h"
  #include <vgui/ILocalize.h>

  using namespace vgui;
 
  #include "tier0/memdbgon.h"
CHudLeft::CHudLeft( const char *pElementName ) : CHudElement( pElementName ), BaseClass( NULL, "HudLeft" )
    {
        vgui::Panel *pParent = g_pClientMode->GetViewport();
        SetParent( pParent );
    
        //AW Create Texture for Looking around
          m_nTextureID = vgui::surface()->CreateNewTextureID();//important 1
       
       
          SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT | HIDEHUD_INVENTAIRE);//HIDEHUD_INVENTAIRE have been added
    };
 
    DECLARE_HUDELEMENT( CHudLeft );
void CHudLeft::Paint()
  {
    
   vgui::surface()->DrawSetTextureFile( m_nTextureID, "hud/logo_hud_fond" , true, true);//important 2 : the game will load logo_hud_fond.vmt data which is in materials/hud file of your mod
    vgui::surface()->DrawSetTexture( m_nTextureID );//important 3
    // vgui::surface()->DrawTexturedRect( 6*GetWide()/640, 378*GetTall()/480, 102*GetWide()/640, 474*GetTall()/480  );
    vgui::surface()->DrawTexturedRect( 0, 0, GetWide(), GetTall()  );//Important 4, to resize your texture. GetWide and GetTall are data you have to give to your hud size in HudLayout.res in script file of your mod
  }
Back to top Go down
View user profile
 
Question
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Question sur cities xl 2011
» Question 3DO
» Question sur diverses choses dans wow (Lore)
» Topic d'aide et de question GS.
» question sur le recrutement et les phase de teste

Permissions in this forum:You cannot reply to topics in this forum
Get A Life :: Get a Life : English :: General discussion-
Jump to: