aboutsummaryrefslogtreecommitdiff
path: root/src/mg_decoration.h
Commit message (Expand)AuthorAge
* Modernize various files (src/m*) (#6267)Loïc Blot2017-08-18
* C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17
* Biomes/decorations/ores: Make relative to 'water_level' settingparamat2017-07-11
* Cpp11 patchset 11: continue working on constructor style migration (#6004)Loïc Blot2017-06-18
* C++11 patchset 2: remove util/cpp11.h and util/cpp11_container.h (#5821)Loïc Blot2017-06-04
* Mapgen files: Update and correct copyright creditsparamat2017-05-26
* Simple deco: Allow setting param2 value on placementAuke Kok2016-12-07
* Decorations: Generalise 'spawn by' to be used by all decoration typesparamat2016-09-14
* Permit usage of std::unordered_map & std::unorderered_set on c++11 compilers ...Ner'zhul2016-08-10
* Convert usages of PseudoRandom to PcgRandom for ore and deco placementkwolekr2015-11-09
* Decoration API: Add flag for placement on liquid surfaceparamat2015-10-23
* Clean up threadingShadowNinja2015-08-23
* Split ObjDef/ObjDefManager out to objdef.cppkwolekr2015-05-18
* Schematics: Remove referenced schematics from Decorations on clearkwolekr2015-04-17
* Schematics: Refactor NodeResolver and add NodeResolveMethodkwolekr2015-04-16
* ObjDefManager, Mapgen SAPI: Huge refactoringkwolekr2015-03-31
* GenElementManager: Pass opaque handles to Lua and rename to ObjDefManagerkwolekr2015-03-31
* mg_decoration: Raise highest allowed deco top to max edge of voxelmanipparamat2015-03-15
* Biome API: Enable decorations placed on waterparamat2015-03-06
* Shorten ManualMapVoxelManipulator to MMVManipkwolekr2015-01-05
* Add minetest.generate_ores() and minetest.generate_decorations()kwolekr2015-01-04
* Replace instances of height_min/height_max with y_min/y_max to remove ambiguitykwolekr2014-12-30
* Decoration: Add height_min and height_max parameterskwolekr2014-12-28
* Redefine NodeResolver interface and replace with callback mechanismkwolekr2014-12-27
* Add minetest.clear_registered_decorations() and clear_registered_ores()kwolekr2014-12-12
* Remove get_noiseparams function. read_noiseparams should be used from now onkwolekr2014-12-10
* Fix struct vs. class in forward declarationsKahrl2014-12-08
* Rewrite generate notification mechanismkwolekr2014-12-06
* Add Generator Element Management frameworkkwolekr2014-11-12
* Split up mapgen.cppkwolekr2014-11-01
>284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
/*
 Minetest-c55
 Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
 Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
 Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program 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 General Public License for more details.

 You should have received a copy of the GNU General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "guiKeyChangeMenu.h"
#include "debug.h"
#include "serialization.h"
#include "main.h"
#include <string>
#include <IGUICheckBox.h>
#include <IGUIEditBox.h>
#include <IGUIButton.h>
#include <IGUIStaticText.h>
#include <IGUIFont.h>
#include "settings.h"

GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env,
		gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) :
	GUIModalMenu(env, parent, id, menumgr)
{
	activeKey = -1;
	init_keys();
}

GUIKeyChangeMenu::~GUIKeyChangeMenu()
{
	removeChildren();
}

void GUIKeyChangeMenu::removeChildren()
{
	const core::list<gui::IGUIElement*> &children = getChildren();
	core::list<gui::IGUIElement*> children_copy;
	for (core::list<gui::IGUIElement*>::ConstIterator i = children.begin(); i
			!= children.end(); i++)
	{
		children_copy.push_back(*i);
	}
	for (core::list<gui::IGUIElement*>::Iterator i = children_copy.begin(); i
			!= children_copy.end(); i++)
	{
		(*i)->remove();
	}
}

void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
{
	/*
	 Remove stuff
	 */
	removeChildren();

	/*
	 Calculate new sizes and positions
	 */

	v2s32 size(620, 430);

	core::rect < s32 > rect(screensize.X / 2 - size.X / 2,
			screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2,
			screensize.Y / 2 + size.Y / 2);

	DesiredRect = rect;
	recalculateAbsolutePosition(false);

	v2s32 topleft(0, 0);
	changeCtype("");
	{
		core::rect < s32 > rect(0, 0, 125, 20);
		rect += topleft + v2s32(25, 3);
		//gui::IGUIStaticText *t =
		Environment->addStaticText(wgettext("KEYBINDINGS"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}
	v2s32 offset(25, 40);
	// buttons

	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Forward"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->forward = Environment->addButton(rect, this,
				GUI_ID_KEY_FORWARD_BUTTON,
				wgettext(key_forward.name()));
	}

	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Backward"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->backward = Environment->addButton(rect, this,
				GUI_ID_KEY_BACKWARD_BUTTON,
				wgettext(key_backward.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Left"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON,
				wgettext(key_left.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Right"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->right = Environment->addButton(rect, this,
				GUI_ID_KEY_RIGHT_BUTTON,
				wgettext(key_right.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Use"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON,
				wgettext(key_use.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Sneak"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->sneak = Environment->addButton(rect, this,
				GUI_ID_KEY_SNEAK_BUTTON,
				wgettext(key_sneak.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Jump"), rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON,
				wgettext(key_jump.name()));
	}

	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Inventory"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->inventory = Environment->addButton(rect, this,
				GUI_ID_KEY_INVENTORY_BUTTON,
				wgettext(key_inventory.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Chat"), rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON,
				wgettext(key_chat.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Command"), rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->cmd = Environment->addButton(rect, this, GUI_ID_KEY_CMD_BUTTON,
				wgettext(key_cmd.name()));
	}


	//next col
	offset = v2s32(250, 40);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Toggle fly"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON,
				wgettext(key_fly.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Toggle fast"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON,
				wgettext(key_fast.name()));
	}
	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Range select"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->range = Environment->addButton(rect, this,
				GUI_ID_KEY_RANGE_BUTTON,
				wgettext(key_range.name()));
	}

	offset += v2s32(0, 25);
	{
		core::rect < s32 > rect(0, 0, 100, 20);
		rect += topleft + v2s32(offset.X, offset.Y);
		Environment->addStaticText(wgettext("Print stacks"),
				rect, false, true, this, -1);
		//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
	}

	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(offset.X + 105, offset.Y - 5);
		this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON,
				wgettext(key_dump.name()));
	}
	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40);
		Environment->addButton(rect, this, GUI_ID_BACK_BUTTON,
		wgettext("Save"));
	}
	{
		core::rect < s32 > rect(0, 0, 100, 30);
		rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40);
		Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON,
		wgettext("Cancel"));
	}
	changeCtype("C");
}

void GUIKeyChangeMenu::drawMenu()
{
	gui::IGUISkin* skin = Environment->getSkin();
	if (!skin)
		return;
	video::IVideoDriver* driver = Environment->getVideoDriver();

	video::SColor bgcolor(140, 0, 0, 0);

	{
		core::rect < s32 > rect(0, 0, 620, 620);
		rect += AbsoluteRect.UpperLeftCorner;
		driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect);
	}

	gui::IGUIElement::draw();
}

bool GUIKeyChangeMenu::acceptInput()
{
	g_settings->set("keymap_forward", key_forward.sym());
	g_settings->set("keymap_backward", key_backward.sym());
	g_settings->set("keymap_left", key_left.sym());
	g_settings->set("keymap_right", key_right.sym());
	g_settings->set("keymap_jump", key_jump.sym());
	g_settings->set("keymap_sneak", key_sneak.sym());
	g_settings->set("keymap_inventory", key_inventory.sym());
	g_settings->set("keymap_chat", key_chat.sym());
	g_settings->set("keymap_cmd", key_cmd.sym());
	g_settings->set("keymap_rangeselect", key_range.sym());
	g_settings->set("keymap_freemove", key_fly.sym());
	g_settings->set("keymap_fastmove", key_fast.sym());
	g_settings->set("keymap_special1", key_use.sym());
	g_settings->set("keymap_print_debug_stacks", key_dump.sym());
	clearKeyCache();
	return true;
}
void GUIKeyChangeMenu::init_keys()
{
	key_forward = getKeySetting("keymap_forward");
	key_backward = getKeySetting("keymap_backward");
	key_left = getKeySetting("keymap_left");
	key_right = getKeySetting("keymap_right");
	key_jump = getKeySetting("keymap_jump");
	key_sneak = getKeySetting("keymap_sneak");
	key_inventory = getKeySetting("keymap_inventory");
	key_chat = getKeySetting("keymap_chat");
	key_cmd = getKeySetting("keymap_cmd");
	key_range = getKeySetting("keymap_rangeselect");
	key_fly = getKeySetting("keymap_freemove");
	key_fast = getKeySetting("keymap_fastmove");
	key_use = getKeySetting("keymap_special1");
	key_dump = getKeySetting("keymap_print_debug_stacks");
}

bool GUIKeyChangeMenu::resetMenu()
{
	if (activeKey >= 0)
	{
		switch (activeKey)
		{
		case GUI_ID_KEY_FORWARD_BUTTON:
			this->forward->setText(
					wgettext(key_forward.name()));
			break;
		case GUI_ID_KEY_BACKWARD_BUTTON:
			this->backward->setText(
					wgettext(key_backward.name()));
			break;
		case GUI_ID_KEY_LEFT_BUTTON:
			this->left->setText(wgettext(key_left.name()));
			break;
		case GUI_ID_KEY_RIGHT_BUTTON:
			this->right->setText(wgettext(key_right.name()));
			break;
		case GUI_ID_KEY_JUMP_BUTTON:
			this->jump->setText(wgettext(key_jump.name()));
			break;
		case GUI_ID_KEY_SNEAK_BUTTON:
			this->sneak->setText(wgettext(key_sneak.name()));
			break;
		case GUI_ID_KEY_INVENTORY_BUTTON:
			this->inventory->setText(
					wgettext(key_inventory.name()));
			break;
		case GUI_ID_KEY_CHAT_BUTTON:
			this->chat->setText(wgettext(key_chat.name()));
			break;
		case GUI_ID_KEY_CMD_BUTTON:
			this->cmd->setText(wgettext(key_cmd.name()));
			break;
		case GUI_ID_KEY_RANGE_BUTTON:
			this->range->setText(wgettext(key_range.name()));
			break;
		case GUI_ID_KEY_FLY_BUTTON:
			this->fly->setText(wgettext(key_fly.name()));
			break;
		case GUI_ID_KEY_FAST_BUTTON:
			this->fast->setText(wgettext(key_fast.name()));
			break;
		case GUI_ID_KEY_USE_BUTTON:
			this->use->setText(wgettext(key_use.name()));
			break;
		case GUI_ID_KEY_DUMP_BUTTON:
			this->dump->setText(wgettext(key_dump.name()));
			break;
		}
		activeKey = -1;
		return false;
	}
	return true;
}
bool GUIKeyChangeMenu::OnEvent(const SEvent& event)
{
	if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0
			&& event.KeyInput.PressedDown)
	{
		changeCtype("");
		KeyPress kp(event.KeyInput);

		if (activeKey == GUI_ID_KEY_FORWARD_BUTTON)
		{
			this->forward->setText(wgettext(kp.name()));
			this->key_forward = kp;
		}
		else if (activeKey == GUI_ID_KEY_BACKWARD_BUTTON)
		{
			this->backward->setText(wgettext(kp.name()));
			this->key_backward = kp;
		}
		else if (activeKey == GUI_ID_KEY_LEFT_BUTTON)
		{
			this->left->setText(wgettext(kp.name()));
			this->key_left = kp;
		}
		else if (activeKey == GUI_ID_KEY_RIGHT_BUTTON)
		{
			this->right->setText(wgettext(kp.name()));
			this->key_right = kp;
		}
		else if (activeKey == GUI_ID_KEY_JUMP_BUTTON)
		{
			this->jump->setText(wgettext(kp.name()));
			this->key_jump = kp;
		}
		else if (activeKey == GUI_ID_KEY_SNEAK_BUTTON)
		{
			this->sneak->setText(wgettext(kp.name()));
			this->key_sneak = kp;
		}
		else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON)
		{
			this->inventory->setText(wgettext(kp.name()));
			this->key_inventory = kp;
		}
		else if (activeKey == GUI_ID_KEY_CHAT_BUTTON)
		{
			this->chat->setText(wgettext(kp.name()));
			this->key_chat = kp;
		}
		else if (activeKey == GUI_ID_KEY_CMD_BUTTON)
		{
			this->cmd->setText(wgettext(kp.name()));
			this->key_cmd = kp;
		}
		else if (activeKey == GUI_ID_KEY_RANGE_BUTTON)
		{
			this->range->setText(wgettext(kp.name()));
			this->key_range = kp;
		}
		else if (activeKey == GUI_ID_KEY_FLY_BUTTON)
		{
			this->fly->setText(wgettext(kp.name()));
			this->key_fly = kp;
		}
		else if (activeKey == GUI_ID_KEY_FAST_BUTTON)
		{
			this->fast->setText(wgettext(kp.name()));
			this->key_fast = kp;
		}
		else if (activeKey == GUI_ID_KEY_USE_BUTTON)
		{
			this->use->setText(wgettext(kp.name()));
			this->key_use = kp;
		}
		else if (activeKey == GUI_ID_KEY_DUMP_BUTTON)
		{
			this->dump->setText(wgettext(kp.name()));
			this->key_dump = kp;
		}
		changeCtype("C");
		activeKey = -1;
		return true;
	}
	if (event.EventType == EET_GUI_EVENT)
	{
		if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST
				&& isVisible())
		{
			if (!canTakeFocus(event.GUIEvent.Element))
			{
				dstream << "GUIMainMenu: Not allowing focus change."
						<< std::endl;
				// Returning true disables focus change
				return true;
			}
		}
		if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED)
		{
			if(event.GUIEvent.Caller->getID() != GUI_ID_BACK_BUTTON &&
				event.GUIEvent.Caller->getID() != GUI_ID_ABORT_BUTTON)
			{
				changeCtype("");
			}

			switch (event.GUIEvent.Caller->getID())
			{
			case GUI_ID_BACK_BUTTON: //back
				acceptInput();
				quitMenu();
				return true;
			case GUI_ID_ABORT_BUTTON: //abort
				quitMenu();
				return true;
			case GUI_ID_KEY_FORWARD_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->forward->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_BACKWARD_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->backward->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_LEFT_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->left->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_RIGHT_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->right->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_USE_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->use->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_FLY_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->fly->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_FAST_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->fast->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_JUMP_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->jump->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_CHAT_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->chat->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_CMD_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->cmd->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_SNEAK_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->sneak->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_INVENTORY_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->inventory->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_DUMP_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->dump->setText(wgettext("press Key"));
				break;
			case GUI_ID_KEY_RANGE_BUTTON:
				resetMenu();
				activeKey = event.GUIEvent.Caller->getID();
				this->range->setText(wgettext("press Key"));
				break;
			}
			//Buttons
			changeCtype("C");

		}
	}
	return Parent ? Parent->OnEvent(event) : false;
}