Game GUIs

Started by
53 comments, last by sakky 21 years, 1 month ago
I'm currently thinking of adding a GUI to ZEngine [http://zengine.sourceforge.net] a 2D OpenGL Ortho Engine.

If anybody would like to help out on this open source project I'd really appreciate it, some of what I saw here was really great 8).

[edited by - cozman on February 17, 2003 11:27:28 PM]
Advertisement
cozman: Email me if you''re interested in my GUI (Ready4Dis@aol.com), or catch me online, AIM = CrazyGuy4Eva, MSN = Ready4Dis_1@hotmail.com. I''d be glad to let you use my code, and help you get it working with your project (with all the necessary objects and stuff).
I''ve got a simple design from some framework. It''s alot like the Java GUI system because I like having layouts and other things. It''s also easy for me to visualize and design how things will be.
Take back the internet with the most awsome browser around, FireFox
Here is a pretty cool looking OpenGL based gui

http://www.cs.unc.edu/~rademach/glui/
Sakky, sorry it took so long to reply, didn''t check back on the thread.

Basicly, here''s how things work. I use a main window (on the left) as my parent. All other windows are children.
I have an event listener in my windows update, so when the user clicks the mouse, i send the location and which mouse button was pressed to my main window update function.
the basics of that function, is that we pass the same data to all our children (since children exist above parents) if we get a return value from one of the children (clicked a child window) then we exit out. If not, we check to see if the user clicked on any of my buttons, text boxes, panels, etc etc etc. here''s the code for just the event update section. If you would like more, send me an e-mail.



  inline void GUIWindow::EventUpdate(int button, int state){	//if we''re not visible, don''t do anything, shouldn''t have to check this though	if(!visible)return;		//only reference our children, since they are on top.	bool otherwin=false;	if(ChildWindows.size()>0)	{		//if we have children, cycle through them		for(int i=0;i<ChildWindows.size();i++)			if(ChildWindows[i].visible==true)			{				ChildWindows[i].EventUpdate(button,state);				otherwin=true;			}	}//Handle ME (I need some TLC too baby)	int i=0;	int tx, ty, th, tw;	POINT mpos;	GetCursorPos(&mpos);//if our mouse has been clicked	if(button==LMOUSE)		{		if(state==MDOWN)		{//are we in our window''s bounds?		if(!(mpos.x >x && mpos.x < x+w && mpos.y > y && mpos.y < y+h))			return;//if we''ve got an active window over us, don''t check for anything inside the window''s bounds		if(otherwin)		{			for(i=0;i<ChildWindows.size();i++)			if(ChildWindows[i].visible==true)			{				if(mpos.x >ChildWindows[i].x && mpos.x < ChildWindows[i].x+ChildWindows[i].w && 					mpos.y > ChildWindows[i].y && mpos.y < ChildWindows[i].y+ChildWindows[i].h)					return;			}		}		//did we click on our close icon?			if( (mpos.x > x + w-22) && (mpos.x < x + w-6))			 if( (mpos.y > y+8) && (mpos.y < y + 24))			 {					 visible=false;				return;			}//check first to see if we''ve clicked on the title bar		if(moveable && mpos.x>x && mpos.x<x+w && mpos.y>y+1 && mpos.y<y+26 )		  {			moving=true;			return;		  }//Check if we pressed a button down			for(i=0;i<Buttons.size();i++)			{				tx=x+5+Buttons[i].x;				ty=y+27+Buttons[i].y;				th=Buttons[i].h;				tw=Buttons[i].w;				if(mpos.x>tx && mpos.x <tx+tw && mpos.y >ty && mpos.y <ty+th)					Buttons[i].pressed=true;				else					Buttons[i].pressed=false;			}//see if we hit a checkbox			for(i=0;i<CheckBoxes.size();i++)			{				tx=x+5+CheckBoxes[i].x;				ty=y+27+CheckBoxes[i].y;				th=16;				tw=16;				if(mpos.x>tx && mpos.x <tx+tw && mpos.y >ty && mpos.y <ty+th)					CheckBoxes[i].checked=!CheckBoxes[i].checked;			}//see if we hit a Radiobox			for(i=0;i<RadioButtons.size();i++)			{				tx=x+5+RadioButtons[i].x;				ty=y+27+RadioButtons[i].y;				th=16;				tw=16;				if(mpos.x>tx && mpos.x <tx+tw && mpos.y >ty && mpos.y <ty+th)				{										//uncheck the rest in this group					for(int z=0;z<RadioButtons.size();z++)					{						if(RadioButtons[z].group==RadioButtons[i].group)							RadioButtons[z].checked=false;					}					RadioButtons[i].checked=true;					Function(this,&RadioButtons[i]);				}			}			for(i=0;i<SlideBars.size();i++)			{				tx=x+5+SlideBars[i].x;				ty=y+27+SlideBars[i].y;				th=SlideBars[i].h;				tw=SlideBars[i].w;				if(mpos.x>tx && mpos.x <tx+tw && mpos.y >ty && mpos.y <ty+th)				{					SlideBars[i].mv=(mpos.x-tx); //give us our percent					SlideBars[i].val=SlideBars[i].start + SlideBars[i].mv*SlideBars[i].itr;//Update our value					Function(this,&SlideBars[i]);				}			}		}		else //MUP		{			//reset our moveing variable			moving=false;			//check our buttons, were we released?			for(i=0;i<Buttons.size();i++)			{				if(Buttons[i].pressed==true)				{					//execute the button onclick					Function(this,&Buttons[i]);				}				Buttons[i].pressed=false;			}		}	}	else//Right mouse button	{	//	if(state==MDOWN)	//	else //MUP	}}  



~Main


==
Colt "MainRoach" McAnlis
Programmer
www.badheat.com/sinewave
==Colt "MainRoach" McAnlisGraphics Engineer - http://mainroach.blogspot.com

This topic is closed to new replies.

Advertisement