void CCardLabel::mouseMoveEvent(QMouseEvent *ev)
{
    if (mLockButton)
    {
        mLockButton->setVisible(mLockButton->isChecked()
            || (mCard.isValid() && mLockButton->geometry().contains(ev->pos())));
    }
    if (mLastLeftClickPos && mCard.isValid())
    {
        QLineF moveLine(ev->globalPos(), *mLastLeftClickPos);
        if (moveLine.length() >= QApplication::startDragDistance())
        {
            QDrag *drag = new QDrag(this);
            QMimeData *dragData = createCardLabelDropData(*this);
            drag->setMimeData(dragData);
            drag->setHotSpot(ev->pos());

            const QPixmap *unitImg = pixmap();
            if (unitImg)
            {
                int w = unitImg->width() / 2;
                int h = unitImg->height() / 2;
                QPixmap dragImg(w, h);
                dragImg.fill(Qt::transparent);
                QPainter painter(&dragImg);
                painter.setOpacity(0.75);
                painter.drawPixmap(0, 0, w, h, unitImg->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation));
                painter.end();
                drag->setPixmap(dragImg);
            }

            if (QApplication::keyboardModifiers() == Qt::ControlModifier || !acceptDrops())
            {     
                drag->exec(Qt::CopyAction);
            }
            else
            {
                CCard cardBuf = mCard;
                bool lockBuf = isLocked();
                setCard(CCard::INVALID_CARD);
                setLocked(false);
                if (!drag->exec(Qt::MoveAction))
                {
                    setCard(cardBuf);
                    setLocked(lockBuf);
                }
            }
            delete mLastLeftClickPos;
            mLastLeftClickPos = 0;
            emit unitDragged();
        }
    }
}
Ejemplo n.º 2
0
bool ShowFunction::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLShowFunction)
    {
        qWarning() << Q_FUNC_INFO << "ShowFunction node not found";
        return false;
    }

    QXmlStreamAttributes attrs = root.attributes();

    if (attrs.hasAttribute(KXMLShowFunctionID))
        setFunctionID(attrs.value(KXMLShowFunctionID).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionStartTime))
        setStartTime(attrs.value(KXMLShowFunctionStartTime).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionDuration))
        setDuration(attrs.value(KXMLShowFunctionDuration).toString().toUInt());
    if (attrs.hasAttribute(KXMLShowFunctionColor))
        setColor(QColor(attrs.value(KXMLShowFunctionColor).toString()));
    if (attrs.hasAttribute(KXMLShowFunctionLocked))
        setLocked(true);

    root.skipCurrentElement();

    return true;
}
void CCardLabel::dropEvent(QDropEvent *ev)
{
    if (ev && isCardLabelDropData(ev->mimeData()))
    {
        QString textData = ev->mimeData()->html().toLatin1();
        QStringList valueList = textData.split(QRegExp("=|;"));
        if (valueList.size() == 4)
        {
            bool ok1(true);
            bool ok2(true);
            int id = valueList.at(1).toInt(&ok1);
            bool locked = valueList.at(3).toInt(&ok2) == 1;
            if (ok1 && ok2)
            {
                ev->accept();
                const CCard &card = CCardTable::getCardTable().getCardForId(id);
                if (card.isValid())
                {
                    CCard cardBuf = mCard;
                    bool lockBuf = isLocked();
                    setCard(card);
                    setLocked(locked);
                    CCardLabel *source = dynamic_cast<CCardLabel*>(ev->source());
                    if (source && source != this && ev->dropAction() == Qt::MoveAction)
                    {
                        source->setCard(cardBuf);
                        source->setLocked(lockBuf);
                    }
                    emit unitDropped();
                }
            }
        }
    }
}
Ejemplo n.º 4
0
void QcNumberBox::updateText()
{
  QString str;

  switch( _valueType ) {
    case Number:
      str = stringForVal( _value );
      break;
    case Text:
      return; // text was already set
    case Infinite:
      str = "+inf"; break;
    case InfiniteNegative:
      str = "-inf"; break;
    case NaN:
      str = "NaN"; break;
  }

  blockSignals(true);
  setText( str );
  // Set cursor to beginning so most significant digits are shown
  // if widget size too small.
  setCursorPosition(0);
  setLocked( true );
  blockSignals(false);
}
Ejemplo n.º 5
0
QcNumberBox::QcNumberBox()
: scroll( true ),
  lastPos( 0 ),
  editedTextColor( QColor( "red" ) ),
  normalTextColor( palette().color(QPalette::Text) ),
  _validator( new QDoubleValidator( this ) ),
  step( 0.1f ),
  scrollStep( 1.0f ),
  dragDist( 10.f ),
  _value( 0. ),
  _valueType( Number ),
  _minDec(0),
  _maxDec(2)
{
  _validator->setDecimals( _maxDec );
  setValidator( _validator );

  // Do not display thousands separator. It only eats up precious space.
  QLocale loc( locale() );
  loc.setNumberOptions( QLocale::OmitGroupSeparator );
  setLocale( loc );

  setLocked( true );

  connect( this, SIGNAL( editingFinished() ),
           this, SLOT( onEditingFinished() ) );
  connect( this, SIGNAL( valueChanged() ),
           this, SLOT( updateText() ), Qt::QueuedConnection );
  setValue( 0 );
}
Ejemplo n.º 6
0
void FMainWindow::onSystemTrayIconClicked(QSystemTrayIcon::ActivationReason reason)
{
    switch(reason)
        {
        //单击
        case QSystemTrayIcon::Trigger:
            //双击
        case QSystemTrayIcon::DoubleClick:
            if(isHidden())
            {
                //恢复窗口显示
                show();
                //一下两句缺一均不能有效将窗口置顶
                setWindowState(Qt::WindowActive);
                activateWindow();
                setLocked(locked);
            }
            else
            {
                if(! locked)
                {
                    hide();
                }
            }
            break;
        case QSystemTrayIcon::Context:
            break;
        default:
            break;
        }
}
Ejemplo n.º 7
0
void Cell::start(Command command)
{
    if((ddirs == Free) || (ddirs == None) || gameOver)
    {
	if(blinkTimer)
            killTimer(blinkTimer);
        blinkTimer = startTimer(BlinkTimeout);
	emit noRotation();
    }
    else if(command == LockUnlock)
    {
	setLocked(!locked);
    }
    else if(locked)
    {
	if(blinkTimer)
            killTimer(blinkTimer);
        blinkTimer = startTimer(BlinkTimeout);
	emit noRotation();
    }
    else if(command == RotationToLeft)
    {
	if(rotationTimer)
            killTimer(rotationTimer);
	rotationStep = -RotationStep;
        rotationTimer = startTimer(RotationTimeout);
    }
    else if(command == RotationToRight)
    {
	if(rotationTimer)
            killTimer(rotationTimer);
	rotationStep = RotationStep;
        rotationTimer = startTimer(RotationTimeout);
    }
}
Ejemplo n.º 8
0
void QcNumberBox::keyPressEvent ( QKeyEvent * event )
{
  if( !isReadOnly() ) return QLineEdit::keyPressEvent( event );

  int key = event->key();

  if( key == Qt::Key_Up ){
    stepBy( 1, step );
    Q_EMIT( action() );
    return;
  }
  else if( key == Qt::Key_Down ) {
    stepBy( -1, step );
    Q_EMIT( action() );
    return;
  }
  else {
    // unlock typing if valid char is entered
    QString t = event->text();
    int i = 0;
    if( !t.isEmpty() &&
        ( _validator->validate( t, i ) != QValidator::Invalid ) )
    {
      blockSignals(true);
      clear();
      blockSignals( false );
      setLocked( false );
    }
  }

  QLineEdit::keyPressEvent( event );
}
Ejemplo n.º 9
0
bool ExistenceChecker::checkExistence(const QString &addr)
{
    if (locked_) return false;
    setLocked(true);

    auto address = Kullo::Api::Address::create(addr.toStdString());
    if (!address)
    {
        Log.e() << "Existence check run with invalid Kullo address: "
                << addr.toStdString();
        emit invalidKulloAddress();
        setLocked(false);
        return true;
    }

    bgTask_ = client_->raw()->addressExistsAsync(address, listener_);
    return true;
}
Ejemplo n.º 10
0
bool Mutex::tryLock() {
  bool result;

  if ((result = m_mutex->tryLock())) {
    setLocked();
  }

  return result;
}
Ejemplo n.º 11
0
bool Mutex::tryLock(int timeout) {
  bool result;

  if ((result = m_mutex->tryLock(timeout))) {
    setLocked();
  }

  return result;
}
Ejemplo n.º 12
0
ItemDoor::ItemDoor(LvlScene *parentScene, QGraphicsItem *parent)
    : LvlBaseItem(parentScene, parent)
{
    construct();
    if(!parentScene) return;
    setScenePoint(parentScene);
    m_scene->addItem(this);
    setLocked(m_scene->m_lockDoor);
}
Ejemplo n.º 13
0
/**
 * @brief Update visiblity of lock buttons
 * @param bool _lockEnabled
 */
void TrayIcon::setLockEnabled(bool _lockEnabled)
{
    m_actionLock->setVisible(_lockEnabled);
    m_actionUnlock->setVisible(_lockEnabled);

    if (_lockEnabled)
    {
        setLocked(m_ctrl->locked());
    }
}
Ejemplo n.º 14
0
ItemPhysEnv::ItemPhysEnv(LvlScene *parentScene, QGraphicsItem *parent)
    : LvlBaseItem(parentScene, parent)
{
    construct();
    if(!parentScene) return;
    setScenePoint(parentScene);
    m_scene->addItem(this);
    m_gridSize = m_scene->m_configs->defaultGrid.general / 2;
    setZValue(m_scene->Z_sys_PhysEnv);
    setLocked(m_scene->m_lockPhysenv);
}
Ejemplo n.º 15
0
DoorActor::DoorActor(const String& spritePath, const Bitmask* const maskOpen, const Bitmask* const maskClosed, const Vector2& position, const Vector2& size, const std::vector<ButtonActor *>& buttons, bool locked)
    : CollidingActor(maskClosed, size)
    , m_spritePath(spritePath)
    , m_buttons(buttons)
{
    m_open = new Bitmask(*maskOpen);
    m_open->m_original_mask = maskOpen;
    m_closed = m_mask;
    setLocked(locked);

	SetPosition(position);
    m_open->setSize(size);
}
Ejemplo n.º 16
0
bool Video::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::Video))
    {
        qWarning() << Q_FUNC_INFO << root.attribute(KXMLQLCFunctionType)
                   << "is not Video";
        return false;
    }

    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();
        if (tag.tagName() == KXMLQLCVideoSource)
        {
            if (tag.hasAttribute(KXMLQLCVideoStartTime))
                setStartTime(tag.attribute(KXMLQLCVideoStartTime).toUInt());
            if (tag.hasAttribute(KXMLQLCVideoColor))
                setColor(QColor(tag.attribute(KXMLQLCVideoColor)));
            if (tag.hasAttribute(KXMLQLCVideoLocked))
                setLocked(true);
            if (tag.hasAttribute(KXMLQLCVideoScreen))
                setScreen(tag.attribute(KXMLQLCVideoScreen).toInt());
            if (tag.hasAttribute(KXMLQLCVideoFullscreen))
            {
                if (tag.attribute(KXMLQLCVideoFullscreen) == "1")
                    setFullscreen(true);
                else
                    setFullscreen(false);
            }
            if (tag.text().contains("://") == true)
                setSourceUrl(tag.text());
            else
                setSourceUrl(m_doc->denormalizeComponentPath(tag.text()));
        }
        else if (tag.tagName() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(tag);
        }
        node = node.nextSibling();
    }

    return true;
}
Ejemplo n.º 17
0
bool WindowManager::mousePressEvent(QObject *object, QEvent *event)
{
    // cast event and check buttons/modifiers
    QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
    if (!(Qt::NoModifier==mouseEvent->modifiers() && Qt::LeftButton==mouseEvent->button())) {
        return false;
    }

    // check lock
    if (isLocked()) {
        return false;
    } else {
        setLocked(true);
    }

    // cast to widget
    QWidget *widget = static_cast<QWidget*>(object);

    // check if widget can be dragged from current position
    if (isBlackListed(widget) || !canDrag(widget)) {
        return false;
    }

    // retrieve widget's child at event position
    QPoint position(mouseEvent->pos());
    QWidget *child = widget->childAt(position);
    if (!canDrag(widget, child, position)) {
        return false;
    }

    // save target and drag point
    _target = widget;
    _dragPoint = position;
    _globalDragPoint = mouseEvent->globalPos();
    _dragAboutToStart = true;

    // send a move event to the current child with same position
    // if received, it is caught to actually start the drag
    QPoint localPoint(_dragPoint);
    if (child) {
        localPoint = child->mapFrom(widget, localPoint);
    } else {
        child = widget;
    }
    QMouseEvent localMouseEvent(QEvent::MouseMove, localPoint, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
    qApp->sendEvent(child, &localMouseEvent);
    // never eat event
    return false;
}
Ejemplo n.º 18
0
void EpisodeConverter::workFinished(bool isFine)
{
    m_process.waitForFinished();
    m_progressWatcher.stop();
    ui->progressBar->reset();
    emit setLocked(false);

    if(isFine)
        QMessageBox::information(this, tr("Work finished"), tr("Episode has been converted!"));
    else
        QMessageBox::warning(this,
                             tr("Error occouped while work process"),
                             tr("Episode conversion aborted with error: %1")
                             .arg(m_worker.errorString()));
}
Ejemplo n.º 19
0
void DoorActor::Update(float dt){
	std::vector<ButtonActor*>::iterator it;
    if(!m_buttons.empty())
	{
        bool tmp=false;
	    for(it=m_buttons.begin();it!=m_buttons.end();it++){
		    if(!(*it)->isPressed()){
			    tmp=true;
			    break;
		    }
	    }
	    setLocked(tmp);
    }

    CollidingActor::Update(dt);
}
Ejemplo n.º 20
0
bool Audio::loadXML(QXmlStreamReader &root)
{
    if (root.name() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attributes().value(KXMLQLCFunctionType).toString() != typeToString(Function::Audio))
    {
        qWarning() << Q_FUNC_INFO << root.attributes().value(KXMLQLCFunctionType).toString()
                   << "is not Audio";
        return false;
    }

    QString fname = name();

    while (root.readNextStartElement())
    {
        if (root.name() == KXMLQLCAudioSource)
        {
            QXmlStreamAttributes attrs = root.attributes();
            if (attrs.hasAttribute(KXMLQLCAudioDevice))
                setAudioDevice(attrs.value(KXMLQLCAudioDevice).toString());
            if (attrs.hasAttribute(KXMLQLCAudioStartTime))
                setStartTime(attrs.value(KXMLQLCAudioStartTime).toString().toUInt());
            if (attrs.hasAttribute(KXMLQLCAudioColor))
                setColor(QColor(attrs.value(KXMLQLCAudioColor).toString()));
            if (attrs.hasAttribute(KXMLQLCAudioLocked))
                setLocked(true);
            setSourceFileName(m_doc->denormalizeComponentPath(root.readElementText()));
        }
        else if (root.name() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(root);
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown Audio tag:" << root.name();
            root.skipCurrentElement();
        }
    }

    setName(fname);

    return true;
}
Ejemplo n.º 21
0
void ExistenceChecker::onError(const std::string &address, Kullo::Api::NetworkError error)
{
    setLocked(false);

    switch (error) {
    case Kullo::Api::NetworkError::Server:
        Log.e() << "Server error.";
        emit serverError(QString::fromStdString(address));
        break;
    case Kullo::Api::NetworkError::Protocol:
        Log.e() << "Protocol error.";
        emit protocolError(QString::fromStdString(address));
        break;
    case Kullo::Api::NetworkError::Connection:
        Log.e() << "Connection error.";
        emit networkError(QString::fromStdString(address));
        break;
    default:
        kulloAssert(false);
    }
}
Ejemplo n.º 22
0
void EpisodeConverter::on_DoMadJob_clicked()
{
    if(ui->episodePath->text().isEmpty() || !QDir(ui->episodePath->text()).exists())
    {
        QMessageBox::warning(this,
                             tr("Episode path error"),
                             tr("Episode path wasn't declared. Please choice target episode path first."));
        return;
    }

    m_worker.setBackup(ui->makeBacup->isChecked());
    emit setLocked(true);

    m_process = QtConcurrent::run<bool>(&m_worker,
                                        &EpisodeConverterWorker::initJob,
                                        ui->episodePath->text(),
                                        ui->lookForSubDirs->isChecked(),
                                        ui->targetFormat->currentIndex(),
                                        ui->targetFormatVer->value());

    while(m_process.isRunning())
    {
        qApp->processEvents(); QThread::msleep(10);
    }

    if(!m_process.result())
    {
        QMessageBox::warning(this,
                             tr("Worker error"),
                             tr("Can't initialize job because %1").arg(m_worker.errorString()));
        return;
    }

    m_process = QtConcurrent::run<bool>(&m_worker, &EpisodeConverterWorker::runJob);
    m_progressWatcher.start(100);
}
Ejemplo n.º 23
0
void AudioItem::slotLockItemClicked()
{
    setLocked(!isLocked());
}
Ejemplo n.º 24
0
void LVL_Player::update(float ticks)
{
    if(isLocked) return;
    if(!_isInited) return;
    if(!camera) return;
    LVL_Section* section = sct();
    if(!section) return;

    event_queue.processEvents(ticks);

    if((isWarping) || (!isAlive))
    {
        animator.tickAnimation(ticks);
        updateCamera();
        return;
    }

    _onGround = !foot_contacts_map.isEmpty();
    on_slippery_surface = !foot_sl_contacts_map.isEmpty();
    bool climbableUp  = !climbable_map.isEmpty();
    bool climbableDown= climbableUp && !_onGround;
    climbing = (climbableUp && climbing && !_onGround && (posRect.center().y()>=(climbableHeight-physics_cur.velocity_climb_y_up)) );
    if(_onGround)
    {
        phys_setup.decelerate_x =
                (fabs(speedX())<=physics_cur.MaxSpeed_walk)?
                (on_slippery_surface?physics_cur.decelerate_stop/physics_cur.slippery_c : physics_cur.decelerate_stop):
                (on_slippery_surface?physics_cur.decelerate_run/physics_cur.slippery_c : physics_cur.decelerate_run);

        if(physics_cur.strict_max_speed_on_ground)
        {
            if((speedX()>0)&&(speedX()>phys_setup.max_vel_x))
                setSpeedX(phys_setup.max_vel_x);
            else
            if((speedX()<0)&&(speedX()<phys_setup.min_vel_x))
                setSpeedX(phys_setup.min_vel_x);
        }
    }
    else
        phys_setup.decelerate_x = physics_cur.decelerate_air;

    if(doKill)
    {
        doKill=false;
        isAlive = false;
        setPaused(true);
        LvlSceneP::s->checkPlayers();
        return;
    }

    if(climbing)
    {
        PGE_Phys_Object* climbableItem = static_cast<PGE_Phys_Object*>((void*)(intptr_t)climbable_map[climbable_map.keys().first()]);
        if(climbableItem)
        {
            _velocityX_add=climbableItem->speedX();
            _velocityY_add=climbableItem->speedY();
        } else
        {
            _velocityX_add=0.0f;
            _velocityY_add=0.0f;
        }

        if(gscale_Backup != 1)
        {
            setGravityScale(0);
            gscale_Backup = 1;
        }
    }
    else
    {
        if(gscale_Backup != 0.f)
        {
            setGravityScale(physics_cur.gravity_scale);
            gscale_Backup = 0.f;
        }
    }

    if(climbing)
    {
        setSpeed(0,0);
    }

    if(environments_map.isEmpty())
    {
        if(last_environment!=section->getPhysicalEnvironment() )
        {
            environment = section->getPhysicalEnvironment();
        }
    }
    else
    {
        int newEnv = section->getPhysicalEnvironment();

        foreach(int x, environments_map)
        {
            newEnv = x;
        }

        if(last_environment != newEnv)
        {
            qDebug()<<"Enter to environment" << newEnv;
            environment = newEnv;
        }
    }

    refreshEnvironmentState();

    if(_onGround)
    {
        if(!floating_isworks)
        {
            floating_timer=floating_maxtime;
        }
    }

    //Running key
    if(keys.run)
    {
        if(!_isRunning)
        {
            phys_setup.max_vel_x = physics_cur.MaxSpeed_run;
            phys_setup.min_vel_x = -physics_cur.MaxSpeed_run;
            _isRunning=true;
        }
    }
    else
    {
        if(_isRunning)
        {
            phys_setup.max_vel_x = physics_cur.MaxSpeed_walk;
            phys_setup.min_vel_x = -physics_cur.MaxSpeed_walk;
            _isRunning=false;
        }
    }
    if((physics_cur.ground_c_max!=1.0f))
    {
        phys_setup.max_vel_x = fabs(_isRunning ?
                    physics_cur.MaxSpeed_run :
                    physics_cur.MaxSpeed_walk) *(_onGround?physics_cur.ground_c_max:1.0f);
        phys_setup.min_vel_x = -fabs(_isRunning ?
                    physics_cur.MaxSpeed_run :
                    physics_cur.MaxSpeed_walk) *(_onGround?physics_cur.ground_c_max:1.0f);
    }


    if(keys.alt_run)
    {
        if(attack_enabled && !attack_pressed && !climbing)
        {
            attack_pressed=true;

            if(keys.up)
                attack(Attack_Up);
            else
            if(keys.down)
                attack(Attack_Down);
            else
            {
                attack(Attack_Forward);
                PGE_Audio::playSoundByRole(obj_sound_role::PlayerTail);
                animator.playOnce(MatrixAnimator::RacoonTail, _direction, 75, true, true, 1);
            }
        }
    }
    else
    {
        if(attack_pressed) attack_pressed=false;
    }



    //if
    if(!keys.up && !keys.down && !keys.left && !keys.right)
    {
        if(wasEntered)
        {
            wasEntered = false;
            wasEnteredTimeout=0;
        }
    }

    //Reset state
    if(wasEntered)
    {
        wasEnteredTimeout-=ticks;
        if(wasEnteredTimeout<0)
        {
            wasEnteredTimeout=0;
            wasEntered=false;
        }
    }

    if(keys.up)
    {
        if(climbableUp&&(jumpTime<=0))
        {
            setDuck(false);
            climbing=true;
            floating_isworks=false;//!< Reset floating on climbing start
        }

        if(climbing)
        {
            if(posRect.center().y() >= climbableHeight)
                setSpeedY(-physics_cur.velocity_climb_y_up);
        }
    }

    if(keys.down)
    {
        if( climbableDown && (jumpTime<=0) )
        {
            setDuck(false);
            climbing=true;
            floating_isworks=false;//!< Reset floating on climbing start
        }
        else
        {
            if((duck_allow & !ducking)&&( (animator.curAnimation()!=MatrixAnimator::RacoonTail) ) )
            {
                setDuck(true);
            }
        }

        if(climbing)
        {
            setSpeedY(physics_cur.velocity_climb_y_down);
        }
    }
    else
    {
        if(ducking)
            setDuck(false);
    }

    if( (!keys.left) || (!keys.right) )
    {
        bool turning=(((speedX()>0)&&(_direction<0))||((speedX()<0)&&(_direction>0)));

        float force = turning?
                    physics_cur.decelerate_turn :
                    (fabs(speedX())>physics_cur.MaxSpeed_walk)?physics_cur.run_force : physics_cur.walk_force;

        if(on_slippery_surface) force=force/physics_cur.slippery_c;
        else if((_onGround)&&(physics_cur.ground_c!=1.0f)) force=force*physics_cur.ground_c;

        if(keys.left) _direction=-1;
        if(keys.right) _direction=1;

        if(!ducking || !_onGround)
        {
            //If left key is pressed
            if(keys.right && collided_right.isEmpty())
            {
                if(climbing)
                    setSpeedX(physics_cur.velocity_climb_x);
                else
                    applyAccel(force, 0);
            }
            //If right key is pressed
            if(keys.left && collided_left.isEmpty())
            {
                if(climbing)
                    setSpeedX(-physics_cur.velocity_climb_x);
                else
                    applyAccel(-force, 0);
            }
        }
    }

    if( keys.alt_jump )
    {
        //Temporary it is ability to fly up!
        if(!bumpDown && !bumpUp) {
            setSpeedY(-physics_cur.velocity_jump);
        }
    }

    if( keys.jump )
    {
        if(!JumpPressed)
        {
            if(environment!=LVL_PhysEnv::Env_Water)
                { if(climbing || _onGround || (environment==LVL_PhysEnv::Env_Quicksand))
                    PGE_Audio::playSoundByRole(obj_sound_role::PlayerJump); }
            else
                PGE_Audio::playSoundByRole(obj_sound_role::PlayerWaterSwim);
        }

        if((environment==LVL_PhysEnv::Env_Water)||(environment==LVL_PhysEnv::Env_Quicksand))
        {
            if(!JumpPressed)
            {
                if(environment==LVL_PhysEnv::Env_Water)
                {
                    if(!ducking) animator.playOnce(MatrixAnimator::SwimUp, _direction, 75);
                }
                else
                if(environment==LVL_PhysEnv::Env_Quicksand)
                {
                    if(!ducking) animator.playOnce(MatrixAnimator::JumpFloat, _direction, 64);
                }

                JumpPressed=true;
                jumpTime = physics_cur.jump_time;
                jumpVelocity=physics_cur.velocity_jump;
                floating_timer = floating_maxtime;
                setSpeedY(speedY()-jumpVelocity);
            }
        }
        else
        if(!JumpPressed)
        {
            JumpPressed=true;
            if(_onGround || climbing)
            {
                climbing=false;
                jumpTime=physics_cur.jump_time;
                jumpVelocity=physics_cur.velocity_jump;
                floating_timer = floating_maxtime;
                setSpeedY(-jumpVelocity-fabs(speedX()/physics_cur.velocity_jump_c));
            }
            else
            if((floating_allow)&&(floating_timer>0))
            {
                floating_isworks=true;

                //if true - do floating with sin, if false - do with cos.
                floating_start_type=(speedY()<0);

                setSpeedY(0);
                setGravityScale(0);
            }
        }
        else
        {
            if(jumpTime>0)
            {
                jumpTime -= ticks;
                setSpeedY(-jumpVelocity-fabs(speedX()/physics_cur.velocity_jump_c));
            }

            if(floating_isworks)
            {
                floating_timer -= ticks;
                if(floating_start_type)
                    setSpeedY( state_cur.floating_amplitude*(-cos(floating_timer/80.0)) );
                else
                    setSpeedY( state_cur.floating_amplitude*(cos(floating_timer/80.0)) );
                if(floating_timer<=0)
                {
                    floating_timer=0;
                    floating_isworks=false;
                    setGravityScale(climbing?0:physics_cur.gravity_scale);
                }
            }
        }
    }
    else
    {
        jumpTime=0;
        if(JumpPressed)
        {
            JumpPressed=false;
            if(floating_allow)
            {
                if(floating_isworks)
                {
                    floating_timer=0;
                    floating_isworks=false;
                    setGravityScale(climbing?0:physics_cur.gravity_scale);
                }
            }
        }
    }

    refreshAnimation();
    animator.tickAnimation(ticks);

    PGE_RectF sBox = section->sectionLimitBox();

    //Return player to start position on fall down
    if( posY() > sBox.bottom()+_height )
    {
        kill(DEAD_fall);
    }

    if(bumpDown)
    {
        bumpDown=false;
        jumpTime=0;
        setSpeedY(bumpVelocity);
    }
    else
    if(bumpUp)
    {
        bumpUp=false;
        if(keys.jump)
        {
            jumpTime=bumpJumpTime;
            jumpVelocity=bumpJumpVelocity;
        }
        setSpeedY( (keys.jump ?
                        (-fabs(bumpJumpVelocity)-fabs(speedX()/physics_cur.velocity_jump_c)):
                         -fabs(bumpJumpVelocity)) );
    }


    //Connection of section opposite sides
    if(isExiting) // Allow walk offscreen if exiting
    {
        if((posX() < sBox.left()-_width-1 )||(posX() > sBox.right() + 1 ))
        {
            setGravityScale(0.0);//Prevent falling [we anyway exited from this level, isn't it?]
            setSpeedY(0.0);
        }
        if(keys.left||keys.right)
        {
            if((environment==LVL_PhysEnv::Env_Water)||(environment==LVL_PhysEnv::Env_Quicksand))
            {
                keys.run=true;
                if(_exiting_swimTimer<0 && !keys.jump)
                    keys.jump=true;
                else
                if(_exiting_swimTimer<0 && keys.jump)
                {
                    keys.jump=false; _exiting_swimTimer=(environment==LVL_PhysEnv::Env_Quicksand)? 1 : 500;
                }
                _exiting_swimTimer-= ticks;
            } else keys.run=false;
        }
    }
    else
    if(section->isWarp())
    {
        if(posX() < sBox.left()-_width-1 )
            setPosX( sBox.right()+1 );
        else
        if(posX() > sBox.right() + 1 )
            setPosX( sBox.left()-_width-1 );
    }
    else
    {

        if(section->ExitOffscreen())
        {
            if(section->RightOnly())
            {
                if( posX() < sBox.left())
                {
                    setPosX( sBox.left() );
                    setSpeedX(0.0);
                }
            }

            if((posX() < sBox.left()-_width-1 ) || (posX() > sBox.right() + 1 ))
            {
                setLocked(true);
                _no_render=true;
                LvlSceneP::s->setExiting(1000, LvlExit::EXIT_OffScreen);
                return;
            }
        }
        else
        {
            //Prevent moving of player away from screen
            if( posX() < sBox.left())
            {
                setPosX(sBox.left());
                setSpeedX(0.0);
            }
            else
            if( posX()+_width > sBox.right())
            {
                setPosX(sBox.right()-_width);
                setSpeedX(0.0);
            }
        }
    }

    if(_stucked)
    {
        posRect.setX(posRect.x()-_direction*2);
        applyAccel(0, 0);
    }

    processWarpChecking();

    if(_doSafeSwitchCharacter) setCharacter(characterID, stateID);

    try {
        lua_onLoop();
    } catch (luabind::error& e) {
        LvlSceneP::s->getLuaEngine()->postLateShutdownError(e);
    }
    updateCamera();
}
Ejemplo n.º 25
0
void PwDatabaseFacade::onDbLocked() {
    setLocked(true);
    releaseDatabase(false); // no need to lock, already locked
    emit dbLocked();
}
Ejemplo n.º 26
0
void Mutex::lock() {
  m_mutex->lock();
  setLocked();
}
Ejemplo n.º 27
0
void PwDatabaseFacade::onDbUnlocked() {
    setLocked(false);
    emit dbUnlocked();
}
Ejemplo n.º 28
0
void RGBMatrixItem::slotLockItemClicked()
{
    setLocked(!isLocked());
}
Ejemplo n.º 29
0
void QcNumberBox::mouseDoubleClickEvent ( QMouseEvent * event )
{
  Q_UNUSED( event );
  setCursorPosition( cursorPositionAt( event->pos() ) );
  setLocked( false );
}
Ejemplo n.º 30
0
bool Chaser::loadXML(const QDomElement& root)
{
    if (root.tagName() != KXMLQLCFunction)
    {
        qWarning() << Q_FUNC_INFO << "Function node not found";
        return false;
    }

    if (root.attribute(KXMLQLCFunctionType) != typeToString(Function::Chaser))
    {
        qWarning() << Q_FUNC_INFO << root.attribute(KXMLQLCFunctionType)
                   << "is not a chaser";
        return false;
    }

    /* Load chaser contents */
    QDomNode node = root.firstChild();
    while (node.isNull() == false)
    {
        QDomElement tag = node.toElement();

        if (tag.tagName() == KXMLQLCBus)
        {
            m_legacyHoldBus = tag.text().toUInt();
        }
        else if (tag.tagName() == KXMLQLCFunctionSpeed)
        {
            loadXMLSpeed(tag);
        }
        else if (tag.tagName() == KXMLQLCFunctionDirection)
        {
            loadXMLDirection(tag);
        }
        else if (tag.tagName() == KXMLQLCFunctionRunOrder)
        {
            loadXMLRunOrder(tag);
        }
        else if (tag.tagName() == KXMLQLCChaserSpeedModes)
        {
            QString str;

            str = tag.attribute(KXMLQLCFunctionSpeedFadeIn);
            setFadeInMode(stringToSpeedMode(str));

            str = tag.attribute(KXMLQLCFunctionSpeedFadeOut);
            setFadeOutMode(stringToSpeedMode(str));

            str = tag.attribute(KXMLQLCFunctionSpeedDuration);
            setDurationMode(stringToSpeedMode(str));
        }
        else if (tag.tagName() == KXMLQLCChaserSequenceTag)
        {
            QString str = tag.attribute(KXMLQLCChaserSequenceBoundScene);
            enableSequenceMode(str.toUInt());
            if (tag.hasAttribute(KXMLQLCChaserSequenceStartTime))
                setStartTime(tag.attribute(KXMLQLCChaserSequenceStartTime).toUInt());
            if (tag.hasAttribute(KXMLQLCChaserSequenceColor))
                setColor(QColor(tag.attribute(KXMLQLCChaserSequenceColor)));
            if (tag.hasAttribute(KXMLQLCChaserSequenceLocked))
                setLocked(true);
        }
        else if (tag.tagName() == KXMLQLCFunctionStep)
        {
            //! @todo stepNumber is useless if the steps are in the wrong order
            ChaserStep step;
            int stepNumber = -1;

            if (step.loadXML(tag, stepNumber) == true)
            {
                if (isSequence() == true)
                    step.fid = getBoundSceneID();
                if (stepNumber >= m_steps.size())
                    m_steps.append(step);
                else
                    m_steps.insert(stepNumber, step);
            }
        }
        else
        {
            qWarning() << Q_FUNC_INFO << "Unknown chaser tag:" << tag.tagName();
        }

        node = node.nextSibling();
    }

    return true;
}