2022-12-02 11:03:28 +01:00
|
|
|
using CommonHelpers;
|
|
|
|
|
|
|
|
|
|
namespace SteamController.Managers
|
|
|
|
|
{
|
|
|
|
|
public sealed class SharedDataManager : Manager
|
|
|
|
|
{
|
|
|
|
|
SharedData<SteamControllerSetting> sharedData = SharedData<SteamControllerSetting>.CreateNew();
|
|
|
|
|
|
|
|
|
|
public override void Tick(Context context)
|
|
|
|
|
{
|
|
|
|
|
if (sharedData.GetValue(out var value) && value.DesiredProfile != "")
|
|
|
|
|
{
|
|
|
|
|
context.SelectProfile(value.DesiredProfile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sharedData.SetValue(new SteamControllerSetting()
|
|
|
|
|
{
|
|
|
|
|
CurrentProfile = context.CurrentProfile?.Name ?? "",
|
2022-12-03 20:32:25 +01:00
|
|
|
SelectableProfiles = SelectableProfiles(context).JoinWithN(),
|
2022-12-02 11:03:28 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerable<String> SelectableProfiles(Context context)
|
|
|
|
|
{
|
|
|
|
|
return context.Profiles.
|
|
|
|
|
Where((profile) => profile.Selected(context) || profile.Visible).
|
|
|
|
|
Select((profile) => profile.Name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|