Beispiel #1
0
        private void ChangeMapIDs(IEnumerable <MapIDControl> boxes, MapStatus area)
        {
            var input = new IDInputDialog(boxes.First().ID);

            input.ShowDialog(this);
            if (input.Confirmed)
            {
                long firstid;
                if (input.WantsAuto)
                {
                    firstid = Controller.GetSafeID();
                }
                else
                {
                    firstid = input.SelectedID;
                }
                int count = Controller.ChangeMapIDs(boxes, firstid, area, MapReplaceOption.Info);
                if (count > 0)
                {
                    var picker = new ReplaceOptionDialog(count);
                    picker.ShowDialog(this);
                    Controller.ChangeMapIDs(boxes, firstid, area, picker.SelectedOption);
                }
                else
                {
                    Controller.ChangeMapIDs(boxes, firstid, area, MapReplaceOption.Skip);
                }
            }
        }
Beispiel #2
0
        private void InputChangeMapIDs(IEnumerable <long> originals)
        {
            var input = new IDInputDialog(originals.First());

            input.ShowDialog(this);
            if (input.Confirmed)
            {
                long firstid;
                if (input.WantsAuto)
                {
                    firstid = GetSafeID();
                }
                else
                {
                    firstid = input.SelectedID;
                }
                var desired_range = Util.CreateRange(firstid, originals.Count());
                var from_to       = originals.OrderBy(x => x).Zip(desired_range.OrderBy(x => x), (x, y) => new KeyValuePair <long, long>(x, y));

                // the map IDs that are currently being used and are not changing (potentially conflicting with the ones we want)
                var taken_ids = ActiveSide.GetTakenIDs().Except(originals);
                var conflicts = taken_ids.Intersect(desired_range);

                var replace_option = MapReplaceOption.ReplaceExisting;
                if (conflicts.Any())
                {
                    var picker = new ReplaceOptionDialog(conflicts.Count());
                    picker.ShowDialog(this);
                    if (picker.Confirmed)
                    {
                        replace_option = picker.SelectedOption;
                    }
                    else
                    {
                        return;
                    }
                }

                // go reverse so that we can change 0->1->2->3 without replacing 1 before we can change it to 2
                if (firstid > originals.First())
                {
                    from_to = from_to.Reverse();
                }

                foreach (var change in from_to.ToList())
                {
                    if (replace_option == MapReplaceOption.ChangeExisting && conflicts.Contains(change.Value))
                    {
                        ActiveSide.ChangeMapID(change.Value, GetSafeID());
                    }
                    else if (replace_option == MapReplaceOption.Skip && conflicts.Contains(change.Value))
                    { /* do nothing */
                    }
                    else
                    {
                        ActiveSide.ChangeMapID(change.Key, change.Value);
                    }
                }
            }
        }
Beispiel #3
0
        private void SendMapsWithMessage(IEnumerable <MapIDControl> maps, string destination)
        {
            int conflicts = Controller.SendMapsToWorld(maps, MapReplaceOption.Info, destination);

            if (conflicts > 0)
            {
                var option = new ReplaceOptionDialog(conflicts);
                option.ShowDialog(this);
                Controller.SendMapsToWorld(maps, option.SelectedOption, destination);
            }
            else
            {
                Controller.SendMapsToWorld(maps, MapReplaceOption.ReplaceExisting, destination);
            }
        }
Beispiel #4
0
        private void SendMapsCheckConflicts(IEnumerable <long> maps, bool local, string uuid)
        {
            var world     = WorldSide.GetTakenIDs();
            var conflicts = maps.Where(x => world.Contains(x));

            if (conflicts.Any())
            {
                var option = new ReplaceOptionDialog(conflicts.Count());
                option.ShowDialog(this);
                if (option.Confirmed)
                {
                    SendMapsToWorld(maps, option.SelectedOption, local, uuid);
                }
            }
            else
            {
                SendMapsToWorld(maps, MapReplaceOption.ReplaceExisting, local, uuid);
            }
        }