Begin to implement ProjectTypeVariables

This commit is contained in:
Michael Becker 2014-12-26 00:03:08 -05:00
parent 0306364bb6
commit c72ecdbde0
4 changed files with 122 additions and 8 deletions

View File

@ -89,7 +89,56 @@ namespace UniversalEditor.UserInterface.WindowsForms.Dialogs
return;
}
mvarSelectedItem = (lvProjectTemplates.SelectedItems[0].Data as Template);
ProjectTemplate template = (lvProjectTemplates.SelectedItems[0].Data as ProjectTemplate);
if (template.ProjectType.Variables.Count > 0)
{
CustomOption.CustomOptionCollection coll = new CustomOption.CustomOptionCollection();
foreach (ProjectTypeVariable ptv in template.ProjectType.Variables)
{
switch (ptv.Type)
{
case ProjectTypeVariableType.Choice:
{
List<CustomOptionFieldChoice> choices = new List<CustomOptionFieldChoice>();
foreach (KeyValuePair<string, object> kvp in ptv.ValidValues)
{
choices.Add(new CustomOptionFieldChoice(kvp.Key, kvp.Value, kvp.Value == ptv.DefaultValue));
}
CustomOptionChoice co = new CustomOptionChoice(ptv.Name, ptv.Title, true, choices.ToArray());
coll.Add(co);
break;
}
case ProjectTypeVariableType.FileOpen:
{
CustomOptionFile co = new CustomOptionFile(ptv.Name, ptv.Title);
co.DialogMode = CustomOptionFileDialogMode.Open;
coll.Add(co);
break;
}
case ProjectTypeVariableType.FileSave:
{
CustomOptionFile co = new CustomOptionFile(ptv.Name, ptv.Title);
co.DialogMode = CustomOptionFileDialogMode.Save;
coll.Add(co);
break;
}
}
}
if (!Engine.CurrentEngine.ShowCustomOptionDialog(ref coll, template.ProjectType.Title + " properties"))
{
return;
}
foreach (CustomOption co in coll)
{
// template.ProjectType.Variables[co.PropertyName].Value = co.GetValue().ToString();
// TODO: Figure out how to assign variable values to the newly
// created project from the template
}
}
mvarSelectedItem = template;
break;
}
}

View File

@ -444,6 +444,69 @@ namespace UniversalEditor.DataFormats.UEPackage
}
}
#endregion
#region Variables
{
MarkupTagElement tagVariables = (tagProjectType.Elements["Variables"] as MarkupTagElement);
if (tagVariables != null)
{
foreach (MarkupElement el in tagVariables.Elements)
{
MarkupTagElement tag = (el as MarkupTagElement);
if (tag == null) continue;
if (tag.FullName != "Variable") continue;
ProjectTypeVariable varr = new ProjectTypeVariable();
varr.Name = (tag.Attributes["Name"] == null ? String.Empty : tag.Attributes["Name"].Value);
varr.Title = (tag.Attributes["Title"] == null ? String.Empty : tag.Attributes["Title"].Value);
MarkupAttribute attType = tag.Attributes["Type"];
if (attType != null)
{
switch (attType.Value.ToLower())
{
case "choice":
{
varr.Type = ProjectTypeVariableType.Choice;
break;
}
case "fileopen":
{
varr.Type = ProjectTypeVariableType.FileOpen;
break;
}
case "filesave":
{
varr.Type = ProjectTypeVariableType.FileSave;
break;
}
default:
{
varr.Type = ProjectTypeVariableType.Text;
break;
}
}
}
MarkupTagElement tagValidValues = (tag.Elements["ValidValues"] as MarkupTagElement);
if (tagValidValues != null)
{
foreach (MarkupElement elValidValue in tagValidValues.Elements)
{
MarkupTagElement tagValidValue = (elValidValue as MarkupTagElement);
if (tagValidValue == null) continue;
if (tagValidValue.FullName != "ValidValue") continue;
string value = (tagValidValue.Attributes["Value"] == null ? String.Empty : tagValidValue.Attributes["Value"].Value);
string title = (tagValidValue.Attributes["Title"] == null ? value : tagValidValue.Attributes["Title"].Value);
varr.ValidValues.Add(title, value);
}
}
projtype.Variables.Add(varr);
}
}
}
#endregion
package.ProjectTypes.Add(projtype);
}
@ -1077,17 +1140,15 @@ namespace UniversalEditor.DataFormats.UEPackage
}
}
#endregion
#region ProjectVariables
#region Variables
{
/*
if (projtype.ProjectVariables.Count > 0)
if (projtype.Variables.Count > 0)
{
MarkupTagElement tagProjectVariables = new MarkupTagElement();
tagProjectVariables.FullName = "ProjectVariables";
MarkupTagElement tagVariables = new MarkupTagElement();
tagVariables.FullName = "Variables";
tagProjectType.Elements.Add(tagProjectVariables);
tagProjectType.Elements.Add(tagVariables);
}
*/
}
#endregion

View File

@ -33,6 +33,9 @@ namespace UniversalEditor
private ProjectTypeItemShortcut.ProjectTypeItemShortcutCollection mvarItemShortcuts = new ProjectTypeItemShortcut.ProjectTypeItemShortcutCollection();
public ProjectTypeItemShortcut.ProjectTypeItemShortcutCollection ItemShortcuts { get { return mvarItemShortcuts; } }
private ProjectTypeVariable.ProjectTypeVariableCollection mvarVariables = new ProjectTypeVariable.ProjectTypeVariableCollection();
public ProjectTypeVariable.ProjectTypeVariableCollection Variables { get { return mvarVariables; } }
}
/// <summary>
/// A shortcut placed in the "Add New Item" menu when the project is selected. When

View File

@ -116,6 +116,7 @@
<Compile Include="ProjectTaskActions\ProjectTaskActionPackage.cs" />
<Compile Include="ProjectTaskEvent.cs" />
<Compile Include="ProjectType.cs" />
<Compile Include="ProjectTypeVariable.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Template.cs" />
</ItemGroup>