Пример #1
0
/// Constructor
TUIFileBrowserButton::TUIFileBrowserButton(int id, int type, QWidget *w, int parent, QString name)
    : TUIElement(id, type, w, parent, name)
{
    QPushButton *b = new QPushButton(w);
    if (name.contains("."))
    {
        QPixmap pm(name);
        if (pm.isNull())
        {
            QString covisedir = QString(getenv("COVISEDIR"));
            QPixmap pm(covisedir + "/" + name);
            if (pm.isNull())
            {
                b->setText(name);
            }
            else
            {
                b->setIcon(pm);
            }
        }
        else
        {
            b->setIcon(pm);
        }
    }
    else
        b->setText(name);

    //b->setFixedSize(b->sizeHint());
    //std::cerr << "Creating new Filebrowser instance!" << std::endl;
    this->mFileBrowser = new FileBrowser(this, 0, id);
    connect(this, SIGNAL(dirUpdate(QStringList)), this->mFileBrowser, SLOT(handleDirUpdate(QStringList)));
    connect(this, SIGNAL(fileUpdate(QStringList)), this->mFileBrowser, SLOT(handleFileUpdate(QStringList)));
    connect(this, SIGNAL(clientUpdate(QStringList)), this->mFileBrowser, SLOT(handleClientUpdate(QStringList)));
    /*connect(this,SIGNAL(filterUpdate(QStringList)),this->mFileBrowser, SLOT(handleFilterUpdate(QStringList)));*/
    connect(this, SIGNAL(curDirUpdate(QString)), this->mFileBrowser, SLOT(handleCurDirUpdate(QString)));
    connect(this, SIGNAL(driveUpdate(QStringList)), this->mFileBrowser, SLOT(handleDriveUpdate(QStringList)));
    connect(this, SIGNAL(updateMode(int)), this->mFileBrowser, SLOT(handleUpdateMode(int)));
    connect(this, SIGNAL(updateFilterList(char *)), this->mFileBrowser, SLOT(handleUpdateFilterList(char *)));
    connect(this, SIGNAL(locationUpdate(QString)), this->mFileBrowser, SLOT(handleLocationUpdate(QString)));
    connect(this, SIGNAL(updateRemoteButtonState(int)), this->mFileBrowser, SLOT(handleupdateRemoteButtonState(int)));
    connect(this, SIGNAL(updateLoadCheckBox(bool)), this->mFileBrowser, SLOT(handleUpdateLoadCheckBox(bool)));

    mFileBrowser->setWindowTitle("TabletUI VRML - Remote File Browser");

    widget = b;

    connect(b, SIGNAL(pressed()), this, SLOT(onPressed()));
}
Пример #2
0
static void gameStateUpdate()
{
	// Can't dump isHumanPlayer, since it causes spurious desynch dumps when players leave.
	// TODO isHumanPlayer should probably be synchronised, since the game state seems to depend on it, so there might also be a risk of real desynchs when players leave.
	//syncDebug("map = \"%s\", humanPlayers = %d %d %d %d %d %d %d %d", game.map, isHumanPlayer(0), isHumanPlayer(1), isHumanPlayer(2), isHumanPlayer(3), isHumanPlayer(4), isHumanPlayer(5), isHumanPlayer(6), isHumanPlayer(7));
	syncDebug("map = \"%s\"", game.map);

	// Actually send pending droid orders.
	sendQueuedDroidInfo();

	sendPlayerGameTime();
	gameSRand(gameTime);   // Brute force way of synchronising the random number generator, which can't go out of synch.

	if (!paused && !scriptPaused() && !editPaused())
	{
		/* Update the event system */
		if (!bInTutorial)
		{
			eventProcessTriggers(gameTime/SCR_TICKRATE);
		}
		else
		{
			eventProcessTriggers(realTime/SCR_TICKRATE);
		}
		updateScripts();
	}

	// Update abandoned structures
	handleAbandonedStructures();

	// Update the visibility change stuff
	visUpdateLevel();

	// Put all droids/structures/features into the grid.
	gridReset();

	// Check which objects are visible.
	processVisibility();

	// Update the map.
	mapUpdate();

	//update the findpath system
	fpathUpdate();

	// update the cluster system
	clusterUpdate();

	// update the command droids
	cmdDroidUpdate();
	if(getDrivingStatus())
	{
		driveUpdate();
	}

	fireWaitingCallbacks(); //Now is the good time to fire waiting callbacks (since interpreter is off now)

	for (unsigned i = 0; i < MAX_PLAYERS; i++)
	{
		//update the current power available for a player
		updatePlayerPower(i);

		//set the flag for each player
		setHQExists(false, i);
		setSatUplinkExists(false, i);

		numCommandDroids[i] = 0;
		numConstructorDroids[i] = 0;
		numDroids[i]=0;
		numTransporterDroids[i]=0;

		DROID *psNext;
		for (DROID *psCurr = apsDroidLists[i]; psCurr != NULL; psCurr = psNext)
		{
			// Copy the next pointer - not 100% sure if the droid could get destroyed but this covers us anyway
			psNext = psCurr->psNext;
			droidUpdate(psCurr);

			// update the droid counts
			numDroids[i]++;
			switch (psCurr->droidType)
			{
				case DROID_COMMAND:
					numCommandDroids[i] += 1;
					break;
				case DROID_CONSTRUCT:
				case DROID_CYBORG_CONSTRUCT:
					numConstructorDroids[i] += 1;
					break;
				case DROID_TRANSPORTER:
					if( (psCurr->psGroup != NULL) )
					{
						DROID *psDroid = NULL;

						numTransporterDroids[i] += psCurr->psGroup->refCount-1;
						// and count the units inside it...
							for (psDroid = psCurr->psGroup->psList; psDroid != NULL && psDroid != psCurr; psDroid = psDroid->psGrpNext)
							{
							if (psDroid->droidType == DROID_CYBORG_CONSTRUCT || psDroid->droidType == DROID_CONSTRUCT)
								{
									numConstructorDroids[i] += 1;
								}
							if (psDroid->droidType == DROID_COMMAND)
							{
								numCommandDroids[i] += 1;
							}
						}
					}
					break;
				default:
					break;
			}
		}

		numMissionDroids[i]=0;
		for (DROID *psCurr = mission.apsDroidLists[i]; psCurr != NULL; psCurr = psNext)
		{
			/* Copy the next pointer - not 100% sure if the droid could
			get destroyed but this covers us anyway */
			psNext = psCurr->psNext;
			missionDroidUpdate(psCurr);
			numMissionDroids[i]++;
			switch (psCurr->droidType)
			{
				case DROID_COMMAND:
					numCommandDroids[i] += 1;
					break;
				case DROID_CONSTRUCT:
				case DROID_CYBORG_CONSTRUCT:
					numConstructorDroids[i] += 1;
					break;
				case DROID_TRANSPORTER:
					if( (psCurr->psGroup != NULL) )
					{
						numTransporterDroids[i] += psCurr->psGroup->refCount-1;
					}
					break;
				default:
					break;
			}
		}
		for (DROID *psCurr = apsLimboDroids[i]; psCurr != NULL; psCurr = psNext)
		{
			/* Copy the next pointer - not 100% sure if the droid could
			get destroyed but this covers us anyway */
			psNext = psCurr->psNext;

			// count the type of units
			switch (psCurr->droidType)
			{
				case DROID_COMMAND:
					numCommandDroids[i] += 1;
					break;
				case DROID_CONSTRUCT:
				case DROID_CYBORG_CONSTRUCT:
					numConstructorDroids[i] += 1;
					break;
				default:
					break;
			}
		}

		// FIXME: These for-loops are code duplicationo
		/*set this up AFTER droidUpdate so that if trying to building a
		new one, we know whether one exists already*/
		setLasSatExists(false, i);
		STRUCTURE *psNBuilding;
		for (STRUCTURE *psCBuilding = apsStructLists[i]; psCBuilding != NULL; psCBuilding = psNBuilding)
		{
			/* Copy the next pointer - not 100% sure if the structure could get destroyed but this covers us anyway */
			psNBuilding = psCBuilding->psNext;
			structureUpdate(psCBuilding, false);
			//set animation flag
			if (psCBuilding->pStructureType->type == REF_HQ &&
				psCBuilding->status == SS_BUILT)
			{
				setHQExists(true, i);
			}
			if (psCBuilding->pStructureType->type == REF_SAT_UPLINK &&
				psCBuilding->status == SS_BUILT)
			{
				setSatUplinkExists(true, i);
			}
			//don't wait for the Las Sat to be built - can't build another if one is partially built
			if (asWeaponStats[psCBuilding->asWeaps[0].nStat].
				weaponSubClass == WSC_LAS_SAT)
			{
				setLasSatExists(true, i);
			}
		}
		for (STRUCTURE *psCBuilding = mission.apsStructLists[i]; psCBuilding != NULL; psCBuilding = psNBuilding)
		{
			/* Copy the next pointer - not 100% sure if the structure could get destroyed but this covers us anyway. It shouldn't do since its not even on the map!*/
			psNBuilding = psCBuilding->psNext;
			structureUpdate(psCBuilding, true); // update for mission
			if (psCBuilding->pStructureType->type == REF_HQ &&
				psCBuilding->status == SS_BUILT)
			{
				setHQExists(true, i);
			}
			if (psCBuilding->pStructureType->type == REF_SAT_UPLINK &&
				psCBuilding->status == SS_BUILT)
			{
				setSatUplinkExists(true, i);
			}
			//don't wait for the Las Sat to be built - can't build another if one is partially built
			if (asWeaponStats[psCBuilding->asWeaps[0].nStat].
				weaponSubClass == WSC_LAS_SAT)
			{
				setLasSatExists(true, i);
			}
		}
	}

	missionTimerUpdate();

	proj_UpdateAll();

	FEATURE *psNFeat;
	for (FEATURE *psCFeat = apsFeatureLists[0]; psCFeat; psCFeat = psNFeat)
	{
		psNFeat = psCFeat->psNext;
		featureUpdate(psCFeat);
	}

	objmemUpdate();

	// Do completely useless stuff.
	if (!isInSync())
	{
		sendCheck();  // send some pointless checking info if we're doomed anyway
	}


	// Must end update, since we may or may not have ticked, and some message queue processing code may vary depending on whether it's in an update.
	gameTimeUpdateEnd();
}