/*
* EditorUtil.cs
* Authors:
* Copyright (c) 2007-2008 Cornell University
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;
namespace TACParticleEngine
{
///
/// Provides information for the particle editors texture type converter
///
public static class EditorUtil
{
///
/// Returns an array of texture file names from the current minigame's texture directory
///
/// An array of texture file names from the current minigame's texture directory
public static string[] GetParticleTextures()
{
int start = 0;
int length = System.IO.Directory.GetCurrentDirectory().LastIndexOf("Content");
if (length > 0)
{
System.IO.Directory.SetCurrentDirectory(System.IO.Directory.GetCurrentDirectory().Substring(start, length));
}
string[] textures = System.IO.Directory.GetFiles(@"Content\\Textures");
List result = new List();
foreach (string file in textures)
{
if (file.EndsWith(".xnb"))
{
start = file.LastIndexOf("\\") + 1;
length = file.LastIndexOf(".") - start;
result.Add(@"Textures\" + file.Substring(start, length));
}
}
return result.ToArray();
}
}
///
/// Provides type converters for use in the particle editor form
///
public class TypeConverterTexture : TypeConverter
{
///
/// Whether or not standard values collections are supported
///
/// The type descriptor's context
/// True
public override bool GetStandardValuesSupported(
ITypeDescriptorContext context)
{
return true;
}
///
/// Overwriting of the standard values collection for textures in the particle editor
///
/// The type descriptor's context
/// An array of texture file names from the current minigame's texture directory
public override StandardValuesCollection
GetStandardValues(ITypeDescriptorContext context)
{
return new StandardValuesCollection(EditorUtil.GetParticleTextures());
}
}
}