Class StationManager
- Namespace
- RadioExt_Helper.utility
- Assembly
- RadioExt-Helper.dll
This class is responsible for managing the radio stations. It provides methods for adding and removing stations as well as their various editors and icons.
Everything to do with stations is managed here.
This class cannot be instantiated. It is a singleton.
public class StationManager : IDisposable
- Inheritance
-
StationManager
- Implements
- Inherited Members
Properties
Instance
Get the singleton instance of the StationManager class.
public static StationManager Instance { get; }
Property Value
IsEmpty
Get a value indicating whether the station manager is empty (i.e., has no stations).
public bool IsEmpty { get; }
Property Value
StationsAsBindingList
The current list of stations managed by the manager as a binding list. Auto-updates when stations are added or removed.
public BindingList<TrackableObject<Station>> StationsAsBindingList { get; }
Property Value
StationsAsList
The current list of stations managed by the manager as a list.
public List<TrackableObject<Station>> StationsAsList { get; }
Property Value
ValidArchiveExtensions
Get a list of valid archive file extensions for station icons.
public string?[] ValidArchiveExtensions { get; }
Property Value
- string[]
ValidAudioExtensions
Get a list of valid audio file extensions for song files.
public string?[] ValidAudioExtensions { get; }
Property Value
- string[]
ValidImageExtensions
Get a list of valid image file extensions for station icons.
public string?[] ValidImageExtensions { get; }
Property Value
- string[]
Methods
AddProtectedFolder(string)
Add a protected folder to the list of folders that should not be deleted during station synchronization.
public void AddProtectedFolder(string folder)
Parameters
folder
string- The path to a folder to protect.
AddStation()
Add a new, blank station to the manager. The station will have the default metadata and no songs.
The station will be added to the manager and the ID will be returned.
public Guid AddStation()
Returns
AddStation(TrackableObject<Station>, bool)
Adds a new station and editor to the manager.
public Guid AddStation(TrackableObject<Station> station, bool isOnDisk)
Parameters
station
TrackableObject<Station>- The station to add.
isOnDisk
bool- Indicates whether the station is an in-memory addition or was added from .json files on disk.
Returns
AddStation(TrackableObject<Station>, bool, string)
Adds a new station and editor to the manager. Optionally, specify the path to the station folder relative to the staging folder.
public Guid AddStation(TrackableObject<Station> station, bool isOnDisk, string pathOnDisk)
Parameters
station
TrackableObject<Station>- The station to add.
isOnDisk
bool- Indicates whether the station is an in-memory addition or was added from .json files on disk.
pathOnDisk
string- Specifies the path to the station folder relative to the staging folder.
Returns
AddStationIcon(Guid, TrackableObject<WolvenIcon>)
Add an icon to a station. Also, adds an IconEditor the internal list of editors for the station.
public bool AddStationIcon(Guid stationId, TrackableObject<WolvenIcon> icon)
Parameters
stationId
Guid- The station ID to add the icon to.
icon
TrackableObject<WolvenIcon>- The Icon to add.
Returns
- bool
true
if the icon was added successfully;false
otherwise.
AddStationIcon(Guid, TrackableObject<WolvenIcon>, bool, bool)
Add an icon to a station. Also, adds an IconEditor the internal list of editors for the station. Optionally, make the icon active and specify whether the icon is an existing icon.
public bool AddStationIcon(Guid stationId, TrackableObject<WolvenIcon> icon, bool makeActive, bool isExistingIcon)
Parameters
stationId
Guid- The station ID to add the icon to.
icon
TrackableObject<WolvenIcon>- The Icon to add.
makeActive
bool- Whether to immediately make this icon the active one for the station, de-activating other icons.
isExistingIcon
bool- Whether the icon editor should be initialized with an existing .archive file.
Returns
- bool
true
if the icon was added successfully;false
otherwise.
AddStationIconEditor(Guid?, Guid?, bool)
Add an icon editor the station based on the station ID and icon ID.
public void AddStationIconEditor(Guid? stationId, Guid? iconId, bool isExistingArchive)
Parameters
stationId
Guid?- The station to add an editor of, by id.
iconId
Guid?- The icon to associate with the editor, by id.
isExistingArchive
bool- Whether the editor should be initialized with an existing .archive file.
ChangeStationStatus(Guid, bool)
Set the station's active status to the new status and raise the StationUpdated event.
public void ChangeStationStatus(Guid stationId, bool newStatus)
Parameters
stationId
Guid- The ID of the station to change the status of.
newStatus
bool- The new status of the station:
true
= enabled;false
= disabled.
CheckForDuplicateStation(Guid)
Checks for duplicate station names and gets an updated name if a duplicate is found.
public string CheckForDuplicateStation(Guid stationId)
Parameters
stationId
Guid- The ID of the station to check.
Returns
- string
- The updated station name.
CheckForMissingSongs()
Get a dictionary of stations with a pair indicating if the station has missing songs and the count of missing songs.
public Dictionary<Guid, Pair<bool, int>> CheckForMissingSongs()
Returns
- Dictionary<Guid, Pair<bool, int>>
- A dictionary where the key is the station's ID and the value is a pair containing whether the station is missing songs and the count of missing songs.
CheckGameForExistingStations(string, string)
Get the count of stations that exist in the game's radios folder but do not exist in the staging folder.
public static int CheckGameForExistingStations(string stagingPath, string gameBasePath)
Parameters
stagingPath
string- The path to the staging directory.
gameBasePath
string- The path to the game's base path where the
radios
directory is derived from.
Returns
- int
- A non-zero integer if there are station's in the game's radios folder that are not in the staging folder;
0
otherwise.
CheckPendingSave()
Get a dictionary of station ids with a value indicating if the station has pending saves.
public Dictionary<Guid, bool> CheckPendingSave()
Returns
- Dictionary<Guid, bool>
- A dictionary where the key is the station's ID and the value indicates if the station is pending save.
CheckStatus(Guid)
Check the pending save status of the station with the specified ID.
public bool CheckStatus(Guid stationId)
Parameters
stationId
Guid- The ID of the station to check.
Returns
- bool
true
if there are pending changes;false
otherwise.
ClearProtectedFolders()
Clear all protected folders from the list of folders that should not be deleted during station synchronization.
public void ClearProtectedFolders()
ClearStations()
Clear all stations and their editors from the manager. Does not delete the folders in the staging directory.
public void ClearStations()
ClearStations(bool)
Clears all stations and their editors from the manager. Optionally, delete the folders in the staging directory.
public void ClearStations(bool deleteFoldersFromStaging)
Parameters
deleteFoldersFromStaging
bool- Indicates if the folders in the staging directory should also be deleted.
CopyStationIcon(Guid, Guid, TrackableObject<WolvenIcon>)
Copy an existing icon from a reference station to another station.
public Guid? CopyStationIcon(Guid stationId, Guid referenceStationId, TrackableObject<WolvenIcon> icon)
Parameters
stationId
Guid- The station ID to which the icon should be copied.
referenceStationId
Guid- The station ID from which the icon is being copied.
icon
TrackableObject<WolvenIcon>- The WIG.Lib.Models.WolvenIcon to copy.
Returns
- Guid?
- The internal id of the new copied icon;
null
if the icon couldn't be copied.
CopyStationIcon(Guid, Guid, TrackableObject<WolvenIcon>, bool)
Copies an existing icon from a reference station to another station. Optionally, make the copied icon active.
public Guid? CopyStationIcon(Guid stationId, Guid referenceStationId, TrackableObject<WolvenIcon> icon, bool makeActive)
Parameters
stationId
Guid- The station ID to which the icon should be copied.
referenceStationId
Guid- The station ID from which the icon is being copied.
icon
TrackableObject<WolvenIcon>- The WIG.Lib.Models.WolvenIcon to copy.
makeActive
bool- Whether to make this copied icon active for the current station.
Returns
- Guid?
- The internal id of the new copied icon;
null
if the icon couldn't be copied.
DisableStationIcon(Guid, Guid)
Disable a specific icon for a station.
public void DisableStationIcon(Guid stationId, Guid iconId)
Parameters
Dispose()
Disposes of the station manager and clears all stations.
public virtual void Dispose()
EnableStationIcon(Guid, Guid)
Enable a specific icon for a station. An icon can only have one active icon at a time.
public void EnableStationIcon(Guid stationId, Guid iconId)
Parameters
EnsureDisplayNameFormat(TrackableObject<Station>)
Ensures the display name contains the station's FM number at the beginning of its name like so:
00.00 Station Name
public float EnsureDisplayNameFormat(TrackableObject<Station> station)
Parameters
station
TrackableObject<Station>- The station to ensure the display name of.
Returns
- float
- The parsed FM number from the original display name string; or, the original FM number if the same.
EnsureDisplayNameFormat(TrackableObject<Station>, float?)
Ensures the display name contains the station's FM number at the beginning of its name like so:
00.00 Station Name
public float EnsureDisplayNameFormat(TrackableObject<Station> station, float? optionalFmVal)
Parameters
station
TrackableObject<Station>- The station to ensure the display name of.
optionalFmVal
float?- The FM number to ensure is in front of the station name. If null, the default FM value will be used instead.
Returns
- float
- The parsed FM number from the original display name string; or, the original FM number if the same.
ExtractStationArchive(string)
Extracts the contents of a station archive file (.zip or .rar) to a temporary directory.
public static (string tempDir, string songDir) ExtractStationArchive(string filePath)
Parameters
filePath
string- The path to a .zip or .rar file containing a station's files.
Returns
- (string tempDir, string songDir)
- A tuple containing the temporary station directory and the song directory for the station.
GetStation(Guid?)
Get the station and editors for the specified station ID.
public Pair<TrackableObject<Station>, List<IEditor>>? GetStation(Guid? stationId)
Parameters
stationId
Guid?- The ID of the station to get.
Returns
- Pair<TrackableObject<Station>, List<IEditor>>?
- A pair where the key is the TrackableObject<T> and the value is
the list of IEditors associated with the station;
or
null
if thestationId
did not exist in the manager.
GetStationActiveIcon(Guid?)
Gets the station icon for the specified station ID.
public TrackableObject<WolvenIcon>? GetStationActiveIcon(Guid? stationId)
Parameters
stationId
Guid?- The station to get the icon of, by id.
Returns
- TrackableObject<WolvenIcon>
- The active Icon of the station or
null
if no active icons.
GetStationCount()
Gets the station count string, formatted with the enabled station count and localized.
public string GetStationCount()
Returns
- string
- A formatted string showing enabled and disabled station counts:
Enabled Stations: {0} / {1}
GetStationEditor(Guid?)
Get the station editor for the specified station ID.
public StationEditor? GetStationEditor(Guid? stationId)
Parameters
stationId
Guid?- The station to get the editor of, by id.
Returns
- StationEditor
- The station editor for the specified station id or
null
if no editor exists in the manager.
GetStationIcon(Guid, Guid)
Get the icon associated with the station by id.
public TrackableObject<WolvenIcon>? GetStationIcon(Guid stationId, Guid iconId)
Parameters
stationId
Guid- The id of the station to get the icon of.
iconId
Guid- The id of the icon to retrieve from the station.
Returns
- TrackableObject<WolvenIcon>
- The TrackableObject<T> corresponding to the id or
null
if no icon existed with the id.
GetStationIconEditor(Guid?, Guid?)
Gets the icon editor for the specified station ID and icon ID.
public IconEditor? GetStationIconEditor(Guid? stationId, Guid? iconId)
Parameters
stationId
Guid?- The station to get the editor of, by id.
iconId
Guid?- The icon associated with the editor, by id.
Returns
- IconEditor
- The IconEditor for the specified station and icon or
null
if the editor could not be found in the manager.
GetStationPath(Guid?)
Get the relative path in the staging folder to the station with the specified ID.
public string GetStationPath(Guid? stationId)
Parameters
stationId
Guid?- The ID of the station to get the relative path of.
Returns
ImportStationFromArchive(string)
Import a station from an archive file. The station will be extracted and added to the manager.
public Guid? ImportStationFromArchive(string filePath)
Parameters
filePath
string- The path to the .zip file containing the radio station.
Returns
IsIconLinkedToOtherStations(Guid?, Guid)
Checks if an icon is linked to other stations.
public bool IsIconLinkedToOtherStations(Guid? iconId, Guid excludingStationId)
Parameters
iconId
Guid?- The ID of the icon to check.
excludingStationId
Guid- The station ID to exclude from the check.
Returns
- bool
true
if the icon is linked to other stations;false
otherwise.
IsNewStation(Guid)
Get a value indicating if the station with the specified ID is a new station added during the current session.
public bool IsNewStation(Guid stationId)
Parameters
stationId
Guid- The ID of the station to check.
Returns
- bool
true
if the station is new;false
otherwise.
IsProtectedFolder(string)
Get a value indicating if the specified folder is protected from deletion during station synchronization.
public bool IsProtectedFolder(string folder)
Parameters
folder
string- The path to a folder.
Returns
- bool
true
if the folder is protected.false
, otherwise.
LoadStationFromDirectory(string?, string?, bool)
Loads a station from the specified directory into the manager.
This method will not clear existing stations, unlike LoadStations(string)
and is used to load a single station from a single directory, not from the staging directory.
public Guid? LoadStationFromDirectory(string? directory, string? songDirectory, bool treatAsNewStation)
Parameters
directory
string- The directory to load the station from.
songDirectory
string- The song directory to load the station's songs from.
treatAsNewStation
bool- Indicates whether the station should be treated as a new station (i.e., it is not present in the staging directory already.
Returns
LoadStations(string)
Loads stations from the specified directory into the manager, clearing any existing stations.
public void LoadStations(string directory)
Parameters
directory
string- The directory to load stations from.
OnStationUpdated(Guid)
Occurs when a station is updated.
public void OnStationUpdated(Guid stationId)
Parameters
RemoveAllStationIcons(Guid)
Remove all icons from a station, including the associated IconEditors. Does not delete the icon files from disk.
public bool RemoveAllStationIcons(Guid stationId)
Parameters
stationId
Guid- The station ID to remove all icons from.
Returns
- bool
true
if all icons were removed successfully;false
otherwise.
RemoveAllStationIcons(Guid, bool)
Remove all icons from a station, including the associated IconEditors. Optionally, delete the icon files from disk.
public bool RemoveAllStationIcons(Guid stationId, bool deleteFiles)
Parameters
stationId
Guid- The station ID to remove all icons from.
deleteFiles
bool- Indicates whether to delete the Icon files from disk.
Returns
- bool
true
if all icons were removed successfully;false
otherwise.
RemoveProtectedFolder(string)
Remove a protected folder from the list of folders that should not be deleted during station synchronization.
public void RemoveProtectedFolder(string folder)
Parameters
folder
string- The path to a folder to remove from protection.
RemoveStation(Guid)
Removes a station, and it's editors from the manager.
public void RemoveStation(Guid stationId)
Parameters
stationId
Guid- The station to remove, by ID.
RemoveStationIcon(Guid, TrackableObject<WolvenIcon>)
Remove an icon from a station, including the associated IconEditor.
public bool RemoveStationIcon(Guid stationId, TrackableObject<WolvenIcon> icon)
Parameters
stationId
Guid- The station ID to remove the icon from.
icon
TrackableObject<WolvenIcon>- The WIG.Lib.Models.WolvenIcon to remove.
Returns
- bool
true
if the icon was removed successfully;false
otherwise.
RemoveStationIcon(Guid, TrackableObject<WolvenIcon>, bool)
Remove an icon from a station, including the associated IconEditor. Optionally, delete the icon files from disk.
public bool RemoveStationIcon(Guid stationId, TrackableObject<WolvenIcon> icon, bool deleteFiles)
Parameters
stationId
Guid- The station ID to remove the icon from.
icon
TrackableObject<WolvenIcon>- The WIG.Lib.Models.WolvenIcon to remove.
deleteFiles
bool- Indicates whether to delete the icon files from disk.
Returns
- bool
true
if the icon was removed successfully;false
otherwise.
RemoveStationIconEditor(Guid?, Guid?)
Remove the icon editor for the specified station ID and icon ID.
public void RemoveStationIconEditor(Guid? stationId, Guid? iconId)
Parameters
stationId
Guid?- The station to remove the editor from, by id.
iconId
Guid?- The icon to remove the editor of, by id.
ResetNewStations()
Clear the list of new stations added during the current session.
public void ResetNewStations()
StopAllMusicPlayers()
Stops all music players for all stations in the manager.
public void StopAllMusicPlayers()
SynchronizeStationsAsync(string, string)
Sync stations from the game's radios folder to the staging folder.
This will copy all stations and songs from the game's radios folder to the staging folder
if they do not exist and update them if they are newer.
public Task SynchronizeStationsAsync(string stagingPath, string gameBasePath)
Parameters
stagingPath
string- The path to the staging directory.
gameBasePath
string- The path to the game's base path where the
radios
directory is derived from.
Returns
- Task
- A task representing the asynchronous operation.
TranslateEditors()
Translates all editors in the manager to the current language.
public void TranslateEditors()
Events
StationAdded
Event that is raised when a station is added to the manager. Event data is the station ID.
public event EventHandler<Guid>? StationAdded
Event Type
StationImported
Event that is raised when a station is imported into the manager. Event data is the station ID.
public event EventHandler<List<Guid?>>? StationImported
Event Type
- EventHandler<List<Guid?>>
StationNameDuplicate
Event that is raised when a station name is found to be a duplicate. Event data is a tuple with the station ID and the updated name.
public event EventHandler<(Guid stationId, string updatedName)>? StationNameDuplicate
Event Type
StationRemoved
Event that is raised when a station is removed from the manager. Event data is the station ID.
public event EventHandler<Guid>? StationRemoved
Event Type
StationUpdated
Event that is raised when a station is updated in the manager. Event data is the station ID.
public event EventHandler<Guid>? StationUpdated
Event Type
StationsCleared
Event that is raised when all stations are cleared from the manager.
public event EventHandler? StationsCleared
Event Type
StationsSynchronized
Event that is raised when stations have finished synchronizing from the game's radios folder to staging.
Event data is a flag indicating success.
public event Action<bool>? StationsSynchronized
Event Type
SyncProgressChanged
Event that is raised when the synchronization progress changes. Event data is the current progress percentage.
public event Action<int>? SyncProgressChanged
Event Type
SyncStatusChanged
Event that is raised when the synchronization status changes. Event data is a message describing the status.
public event Action<string>? SyncStatusChanged