Ejemplo n.º 1
0
void ribi::pylos::QtPylosMenuDialog::mousePressEvent(QMouseEvent *)
{
  if (ui->label_theme->underMouse())
  {
    m_theme_bw = !m_theme_bw;
    if (m_theme_bw)
      ui->label_theme->setText("Theme: black & white");
    else
      ui->label_theme->setText("Theme: red & blue");
    return;
  }

  if (ui->label_type->underMouse())
  {
    m_type_basic = !m_type_basic;
    if (m_type_basic)
      ui->label_type->setText("Game type: basic");
    else
      ui->label_type->setText("Game type: advanced");
    return;
  }

  switch (m_selected)
  {
    case 0: OnStart(); return;
    case 1: OnInstructions(); return;
    case 2: OnAbout(); return;
    case 3: this->close(); return;
  }
}
void ribi::maziak::QtMaziakMenuDialog2::keyPressEvent(QKeyEvent * event)
{
    switch (event->key())
    {
    case Qt::Key_Up:
    case Qt::Key_Left:
    {
        switch (m_difficulty)
        {
        case Difficulty::easy:
            return;
        case Difficulty::medium:
            m_difficulty = Difficulty::easy;
            repaint();
            return;
        case Difficulty::hard:
            m_difficulty = Difficulty::medium;
            repaint();
            return;
        default:
            assert(!"Should not get here");
        }
    }
    case Qt::Key_Down:
    case Qt::Key_Right:
    {
        switch (m_difficulty)
        {
        case Difficulty::easy:
            m_difficulty = Difficulty::medium;
            repaint();
            return;
        case Difficulty::medium:
            m_difficulty = Difficulty::hard;
            repaint();
            return;
        case Difficulty::hard:
            return;
        default:
            assert(!"Should not get here");
        }
    }
    case Qt::Key_S:
        OnStart();
        break;
    case Qt::Key_I:
        OnInstructions();
        break;
    case Qt::Key_A:
        OnAbout();
        break;
    case Qt::Key_Q:
    case Qt::Key_Escape:
        close();
        return;
    default:
        break;
    }
}
void ribi::maziak::QtMaziakMenuDialog2::mousePressEvent(QMouseEvent * event)
{
    if (ui->widget_easy->geometry().contains(
                event->x(), event->y()))
    {
        m_difficulty = Difficulty::easy;
        repaint();
        return;
    }
    if (ui->widget_medium->geometry().contains(
                event->x(), event->y()))
    {
        m_difficulty = Difficulty::medium;
        repaint();
        return;
    }
    if (ui->widget_hard->geometry().contains(
                event->x(), event->y()))
    {
        m_difficulty = Difficulty::hard;
        repaint();
        return;
    }
    if (ui->widget_start->geometry().contains(
                event->x(), event->y()))
    {
        OnStart();
        return;
    }
    if (ui->widget_start_retro->geometry().contains(
                event->x(), event->y()))
    {
        OnStartRetro();
        return;
    }
    if (ui->widget_instructions->geometry().contains(
                event->x(), event->y()))
    {
        OnInstructions();
        return;
    }
    if (ui->widget_about->geometry().contains(
                event->x(), event->y()))
    {
        OnAbout();
        return;
    }
    if (ui->widget_quit->geometry().contains(
                event->x(), event->y()))
    {
        close();
    }
}
Ejemplo n.º 4
0
	void Master::OnHeartbeat()
	{
		//Just process instructions  since the soft signal may loss
		OnInstructions();
		if (!m_server->m_cfg.master_host.empty())
		{
			//let master feed 'ping' command
			return;
		}
		if (!m_slave_table.empty())
		{
			RedisCommandFrame ping("ping");
			ping.SetType(REDIS_CMD_PING);
			//m_backlog.Feed(ping, 0);
			WriteSlaves(0, ping);
			DEBUG_LOG("Ping slaves.");
		}
	}
Ejemplo n.º 5
0
	void Master::OnSoftSignal(uint32 soft_signo, uint32 appendinfo)
	{
		ASSERT(soft_signo == SOFT_SIGNAL_REPL_INSTRUCTION);
		OnInstructions();
	}