Пример #1
0
        private static void CreateParticleSystemWithSubContent(ContentIconAndName content)
        {
            var particleSystem           = ContentLoader.Load <ParticleSystemData>(content.Name);
            var emitterNames             = particleSystem.MetaData.Get("EmitterNames", "emitter");
            var particleSystemSubContent = new ObservableCollection <ContentIconAndName>();

            for (int i = 0; i < emitterNames.Split(new[] { ',', ' ' }).Length; i++)
            {
                var newEmitterName = emitterNames.Split(new[] { ',', ' ' })[i];
                RemoveContentFromContentList(newEmitterName);
                if (string.IsNullOrEmpty(newEmitterName))
                {
                    continue;
                }
                particleSystemSubContent.Add(
                    new ContentIconAndName(
                        ContentIconAndName.GetContentTypeIcon(ContentType.ParticleEmitter), newEmitterName));
            }
            var contentIndex = contentList.IndexOf(content);

            contentList.RemoveAt(contentIndex);
            contentList.Insert(contentIndex,
                               new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.ParticleSystem),
                                                      content.Name, particleSystemSubContent));
        }
Пример #2
0
 private static ContentIconAndName GetAnimationSubContent(string animationName)
 {
     RemoveContentFromContentList(animationName);
     return
         (new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.MeshAnimation),
                                 animationName));
 }
Пример #3
0
 private static void TryAddSubContentAndRemoveDuplicateContent(ContentIconAndName content)
 {
     if (service.GetTypeOfContent(content.Name) == ContentType.Model)
     {
         GetModelSubContent(content);
     }
     if (service.GetTypeOfContent(content.Name) == ContentType.Mesh)
     {
         CreateMeshWithSubContent(content);
     }
     if (service.GetTypeOfContent(content.Name) == ContentType.Material)
     {
         CreateMaterialWithSubContent(content);
     }
     if (service.GetTypeOfContent(content.Name) == ContentType.ImageAnimation)
     {
         CreateImageAnimationWithSubContent(content);
     }
     if (service.GetTypeOfContent(content.Name) == ContentType.SpriteSheetAnimation)
     {
         CreateSpriteSheetWithSubContent(content);
     }
     if (service.GetTypeOfContent(content.Name) == ContentType.Font)
     {
         CreateFontWithSubContent(content);
     }
     if (service.GetTypeOfContent(content.Name) == ContentType.ParticleSystem)
     {
         CreateParticleSystemWithSubContent(content);
     }
 }
Пример #4
0
 public void Init(Service service)
 {
     DataContext             = contentManagerViewModel = new ContentManagerViewModel(service);
     service.ContentUpdated += (type, name) =>
     {
         AddContentToContentList(type, name);
         ContentLoader.RemoveResource(name);
         if (isContentReadyForUse)
         {
             Dispatcher.Invoke(
                 new Action(
                     () =>
                     contentManagerViewModel.SelectedContent =
                         new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(type), name)));
         }
     };
     service.ContentDeleted += name =>
     {
         DeleteContentFromContentList(name);
         ContentLoader.RemoveResource(name);
     };
     service.ProjectChanged += () =>
     {
         isContentReadyForUse = false;
         RefreshContentList();
     };
     service.ContentReady += () =>
     {
         Dispatcher.Invoke(new Action(contentManagerViewModel.ShowStartContent));
         isContentReadyForUse = true;
     };
     contentManagerViewModel.RefreshContentList();
 }
        private Entity2D TryCreateEntityAndSetDrawAreaPosition(ContentIconAndName content, int row,
                                                               int column)
        {
            var entity = new Sprite(content.Name, new Rectangle(0, 0, 1, 1));

            SetDrawAreaPosition(entity, row, column);
            return(entity);
        }
        public void AddNewContent(string contentName)
        {
            var contentType = service.GetTypeOfContent(contentName);
            var newContent  = new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(contentType),
                                                     contentName);

            ContentList.Add(newContent);
        }
Пример #7
0
        private static void CreateMaterialWithSubContent(ContentIconAndName content)
        {
            var materialSubContent = GetMaterialSubContent(content.Name, false);
            var contentIndex       = contentList.IndexOf(content);

            contentList.RemoveAt(contentIndex);
            contentList.Insert(contentIndex, materialSubContent);
        }
        public void AddContentToContentList(ContentType type, string name)
        {
            RemoveContentFromContentLists(name);
            var newContent = new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(type), name);

            DisplayContentList.Add(newContent);
            ContentList.Add(newContent);
            SubContentManager.AddSubContentAndRemoveDuplicateContent(DisplayContentList, service,
                                                                     newContent);
            RaisePropertyChanged("ContentList");
        }
        private bool TryLoadMaterialCreateSpriteAndSetDrawAreaPosition(ContentIconAndName content,
                                                                       int row, int column)
        {
            var material = ContentLoader.Load <Material>(content.Name);

            if ((material.Shader as ShaderWithFormat).Format.Is3D)
            {
                return(false);
            }
            var sprite = new Sprite(material, new Rectangle(0, 0, 1, 1));

            SetDrawAreaPosition(sprite, row, column);
            return(true);
        }
Пример #10
0
        private static void CreateSpriteSheetWithSubContent(ContentIconAndName content)
        {
            var spriteSheetAnimation = ContentLoader.Load <SpriteSheetAnimation>(content.Name);
            var image = spriteSheetAnimation.MetaData.Get("ImageName", "image");
            var spriteSheetSubContent = new ObservableCollection <ContentIconAndName>
            {
                new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image), image)
            };
            var contentIndex = contentList.IndexOf(content);

            contentList.RemoveAt(contentIndex);
            contentList.Insert(contentIndex,
                               new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.ImageAnimation),
                                                      content.Name, spriteSheetSubContent));
        }
Пример #11
0
        private static ContentIconAndName GetMaterialSubContent(string contentName, bool isSubContent)
        {
            if (isSubContent)
            {
                RemoveContentFromContentList(contentName);
            }
            var material           = ContentLoader.Load <Material>(contentName);
            var images             = material.MetaData.Get("ImageOrAnimationName", "image");
            var materialSubContent = new ObservableCollection <ContentIconAndName>();

            materialSubContent.Add(
                new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image), images));
            RemoveContentFromContentList(images);
            return(new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Material),
                                          contentName, materialSubContent));
        }
Пример #12
0
        private static void CreateFontWithSubContent(ContentIconAndName content)
        {
            var fontSubContent = new ObservableCollection <ContentIconAndName>
            {
                new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image),
                                       content.Name + "Font")
            };

            RemoveContentFromContentList(content.Name + "Font");
            var contentIndex = contentList.IndexOf(content);

            contentList.RemoveAt(contentIndex);
            contentList.Insert(contentIndex,
                               new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Font),
                                                      content.Name, fontSubContent));
        }
Пример #13
0
		public static void AddSubContentAndRemoveDuplicateContent(
			ObservableCollection<ContentIconAndName> setContentList, Service setService,
			ContentIconAndName content)
		{
			if (!setContentList.Contains(content))
				return;
			contentList = setContentList;
			service = setService;
			try
			{
				TryAddSubContentAndRemoveDuplicateContent(content);
			}
			catch (Exception ex)
			{
				Logger.Warning("Could not get the subcontent of " + content.Name + ": " + ex.Message);
			}
		}
Пример #14
0
		private static void GetModelSubContent(ContentIconAndName content)
		{
			var model = ContentLoader.Load<ModelData>(content.Name);
			var meshName = model.MetaData.Get("MeshNames", "mesh");
			var meshSubContent = new ObservableCollection<ContentIconAndName>();
			for (int i = 0; i < meshName.Split(new[] { ',', ' ' }).Length; i++)
			{
				var newMeshName = meshName.Split(new[] { ',', ' ' })[i];
				if (string.IsNullOrEmpty(newMeshName))
					continue;
				meshSubContent.Add(GetMeshSubContent(newMeshName, true));
			}
			var contentIndex = contentList.IndexOf(content);
			contentList.RemoveAt(contentIndex);
			contentList.Insert(contentIndex,
				new ContentIconAndName(content.Icon, content.Name, meshSubContent));
		}
Пример #15
0
		private static void TryAddSubContentAndRemoveDuplicateContent(ContentIconAndName content)
		{
			if (service.GetTypeOfContent(content.Name) == ContentType.Model)
				GetModelSubContent(content);
			if (service.GetTypeOfContent(content.Name) == ContentType.Mesh)
				CreateMeshWithSubContent(content);
			if (service.GetTypeOfContent(content.Name) == ContentType.Material)
				CreateMaterialWithSubContent(content);
			if (service.GetTypeOfContent(content.Name) == ContentType.ImageAnimation)
				CreateImageAnimationWithSubContent(content);
			if (service.GetTypeOfContent(content.Name) == ContentType.SpriteSheetAnimation)
				CreateSpriteSheetWithSubContent(content);
			if (service.GetTypeOfContent(content.Name) == ContentType.Font)
				CreateFontWithSubContent(content);
			if (service.GetTypeOfContent(content.Name) == ContentType.ParticleSystem)
				CreateParticleSystemWithSubContent(content);
		}
Пример #16
0
 public static void AddSubContentAndRemoveDuplicateContent(
     ObservableCollection <ContentIconAndName> setContentList, Service setService,
     ContentIconAndName content)
 {
     if (!setContentList.Contains(content))
     {
         return;
     }
     contentList = setContentList;
     service     = setService;
     try
     {
         TryAddSubContentAndRemoveDuplicateContent(content);
     }
     catch (Exception ex)
     {
         Logger.Warning("Could not get the subcontent of " + content.Name + ": " + ex.Message);
     }
 }
Пример #17
0
        private static ContentIconAndName GetMeshSubContent(string meshName, bool isSubContent)
        {
            if (isSubContent)
            {
                RemoveContentFromContentList(meshName);
            }
            var mesh             = ContentLoader.Load <Mesh>(meshName);
            var aditionalContent = new ObservableCollection <ContentIconAndName>();
            var geometryName     = mesh.MetaData.Get("GeometryName", "geometry");

            aditionalContent.Add(GetGeometrySubContent(geometryName));
            var animationName = mesh.MetaData.Get("AnimationName", "animation");

            aditionalContent.Add(GetAnimationSubContent(animationName));
            var meshSubContent = new ObservableCollection <ContentIconAndName>();
            var materialName   = mesh.MetaData.Get("MaterialName", "material");

            meshSubContent.Add(GetMaterialSubContent(materialName, true));
            return(new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Mesh),
                                          meshName, meshSubContent, aditionalContent));
        }
Пример #18
0
        private static void GetModelSubContent(ContentIconAndName content)
        {
            var model          = ContentLoader.Load <ModelData>(content.Name);
            var meshName       = model.MetaData.Get("MeshNames", "mesh");
            var meshSubContent = new ObservableCollection <ContentIconAndName>();

            for (int i = 0; i < meshName.Split(new[] { ',', ' ' }).Length; i++)
            {
                var newMeshName = meshName.Split(new[] { ',', ' ' })[i];
                if (string.IsNullOrEmpty(newMeshName))
                {
                    continue;
                }
                meshSubContent.Add(GetMeshSubContent(newMeshName, true));
            }
            var contentIndex = contentList.IndexOf(content);

            contentList.RemoveAt(contentIndex);
            contentList.Insert(contentIndex,
                               new ContentIconAndName(content.Icon, content.Name, meshSubContent));
        }
Пример #19
0
        private static void CreateImageAnimationWithSubContent(ContentIconAndName content)
        {
            var imageAnimation           = ContentLoader.Load <ImageAnimation>(content.Name);
            var images                   = imageAnimation.MetaData.Get("ImageNames", "image");
            var imageAnimationSubContent = new ObservableCollection <ContentIconAndName>();

            for (int i = 0; i < images.Split(new[] { ',', ' ' }).Length; i++)
            {
                var newMeshName = images.Split(new[] { ',', ' ' })[i];
                if (string.IsNullOrEmpty(newMeshName))
                {
                    continue;
                }
                imageAnimationSubContent.Add(
                    new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image),
                                           newMeshName));
            }
            var contentIndex = contentList.IndexOf(content);

            contentList.RemoveAt(contentIndex);
            contentList.Insert(contentIndex,
                               new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.ImageAnimation),
                                                      content.Name, imageAnimationSubContent));
        }
Пример #20
0
		private static void CreateImageAnimationWithSubContent(ContentIconAndName content)
		{
			var imageAnimation = ContentLoader.Load<ImageAnimation>(content.Name);
			var images = imageAnimation.MetaData.Get("ImageNames", "image");
			var imageAnimationSubContent = new ObservableCollection<ContentIconAndName>();
			for (int i = 0; i < images.Split(new[] { ',', ' ' }).Length; i++)
			{
				var newMeshName = images.Split(new[] { ',', ' ' })[i];
				if (string.IsNullOrEmpty(newMeshName))
					continue;
				imageAnimationSubContent.Add(
					new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image),
						newMeshName));
			}
			var contentIndex = contentList.IndexOf(content);
			contentList.RemoveAt(contentIndex);
			contentList.Insert(contentIndex,
				new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.ImageAnimation),
					content.Name, imageAnimationSubContent));
		}
Пример #21
0
		private static void CreateMaterialWithSubContent(ContentIconAndName content)
		{
			var materialSubContent = GetMaterialSubContent(content.Name, false);
			var contentIndex = contentList.IndexOf(content);
			contentList.RemoveAt(contentIndex);
			contentList.Insert(contentIndex, materialSubContent);
		}
Пример #22
0
 private static ContentIconAndName GetGeometrySubContent(string geometryName)
 {
     RemoveContentFromContentList(geometryName);
     return(new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Geometry),
                                   geometryName));
 }
Пример #23
0
		private static void CreateParticleSystemWithSubContent(ContentIconAndName content)
		{
			var particleSystem = ContentLoader.Load<ParticleSystemData>(content.Name);
			var emitterNames = particleSystem.MetaData.Get("EmitterNames", "emitter");
			var particleSystemSubContent = new ObservableCollection<ContentIconAndName>();
			for (int i = 0; i < emitterNames.Split(new[] { ',', ' ' }).Length; i++)
			{
				var newEmitterName = emitterNames.Split(new[] { ',', ' ' })[i];
				RemoveContentFromContentList(newEmitterName);
				if (string.IsNullOrEmpty(newEmitterName))
					continue;
				particleSystemSubContent.Add(
					new ContentIconAndName(
						ContentIconAndName.GetContentTypeIcon(ContentType.ParticleEmitter), newEmitterName));
			}
			var contentIndex = contentList.IndexOf(content);
			contentList.RemoveAt(contentIndex);
			contentList.Insert(contentIndex,
				new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.ParticleSystem),
					content.Name, particleSystemSubContent));
		}
Пример #24
0
		private Entity2D TryCreateEntityAndSetDrawAreaPosition(ContentIconAndName content, int row,
			int column)
		{
			var entity = new Sprite(content.Name, new Rectangle(0, 0, 1, 1));
			SetDrawAreaPosition(entity, row, column);
			return entity;
		}
		private void SelectContentInContentManager(ContentIconAndName content)
		{
			var type = service.GetTypeOfContent(content.Name);
			if (type == ContentType.ImageAnimation)
			{
				var newAnimation = ContentLoader.Load<ImageAnimation>(content.Name);
				AnimationName = content.Name;
				var imageNames = newAnimation.MetaData.Get("ImageNames", "").SplitAndTrim(',');
				ImageList.Clear();
				foreach (var imageName in imageNames)
					ImageList.Add(imageName);
				Duration = float.Parse(newAnimation.MetaData.Get("DefaultDuration", ""));
			}
			if (type == ContentType.SpriteSheetAnimation)
			{
				var spritesheet = ContentLoader.Load<SpriteSheetAnimation>(content.Name);
				AnimationName = content.Name;
				var imageNames = spritesheet.MetaData.Get("ImageName", "").SplitAndTrim(',');
				ImageList.Clear();
				foreach (var imageName in imageNames)
					ImageList.Add(imageName);
				Duration = float.Parse(animation.MetaData.Get("DefaultDuration", ""));
				SubImageSize = spritesheet.MetaData.Get("SubImageSize", Size.Zero);
			}
		}
Пример #26
0
		private bool TryLoadMaterialCreateSpriteAndSetDrawAreaPosition(ContentIconAndName content,
			int row, int column)
		{
			var material = ContentLoader.Load<Material>(content.Name);
			if ((material.Shader as ShaderWithFormat).Format.Is3D)
				return false;
			var sprite = new Sprite(material, new Rectangle(0, 0, 1, 1));
			SetDrawAreaPosition(sprite, row, column);
			return true;
		}
Пример #27
0
		private static void CreateSpriteSheetWithSubContent(ContentIconAndName content)
		{
			var spriteSheetAnimation = ContentLoader.Load<SpriteSheetAnimation>(content.Name);
			var image = spriteSheetAnimation.MetaData.Get("ImageName", "image");
			var spriteSheetSubContent = new ObservableCollection<ContentIconAndName>
			{
				new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image), image)
			};
			var contentIndex = contentList.IndexOf(content);
			contentList.RemoveAt(contentIndex);
			contentList.Insert(contentIndex,
				new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.ImageAnimation),
					content.Name, spriteSheetSubContent));
		}
Пример #28
0
		private static void CreateFontWithSubContent(ContentIconAndName content)
		{
			var fontSubContent = new ObservableCollection<ContentIconAndName>
			{
				new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Image),
					content.Name + "Font")
			};
			RemoveContentFromContentList(content.Name + "Font");
			var contentIndex = contentList.IndexOf(content);
			contentList.RemoveAt(contentIndex);
			contentList.Insert(contentIndex,
				new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(ContentType.Font),
					content.Name, fontSubContent));
		}
Пример #29
0
		public void AddNewContent(string contentName)
		{
			var contentType = service.GetTypeOfContent(contentName);
			var newContent = new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(contentType),
				contentName);
			ContentList.Add(newContent);
		}
Пример #30
0
		private void SelectContentInContentManager(ContentIconAndName content)
		{
			var type = service.GetTypeOfContent(content.Name);
			if (type == ContentType.ParticleSystem)
			{
				particleSystemName = content.Name;
				LoadEffect();
			}
		}
Пример #31
0
		public void AddContentToContentList(ContentType type, string name)
		{
			RemoveContentFromContentLists(name);
			var newContent = new ContentIconAndName(ContentIconAndName.GetContentTypeIcon(type), name);
			DisplayContentList.Add(newContent);
			ContentList.Add(newContent);
			SubContentManager.AddSubContentAndRemoveDuplicateContent(DisplayContentList, service,
				newContent);
			RaisePropertyChanged("ContentList");
		}
Пример #32
0
		private void SelectContentInContentManager(ContentIconAndName content)
		{
			if (content.GetContentType() != ContentType.Material)
				return;
			var material = ContentLoader.Load<Material>(content.Name);
			MaterialName = content.Name;
			SelectedImage = material.DiffuseMap.Name;
			SelectedBlendMode =
				material.DiffuseMap.MetaData.Get("BlendMode", BlendMode.Normal).ToString();
			SelectedRenderSize = material.RenderSizeMode.ToString();
			foreach (var color in colorList.Where(color => color.Value == material.DefaultColor))
				SelectedColor = color.Key;
			SelectedShader = material.MetaData.Get("ShaderFlags", ShaderFlags.ColoredTextured);
		}
Пример #33
0
		//ncrunch: no coverage start
		private void SelectContentInContentManager(ContentIconAndName content)
		{
			var type = service.GetTypeOfContent(content.Name);
			if (type != ContentType.Scene)
				return;
			UIName = content.Name;
			LoadScene();
		}//ncrunch: no coverage end