void
MenuManager::set_menu(std::unique_ptr<Menu> menu)
{
  if (menu)
  {
    transition(m_menu_stack.empty() ? nullptr : m_menu_stack.back().get(),
               menu.get());
    m_menu_stack.clear();
    m_menu_stack.push_back(std::move(menu));
  }
  else
  {
    transition(m_menu_stack.empty() ? nullptr : m_menu_stack.back().get(),
               nullptr);
    m_menu_stack.clear();
  }

  // just to be sure...
  InputManager::current()->reset();
}
Example #2
0
/*!
  Handle a wheel event for the observed widget.

  Move the last point of the selection in case of isActive() == true

  \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(),
      widgetKeyPressEvent(), widgetKeyReleaseEvent()
*/
void QwtPicker::widgetWheelEvent(QWheelEvent *e)
{
    if ( pickRect().contains(e->pos()) )
        d_data->labelPosition = e->pos();
    else
        d_data->labelPosition = QPoint(-1, -1);

    updateDisplay();

    transition(e);
}
Example #3
0
void replay(const char *file_name)
{
	U8 data;
	int n = 0;

	f = fopen(file_name, "r");
	while (!feof(f)) {
		fread(&data, 1, 1, f);
		transition(data);
	}
}
Example #4
0
void Title::key_released(SDLKey key, SDLMod)
{
	if (key == SDLK_z)
	{
		Arena *arena = new Arena(m_inputDevice, 1);
		transition(arena);
	}
	
	if (key == SDLK_x)
	{
		Arena *arena = new Arena(m_inputDevice, 2);
		transition(arena);
	}
	
	if (key == SDLK_c)
	{
		Arena *arena = new Arena(m_inputDevice, 3);
		transition(arena);
	}
}
void PlayerSwimmingState :: onMoveReleased ( Direction d)
{
    tempDir = tempDir ^ d;
    if(!tempDir.isNone())
    {
        pData -> dir = tempDir;
    }
    else
        transition(new PlayerDivingState(pData));

}
Example #6
0
/* make one simulation iteration with lines lines.
 * old configuration is in from, new one is written to to.
 */
static void simulate(Line *from, Line *to, int lines)
{
   int x,y;
  
   boundary(from, lines);
   for (y = 1;  y <= lines;  y++) {
      for (x = 1;  x <= XSIZE;  x++) {
         to[y][x  ] = transition(from, x  , y);
      }
   }
}
/* Calculate the new values of an edge normal to the YZ plane */
inline void updateYZedge(int Ix, int Iy, int Iz, unsigned char *data,
				 unsigned char *newData, int y, int z, int rank) {
	int x;
	unsigned char c, old;

	for (x=2;x<Ix;x++) {
		c = count(Ix, Iy, Iz, data, x, y, z);
		old = data[xoff*x + yoff*y + z];
		newData[xoff*x + yoff*y + z] = transition(c, old);
	}
}
Example #8
0
/*!
  Handle a wheel event for the observed widget.

  Move the last point of the selection in case of isActive() == true

  \param wheelEvent Wheel event

  \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseDoubleClickEvent(), widgetMouseMoveEvent(),
      widgetKeyPressEvent(), widgetKeyReleaseEvent()
*/
void QwtPicker::widgetWheelEvent( QWheelEvent *wheelEvent )
{
    if ( pickArea().contains( wheelEvent->pos() ) )
        d_data->trackerPosition = wheelEvent->pos();
    else
        d_data->trackerPosition = QPoint( -1, -1 );

    updateDisplay();

    transition( wheelEvent );
}
/* Calculate the new values of an edge normal to the ZX plane */
inline void updateZXedge(int Ix, int Iy, int Iz, unsigned char *data,
				 unsigned char *newData, int z, int x, int rank) {
	int y;
	unsigned char c, old;

	for (y=2;y<Iy;y++) {
		c = count(Ix, Iy, Iz, data, x, y, z);
		old = data[xoff*x + yoff*y + z];
		newData[xoff*x + yoff*y + z] = transition(c, old);
	}
}
Example #10
0
QByteArray KTimeZoneData::abbreviation(const QDateTime &utcDateTime) const
{
    if (d->phases.isEmpty())
        return "UTC";
    const KTimeZone::Transition *tr = transition(utcDateTime);
    const QList<QByteArray> abbrevs = tr ? tr->phase().abbreviations()
                                         : d->prePhase.abbreviations();
    if (abbrevs.isEmpty())
        return QByteArray();
    return abbrevs[0];
}
/* Calculate the new values of an edge normal to the XY plane */
inline void updateXYedge(int Ix, int Iy, int Iz, unsigned char *data,
				 unsigned char *newData, int x, int y, int rank) {
	int z;
	unsigned char c, old;

	for (z=2;z<Iz;z++) {
		c = count(Ix, Iy, Iz, data, x, y, z);
		old = data[xoff*x + yoff*y + z];
		newData[xoff*x + yoff*y + z] = transition(c, old);
	}
}
void EnermySoldierFallingState::onUpdate()
{
    EnermyState::onUpdate();

    this->pData->y += this->pData->vy;
    this->pData->vy += acceleration;

    if (!(this->pData->cSupportRect == CollisionRectF()))
    {
        transition(new EnermySoldierRunningState(this->pData));
    }
}
Example #13
0
/*!
  Handle a mouse move event for the observed widget.

  \param mouseEvent Mouse event

  \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseDoubleClickEvent(),
      widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent()
*/
void QwtPicker::widgetMouseMoveEvent( QMouseEvent *mouseEvent )
{
    if ( pickArea().contains( mouseEvent->pos() ) )
        d_data->trackerPosition = mouseEvent->pos();
    else
        d_data->trackerPosition = QPoint( -1, -1 );

    if ( !isActive() )
        updateDisplay();

    transition( mouseEvent );
}
Example #14
0
/*!
  Handle a mouse move event for the observed widget.

  Move the last point of the selection in case of isActive() == true

  \sa eventFilter(), widgetMousePressEvent(), widgetMouseReleaseEvent(),
      widgetMouseDoubleClickEvent(),
      widgetWheelEvent(), widgetKeyPressEvent(), widgetKeyReleaseEvent()
*/
void QwtPicker::widgetMouseMoveEvent(QMouseEvent *e)
{
    if ( pickRect().contains(e->pos()) )
        d_data->labelPosition = e->pos();
    else
        d_data->labelPosition = QPoint(-1, -1);

    if ( !isActive() )
        updateDisplay();

    transition(e);
}
Example #15
0
void
rust_task::block(rust_cond *on, const char* name) {
    scoped_lock with(lock);
    LOG(this, task, "Blocking on 0x%" PRIxPTR ", cond: 0x%" PRIxPTR,
        (uintptr_t) on, (uintptr_t) cond);
    A(sched, cond == NULL, "Cannot block an already blocked task.");
    A(sched, on != NULL, "Cannot block on a NULL object.");

    transition(&sched->running_tasks, &sched->blocked_tasks);
    cond = on;
    cond_name = name;
}
Example #16
0
//___________________________________________________________________
void LabelData::timerEvent( QTimerEvent* event ) {
      if ( event->timerId() == timer_.timerId() ) {

            timer_.stop();

            // check transition and widget validity
            if ( !( enabled() && target_ && transition() ) ) return;

            // assign end pixmap
            transition().data()->setEndPixmap( transition().data()->grab( target_.data() ) );

            // start animation
            animate();

            }
      else if ( event->timerId() == animationLockTimer_.timerId() ) {

            unlockAnimations();

            // check transition and widget validity
            if ( !( enabled() && target_ && transition() ) ) return;

            // reassign end pixmap for the next transition to be properly initialized
            transition().data()->setEndPixmap( transition().data()->grab( target_.data() ) );

            }
      else return TransitionData::timerEvent( event );

      }
Example #17
0
/*
 Parameters:
 ////////////
 Azimuth
 Elevation
 Shape
 Width
 Height
 Gain
 Window
*/
void Ambix_directional_loudnessAudioProcessor::setParameter (int index, float newValue)
{

    int filter_id = (int)floor(index/PARAMS_PER_FILTER);

    if (filter_id < NUM_FILTERS) // safety..
    {
        _param_changed = true;

        switch (index%PARAMS_PER_FILTER) {

        case 0:
            center_sph(filter_id, 0) = newValue;
            break;

        case 1:
            center_sph(filter_id, 1) = newValue;
            break;

        case 2:
            shape(filter_id) = (newValue <= 0.5f ? 0 : 1.f);
            break;

        case 3:
            width(filter_id) = newValue;
            break;

        case 4:
            height(filter_id) = newValue;
            break;

        case 5:
            gain(filter_id) = newValue;
            break;

        case 6:
            window(filter_id) = newValue > 0.5f ? true : false;
            break;

        case 7:
            transition(filter_id) = newValue;
            break;

        default:
            _param_changed = false;
            break;
        }

    }

    sendChangeMessage();
}
Example #18
0
ArrayData* StructArray::SetStr(
  ArrayData* ad,
  StringData* k,
  Cell v,
  bool copy
) {
  auto structArray = asStructArray(ad);
  auto shape = structArray->shape();
  auto result = structArray;

  auto offset = shape->offsetFor(k);
  bool isNewProperty = offset == PropertyTable::kInvalidOffset;

  auto convertToMixedAndAdd = [&]() {
    auto mixed = copy ? ToMixedCopy(structArray) : ToMixed(structArray);
    return mixed->addValNoAsserts(k, v);
  };

  if (isNewProperty) {
    StringData* staticKey;
    // We don't support adding non-static strings yet.
    if (k->isStatic()) {
      staticKey = k;
    } else {
      staticKey = lookupStaticString(k);
      if (!staticKey) return convertToMixedAndAdd();
    }

    auto newShape = shape->transition(staticKey);
    if (!newShape) return convertToMixedAndAdd();
    result = copy ? CopyAndResizeIfNeeded(structArray, newShape)
                  : ResizeIfNeeded(structArray, newShape);
    offset = result->shape()->offsetFor(staticKey);
    assert(offset != PropertyTable::kInvalidOffset);
    TypedValue* dst = &result->data()[offset];
    // TODO(#3888164): we should restructure things so we don't have to
    // check KindOfUninit here.
    if (UNLIKELY(v.m_type == KindOfUninit)) v = make_tv<KindOfNull>();
    cellDup(v, *dst);
    return result;
  }

  if (copy) {
    result = asStructArray(Copy(structArray));
  }

  assert(offset != PropertyTable::kInvalidOffset);
  TypedValue* dst = &result->data()[offset];
  if (UNLIKELY(v.m_type == KindOfUninit)) v = make_tv<KindOfNull>();
  cellSet(v, *tvToCell(dst));
  return result;
}
Example #19
0
// We can ignore scale(i) here, because it factors out.
efloat_t DParrayConstrained::path_P(const vector<int>& g_path) const
{
    const int I = size()-1;
    int i=I;
    int l=g_path.size()-1;
    int state2 = g_path[l];

    vector<double> transition(nstates());

    efloat_t Pr=1.0;
    while (l>0)
    {
        transition.resize(states(i).size());
        for(int s1=0; s1<transition.size(); s1++) {
            int state1 = states(i)[s1];
            transition[s1] = (*this)(i,state1)*GQ(state1,state2);
        }

        int state1 = g_path[l-1];
        int s1 = find_index(states(i),state1);
        assert(s1 != -1);
        double p = choose_P(s1,transition);
        assert(p > 0.0);

        if (di(state1)) i--;

        l--;
        state2 = state1;
        Pr *= p;
        assert(Pr > 0.0);
    }

    // In column 0, all states are allowed:
    // - silent states can't contradict anything
    // - non-silent states reprent the start state.
    transition.resize(states(0).size());

    // include probability of choosing 'Start' vs ---+ !
    for(int state1=0; state1<nstates(); state1++)
        transition[state1] = (*this)(0,state1) * GQ(state1,state2);

    // Get the probability that the previous state was 'Start'
    double p=0.0;
    for(int state1=0; state1<nstates(); state1++)
        if (not silent(state1))
            p += choose_P(state1,transition);

    Pr *= p;

    assert(Pr > 0.0);
    return Pr;
}
Example #20
0
void parse_table::for_each(buffer<transition> & ts,
                           std::function<void(unsigned, transition const *,
                                              list<accepting> const &)> const & fn) const {
    if (!is_nil(m_ptr->m_accept))
        fn(ts.size(), ts.data(), m_ptr->m_accept);
    m_ptr->m_children.for_each([&](name const & k, list<pair<action, parse_table>> const & lst) {
            for (auto const & p : lst) {
                ts.push_back(transition(k, p.first));
                p.second.for_each(ts, fn);
                ts.pop_back();
            }
        });
}
void StateManager::registerState(std::string name, GameState* state) {
	if(states.count(name) > 0) {
		char buf[256];
		sprintf(buf, "Error: trying to duplicate existing state %s", name.c_str());
		LOG(buf);
		return;
	}
	states[name] = state;
	if(firstState) {
		transition(name);
	}
	firstState = false;
}
Example #22
0
static int add(lua_State * L) {
    int nargs = lua_gettop(L);
    buffer<transition> ts;
    luaL_checktype(L, 2, LUA_TTABLE);
    int sz = objlen(L, 2);
    for (int i = 1; i <= sz; i++) {
        lua_rawgeti(L, 2, i);
        if (lua_isstring(L, -1) || is_name(L, -1)) {
            ts.push_back(transition(to_name_ext(L, -1), mk_expr_action()));
            lua_pop(L, 1);
        } else {
            luaL_checktype(L, -1, LUA_TTABLE);
            lua_rawgeti(L, -1, 1);
            lua_rawgeti(L, -2, 2);
            ts.push_back(transition(to_name_ext(L, -2), to_notation_action_ext(L, -1)));
            lua_pop(L, 3);
        }
    }
    bool overload = (nargs <= 3) || lua_toboolean(L, 4);
    return push_parse_table(L, to_parse_table(L, 1).add(ts.size(), ts.data(), to_expr(L, 3), LEAN_DEFAULT_NOTATION_PRIORITY,
                                                        overload));
}
void PlayerSwimmingState :: onVeticalDirectionPressed( Direction d)
{
    pData ->verticalDir = d;
    if(d.isDown())
    {
        //pData ->iCurrentArr = PlayerData :: RUNDOWN;
        transition(new PlayerDivingState(pData));
    }
    else
    {
        pData ->setiCurrentArray (PlayerData :: SWIMUP) ;
    }
}
Example #24
0
File: state.c Project: nbargnesi/xy
void transition(const STATE state) {
    switch (state) {
        case STATE_INIT:
            xy_startup();
            transition(STATE_RUNNING);
            break;
        case STATE_RUNNING:
            main_loop();
            break;
        case STATE_RESTARTING:
            xy_shutting_down();
            xy_restart();
            break;
        case STATE_SHUTTING_DOWN:
            xy_shutting_down();
            transition(STATE_SHUTDOWN);
            break;
        case STATE_SHUTDOWN:
            xy_shutdown();
            break;
    }
}
Example #25
0
//___________________________________________________________________
bool StackedWidgetData::initializeAnimation( void ) {

      // check enability
      if ( !( target_ && target_.data()->isVisible() ) ) {
            return false;
            }

      // check index
      if ( target_.data()->currentIndex() == index_ ) {
            return false;
            }

      // do not animate if either index or currentIndex is not valid
      // but update index_ none the less
      if ( target_.data()->currentIndex() < 0 || index_ < 0 ) {
            index_ = target_.data()->currentIndex();
            return false;
            }

      // get old widget (matching index_) and initialize transition
      if ( QWidget* widget = target_.data()->widget( index_ ) ) {

            transition().data()->setOpacity( 0 );
            startClock();
            transition().data()->setGeometry( widget->geometry() );
            transition().data()->setStartPixmap( transition().data()->grab( widget ) );

            index_ = target_.data()->currentIndex();
            return !slow();

            }
      else {

            index_ = target_.data()->currentIndex();
            return false;

            }

      }
Example #26
0
task main()
{
  initialize ();  // In the original template this was "initializeRobot();"

  waitForStart (); // Wait for the beginning of autonomous phase.

  clasp_goal(true);

  distanceToDrive = 72.0; //6 feet
  drive_both_wheels (-motorSpeed, -motorSpeed, distanceToDrive * kInch); //drives out of parking zone to kickstand

  int i = 0;
  for(i = 0; i <= 1; i++){
  	distanceToDrive = 6.0; //6 in
  	drive_both_wheels (motorSpeed, motorSpeed, distanceToDrive * kInch);

  	distanceToDrive = 10.0 //10 in
  	drive_both_wheels (-motorSpeed, -motorSpeed, distanceToDrive * kInch);
  }

  distanceToDrive = 12.0; //12 in
  drive_both_wheels(motorSpeed, motorSpeed, distanceToDrive * kInch); //backs up to angle for final try

  degreesToTurn = 90.0; //90 degrees
  TurnLeft(degreesToTurn * kDegrees); //turns 90 degrees

  distanceToDrive = 10.0; //10 in
  drive_both_wheels(motorSpeed, motorSpeed, distanceToDrive * kInch); //drives 4 in

  degreesToTurn = 90.0; //90 degrees
  TurnRight(degreesToTurn * kDegrees); //turns 90 degrees

  distanceToDrive = 30.0; //2.5 feet
  drive_both_wheels(-motorSpeed, -motorSpeed, distanceToDrive * kInch); //comes in for final try to knock down the kickstand

  for(i = 0; i <= 1; i++){
  	distanceToDrive = 6.0; //6 in
  	drive_both_wheels (motorSpeed, motorSpeed, distanceToDrive * kInch);

  	distanceToDrive = 10.0; //10 in
  	drive_both_wheels (-motorSpeed, -motorSpeed, distanceToDrive * kInch);
  }
  //the program basically flails around to knock down the kickstand




  transition(); //waits for autonomous phase to end

} // main
void Boss2FinalHeadShuttingState::onUpdate()
{
    EnermyState::onUpdate();

    if (frameCountOpen >= 0)
    {
        frameCountOpen--;
    }
    else
    {
        transition(new Boss2FinalHeadOpeningState(this->pData));
        return;
    }
}
void EnemyBazokaFiringState::onUpdate()
{
	EnermyState::onUpdate();
	if(counter == 0)
	{
		Sound:: getInstance() -> play("shootM", false, 1);
		pData -> bulletsVector.push_back(new MBullet(pData -> x - pData -> ppTextureArrays[pData -> iCurrentArr] -> getWidth() /2, pData -> y - 25, 3.0f, M_PI));
	}
	counter ++;
	if(counter >= nHoldingFrames )
	{
		transition(new EnemyBazokaStandingState(pData));
	}
}
Example #29
0
void LumaMixTransition::on_lumaCombo_activated(int index)
{
    if (index == kLumaComboDissolveIndex || index == kLumaComboCutIndex) {
        on_invertCheckBox_clicked(false);
        ui->invertCheckBox->setChecked(false);
    }
    ui->invertCheckBox->setEnabled( index != kLumaComboDissolveIndex && index != kLumaComboCutIndex);
    ui->softnessSlider->setEnabled( index != kLumaComboDissolveIndex);
    ui->softnessSpinner->setEnabled(index != kLumaComboDissolveIndex);

    QScopedPointer<Mlt::Transition> transition(getTransition("luma"));
    if (transition && transition->is_valid()) {
        if (index == kLumaComboDissolveIndex) {
            transition->set("resource", "");
            ui->softnessLabel->setText(tr("Softness"));
        } else if (index == kLumaComboCutIndex) { // Cut
            ui->softnessLabel->setText(tr("Position"));
            ui->softnessSlider->setValue(50);
        } else if (index == kLumaComboCustomIndex) {
            ui->softnessLabel->setText(tr("Softness"));
            // Custom file
            QString path = Settings.openPath();
#ifdef Q_OS_MAC
            path.append("/*");
#endif
            QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), path,
                tr("Images (*.bmp *.jpeg *.jpg *.pgm *.png *.svg *.tga *.tif *.tiff);;All Files (*)"));
            activateWindow();
            if (!filename.isEmpty()) {
                transition->set("resource", filename.toUtf8().constData());
                MAIN.getHash(*transition);
            }
        } else {
            ui->softnessLabel->setText(tr("Softness"));
            transition->set("resource", QString("%luma%1.pgm").arg(index - 1, 2, 10, QChar('0')).toLatin1().constData());
        }
        if (qstrcmp(transition->get("resource"), "")) {
            transition->set("progressive", 1);
            if (index == kLumaComboCutIndex) {
                transition->set("invert", 0);
                transition->set("softness", 0);
            } else {
                transition->set("invert", ui->invertCheckBox->isChecked());
                transition->set("softness", ui->softnessSlider->value() / 100.0);
            }
        }
        updateCustomLumaLabel(*transition);
        MLT.refreshConsumer();
    }
}
Example #30
0
    //______________________________________________________
    LabelData::LabelData( QObject* parent, QLabel* target, int duration ):
        TransitionData( parent, target, duration ),
        _target( target )
    {
        _target.data()->installEventFilter( this );

        const bool hasProxy( _target.data()->graphicsProxyWidget() );
        const bool hasMessageWidget( hasParent( target, "KMessageWidget" ) );

        transition().data()->setFlags( hasProxy||hasMessageWidget ? TransitionWidget::Transparent : TransitionWidget::GrabFromWindow );

        connect( _target.data(), SIGNAL(destroyed()), SLOT(targetDestroyed()) );

    }