// // Copyright 2020 Electronic Arts Inc. // // The Command & Conquer Map Editor and corresponding source code 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. // The Command & Conquer Map Editor and corresponding source code is distributed // in the hope that it will be useful, but with permitted additional restrictions // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT // distributed with this program. You should have received a copy of the // GNU General Public License along with permitted additional restrictions // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection using MobiusEditor.Interface; using MobiusEditor.Render; using MobiusEditor.Utility; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using TGASharpLib; namespace MobiusEditor.Model { [Flags] public enum MapLayerFlag { None = 0, Basic = 1 << 0, Map = 1 << 1, Template = 1 << 2, Terrain = 1 << 3, Resources = 1 << 4, Walls = 1 << 5, Overlay = 1 << 6, Smudge = 1 << 7, Waypoints = 1 << 8, CellTriggers = 1 << 9, Houses = 1 << 10, Infantry = 1 << 11, Units = 1 << 12, Buildings = 1 << 13, Boundaries = 1 << 14, TechnoTriggers = 1 << 15, OverlayAll = Resources | Walls | Overlay, Technos = Terrain | Walls | Infantry | Units | Buildings, All = int.MaxValue } public class MapContext : ITypeDescriptorContext { public IContainer Container { get; private set; } public object Instance { get; private set; } public PropertyDescriptor PropertyDescriptor { get; private set; } public Map Map => Instance as Map; public readonly bool FractionalPercentages; public MapContext(Map map, bool fractionalPercentages) { Instance = map; FractionalPercentages = fractionalPercentages; } public object GetService(Type serviceType) => null; public void OnComponentChanged() { } public bool OnComponentChanging() => true; } public class Map : ICloneable { private int updateCount = 0; private bool updating = false; private IDictionary> invalidateLayers = new Dictionary>(); private bool invalidateOverlappers; public readonly BasicSection BasicSection; public readonly MapSection MapSection = new MapSection(); public readonly BriefingSection BriefingSection = new BriefingSection(); public readonly SteamSection SteamSection = new SteamSection(); public TheaterType Theater { get => MapSection.Theater; set => MapSection.Theater = value; } public Point TopLeft { get => new Point(MapSection.X, MapSection.Y); set { MapSection.X = value.X; MapSection.Y = value.Y; } } public Size Size { get => new Size(MapSection.Width, MapSection.Height); set { MapSection.Width = value.Width; MapSection.Height = value.Height; } } public Rectangle Bounds { get => new Rectangle(TopLeft, Size); set { MapSection.X = value.Left; MapSection.Y = value.Top; MapSection.Width = value.Width; MapSection.Height = value.Height; } } public readonly Type HouseType; public readonly HouseType[] HouseTypes; public readonly List TheaterTypes; public readonly List TemplateTypes; public readonly List TerrainTypes; public readonly List OverlayTypes; public readonly List SmudgeTypes; public readonly string[] EventTypes; public readonly string[] ActionTypes; public readonly string[] MissionTypes; public readonly List DirectionTypes; public readonly List InfantryTypes; public readonly List UnitTypes; public readonly List BuildingTypes; public readonly string[] TeamMissionTypes; public readonly CellMetrics Metrics; public readonly CellGrid