preliminary implementation of document properties settings provider for the Heroes of Might and Magic II map editor
This commit is contained in:
parent
23a4d71223
commit
c6883c787d
@ -0,0 +1,82 @@
|
||||
//
|
||||
// MapDocumentPropertiesSettingsProvider.cs
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 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 MBS.Framework.UserInterface;
|
||||
using UniversalEditor.ObjectModels.NewWorldComputing.Map;
|
||||
|
||||
namespace UniversalEditor.Plugins.NewWorldComputing.UserInterface.Editors.NewWorldComputing.Map
|
||||
{
|
||||
public class MapDocumentPropertiesSettingsProvider : SettingsProvider
|
||||
{
|
||||
public MapEditor Editor { get; private set; } = null;
|
||||
|
||||
public MapDocumentPropertiesSettingsProvider(MapEditor editor)
|
||||
{
|
||||
Editor = editor;
|
||||
SettingsGroups.Add(new SettingsGroup("General", new Setting[]
|
||||
{
|
||||
new TextSetting("Map name"),
|
||||
new TextSetting("Map description"),
|
||||
new ChoiceSetting("Difficulty", null, new ChoiceSetting.ChoiceSettingValue[]
|
||||
{
|
||||
new ChoiceSetting.ChoiceSettingValue("Easy", MapDifficulty.Easy),
|
||||
new ChoiceSetting.ChoiceSettingValue("Normal", MapDifficulty.Normal),
|
||||
new ChoiceSetting.ChoiceSettingValue("Hard", MapDifficulty.Hard),
|
||||
new ChoiceSetting.ChoiceSettingValue("Expert", MapDifficulty.Expert)
|
||||
}),
|
||||
new BooleanSetting("Start with hero in each player's castle", true),
|
||||
new ChoiceSetting("Special victory condition", null, new ChoiceSetting.ChoiceSettingValue[]
|
||||
{
|
||||
new ChoiceSetting.ChoiceSettingValue("None", 0),
|
||||
new ChoiceSetting.ChoiceSettingValue("Capture a particular castle", 1),
|
||||
new ChoiceSetting.ChoiceSettingValue("Defeat a particular hero", 2),
|
||||
new ChoiceSetting.ChoiceSettingValue("Find a particular artifact", 3),
|
||||
new ChoiceSetting.ChoiceSettingValue("One side defeats another", 4),
|
||||
new ChoiceSetting.ChoiceSettingValue("Accumulate gold", 5)
|
||||
}),
|
||||
new ChoiceSetting("Special loss condition", null, new ChoiceSetting.ChoiceSettingValue[]
|
||||
{
|
||||
new ChoiceSetting.ChoiceSettingValue("None", 0),
|
||||
new ChoiceSetting.ChoiceSettingValue("Lose a particular castle", 1),
|
||||
new ChoiceSetting.ChoiceSettingValue("Lose a particular hero", 2),
|
||||
new ChoiceSetting.ChoiceSettingValue("Run out of time", 3)
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
protected override void LoadSettingsInternal()
|
||||
{
|
||||
MapObjectModel map = (Editor.ObjectModel as MapObjectModel);
|
||||
|
||||
SettingsGroups[0].Settings[0].SetValue(map.Name);
|
||||
SettingsGroups[0].Settings[1].SetValue(map.Description);
|
||||
SettingsGroups[0].Settings[2].SetValue(map.Difficulty);
|
||||
}
|
||||
protected override void SaveSettingsInternal()
|
||||
{
|
||||
MapObjectModel map = (Editor.ObjectModel as MapObjectModel);
|
||||
|
||||
map.Name = SettingsGroups[0].Settings[0].GetValue<string>();
|
||||
map.Description = SettingsGroups[0].Settings[1].GetValue<string>();
|
||||
map.Difficulty = SettingsGroups[0].Settings[2].GetValue<MapDifficulty>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -69,6 +69,16 @@ namespace UniversalEditor.Plugins.NewWorldComputing.UserInterface.Editors.NewWor
|
||||
mapView.Refresh();
|
||||
}
|
||||
|
||||
private MapDocumentPropertiesSettingsProvider _mpds = null;
|
||||
public MapEditor()
|
||||
{
|
||||
_mpds = new MapDocumentPropertiesSettingsProvider(this);
|
||||
}
|
||||
|
||||
protected override SettingsProvider[] GetDocumentPropertiesSettingsProviders()
|
||||
{
|
||||
return new SettingsProvider[] { _mpds };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Editors\NewWorldComputing\Map\MapEditor.cs" />
|
||||
<Compile Include="Editors\NewWorldComputing\Map\Controls\MapViewControl.cs" />
|
||||
<Compile Include="Editors\NewWorldComputing\Map\MapDocumentPropertiesSettingsProvider.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Editors\" />
|
||||
|
||||
@ -41,12 +41,32 @@ namespace UniversalEditor.ObjectModels.NewWorldComputing.Map
|
||||
|
||||
public override void Clear()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void CopyTo(ObjectModel where)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
MapObjectModel clone = (where as MapObjectModel);
|
||||
clone.AllowedComputerPlayerColors = AllowedComputerPlayerColors;
|
||||
clone.AllowedHumanPlayerColors = AllowedHumanPlayerColors;
|
||||
clone.AllowedKingdomColors = AllowedKingdomColors;
|
||||
clone.AllowNormalVictory = AllowNormalVictory;
|
||||
clone.ComputerAlsoWins = ComputerAlsoWins;
|
||||
clone.Description = (Description?.Clone() as string);
|
||||
clone.Difficulty = Difficulty;
|
||||
clone.Height = Height;
|
||||
for (int i = 0; i < Items.Count; i++)
|
||||
{
|
||||
clone.Items.Add(Items[i]/*.Clone() as MapItem*/);
|
||||
}
|
||||
clone.LoseConditions = LoseConditions;
|
||||
clone.Name = (Name?.Clone() as string);
|
||||
clone.ObeliskCount = ObeliskCount;
|
||||
for (int i = 0; i < Tiles.Count; i++)
|
||||
{
|
||||
clone.Tiles.Add(Tiles[i]/*.Clone() as MapTile*/);
|
||||
}
|
||||
clone.Width = Width;
|
||||
clone.WinConditions = WinConditions;
|
||||
}
|
||||
|
||||
public MapDifficulty Difficulty { get; set; } = MapDifficulty.Easy;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user