Skip to content

Commit

Permalink
Merge pull request #139 from pilot538/master
Browse files Browse the repository at this point in the history
Feature: Add player alerting ability for intel channels
  • Loading branch information
Slazanger authored Mar 6, 2024
2 parents 69730b0 + 4bab97a commit 0cc7f9f
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
28 changes: 28 additions & 0 deletions EVEData/EveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ public static EveManager Instance
/// </summary>
public List<string> IntelIgnoreFilters { get; set; }

/// <summary>
/// Gets or sets the current list of alerting intel market for intel (eg "pilot538 Maken")
/// </summary>
public List<string> IntelAlertFilters { get; set; }

/// <summary>
/// Gets or sets the Name to System dictionary
/// </summary>
Expand Down Expand Up @@ -1854,6 +1859,7 @@ public void SaveData()
File.WriteAllLines(Path.Combine(SaveDataRootFolder, "IntelChannels.txt"), IntelFilters);
File.WriteAllLines(Path.Combine(SaveDataRootFolder, "IntelClearFilters.txt"), IntelClearFilters);
File.WriteAllLines(Path.Combine(SaveDataRootFolder, "IntelIgnoreFilters.txt"), IntelIgnoreFilters);
File.WriteAllLines(Path.Combine(SaveDataRootFolder, "IntelAlertFilters.txt"), IntelAlertFilters);
File.WriteAllLines(Path.Combine(SaveDataRootFolder, "CynoBeacons.txt"), beaconsToSave);
}

Expand Down Expand Up @@ -1932,6 +1938,28 @@ public void SetupIntelWatcher()
IntelIgnoreFilters.Add("Status");
}

IntelAlertFilters = new List<string>();
string intelAlertFileFilter = Path.Combine(SaveDataRootFolder, "IntelAlertFilters.txt");

if (File.Exists(intelAlertFileFilter))
{
StreamReader file = new StreamReader(intelAlertFileFilter);
string line;
while ((line = file.ReadLine()) != null)
{
line = line.Trim();
if (!string.IsNullOrEmpty(line))
{
IntelAlertFilters.Add(line);
}
}
}
else
{
// default, alert on nothing
IntelAlertFilters.Add("");
}

intelFileReadPos = new Dictionary<string, int>();

if (string.IsNullOrEmpty(EVELogFolder) || !Directory.Exists(EVELogFolder))
Expand Down
22 changes: 21 additions & 1 deletion SMT/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,16 @@ public MainWindow()
IntelData idtwo = new IntelData("[00:00] blah.... > blah", "System");
idtwo.IntelString = "Intel Filters : " + String.Join(",", EVEManager.IntelFilters);

IntelData idthree = new IntelData("[00:00] blah... > blah", "System");
idthree.IntelString = "Intel Alert Filters : " + String.Join(", ", EVEManager.IntelAlertFilters);

IntelData idfour = new IntelData("[00:00] blah... > blah", "System");
idfour.IntelString = "Intel Alert Filters Count: " + EVEManager.IntelAlertFilters.Count();

IntelCache.Add(id);
IntelCache.Add(idtwo);
IntelCache.Add(idthree);
IntelCache.Add(idfour);

MapConf.CurrentEveLogFolderLocation = EVEManager.EVELogFolder;

Expand Down Expand Up @@ -1167,7 +1175,7 @@ private void OnIntelUpdated(List<IntelData> idl)
return;
}

if (MapConf.PlayIntelSound || MapConf.FlashWindow)
if (MapConf.PlayIntelSound || MapConf.FlashWindow || MapConf.PlayIntelSoundOnPlayer)
{
if (MapConf.PlaySoundOnlyInDangerZone || MapConf.FlashWindowOnlyInDangerZone)
{
Expand Down Expand Up @@ -1196,6 +1204,18 @@ private void OnIntelUpdated(List<IntelData> idl)
}
}
}
if (MapConf.PlayIntelSoundOnPlayer)
{
// Check if the intel contains a player we should alert on
foreach (string alertName in EVEManager.IntelAlertFilters)
{
if (id.RawIntelString.Contains(alertName))
{
playSound = playSound || MapConf.PlayIntelSoundOnPlayer;
break;
}
}
}
else
{
playSound = MapConf.PlayIntelSound;
Expand Down
4 changes: 4 additions & 0 deletions SMT/MapConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ public bool PlayIntelSound
}
}

[Category("Intel")]
[DisplayName("Warning on Player")]
public bool PlayIntelSoundOnPlayer { get; set; }

[Category("Intel")]
[DisplayName("Warning On Unknown")]
public bool PlayIntelSoundOnUnknown { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions SMT/Preferences.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<Grid Background="{DynamicResource ButtonBorder}" Height="Auto" Width="Auto" HorizontalAlignment="Left" VerticalAlignment="Top">
<DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TabControl x:Name="tabControl" DockPanel.Dock="Top">
<TabControl x:Name="tabControl" DockPanel.Dock="Top" Height="487">
<TabItem Header="General">
<Grid>
<Grid.ColumnDefinitions>
Expand Down Expand Up @@ -152,6 +152,7 @@
<StackPanel>

<CheckBox IsChecked="{Binding Path=PlayIntelSound}" Margin="0,2">Warning Sound</CheckBox>
<CheckBox IsChecked="{Binding Path=PlayIntelSoundOnPlayer}" Margin="0,2">Warning Sound on Player</CheckBox>
<CheckBox IsChecked="{Binding Path=FlashWindow}" Margin="0,2" Content="Flash Window" />
<StackPanel Orientation="Vertical" Margin="0,2">
<Label Content="Warning Sound Volume" />
Expand Down Expand Up @@ -193,7 +194,7 @@
</StackPanel>

<StackPanel Grid.Column="1">
<GroupBox Margin="4" Height="auto">
<GroupBox Margin="4" Height="453">

<StackPanel Orientation="Vertical">
<Label>Channel Filters</Label>
Expand All @@ -202,6 +203,8 @@
<TextBox Width="271" Height="80" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=EM.IntelClearFilters, Converter={StaticResource stringJoiner}, Mode=TwoWay}" TextWrapping="Wrap" AcceptsReturn="True" />
<Label>Ignore Filters</Label>
<TextBox Width="271" Height="80" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=EM.IntelIgnoreFilters, Converter={StaticResource stringJoiner}, Mode=TwoWay}" TextWrapping="Wrap" AcceptsReturn="True" />
<Label Content="Alert Filters"/>
<TextBox Width="271" Height="80" Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}, Path=EM.IntelAlertFilters, Converter={StaticResource stringJoiner}, Mode=TwoWay}" TextWrapping="Wrap" AcceptsReturn="True" />
</StackPanel>
</GroupBox>
</StackPanel>
Expand Down

0 comments on commit 0cc7f9f

Please sign in to comment.