/// <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(); }
/// <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); }
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); } }
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()); }
/// <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; }
/// <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(); }
/// <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(); }
/// <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)); }
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); } } }
/// <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))); }
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); } }
private void OnChangeView(object sender, EventArgs e) { var marker = GetMarker(); UpdateMarker(MarkerSettings.ChangeView(marker.Settings, ((UIComboBox)sender).SelectedValue.ToString())); }
private void OnChangeExtraColor(object sender, Color selectedColor) { var marker = GetMarker(); UpdateMarker(MarkerSettings.ChangeExtraColor(marker.Settings, selectedColor)); }
public Marker(Tribe tribe, MarkerSettings settings) : this(settings) { Debug.Assert(tribe != null); Tribe = tribe; }
public Marker(Player player, MarkerSettings settings) : this(settings) { Debug.Assert(player != null); Player = player; }
public Marker(MarkerSettings settings) { Debug.Assert(settings != null); Settings = settings; }
private void OnChangeEnabled(object sender, CommandEventArgs e) { var marker = GetMarker(); UpdateMarker(MarkerSettings.ChangeEnabled(marker.Settings, e.Command.IsChecked)); }