void QgsRelationEditorWidget::setRelationFeature( const QgsRelation& relation, const QgsFeature& feature )
{
  if ( mRelation.isValid() )
  {
    disconnect( mRelation.referencingLayer(), SIGNAL( editingStarted() ), this, SLOT( updateButtons() ) );
    disconnect( mRelation.referencingLayer(), SIGNAL( editingStopped() ), this, SLOT( updateButtons() ) );
  }

  mRelation = relation;
  mFeature = feature;

  connect( mRelation.referencingLayer(), SIGNAL( editingStarted() ), this, SLOT( updateButtons() ) );
  connect( mRelation.referencingLayer(), SIGNAL( editingStopped() ), this, SLOT( updateButtons() ) );

  setTitle( relation.name() );

  QgsVectorLayer* lyr = relation.referencingLayer();

  bool canChangeAttributes = lyr->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
  if ( canChangeAttributes && !lyr->readOnly() )
  {
    mToggleEditingButton->setEnabled( true );
    updateButtons();
  }
  else
  {
    mToggleEditingButton->setEnabled( false );
  }

  setObjectName( mRelation.name() );
  loadState();

  // If not yet initialized, it is not (yet) visible, so we don't load it to be faster (lazy loading)
  // If it is already initialized, it has been set visible before and the currently shown feature is changing
  // and the widget needs updating

  if ( mVisible )
  {
    QgsFeatureRequest myRequest = mRelation.getRelatedFeaturesRequest( mFeature );

    mDualView->init( mRelation.referencingLayer(), nullptr, myRequest, mEditorContext );
  }
}
Beispiel #2
0
SearchTextBar::SearchTextBar(QWidget* const parent, const QString& name, const QString& msg)
    : QLineEdit(parent),
      StateSavingObject(this),
      d(new Private)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setClearButtonEnabled(true);
    setPlaceholderText(msg);
    setObjectName(name + QLatin1String(" Search Text Tool"));

    d->completer = new ModelCompleter(this);
    setCompleter(d->completer);

    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));

    connect(this, SIGNAL(textChanged(QString)),
            this, SLOT(slotTextChanged(QString)));

    loadState();
}
Beispiel #3
0
/*!
 * \brief Constructs the WaiterDialog.
 * \details Constructs the WaiterDialog, loads timers and starts updating
 * timers.
 * \param parent The widget's parent, used for Qt's memory management.
 * \param IconPath Where the icon for the GUI is located.
 */
WaiterDialog::WaiterDialog(QWidget *parent, QString IconPath)
    : QDialog(parent), ui(new Ui::WaiterDialog)
{
  ui->setupUi(this);
  ui->EntryDate->setSelectedDate(QDate::currentDate());
  currentTimeLabel = new QLabel(this);
  currentTimeLabel->setAlignment(Qt::AlignHCenter);
  ui->TimerScrollerWidget->layout()->addWidget(currentTimeLabel);
  QVariant saveLocation = settings.value("QWaiter_Location");
  if(!saveLocation.isNull())
  {
    statePath = saveLocation.toString();
  }
  loadState();
  timer = new QTimer(this);
  connect(timer, SIGNAL(timeout()), this, SLOT(notifyAll()));
  timer->setInterval(1000);
  timer->start();
  setWindowIcon(QIcon(IconPath));
}
ossimGeneralRasterInfo::ossimGeneralRasterInfo(const ossimKeywordlist& kwl,
                     const char* prefix)
   :
   theImageFileList(),
   theInterleaveType(OSSIM_BIL),
   theRawImageRect(0,0,0,0),
   theValidImageRect(0,0,0,0),
   theImageRect(0,0,0,0),
   theSubImageOffset(0,0),
   theHeaderSize(0),
   theSetNullsMode(NONE),
   thePixelsToChop(0),
   theImageDataByteOrder(OSSIM_LITTLE_ENDIAN)
{
   theRawImageRect.makeNan();
   theValidImageRect.makeNan();
   theImageRect.makeNan();
   
   loadState(kwl, prefix);
}
void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
{
  // initialise widget on first show event only
  if ( mShown )
  {
    event->accept();
    return;
  }

  // check if groupbox was set to flat in Designer or in code
  mInitFlat = isFlat();

  // find parent QScrollArea - this might not work in complex layouts - should we look deeper?
  if ( parent() && parent()->parent() )
    mParentScrollArea = dynamic_cast<QScrollArea*>( parent()->parent()->parent() );
  else
    mParentScrollArea = 0;
  if ( mParentScrollArea )
    QgsDebugMsg( "found a QScrollArea parent: " + mParentScrollArea->objectName() );
  else
    QgsDebugMsg( "did not find a QScrollArea parent" );

  loadState();

  updateStyle();

  // expand if needed - any calls to setCollapsed() before only set mCollapsed, but have UI effect
  if ( mCollapsed )
  {
    setCollapsed( mCollapsed );
  }
  else
  {
    // emit signal for connections using expanded state
    emit collapsedStateChanged( this );
  }
  // set mShown after first setCollapsed call or expanded groupboxes
  // will scroll scroll areas when first shown
  mShown = true;
  event->accept();
}
Beispiel #6
0
void Game::updateKeysPressedTable() {
	debug(DBG_GAME, "Game::updateKeysPressedTable()");
	_keysPressed[13] = _stub->_pi.enter ? 1 : 0;
	_keysPressed[16] = _stub->_pi.shift ? 1 : 0;
	_keysPressed[32] = _stub->_pi.space ? 1 : 0;
	_keysPressed[37] = (_stub->_pi.dirMask & PlayerInput::DIR_LEFT)  ? 1 : 0;
	_keysPressed[38] = (_stub->_pi.dirMask & PlayerInput::DIR_UP)    ? 1 : 0;
	_keysPressed[39] = (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) ? 1 : 0;
	_keysPressed[40] = (_stub->_pi.dirMask & PlayerInput::DIR_DOWN)  ? 1 : 0;
	if (_stub->_pi.tab) {
		_stub->_pi.tab = false;
		handleBagMenu();
	}
	if (_stub->_pi.ctrl) {
		_stub->_pi.ctrl = false;
		_lifeBarDisplayed = !_lifeBarDisplayed;
	}
	if (_stub->_pi.stateSlot != 0) {
		int slot = _stateSlot + _stub->_pi.stateSlot;
		if (slot >= 1 && slot <= 999) {
			_stateSlot = slot;
			debug(DBG_INFO, "Current game state slot is %d", _stateSlot);
		}
		_stub->_pi.stateSlot = 0;
	}
	if (_stub->_pi.load) {
		_stub->_pi.load = false;
		loadState(_stateSlot, true);
		_loadState = _switchScene; // gamestate will get loaded on scene switch
	}
	if (_stub->_pi.save) {
		_stub->_pi.save = false;
		saveState(_stateSlot);
	}
	if (_gameOver) {
		if (_stub->_pi.enter) {
			_stub->_pi.enter = false;
			restart();
		}
	}
}
    void TagFactory::loadTagOrState( QTreeWidgetItem * item , int column )
    {
        Q_UNUSED( column );

        if ( m_itemToState.contains( item ) )
        {
            m_currentItemState = item;
            loadState( m_itemToState[item] );

            m_appareanceGroupBox->setEnabled( true );
            m_fontGroupBox->setEnabled( true );
        }
        else if ( m_itemToTag.contains( item ) )
        {
            m_currentItemTag = item;
            loadTag( m_itemToTag[item] );

            m_appareanceGroupBox->setEnabled( false );
            m_fontGroupBox->setEnabled( false );
        }
    }
Beispiel #8
0
void drawAxiom(char* axiom, double angle)
{
    int size;
    size = strlen(axiom);
    
    int i;
    for (i = 0; i < size; i++)
    {
        if (axiom[i] == 'F')
            drawLine();
        else if (axiom[i] == 'f')
            move();
        else if (axiom[i] == '+')
            rotate(-1 * angle);
        else if (axiom[i] == '-')
            rotate(angle);
        else if (axiom[i] == '[')
            push(initState(currX, currY, currH));
        else if (axiom[i] == ']')
            loadState(pop());
    }
}
AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::AddNewTorrentDialog)
    , m_contentModel(0)
    , m_contentDelegate(0)
    , m_hasMetadata(false)
    , m_oldIndex(0)
{
    ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);
    ui->lblMetaLoading->setVisible(false);
    ui->progMetaLoading->setVisible(false);

    Preferences* const pref = Preferences::instance();
    ui->start_torrent_cb->setChecked(!pref->addTorrentsInPause());
    ui->save_path_combo->addItem(Utils::Fs::toNativePath(pref->getSavePath()), pref->getSavePath());
    loadSavePathHistory();
    connect(ui->save_path_combo, SIGNAL(currentIndexChanged(int)), SLOT(onSavePathChanged(int)));
    connect(ui->browse_button, SIGNAL(clicked()), SLOT(browseButton_clicked()));
    ui->default_save_path_cb->setVisible(false); // Default path is selected by default

    // Load labels
    const QStringList customLabels = pref->getTorrentLabels();
    ui->label_combo->addItem("");
    foreach (const QString& label, customLabels)
        ui->label_combo->addItem(label);
    ui->label_combo->model()->sort(0);
    ui->content_tree->header()->setSortIndicator(0, Qt::AscendingOrder);
    loadState();
    // Signal / slots
    connect(ui->adv_button, SIGNAL(clicked(bool)), SLOT(showAdvancedSettings(bool)));
    editHotkey = new QShortcut(QKeySequence("F2"), ui->content_tree, 0, 0, Qt::WidgetShortcut);
    connect(editHotkey, SIGNAL(activated()), SLOT(renameSelectedFile()));
    connect(ui->content_tree, SIGNAL(doubleClicked(QModelIndex)), SLOT(renameSelectedFile()));

    ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
}
Beispiel #10
0
void FiFider::begin(void) {
    if(!Memory::getInstance().isReady()) {
        _eta = HW_DEF_INTERVAL;
        _interval = HW_DEF_INTERVAL;
        _portion = HW_DEF_PORTION;
        FiFider::getInstance().saveState();
        Memory::getInstance().initialize();
    }else{
        loadState();
    }

    _feeder_state = FST_WAITING;
    _display_state = DST_ETA;

    Timer1.initialize(1000000);
    Timer1.attachInterrupt(FiFider::timerOverflow);

    _increase_btn.initialize(HW_BTN_INCR_PIN, 20, 800);
    _increase_btn.onUp(FiFider::increaseButton);
    _increase_btn.onHold(FiFider::holdIncreaseButton);
    _increase_btn.holdBlocksUp(false);

    _decrease_btn.initialize(HW_BTN_DECR_PIN, 20, 800);
    _decrease_btn.onUp(FiFider::decreaseButton);
    _decrease_btn.onHold(FiFider::holdDecreaseButton);
    _decrease_btn.holdBlocksUp(false);

    _select_btn.initialize(HW_BTN_SEL_PIN);
    _select_btn.onUp(FiFider::selectButton);
    _select_btn.onHold(FiFider::holdSelectButton);

    wdt_enable(WDTO_1S);

    Display::getInstance().initialize();

}
bool GB::loadState(const std::string &filepath) {
    return loadState(filepath, false);
}
bool GB::loadState() {
    return loadState(statePath(p_->cpu.saveBasePath(), p_->stateNo), true);
}
Beispiel #13
0
void LiteApp::load(bool bUseSession, IApplication *baseApp)
{
    QSplashScreen *splash = 0;
    bool bSplash = m_settings->value(LITEAPP_SPLASHVISIBLE,true).toBool();
    if (baseApp) {
        bSplash = false;
    }
    if (bSplash) {
        splash = new QSplashScreen(QPixmap::fromImage(makeSplashImage(this)),Qt::WindowStaysOnTopHint);
    }
    if (bSplash) {
        splash->show();
    }

    if (bSplash) {
        splash->showMessage("Scanning plugins...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();

    loadMimeType();
    loadPlugins();

    if (bSplash) {
        splash->showMessage("Loading plugins...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();
    initPlugins();

    if (bSplash) {
        splash->showMessage("Loading state...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();
    loadState();
    if (baseApp) {
        if (baseApp->mainWindow()->isMaximized()) {
            m_mainwindow->resize(800,600);
            m_mainwindow->show();
        } else {
            QRect rc = baseApp->mainWindow()->geometry();
            rc.adjust(20,20,20,20);
            m_mainwindow->setGeometry(rc);
            m_mainwindow->show();
        }
    } else {
        m_mainwindow->show();
    }

    emit loaded();
    m_projectManager->setCurrentProject(0);

    if (bSplash) {
        splash->showMessage("Loading session...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();

    bool b = m_settings->value(LITEAPP_AUTOLOADLASTSESSION,true).toBool();
    if (b && bUseSession) {
        loadSession("default");
    }

    if (bSplash) {
        m_mainwindow->raise();
        splash->finish(m_mainwindow);
        splash->deleteLater();
    }

    this->appendLog("HtmlWidgetFactory",m_htmlWidgetManager->classNameList().join(" "));
    this->appendLog("DefaultHtmlWidgetFactory",m_htmlWidgetManager->defaultClassName());

    m_goProxy->call("version");
	
    appendLog("LiteApp","Finished loading");
}
//*************************************************************************************************
// Creates clones of the original and pushes them onto the clone list.
//
// Need to consider the possibility that the original chain is a combiner with multiple image 
// handler inputs, and also the possibility that one handler is wired to multiple input chains
// before the combiner. In order to handle this, we will save the connection information for each 
// input handler encountered so that we can later reproduce it using a shared handler (if requested)
//*************************************************************************************************
bool ossimImageChainMtAdaptor::replicate()
{
   if ((m_clones.empty()) || (m_numThreads == 0))
      return false;

   // Don't need to replicate if only one thread is being requested. This is not an error though:
   if (m_numThreads == 1)
      return true;

   // If the handlers are to be shared, need to isolate them from the original chain and replace
   // them with a "hollow adaptor" (i.e., a handler adaptor without the adaptee set yet:
   m_sharedHandlers.clear();
   if (d_useSharedHandlers)
   {
      if (m_chainContainers.empty())
         return false;

      // Collect all image handlers in original chain for possible sharing with all clones:
      ossimTypeNameVisitor visitor (ossimString("ossimImageHandler"));
      m_chainContainers[0]->accept(visitor);
      ossimRefPtr<ossimImageHandler> handler = 0;
      ossimRefPtr<ossimImageHandlerMtAdaptor> handler_adaptor = 0;
      ossimRefPtr<ossimConnectableObject> output_connection = 0;
      ossim_uint32 handler_idx = 0;

      // Loop over all image handlers found in the original chain. Each handler's connection info
      // is stored and the handler is removed temporarily from the original chain.
      while (1) 
      {
         // Fetch a handler from the chain and wrap it with a handler adaptor:
         handler = visitor.getObjectAs<ossimImageHandler>(handler_idx++);
         if (handler == NULL)
            break; // Only exit point of while loop
         
         handler_adaptor = new ossimImageHandlerMtAdaptor(handler.get());
         m_sharedHandlers.push_back(handler_adaptor);

         // Change ownership:
         m_chainContainers[0]->removeChild(handler.get());
         handler->changeOwner(this);
      } 

      // If no handler was found, we can't continue.
      if (m_sharedHandlers.empty())
         return false;
   }

   // Fetch the state of this and the original chain. This KWL will be used for creating replicas
   // via the loadState. The saveState essentially bootstraps the replication task:
   ossimKeywordlist kwl;
   bool succeeded = saveState(kwl);

   // The original chain may have had the handlers temporarily removed for the saveState in support
   // of shared handlers. If so, need to restore them now:
   if (d_useSharedHandlers)
      succeeded = connectSharedHandlers(0);

   // Finally, initialize THIS chain with the original chain's state. This call will also create
   // the clones:
   if (succeeded)
      succeeded = loadState(kwl);

   return succeeded;
}
SessionManagerServer::SessionManagerServer() : unique32(0), unique64(0), txnidfd(-1)
{
    config::Config* conf;
    string stmp;
    const char* ctmp;

    conf = config::Config::makeConfig();

    try
    {
        stmp = conf->getConfig("SessionManager", "MaxConcurrentTransactions");
    }
    catch (const std::exception& e)
    {
        cout << e.what() << endl;
        stmp.empty();
    }

    if (stmp != "")
    {
        int64_t tmp;
        ctmp = stmp.c_str();
        tmp = config::Config::fromText(ctmp);

        if (tmp < 1)
            maxTxns = 1;
        else
            maxTxns = static_cast<int>(tmp);
    }
    else
        maxTxns = 1;

    txnidFilename = conf->getConfig("SessionManager", "TxnIDFile");

    if (!IDBPolicy::useHdfs())
    {
        txnidfd = open(txnidFilename.c_str(), O_RDWR | O_CREAT | O_BINARY, 0664);

        if (txnidfd < 0)
        {
            perror("SessionManagerServer(): open");
            throw runtime_error("SessionManagerServer: Could not open the transaction ID file");
        }

        //FIXME: do we need this on Win?
#ifndef _MSC_VER
        else
        {
            fchmod(txnidfd, 0664);
        }

#endif
    }

    semValue = maxTxns;
    _verID = 0;
    _sysCatVerID = 0;
    systemState = 0;

    try
    {
        loadState();
    }
    catch (...)
    {
        // first-time run most likely, ignore the error
    }
}
Beispiel #16
0
void Defrag::config()
{

	ASSERT( param(m_state_file,"DEFRAG_STATE_FILE") );
	if( m_last_poll==0 ) {
		loadState();
	}

	int old_polling_interval = m_polling_interval;
	m_polling_interval = param_integer("DEFRAG_INTERVAL",600);
	if( m_polling_interval <= 0 ) {
		dprintf(D_ALWAYS,
				"DEFRAG_INTERVAL=%d, so no pool defragmentation "
				"will be done.\n", m_polling_interval);
		if( m_polling_timer != -1 ) {
			daemonCore->Cancel_Timer(m_polling_timer);
			m_polling_timer = -1;
		}
	}
	else if( m_polling_timer >= 0 ) {
		if( old_polling_interval != m_polling_interval ) {
			daemonCore->Reset_Timer_Period(
				m_polling_timer,
				m_polling_interval);
		}
	}
	else {
		time_t now = time(NULL);
		int first_time = 0;
		if( m_last_poll != 0 && now-m_last_poll < m_polling_interval && m_last_poll <= now ) {
			first_time = m_polling_interval - (now-m_last_poll);
		}
		m_polling_timer = daemonCore->Register_Timer(
			first_time,
			m_polling_interval,
			(TimerHandlercpp)&Defrag::poll,
			"Defrag::poll",
			this );
	}
	if( old_polling_interval != m_polling_interval && m_polling_interval > 0 )
	{
		dprintf(D_ALWAYS,
				"Will evaluate defragmentation policy every DEFRAG_INTERVAL="
				"%d seconds.\n", m_polling_interval);
	}

	m_draining_per_hour = param_double("DEFRAG_DRAINING_MACHINES_PER_HOUR",0,0);

	double rate = m_draining_per_hour/3600.0*m_polling_interval;
	m_draining_per_poll = (int)floor(rate + 0.00001);
	if( m_draining_per_poll < 0 ) m_draining_per_poll = 0;

	double error_per_hour = (rate - m_draining_per_poll)/m_polling_interval*3600.0;
	m_draining_per_poll_hour = (int)floor(error_per_hour + 0.00001);
	if( m_draining_per_hour < 0 || m_polling_interval > 3600 ) {
		m_draining_per_hour = 0;
	}

	double error_per_day = (error_per_hour - m_draining_per_poll_hour)*24.0;
	m_draining_per_poll_day = (int)floor(error_per_day + 0.5);
	if( m_draining_per_poll_day < 0 || m_polling_interval > 3600*24 ) {
		m_draining_per_poll_day = 0;
	}
	dprintf(D_ALWAYS,"polling interval %ds, DEFRAG_DRAINING_MACHINES_PER_HOUR = %f/hour = %d/interval + %d/hour + %d/day\n",
			m_polling_interval,m_draining_per_hour,m_draining_per_poll,
			m_draining_per_poll_hour,m_draining_per_poll_day);

	m_max_draining = param_integer("DEFRAG_MAX_CONCURRENT_DRAINING",-1,-1);
	m_max_whole_machines = param_integer("DEFRAG_MAX_WHOLE_MACHINES",-1,-1);

	ASSERT( param(m_defrag_requirements,"DEFRAG_REQUIREMENTS") );
	validateExpr( m_defrag_requirements.c_str(), "DEFRAG_REQUIREMENTS" );

	ASSERT( param(m_whole_machine_expr,"DEFRAG_WHOLE_MACHINE_EXPR") );
	validateExpr( m_whole_machine_expr.c_str(), "DEFRAG_WHOLE_MACHINE_EXPR" );

	ASSERT( param(m_draining_schedule_str,"DEFRAG_DRAINING_SCHEDULE") );
	if( m_draining_schedule_str.empty() ) {
		m_draining_schedule = DRAIN_GRACEFUL;
		m_draining_schedule_str = "graceful";
	}
	else {
		m_draining_schedule = getDrainingScheduleNum(m_draining_schedule_str.c_str());
		if( m_draining_schedule < 0 ) {
			EXCEPT("Invalid draining schedule: %s\n",m_draining_schedule_str.c_str());
		}
	}

	MyString rank;
	param(rank,"DEFRAG_RANK");
	if( rank.IsEmpty() ) {
		m_rank_ad.Delete(ATTR_RANK);
	}
	else {
		if( !m_rank_ad.AssignExpr(ATTR_RANK,rank.Value()) ) {
			EXCEPT("Invalid expression for DEFRAG_RANK: %s\n",
				   rank.Value());
		}
	}

	int update_interval = param_integer("DEFRAG_UPDATE_INTERVAL", 600);
	if(m_public_ad_update_interval != update_interval) {
		m_public_ad_update_interval = update_interval;

		dprintf(D_FULLDEBUG, "Setting update interval to %d\n",
			m_public_ad_update_interval);

		if(m_public_ad_update_timer >= 0) {
			daemonCore->Reset_Timer_Period(
				m_public_ad_update_timer,
				m_public_ad_update_interval);
		}
		else {
			m_public_ad_update_timer = daemonCore->Register_Timer(
				0,
				m_public_ad_update_interval,
				(TimerHandlercpp)&Defrag::updateCollector,
				"Defrag::updateCollector",
				this);
		}
	}

	if (param(m_cancel_requirements, "DEFRAG_CANCEL_REQUIREMENTS")) {
		validateExpr( m_cancel_requirements.c_str(), "DEFRAG_CANCEL_REQUIREMENTS" );
	} else {
		m_cancel_requirements = "";
	}

	param(m_defrag_name,"DEFRAG_NAME");

	int stats_quantum = m_polling_interval;
	int stats_window = 10*stats_quantum;
	m_stats.SetWindowSize(stats_window,stats_quantum);
}
VesselSceneNode::VesselSceneNode(const VesselSceneNodeState& state, scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id)
    : VesselSceneNode(state.vesData,parent,mgr,id,state.uid)
{
    loadState(state);
}
Beispiel #18
0
/**
 * @brief BoardLeft::resetControls: vuelve al ultimo estado cargado. por defecto es APAGADO
 */
void BoardLeft::resetControls() {
    loadState(lastState);
}
Beispiel #19
0
int levelTwo()
{
	

	moving = 0;
	SDL_RenderClear(gt_graphics_get_active_renderer());
	ResetBuffer();

	backOffset = ((int)camera.x+3200)%3200;
	offset = ((int)camera.x+1600)%1600;

	drawSprite(moonBack,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	
	drawSprite(levelTwoBackTrees,0,vec2d(-backOffset,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
    drawSprite(levelTwoFrontTrees,0,vec2d(-offset,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	drawSprite(levelTwoFloor,0,vec2d(-offset,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	
	drawSprite(levelTwoFrontTrees,0,vec2d(-offset+1600,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	drawSprite(levelTwoBackTrees,0,vec2d(-backOffset+1600,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	drawSprite(levelTwoFloor,0,vec2d(-offset+1600,0),vec2d(1,1),0,gt_graphics_get_active_renderer());

	



	entity_think_all();
	entity_touch_all();
	entity_update_all();
	entity_draw_all();
	if(player->position.x >= 300)
		{
			camera.x = player->position.x - 300;
			
		}
	if(player->position.x < 300)
		{
			camera.x = 0;
			
		}
	if(xDistance == 12000.00)
	{
		done = 1;
	}

	healthBar();
    NextFrame();
    SDL_PumpEvents();
	diff = (gt_graphics_now - gt_graphics_then);
	
	if(playerData.shotTimer>0)
	{
		playerData.shotTimer -= diff;
	}
    keys = SDL_GetKeyboardState(NULL);
    if(keys[SDL_SCANCODE_ESCAPE])
    {
        done = 1;
    }
	else if(keys[SDL_SCANCODE_W])
	{
		moving = 1;
		moveCharacter(DIR_UP,player);
		yDistance = player->position.y;
	}
	else if(keys[SDL_SCANCODE_A])
	{
		moving = 1;
		moveCharacter(DIR_LEFT,player);
		xDistance = player->position.x;
	}
	else if(keys[SDL_SCANCODE_D])
	{
		moving = 1;
		moveCharacter(DIR_RIGHT,player);
		xDistance = player->position.x;
		
	}
	else if(keys[SDL_SCANCODE_S])
	{
		moving = 1;
		moveCharacter(DIR_DOWN,player);
		yDistance = player->position.y;
	}
	else if(keys[SDL_SCANCODE_1])
	{
		fire_Pistol();
	}
	else if(keys[SDL_SCANCODE_2])
	{
		fire_Shotgun();
	}
	else if(keys[SDL_SCANCODE_3])
	{
		fire_Machinegun();
	}
	else if(keys[SDL_SCANCODE_4])
	{
		fire_Heavy_Machinegun();
	}
	else if(keys[SDL_SCANCODE_P])
	{
		saveState();
	}
	else if(keys[SDL_SCANCODE_O])
	{
		loadState();
	}
	if(moving == 0)
	{
		resetAnimation(player, 0);
	}


	
  
  return 0;
}
Beispiel #20
0
void LiteApp::load(bool bUseSession)
{
    QSplashScreen *splash = 0;
    bool bSplash = m_settings->value(LITEAPP_SPLASHVISIBLE,true).toBool();
    if (bSplash) {
        splash = new QSplashScreen(QPixmap::fromImage(makeSplashImage(this)),Qt::WindowStaysOnTopHint);
    }
    if (bSplash) {
        splash->show();
    }

    if (bSplash) {
        splash->showMessage("liteide scan plugins ...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();

    loadMimeType();
    loadPlugins();

    if (bSplash) {
        splash->showMessage("liteide load plugins ...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();
    initPlugins();

    if (bSplash) {
        splash->showMessage("liteide load state ...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();

    loadState();
    m_mainwindow->show();

    emit loaded();
    m_projectManager->setCurrentProject(0);

    if (bSplash) {
        splash->showMessage("liteide load session ...",Qt::AlignLeft|Qt::AlignBottom);
    }

    qApp->processEvents();

    appendLog("LiteApp","loaded");
    bool b = m_settings->value(LITEAPP_AUTOLOADLASTSESSION,true).toBool();
    if (b && bUseSession) {
        loadSession("default");
    }

    if (bSplash) {
        m_mainwindow->raise();
        splash->finish(m_mainwindow);
        splash->deleteLater();
    }

    this->appendLog("HtmlWidgetFactory",m_htmlWidgetManager->classNameList().join(" "));
    this->appendLog("DefaultHtmlWidgetFactory",m_htmlWidgetManager->defaultClassName());

    m_goProxy->call("version");
    m_goProxy->call("cmdlist");    
}
Beispiel #21
0
void Game::runObjectsScript() {
	debug(DBG_GAME, "Game::runObjectsScript()");
	_objectScript.nextScene = -1;
	assert(_loadDataState != 3); // unneeded code
	if (_varsTable[309]) {
		memset(_keysPressed, 0, sizeof(_keysPressed));
	}
	if (_loadDataState == 2) {
		int start = _workaroundRaftFlySceneBug ? 1 : 0;
		_workaroundRaftFlySceneBug = false;
		for (int i = start; i < _sceneObjectsCount; ++i) {
			SceneObject *so = &_sceneObjectsTable[i];
			if (so->statePrev == 0 || so->statePrev == -1) {
				continue;
			}
			debug(DBG_GAME, "Game::runObjectsScript() currentObjectNum=%d", i);
			_objectScript.currentObjectNum = i;
			int anim = _sceneObjectMotionsTable[so->motionNum1].animNum;
			assert(anim >= 0 && anim < _animationsCount);
			_objectScript.data = _animationsTable[anim].scriptData;
			int endOfDataOffset = _animationsTable[anim].scriptSize; // endOfDataOffset2
			_objectScript.dataOffset = 0;
			int statement = 0;
			while (_objectScript.dataOffset < endOfDataOffset) {
				_objectScript.statementNum = statement;
				int endOfStatementDataOffset = _objectScript.fetchNextWord(); // endOfDataOffset1
				_objectScript.testObjectNum = -1;
				_objectScript.testDataOffset = endOfStatementDataOffset;
				bool loop = true;
				while (loop) {
					int op = _objectScript.fetchNextWord();
					debug(DBG_OPCODES, "statement %d condition %d op %d", statement, i, op);
					if (op == 0) {
						break;
					}
					loop = executeConditionOpcode(op);
				}
				if (loop) {
					while (_objectScript.dataOffset < endOfStatementDataOffset) {
						int op = _objectScript.fetchNextWord();
						debug(DBG_OPCODES, "statement %d operator %d op %d", statement, i, op);
						if (op == 100) { // &Game::oop_breakObjectScript
							endOfStatementDataOffset = _objectScript.dataOffset = endOfDataOffset;
							break;
						}
						executeOperatorOpcode(op);
					}
				}
				_objectScript.dataOffset = endOfStatementDataOffset;
				++statement;
			}
		}
		_dialogueEndedFlag = 0;
		if (_objectScript.nextScene != -1 && _objectScript.nextScene < _sceneConditionsCount) {
			strcpy(_tempTextBuffer, _nextScenesTable[_objectScript.nextScene].name);
			_switchScene = true;
			_currentSceneSav[0] = 0;
			if (stringEndsWith(_tempTextBuffer, "SAV")) {

				// debug(DBG_GAME, "End of demo interactive part");
				// strcpy(_tempTextBuffer, "A03.SCN");

				FileHolder fh(_fs, _tempTextBuffer);
				if (!fh._fp) {
					warning("Unable to load game state from file '%s'", _tempTextBuffer);
				} else {
					strcpy(_currentSceneSav, _tempTextBuffer);
					loadState(fh._fp, kDemoSavSlot, true);
					_loadState = _switchScene; // load on scene switch
				}
			}
		}
		for (int i = 0; i < _sceneObjectsCount; ++i) {
			reinitializeObject(i);
		}
		if (kCheatNoHit) {
			_varsTable[0] = 0;
		}
		if (_varsTable[0] >= 10 && !_gameOver) {
			strcpy(_musicName, "..\\midi\\gameover.mid");
			playMusic(_musicName);
			_gameOver = true;
//			_skipUpdateScreen = false;
		}
		if (_loadDataState == 2) {
			updateObjects();
		}
	}
//	_skipUpdateScreen = false;
	if (_varsTable[241] == 1) {
//		_startEndingScene = true;
		stopMusic();
		clearSceneData(-1);
		_varsTable[241] = 2;
		playVideo("DATA/FINAL.AVI");
		strcpy(_tempTextBuffer, "END.SCN");
		_switchScene = true;
	}
}
Beispiel #22
0
void Game::updateKeysPressedTable() {
	debug(DBG_GAME, "Game::updateKeysPressedTable()");
	_keysPressed[13] = _stub->_pi.enter ? 1 : 0;
	_keysPressed[16] = _stub->_pi.shift ? 1 : 0;
	_keysPressed[32] = _stub->_pi.space ? 1 : 0;
	_keysPressed[37] = (_stub->_pi.dirMask & PlayerInput::DIR_LEFT)  ? 1 : 0;
	_keysPressed[38] = (_stub->_pi.dirMask & PlayerInput::DIR_UP)    ? 1 : 0;
	_keysPressed[39] = (_stub->_pi.dirMask & PlayerInput::DIR_RIGHT) ? 1 : 0;
	_keysPressed[40] = (_stub->_pi.dirMask & PlayerInput::DIR_DOWN)  ? 1 : 0;
	if (_keyboardReplayData) {
		for (uint32_t i = 0; i < sizeof(_keysPressed) && _keyboardReplayOffset < _keyboardReplaySize; ++i) {
			_keysPressed[i] |= _keyboardReplayData[_keyboardReplayOffset];
			++_keyboardReplayOffset;
		}
	}
	if (_stub->_pi.tab) {
		_stub->_pi.tab = false;
		if (_varsTable[0] < 10 && _loadDataState == 2 && _sceneNumber > -1000) {
			_nextState = kStateBag;
		}
	}
	if (_stub->_pi.ctrl) {
		_stub->_pi.ctrl = false;
		_lifeBarDisplayed = !_lifeBarDisplayed;
	}
	if (_stub->_pi.stateSlot != 0) {
		int slot = _stateSlot + _stub->_pi.stateSlot;
		if (slot >= 1 && slot <= 999) {
			_stateSlot = slot;
			debug(DBG_INFO, "Current game state slot is %d", _stateSlot);
		}
		_stub->_pi.stateSlot = 0;
	}
	if (_stub->_pi.load) {
		_stub->_pi.load = false;
		char filePath[MAXPATHLEN];
		snprintf(filePath, sizeof(filePath), kGameStateFileNameFormat, _savePath, _stateSlot);
		File f;
		if (!f.open(filePath, "rb")) {
			warning("Unable to load game state from file '%s'", filePath);
		} else {
			loadState(&f, _stateSlot, true);
			_loadState = _switchScene; // gamestate will get loaded on scene switch
		}
	}
	if (_stub->_pi.save) {
		_stub->_pi.save = false;
		char filePath[MAXPATHLEN];
		snprintf(filePath, sizeof(filePath), kGameStateFileNameFormat, _savePath, _stateSlot);
		File f;
		if (!f.open(filePath, "wb")) {
			warning("Unable to save game state to file '%s'", filePath);
		} else {
			saveState(&f, _stateSlot);
		}
	}
	if (!_isDemo) {
		if (_stub->_pi.escape) {
			_stub->_pi.escape = false;
			_nextState = kStateMenu1;
		}
	}
	if (_gameOver) {
		if (_stub->_pi.enter) {
			_stub->_pi.enter = false;
			restart();
		}
	}
}
Beispiel #23
0
void Game::mainLoop() {
	if (_nextState != _state) {
		// fini
		switch (_state) {
		case kStateGame:
			break;
		case kStateDialogue:
			finiDialogue();
			break;
		case kStateMenu1:
		case kStateMenu2:
			finiMenu();
			break;
		}
		_state = _nextState;
		// init
		switch (_state) {
		case kStateGame:
			break;
		case kStateDialogue:
			initDialogue();
			break;
		case kStateBitmap:
			displayTitleBitmap();
			break;
		case kStateMenu1:
		case kStateMenu2:
			initMenu(1 + _state - kStateMenu1);
			break;
		}
	}
	switch (_state) {
	case kStateGame:
		while (_switchScene) {
			_switchScene = false;
			if (stringEndsWith(_tempTextBuffer, "SCN")) {
				win16_sndPlaySound(6);
				debug(DBG_GAME, "switch to scene '%s'", _tempTextBuffer);
				if (strcmp(_tempTextBuffer, "PIC4.SCN") == 0) {
					debug(DBG_INFO, "End of game");
					break;
				}
				strcpy(_currentSceneScn, _tempTextBuffer);
				parseSCN(_tempTextBuffer);
			} else {
				debug(DBG_GAME, "load mov '%s'", _tempTextBuffer);
				loadMOV(_tempTextBuffer);
			}
			if (_loadState) {
				_loadState = false;
				if (_currentSceneSav[0]) {
					FileHolder fh(_fs, _currentSceneSav);
					if (!fh._fp) {
						warning("Unable to load game state from file '%s'", _tempTextBuffer);
					} else {
						warning("Loading game state from '%s'", _currentSceneSav);
						loadState(fh._fp, kDemoSavSlot, false);
						loadKBR(_currentSceneSav);
					}
				} else {
					char filePath[MAXPATHLEN];
					snprintf(filePath, sizeof(filePath), kGameStateFileNameFormat, _savePath, _stateSlot);
					File f;
					if (!f.open(filePath, "rb")) {
						warning("Unable to load game state from file '%s'", filePath);
					} else {
						loadState(&f, _stateSlot, false);
					}
				}
				playMusic(_musicName);
				memset(_keysPressed, 0, sizeof(_keysPressed));
			}
			assert(_sceneObjectsCount != 0);
			if (_currentBagObject == -1) {
				_currentBagObject = _bagObjectsCount - 1;
				if (_currentBagObject > 0) {
					_currentBagObject = 0;
				}
			}
			if (_loadDataState != 0) {
				_stub->setPalette(_bitmapBuffer0 + kOffsetBitmapPalette, 256);
				_stub->copyRectWidescreen(kGameScreenWidth, kGameScreenHeight, _bitmapBuffer1.bits, _bitmapBuffer1.pitch);
			}
			_gameOver = false;
			_workaroundRaftFlySceneBug = strncmp(_currentSceneScn, "FLY", 3) == 0;
		}
		updateKeysPressedTable();
		updateMouseButtonsPressed();
		runObjectsScript();
		if (_startDialogue) {
			_startDialogue = false;
			_nextState = kStateDialogue;
		}
		break;
	case kStateBag:
		handleBagMenu();
		break;
	case kStateDialogue:
		handleDialogue();
		if (_dialogueEndedFlag) {
			_nextState = kStateGame;
		}
		break;
	case kStateBitmap:
		if (_stub->_pi.enter) {
			_stub->_pi.enter = false;
			playVideo("DATA/INTRO.AVI");
			_nextState = kStateGame;
		}
		break;
	case kStateMenu1:
		handleMenu();
		switch (_menuOption) {
		case kMenuOptionNewGame:
			restart();
			_nextState = kStateGame;
			break;
		case kMenuOptionLoadGame:
			_stub->_pi.load = true;
			_nextState = kStateGame;
			break;
		case kMenuOptionSaveGame:
			_stub->_pi.save = true;
			_nextState = kStateGame;
			break;
		case kMenuOptionQuitGame:
			_nextState = kStateMenu2;
			break;
		}
		if (_stub->_pi.escape) {
			_stub->_pi.escape = false;
			_nextState = kStateGame;
		}
		break;
	case kStateMenu2:
		handleMenu();
		switch (_menuOption) {
		case kMenuOptionExitGame:
			_stub->_quit = true;
			break;
		case kMenuOptionReturnGame:
			_nextState = kStateGame;
			break;
		}
		if (_stub->_pi.escape) {
			_stub->_pi.escape = false;
			_nextState = kStateGame;
		}
		break;
	}
	_stub->updateScreen();
}
void saverScene::loadPreState(){
	whichState--;
	loadState();
}
void saverScene::loadNextState(){
	whichState++;
	loadState();
}
AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
    : QDialog(parent)
    , m_ui(new Ui::AddNewTorrentDialog)
    , m_contentModel(nullptr)
    , m_contentDelegate(nullptr)
    , m_hasMetadata(false)
    , m_oldIndex(0)
    , m_torrentParams(inParams)
{
    // TODO: set dialog file properties using m_torrentParams.filePriorities
    m_ui->setupUi(this);
    setAttribute(Qt::WA_DeleteOnClose);
    m_ui->lblMetaLoading->setVisible(false);
    m_ui->progMetaLoading->setVisible(false);

    m_ui->savePath->setMode(FileSystemPathEdit::Mode::DirectorySave);
    m_ui->savePath->setDialogCaption(tr("Choose save path"));
    m_ui->savePath->setMaxVisibleItems(20);

    auto session = BitTorrent::Session::instance();

    if (m_torrentParams.addPaused == TriStateBool::True)
        m_ui->startTorrentCheckBox->setChecked(false);
    else if (m_torrentParams.addPaused == TriStateBool::False)
        m_ui->startTorrentCheckBox->setChecked(true);
    else
        m_ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());

    m_ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
    m_ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
    m_ui->comboTTM->blockSignals(false);
    populateSavePathComboBox();
    connect(m_ui->savePath, &FileSystemPathEdit::selectedPathChanged, this, &AddNewTorrentDialog::onSavePathChanged);

    const bool rememberLastSavePath = settings()->loadValue(KEY_REMEMBERLASTSAVEPATH, false).toBool();
    m_ui->checkBoxRememberLastSavePath->setChecked(rememberLastSavePath);

    if (m_torrentParams.createSubfolder == TriStateBool::True)
        m_ui->createSubfolderCheckBox->setChecked(true);
    else if (m_torrentParams.createSubfolder == TriStateBool::False)
        m_ui->createSubfolderCheckBox->setChecked(false);
    else
        m_ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());

    m_ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking);
    m_ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);

    // Load categories
    QStringList categories = session->categories().keys();
    std::sort(categories.begin(), categories.end(), Utils::String::naturalLessThan<Qt::CaseInsensitive>);
    QString defaultCategory = settings()->loadValue(KEY_DEFAULTCATEGORY).toString();

    if (!m_torrentParams.category.isEmpty())
        m_ui->categoryComboBox->addItem(m_torrentParams.category);
    if (!defaultCategory.isEmpty())
        m_ui->categoryComboBox->addItem(defaultCategory);
    m_ui->categoryComboBox->addItem("");

    foreach (const QString &category, categories)
        if (category != defaultCategory && category != m_torrentParams.category)
            m_ui->categoryComboBox->addItem(category);

    m_ui->contentTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
    loadState();
    // Signal / slots
    connect(m_ui->toolButtonAdvanced, &QToolButton::clicked, this, &AddNewTorrentDialog::showAdvancedSettings);
    connect(m_ui->doNotDeleteTorrentCheckBox, &QCheckBox::clicked, this, &AddNewTorrentDialog::doNotDeleteTorrentClicked);
    QShortcut *editHotkey = new QShortcut(Qt::Key_F2, m_ui->contentTreeView, nullptr, nullptr, Qt::WidgetShortcut);
    connect(editHotkey, &QShortcut::activated, this, &AddNewTorrentDialog::renameSelectedFile);
    connect(m_ui->contentTreeView, &QAbstractItemView::doubleClicked, this, &AddNewTorrentDialog::renameSelectedFile);

    m_ui->buttonBox->button(QDialogButtonBox::Ok)->setFocus();
}
Beispiel #27
0
void MySensor::saveState(uint8_t pos, uint8_t value) {
	if (loadState(pos) != value) {
		eeprom_write_byte((uint8_t*)(EEPROM_LOCAL_CONFIG_ADDRESS+pos), value);
	}
}
bool ossimGeneralRasterInfo::open( const ossimFilename& imageFile )
{
   static const char MODULE[] = "ossimGeneralRasterInfo::open";
   if ( traceDebug() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE << " entered..." << "\nimageFile: " << imageFile << std::endl;
   }

   bool result = false;

   // Wipe any previous state slick.
   clear();

   ossimFilename copyFile = imageFile;
   if ( !imageFile.exists() )
   {
      copyFile = imageFile.expand();
   }

   // Look for the headrer of omd file as they are written out by img2rr.
   ossimFilename hdr = copyFile;
   hdr.setExtension("hdr"); // image.hdr
   if ( !hdr.exists() )
   {
      hdr = imageFile;
      hdr.string() += ".hdr"; // image.ras.hdr
      if ( ! hdr.exists() )
      {
         hdr = imageFile;
         hdr.setExtension("xml"); // image.xml
      }
   }

   if ( hdr.exists() )
   {
      if ( traceDebug() )
      {
         ossimNotify(ossimNotifyLevel_DEBUG) << "header file: " << hdr << std::endl;
      }
      
      ossimString ext = hdr.ext().downcase();
      
      if ( ext == "hdr" )
      {
         if ( ossimEnviHeader::isEnviHeader( hdr ) )
         {
            result = initializeFromEnviHdr( hdr );
         }
         else
         {
            result = initializeFromHdr( imageFile, hdr );
         }

         if ( !result )
         {
            // Could be an ossim meta data file:
            ossimKeywordlist kwl( hdr );
            result = loadState( kwl, 0 );
         }
      }
      else if ( ext == "xml" )
      {
         result = initializeFromXml( imageFile, hdr );
      }
   }
   
   //---
   // Set the file name.  Needed for ossimGeneralRasterTileSource::open.
   // Note set here above loadState call to stop loadState from returning
   // false if no image file found.
   //---
   if ( theImageFileList.empty() )
   {
      setImageFile( imageFile );
   }
   
   ossimFilename omd = imageFile;
   omd.setExtension("omd"); // image.omd
   if ( !omd.exists() )
   {
      omd.setExtension("kwl"); // image.kwl
   }

   if ( omd.exists() )
   {
      if ( traceDebug() )
      {
         ossimNotify(ossimNotifyLevel_DEBUG) << "omd file: " << omd << std::endl;
      }

      ossimKeywordlist kwl( omd );

      if ( result && theMetaData.getNumberOfBands() )
      {
         //---
         // Just update the band info in case it has min/max values from
         // a compute min/max scan.
         //---
         theMetaData.updateMetaData( kwl, std::string("") );
      }
      else
      {
         // We're not initialized yet so do a loadState:
         result = loadState( kwl, 0 );
      }
   }
   
   if ( traceDebug() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << MODULE  << " Exit status: " << (result?"true":"false") << std::endl;
   }
   
   return result;
}
Beispiel #29
0
int main_menu()
{
  static int i = 0;
  static int upHeld = 0;
  static int downHeld = 0;
  SDL_Renderer *render;
  render = gt_graphics_get_active_renderer();
  SDL_RenderClear(gt_graphics_get_active_renderer());
  ResetBuffer();
  mainScreen = loadSprite("images/opening_screen.png",800,600,1);
  selection = loadSprite("images/selection.png",149,53,1);
  printf("%i", i);
  if(i == 0)
	{
		drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
		drawSprite(selection,0,vec2d(311,292),vec2d(1,1),0,gt_graphics_get_active_renderer());
  }else if(i == 1)
  {
	  drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  drawSprite(selection,0,vec2d(275,376),vec2d(1.5,1),0,gt_graphics_get_active_renderer());
	  
  }else if(i == 2)
  {
	  drawSprite(mainScreen,0,vec2d(0,0),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  drawSprite(selection,0,vec2d(311,460),vec2d(1,1),0,gt_graphics_get_active_renderer());
	  
  }
  NextFrame();
  SDL_PumpEvents();
  keys = SDL_GetKeyboardState(NULL);
  if(keys[SDL_SCANCODE_ESCAPE])
    {
        done = 1;
    }
  if(keys[SDL_SCANCODE_DOWN]&&downHeld == 0)
    {
	  i=(i+1)%3;
	  downHeld = 1;
	}else if(!keys[SDL_SCANCODE_DOWN])
  {
		downHeld = 0;
  }
  if(keys[SDL_SCANCODE_UP]&&upHeld == 0)
  {
	  if((i = i-1)<0)
		  i = 2;

	  upHeld = 1;
	}else if(!keys[SDL_SCANCODE_UP])
  {
		upHeld = 0;
  }
  if(keys[SDL_SCANCODE_RETURN])
  {
	  if(i == 0)
	  {
		  gameState = 1;
		  init_lvl1();
	  }
	  else if(i == 2)
	  {
		  done = 1;
	  }
	  else if(i == 1)
	  {
		  init_player();

		  loadState();
		  if(gameState == 1)
		  {
			  init_lvl1();
		  }else if(gameState == 2)
		  {
			  init_lvl2();
		  }
	  }
  }	  
   return 1;
}
Beispiel #30
0
void Game::mainLoop() {
	_stub->init(_gameWindowTitle, kGameScreenWidth, kGameScreenHeight);
	allocateTables();
	loadCommonSprites();
	_mixer->open();
	restart();
	if (_isDemo) {
		playBitmapSequenceDemo();
	} else {
		playVideo("DATA/LOGO.AVI");
		playVideo("DATA/INTRO.AVI");
	}
	_lastFrameTimeStamp = _stub->getTimeStamp();
	while (!_stub->_quit) {
		if (_switchScene) {
			_switchScene = false;
			if (stringEndsWith(_tempTextBuffer, "SCN")) {
				win16_sndPlaySound(6);
				debug(DBG_GAME, "switch to scene '%s'", _tempTextBuffer);
				if (strcmp(_tempTextBuffer, "PIC4.SCN") == 0) {
					debug(DBG_INFO, "End of game");
					break;
				}
				strcpy(_currentSceneScn, _tempTextBuffer);
				parseSCN(_tempTextBuffer);
			} else if (stringEndsWith(_tempTextBuffer, "SAV")) {
				if (_isDemo && strcmp(_tempTextBuffer, "A16.SAV") == 0) {
					debug(DBG_GAME, "End of demo interactive part");
					restart();
					continue;
				}
				warning("Ignoring savestate load '%s'", _tempTextBuffer);
				// should work though, as the original savestates load fine
				// now, but this "feature" is only used in the demo AFAICT,
				// so no need to bother...
			} else {
				debug(DBG_GAME, "load mov '%s'", _tempTextBuffer);
				loadMOV(_tempTextBuffer);
			}
			if (_loadState) {
				_loadState = false;
				loadState(_stateSlot, false);
				playMusic(_musicName);
				memset(_keysPressed, 0, sizeof(_keysPressed));
			}
			assert(_sceneObjectsCount != 0);
			if (_currentBagObject == -1) {
				_currentBagObject = _bagObjectsCount - 1;
				if (_currentBagObject > 0) {
					_currentBagObject = 0;
				}
			}
			if (_loadDataState != 0) {
				setupScreenPalette(_bitmapBuffer0 + kOffsetBitmapPalette);
			}
			_gameOver = false;
			_workaroundRaftFlySceneBug = strncmp(_currentSceneScn, "FLY", 3) == 0;
		}
		updateKeysPressedTable();
		updateMouseButtonsPressed();
		runObjectsScript();
		if (!_switchScene) {
			_stub->updateScreen();
			uint32 end = _lastFrameTimeStamp + kCycleDelay;
			do {
				_stub->sleep(10);
				_stub->processEvents();
			} while (!_stub->_pi.fastMode && _stub->getTimeStamp() < end);
			_lastFrameTimeStamp = _stub->getTimeStamp();
		}
		if (_startDialogue) {
			_startDialogue = false;
			handleDialogue();
		}
	}
	clearSceneData(-1);
	deallocateTables();
	unloadCommonSprites();
	_mixer->close();
	_stub->destroy();
}