⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hgeguictrls.h

📁 2D游戏引擎hge的代码
💻 H
字号:
/*
** Haaf's Game Engine 1.4
** Copyright (C) 2003-2004, Relish Games
** hge.relishgames.com
**
** hgeGUI default controls header
*/


#ifndef HGEGUICTRLS_H
#define HGEGUICTRLS_H


#include "hgehelpers.h"
#include "hgesprite.h"
#include "hgefont.h"
#include "hgerect.h"
#include "hgegui.h"


#define hgeButtonGetState(gui,id)		((hgeGUIButton*)gui->GetCtrl(id))->GetState()
#define hgeButtonSetState(gui,id,b)		((hgeGUIButton*)gui->GetCtrl(id))->SetState(b)
#define hgeSliderGetValue(gui,id)		((hgeGUISlider*)gui->GetCtrl(id))->GetValue()
#define hgeSliderSetValue(gui,id,f)		((hgeGUISlider*)gui->GetCtrl(id))->SetValue(f)
#define hgeGetTextCtrl(gui,id)			((hgeGUIText*)gui->GetCtrl(id))


/*
** hgeGUIText
*/
class hgeGUIText : public hgeGUIObject
{
public:
	hgeGUIText(int id, float x, float y, float w, float h, hgeFont *fnt);

	void			SetMode(int _align);
	void			SetText(char *_text);
	void			printf(char *format, ...);
	void			SetColor(DWORD _col) { col=_col; }

	virtual void	Render();

private:
	hgeFont*		font;
	float			tx, ty;
	int				align;
	char			text[256];
	DWORD			col;
};


/*
** hgeGUIButton
*/
class hgeGUIButton : public hgeGUIObject
{
public:
	hgeGUIButton(int id, float x, float y, float w, float h, HTEXTURE tex, float tx, float ty);
	virtual			~hgeGUIButton();

	void			SetMode(bool _bTrigger) { bTrigger=_bTrigger; }
	void			SetState(bool _bPressed) { bPressed=_bPressed; }
	bool			GetState() const { return bPressed; }

	virtual void	Render();
	virtual bool	MouseLButton(bool bDown);

private:
	bool			bTrigger;
	bool			bPressed;
	bool			bOldState;
	hgeSprite		*sprUp, *sprDown;
};


/*
** hgeGUISlider
*/
#define HGESLIDER_BAR			0
#define HGESLIDER_BARRELATIVE	1
#define HGESLIDER_SLIDER		2

class hgeGUISlider : public hgeGUIObject
{
public:
	hgeGUISlider(int id, float x, float y, float w, float h, HTEXTURE tex, float tx, float ty, float sw, float sh);
	virtual			~hgeGUISlider();

	void			SetMode(float _fMin, float _fMax, int _mode) { fMin=_fMin; fMax=_fMax; mode=_mode; }
	void			SetValue(float _fVal);
	float			GetValue() const { return fVal; }

	virtual void	Render();
	virtual bool	MouseMove(float x, float y);
	virtual bool	MouseLButton(bool bDown);

private:
	bool			bPressed;
	int				mode;
	float			fMin, fMax, fVal;
	float			sl_w, sl_h;
	hgeSprite		*sprSlider;
};


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -