Пример #1
0
void WindowPlanes::setScore(int num)
{
    myScore+=num;
    if(myScore>60000&&!prop_state)
    {
        timer_prop.start(30000);
        prop_state=true;
    }

    if(myScore>400000&&grade==1)
    {
        grade=2;
        upgrade();
    }
    if(myScore>500000&&grade==2)
    {
        grade=3;
        upgrade();
    }
    if(myScore>700000&&grade==3)
    {
        grade=4;
        upgrade();
    }
    if(myScore>1000000&&grade==4)
    {
        grade=5;
        upgrade();
    }
    emit addScore(num);
}
Пример #2
0
bool DatabaseUtilities::createDb(const DatabaseParameters& params,
																 const QString& root,
																 const QString& pwd)
{
	bool success;
	QString dbID = "root_db";

	// creating the QSqlDatabase object within a code block.
	// Assures proper cleanup when removing the db.
	{
		// create a parameter object with db admin credentials
		DatabaseParameters setupdbparams = params;
		setupdbparams.setDBUserName(root);
		setupdbparams.setDBPassword(pwd);
		// create a connection to a root db (using admin credentials)
		QSqlDatabase setupDb = QSqlDatabase::addDatabase(setupdbparams.dBType(), dbID);
		setupdbparams.apply(setupDb,true);
		// try accessing
		success = setupDb.open();
		if(success)
		{
			// create schema
			Upgrade upgrade(setupDb);
			upgrade.setup(params);
			setupDb.close();
		}
	}
	QSqlDatabase::removeDatabase(dbID);

	return success;
}
Пример #3
0
void WindowPlanes::start_game()
{
    //qDebug()<<QThread::currentThread();
    if(game_state=="stop")
    {
        myScore=0;
        grade=1;
        number=0;
        bullet_type=1;
        prop_state=false;
        pixmap_bullet=&pixmap_bullet1;
        save_timer_bullet_to_single=save_timer_two_secs=-1;

        planes->setX(width()/2-planes->width()/2);//设置飞机的位置
        planes->setY(height()-planes->height());//设置飞机的位置
        //qDebug()<<QString::fromUtf8("飞机的位置是")<<width()<<height();

        game_state="run";
        planes->show();
        planes->timer.start(100);
        timer_bullet.start(230);
        time_game_start_runing.start();

        upgrade();
//        mythread->start();
        // Yeatse:
        emit myThreadStart();
    }
}
Пример #4
0
bool Flashlight::shoot(vector<Enemy*>& enemyVector, SDL_Renderer* renderer, field heroField, field mousePosition)
{
    if((cooldownTimer_ + cooldown_) <SDL_GetTicks()) ///Check cooldown
    {
        cooldownTimer_ = SDL_GetTicks();
        lastAttackMode_ = 1;

        int i=0;
        for(Enemy* enemy : enemyVector)
        {
            ///Check if hit
            if(WrapperSDL::lineIntesectsSquare(heroField, mousePosition, enemy->getPixelLocalization(), 80, 80)
               && WrapperSDL::checkIfInRadius(heroField, enemy->getPixelLocalization(), range_+20))
            {

                enemy->killed(renderer);
                enemyVector.erase(enemyVector.begin()+i);
                i--;                                          
                ghostKilled_++;
                if(ghostKilled_ == 3)
                {
                    upgrade(renderer);
                }
            }
            i++;
        }
    }
    return 1;
}
Пример #5
0
 int get(int key) {
     if (kv.find(key) != kv.end()){
         int rp = kv[key];
         upgrade(rp);
         return V[rp];
     }
     return -1;
 }
Пример #6
0
void World::upgradeTower(cocos2d::Vec2 tile) {
    auto tower = _gameplayLayer->getTower(tile);

    tower->upgrade();
    _mapLayer->setSlotColor(tile, tower->getBaseColor());

    _gameplayLayer->balanceTotalEnergy(-tower->getCost());
}
Пример #7
0
Openable::Openable(DescriptionPtr dsc)
  : _locked(false)
  , _lockId(0)
  , _lockLevel(0)
  , _scriptId(0)
  , _closed(false)
{
  upgrade(dsc);
}
Пример #8
0
////////////////////////////////////////////////////////////////////////////////
// If 'other' has styles that are compatible, merge them into this.  Colors in
// other take precedence.
void Color::blend (const Color& other)
{
#ifdef FEATURE_COLOR
  Color c (other);
  _value |= (c._value & _COLOR_UNDERLINE);    // Always inherit underline.
  _value |= (c._value & _COLOR_INVERSE);      // Always inherit inverse.

  // 16 <-- 16.
  if (!(_value   & _COLOR_256) &&
      !(c._value & _COLOR_256))
  {
    _value |= (c._value & _COLOR_BOLD);       // Inherit bold.
    _value |= (c._value & _COLOR_BRIGHT);     // Inherit bright.

    if (c._value & _COLOR_HASFG)
    {
      _value |= _COLOR_HASFG;                 // There is now a color.
      _value &= ~_COLOR_FG;                   // Remove previous color.
      _value |= (c._value & _COLOR_FG);       // Apply other color.
    }

    if (c._value & _COLOR_HASBG)
    {
      _value |= _COLOR_HASBG;                 // There is now a color.
      _value &= ~_COLOR_BG;                   // Remove previous color.
      _value |= (c._value & _COLOR_BG);       // Apply other color.
    }

    return;
  }
  else
  {
    // Upgrade either color, if necessary.
    if (!(_value   & _COLOR_256)) upgrade ();
    if (!(c._value & _COLOR_256)) c.upgrade ();

    // 256 <-- 256.
    if (c._value & _COLOR_HASFG)
    {
      _value |= _COLOR_HASFG;                  // There is now a color.
      _value &= ~_COLOR_FG;                    // Remove previous color.
      _value |= (c._value & _COLOR_FG);        // Apply other color.
    }

    if (c._value & _COLOR_HASBG)
    {
      _value |= _COLOR_HASBG;                  // There is now a color.
      _value &= ~_COLOR_BG;                    // Remove previous color.
      _value |= (c._value & _COLOR_BG);        // Apply other color.
    }
  }
#endif
}
Пример #9
0
void Building::upgrade_building(std::string description){
	if(description == "fire_upgrade"){
		//std::cout<<"fire upgrade"<<std::endl;
		//attack_alter(1.0);
		upgrade("fire", 1);
	}
	else if(description == "water_upgrade"){
		//std::cout<<"water upgrade"<<std::endl;
		max_hp_alter(50);
		upgrade("water", 1);
	}
	else if(description == "earth_upgrade"){
		//std::cout<<"earth upgrade"<<std::endl;
		armor_alter(1.0);
		upgrade("earth", 1);

	}
	else if(description == "air_upgrade"){
		//std::cout<<"air upgrade"<<std::endl;
		attack_cycle_alter(-1.0);
		upgrade("air", 1);
	}
}
Пример #10
0
bool CarOption::buyOption(Player* pl)
{
    bool hasBought = false;
    if (m_current < m_maxOpt)
    {
        if (pl->spendMoney(getPrice()))
        {
            m_current++;
            upgrade();   // increase the value(s) of car settings
            hasBought = true;
        }
    }
    return hasBought;
}
Пример #11
0
int init (int *m_isUp) {

    printf ("\n[init] init.c\n");

    head = (init_config *)malloc(sizeof(init_config));
    head->isUpgraded = m_isUp;// false;
    //head->flag = 0;
    upgrade(head->isUpgraded);
    if (*head->isUpgraded == 1)
      printf ("\n[init] true ");
    else
      printf ("\n[init] false ");
    return 0;
}
Пример #12
0
void Config::DownloadCompletedCallback(http::Download &download) {
	if (download.ResultCode() != 200) {
		ERROR_LOG(LOADER, "Failed to download version.json");
		return;
	}
	std::string data;
	download.buffer().TakeAll(&data);
	if (data.empty()) {
		ERROR_LOG(LOADER, "Version check: Empty data from server!");
		return;
	}

	JsonReader reader(data.c_str(), data.size());
	const json_value *root = reader.root();
	if (!root) {
		ERROR_LOG(LOADER, "Failed to parse json");
		return;
	}

	std::string version = root->getString("version", "");

	const char *gitVer = PPSSPP_GIT_VERSION;
	Version installed(gitVer);
	Version upgrade(version);
	Version dismissed(g_Config.dismissedVersion);

	if (!installed.IsValid()) {
		ERROR_LOG(LOADER, "Version check: Local version string invalid. Build problems? %s", PPSSPP_GIT_VERSION);
		return;
	}
	if (!upgrade.IsValid()) {
		ERROR_LOG(LOADER, "Version check: Invalid server version: %s", version.c_str());
		return;
	}

	if (installed >= upgrade) {
		INFO_LOG(LOADER, "Version check: Already up to date, erasing any upgrade message");
		g_Config.upgradeMessage = "";
		g_Config.upgradeVersion = upgrade.ToString();
		g_Config.dismissedVersion = "";
		return;
	}

	if (installed < upgrade && dismissed != upgrade) {
		g_Config.upgradeMessage = "New version of PPSSPP available!";
		g_Config.upgradeVersion = upgrade.ToString();
		g_Config.dismissedVersion = "";
	}
}
Пример #13
0
 void set(int key, int value) {
     int rp;
     if (kv.find(key) != kv.end()){
         rp = kv[key];
     }else{
         rp = L[n+1];
         if (V[rp] != -1){
             kv.erase(K[rp]);
         }
         kv[key] = rp;
         K[rp] = key;
     }
     V[rp] = value;
     upgrade(rp);
 }
Пример #14
0
CannonTower::CannonTower(std::string parms)
: Tower(parms,50,"Sprites/Bunny/Original/tower_bunnies_small.png")
{
	towerType="CannonTower";
    firingSound = new sf::Sound(SoundLoader::getSoundBuffer("canon_fire.wav"));
	if(firingSound != NULL)
	{
	    firingSound->setVolume(80);
	}

    int upgradePack = currentUpgradePack;
    currentUpgradePack = 0;
    while(currentUpgradePack < upgradePack){
        upgrade();
    }
}
Пример #15
0
LongTower::LongTower(std::string parms)
: Tower(parms,30,"Sprites/Bunny/Original/bunny_1_small.png")
{
	towerType="LongTower";
    firingSound = new sf::Sound(SoundLoader::getSoundBuffer("arrow_fire.wav"));
    if(firingSound != NULL)
	{
	    firingSound->setVolume(80);
	}

    int upgradePack = currentUpgradePack;
    currentUpgradePack = 0;
    while(currentUpgradePack < upgradePack){
        upgrade();
    }
}
void HttpServerRequest::onReadyRead()
{
    if (priv->timeout)
        priv->timer->start(priv->timeout);

    priv->buffer += priv->socket.readAll();
    size_t nparsed = http_parser_execute(&priv->parser,
                                         &Priv::httpSettingsInstance,
                                         priv->buffer.constData(),
                                         priv->buffer.size());

    if (priv->parser.http_errno) {
        priv->socket.close();
        return;
    }

    if (priv->whatEmit.testFlag(Priv::READY)) {
        priv->whatEmit &= ~Priv::Signals(Priv::READY);
        this->disconnect(SIGNAL(data()));
        this->disconnect(SIGNAL(end()));
        emit ready();
    }

    if (priv->whatEmit.testFlag(Priv::DATA)) {
        priv->whatEmit &= ~Priv::Signals(Priv::DATA);
        emit data();
    }

    priv->buffer.remove(0, nparsed);

    if (priv->whatEmit.testFlag(Priv::END)) {
        priv->whatEmit &= ~Priv::Signals(Priv::END);
        emit end();
        return;
    }

    if (priv->parser.upgrade) {
        disconnect(&priv->socket, SIGNAL(readyRead()),
                   this, SLOT(onReadyRead()));
        disconnect(&priv->socket, SIGNAL(disconnected()),
                   this, SIGNAL(close()));
        disconnect(priv->timer, SIGNAL(timeout()), this, SLOT(onTimeout()));

        priv->body.swap(priv->buffer);
        emit upgrade();
    }
}
Пример #17
0
LongTower::LongTower(int newX, int newY, int upgradePack)
: Tower(newX, newY, 80, 10, 140, 60, "Sprites/Bunny/Original/bunny_1_small.png")
{
	towerType="LongTower";
    firingSound = new sf::Sound(SoundLoader::getSoundBuffer("arrow_fire.wav"));
	if(firingSound != NULL)
	{
	    firingSound->setVolume(80);
	}

    // Upgrade if it should be upgraded
	currentUpgradePack = 0;
	upgradeText = "+Range\nCost: 80";
	upgradePrice = 80;
    while(currentUpgradePack < upgradePack){
        upgrade();
    }
}
Пример #18
0
CannonTower::CannonTower(int newX, int newY, int upgradePack)
: Tower(newX, newY, 200, 20, 200, 140, "Sprites/Bunny/Original/tower_bunnies_small.png")
{
	towerType="CannonTower";
	firingSound = new sf::Sound(SoundLoader::getSoundBuffer("canon_fire.wav"));
	if(firingSound != NULL)
	{
	    firingSound->setVolume(80);
	}

    // Upgrade if it should be upgraded
	currentUpgradePack = 0;
	upgradeText = "+Damage\nCost: 90";
	upgradePrice = 90;
    while(currentUpgradePack < upgradePack){
        upgrade();
    }

}
Пример #19
0
/**
\brief Updates the state of the producer.
\param change change in productivity.

Produces items until storage is full or productionAmount is reached. 
Then calls producers::upgrade if >0, producers::downgrade if <0 or does nothing.
*/
void producers::update(char change)
	{
	eat();
	if(alive){
		if(stock[item]<storage[item])
			stock[item]+=productionAmount;
		if(change>0)
			upgrade();
		if(change<0)
			downgrade();
		return;
		}
	else
		{
		std::cout << "This producer is dead!\n";
		return;
		}

	}
Пример #20
0
void multimediaProject::loadData( const QByteArray & _data,
					const QString & _sourceFile )
{
	QString errorMsg;
	int line = -1, col = -1;
	if( !setContent( _data, &errorMsg, &line, &col ) )
	{
		// parsing failed? then try to uncompress data
		QByteArray uncompressed = qUncompress( _data );
		if( !uncompressed.isEmpty() )
		{
			if( setContent( uncompressed, &errorMsg, &line, &col ) )
			{
				line = col = -1;
			}
		}
		if( line >= 0 && col >= 0 )
		{
			qWarning() << "at line" << line << "column" << errorMsg;
			QMessageBox::critical( NULL,
				songEditor::tr( "Error in file" ),
				songEditor::tr( "The file %1 seems to contain "
						"errors and therefore can't be "
						"loaded." ).
							arg( _sourceFile ) );
			return;
		}
	}

	QDomElement root = documentElement();
	m_type = type( root.attribute( "type" ) );
	m_head = root.elementsByTagName( "head" ).item( 0 ).toElement();

	if( root.hasAttribute( "creatorversion" ) &&
		root.attribute( "creatorversion" ) != LMMS_VERSION )
	{
		upgrade();
	}

	m_content = root.elementsByTagName( typeName( m_type ) ).
							item( 0 ).toElement();
}
Пример #21
0
int equipmentUpdater::upgradeEquipment(int equipID,int isHaveRuby,int isHavaSap)
{

    int ret = equipID;
    UpgradeInfo* pui = smashHeroDatabaseUtil::getInstance()->getUpgradeInfoForItemID(equipID);
	
	timeval psv;
	gettimeofday(&psv, NULL);
	unsigned long int seed = psv.tv_sec * 1000 + psv.tv_usec / 1000;
	srand(seed);
    int roll = rand()%100+1;
//    CCLOG(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::rolled : %i with succedrate :%i",roll,pui->succeedRate);

    if (roll<=(pui->succeedRate+pui->succeedRate*isHaveRuby))
    {
        ret = upgrade(equipID);
    }
    else
    {
		//srand(unsigned(time(0)));
        roll = rand()%100+1;
        if (isHavaSap==1)
        {
            ret = equipID;
        }
        else
        {
            if (roll<pui->destoryRate)
            {
                ret = 0;
            }
            else if(roll<pui->destoryRate+pui->degradeRate)
            {
                ret = degrade(equipID);
            }
        }
    }

    delete pui;
	pui = NULL;
    return ret;
}
Пример #22
0
StateChange * StateChanges::get(state from)
{
  StateChange * ret = NULL;
  states::iterator sq = findInQueue(from);  
  if(sq!=scq.end()){
    (*sq)->inc();
    ret = *sq;
    upgrade(sq);
    return ret;
  }
  states::iterator s = find(from);
  if(s!=sc.end()){
    (*s)->inc();
    StateChange * ss = (*s);
    ret = ss;
    sc.erase(s);
    insertSorted(ss);
  }
  return ret;
}
Пример #23
0
static void init(void) {
    upgrade();

    app_message_init();
    error_window_init();
    stats_layer_global_init();
    refresh_layer_global_init();

    window = window_create();
    window_set_background_color(window, GColorBlack);
    window_set_click_config_provider(window, window_click_config_provider);
    window_set_fullscreen(window, true);

    static const WindowHandlers window_handlers = {
        .load = window_load,
        .unload = window_unload,
    };
    window_set_window_handlers(window, window_handlers);
    window_stack_push(window, true);
}
Пример #24
0
/*
 *  Constructs a Example which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'
 */
Accueil::Accueil(QWidget *parent, Qt::WFlags f)
    : QWidget(parent, f)
{
	setupUi(this); // reads the .ui file to determine widgets and layout
    // Construct context menu, available to the user via Qtopia's soft menu bar.
    QMenu *menu = QSoftMenuBar::menuFor(this);
	menu->addAction(tr("Options"), this, SLOT(options()));
	menu->addAction(tr("Upgrade mplayer"), this, SLOT(upgrade()));
    QAction *actionClose = new QAction(QIcon("close"),tr("Close"),this);
    connect(actionClose,SIGNAL(triggered()), this, SLOT(close()));
    connect(RadioButton,SIGNAL(clicked()), this, SLOT(RadioButton_clicked()));
    connect(VideoButton,SIGNAL(clicked()), this, SLOT(VideoButton_clicked()));
    menu->addAction(actionClose);
    QSoftMenuBar::setHelpEnabled(this,false);
    
    //Test and create the .QmokoPlayer in the current home user if necessary
    QDir Directory(QDir::homePath () +"/.QMokoPlayer");
    if (!Directory.exists())
    	Directory.mkdir(QDir::homePath () +"/.QMokoPlayer");
    
    //verify if mplayer is already installed
	if (!QFile::exists("/usr/bin/mplayer"))
	{

		 if(QMessageBox::question(this, tr("qmplayer"),
                             tr("Program MPlayer must be downloaded. Please make sure you have internet connection and press yes to confirm download"),
                             QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
       {
           if(installMplayer())
           {
               QMessageBox::information(this, tr("qmplayer"), tr("MPlayer installed sucessfully"));
           }
           else
           	QMessageBox::warning(this, tr("qmplayer"), tr("Failed to install MPlayer"));
       }
			
	}

}
Пример #25
0
void work_task(void *pvParam)
{	
	while(1) {
		if(KEY_PowerOff()) {
			POWER_Off();
			
			return;
		} else if(KEY_Pressed(KEY_State(), key_broadcast)) {
			power_screen(true);			
			LED_Light(led_red, true);
			LED_Light(led_green, true);
			LED_Light(led_blue, true);		
			
			{
				strcpy(watcher_data->sid, "18000000000072");
				upgrade();
			}
			LED_Light(led_red, false);
			LED_Light(led_green, false);
			LED_Light(led_blue, false);	
			power_screen(false);
		}
	}
}
Пример #26
0
void PackageItem::handleUpgrade()
{
  emit upgrade(package);
}
Пример #27
0
void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
	const bool useIniFilename = iniFileName != nullptr && strlen(iniFileName) > 0;
	iniFilename_ = FindConfigFile(useIniFilename ? iniFileName : "ppsspp.ini");

	const bool useControllerIniFilename = controllerIniFilename != nullptr && strlen(controllerIniFilename) > 0;
	controllerIniFilename_ = FindConfigFile(useControllerIniFilename ? controllerIniFilename : "controls.ini");

	INFO_LOG(LOADER, "Loading config: %s", iniFilename_.c_str());
	bSaveSettings = true;

	bShowFrameProfiler = true;

	IniFile iniFile;
	if (!iniFile.Load(iniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting config to default.", iniFilename_.c_str());
		// Continue anyway to initialize the config.
	}

	for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) {
		IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section);
		for (auto setting = sections[i].settings; setting->HasMore(); ++setting) {
			setting->Get(section);
		}
	}

	iRunCount++;
	if (!File::Exists(currentDirectory))
		currentDirectory = "";

	IniFile::Section *recent = iniFile.GetOrCreateSection("Recent");
	recent->Get("MaxRecent", &iMaxRecent, 30);

	// Fix issue from switching from uint (hex in .ini) to int (dec)
	// -1 is okay, though. We'll just ignore recent stuff if it is.
	if (iMaxRecent == 0)
		iMaxRecent = 30;

	if (iMaxRecent > 0) {
		recentIsos.clear();
		for (int i = 0; i < iMaxRecent; i++) {
			char keyName[64];
			std::string fileName;

			snprintf(keyName, sizeof(keyName), "FileName%d", i);
			if (recent->Get(keyName, &fileName, "") && !fileName.empty()) {
				recentIsos.push_back(fileName);
			}
		}
	}

	auto pinnedPaths = iniFile.GetOrCreateSection("PinnedPaths")->ToMap();
	vPinnedPaths.clear();
	for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
		vPinnedPaths.push_back(it->second);
	}

	if (iAnisotropyLevel > 4) {
		iAnisotropyLevel = 4;
	}

	// Check for an old dpad setting
	IniFile::Section *control = iniFile.GetOrCreateSection("Control");
	float f;
	control->Get("DPadRadius", &f, 0.0f);
	if (f > 0.0f) {
		ResetControlLayout();
	}

	// MIGRATION: For users who had the old static touch layout, aren't I nice?
	// We can probably kill this in 0.9.8 or something.
	if (fDpadX > 1.0 || fDpadY > 1.0) { // Likely the rest are too!
		float screen_width = dp_xres;
		float screen_height = dp_yres;

		fActionButtonCenterX /= screen_width;
		fActionButtonCenterY /= screen_height;
		fDpadX /= screen_width;
		fDpadY /= screen_height;
		fStartKeyX /= screen_width;
		fStartKeyY /= screen_height;
		fSelectKeyX /= screen_width;
		fSelectKeyY /= screen_height;
		fUnthrottleKeyX /= screen_width;
		fUnthrottleKeyY /= screen_height;
		fLKeyX /= screen_width;
		fLKeyY /= screen_height;
		fRKeyX /= screen_width;
		fRKeyY /= screen_height;
		fAnalogStickX /= screen_width;
		fAnalogStickY /= screen_height;
	}
	
	const char *gitVer = PPSSPP_GIT_VERSION;
	Version installed(gitVer);
	Version upgrade(upgradeVersion);
	const bool versionsValid = installed.IsValid() && upgrade.IsValid();

	// Do this regardless of iRunCount to prevent a silly bug where one might use an older
	// build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice,
	// even if said newer version is >= the upgrade found online.
	if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) {
		upgradeMessage = "";
	}

	// Check for new version on every 10 runs.
	// Sometimes the download may not be finished when the main screen shows (if the user dismisses the
	// splash screen quickly), but then we'll just show the notification next time instead, we store the
	// upgrade number in the ini.
#if !defined(ARMEABI)
	if (iRunCount % 10 == 0 && bCheckForNewVersion) {
		std::shared_ptr<http::Download> dl = g_DownloadManager.StartDownloadWithCallback(
			"http://www.ppsspp.org/version.json", "", &DownloadCompletedCallback);
		dl->SetHidden(true);
	}
#endif

	INFO_LOG(LOADER, "Loading controller config: %s", controllerIniFilename_.c_str());
	bSaveSettings = true;

	IniFile controllerIniFile;
	if (!controllerIniFile.Load(controllerIniFilename_)) {
		ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
		KeyMap::RestoreDefault();
	} else {
		// Continue anyway to initialize the config. It will just restore the defaults.
		KeyMap::LoadFromIni(controllerIniFile);
	}
	
	//so this is all the way down here to overwrite the controller settings
	//sadly it won't benefit from all the "version conversion" going on up-above
	//but these configs shouldn't contain older versions anyhow
	if (bGameSpecific)
	{
		loadGameConfig(gameId_);
	}

	CleanRecent();

#ifdef _WIN32
	iTempGPUBackend = iGPUBackend;
#endif

	// Fix Wrong MAC address by old version by "Change MAC address"
	if (sMACAddress.length() != 17)
		sMACAddress = CreateRandMAC();

	if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
		g_Config.iRenderingMode = FB_BUFFERED_MODE;
	}
}
Пример #28
0
Wearer::Wearer(DescriptionPtr dsc)
  : _equippedItems( new ActorContainer )
{
  upgrade(dsc);
  if ( _equippedItems ) assignItemsToSlots();
}
Пример #29
0
// Main
int main(int argc, char *argv[])
{
    // We must save it here because QApplication constructor may change it
    bool isOneArg = (argc == 2);

#ifdef Q_OS_MAC
    // On macOS 10.12 Sierra, Apple changed the behaviour of CFPreferencesSetValue() https://bugreports.qt.io/browse/QTBUG-56344
    // Due to this, we have to move from native plist to IniFormat
    macMigratePlists();
#endif

#ifndef DISABLE_GUI
    migrateRSS();
#endif

    // Create Application
    QString appId = QLatin1String("qBittorrent-") + Utils::Misc::getUserIDString();
    QScopedPointer<Application> app(new Application(appId, argc, argv));

    const QBtCommandLineParameters params = parseCommandLine();

    if (!params.unknownParameter.isEmpty()) {
        displayBadArgMessage(QObject::tr("%1 is an unknown command line parameter.", "--random-parameter is an unknown command line parameter.")
                             .arg(params.unknownParameter));
        return EXIT_FAILURE;
    }

#ifndef Q_OS_WIN
    if (params.showVersion) {
        if (isOneArg) {
            displayVersion();
            return EXIT_SUCCESS;
        }
        else {
            displayBadArgMessage(QObject::tr("%1 must be the single command line parameter.")
                                 .arg(QLatin1String("-v (or --version)")));
            return EXIT_FAILURE;
        }
    }
#endif

    if (params.showHelp) {
        if (isOneArg) {
            displayUsage(argv[0]);
            return EXIT_SUCCESS;
        }
        else {
            displayBadArgMessage(QObject::tr("%1 must be the single command line parameter.")
                                 .arg(QLatin1String("-h (or --help)")));
            return EXIT_FAILURE;
        }
    }

    if ((params.webUiPort > 0) && (params.webUiPort <= 65535)) {
        Preferences::instance()->setWebUiPort(params.webUiPort);
    }
    else {
        displayBadArgMessage(QObject::tr("%1 must specify the correct port (1 to 65535).")
                             .arg(QLatin1String("--webui-port")));
        return EXIT_FAILURE;
    }

    // Set environment variable
    if (!qputenv("QBITTORRENT", QBT_VERSION))
        std::cerr << "Couldn't set environment variable...\n";

#ifndef DISABLE_GUI
    if (!userAgreesWithLegalNotice())
        return EXIT_SUCCESS;
#else
    if (!params.shouldDaemonize
        && isatty(fileno(stdin))
        && isatty(fileno(stdout))
        && !userAgreesWithLegalNotice())
        return EXIT_SUCCESS;
#endif

    // Check if qBittorrent is already running for this user
    if (app->isRunning()) {
#ifdef DISABLE_GUI
        if (params.shouldDaemonize) {
            displayBadArgMessage(QObject::tr("You cannot use %1: qBittorrent is already running for this user.")
                                 .arg(QLatin1String("-d (or --daemon)")));
            return EXIT_FAILURE;
        }
        else
#endif
        qDebug("qBittorrent is already running for this user.");

        Utils::Misc::msleep(300);
        app->sendParams(params.torrents);

        return EXIT_SUCCESS;
    }

#if defined(Q_OS_WIN)
    // This affects only Windows apparently and Qt5.
    // When QNetworkAccessManager is instantiated it regularly starts polling
    // the network interfaces to see what's available and their status.
    // This polling creates jitter and high ping with wifi interfaces.
    // So here we disable it for lack of better measure.
    // It will also spew this message in the console: QObject::startTimer: Timers cannot have negative intervals
    // For more info see:
    // 1. https://github.com/qbittorrent/qBittorrent/issues/4209
    // 2. https://bugreports.qt.io/browse/QTBUG-40332
    // 3. https://bugreports.qt.io/browse/QTBUG-46015

    qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1));
#endif

#if defined(Q_OS_MAC)
{
    // Since Apple made difficult for users to set PATH, we set here for convenience.
    // Users are supposed to install Homebrew Python for search function.
    // For more info see issue #5571.
    QByteArray path = "/usr/local/bin:";
    path += qgetenv("PATH");
    qputenv("PATH", path.constData());
}
#endif

#ifndef DISABLE_GUI
    if (!upgrade()) return EXIT_FAILURE;
#else
    if (!upgrade(!params.shouldDaemonize
                 && isatty(fileno(stdin))
                 && isatty(fileno(stdout)))) return EXIT_FAILURE;
#endif

#ifdef DISABLE_GUI
    if (params.shouldDaemonize) {
        app.reset(); // Destroy current application
        if ((daemon(1, 0) == 0)) {
            app.reset(new Application(appId, argc, argv));
            if (app->isRunning()) {
                // Another instance had time to start.
                return EXIT_FAILURE;
            }
        }
        else {
            qCritical("Something went wrong while daemonizing, exiting...");
            return EXIT_FAILURE;
        }
    }
#else
    if (!params.noSplash)
        showSplashScreen();
#endif

#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN)
    signal(SIGINT, sigNormalHandler);
    signal(SIGTERM, sigNormalHandler);
    signal(SIGABRT, sigAbnormalHandler);
    signal(SIGSEGV, sigAbnormalHandler);
#endif

    return app->exec(params.torrents);
}
Пример #30
0
void DataFile::loadData( const QByteArray & _data, const QString & _sourceFile )
{
	QString errorMsg;
	int line = -1, col = -1;
	if( !setContent( _data, &errorMsg, &line, &col ) )
	{
		// parsing failed? then try to uncompress data
		QByteArray uncompressed = qUncompress( _data );
		if( !uncompressed.isEmpty() )
		{
			if( setContent( uncompressed, &errorMsg, &line, &col ) )
			{
				line = col = -1;
			}
		}
		if( line >= 0 && col >= 0 )
		{
			qWarning() << "at line" << line << "column" << errorMsg;
			if( Engine::hasGUI() )
			{
				QMessageBox::critical( NULL,
					SongEditor::tr( "Error in file" ),
					SongEditor::tr( "The file %1 seems to contain "
							"errors and therefore can't be "
							"loaded." ).
								arg( _sourceFile ) );
			}

			return;
		}
	}

	QDomElement root = documentElement();
	m_type = type( root.attribute( "type" ) );
	m_head = root.elementsByTagName( "head" ).item( 0 ).toElement();


	if( root.hasAttribute( "creatorversion" ) )
	{
		// compareType defaults to Build,so it doesn't have to be set here
		ProjectVersion createdWith = root.attribute( "creatorversion" );
		ProjectVersion openedWith = LMMS_VERSION;;

		if ( createdWith != openedWith )
		{
			// only one compareType needs to be set, and we can compare on one line because setCompareType returns ProjectVersion
			if ( createdWith.setCompareType(Minor) != openedWith)
			{
				if( Engine::hasGUI() && root.attribute( "type" ) == "song" ) //documentElement()
				{
					QMessageBox::information( NULL,
						SongEditor::tr( "Project Version Mismatch" ),
						SongEditor::tr( 
								"This project was created with "
								"LMMS version %1, but version %2 "
								"is installed")
								.arg( root.attribute( "creatorversion" ) )
								.arg( LMMS_VERSION ) );
				}
			}

			// the upgrade needs to happen after the warning as it updates the project version.
			if( createdWith.setCompareType(Build) < openedWith )
			{
				upgrade();
			}
		}
	}

	m_content = root.elementsByTagName( typeName( m_type ) ).
							item( 0 ).toElement();
}