Skip to content

Commit

Permalink
Merge pull request #155 from pstarn/feature/anom-panel-improvements
Browse files Browse the repository at this point in the history
Anomalies panel improvements
  • Loading branch information
Slazanger authored Apr 7, 2024
2 parents d08c761 + 4bc99be commit 1954553
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 91 deletions.
4 changes: 2 additions & 2 deletions EVEData/Anom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public enum SignatureType
public string Type { get; set; }

/// <summary>
/// To String
/// Convert to string, keeping the in-game format so that the string can be imported back into SMT
/// </summary>
public override string ToString() => Signature + " " + Type + " " + Name;
public override string ToString() => Signature + "\t" + "Cosmic Signature" + "\t" + Type + "\t" + Name + "\t\t";
}
}
110 changes: 46 additions & 64 deletions EVEData/AnomData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,82 +40,64 @@ public AnomData()
/// Update the AnomData from the string (usually the clipboard)
/// </summary>
/// <param name="pastedText">raw Anom strings</param>
public void UpdateFromPaste(string pastedText)
/// <returns>HashSet of anom IDs present in the dictionary but missing from the pasted text</returns>
public HashSet<string> UpdateFromPaste(string pastedText)
{
bool validPaste = false;
List<string> itemsToKeep = new List<string>();
HashSet<string> signaturesPresent = new HashSet<string>();

string[] pastelines = pastedText.Split('\n');
foreach (string line in pastelines)
{
// split on tabs
string[] words = line.Split('\t');
if (words.Length == 6)
{
// only care about "Cosmic Signature"
if (CosmicSignatureTags.Contains(words[1]))
{
validPaste = true;

string sigID = words[0];
string sigType = words[2];
string sigName = words[3];

if (string.IsNullOrEmpty(sigType))
{
sigType = "Unknown";
}

itemsToKeep.Add(sigID);

// valid sig
if (Anoms.ContainsKey(sigID))
{
// updating an existing one
Anom an = Anoms[sigID];
if (an.Type == "Unknown")
{
an.Type = sigType;
}

if (!string.IsNullOrEmpty(sigName))
{
an.Name = sigName;
}
}
else
{
Anom an = new Anom();
an.Signature = sigID;
an.Type = sigType;

if (!string.IsNullOrEmpty(sigName))
{
an.Name = sigName;
}

Anoms.Add(sigID, an);
}
}
}
}

// if we had a valid paste dump any items we didnt reference, brute force scan and remove.. come back to this later..
if (validPaste)
{
List<string> toRemove = new List<string>();
foreach (string an in Anoms.Keys.ToList())
if (words.Length != 6)
continue;

// only care about "Cosmic Signature"
if (!CosmicSignatureTags.Contains(words[1]))
continue;

string sigID = words[0];
string sigType = words[2];
string sigName = words[3];

if (string.IsNullOrEmpty(sigType))
sigType = "Unknown";

signaturesPresent.Add(sigID);

if (Anoms.ContainsKey(sigID))
{
if (!itemsToKeep.Contains(an))
{
toRemove.Add(an);
}
}
// update an existing signature
Anom an = Anoms[sigID];

foreach (string s in toRemove)
if (an.Type == "Unknown")
an.Type = sigType;

if (!string.IsNullOrEmpty(sigName))
an.Name = sigName;
}
else
{
Anoms.Remove(s);
// add a new signature
Anom an = new Anom();
an.Signature = sigID;
an.Type = sigType;

if (!string.IsNullOrEmpty(sigName))
an.Name = sigName;

Anoms.Add(sigID, an);
}
}

// find existing signatures that are missing from the paste
var signaturesMissing = Anoms.Where(kvp => !signaturesPresent.Contains(kvp.Value.Signature))
.Select(kvp => kvp.Key)
.ToHashSet();

return signaturesMissing;
}
}
}
62 changes: 44 additions & 18 deletions SMT/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<local:ZKBBackgroundConverter x:Key="zkbBGConverter" />
<local:ZKBForegroundConverter x:Key="zkbBGFConverter" />
<local:TimeSpanConverter x:Key="timeSpanConverter" />
<local:TimeSinceConverter x:Key="TimeSinceConverter" />

<ObjectDataProvider x:Key="navigationEnumData" MethodName="GetValues" ObjectType="{x:Type System:Enum}">
<ObjectDataProvider.MethodParameters>
Expand Down Expand Up @@ -114,43 +115,68 @@
<xcadl:LayoutAnchorGroup>

<xcadl:LayoutAnchorable Title="Anoms" CanClose="False" CanAutoHide="True" CanHide="False" ContentId="AnomsContentID" AutoHideMinHeight="200" AutoHideMinWidth="280" x:Name="avlpAnoms">
<Grid x:Name="MainAnomGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid x:Name="MainAnomGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="60" />
<RowDefinition Height="auto" />
<RowDefinition Height="*" />
<RowDefinition Height="26" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0">
<Button x:Name="btnClearAnomList" Content="Clear" Click="btnClearAnomList_Click" />
<Label Content="{Binding ANOMManager.ActiveSystem.SystemName}" FontSize="18" FontWeight="Bold" />
</StackPanel>

<DataGrid x:Name="AnomSigList" Grid.Row="1" AreRowDetailsFrozen="True" AutoGenerateColumns="False" ItemsSource="{Binding ANOMManager.ActiveSystem.Anoms.Values}" HeadersVisibility="Column">

<DataGrid Grid.Row="1" x:Name="AnomSigList" Focusable="True" AreRowDetailsFrozen="True" AutoGenerateColumns="False" ItemsSource="{Binding ANOMManager.ActiveSystem.Anoms.Values}" HeadersVisibility="Column" IsReadOnly="True" GridLinesVisibility="Horizontal" Margin="0, 0, 0, 8" PreviewMouseDown="AnomSigList_PreviewMouseDown" PreviewKeyDown="AnomSigList_PreviewKeyDown">
<DataGrid.Resources>
<SolidColorBrush x:Key="SelectedBackgroundColor" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
<SolidColorBrush x:Key="SelectedForegroundColor" Color="{DynamicResource {x:Static SystemColors.HighlightTextColorKey}}" />
</DataGrid.Resources>
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">

<Setter Property="BorderThickness" Value="0" />
<Style.Triggers>
<DataTrigger Binding="{Binding Type}" Value="Unknown">
<Setter Property="Background" Value="Red" />
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Wormhole">
<Setter Property="Foreground" Value="DeepSkyBlue" />
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Relic Site">
<Setter Property="Foreground" Value="Gold" />
</DataTrigger>
<DataTrigger Binding="{Binding State}" Value="State2">
<Setter Property="Background" Value="Green" />
<DataTrigger Binding="{Binding Type}" Value="Data Site">
<Setter Property="Foreground" Value="LightBlue" />
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Combat Site">
<Setter Property="Foreground" Value="Tomato" />
</DataTrigger>
<DataTrigger Binding="{Binding Type}" Value="Gas Site">
<Setter Property="Foreground" Value="LightGreen" />
</DataTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{StaticResource SelectedBackgroundColor}" />
<Setter Property="Foreground" Value="{StaticResource SelectedForegroundColor}" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>

<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent" />
</Style>
</DataGrid.RowStyle>
<DataGrid.Columns>
<DataGridTextColumn Header="SIG" Binding="{Binding Signature}" Width="*" />

<DataGridTextColumn Header="Type" Binding="{Binding Type}" Width="*" />
<DataGridTextColumn Header="SIG" Binding="{Binding Signature}" Width="60" />
<DataGridTextColumn Header="Type" Binding="{Binding Type}" Width="75" />
<DataGridTextColumn Header="Name" Binding="{Binding Name}" Width="*" />
<DataGridTextColumn Header="Since" Binding="{Binding TimeFound, Converter={StaticResource TimeSinceConverter}}" Width="Auto" />
</DataGrid.Columns>
</DataGrid>
<StackPanel Grid.Row="2">
<Button x:Name="btnUpdateAnomList" Content="Update from Clipboard" Click="btnUpdateAnomList_Click" />
</StackPanel>
<UniformGrid Grid.Row="2" Columns="2" Margin="8,0,8,8">
<Button x:Name="btnUpdateAnomList" Content="Update from Clipboard" Click="btnUpdateAnomList_Click" Margin="0,0,4,0" Height="32"/>
<Button x:Name="btnDeleteSelectedAnoms" Content="Delete Selected" Click="btnDeleteSelectedAnoms_Click" Margin="4,0,0,0" Height="32" />
</UniformGrid>
<Button Grid.Row="3" x:Name="btnClearAnomList" Content="Clear" Click="btnClearAnomList_Click" Margin="8,0,8,8" Height="32" />
</Grid>
</xcadl:LayoutAnchorable>

Expand Down
Loading

0 comments on commit 1954553

Please sign in to comment.