IGameConsole: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
 
m (links)
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
This interface can help you manage the console using the GameUI module.  It is not included in any of the SDK code.
This interface can help you manage the console using the [[GameUI]] module rather than using the corresponding [[ConCommand]]s & [[ConVar]]s.  You can also print out messages in whatever color you'd like.  It is not included in any of the SDK code.
 
==public\gameui\IGameConsole.h==
<pre>//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
<pre>//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
//
Line 14: Line 14:


#include "interface.h"
#include "interface.h"
#include <vgui\VGUI.h>


class Color;
class Color;
using namespace vgui;


//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
Line 24: Line 26:
public:
public:
// activates the console, makes it visible and brings it to the foreground
// activates the console, makes it visible and brings it to the foreground
virtual void Activate() = 0;
virtual void Activate() = 0;


virtual void Initialize() = 0;
virtual void Initialize() = 0;


// hides the console
// hides the console
virtual void Hide() = 0;
virtual void Hide() = 0;


// clears the console
// clears the console
virtual void Clear() = 0;
virtual void Clear() = 0;


// return true if the console has focus
// return true if the console has focus
virtual bool IsConsoleVisible() = 0;
virtual bool IsConsoleVisible() = 0;


// prints a message to the console
// prints a message to the console
virtual void Printf(const char *format, ...) = 0;
virtual void Printf(const char *format, ...) = 0;


// printes a debug message to the console
// printes a debug message to the console
virtual void DPrintf(const char *format, ...) = 0;
virtual void DPrintf(const char *format, ...) = 0;


// printes a debug message to the console
// printes a debug message to the console
virtual void ColorPrintf( Color& clr, const char *format, ...) = 0;
virtual void ColorPrintf( Color& clr, const char *format, ...) = 0;


virtual void SetParent( int parent ) = 0;
virtual void SetParent( VPANEL parent ) = 0;
};
};


Line 54: Line 56:


==Access==
==Access==
These lines go in the client/server init files:
#include <gameui\IGameConsole.h>
IGameConsole *gameconsole = NULL;
  CreateInterfaceFn gameUIFactory = Sys_GetFactory("gameui.dll");
  CreateInterfaceFn gameUIFactory = Sys_GetFactory("gameui.dll");
  gameconsole = (IGameConsole *)gameUIFactory(GAMECONSOLE_INTERFACE_VERSION,NULL);
  gameconsole = (IGameConsole *)gameUIFactory(GAMECONSOLE_INTERFACE_VERSION, NULL);
[[Category:Interfaces]]
[[Category:Interfaces]]

Latest revision as of 01:06, 12 April 2011

This interface can help you manage the console using the GameUI module rather than using the corresponding ConCommands & ConVars. You can also print out messages in whatever color you'd like. It is not included in any of the SDK code.

public\gameui\IGameConsole.h

//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============
//
// Purpose: 
//
//=============================================================================

#ifndef IGAMECONSOLE_H
#define IGAMECONSOLE_H
#ifdef _WIN32
#pragma once
#endif

#include "interface.h"
#include <vgui\VGUI.h>

class Color;
using namespace vgui;

//-----------------------------------------------------------------------------
// Purpose: interface to game/dev console
//-----------------------------------------------------------------------------
class IGameConsole : public IBaseInterface
{
public:
	// activates the console, makes it visible and brings it to the foreground
	virtual void	Activate() = 0;

	virtual void	Initialize() = 0;

	// hides the console
	virtual void	Hide() = 0;

	// clears the console
	virtual void	Clear() = 0;

	// return true if the console has focus
	virtual bool	IsConsoleVisible() = 0;

	// prints a message to the console
	virtual void	Printf(const char *format, ...) = 0;

	// printes a debug message to the console
	virtual void	DPrintf(const char *format, ...) = 0;

	// printes a debug message to the console
	virtual void	ColorPrintf( Color& clr, const char *format, ...) = 0;

	virtual void	SetParent( VPANEL parent ) = 0;
};

#define GAMECONSOLE_INTERFACE_VERSION "GameConsole003"

#endif // IGAMECONSOLE_H

Access

These lines go in the client/server init files:

#include <gameui\IGameConsole.h>
IGameConsole *gameconsole = NULL;
	CreateInterfaceFn gameUIFactory = Sys_GetFactory("gameui.dll");
	gameconsole = (IGameConsole *)gameUIFactory(GAMECONSOLE_INTERFACE_VERSION, NULL);