mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-03-06 21:13:55 +01:00
Data sharing is part of Manager
This commit is contained in:
parent
33f9e8581f
commit
57b36c7e53
|
|
@ -27,12 +27,11 @@ namespace SteamController
|
|||
Managers = {
|
||||
new Managers.ProcessManager(),
|
||||
new Managers.SteamManager(),
|
||||
new Managers.ProfileSwitcher()
|
||||
new Managers.ProfileSwitcher(),
|
||||
new Managers.SharedDataManager()
|
||||
}
|
||||
};
|
||||
|
||||
SharedData<SteamControllerSetting> sharedData = SharedData<SteamControllerSetting>.CreateNew();
|
||||
|
||||
public Controller()
|
||||
{
|
||||
Instance.RunOnce(TitleWithVersion, "Global\\SteamController");
|
||||
|
|
@ -130,24 +129,9 @@ namespace SteamController
|
|||
context.Start();
|
||||
}
|
||||
|
||||
private void SharedData_Update()
|
||||
{
|
||||
if (sharedData.GetValue(out var value) && value.DesiredProfile != "")
|
||||
{
|
||||
context.SelectProfile(value.DesiredProfile);
|
||||
}
|
||||
|
||||
sharedData.SetValue(new SteamControllerSetting()
|
||||
{
|
||||
CurrentProfile = context.CurrentProfile?.Name ?? "",
|
||||
SelectableProfiles = context.Profiles.Where((profile) => profile.Selected(context) || profile.Visible).JoinWithN((profile) => profile.Name),
|
||||
});
|
||||
}
|
||||
|
||||
private void ContextStateUpdate_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
context.Tick();
|
||||
SharedData_Update();
|
||||
|
||||
var isDesktop = context.CurrentProfile?.IsDesktop ?? false;
|
||||
|
||||
|
|
|
|||
30
SteamController/Managers/SharedDataManager.cs
Normal file
30
SteamController/Managers/SharedDataManager.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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 ?? "",
|
||||
SelectableProfiles = SelectableProfiles(context).JoinWith0(),
|
||||
});
|
||||
}
|
||||
|
||||
private IEnumerable<String> SelectableProfiles(Context context)
|
||||
{
|
||||
return context.Profiles.
|
||||
Where((profile) => profile.Selected(context) || profile.Visible).
|
||||
Select((profile) => profile.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue