All pastes #809054 Raw Edit

Miscellany

public cpp v1 · immutable
·published 2007-12-08 05:19 UTC
rendered paste body
#include "cGUI.h"// Console variablesint consoleId;int btnSubmit;int lstConsole;int txtInput;void EmptyFunc(cbParam Param){}void MsgBoxFunc(cbParam Param){	gGUI->ChangeWindowProperty(GUI_PROP_VISIBLE, Param.pId, INVISIBLE);}void MsgBox(string text, string caption){	vec2f camDimentions = gCamera->GetDimentions();	int tmp = gGUI->CreateGUIWindow(camDimentions.x / 2 - 150, 		camDimentions.y / 2 - 100, 		300, 120, caption, 		&EmptyFunc, 		VISIBLE);	gGUI->CreateGUIObject(tmp, 		GUI_OBJECT_BUTTON, 		60, 		40, 		180, 		24, 		"Ok", 		&MsgBoxFunc, 		VISIBLE);}cbParam::cbParam(int itemID, int itemPID, int itemType, int intParam, Object *obj, Window *wndw, string itemParam){	id = itemID;	pId = itemPID;	type = itemType;	Param = itemParam;	iParam = intParam;}int ListBox::AddItem(string value){	list.push_back(value.c_str());	return 1;}int ListBox::AddItem(int value){	char *dest;	itoa(value, dest, 10);	this->list.push_back(dest);	return 1;}int ListBox::AddItem(ostringstream value){	this->list.push_back(value.str().c_str());	return 1;}void Window::Hide(){	visible = false;}void Window::Show(){	visible = true;}void cGUI::renderBitmapString(						float x, 						float y, 						float z, 						void *font, 						char *string) {  							char *c;							glRasterPos3f(x, y,z);							for (c=string; *c != '\0'; c++) {								glutBitmapCharacter(font, *c);							}}void ConsoleProc(cbParam Param){	if(Param.type == GUI_OBJECT && Param.id == btnSubmit)	{		Object *list;		Object *input;		list = gGUI->GetObjectPointer(lstConsole, Param.pId);		input = gGUI->GetObjectPointer(txtInput, Param.pId);		list->listBox.AddItem(input->textBox.value);	} else if(Param.type == GUI_WINDOW && Param.iParam == GUI_RESIZE)	{		// Resize		Window *window;		window = Param.window;		Param.window->x = Param.window->x + 40;	}}cGUI::cGUI(){	escMenuUp=false;	curWindowID=0;	dragId=-1;	resizeId=-1;	vector<Window> * windowLst = new vector<Window>;}cGUI::~cGUI(){}void cGUI::Init(){	// This can't be in the constructor because it needs to be initiated AFTER the OGL initiation.	gLoad->loadTexture("../images/top-corner.png");	// Top corners	gLoad->loadTexture("../images/top.png");	// Top	gLoad->loadTexture("../images/bottom-corner.png");	// Bottom Corners	gLoad->loadTexture("../images/side.png");		// Sides	gLoad->loadTexture("../images/center.png");		// Center	// Create the console	consoleId = gGUI->CreateGUIWindow( 20, 20, 540, 580, "Console", &ConsoleProc, false );	lstConsole = gGUI->CreateGUIObject(consoleId, GUI_OBJECT_LISTBOX, 8, 34, 526, 510, "Log", &ConsoleProc, true);	txtInput = gGUI->CreateGUIObject(consoleId, GUI_OBJECT_TEXTBOX, 8, 548, 443, 20, "Input", &ConsoleProc, true);	btnSubmit = gGUI->CreateGUIObject(consoleId, GUI_OBJECT_BUTTON, 454, 548, 80, 19, "Submit", &ConsoleProc, true);	// Welcome messages in the console	Object *con;	con = gGUI->GetObjectPointer(lstConsole, consoleId);	con->listBox.AddItem("Welcome to the Xomni Engine!");	con->listBox.AddItem("Engine Build: 1. DEBUG");}void cGUI::Render(){	glColor3f(1.0f,1.0f,1.0f);	for(int i = windowLst.size() - 1; i >= 0; i--)	{		if(windowLst[i].visible)		{			RenderWindow( windowLst[i].x, windowLst[i].y, windowLst[i].width, windowLst[i].height, windowLst[i].name );			for(int o = 0; o < windowLst[i].objects.size(); o++)			{				Object tmpObject = windowLst[i].objects[o];				switch(tmpObject.type)				{					case(GUI_OBJECT_BUTTON):					{						RenderButton(&windowLst[i], &tmpObject);						break;					}					case(GUI_OBJECT_TEXTBOX):					{						RenderTextBox(&windowLst[i], &tmpObject);						break;					}					case(GUI_OBJECT_LISTBOX):					{						RenderListBox(&windowLst[i], &tmpObject);					}					case(GUI_OBJECT_LABEL):					{						RenderLabel(&windowLst[i], &tmpObject);					}				}			}		}	}	/*POINT pos;	WINDOWPLACEMENT wp;	GetCursorPos(&pos);	GetWindowPlacement(gGUI->hWnd, &wp);	gRender->DrawTexture("../images/cursor.png", pos.x - wp.rcNormalPosition.left - 4, pos.y - wp.rcNormalPosition.top - 30, 12, 22);	*/	if(!escMenuUp)		return;	glColor3f(0.3f,0.3f,0.3f);}void cGUI::RenderWindow( int x, int y, int width, int height, string name ){	glColor4f(1.0f,1.0f,1.0f, 0.9f);	// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/top-corner.png"));	glBegin(GL_QUADS);		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 28, 0, 0);				// Top Right		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 28, 28, 0);				// Bottom Right		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, 28, 0);				// Bottom Left	glEnd();	// Top	glLoadIdentity();	glTranslatef( x + 28, y, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/top.png"));	glBegin(GL_QUADS);		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width - 56, 0, 0);				// Top Right		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width - 56, 28, 0);				// Bottom Right		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, 28, 0);				// Bottom Left	glEnd();	// Top Right	glLoadIdentity();	glTranslatef( x + width - 28, y, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/top-corner.png"));	glBegin(GL_QUADS);		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 28, 0, 0);				// Top Right		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 28, 28, 0);				// Bottom Right		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 0, 28, 0);				// Bottom Left	glEnd();	// Bottom Left	glLoadIdentity();	glTranslatef( x, y + height - 28, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/bottom-corner.png"));	glBegin(GL_QUADS);		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 28, 0, 0);				// Top Right		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 28, 28, 0);				// Bottom Right		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, 28, 0);				// Bottom Left	glEnd();	// Bottom	glLoadIdentity();	glTranslatef( x + 28, y + height -28, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/top.png"));	glBegin(GL_QUADS);		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width - 56, 0, 0);				// Top Right		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width - 56, 28, 0);				// Bottom Right		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 28, 0);				// Bottom Left	glEnd();	// Bottom Right	glLoadIdentity();	glTranslatef( x + width - 28, y + height - 28, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/bottom-corner.png"));	glBegin(GL_QUADS);		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 28, 0, 0);				// Top Right		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 28, 28, 0);				// Bottom Right		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 0, 28, 0);				// Bottom Left	glEnd();	// Center	glLoadIdentity();	glTranslatef( x, y + 28, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/center.png"));	glBegin(GL_QUADS);		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 28, 0, 0);				// Top Left		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( width - 28, 0, 0);				// Top Right		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( width - 28, height - 56, 0);				// Bottom Right		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 28, height - 56, 0);				// Bottom Left	glEnd();	// Left	glLoadIdentity();	glTranslatef( x, y + 28, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/side.png"));	glBegin(GL_QUADS);		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 1.0f, 0.0f ); glVertex3f( 28, 0, 0);				// Top Right		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 28, height - 56, 0);				// Bottom Right		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, height - 56, 0);				// Bottom Left	glEnd();	// Right	glLoadIdentity();	glTranslatef( x + width - 28, y + 28, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/side.png"));	glBegin(GL_QUADS);		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left		glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 28, 0, 0);				// Top Right		glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 28, height - 56, 0);				// Bottom Right		glTexCoord2f( 1.0f, 1.0f ); glVertex3f( 0, height - 56, 0);				// Bottom Left	glEnd();	glLoadIdentity();	glColor3f(0.6f,0.6f,0.6f);	renderBitmapString(x + 10, y + 20, 0, GLUT_BITMAP_HELVETICA_12, (char *)name.c_str());	glColor3f(1.0f,1.0f,1.0f);}void cGUI::RenderButton( int x, int y, int width, int height, string name, bool enabled ){	// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/center.png"));	glColor3f(0.0f,0.0f,0.0f);	glBegin(GL_QUADS);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1, -1, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width + 2, -1, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width + 2, height + 2, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1, height + 2, 0);				// Bottom Left	glLoadIdentity();	glColor3f(1.0f,1.0f,1.0f);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, 0, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width, height, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, height, 0);				// Bottom Left	glEnd();	glLoadIdentity();	if(!enabled)		glColor3f(0.6f,0.6f,0.6f);	else		glColor3f(0.0f,0.0f,0.0f);	renderBitmapString(x + 4, y + (height / 2 + 5), 0, GLUT_BITMAP_HELVETICA_12, (char *)name.c_str());	glColor3f(1.0f,1.0f,1.0f);}void cGUI::RenderButton(Window *wndw, Object *obj){	int x = wndw->x + obj->x;	int y = wndw->y + obj->y;	int width = obj->width;	int height = obj->height;	string name = obj->name;	bool active = true;	bool enabled = obj->enabled;	// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D, gLoad->GetGLTexture("../images/center.png"));	glColor3f(0.0f,0.0f,0.0f);	glBegin(GL_QUADS);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -1, -1, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width + 2, -1, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width + 2, height + 2, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -1, height + 2, 0);				// Bottom Left	glLoadIdentity();	glColor3f(1.0f,1.0f,1.0f);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, 0, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width, height, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, height, 0);				// Bottom Left	glEnd();	glLoadIdentity();	if(!enabled)		glColor3f(0.6f,0.6f,0.6f);	else		glColor3f(0.0f,0.0f,0.0f);	renderBitmapString(x + 4, y + (height / 2 + 5), 0, GLUT_BITMAP_HELVETICA_12, (char *)name.c_str());	glColor3f(1.0f,1.0f,1.0f);}void cGUI::RenderTextBox( int x, int y, int width, int height, string name, string value, bool active, bool enabled ){	// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D,50);	glColor3f(0.0f,0.0f,0.0f);	glBegin(GL_QUADS);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -2, -2, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width + 1, -2, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width + 1, height + 1, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -2, height + 1, 0);				// Bottom Left	glLoadIdentity();	glColor3f(0.7f,0.7f,0.7f);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, 0, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width, height, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, height, 0);				// Bottom Left	glEnd();	glLoadIdentity();	if(!enabled)		glColor3f(0.6f,0.6f,0.6f);	else		glColor3f(0.0f,0.0f,0.0f);	if(active)	{		ostringstream val;		val << value << "|";		renderBitmapString(x + 3, y + 15, 0, GLUT_BITMAP_HELVETICA_12, (char *)val.str().c_str());	}else		renderBitmapString(x + 3, y + 15, 0, GLUT_BITMAP_HELVETICA_12, (char *)value.c_str());	glColor3f(1.0f,1.0f,1.0f);}void cGUI::RenderTextBox(Window *wndw, Object *obj){	int x = wndw->x + obj->x;	int y = wndw->y + obj->y;	int width = obj->width;	int height = obj->height;	string name = obj->name;	string value = obj->textBox.value;	bool active;	bool enabled = obj->enabled;	if(wndw->activeObjID == obj->id)		active = true;	else		active = false;		// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D,50);	glColor3f(0.0f,0.0f,0.0f);	glBegin(GL_QUADS);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -2, -2, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width + 1, -2, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width + 1, height + 1, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -2, height + 1, 0);				// Bottom Left	glLoadIdentity();	glColor3f(0.7f,0.7f,0.7f);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, 0, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width, height, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, height, 0);				// Bottom Left	glEnd();	glLoadIdentity();	if(!enabled)		glColor3f(0.6f,0.6f,0.6f);	else		glColor3f(0.0f,0.0f,0.0f);	if(active)	{		ostringstream val;		val << value << "|";		renderBitmapString(x + 3, y + 15, 0, GLUT_BITMAP_HELVETICA_12, (char *)val.str().c_str());	}else		renderBitmapString(x + 3, y + 15, 0, GLUT_BITMAP_HELVETICA_12, (char *)value.c_str());	glColor3f(1.0f,1.0f,1.0f);}void cGUI::RenderListBox(Window *wndw, Object *obj){	int x = wndw->x + obj->x;	int y = wndw->y + obj->y;	int width = obj->width;	int height = obj->height;	string name = obj->name;	bool active = true;	bool enabled = obj->enabled;	// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D,50);	glColor3f(0.0f,0.0f,0.0f);	glBegin(GL_QUADS);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( -2, -2, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width + 1, -2, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width + 1, height + 1, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( -2, height + 1, 0);				// Bottom Left	glLoadIdentity();	glColor3f(0.7f,0.7f,0.7f);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, 0, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width, height, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, height, 0);				// Bottom Left	glEnd();	glLoadIdentity();	if(!enabled)		glColor3f(0.6f,0.6f,0.6f);	else		glColor3f(0.0f,0.0f,0.0f);	vector <string> tmpList = obj->listBox.list;	y += 11;	for(int i = 0; i < tmpList.size(); i++)	{		renderBitmapString(x + 3, (10 * i) + y, 0, GLUT_BITMAP_HELVETICA_10, (char *)tmpList[i].c_str());	}	glColor3f(1.0f,1.0f,1.0f);}void cGUI::RenderLabel(Window *wndw, Object *obj){	int x = wndw->x + obj->x;	int y = wndw->y + obj->y;	int width = obj->width;	int height = obj->height;	string value = obj->name;	bool active;	bool enabled = obj->enabled;	if(wndw->activeObjID == obj->id)		active = true;	else		active = false;	// Top Left	glLoadIdentity();	glTranslatef( x, y, 0);	glBindTexture(GL_TEXTURE_2D,50);	glLoadIdentity();	glColor3f(0.7f,0.7f,0.7f);	glTexCoord2f( 0.0f, 1.0f ); glVertex3f( 0, 0, 0);				// Top Left	glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, 0, 0);				// Top Right	glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width, height, 0);				// Bottom Right	glTexCoord2f( 0.0f, 0.0f ); glVertex3f( 0, height, 0);				// Bottom Left	glEnd();	glLoadIdentity();	if(!enabled)		glColor3f(0.6f,0.6f,0.6f);	else		glColor3f(0.0f,0.0f,0.0f);	if(active)	{		ostringstream val;		val << value << "|";		renderBitmapString(x, y, 0, GLUT_BITMAP_HELVETICA_12, (char *)val.str().c_str());	}else		renderBitmapString(x, y, 0, GLUT_BITMAP_HELVETICA_12, (char *)value.c_str());	glColor3f(1.0f,1.0f,1.0f);}int cGUI::CreateGUIWindow( int x, int y, int width, int height, string name, void (*cbFunc)(cbParam), bool visible ){	Window tmp;	curWindowID++;	tmp.id = curWindowID;	tmp.x = x;	tmp.y = y;	tmp.width = width;	tmp.height = height;	tmp.minHeight = 100;	tmp.minWidth = 100;	tmp.name = name;	tmp.visible = visible;	tmp.cbFunc = cbFunc;	tmp.currentObjectID=0;	tmp.activeObjID = -1;	windowLst.insert(windowLst.begin(), tmp);	return curWindowID;}int cGUI::CreateGUIWindow(Window window){	curWindowID++;	window.id = curWindowID;	window.currentObjectID=0;	window.activeObjID = -1;	windowLst.insert(windowLst.begin(), window);	return curWindowID;}int cGUI::CreateGUIObject( int hWnd, int type, int x, int y, int width, int height, string name, void (*cbFunc)(cbParam), bool visible ){	int Index;	for(int i = 0; i < windowLst.size(); i++)	{		if(windowLst[i].id == hWnd)		{			Index = i;			break;		}	}	Object tmp;	windowLst[Index].currentObjectID++;	tmp.id = windowLst[Index].currentObjectID;	tmp.x = x;	tmp.y = y;	tmp.width = width;	tmp.height = height;	tmp.name = name;	tmp.visible = visible;	tmp.cbFunc = cbFunc;	tmp.type = type;	tmp.enabled = true;	tmp.pId = hWnd;	windowLst[Index].objects.insert(windowLst[Index].objects.begin(), tmp);	return windowLst[Index].currentObjectID;}int cGUI::CreateGUIObject(Window *window, Object object){	window->currentObjectID++;	object.id = window->currentObjectID;	object.pId = window->id;	window->objects.insert(window->objects.begin(), object);	return window->currentObjectID;}int cGUI::ChangeWindowProperty( int prop, int id, int value ){	int windx;	for(int i = 0; i < windowLst.size(); ++i)	{		if(windowLst[i].id == id)		{			windx = i;			break;		}	}	switch(prop)	{		case GUI_PROP_VISIBLE:		{			windowLst[windx].visible=value;		}	}	return 1;}int cGUI::ChangeWindowProperty( int prop, int id, string value ){	return 1;}int cGUI::MouseUp( WPARAM param, int x, int y ){	bool itemFound = false;;	vector<Window>::iterator tempIterator;	tempIterator = windowLst.begin();	if( dragId != -1 || resizeId != -1)	{		dragId=-1;		resizeId=-1;		return 1;	}	for(int i = 0; i < windowLst.size(); ++i)	{		if(windowLst[i].visible)		{			if(x > windowLst[i].x && x < (windowLst[i].x + windowLst[i].width) && y > windowLst[i].y && y < (windowLst[i].y + windowLst[i].height))			{				itemFound=true;				for(int o = 0; o < windowLst[i].objects.size(); ++o)				{					if((x - windowLst[i].x) > windowLst[i].objects[o].x && (x - windowLst[i].x) < (windowLst[i].objects[o].x + windowLst[i].objects[o].width) && (y - windowLst[i].y) > windowLst[i].objects[o].y && (y - windowLst[i].y) < (windowLst[i].objects[o].y + windowLst[i].objects[o].height))					{						int ids = windowLst[i].objects[o].id;						windowLst[i].objects[o].cbFunc(cbParam(windowLst[i].objects[o].id, windowLst[i].id, GUI_OBJECT, GUI_MOUSEUP, &windowLst[i].objects[o]));						windowLst[i].activeObjID = windowLst[i].objects[o].id;						break;					}				}				windowLst[i].cbFunc(cbParam(windowLst[i].id, 0, GUI_WINDOW, GUI_MOUSEUP, NULL, &windowLst[i]));				MakeActive( windowLst[i].id, tempIterator );				break;			}		}		tempIterator++;	}	if(itemFound)		return 1;	else	{		// Nothing was clicked, so we set the activeObjId of the active window to -1 because the user clicked outside of all windows		windowLst[0].activeObjID = -1;		return 0;	}}int cGUI::MouseDown ( WPARAM param, int x, int y ){	return 0;}int cGUI::MouseMove( WPARAM param, int x, int y ){	vector<Window>::iterator tempIterator;	tempIterator = windowLst.begin();	for(int i = 0; i < windowLst.size(); ++i)	{		if(windowLst[i].visible)		{			if(dragId==windowLst[i].id)			{				windowLst[i].x = x - windowLst[i].dragX;				windowLst[i].y = y - windowLst[i].dragY;				MakeActive( windowLst[i].id, tempIterator );				break;			} else if ( resizeId == windowLst[i].id )			{				int newWidth, newHeight;				newWidth = x - windowLst[i].x;				newHeight = y - windowLst[i].y;				if(newWidth > windowLst[i].minWidth)					windowLst[i].width = newWidth;				if(newHeight > windowLst[i].minHeight)					windowLst[i].height = newHeight;												MakeActive( windowLst[i].id, tempIterator );				break;			}else if(param==MK_LBUTTON && dragId == -1 && resizeId == -1 && x > windowLst[i].x && x < (windowLst[i].x + windowLst[i].width) && y > windowLst[i].y && y < (windowLst[i].y + windowLst[i].height))			{				// Resize/Drag				int tmpX = windowLst[i].height;				if( x > (windowLst[i].x + windowLst[i].width - 40) && y > (windowLst[i].y + windowLst[i].height - 40))				{					// Resize					resizeId = windowLst[i].id;					windowLst[i].dragX = x - windowLst[i].x;					windowLst[i].dragY = y - windowLst[i].y;					MakeActive( windowLst[i].id, tempIterator );					windowLst[i].cbFunc(cbParam(windowLst[i].id, 0, GUI_WINDOW, GUI_RESIZE, NULL, &windowLst[i]));					break;				} else {					// Drag					dragId = windowLst[i].id;					windowLst[i].dragX = x - windowLst[i].x;					windowLst[i].dragY = y - windowLst[i].y;					MakeActive( windowLst[i].id, tempIterator );					if(windowLst[i].cbFunc!=NULL)						windowLst[i].cbFunc(cbParam(windowLst[i].id, 0, GUI_WINDOW, GUI_DRAG, NULL, &windowLst[i]));					break;				}			}						}		tempIterator = windowLst.begin() + i + 1;	}	return 1;}int cGUI::KeyUp(WPARAM param){	return 0;}int cGUI::KeyPress(WPARAM param){	if(param == 96)	// `/~	{		if(windowLst[GetIndex(GUI_WINDOW, consoleId)].visible)			windowLst[GetIndex(GUI_WINDOW, consoleId)].Hide();		else			windowLst[GetIndex(GUI_WINDOW, consoleId)].Show();	}	if(windowLst[0].activeObjID == -1)		return false;	int oIndex = GetIndex(GUI_OBJECT, windowLst[0].activeObjID, windowLst[0].id);	if(windowLst[0].objects[oIndex].type == GUI_OBJECT_TEXTBOX)		windowLst[0].objects[oIndex].textBox.value += param;	return 1;}int cGUI::MakeActive( int id, vector<Window>::iterator Iterator ){	// This MUST be the last item in a for loop because it will change the indexes	if(windowLst[0].id==id)		return 1;	windowLst[0].activeObjID = -1;	Window tmpWnd = windowLst[GetIndex(GUI_WINDOW, id)];	windowLst.erase(Iterator);	windowLst.insert(windowLst.begin(), tmpWnd);	return 1;}int cGUI::GetIndex(int type, int id, int pID){	// Returns -1 if somethign is wrong.	// Careful with this function, don't get the value and store it for later use, because this changes often	if(type==GUI_OBJECT)	{		if(pID == -1)			return -1;		int pIndex = GetIndex(GUI_WINDOW, pID);		for(int i = 0; i < windowLst[pIndex].objects.size(); i++)		{			if(windowLst[pIndex].objects[i].id == id)				return i;		}	} else if(type==GUI_WINDOW)	{		for(int w = 0; w < windowLst.size(); w++)		{			if(windowLst[w].id == id)				return w;		}	}}Object *cGUI::GetObjectPointer(int id, int pId){	return &windowLst[GetIndex(GUI_WINDOW, pId)].objects[GetIndex(GUI_OBJECT, id, pId)];}Window *cGUI::GetWindowPointer(int id){	return &windowLst[GetIndex(GUI_WINDOW, id)];}