Exemplo n.º 1
0
        public HexSectorSelector(ResourceManager resourceManager, Sector sector, Hex coords, int jump)
        {
            if (resourceManager == null)
                throw new ArgumentNullException("resourceManager");

            if (sector == null)
                throw new ArgumentNullException("sector");

            this.sector = sector;
            this.resourceManager = resourceManager;
            this.coords = coords;
            this.jump = jump;
        }
Exemplo n.º 2
0
        public HexSectorSelector(ResourceManager resourceManager, Sector sector, Point coords, int jump)
        {
            if (resourceManager == null)
                throw new ArgumentNullException("resourceManager");

            if (sector == null)
                throw new ArgumentNullException("sector");

            m_sector = sector;
            m_resourceManager = resourceManager;
            m_coords = coords;
            m_jump = jump;
        }
Exemplo n.º 3
0
        public void Resolve(SectorMap sectorMap, ResourceManager resourceManager, out Sector sector, out World world)
        {
            if (sectorMap == null)
                throw new ArgumentNullException("sectorMap");

            sector = null;
            world = null;

            sector = sectorMap.FromLocation(Sector.X, Sector.Y);
            if (sector == null)
                return;

            WorldCollection worlds = sector.GetWorlds(resourceManager, cacheResults: true);
            if (worlds != null)
                world = worlds[World.X, World.Y];
        }
Exemplo n.º 4
0
        public WorldLocation(Sector sector, World world)
        {
            if (sector == null)
                throw new ArgumentNullException("sector");
            if (world == null)
                throw new ArgumentNullException("world");

            Sector = sector.Location;
            World = world.Location;
        }
Exemplo n.º 5
0
        public void Resolve(SectorMap sectorMap, out Sector sector, out Subsector subsector)
        {
            if (sectorMap == null)
                throw new ArgumentNullException("sectorMap");

            sector = null;
            subsector = null;

            sector = sectorMap.FromLocation(SectorLocation.X, SectorLocation.Y);
            if (sector != null)
                subsector = sector[Index];
        }
Exemplo n.º 6
0
        public SubsectorLocation(Sector sector, Subsector subsector)
        {
            if (sector == null)
                throw new ArgumentNullException("sector");
            if (subsector == null)
                throw new ArgumentNullException("subsector");

            SectorLocation = sector.Location;
            Index = subsector.Index[0];
        }
Exemplo n.º 7
0
        public SectorLocation(Sector sector)
        {
            if (sector == null)
                throw new ArgumentNullException("sector");

            SectorCoords = sector.Location;
        }
Exemplo n.º 8
0
        public void Merge(Sector metadataSource)
        {
            if (metadataSource == null)
                throw new ArgumentNullException("metadataSource");

            // TODO: This is very fragile; if a new type is added to Sector we need to add more code here.

            if (metadataSource.Names.Any()) { Names.Clear(); Names.AddRange(metadataSource.Names); }

            if (metadataSource.DataFile != null && DataFile != null &&
                (metadataSource.DataFile.FileName != DataFile.FileName ||
                metadataSource.DataFile.Type != DataFile.Type)) {
                throw new Exception(string.Format("Mismatching DataFile entries for {0}", this.Names[0].Text));
            }

            if (metadataSource.DataFile != null) DataFile = metadataSource.DataFile;

            Subsectors.AddRange(metadataSource.Subsectors);
            Allegiances.AddRange(metadataSource.Allegiances);
            Borders.AddRange(metadataSource.Borders);
            Routes.AddRange(metadataSource.Routes);
            Labels.AddRange(metadataSource.Labels);
            Credits = metadataSource.Credits;
            Products.AddRange(metadataSource.Products);
            StylesheetText = metadataSource.StylesheetText;
        }
Exemplo n.º 9
0
        internal BorderPath ComputeGraphicsPath(Sector sector, PathUtil.PathType type)
        {
            lock (this)
            {
                if (borderPathsCache[(int)type] == null)
                    borderPathsCache[(int)type] = new BorderPath(this, sector, type);
            }

            return borderPathsCache[(int)type];
        }
Exemplo n.º 10
0
 public string GetLabel(Sector sector)
 {
     if (!ShowLabel)
         return null;
     if (!string.IsNullOrEmpty(Label))
         return Label;
     Allegiance alleg = sector.GetAllegianceFromCode(Allegiance);
     if (alleg == null)
         return null;
     return alleg.Name;
 }
Exemplo n.º 11
0
            public ClipPath(Sector sector, PathUtil.PathType borderPathType)
            {
                float[] edgex, edgey;
                RenderUtil.HexEdges(borderPathType, out edgex, out edgey);

                IEnumerable<Hex> hexes =
                    Util.Sequence(1, Astrometrics.SectorWidth).Select(x => new Hex((byte)x, 1))
                    .Concat(Util.Sequence(2, Astrometrics.SectorHeight).Select(y => new Hex(Astrometrics.SectorWidth, (byte)y)))
                    .Concat(Util.Sequence(Astrometrics.SectorWidth - 1, 1).Select(x => new Hex((byte)x, Astrometrics.SectorHeight)))
                    .Concat(Util.Sequence(Astrometrics.SectorHeight - 1, 1).Select(y => new Hex(1, (byte)y)));

                Rectangle bounds = sector.Bounds;
                IEnumerable<Point> points = (from hex in hexes select new Point(hex.X + bounds.X, hex.Y + bounds.Y)).ToList();
                PathUtil.ComputeBorderPath(points, edgex, edgey, out clipPathPoints, out clipPathPointTypes);

                PointF min = clipPathPoints[0];
                PointF max = clipPathPoints[0];
                for (int i = 1; i < clipPathPoints.Length; ++i)
                {
                    PointF pt = clipPathPoints[i];
                    if (pt.X < min.X)
                        min.X = pt.X;
                    if (pt.Y < min.Y)
                        min.Y = pt.Y;
                    if (pt.X > max.X)
                        max.X = pt.X;
                    if (pt.Y > max.Y)
                        max.Y = pt.Y;
                }
                this.bounds = new RectangleF(min, new SizeF(max.X - min.X, max.Y - min.Y));
            }
Exemplo n.º 12
0
        public QuadrantSelector(ResourceManager resourceManager, Sector sector, int index)
        {
            if (resourceManager == null)
                throw new ArgumentNullException("resourceManager");

            if (sector == null)
                throw new ArgumentNullException("sector");

            if (index < 0 || index >= 4)
                throw new ArgumentOutOfRangeException("index", "index must be 0...3");

            this.sector = sector;
            this.index = index;
            this.resourceManager = resourceManager;
        }
Exemplo n.º 13
0
        public void MSECWriterTest()
        {
            Sector sector = new Sector();
            sector.Names.Add(new Name("Sector Name"));
            sector.Allegiances.Add(new Allegiance("X7", "Seven Evil Exes"));
            sector.Borders.Add(new Border("0001 0002 0003 0004"));
            sector.Borders.Add(new Border("0000 0001 0002 0003 0004 0005 0006", "blue"));
            sector.Routes.Add(new Route(start: 0101, end: 0202));
            sector.Routes.Add(new Route(new Point(-1, -1), 3240, new Point(1, 1), 0101, "red"));
            sector.Labels.Add(new Label(0123, "Your text here"));

            StringWriter writer = new StringWriter();
            MSECSerializer msec = new MSECSerializer();
            msec.Serialize(writer, sector);

            string expected = String.Join("\r\n", new string[] {
                "# Generated by http://www.travellermap.com",
                "# <DATETIME>",
                "",
                "sector Sector Name",
                "",
                "",
                "# Other",
                "#",
                "border 0001 0002 0003 0004 red",
                "border 0000 0001 0002 0003 0004 0005 0006 blue",
                "label 0123 Your text here",
                "",
                "# Third Imperium",
                "#",
                "route -1 -1 3240 1 1 0101 red",
                "route 0101 0202 green",
                "",
                "# Seven Evil Exes",
                "#",
                "ally X7 Seven Evil Exes",
                ""
            });
            string actual = writer.ToString();
            actual = Regex.Replace(actual, @"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\S+", "<DATETIME>");
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 14
0
        public SectorSelector(ResourceManager resourceManager, Sector sector)
        {
            if (resourceManager == null)
                throw new ArgumentNullException("resourceManager");

            if (sector == null)
                throw new ArgumentNullException("sector");

            m_sector = sector;
            m_resourceManager = resourceManager;
        }
Exemplo n.º 15
0
        public void Merge(Sector metadataSource)
        {
            if (metadataSource == null)
                throw new ArgumentNullException("metadataSource");

            // TODO: This is very fragile; if a new type is added to Sector we need to add more code here.

            if (metadataSource.Names.Any()) { Names.Clear(); Names.AddRange(metadataSource.Names); }
            if (metadataSource.DataFile != null) DataFile = metadataSource.DataFile;

            Subsectors.AddRange(metadataSource.Subsectors);
            Allegiances.AddRange(metadataSource.Allegiances);
            Borders.AddRange(metadataSource.Borders);
            Routes.AddRange(metadataSource.Routes);
            Labels.AddRange(metadataSource.Labels);
            Credits = metadataSource.Credits;
            Products.AddRange(metadataSource.Products);
            StylesheetText = metadataSource.StylesheetText;
        }
Exemplo n.º 16
0
        public SubsectorSelector(ResourceManager resourceManager, Sector sector, int index)
        {
            if (resourceManager == null)
                throw new ArgumentNullException("resourceManager");

            if (sector == null)
                throw new ArgumentNullException("sector");

            if (index < 0 || index >= 16)
                throw new ArgumentOutOfRangeException("index", "index must be 0...15");

            m_sector = sector;
            m_index = index;
            m_resourceManager = resourceManager;
        }
Exemplo n.º 17
0
 public SectorSelector(ResourceManager resourceManager, Sector sector)
 {
     this.sector          = sector ?? throw new ArgumentNullException(nameof(sector));
     this.resourceManager = resourceManager ?? throw new ArgumentNullException(nameof(resourceManager));
 }