diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapDocumentPropertiesSettingsProvider.cs b/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapDocumentPropertiesSettingsProvider.cs new file mode 100644 index 00000000..74857901 --- /dev/null +++ b/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapDocumentPropertiesSettingsProvider.cs @@ -0,0 +1,82 @@ +// +// MapDocumentPropertiesSettingsProvider.cs +// +// Author: +// Michael Becker +// +// 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 . +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(); + map.Description = SettingsGroups[0].Settings[1].GetValue(); + map.Difficulty = SettingsGroups[0].Settings[2].GetValue(); + } + } +} diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapEditor.cs b/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapEditor.cs index c26a53b4..4c6ddd79 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapEditor.cs +++ b/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/Editors/NewWorldComputing/Map/MapEditor.cs @@ -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 }; + } } } diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface.csproj b/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface.csproj index 2d488685..a7a58918 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface.csproj +++ b/Plugins.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface/UniversalEditor.Plugins.NewWorldComputing.UserInterface.csproj @@ -34,6 +34,7 @@ + diff --git a/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NewWorldComputing/Map/MapObjectModel.cs b/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NewWorldComputing/Map/MapObjectModel.cs index 8c21f29a..4d6fb9de 100644 --- a/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NewWorldComputing/Map/MapObjectModel.cs +++ b/Plugins/UniversalEditor.Plugins.NewWorldComputing/ObjectModels/NewWorldComputing/Map/MapObjectModel.cs @@ -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;