Skip to content
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
207 changes: 207 additions & 0 deletions EVEData/EveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2999,6 +2999,13 @@

ActiveSovCampaigns = new List<SOVCampaign>();

// Auto-load infrastructure upgrades if file exists
string upgradesFile = Path.Combine(SaveDataRootFolder, "InfrastructureUpgrades.txt");
if (File.Exists(upgradesFile))
{
LoadInfrastructureUpgrades(upgradesFile);
}

InitZKillFeed();

StartBackgroundThread();
Expand Down Expand Up @@ -4006,5 +4013,205 @@
catch { }
}

public void RemoveCharacter(LocalCharacter lc)

Check failure on line 4016 in EVEData/EveManager.cs

View workflow job for this annotation

GitHub Actions / build

Type 'EveManager' already defines a member called 'RemoveCharacter' with the same parameter types
{
LocalCharacters.Remove(lc);

if(LocalCharacterUpdateEvent != null)
{
LocalCharacterUpdateEvent();
}
}

/// <summary>
/// Load Infrastructure Hub Upgrades from a text file
/// Format:
/// SYSTEMNAME
/// 1 Upgrade Name Level Status
/// or (legacy format):
/// Sovereignty Hub SYSTEMNAME
/// 1 Upgrade Name Level Status
/// </summary>
public void LoadInfrastructureUpgrades(string filePath)
{
if (!File.Exists(filePath))
{
return;
}

try
{
string[] lines = File.ReadAllLines(filePath);
string currentSystem = null;

foreach (string line in lines)
{
if (string.IsNullOrWhiteSpace(line))
{
continue;
}

string trimmedLine = line.Trim();

// Check if this line starts with a digit (upgrade line)
bool isUpgradeLine = char.IsDigit(trimmedLine.FirstOrDefault());

if (!isUpgradeLine)
{
// This is a system header line
// Support both "Sovereignty Hub SYSTEMNAME" and just "SYSTEMNAME"
if (trimmedLine.StartsWith("Sovereignty Hub "))
{
currentSystem = trimmedLine.Replace("Sovereignty Hub ", "").Trim();
}
else
{
currentSystem = trimmedLine;
}

// Clear existing upgrades for this system
System sys = GetEveSystem(currentSystem);
if (sys != null)
{
sys.InfrastructureUpgrades.Clear();
}
}
else if (currentSystem != null)
{
// Parse upgrade line
string[] parts = line.Split(new[] { '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries);

if (parts.Length >= 3)
{
System sys = GetEveSystem(currentSystem);
if (sys != null)
{
InfrastructureUpgrade upgrade = new InfrastructureUpgrade();

// Parse slot number
if (int.TryParse(parts[0], out int slotNum))
{
upgrade.SlotNumber = slotNum;
}

// Parse upgrade name and level
// The upgrade name could be multiple words, and the level might be at the end
// Status is always the last word (Online/Offline)
string status = parts[parts.Length - 1];
upgrade.IsOnline = status.Equals("Online", StringComparison.OrdinalIgnoreCase);

// Check if second-to-last part is a number (level)
int levelIndex = -1;
int level = 0;
if (parts.Length >= 4 && int.TryParse(parts[parts.Length - 2], out level))
{
upgrade.Level = level;
levelIndex = parts.Length - 2;
}
else
{
upgrade.Level = 0;
levelIndex = parts.Length - 1;
}

// Build upgrade name from remaining parts
List<string> nameParts = new List<string>();
for (int i = 1; i < levelIndex; i++)
{
nameParts.Add(parts[i]);
}
upgrade.UpgradeName = string.Join(" ", nameParts);

sys.InfrastructureUpgrades.Add(upgrade);
}
}
}
}
}
catch (Exception ex)
{
// Log error if needed
}
}

/// <summary>
/// Save Infrastructure Hub Upgrades to a text file
/// </summary>
public void SaveInfrastructureUpgrades(string filePath)
{
try
{
List<string> lines = new List<string>();

foreach (System sys in Systems)
{
if (sys.InfrastructureUpgrades.Count > 0)
{
lines.Add(sys.Name);

foreach (InfrastructureUpgrade upgrade in sys.InfrastructureUpgrades.OrderBy(u => u.SlotNumber))
{
lines.Add(upgrade.ToString());
}

lines.Add(""); // Empty line between systems
}
}

File.WriteAllLines(filePath, lines);
}
catch (Exception ex)
{
// Log error if needed
}
}

/// <summary>
/// Add or update an infrastructure upgrade for a system
/// </summary>
public void SetInfrastructureUpgrade(string systemName, int slotNumber, string upgradeName, int level, bool isOnline)
{
System sys = GetEveSystem(systemName);
if (sys != null)
{
// Check if upgrade already exists in this slot
InfrastructureUpgrade existing = sys.InfrastructureUpgrades.FirstOrDefault(u => u.SlotNumber == slotNumber);

if (existing != null)
{
// Update existing
existing.UpgradeName = upgradeName;
existing.Level = level;
existing.IsOnline = isOnline;
}
else
{
// Add new
sys.InfrastructureUpgrades.Add(new InfrastructureUpgrade
{
SlotNumber = slotNumber,
UpgradeName = upgradeName,
Level = level,
IsOnline = isOnline
});
}
}
}

/// <summary>
/// Remove an infrastructure upgrade from a system
/// </summary>
public void RemoveInfrastructureUpgrade(string systemName, int slotNumber)
{
System sys = GetEveSystem(systemName);
if (sys != null)
{
InfrastructureUpgrade upgrade = sys.InfrastructureUpgrades.FirstOrDefault(u => u.SlotNumber == slotNumber);
if (upgrade != null)
{
sys.InfrastructureUpgrades.Remove(upgrade);
}
}
}
}
}
106 changes: 106 additions & 0 deletions EVEData/InfrastructureUpgrade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using System.ComponentModel;

namespace SMT.EVEData
{
/// <summary>
/// Represents an Infrastructure Hub Upgrade
/// </summary>
public class InfrastructureUpgrade : INotifyPropertyChanged
{
private int m_SlotNumber;
private string m_UpgradeName;
private int m_Level;
private bool m_IsOnline;

/// <summary>
/// Slot number (1-based)
/// </summary>
public int SlotNumber
{
get { return m_SlotNumber; }
set
{
m_SlotNumber = value;
OnPropertyChanged("SlotNumber");
}
}

/// <summary>
/// Name of the upgrade (e.g., "Major Threat Detection Array", "Cynosural Navigation")
/// </summary>
public string UpgradeName
{
get { return m_UpgradeName; }
set
{
m_UpgradeName = value;
OnPropertyChanged("UpgradeName");
}
}

/// <summary>
/// Level of the upgrade (1-3, or 0 for upgrades without levels)
/// </summary>
public int Level
{
get { return m_Level; }
set
{
m_Level = value;
OnPropertyChanged("Level");
}
}

/// <summary>
/// Whether the upgrade is online
/// </summary>
public bool IsOnline
{
get { return m_IsOnline; }
set
{
m_IsOnline = value;
OnPropertyChanged("IsOnline");
}
}

/// <summary>
/// Full display name including level if applicable
/// </summary>
public string DisplayName
{
get
{
if (Level > 0)
{
return $"{UpgradeName} {Level}";
}
return UpgradeName;
}
}

/// <summary>
/// Status text
/// </summary>
public string Status
{
get { return IsOnline ? "Online" : "Offline"; }
}

public event PropertyChangedEventHandler PropertyChanged;

protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}

public override string ToString()
{
return $"{SlotNumber}\t{DisplayName}\t{Status}";
}
}
}
8 changes: 8 additions & 0 deletions EVEData/System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public System()
Jumps = new List<string>();
SOVAllianceID = 0;
HasJumpBeacon = false;
InfrastructureUpgrades = new List<InfrastructureUpgrade>();
}

/// <summary>
Expand Down Expand Up @@ -48,6 +49,7 @@ public System(string name, long id, string region, bool station, bool iceBelt)
SOVAllianceID = 0;

Jumps = new List<string>();
InfrastructureUpgrades = new List<InfrastructureUpgrade>();
}

public enum EdenComTrigStatus
Expand Down Expand Up @@ -212,6 +214,12 @@ public enum EdenComTrigStatus
[XmlIgnoreAttribute]
public DateTime TCUVunerabliltyStart { get; set; }

/// <summary>
/// Gets or sets the list of Infrastructure Hub Upgrades for this system
/// </summary>
[XmlIgnoreAttribute]
public List<InfrastructureUpgrade> InfrastructureUpgrades { get; set; }

/// <summary>
/// Gets or sets the Systems True Security Value
/// </summary>
Expand Down
34 changes: 34 additions & 0 deletions EVEData/data/infrastructure_upgrades_example.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
L5D-ZL
1 Major Threat Detection Array 3 Online
2 Minor Threat Detection Array 2 Online

Y-CWQY
1 Major Threat Detection Array 3 Online
2 Advanced Logistics Network Online
3 Cynosural Navigation Online

EIMJ-M
1 Power Monitoring Division 1 Online
2 Major Threat Detection Array 3 Online
3 Minor Threat Detection Array 1 Offline

VQE-CN
1 Minor Threat Detection Array 2 Online
2 Major Threat Detection Array 3 Online

8KR9-5
1 Major Threat Detection Array 2 Offline
2 Minor Threat Detection Array 3 Offline
3 Nocxium Prospecting Array 3 Offline
4 Pyerite Prospecting Array 2 Online

1-NJLK
1 Supercapital Construction Facilities Offline
2 Minor Threat Detection Array 3 Online
3 Major Threat Detection Array 3 Online

G-C8QO
1 Power Monitoring Division 3 Online
2 Pyerite Prospecting Array 2 Online
3 Minor Threat Detection Array 3 Online
4 Major Threat Detection Array 2 Offline
Loading
Loading