示例#1
0
        /// <summary>
        /// Update Enemy or Abandoned markers
        /// </summary>
        public void UpdateDefaultMarker(Map map, MarkerSettings settings)
        {
            switch (settings.Name)
            {
            case Marker.DefaultNames.Abandoned:
                AbandonedMarker = new Marker(settings);
                break;

            case Marker.DefaultNames.Enemy:
                EnemyMarker = new Marker(settings);
                break;

            case Marker.DefaultNames.You:
                YourMarker = new Marker(settings);
                break;

            case Marker.DefaultNames.YourTribe:
                YourTribeMarker = new Marker(settings);
                break;

            default:
                Debug.Assert(false, "'You' and 'Your Tribe' markers are updated through the regular UpdateMarker methods");
                break;
            }

            World.Default.InvalidateMarkers();
        }
示例#2
0
        /// <summary>
        /// Gets the marker for the player or
        /// return a new one
        /// </summary>
        public Marker GetMarker(Player player)
        {
            Debug.Assert(player != null);
            if (player.Name == World.Default.You.Name)
            {
                Debug.Assert(YourMarker.Settings.Name == Marker.DefaultNames.You);
                return(YourMarker);
            }

            Marker found;

            if (_markPlayer.TryGetValue(player.Id, out found))
            {
                return(found);
            }

            MarkerSettings defaultSettings = EnemyMarker.Settings;

            if (player.HasTribe)
            {
                Marker marker;
                if (_markTribe.TryGetValue(player.Tribe.Id, out marker))
                {
                    defaultSettings = marker.Settings;
                }
            }
            return(new Marker(MarkerSettings.Create(defaultSettings.Color, defaultSettings.View)));
        }
 private void MarkerView_SelectedValueChanged(object sender, EventArgs e)
 {
     if (!_settingProperties)
     {
         var settings = GetMarkerSettings();
         UpdateMarker(MarkerSettings.ChangeView(settings, MarkerView.SelectedValue.ToString()));
     }
 }
 private void MarkerExtraColor_SelectedColorChanged(object sender, EventArgs e)
 {
     if (!_settingProperties)
     {
         var settings = GetMarkerSettings();
         UpdateMarker(MarkerSettings.ChangeExtraColor(settings, MarkerExtraColor.SelectedColor));
     }
 }
        public void SetMarker(MarkerSettings settings)
        {
            _settings = settings;
            _player   = null;
            _tribe    = null;

            SetControlProperties(settings);
        }
        private void MarkerActive_CheckedChanged(object sender, EventArgs e)
        {
            MarkerActivePanel.Enabled = MarkerActive.Checked;

            if (!_settingProperties)
            {
                var settings = GetMarkerSettings();
                UpdateMarker(MarkerSettings.ChangeEnabled(settings, MarkerActive.Checked));
            }
        }
        public void SetMarker(Tribe tribe)
        {
            _settings = null;
            _player   = null;
            _tribe    = tribe;

            Marker marker = World.Default.Map.MarkerManager.GetMarker(tribe);

            SetControlProperties(marker.Settings);
        }
        public void SetMarker(Player player)
        {
            _settings = null;
            _player   = player;
            _tribe    = null;

            Marker marker = World.Default.Map.MarkerManager.GetMarker(player);

            SetControlProperties(marker.Settings);
        }
示例#9
0
 private void UpdateMarker(MarkerGridRow data, MarkerSettings settings)
 {
     if (data.Player != null)
     {
         World.Default.Map.MarkerManager.UpdateMarker(World.Default.Map, data.Player, settings);
     }
     else if (data.Tribe != null)
     {
         World.Default.Map.MarkerManager.UpdateMarker(World.Default.Map, data.Tribe, settings);
     }
 }
示例#10
0
 private void UpdateMarker(MarkerSettings settings)
 {
     if (_tribe != null)
     {
         _map.MarkerManager.UpdateMarker(_map, _tribe, settings);
     }
     else
     {
         _map.MarkerManager.UpdateMarker(_map, _player, settings);
     }
     _mainCommand.Image = GetMainCommandImage(GetMarker());
 }
示例#11
0
        /// <summary>
        /// Make the control reflect the MarkerSettings
        /// </summary>
        private void SetControlProperties(MarkerSettings settings)
        {
            _settingProperties = true;

            MarkerView.DataSource    = World.Default.Views.GetBackgroundViews(AllowBarbarianViews).ToArray();
            MarkerView.SelectedValue = settings.View;

            MarkerActive.Checked           = settings.Enabled;
            MarkerColor.SelectedColor      = settings.Color;
            MarkerExtraColor.SelectedColor = settings.ExtraColor;

            _settingProperties = false;
        }
示例#12
0
        /// <summary>
        /// Update a tribe marker and refresh the map
        /// </summary>
        public void UpdateMarker(Map map, Tribe tribe, MarkerSettings settings)
        {
            if (World.Default.You.HasTribe && tribe == World.Default.You.Tribe)
            {
                settings        = MarkerSettings.ChangeName(settings, Marker.DefaultNames.YourTribe);
                YourTribeMarker = new Marker(settings);
            }
            else
            {
                _markers.RemoveAll(x => x.Tribe == tribe);
                _markers.Add(new Marker(tribe, settings));
            }

            World.Default.InvalidateMarkers();
        }
示例#13
0
        /// <summary>
        /// Update a player marker and refresh the map
        /// </summary>
        public void UpdateMarker(Map map, Player player, MarkerSettings settings)
        {
            if (player == World.Default.You)
            {
                settings   = MarkerSettings.ChangeName(settings, Marker.DefaultNames.You);
                YourMarker = new Marker(settings);
            }
            else
            {
                _markers.RemoveAll(x => x.Player == player);
                _markers.Add(new Marker(player, settings));
            }

            World.Default.InvalidateMarkers();
        }
示例#14
0
        /// <summary>
        /// Reads a Marker from the XML node
        /// </summary>
        private static Marker ReadMarker(XmlReader r)
        {
            string name       = r.GetAttribute("Name");
            bool   enabled    = Convert.ToBoolean(r.GetAttribute("Enabled").ToLower());
            Color  color      = XmlHelper.GetColor(r.GetAttribute("Color"));
            Color  extraColor = XmlHelper.GetColor(r.GetAttribute("ExtraColor"));
            string view       = r.GetAttribute("View");
            var    settings   = new MarkerSettings(name, enabled, color, extraColor, view);
            Marker marker     = null;

            if (!r.IsEmptyElement)
            {
                r.ReadStartElement();
                while (r.IsStartElement("Marker"))
                {
                    string markerType = r.GetAttribute("Type");
                    string markerName = r.GetAttribute("Name");

                    if (markerType == "Player")
                    {
                        Player ply = World.Default.GetPlayer(markerName);
                        if (ply != null)
                        {
                            marker = new Marker(ply, settings);
                        }
                    }
                    else
                    {
                        Debug.Assert(markerType == "Tribe");
                        Tribe tribe = World.Default.GetTribe(markerName);
                        if (tribe != null)
                        {
                            marker = new Marker(tribe, settings);
                        }
                    }

                    r.Read();
                }
                r.ReadEndElement();
            }
            else
            {
                r.Read();
            }

            return(marker ?? new Marker(settings));
        }
示例#15
0
        private void MarkersGrid_UpdatingCell(object sender, UpdatingCellEventArgs e)
        {
            var currentRow = MarkersGrid.CurrentRow;

            if (currentRow != null && currentRow.RowType == RowType.Record)
            {
                var data = currentRow.DataRow as MarkerGridRow;
                if (data != null)
                {
                    MarkerSettings settings = data.GetMarkerSettings();

                    object newValue = e.Value;
                    if (e.Value != null)
                    {
                        switch (e.Column.Key)
                        {
                        case "Enabled":
                            settings     = MarkerSettings.ChangeEnabled(settings, (bool)newValue);
                            data.Enabled = (bool)newValue;
                            break;

                        case "Name":
                            // Done in Init/EndCustomEdit
                            break;

                        case "Color":
                            settings   = MarkerSettings.ChangeColor(settings, (Color)newValue);
                            data.Color = (Color)newValue;
                            break;

                        case "ExtraColor":
                            settings        = MarkerSettings.ChangeExtraColor(settings, (Color)newValue);
                            data.ExtraColor = (Color)newValue;
                            break;

                        case "View":
                            settings  = MarkerSettings.ChangeView(settings, (string)newValue);
                            data.View = (string)newValue;
                            break;
                        }
                    }

                    UpdateMarker(data, settings);
                }
            }
        }
示例#16
0
        /// <summary>
        /// Gets the marker for the tribe or
        /// return a new one
        /// </summary>
        public Marker GetMarker(Tribe tribe)
        {
            Debug.Assert(tribe != null);
            if (World.Default.You.HasTribe && World.Default.You.Tribe == tribe)
            {
                Debug.Assert(YourTribeMarker.Settings.Name == Marker.DefaultNames.YourTribe);
                return(YourTribeMarker);
            }

            Marker found;

            if (_markTribe.TryGetValue(tribe.Id, out found))
            {
                return(found);
            }

            return(new Marker(MarkerSettings.Create(EnemyMarker.Settings.Color, EnemyMarker.Settings.View)));
        }
示例#17
0
 private void UpdateMarker(MarkerSettings settings)
 {
     if (_settings != null)
     {
         if (AutoUpdateMarkers)
         {
             World.Default.Map.MarkerManager.UpdateDefaultMarker(World.Default.Map, settings);
         }
         _settings = settings;
     }
     else if (_tribe != null)
     {
         Debug.Assert(AutoUpdateMarkers);
         World.Default.Map.MarkerManager.UpdateMarker(World.Default.Map, _tribe, settings);
     }
     else
     {
         Debug.Assert(AutoUpdateMarkers);
         World.Default.Map.MarkerManager.UpdateMarker(World.Default.Map, _player, settings);
     }
 }
示例#18
0
        private void OnChangeView(object sender, EventArgs e)
        {
            var marker = GetMarker();

            UpdateMarker(MarkerSettings.ChangeView(marker.Settings, ((UIComboBox)sender).SelectedValue.ToString()));
        }
示例#19
0
        private void OnChangeExtraColor(object sender, Color selectedColor)
        {
            var marker = GetMarker();

            UpdateMarker(MarkerSettings.ChangeExtraColor(marker.Settings, selectedColor));
        }
示例#20
0
 public Marker(Tribe tribe, MarkerSettings settings)
     : this(settings)
 {
     Debug.Assert(tribe != null);
     Tribe = tribe;
 }
示例#21
0
 public Marker(Player player, MarkerSettings settings)
     : this(settings)
 {
     Debug.Assert(player != null);
     Player = player;
 }
示例#22
0
 public Marker(MarkerSettings settings)
 {
     Debug.Assert(settings != null);
     Settings = settings;
 }
示例#23
0
        private void OnChangeEnabled(object sender, CommandEventArgs e)
        {
            var marker = GetMarker();

            UpdateMarker(MarkerSettings.ChangeEnabled(marker.Settings, e.Command.IsChecked));
        }