예제 #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