Beispiel #1
0
float obj_ParticleSystem::DrawPropertyEditor(float scrx, float scry, float scrw, float scrh, const AClass* startClass, const GameObjects& selected)
{
	float starty = scry;

	starty += parent::DrawPropertyEditor(scrx, scry, scrw, scrh, startClass, selected );

	if( IsParentOrEqual( &ClassData, startClass ) )
	{
		int temp = m_isSerializable?1:0;
		starty += imgui_Checkbox(scrx, starty, "Serializable", &temp, 1);
		bool btemp = temp?true:false;

		PropagateChange( btemp, &obj_ParticleSystem::m_isSerializable, this, selected ) ;

		temp = DoFreese ? 1 : 0;
		static float freeseTimeOffset = 0;
		starty += imgui_Value_Slider(scrx, starty, "Pause time", &freeseTimeOffset, 0.0f, Torch->PD->EmitTime, "%.2f");
		starty += imgui_Checkbox(scrx, starty, "Pause", &temp, 1);
		if (!!temp != DoFreese)
		{
			float freeseTime = r3dGetTime() + freeseTimeOffset;
			bool doFreese = !!temp;
			if (doFreese)
			{
				Restart();
				//	Advance to particle pause position
				while (UpdateTime < freeseTime)
				{
					Update();
				}
			}
			DoFreese = doFreese;
		}

		if( selected.Count() <= 1 )
		{
			void ParticleEditorSetDefaultParticle ( const char * );
			ParticleEditorSetDefaultParticle ( Name.c_str() );

			if ( imgui_Button ( scrx,starty, 180.0f, 25.0f, "Edit Particle" ) )
			{
				void ParticleEditorSetDefaultParticle ( const char * );
				void SetHud ( int );

				ParticleEditorSetDefaultParticle ( Name.c_str() );
				SetHud ( 3 );
			}
		}

		starty += 25.0f;
	}
	return starty-scry;
}
Beispiel #2
0
void GameScene::ScheduleLoad(std::shared_ptr<Loader> loader)
{
	auto rulebook = rules->GetRulebook();

	loader->AddLoader("Track and players", [=]{
		// Load the selected track
		std::shared_ptr<Model::Track> track;

		auto entry = this->rules->GetTrackEntry();
		if (!entry) throw Parcel::ObjStreamExn("Track does not exist.");
		track = Config::GetInstance()->GetTrackBundle().OpenTrack(entry);
		if (!track) throw Parcel::ObjStreamExn(
			"Track does not exist: " + entry->name);
		if (!session->LoadNew(entry->name.c_str(), scripting,
			track, &display.GetLegacyDisplay()))
		{
			throw Parcel::ObjStreamExn("Track load failed.");
		}

		// This must be done after the track has loaded.
		const auto maxPlayers = rules->GetRulebook()->GetMaxPlayers();
		int i = 0;
		std::vector<std::shared_ptr<Player::Player>> localHumans;
		director.GetParty()->ForEach([&](std::shared_ptr<Player::Player> &p) {
			if (p->IsCompeting() && i < maxPlayers) {
				session->AttachPlayer(i, p);
				i++;

				if (p->IsLocal() && p->IsHuman()) {
					localHumans.emplace_back(p);
				}
			}
		});

		// Split-screen with multiple viewports.
		// The bounds of each viewport will be set in LayoutViewports().
		for (auto &player : localHumans) {
			viewports.emplace_back(
				display,
				player,
				new Observer(),
				new Display::Hud(display,
					player, track,
					Display::UiLayoutFlags::FLOATING));
		}
	});

	loader->AddLoader("Session", [=]{
		metaSession = rulebook->GetMetas().session(
			std::make_shared<SessionPeer>(*scripting, session));
		metaSession->OnInit();
		session->SetMeta(metaSession);

		director.GetSessionChangedSignal()(metaSession);

		session->AdvancePhase(ClientSession::Phase::PREGAME);

		auto sessionPeer = metaSession->GetSession();
		sessionPeer->ForEachPlayer([&](std::shared_ptr<MetaPlayer> &player) {
			auto playerPeer = player->GetPlayer();

			// Look up the correct HUD for this player.
			for (auto &viewport : viewports) {
				if (viewport.player.get() == playerPeer->GetPlayer()) {
					playerPeer->SetHud(
						std::make_shared<HudPeer>(*scripting, display,
							viewport.hud));
					break;
				}
			}

			// Get notified when each player finishes.
			auto mainChar = player->GetPlayer()->GetPlayer()->GetMainCharacter();
			mainChar->GetFinishedSignal().connect(
				std::bind(&GameScene::OnRaceFinish, this));

			player->OnJoined(metaSession);
		});
	});
}