remove ProjectTypeVariable in favor of using Setting everywhere
This commit is contained in:
parent
2e33c6803d
commit
d973de830d
@ -24,6 +24,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using MBS.Framework;
|
||||
using MBS.Framework.Logic;
|
||||
using MBS.Framework.Settings;
|
||||
using UniversalEditor.Accessors;
|
||||
using UniversalEditor.DataFormats.Markup.XML;
|
||||
using UniversalEditor.DataFormats.PropertyList.XML;
|
||||
@ -438,9 +439,10 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
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);
|
||||
Setting varr = null;
|
||||
|
||||
string name = (tag.Attributes["Name"] == null ? String.Empty : tag.Attributes["Name"].Value);
|
||||
string title = (tag.Attributes["Title"] == null ? String.Empty : tag.Attributes["Title"].Value);
|
||||
|
||||
MarkupAttribute attType = tag.Attributes["Type"];
|
||||
if (attType != null)
|
||||
@ -449,27 +451,32 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
{
|
||||
case "choice":
|
||||
{
|
||||
varr.Type = ProjectTypeVariableType.Choice;
|
||||
varr = new ChoiceSetting(name, title);
|
||||
break;
|
||||
}
|
||||
case "fileopen":
|
||||
{
|
||||
varr.Type = ProjectTypeVariableType.FileOpen;
|
||||
varr = new FileSetting(name, title);
|
||||
((FileSetting)varr).Mode = FileSettingMode.Open;
|
||||
break;
|
||||
}
|
||||
case "filesave":
|
||||
{
|
||||
varr.Type = ProjectTypeVariableType.FileSave;
|
||||
varr = new FileSetting(name, title);
|
||||
((FileSetting)varr).Mode = FileSettingMode.Save;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
varr.Type = ProjectTypeVariableType.Text;
|
||||
varr = new TextSetting(name, title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (varr == null)
|
||||
continue;
|
||||
|
||||
MarkupTagElement tagValidValues = (tag.Elements["ValidValues"] as MarkupTagElement);
|
||||
if (tagValidValues != null)
|
||||
{
|
||||
@ -480,9 +487,12 @@ namespace UniversalEditor.DataFormats.UEPackage
|
||||
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);
|
||||
string valueTitle = (tagValidValue.Attributes["Title"] == null ? value : tagValidValue.Attributes["Title"].Value);
|
||||
|
||||
varr.ValidValues.Add(title, value);
|
||||
if (varr is ChoiceSetting)
|
||||
{
|
||||
((ChoiceSetting)varr).ValidValues.Add(new ChoiceSetting.ChoiceSettingValue(title, title, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
projtype.Variables.Add(varr);
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using MBS.Framework;
|
||||
using MBS.Framework.Logic;
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
@ -55,8 +57,7 @@ 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; } }
|
||||
public Setting.SettingCollection Variables { get; } = new Setting.SettingCollection();
|
||||
|
||||
public string ProjectFileExtension { get; set; } = null;
|
||||
}
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
//
|
||||
// ProjectTypeVariable.cs - represents a variable for a ProjectType
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2011-2020 Mike Becker's Software
|
||||
//
|
||||
// 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UniversalEditor
|
||||
{
|
||||
public enum ProjectTypeVariableType
|
||||
{
|
||||
Text,
|
||||
Choice,
|
||||
FileOpen,
|
||||
FileSave
|
||||
}
|
||||
/// <summary>
|
||||
/// Represents a variable for a <see cref="ProjectType" />.
|
||||
/// </summary>
|
||||
public class ProjectTypeVariable
|
||||
{
|
||||
|
||||
public class ProjectTypeVariableCollection
|
||||
: System.Collections.ObjectModel.Collection<ProjectTypeVariable>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Name { get; set; } = String.Empty;
|
||||
public string Title { get; set; } = String.Empty;
|
||||
public ProjectTypeVariableType Type { get; set; } = ProjectTypeVariableType.Text;
|
||||
public object DefaultValue { get; set; } = null;
|
||||
public Dictionary<string, object> ValidValues { get; } = new Dictionary<string, object>();
|
||||
}
|
||||
}
|
||||
@ -154,7 +154,6 @@
|
||||
<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" />
|
||||
<Compile Include="ObjectModels\Text\Formatted\Items\FormattedTextItemItalic.cs" />
|
||||
|
||||
@ -285,52 +285,18 @@ namespace UniversalEditor.UserInterface.Dialogs
|
||||
|
||||
for (int i = 0; i < template.ProjectTypes.Count; i++)
|
||||
{
|
||||
SettingsGroup sg = new SettingsGroup(template.ProjectTypes[i].Title);
|
||||
if (template.ProjectTypes[i].Variables.Count > 0)
|
||||
{
|
||||
foreach (ProjectTypeVariable ptv in template.ProjectTypes[i].Variables)
|
||||
SettingsGroup sg = new SettingsGroup(template.ProjectTypes[i].Title);
|
||||
foreach (Setting ptv in template.ProjectTypes[i].Variables)
|
||||
{
|
||||
switch (ptv.Type)
|
||||
{
|
||||
case ProjectTypeVariableType.Text:
|
||||
{
|
||||
sg.Settings.Add(new TextSetting(ptv.Name, ptv.Title));
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.Choice:
|
||||
{
|
||||
List<ChoiceSetting.ChoiceSettingValue> choices = new List<ChoiceSetting.ChoiceSettingValue>();
|
||||
foreach (KeyValuePair<string, object> kvp in ptv.ValidValues)
|
||||
{
|
||||
choices.Add(new ChoiceSetting.ChoiceSettingValue(kvp.Key, kvp.Key, kvp.Value));
|
||||
}
|
||||
sg.Settings.Add(new ChoiceSetting(ptv.Name, ptv.Title, null, choices.ToArray()));
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.FileOpen:
|
||||
{
|
||||
FileSetting co = new FileSetting(ptv.Name, ptv.Title);
|
||||
co.Mode = FileSettingMode.Open;
|
||||
sg.Settings.Add(co);
|
||||
break;
|
||||
}
|
||||
case ProjectTypeVariableType.FileSave:
|
||||
{
|
||||
FileSetting co = new FileSetting(ptv.Name, ptv.Title);
|
||||
co.Mode = FileSettingMode.Save;
|
||||
sg.Settings.Add(co);
|
||||
break;
|
||||
}
|
||||
}
|
||||
sg.Settings.Add(ptv);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
if (sg.Settings.Count > 0)
|
||||
{
|
||||
// only add the SettingsGroup if there are settings to be displayed
|
||||
// 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
|
||||
|
||||
csp.SettingsGroups.Add(sg);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user