Beispiel #1
0
bool EditorEventReceiver::OnEvent(const SEvent& event)
{
	if (event.EventType == irr::EET_KEY_INPUT_EVENT)
	{
		KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
		if (KeyIsDown[KEY_ESCAPE])
		{ //Return to the main menu
			delete Universe::instance->gameName;
			Universe::instance->gameName = NULL;
			Universe::instance->state = NextLevel;
		}
	}
	else if (event.EventType == EET_GUI_EVENT)
	{
		s32 eventCallerId = event.GUIEvent.Caller->getID();

		switch(event.GUIEvent.EventType)
		{
			case EGET_BUTTON_CLICKED:
				if (eventCallerId >= MapCellSelectWindowToggleButton && eventCallerId <= CharacterSelectWindowToggleButton)
				{
					if (!Universe::instance->guienv->getRootGUIElement()->getElementFromId(eventCallerId - 10))
					{ //Window is not created
						wchar_t wstr[512]; //Buffer
						MapObject** mapObjects; //General pointer to any MapObjects in GameResources. Is defined in the switch below
						int mapObjectsCount; //'mapObjects' count
						int brushIndex; //Current brush (0: MapCell, 1:NPC, 2:Item, 3:Static, 4:Character)

						brushIndex = eventCallerId - MapCellSelectWindowToggleButton;

						switch (eventCallerId)
						{
							case MapCellSelectWindowToggleButton:
								//Define specific title
								wcscpy(wstr, L"Map cell selection");
								//Define that we would use MapCells as MapObjects
								mapObjects = (MapObject**)Universe::instance->game->resources->mapCells;
								mapObjectsCount = Universe::instance->game->resources->mapCellsCount;
								break;
							case NPCSelectWindowToggleButton:
								//Define specific title
								wcscpy(wstr, L"NPC selection");
								//Define that we would use NPCs as MapObjects
								mapObjects = (MapObject**)Universe::instance->game->resources->npcs;
								mapObjectsCount = Universe::instance->game->resources->npcsCount;
								break;
							case ItemSelectWindowToggleButton:
								//Define specific title
								wcscpy(wstr, L"Item selection");
								//Define that we would use Items as MapObjects
								mapObjects = (MapObject**)Universe::instance->game->resources->items;
								mapObjectsCount = Universe::instance->game->resources->itemsCount;
								break;
							case StaticSelectWindowToggleButton:
								//Define specific title
								wcscpy(wstr, L"Static selection");
								//Define that we would use Statics as MapObjects
								mapObjects = (MapObject**)Universe::instance->game->resources->statics;
								mapObjectsCount = Universe::instance->game->resources->staticsCount;
								break;
							case CharacterSelectWindowToggleButton:
								//Define specific title
								wcscpy(wstr, L"Character selection");
								//Define that we would use Characters as MapObjects
								mapObjects = (MapObject**)Universe::instance->game->resources->characters;
								mapObjectsCount = Universe::instance->game->resources->charactersCount;
								break;
						}

						char** tags;
						int tagsCount;
						IGUIWindow* wnd1;

						//Create window with the specific title 'wstr'
						wnd1 = Universe::instance->guienv->addWindow(rect< s32 >(224, 64, 760, 536), false, wstr, 0, eventCallerId - 10);

						//ListBox for MapObjects
						IGUIListBox* molb = Universe::instance->guienv->addListBox(rect< s32 >(128, 64, 128 + 224, 64 + 320), wnd1, eventCallerId + 5, true);
						for (int i = 0; i < mapObjectsCount; i++)
						{
							swprintf(wstr, L"[%d] ", mapObjects[i]->id);
							mbstowcs(wstr + wcslen(wstr), mapObjects[i]->name, 511);
							molb->addItem(wstr);
							if (Universe::instance->brush[brushIndex] == mapObjects[i])
								molb->setSelected(i); //Select item in list that was used last time in this MapObject list
						}

						tagsCount = Universe::instance->game->resources->GetMapObjectsTags(mapObjects, mapObjectsCount, tags);
						if (tagsCount > 0)
						{ //Tags exists. Therefore we're to put 'All' CheckBox
							Universe::instance->guienv->addCheckBox(true, rect< s32 >(32, 64, 32 + 92, 64 + 16), wnd1, -1, L"All");
							//IGUIElement* container = Universe::instance->guienv->addModalScreen(wnd1);
							//IGUIElement* container = Universe::instance->guienv->addScrollBar(false, rect< s32 >(16, 64, 16 + 92, 64 + 256), wnd1, -1);
							for (int i = 0; i < tagsCount; i++)
							{
								mbstowcs(wstr, tags[i], 511);
								Universe::instance->guienv->addCheckBox(true, rect< s32 >(32, 80 + 16 * i, 32 + 92, 80 + 16 * (i + 1)), wnd1, -1, wstr);
							}
							delete[] tags;
						}

						Universe::instance->guienv->addButton(rect< s32 >(415, 420, 415 + 96, 420 + 32), wnd1, eventCallerId + 10, L"OK", L"Select current map object");
					}
					//Focus just created MapObject selection window (or focus old window)
					Universe::instance->guienv->setFocus(Universe::instance->guienv->getRootGUIElement()->getElementFromId(eventCallerId - 10));
				}
				else if (eventCallerId >= MapCellSelectWindowOKButton && eventCallerId <= CharacterSelectWindowOKButton)
				{
					IGUIListBox* lb = (IGUIListBox*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(eventCallerId - 20)->getElementFromId(eventCallerId - 5);
					if (lb->getSelected() >= 0)
					{
						int mapObjectId;
						swscanf(lb->getListItem(lb->getSelected()), L"[%d]", &mapObjectId);
						switch (eventCallerId)
						{
							case MapCellSelectWindowOKButton:
								Universe::instance->brush[0] = Universe::instance->game->resources->GetMapCell(mapObjectId);
								break;
							case NPCSelectWindowOKButton:
								Universe::instance->brush[1] = Universe::instance->game->resources->GetNPC(mapObjectId);
								break;
							case ItemSelectWindowOKButton:
								Universe::instance->brush[2] = Universe::instance->game->resources->GetItem(mapObjectId);
								break;
							case StaticSelectWindowOKButton:
								Universe::instance->brush[3] = Universe::instance->game->resources->GetStatic(mapObjectId);
								break;
							case CharacterSelectWindowOKButton:
								Universe::instance->brush[4] = Universe::instance->game->resources->GetCharacter(mapObjectId);
								break;
						}
						//Close parent window (MapObject selection window)
						lb->getParent()->remove();
					}
				}
				else
				{
					switch (eventCallerId)
					{
						case LocationsEditButton:
						{
							IGUIWindow* wnd;
							wnd = (IGUIWindow*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow);
							if (wnd)
							{
								wnd->remove();
								Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox)->setEnabled(true);
							}
							else
							{
								wnd = Universe::instance->guienv->addWindow(rect< s32 >(Universe::instance->toolbarWidth, 0, Universe::instance->toolbarWidth + 242, 184), false, L"Locations edit", 0, LocationsEditWindow);
								wnd->getCloseButton()->setEnabled(false);
								wnd->getCloseButton()->setVisible(false);
								Universe::instance->guienv->addEditBox(Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox)->getText(), rect< s32 >(32, 32, 208, 56), true, wnd, LocationNameEditBox);
								Universe::instance->guienv->addEditBox(L"64", rect< s32 >(32, 80, 112, 104), true, wnd, LocationWidthEditBox);
								Universe::instance->guienv->addEditBox(L"64", rect< s32 >(128, 80, 208, 104), true, wnd, LocationHeightEditBox);
								Universe::instance->guienv->addButton(rect< s32 >(32, 128, 32 + 48, 160), wnd, LocationsEditDeleteButton, L"Delete", L"Delete current location");
								Universe::instance->guienv->addButton(rect< s32 >(96, 128, 96 + 48, 160), wnd, LocationsEditSaveButton, L"Save", L"Apply settings to the current location")->setEnabled(false);
								Universe::instance->guienv->addButton(rect< s32 >(160, 128, 160 + 48, 160), wnd, LocationsEditAddButton, L"Save as", L"Apply settings to the new location");
								Universe::instance->guienv->setFocus(wnd);
								Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox)->setEnabled(false);
							}
							break;
						}
						case LocationsEditSaveButton:
						{
							char str[256];
							int width, height;
							wcstombs(str, Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationNameEditBox)->getText(), 256);
							//swscanf(Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationWidthEditBox)->getText(), L"%d", &width);
							//swscanf(Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationHeightEditBox)->getText(), L"%d", &height);
							delete Universe::instance->currentLocation->name;
							Universe::instance->currentLocation->name = new char[strlen(str) + 1];
							strcpy(Universe::instance->currentLocation->name, str);
							Universe::instance->currentLocation->Update();
							//Update ComboBox
								// ((IGUIComboBox*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox))->updateItem(L"sd");
							//Close locations edit Window and enable locations ComboBox
							Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->remove();
							Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox)->setEnabled(true);
							break;
						}
						case LocationsEditAddButton:
						{
							char str[256];
							int width, height;
							wcstombs(str, Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationNameEditBox)->getText(), 255);
							swscanf(Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationWidthEditBox)->getText(), L"%d", &width);
							swscanf(Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationHeightEditBox)->getText(), L"%d", &height);
							//Add location to DB and spawn it
							Universe::instance->game->data->LocationSpawn(Universe::instance->game->data->AddLocation(str, width, height), Editor);
							//Add location to the locations list
							((IGUIComboBox*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox))->addItem(Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->getElementFromId(LocationNameEditBox)->getText());
							//Close locations edit Window and enable locations ComboBox
							Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->remove();
							Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox)->setEnabled(true);
							break;
						}
						case LocationsEditDeleteButton:
						{
							IGUIComboBox* lcb = (IGUIComboBox*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox);
							if (lcb->getItemCount() > 1)
							{ //It's not the last location
								//Delete location from DB and unspawn it
								Universe::instance->game->data->LocationDelete(lcb->getSelected());
								//Delete location from the locations list
								lcb->removeItem(lcb->getSelected());
								//Select another location
								lcb->setSelected(0);
								//Close locations edit Window and enable locations ComboBox
								Universe::instance->guienv->getRootGUIElement()->getElementFromId(LocationsEditWindow)->remove();
								Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox)->setEnabled(true);
							}
							break;
						}
					}
				}
				break;
			case EGET_COMBO_BOX_CHANGED:
				switch (eventCallerId)
				{
					case LocationsComboBox:
						Universe::instance->render->smgr->clear();
						Universe::instance->SetLocation(Universe::instance->game->data->locations[((IGUIComboBox*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(LocationsComboBox))->getSelected()]);
						//The code below (3 lines) does not prevent exception during loading another locations due to camera test mode
						ISceneNode* camPos = Universe::instance->render->smgr->addEmptySceneNode();
						camPos->setPosition(vector3df(50,50,10));
						ICameraSceneNode *camera = Universe::instance->render->smgr->addCameraSceneNode(0, vector3df(50,50,10), vector3df(50,0,40));
						Universe::instance->DrawScene();
						break;
				}
				break;
			case EGET_TAB_CHANGED:
				switch (eventCallerId)
				{
					case MapObjectsTabControl:
						Universe::instance->brushIndex = ((IGUITabControl*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(ToolBarWindow)->getElementFromId(MapObjectsTabControl))->getActiveTab();
						break;
				}
				break;
			case EGET_CHECKBOX_CHANGED:
				/*
				IGUIListBox* molb = Universe::instance->guienv->addListBox(rect< s32 >(128, 64, 128 + 224, 64 + 320), wnd1, eventCallerId + 5, true);
				for (int i = 0; i < mapObjectsCount; i++)
				{
					swprintf(wstr, L"[%d] ", mapObjects[i]->id);
					mbstowcs(wstr + wcslen(wstr), mapObjects[i]->name, 511);
					molb->addItem(wstr);
					if (Universe::instance->brush[brushIndex] == mapObjects[i])
						molb->setSelected(i); //Select item in list that was used last time in this MapObject list
				}
				*/
				//Filter
				//Universe::instance->game->resources->FilterByTag<MapCell>(Universe::instance->game->resources->mapCells, Universe::instance->game->resources->mapCellsCount, , );
				break;
		}
	}

	return false;
}
Beispiel #2
0
bool ClientEventReceiver::OnEvent(const SEvent& event)
{
	if (event.EventType == irr::EET_KEY_INPUT_EVENT)
	{
		KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
		if (event.KeyInput.Key >= KEY_KEY_1 && event.KeyInput.Key <= KEY_KEY_9)
		{
			if (Universe::instance->guienv->getFocus() != Universe::instance->guienv->getRootGUIElement()->getElementFromId(ChatBox)->getElementFromId(ChatInputEditBox))
			{
				IGUIElement* hkb = Universe::instance->guienv->getRootGUIElement()->getElementFromId(HotkeyBar);
				CGUIButton* btn = ((IGUIIconTable*)hkb)->getButtonAt(event.KeyInput.Key - KEY_KEY_1);
				if (btn)
				{
					SEvent clickEvent;
					clickEvent.EventType = EET_GUI_EVENT;
					clickEvent.GUIEvent.EventType = EGET_BUTTON_CLICKED;
					clickEvent.GUIEvent.Caller = btn;
					Universe::instance->render->device->postEventFromUser(clickEvent);
				}
			}
		}
		else if (KeyIsDown[KEY_ESCAPE])
		{ //Return to the main menu
			delete Universe::instance->login;
			delete Universe::instance->password;
			Universe::instance->login = NULL;
			Universe::instance->password = NULL;
			Universe::instance->state = NextLevel;
		}
		else if (KeyIsDown[KEY_RETURN])
		{
			Universe::instance->guienv->setFocus(Universe::instance->guienv->getRootGUIElement()->getElementFromId(ChatBox)->getElementFromId(ChatInputEditBox));
		}
	}
	else if(event.EventType == irr::EET_MOUSE_INPUT_EVENT)
	{
		for (s32 i = 0; i < EMIE_COUNT; ++i)
            Mouse[i] = i == event.MouseInput.Event;
		IGUIElement* guiElement = Universe::instance->guienv->getRootGUIElement()->getElementFromPoint(vector2di(event.MouseInput.X, event.MouseInput.Y));
		if (guiElement != NULL)
		{ //Mouse is in a window area
			if (guiElement->getID() != 0) //Mouse is on GUI element
				return false;
		}
		else //Mouse is not in a window area
			return false;
		if (Mouse[EMIE_LMOUSE_PRESSED_DOWN])
		{
			CurrentMapObject<MapObject>* targetCurrentMapObject;

			CGUIButton* leftMouseBind = ((IGUIIconTable*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(HotkeyBar))->selectedButton;
			if (leftMouseBind)
			{
				int targetType;
				char outPacket[256];
				
				if (targetCurrentMapObject = (CurrentMapObject<MapObject>*)Universe::instance->render->GetCurrentMapObjectUnderCursor<CurrentNPC>(Universe::instance->currentLocation->currentNPCs, Universe::instance->currentLocation->currentNPCsCount))
				{
					targetType = 0;
				}
				else if (targetCurrentMapObject = (CurrentMapObject<MapObject>*)Universe::instance->render->GetCurrentMapObjectUnderCursor<CurrentCharacter>(Universe::instance->currentLocation->currentCharacters, Universe::instance->currentLocation->currentCharactersCount))
				{
					targetType = 3;
				}
				else
					targetType = -1;

				CreatePacket(outPacket, SkillUse, "%i%b%i", leftMouseBind->currentGameObject->id, targetType, targetCurrentMapObject ? targetCurrentMapObject->id : 0);
				Universe::instance->connectSocket->Send(outPacket);
			}
		}
		else if (Mouse[EMIE_RMOUSE_PRESSED_DOWN])
		{
			CurrentMapObject<MapObject>* targetCurrentMapObject;
			if (targetCurrentMapObject = (CurrentMapObject<MapObject>*)Universe::instance->render->GetCurrentMapObjectUnderCursor<CurrentNPC>(Universe::instance->currentLocation->currentNPCs, Universe::instance->currentLocation->currentNPCsCount))
			{
				char outPacket[256];

				CreatePacket(outPacket, DialogOpen, "%i%i", targetCurrentMapObject->id, 0);
				Universe::instance->connectSocket->Send(outPacket);
			}
			else if (targetCurrentMapObject = (CurrentMapObject<MapObject>*)Universe::instance->render->GetCurrentMapObjectUnderCursor<CurrentItem>(Universe::instance->currentLocation->currentItems, Universe::instance->currentLocation->currentItemsCount))
			{
				char outPacket[256];

				f32 distance = vector2d<f32>(targetCurrentMapObject->x, targetCurrentMapObject->y).getDistanceFrom(vector2d<f32>(Universe::instance->currentCharacter->x, Universe::instance->currentCharacter->y));
				if (distance < 3.0f)
				{
					CreatePacket(outPacket, ItemPickUp, "%i", targetCurrentMapObject->id);
				}
				else
				{ //Emulate character's move request to this item
					double targetX, targetY;
					//TODO: other angles
					targetX = targetCurrentMapObject->x + (targetCurrentMapObject->x < Universe::instance->currentCharacter->x ? 1.0f : -1.0f);
					targetY = targetCurrentMapObject->y + (targetCurrentMapObject->y < Universe::instance->currentCharacter->y ? 1.0f : -1.0f);
					CreatePacket(outPacket, Move, "%f%f", targetX, targetY);
				}

				Universe::instance->connectSocket->Send(outPacket);
			}
			else
			{ //Move
				char outPacket[256];
				vector2d<f32> clickPos = Universe::instance->render->MouseCoordToWorldCoord();
				if (clickPos.X > 0 && clickPos.X < Universe::instance->currentLocation->width && clickPos.Y > 0 && clickPos.Y < Universe::instance->currentLocation->height)
					if (Universe::instance->currentLocation->mask[(int)clickPos.Y][(int)clickPos.X] == Free) //TODO: see 'void Location::SpawnStatic(CurrentStatic* currentStatic)'
					{
						CreatePacket(outPacket, Move, "%f%f", clickPos.X, clickPos.Y);
						Universe::instance->connectSocket->Send(outPacket);
					}
			}
		}
		else if (Mouse[EMIE_MOUSE_WHEEL])
		{
			f32 cameraNextY = Universe::instance->cameraY + event.MouseInput.Wheel * 5.0f;
			if (cameraNextY > 5.0f && cameraNextY < 200.0f)
				Universe::instance->cameraY = cameraNextY;
		}
	}
	else if (event.EventType == EET_GUI_EVENT)
	{
		s32 eventCallerId = event.GUIEvent.Caller->getID();
		IGUIElement* eventCaller = event.GUIEvent.Caller;

		switch(event.GUIEvent.EventType)
		{
			case RPGATOR_EET_ELEMENT_DRAGGED:
				if (event.GUIEvent.Element)
				{ //Element dragged to an GUI element
					if (event.GUIEvent.Element->getParent())
					{ //Element dragged to an GUI element that has parent (IGUIIconTableContainer)
						if (event.GUIEvent.Element->getParent()->getID() == HotkeyBar)
						{ //Empty cell
							CGUIButton* hotkeyButton = new CGUIButton(*((CGUIButton*)event.GUIEvent.Caller));
							((IGUIIconTable::IGUIIconTableContainer*)event.GUIEvent.Element)->setButton(hotkeyButton);
						}
						else if (event.GUIEvent.Element->getParent()->getParent())
						{ //Element dragged to an GUI element that has parent (IGUIIconTable)
							if (event.GUIEvent.Element->getParent()->getParent()->getID() == HotkeyBar)
							{ //Existing cell
								CGUIButton* hotkeyButton = new CGUIButton(*((CGUIButton*)event.GUIEvent.Caller));
								((IGUIIconTable::IGUIIconTableContainer*)event.GUIEvent.Element->getParent())->setButton(hotkeyButton);
							}
						}
					}
				}
				break;
			case EGET_EDITBOX_ENTER:
				switch (eventCallerId)
				{
					case ChatInputEditBox:
						IGUIElement* eb = Universe::instance->guienv->getRootGUIElement()->getElementFromId(ChatBox)->getElementFromId(ChatInputEditBox);
						if (wcslen(eb->getText()) > 0)
						{
							char outPacket[256];
							CreatePacket(outPacket, Say, "%b%ws", Public, eb->getText());
							Universe::instance->connectSocket->Send(outPacket);
							eb->setText(NULL);
						}
						break;
				}
				break;
			case EGDT_WINDOW_CLOSE:
				switch (eventCallerId)
				{
					case InventoryWindow:
						((IGUIButton*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(InventoryToggleButton))->setPressed(false);
						break;
					case SkillsWindow:
						((IGUIButton*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(SkillsToggleButton))->setPressed(false);
						break;
				}
				break;
			case EGET_BUTTON_CLICKED:
				switch (eventCallerId)
				{
					case IconTableItemButton:
					{
						char outPacket[256];
						CreatePacket(outPacket, ItemUse, "%i", ((CGUIButton*)eventCaller)->currentGameObject->id);
						Universe::instance->connectSocket->Send(outPacket);
						break;
					}
					case IconTableSkillButton:
					{
						((IGUIIconTable*)eventCaller->getParent()->getParent())->selectedButton = (CGUIButton*)eventCaller;
						
						//rightMouseBind = eventCaller;
						/*
						char outPacket[256];
						CurrentMapObject<MapObject>* targetCurrentMapObject;
						int currentMapObjectId;
						int targetType;

						if (targetCurrentMapObject = (CurrentMapObject<MapObject>*)Universe::instance->render->GetCurrentMapObjectUnderCursor<CurrentNPC>(Universe::instance->currentLocation->currentNPCs, Universe::instance->currentLocation->currentNPCsCount))
						{
							currentMapObjectId = targetCurrentMapObject->id;
							targetType = 0;
						}
						else if (targetCurrentMapObject = (CurrentMapObject<MapObject>*)Universe::instance->render->GetCurrentMapObjectUnderCursor<CurrentCharacter>(Universe::instance->currentLocation->currentCharacters, Universe::instance->currentLocation->currentCharactersCount))
						{
							currentMapObjectId = targetCurrentMapObject->id;
							targetType = 3;
						}
						else
						{
							currentMapObjectId = 0;
							targetType = -1;
						}

						CreatePacket(outPacket, SkillUse, "%i%b%i", ((CGUIButton*)eventCaller)->currentGameObject->id, targetType, currentMapObjectId);
						Universe::instance->connectSocket->Send(outPacket);
						*/
						break;
					}
					case InventoryToggleButton:
					{
						IGUIWindow* wnd = (IGUIWindow*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(InventoryWindow);
						if (wnd)
							wnd->remove();
						else
						{
							int btnsSize = 48;

							wnd = Universe::instance->guienv->addWindow(rect< s32 >(Universe::instance->render->screenWidth - btnsSize * 6 - (6 - 1) * 2 - 20, 150, Universe::instance->render->screenWidth, 150 + 100 + btnsSize * 6 + (6 - 1) * 2 + 10), false, L"Inventory", NULL, InventoryWindow);

							IGUIIconTable* tbl = new IGUIIconTable(Universe::instance->guienv, wnd, InventoryItemsIconTable, rect< s32 >(10, 100, 10 + btnsSize * 6 + (6 - 1) * 2, 100 + btnsSize * 6 + (6 - 1) * 2), 6, 6);
							tbl->buttonSize = btnsSize;
							wnd->addChild(tbl);
							for (int i = 0; i < Universe::instance->currentCharacter->currentItemsCount; i++)
							{
								tbl->addButton((CurrentGameObject<GameObject>*)Universe::instance->currentCharacter->currentItems[i], IconTableItemButton);
							}
						}
						break;
					}
					case SkillsToggleButton:
					{
						IGUIWindow* wnd = (IGUIWindow*)Universe::instance->guienv->getRootGUIElement()->getElementFromId(SkillsWindow);
						if (wnd)
							wnd->remove();
						else
						{
							int btnsSize = 48;

							wnd = Universe::instance->guienv->addWindow(rect< s32 >(Universe::instance->render->screenWidth - btnsSize * 6 - (6 - 1) * 2 - 20 - 400, 150, Universe::instance->render->screenWidth - 400, 150 + 100 + btnsSize * 6 + (6 - 1) * 2 + 10), false, L"Skills", NULL, SkillsWindow);

							IGUIIconTable* tbl = new IGUIIconTable(Universe::instance->guienv, wnd, SkillsIconTable, rect< s32 >(10, 100, 10 + btnsSize * 6 + (6 - 1) * 2, 100 + btnsSize * 6 + (6 - 1) * 2), 6, 6);
							tbl->buttonSize = btnsSize;
							wnd->addChild(tbl);
							for (int i = 0; i < Universe::instance->currentCharacter->currentSkillsCount; i++)
							{
								tbl->addButton((CurrentGameObject<GameObject>*)Universe::instance->currentCharacter->currentSkills[i], IconTableSkillButton);
							}
						}
						break;
					}
					case ChatInputEditBox:
						Universe::instance->guienv->getRootGUIElement()->getElementFromId(ChatInputEditBox)->setText(L"");
						break;
					default:
						if (eventCallerId > DialogElement) //Dialog button
						{
							char outPacket[256];
							int currentNPCId;

							swscanf(eventCaller->getParent()->getText(), L"[%d]", &currentNPCId);
							eventCaller->getParent()->remove();
							CreatePacket(outPacket, DialogOpen, "%i%i", currentNPCId, eventCallerId - DialogElement);
							Universe::instance->connectSocket->Send(outPacket);
						}
						break;
				}
				break;
			case EGET_COMBO_BOX_CHANGED:
				break;
			case EGET_TAB_CHANGED:
				break;
			case EGET_CHECKBOX_CHANGED:
				break;
		}
	}

	return false;
}