www.pudn.com > RCApp-src.zip > GUI.h


/* 
	RedEye Project (http://members.ozemail.com.au/~ndmcevoy/) 
	Copyright (C) 2003  Nick McEvoy 
 
	This library is free software; you can redistribute it and/or 
	modify it under the terms of the GNU Library General Public 
	License as published by the Free Software Foundation; either 
	version 2 of the License, or (at your option) any later version. 
 
	This library is distributed in the hope that it will be useful, 
	but WITHOUT ANY WARRANTY; without even the implied warranty of 
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
	Library General Public License for more details. 
 
	You should have received a copy of the GNU Library General Public 
	License along with this library; if not, write to the Free 
	Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 
	----------------------------------------------------------------- 
 
		Commented for use with Doxygen (http://www.doxygen.org) 
 
	----------------------------------------------------------------- 
*/ 
 
/*! \file GUI.h 
 *	\brief Game gui. 
 * 
 *		This file contains the game gui. 
 */ 
 
#ifndef _RE_GAME_GUI_H_ 
#define _RE_GAME_GUI_H_ 
 
// PLIB includes 
#include  
#include  
 
//! Maximum length of gui strings 
#define RE_GUI_STRING_MAX	1024 
 
#define RE_LOADING_TEXT	"Please wait game is loading..." 
#define RE_PAUSE_TEXT	"Press any key to continue..." 
 
// Why derive from puText ... I hear you ask ? 
// Well because the puObject::setLabel() does not copy 
// the string buffer !??? ... which is what I want !!!! 
class reText : public puText 
{ 
public: 
	reText(int x, int y) : puText(x, y){}; 
 
	void SetLabel(const char* sText) 
		{strcpy(msText, sText);setLabel(msText);}; 
 
private: 
	// Could make this grow ... but hey I'm lazy! :) 
	char msText[RE_GUI_STRING_MAX]; 
}; 
 
class reGameGUI 
{ 
public: 
	//! Get instance 
	static reGameGUI* GetInstance(); 
 
	//! GLUT callback handlers 
	void Display(); 
	void Reshape(int w, int h); 
	void Keyboard(unsigned char key, int x, int y, bool bKeyDown); 
	void KeyboardSpecial(int key, int x, int y, bool bKeyDown); 
	void MouseFunc(int button, int state, int x, int y); 
	void MotionFunc(int x, int y); 
	void PassiveMotionFunc(int x, int y); 
 
	//! Show load level dialog 
	void ShowLoadLevel(); 
 
	//! Show help dialog 
	void ShowHelp(); 
 
	//! Set all text off 
	void SetTextOff(); 
 
	enum eGUIText 
	{ 
		eNotifyText, // message in center of screen 
		eStatusText, // message in bottom left of screen 
		ePlayerText, 
		eDebugText 
	}; 
 
	//! Set text 
	void SetText(eGUIText eText, const char* sText, bool bOn); 
	void SetTextOn(eGUIText eText, bool bOn); 
 
	//! Destructor 
	~reGameGUI(); 
 
protected: 
	//! Constructor is protected as this class is a singleton 
	reGameGUI(); 
 
private: 
	//! The one and only instance 
	static reGameGUI* mpInstance; 
 
	reText mNotifyText; 
	reText mStatusText; 
	reText mPlayerText; 
	reText mDebugText; 
}; 
 
//! Get the one and only instance 
inline reGameGUI* reGetGameGUI() {return reGameGUI::GetInstance();}; 
 
#endif // _RE_GAME_GUI_H_