Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added options how to display char names on overlay. #169

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions SMT/MapConfig.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows.Media;
using System.Xml.Serialization;

Expand Down Expand Up @@ -108,6 +109,7 @@ public class MapConfig : INotifyPropertyChanged
private bool m_overlayShowSystemNames = false;
private bool m_overlayShowAllCharacterNames = false;
private bool m_overlayIndividualCharacterWindows = false;
private string m_overlayAdditionalCharacterNamesDisplay = "All";

public MapConfig()
{
Expand Down Expand Up @@ -1133,6 +1135,22 @@ public bool OverlayIndividualCharacterWindows
OnPropertyChanged("OverlayIndividualCharacterWindows");
}
}

[Category("Overlay")]
[DisplayName("Overlay Additional Character Names Display")]
public string OverlayAdditionalCharacterNamesDisplay
{
get
{
return m_overlayAdditionalCharacterNamesDisplay;
}
set
{
m_overlayAdditionalCharacterNamesDisplay = value;

OnPropertyChanged("OverlayAdditionalCharacterNamesDisplay");
}
}

[Category("Overlay")]
[DisplayName("Overlay Show System Names")]
Expand Down Expand Up @@ -1342,6 +1360,7 @@ public void SetDefaults()
OverlayShowJumpBridges = true;
OverlayShowSystemNames = false;
OverlayShowAllCharacterNames = false;
OverlayAdditionalCharacterNamesDisplay = "All";

IntelFreshTime = 30;
IntelStaleTime = 120;
Expand Down
96 changes: 68 additions & 28 deletions SMT/Overlay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@

private int overlayDepth = 8;
private Dictionary<LocalCharacter, OverlaySystemData> currentPlayersSystemData = new ();
private OverlaySystemData currentPlayerSystemData;

Check warning on line 273 in SMT/Overlay.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Overlay.currentPlayerSystemData' is never used

Check warning on line 273 in SMT/Overlay.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Overlay.currentPlayerSystemData' is never used

Check warning on line 273 in SMT/Overlay.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Overlay.currentPlayerSystemData' is never used

Check warning on line 273 in SMT/Overlay.xaml.cs

View workflow job for this annotation

GitHub Actions / build

The field 'Overlay.currentPlayerSystemData' is never used
private OverlayCanvasData canvasData = new OverlayCanvasData();

private float intelUrgentPeriod = 300;
Expand Down Expand Up @@ -300,6 +300,7 @@
private bool showSystemNames = false;
private bool showAllCharacterNames = false;
private bool individualCharacterWindows = false;
private string additionalCharacterNamesDisplay = "All";

private DispatcherTimer locationUpdateTimer = new DispatcherTimer();
private DispatcherTimer dataUpdateTimer = new DispatcherTimer();
Expand Down Expand Up @@ -419,6 +420,7 @@
showSystemNames = mainWindow.MapConf.OverlayShowSystemNames;
showAllCharacterNames = mainWindow.MapConf.OverlayShowAllCharacterNames;
individualCharacterWindows = mainWindow.MapConf.OverlayIndividualCharacterWindows;
additionalCharacterNamesDisplay = mainWindow.MapConf.OverlayAdditionalCharacterNamesDisplay;

// Initialize value animation to be used by dashed lines
dashAnimation = new DoubleAnimation();
Expand Down Expand Up @@ -1589,48 +1591,79 @@
double leftCoord = left - (systemData[sysData.system.Name].systemCanvasElement.Width * 0.5);
double topCoord = top - (systemData[sysData.system.Name].systemCanvasElement.Height * 0.5);

if (showSystemNames || showAllCharacterNames )
// Show system and char names.
if (systemData[sysData.system.Name].systemNameElement == null)
{
if (systemData[sysData.system.Name].systemNameElement == null)
{
systemData[sysData.system.Name].systemNameElement = new TextBlock();
}
systemData[sysData.system.Name].systemNameElement.Inlines.Clear();
systemData[sysData.system.Name].systemNameElement.Width = 80;
systemData[sysData.system.Name].systemNameElement = new TextBlock();
}
systemData[sysData.system.Name].systemNameElement.Inlines.Clear();
systemData[sysData.system.Name].systemNameElement.Width = 80;

bool firstEntry = false;

bool firstEntry = false;
if (showSystemNames)
if (showSystemNames)
{
systemData[sysData.system.Name].systemNameElement.Inlines.Add( new Run(sysData.system.Name));
firstEntry = true;
}

List<string> charsInSystem = new();

foreach (KeyValuePair<LocalCharacter, OverlaySystemData> localCharacterEntry in currentPlayersSystemData)
{
if (localCharacterEntry.Value.system != null && sysData.system.Name == localCharacterEntry.Value.system.Name)
{
systemData[sysData.system.Name].systemNameElement.Inlines.Add( new Run(sysData.system.Name));
firstEntry = true;
charsInSystem.Add(localCharacterEntry.Key.Name);
}
}

foreach (KeyValuePair<LocalCharacter, OverlaySystemData> localCharacterEntry in currentPlayersSystemData)
{
if (localCharacterEntry.Value.system != null && sysData.system.Name == localCharacterEntry.Value.system.Name)
switch (additionalCharacterNamesDisplay)
{
case "Overlay Character":
if (charsInSystem.Contains(OverlayCharacter.Name))
{
if (firstEntry)
{
systemData[sysData.system.Name].systemNameElement.Inlines.Add(new LineBreak());
}

systemData[sysData.system.Name].systemNameElement.Inlines
.Add(new Run($"{OverlayCharacter.Name}"));
}
break;
case "All":
foreach (string charName in charsInSystem)
{
if (firstEntry)
{
systemData[sysData.system.Name].systemNameElement.Inlines.Add(new LineBreak());
}
systemData[sysData.system.Name].systemNameElement.Inlines.Add(new Run($"{localCharacterEntry.Key.Name}")) ;
systemData[sysData.system.Name].systemNameElement.Inlines.Add(new Run($"{charName}")) ;
firstEntry = true;
}
}

systemData[sysData.system.Name].systemNameElement.Foreground = Brushes.White;
systemData[sysData.system.Name].systemNameElement.FontSize = 10;
systemData[sysData.system.Name].systemNameElement.TextAlignment = TextAlignment.Center;
systemData[sysData.system.Name].systemNameElement.IsHitTestVisible = false;
break;
case "None":
break;
case "Number":
if (charsInSystem.Count > 0)
{
systemData[sysData.system.Name].systemNameElement.Inlines.Add(new Run($" ({charsInSystem.Count})"));
}
break;
}

systemData[sysData.system.Name].systemNameElement.Foreground = Brushes.White;
systemData[sysData.system.Name].systemNameElement.FontSize = 10;
systemData[sysData.system.Name].systemNameElement.TextAlignment = TextAlignment.Center;
systemData[sysData.system.Name].systemNameElement.IsHitTestVisible = false;

Canvas.SetLeft(systemData[sysData.system.Name].systemNameElement, leftCoord - (systemData[sysData.system.Name].systemNameElement.Width * 0.5f) + (systemData[sysData.system.Name].systemCanvasElement.Width * 0.5f));
Canvas.SetTop(systemData[sysData.system.Name].systemNameElement, topCoord + systemData[sysData.system.Name].systemCanvasElement.Height + 2);
Canvas.SetZIndex(systemData[sysData.system.Name].systemNameElement, 125);
Canvas.SetLeft(systemData[sysData.system.Name].systemNameElement, leftCoord - (systemData[sysData.system.Name].systemNameElement.Width * 0.5f) + (systemData[sysData.system.Name].systemCanvasElement.Width * 0.5f));
Canvas.SetTop(systemData[sysData.system.Name].systemNameElement, topCoord + systemData[sysData.system.Name].systemCanvasElement.Height + 2);
Canvas.SetZIndex(systemData[sysData.system.Name].systemNameElement, 125);

if (!overlay_Canvas.Children.Contains(systemData[sysData.system.Name].systemNameElement))
{
overlay_Canvas.Children.Add(systemData[sysData.system.Name].systemNameElement);
}
if (!overlay_Canvas.Children.Contains(systemData[sysData.system.Name].systemNameElement))
{
overlay_Canvas.Children.Add(systemData[sysData.system.Name].systemNameElement);
}

systemData[sysData.system.Name].canvasCoordinate = new Vector2((float)leftCoord, (float)topCoord);
Expand Down Expand Up @@ -1909,6 +1942,13 @@
individualCharacterWindows = mainWindow.MapConf.OverlayIndividualCharacterWindows;
Close();
}

if (e.PropertyName == "OverlayAdditionalCharacterNamesDisplay")
{
additionalCharacterNamesDisplay = mainWindow.MapConf.OverlayAdditionalCharacterNamesDisplay;
ClearView();
RefreshCurrentView();
}
}

/// <summary>
Expand Down
9 changes: 9 additions & 0 deletions SMT/Preferences.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@
<Label Content="Finally, Intel is historic for x seconds" />
</StackPanel>
<CheckBox Margin="0,3" IsChecked="{Binding Path=OverlayIndividualCharacterWindows}" Content="Open individual windows for each character." />
<StackPanel Orientation="Horizontal" Margin="0,2">
<Label Content="Char names on overlay: " />
<ComboBox SelectedValuePath="Content" SelectedValue="{Binding Path=OverlayAdditionalCharacterNamesDisplay}" Width="150">
<ComboBoxItem Content="All"></ComboBoxItem>
<ComboBoxItem Content="Overlay Character"></ComboBoxItem>
<ComboBoxItem Content="None"></ComboBoxItem>
<ComboBoxItem Content="Number"></ComboBoxItem>
</ComboBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel>
Expand Down
Loading