Esempio n. 1
0
void QuitDialog::keyPressed(KeyEvent &event)
{
    const int actionId = event.getActionId();
    int dir = 0;

    switch (actionId)
    {
        case InputAction::GUI_SELECT:
        case InputAction::GUI_SELECT2:
            action(ActionEvent(nullptr, mOkButton->getActionEventId()));
            break;
        case InputAction::GUI_CANCEL:
            action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
            break;
        case InputAction::GUI_UP:
            dir = -1;
            break;
        case InputAction::GUI_DOWN:
            dir = 1;
            break;
        default:
            break;
    }

    if (dir != 0)
    {
        std::vector<RadioButton*>::const_iterator it = mOptions.begin();
        const std::vector<RadioButton*>::const_iterator
            it_end = mOptions.end();

        for (; it < it_end; ++it)
        {
            if ((*it)->isSelected())
                break;
        }

        if (it == mOptions.end())
        {
            if (mOptions[0])
                mOptions[0]->setSelected(true);
            return;
        }
        else if (it == mOptions.begin() && dir < 0)
        {
            it = mOptions.end();
        }

        it += dir;

        if (it == mOptions.end())
            it = mOptions.begin();

        (*it)->setSelected(true);
    }
}
Esempio n. 2
0
void WorldSelectDialog::keyPressed(KeyEvent &event)
{
    const int actionId = event.getActionId();

    if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
    {
        action(ActionEvent(nullptr,
            mChangeLoginButton->getActionEventId()));
    }
    else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
             || actionId == static_cast<int>(InputAction::GUI_SELECT2))
    {
        action(ActionEvent(nullptr, mChooseWorld->getActionEventId()));
    }
}
Esempio n. 3
0
	void HScrollBar::setValue( int val )
	{
		//store current value to compare later
		int targetVal = val;

		//perform bounds checking
		if (val <= getMinValue())
		{
			targetVal = getMinValue();
		}
		else if(val >= getMaxValue() - getLargeAmount())
		{

			targetVal = getMaxValue() - getLargeAmount();
		}


		//only reposition if there is a change
		if(targetVal != currentValue)
		{
			currentValue = targetVal;
			positionThumb();

			for(std::vector<HScrollBarListener*>::iterator it = 
				hScrollListeners.begin();
				it != hScrollListeners.end(); ++it)
			{
				if((*it))
					(*it)->valueChanged(this,currentValue);
			}

			dispatchActionEvent(ActionEvent(this));
		}
	}
Esempio n. 4
0
	void TextField::keyDown( KeyEvent &keyEvent )
	{
		handleKeyboard(keyEvent);
		if(keyEvent.getKey() == KEY_ENTER)
		{
			dispatchActionEvent(ActionEvent(this));
		}
			keyEvent.consume();
	}
Esempio n. 5
0
	void Button::mouseClick( MouseEvent &mouseEvent )
	{
		if(isToggleButton() && mouseEvent.getButton() == MOUSE_BUTTON_LEFT)
		{
			handleToggleClick();
			mouseEvent.consume();
		}

		if(mouseEvent.getButton() == MOUSE_BUTTON_LEFT)
		dispatchActionEvent(ActionEvent(this));
	}
Esempio n. 6
0
void RegisterDialog::keyPressed(KeyEvent &event)
{
    if (event.isConsumed())
    {
        mRegisterButton->setEnabled(canSubmit());
        return;
    }
    const InputActionT actionId = event.getActionId();
    if (actionId == InputAction::GUI_CANCEL)
    {
        action(ActionEvent(nullptr, mCancelButton->getActionEventId()));
    }
    else if (actionId == InputAction::GUI_SELECT ||
             actionId == InputAction::GUI_SELECT2)
    {
        action(ActionEvent(nullptr, mRegisterButton->getActionEventId()));
    }
    else
    {
        mRegisterButton->setEnabled(canSubmit());
    }
}
Esempio n. 7
0
void ServerDialog::mouseClicked(MouseEvent &event)
{
    if (event.getButton() == MouseButton::LEFT)
    {
        event.consume();
        if (event.getClickCount() == 2 &&
            event.getSource() == mServersList)
        {
            action(ActionEvent(mConnectButton,
                mConnectButton->getActionEventId()));
        }
    }
}
Esempio n. 8
0
void LoginDialog::keyPressed(KeyEvent &event)
{
    if (event.isConsumed())
    {
        mLoginButton->setEnabled(canSubmit());
        return;
    }

    const int actionId = event.getActionId();
    if (actionId == static_cast<int>(InputAction::GUI_CANCEL))
    {
        action(ActionEvent(nullptr, mServerButton->getActionEventId()));
    }
    else if (actionId == static_cast<int>(InputAction::GUI_SELECT)
             || actionId == static_cast<int>(InputAction::GUI_SELECT2))
    {
        action(ActionEvent(nullptr, mLoginButton->getActionEventId()));
    }
    else
    {
        mLoginButton->setEnabled(canSubmit());
    }
}
Esempio n. 9
0
void ServerDialog::keyPressed(KeyEvent &event)
{
    switch (event.getActionId())
    {
        case InputAction::GUI_CANCEL:
            event.consume();
            client->setState(STATE_EXIT);
            return;

        case InputAction::GUI_SELECT:
        case InputAction::GUI_SELECT2:
            event.consume();
            action(ActionEvent(nullptr,
                mConnectButton->getActionEventId()));
            return;

        case InputAction::GUI_INSERT:
            (new EditServerDialog(this, ServerInfo(), -1))->postInit();
            return;

        case InputAction::GUI_DELETE:
        {
            const int index = mServersList->getSelected();
            if (index >= 0)
            {
                mServersList->setSelected(0);
                mServers.erase(mServers.begin() + index);
                saveCustomServers();
            }
            return;
        }

        case InputAction::GUI_BACKSPACE:
        {
            const int index = mServersList->getSelected();
            if (index >= 0)
            {
                (new EditServerDialog(this, mServers.at(index),
                    index))->postInit();
            }
            return;
        }

        default:
            break;
    }
    if (!event.isConsumed())
        mServersList->keyPressed(event);
}
Esempio n. 10
0
void CharCreateDialog::keyPressed(KeyEvent &event)
{
    const InputActionT actionId = event.getActionId();
    switch (actionId)
    {
        case InputAction::GUI_CANCEL:
            event.consume();
            action(ActionEvent(mCancelButton,
                mCancelButton->getActionEventId()));
            break;

        default:
            break;
    }
}
Esempio n. 11
0
	void RadioButton::keyUp( KeyEvent &keyEvent )
	{
		if(!isDoingKeyAction)
		{
			return;
		}
		isDoingKeyAction = false;
		if(keyEvent.getKey() == KEY_SPACE || keyEvent.getKey() == KEY_ENTER)
		{
			dispatchActionEvent(ActionEvent(
				this));
			modifyRadioButtonState();
			nextCheckState();
			keyEvent.consume();
		}
	}
Esempio n. 12
0
void EditServerDialog::keyPressed(KeyEvent &event)
{
    if (event.isConsumed())
        return;

    const InputActionT actionId = event.getActionId();

    if (actionId == InputAction::GUI_CANCEL)
    {
        scheduleDelete();
    }
    else if (actionId == InputAction::GUI_SELECT ||
             actionId == InputAction::GUI_SELECT2)
    {
        action(ActionEvent(nullptr, mOkButton->getActionEventId()));
    }
}
Esempio n. 13
0
	void Button::keyUp( KeyEvent &keyEvent )
	{
		if(!isDoingKeyAction)
		{
			return;
		}
		isDoingKeyAction = false;
		if(keyEvent.getKey() == KEY_SPACE || keyEvent.getKey() == KEY_ENTER)
		{
			dispatchActionEvent(ActionEvent(
				this));
			handleToggleClick();
			modifyButtonState();

			keyEvent.consume();
		}
	}
Esempio n. 14
0
	void RadioButton::changeCheckedState( RadioButtonCheckedEnum state )
	{
		if(state == checkedState)
		{
			return;
		}
		checkedState = state;

		for(std::vector<RadioButtonListener*>::iterator it = 
			radioButtonListeners.begin();
			it != radioButtonListeners.end(); ++it)
		{
			if((*it))
				(*it)->checkedStateChanged(this,state);
		}

		if(checkedState == CHECKED)
		dispatchActionEvent(ActionEvent(this));
	}