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;
}
Exemple #2
0
float obj_Building::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 ) )	
	{
		starty += imgui_Static(scrx, starty, "Building properties");

		std::string sDir = FileName.c_str();
		int iPos1 = sDir.find_last_of('\\');
		int iPos2 = sDir.find_last_of('/');

		if ( ( iPos1 < iPos2 && iPos2 != std::string::npos ) || ( iPos1 == std::string::npos ) )
			iPos1 = iPos2;

		if ( iPos1 != std::string::npos )
			sDir.erase(iPos1 + 1,sDir.length() - iPos1 - 1 );

		std::string sDirFind = sDir + "*.sco";

		if(m_Animation.pSkeleton && MeshLOD[0]->IsSkeletal() )
		{
			int useAnim = m_bAnimated;
			starty += imgui_Checkbox(scrx, starty, "Animated", &m_bAnimated, 1);
			if(useAnim != m_bAnimated)
			{
				PropagateChange( &obj_Building::ChangeAnim, selected ) ;
			}

			if(m_bAnimated)
			{
				int check = m_bGlobalAnimFolder ;
				starty += imgui_Checkbox(scrx, starty, "Global Anim Folder", &check, 1);

				PropagateChange( 1, &obj_Building::m_bAnimated, selected ) ;
				PropagateChange( check, &obj_Building::m_bGlobalAnimFolder, this, selected ) ;
				
				static char sAnimSelected[256] = {0};
				static float fAnimListOffset = 0;

				std::string sDirFind ;

				if( m_bGlobalAnimFolder )
				{
					// try global animation folder
					sDirFind = GLOBAL_ANIM_FOLDER "\\*.anm" ;				
				}
				else
				{
					sDirFind = sDir + "Animations\\*.anm";
				}

				r3dscpy(sAnimSelected, m_sAnimName);
				if ( imgui_FileList (scrx, starty, 360, 200, sDirFind.c_str (), sAnimSelected, &fAnimListOffset, true ) )
				{
					r3dscpy(m_sAnimName, sAnimSelected);
					PropagateChange( &obj_Building::ChangeAnim, selected ) ;
				}
				starty += 200;
			}
		}

		if( m_HitPoints > 0 )
		{
			if ( imgui_Button ( scrx, starty, 360, 20, "Destroy" ) )
			{
				PropagateChange( &obj_Building::DestroyBuilding, selected ) ;
			}
		}
		else
		{
			if ( imgui_Button ( scrx, starty, 360, 20, "Ressurect" ) )
			{
				PropagateChange( &obj_Building::FixBuilding, selected ) ;
			}
		}

		starty += 22.f ;

		if( selected.Count() <= 1 )
		{
			if ( imgui_Button ( scrx, starty, 360, 20, m_pDamageLibEntry ? "To Destruction Params" : "Create Destruction Params" ) )
			{
				LevelEditor.ToDamageLib( GetMeshLibKey().c_str() );
			}
		}

		starty += 22.0f;
	}
	return starty - scry ;
}
float obj_ItemSpawnPoint::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 ) )
	{		
		starty += imgui_Static ( scrx, starty, "Item Spawn Point Parameters" );
		starty += imgui_Value_Slider(scrx, starty, "Tick Period (sec)", &m_TickPeriod, 1.0f, 50000.0f, "%.2f");
		starty += imgui_Value_Slider(scrx, starty, "Cooldown (sec)", &m_Cooldown, 1.0f, 50000.0f, "%.2f");
		starty += imgui_Value_Slider(scrx, starty, "De-spawn (sec)", &m_DestroyItemTimer, 0.0f, 50000.0f, "%.2f");
		int isOneItemSpawn = m_OneItemSpawn?1:0;
		starty += imgui_Checkbox(scrx, starty, "One Item Spawn", &isOneItemSpawn, 1);
		m_OneItemSpawn = isOneItemSpawn?true:false;
		
		if(!m_OneItemSpawn)
		{
			static stringlist_t lootBoxNames;
			static int* lootBoxIDs = NULL;
			static int numLootBoxes = 0;
			if(numLootBoxes == 0)
			{
				struct tempS
				{
					char* name;
					uint32_t id;
				};
				std::vector<tempS> lootBoxes;
				{
					tempS holder;
					holder.name = "EMPTY";
					holder.id = 0;
					lootBoxes.push_back(holder);		
				}

				g_pWeaponArmory->startItemSearch();
				while(g_pWeaponArmory->searchNextItem())
				{
					uint32_t itemID = g_pWeaponArmory->getCurrentSearchItemID();
					const BaseItemConfig* cfg = g_pWeaponArmory->getConfig(itemID);
					if( cfg->category == storecat_LootBox )
					{
						tempS holder;
						holder.name = cfg->m_StoreName;
						holder.id = cfg->m_itemID;
						lootBoxes.push_back(holder);						 
					}
				}
				numLootBoxes = (int)lootBoxes.size();
				lootBoxIDs = new int[numLootBoxes];
				for(int i=0; i<numLootBoxes; ++i)
				{
					lootBoxNames.push_back(lootBoxes[i].name);
					lootBoxIDs[i] = lootBoxes[i].id;
				}
			}

			int sel = 0;
			static float offset = 0;
			for(int i=0; i<numLootBoxes; ++i)
				if(m_LootBoxID == lootBoxIDs[i])
					sel = i;
			starty += imgui_Static ( scrx, starty, "Loot box:" );
			if(imgui_DrawList(scrx, starty, 360, 122, lootBoxNames, &offset, &sel))
			{
				m_LootBoxID = lootBoxIDs[sel];
				PropagateChange( m_LootBoxID, &obj_ItemSpawnPoint::m_LootBoxID, this, selected ) ;
			}
			starty += 122;
		}
		else
		{
			starty += imgui_Value_SliderI(scrx, starty, "ItemID", (int*)&m_LootBoxID, 0, 1000000, "%d", false);
			PropagateChange( m_LootBoxID, &obj_ItemSpawnPoint::m_LootBoxID, this, selected ) ;
		}
		
		// don't allow multi edit of this
		if( selected.Count() <= 1 )
		{
			{
				if(imgui_Button(scrx, starty, 200, 25, "Check locations"))
				{
					for(ITEM_SPAWN_POINT_VECTOR::iterator it=m_SpawnPointsV.begin(); it!=m_SpawnPointsV.end(); ++it)
					{
						PxVec3 from(it->pos.x, it->pos.y+1.0f, it->pos.z);
						PxRaycastHit hit;
						PxSceneQueryFilterData filter(PxFilterData(COLLIDABLE_STATIC_MASK,0,0,0), PxSceneQueryFilterFlags(PxSceneQueryFilterFlag::eSTATIC));
						if(g_pPhysicsWorld->raycastSingle(from, PxVec3(0,-1,0), 10000, PxSceneQueryFlags(PxSceneQueryFlag::eIMPACT), hit, filter))
						{
							r3dPoint3D hitPos(hit.impact.x, hit.impact.y, hit.impact.z);
							if(R3D_ABS(it->pos.y - hitPos.y) > 2.0f)
							{
								gCam = it->pos + r3dPoint3D(0,1,0);
								break;
							}
						}
					}
				}
				starty += 30;
			}

			if(imgui_Button(scrx+110, starty, 100, 25, "Add Location"))
			{
				ItemSpawn itemSpawn;
				itemSpawn.pos = GetPosition() + r3dPoint3D(2, 0, 2);
				m_SpawnPointsV.push_back(itemSpawn);
				m_SelectedSpawnPoint = m_SpawnPointsV.size()-1;
			}

			starty += 25;

			int i=0;
			for(ITEM_SPAWN_POINT_VECTOR::iterator it=m_SpawnPointsV.begin(); it!=m_SpawnPointsV.end(); )
			{
				// selection button
				char tempStr[32];
				sprintf(tempStr, "Location %d", i+1);
				if(imgui_Button(scrx, starty, 100, 25, tempStr, i==m_SelectedSpawnPoint))
				{
					// shift click on location will set camera to it
					if(Keyboard->IsPressed(kbsLeftShift))
					{
						extern BaseHUD* HudArray[6];
						extern int CurHUDID;
						HudArray[CurHUDID]->FPS_Position = m_SpawnPointsV[i].pos;
						HudArray[CurHUDID]->FPS_Position.y += 0.1f;
					}
					
					m_SelectedSpawnPoint = i;
				}

				// delete button
				if(m_SpawnPointsV.size() > 1)
				{
					if(imgui_Button(scrx + 110, starty, 100, 25, "DEL"))
					{
						it = m_SpawnPointsV.erase(it);
						continue;
					}
					m_SelectedSpawnPoint = R3D_CLAMP(m_SelectedSpawnPoint, 0, (int)m_SpawnPointsV.size()-1);
				}

				starty += 25;

				++it;
				++i;
			}

			extern r3dPoint3D UI_TargetPos;
			if((Mouse->IsPressed(r3dMouse::mLeftButton)) && Keyboard->IsPressed(kbsLeftControl))
				m_SpawnPointsV[m_SelectedSpawnPoint].pos = UI_TargetPos;

		}
	}

	return starty-scry;
}