void CScore::Mouse (int button, int state, int x, int y) {
	TWidget* clicked = ClickGUI(state, x, y);
	if (state == 0) {
		if (clicked == textbutton)
			State::manager.RequestEnterState (GameTypeSelect);
	}
}
void CEvent::Mouse (int button, int state, int x, int y) {
	if (state != 1) return;

	TWidget* clicked = ClickGUI(x, y);
	if(clicked == textbuttons[0]) {
		if (ready < 1)
			StartRace ();
	} else if(clicked == textbuttons[1] || clicked == textbuttons[2])
		State::manager.RequestEnterState (EventSelect);
}
void CNewPlayer::Mouse(int button, int state, int x, int y) {
	if (state == 1) {
		TWidget* clicked = ClickGUI(x, y);

		if (clicked == textbuttons[0])
			State::manager.RequestEnterState(Regist);
		else if (clicked == textbuttons[1])
			QuitAndAddPlayer();
	}
}
void CGameConfig::Mouse (int button, int state, int x, int y) {
	if (state == 1) {
		TWidget* focussed = ClickGUI(x, y);

		if (focussed == textbuttons[0])
			State::manager.RequestEnterState (*State::manager.PreviousState());
		else if (focussed == textbuttons[1])
			SetConfig ();
	}
}
void CEventSelect::Mouse(int button, int state, int x, int y) {
	if (state == 1) {
		TWidget* clicked = ClickGUI(x, y);
		if (textbuttons[0] == clicked) {
			if (Events.IsUnlocked(event->GetValue(), cup->GetValue()))
				EnterEvent();
		} else if (textbuttons[1] == clicked)
			State::manager.RequestEnterState(GameTypeSelect);
	}
}
void CRegist::Mouse (int button, int state, int x, int y) {
	if (state == 1) {
		TWidget* focussed = ClickGUI(x, y);
		if(focussed == textbuttons[0])
			QuitRegistration ();
		else if(focussed == textbuttons[1]) {
			g_game.player_id = player->GetValue();
			State::manager.RequestEnterState (NewPlayer);
		}
	}
}
void CRaceSelect::Mouse (int button, int state, int x, int y) {
	TWidget *focused = ClickGUI(state, x, y);
	if (state == 0) {
		if (textbuttons[0]->focussed())
			SetRaceConditions ();
		else if (textbuttons[1]->focussed())
			State::manager.RequestEnterState (GameTypeSelect);

		if (random_btn->focussed()) {
			mirror->SetValue(IRandom (0, 1));
			light->SetValue(IRandom (0, 3));
			snow->SetValue(IRandom (0, 3));
			wind->SetValue(IRandom (0, 3));
		}

		//UpdateInfo ();

		if (focused) focused->focus = false;
	}
}