Ejemplo n.º 1
0
    void LifeGamev2::play() {
        for (; is_run(); delay_fps(SPEED)) {
            if (kbhit()) {
                changeSetting(getch());
            }

            //原始宇宙为universe,进化后为_universe
            evolve();
            cleardevice();
            render();
        }
    }
Ejemplo n.º 2
0
int ai::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: moveNextStep((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 1: { GameState _r = generateGameState((*reinterpret_cast< const GameSetting(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< GameState*>(_a[0]) = _r; }  break;
        case 2: changeSetting(); break;
        case 3: renderGameBoard((*reinterpret_cast< const GameState(*)>(_a[1]))); break;
        case 4: changeBoard((*reinterpret_cast< GameState(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
Ejemplo n.º 3
0
int8_t RogueSD::sync(bool blocking)
{
  // procedure:
  // 1. sync (send ESC, clear prompt)
  // 2. get version ("v"), and module type
  // 3. change settings as needed
  // 4. close files

  // 0. empty any data in the serial buffer
  _comms->flush();

  // 1. sync
  print((char)ASCII_ESC);               // send ESC to clear buffer on uMMC
  if (blocking)
  {
    _readBlocked();                     // consume prompt
  }
  else
  {
    if (_readTimeout(ROGUESD_DEFAULT_READ_TIMEOUT) < 0)
    {
      return 0;
    }
  }

  // 2. get version (ignore prompt - just drop it)
  _getVersion();
  if (_moduleType == uMMC)
    _prefix = "";
  else
    _prefix = "FC";

  // 3. change settings as needed
  // OLD: write timeout setting = 10 ms timeout
  // NEW: listing style = old style (0)
  if ((_moduleType == uMMC && _fwVersion < UMMC_MIN_FW_VERSION_FOR_NEW_COMMANDS) ||
      (_moduleType == uMP3 && _fwVersion < UMP3_MIN_FW_VERSION_FOR_NEW_COMMANDS))
  {
    // we need to set the write timeout to allow us to control when a line is finished
    // in writeln.
    changeSetting('1', 1);              // 10 ms timeout
    _fwLevel = 0;
  }
  else
  {
    // we're using the new version
    _fwLevel = 1;
    // Let's make sure the Listing Style setting is set to the old style
    if (getSetting('L') != 0)
    {
      changeSetting('L', 0);
    }

    // get the prompt char
    print('S');
    if (_moduleType != uMMC) print('T');
    print('P');
    print('\r');  // get our prompt (if possible)
    _promptChar = _getNumber(10);
    _readBlocked();                     // consume prompt
  }

  // 4. close files

  closeAll();                           // ensure all handles are closed

  return 1;
}
Ejemplo n.º 4
0
void MainWindow::reInit()
{
    changeSetting();
}
Ejemplo n.º 5
0
MainWindow::MainWindow( QWidget* parent, const char* name, WFlags fl )
    : ScimDragableFrame( parent, parent, name, fl ),
    ScimXMLGUIClient(SkimPluginManager::self()->getActionCollection()), DCOPObject("Skim_MainWindow"),
    m_autoHideTimeoutTimer(0), m_showHandleTimer(0), m_showExtHandleTimer(0),m_mode(PanelEmbedded),
    m_embedInitialized(false), m_contentIsVisible( false ), m_panelTurnedOn( false ),
    m_updatePropertiesNeeded(false), m_applet_direction(Qt::Horizontal), 
    m_shouldChangeDirection(false), m_logo(0) {

    QXEmbed::initialize ();

//     setWFlags(Qt::WStyle_Customize | Qt::WX11BypassWM | Qt::WStyle_StaysOnTop);
    setKeepVisible( true );
    setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    m_allModules = SkimPluginManager::self();

    m_allModules->registerSpecialProperyObject(this);

    m_inputServer = m_allModules->getInputServer();
    ScimXMLGUIBuilder* guiBuilder = new ScimXMLGUIBuilder(this);
    m_guiFactory = new KXMLGUIFactory(guiBuilder, this);

    setCaption(i18n("Main Toolbar"));

    m_serverAction =
      dynamic_cast<ScimAction *>(m_allModules->getActionCollection()->action( "change_server" ));

    m_mainWindowLayout = new QBoxLayout( this, QBoxLayout::LeftToRight, -1, 0, "m_mainWindowLayout" );
    m_mainWindowLayout->setAlignment(Qt::AlignCenter);
    m_mainWindowLayout->setResizeMode(QLayout::FreeResize);
    m_moveHandle = new ScimMoveHandle( this, this );
    m_moveHandle->setKeepVisible( false );
    m_mainWindowLayout->addWidget( m_moveHandle );

    //FIXME:qpopupmenu will steal focus from current editing widget, however 
    //kpopupmenu won't. this should be a bug in Qt
    m_contextMenu = new KPopupMenu(this, "MainToolBar_RightClickMenu");

    createToolbar();

    m_defaultActionCollection = m_allModules->getActionCollection();

    m_toggleDockingAction =
            static_cast<KToggleAction*>(m_defaultActionCollection->action( "toggledocking_mainwindow" ));
    connect( m_moveHandle, SIGNAL( doubleClicked() ), m_toggleDockingAction, SLOT( activate() ) );

    clearWState( WState_Polished );

    if(m_mode == StandAlone)
        move( ScimKdeSettings::mainWindow_Position());

    changeSetting();

    #if 0 && ENABLE_DEBUG
    KAction * reloadaction;
    //we should remove the old one first if exist
    if(reloadaction = m_defaultActionCollection->action( "reload_wm" ))
        delete reloadaction;

    reloadaction = new KAction( KGuiItem( i18n( "Reload" ), "reload" ),
                "", this, SLOT(requestReloadSelf()), m_defaultActionCollection, "reload_wm");

    reloadaction->plug(m_toolbar);
    #endif

    connect(m_defaultActionCollection, SIGNAL(propertiesRegistered(bool)), SLOT(updateProperties (bool)));
    connect(m_defaultActionCollection, SIGNAL(propertiesRemoved(bool)), SLOT(updateProperties (bool)));
    connect(m_defaultActionCollection, SIGNAL(propertyChanged(bool)), SLOT(updateProperties (bool)));
    connect(m_inputServer, SIGNAL( turnOnPanelReq() ), SLOT( slotTurnOn() ));
    connect(m_inputServer, SIGNAL( turnOffPanelReq() ), SLOT( slotTurnOff() ));

    #if ENABLE_DEBUG
    show();
    #endif

    connect(m_allModules->getActionCollection(), SIGNAL(standaloneHelperActionsChanged()),
        this, SLOT(initContextMenu()));

    //fix bug: https://bugzilla.novell.com/show_bug.cgi?id=149541
    //KXMLGUIClient keeps a list of pluged actions, if actions are deleted, this list
    //won't be changed, so we have to unplug all actions before remove any actions 
    connect( m_defaultActionCollection, SIGNAL( preparePropertiesRemove(bool) ), SLOT( emptyToolbar(bool) ) );

    initContextMenu();
}