Skip to content
Draft
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
25 changes: 18 additions & 7 deletions source/Playnite.FullscreenApp/Controls/SettingsSections/Input.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@
<pctrls:CheckBoxEx x:Name="ToggleGuideFocus"
IsEnabled="{Binding IsChecked, ElementName=ToggleControllerInput}"
Content="{DynamicResource LOCSettingsRefocusOnGuidButton}"/>
<pctrls:CheckBoxEx x:Name="ToggleControllerInput"
Content="{DynamicResource LOCSettingsXInputProcessing}"
Tag="{DynamicResource LOCSettingsXInputProcessingDescription}"/>
<StackPanel Name="StackControllers" Margin="50,0,0,0"
IsEnabled="{Binding IsChecked, ElementName=ToggleControllerInput}" />
</StackPanel>
</local:SettingsSectionControl>
<pctrls:CheckBoxEx x:Name="ToggleControllerInput"
Content="{DynamicResource LOCSettingsXInputProcessing}"
Tag="{DynamicResource LOCSettingsXInputProcessingDescription}"/>
<StackPanel Name="StackControllers" Margin="50,0,0,0"
IsEnabled="{Binding IsChecked, ElementName=ToggleControllerInput}" />
<pctrls:CheckBoxEx x:Name="ToggleLanPartyMode"
Content="{DynamicResource LOCSettingsLanPartyMode}"
Tag="{DynamicResource LOCSettingsLanPartyModeDescription}"/>
<pctrls:CheckBoxEx x:Name="ToggleDisableTaskManager"
IsEnabled="{Binding IsChecked, ElementName=ToggleLanPartyMode}"
Content="{DynamicResource LOCSettingsLanPartyDisableTaskManager}" />
<pctrls:ButtonEx x:Name="ButtonSetLanPartyPassword"
Margin="50,5,0,0"
HorizontalAlignment="Left"
Click="ButtonSetLanPartyPassword_Click"
Content="{DynamicResource LOCSettingsLanPartySetPassword}" />
</StackPanel>
</local:SettingsSectionControl>
138 changes: 103 additions & 35 deletions source/Playnite.FullscreenApp/Controls/SettingsSections/Input.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Playnite.Common;
using Playnite.FullscreenApp.ViewModels;
using System;
using Playnite.Common;
using Playnite.FullscreenApp.Security;
using Playnite.FullscreenApp.ViewModels;
using Playnite.FullscreenApp.Windows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -22,23 +24,25 @@ namespace Playnite.FullscreenApp.Controls.SettingsSections
/// <summary>
/// Interaction logic for Visuals.xaml
/// </summary>
public partial class Input : SettingsSectionControl
{
private FullscreenApplication app;
public partial class Input : SettingsSectionControl
{
private FullscreenApplication app;
private FullscreenAppViewModel mainModel;

public Input()
{
InitializeComponent();
}

public Input(FullscreenAppViewModel mainModel)
{
InitializeComponent();

BindingTools.SetBinding(
ToggleMouseCursor,
ToggleButton.IsCheckedProperty,
mainModel.AppSettings.Fullscreen,
public Input(FullscreenAppViewModel mainModel)
{
InitializeComponent();
this.mainModel = mainModel;

BindingTools.SetBinding(
ToggleMouseCursor,
ToggleButton.IsCheckedProperty,
mainModel.AppSettings.Fullscreen,
nameof(FullscreenSettings.HideMouserCursor),
BindingMode.TwoWay,
UpdateSourceTrigger.PropertyChanged);
Expand Down Expand Up @@ -71,17 +75,35 @@ public Input(FullscreenAppViewModel mainModel)
ToggleGuideFocus,
ToggleButton.IsCheckedProperty,
mainModel.AppSettings.Fullscreen,
nameof(FullscreenSettings.GuideButtonFocus),
BindingMode.TwoWay,
UpdateSourceTrigger.PropertyChanged);

app = mainModel.App as FullscreenApplication;
if (app.GameController != null)
{
LoadControllers();
app.GameController.ControllersChanged += GameController_ControllersChanged;
}
}
nameof(FullscreenSettings.GuideButtonFocus),
BindingMode.TwoWay,
UpdateSourceTrigger.PropertyChanged);

BindingTools.SetBinding(
ToggleLanPartyMode,
ToggleButton.IsCheckedProperty,
mainModel.AppSettings.Fullscreen,
nameof(FullscreenSettings.EnableLanPartyMode),
BindingMode.TwoWay,
UpdateSourceTrigger.PropertyChanged);

BindingTools.SetBinding(
ToggleDisableTaskManager,
ToggleButton.IsCheckedProperty,
mainModel.AppSettings.Fullscreen,
nameof(FullscreenSettings.LanPartyDisableTaskManager),
BindingMode.TwoWay,
UpdateSourceTrigger.PropertyChanged);

app = mainModel.App as FullscreenApplication;
if (app.GameController != null)
{
LoadControllers();
app.GameController.ControllersChanged += GameController_ControllersChanged;
}

ToggleLanPartyMode.Checked += ToggleLanPartyMode_Checked;
}

private void LoadControllers()
{
Expand Down Expand Up @@ -121,11 +143,13 @@ private void GameController_ControllersChanged(object sender, EventArgs e)
ToggleControllerInput.Focus();
}

public override void Dispose()
{
if (app.GameController != null)
{
app.GameController.ControllersChanged -= GameController_ControllersChanged;
public override void Dispose()
{
ToggleLanPartyMode.Checked -= ToggleLanPartyMode_Checked;

if (app.GameController != null)
{
app.GameController.ControllersChanged -= GameController_ControllersChanged;
var newList = app.AppSettings.Fullscreen.DisabledGameControllers.GetClone();
foreach (var controller in app.GameController.Controllers)
{
Expand All @@ -139,8 +163,52 @@ public override void Dispose()
}
}

app.AppSettings.Fullscreen.DisabledGameControllers = newList;
}
}
}
}
app.AppSettings.Fullscreen.DisabledGameControllers = newList;
}
}

private void ToggleLanPartyMode_Checked(object sender, RoutedEventArgs e)
{
if (!mainModel.AppSettings.Fullscreen.HasLanPartyAdminPassword)
{
if (!PromptAndSavePassword())
{
mainModel.AppSettings.Fullscreen.EnableLanPartyMode = false;
Dialogs.ShowErrorMessage(LOC.LanPartyPasswordRequired.GetLocalized(), string.Empty);
}
}
}

private void ButtonSetLanPartyPassword_Click(object sender, RoutedEventArgs e)
{
PromptAndSavePassword();
}

private bool PromptAndSavePassword()
{
var owner = Window.GetWindow(this);
var inputWindow = new LanPartyPasswordWindow();
var first = inputWindow.ShowInput(owner, LOC.LanPartyEnterAdminPassword.GetLocalized());
if (!first.Result || first.SelectedItem.IsNullOrEmpty())
{
return false;
}

var confirmWindow = new LanPartyPasswordWindow();
var confirmation = confirmWindow.ShowInput(owner, LOC.LanPartyConfirmAdminPassword.GetLocalized());
if (!confirmation.Result)
{
return false;
}

if (first.SelectedItem != confirmation.SelectedItem)
{
Dialogs.ShowErrorMessage(LOC.LanPartyPasswordMismatch.GetLocalized(), string.Empty);
return false;
}

mainModel.AppSettings.Fullscreen.LanPartyAdminPasswordHash = LanPartyPasswordHelper.HashPassword(first.SelectedItem);
return true;
}
}
}
39 changes: 24 additions & 15 deletions source/Playnite.FullscreenApp/Playnite.FullscreenApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@
<Compile Include="FullscreenActionSelector.cs" />
<Compile Include="FullscreenCollectionView.cs" />
<Compile Include="FullscreenDialogs.cs" />
<Compile Include="Markup\Markups.cs" />
<Compile Include="Markup\Markups.cs" />
<Compile Include="Security\LanPartyModeController.cs" />
<Compile Include="Security\LanPartyPasswordHelper.cs" />
<Compile Include="ViewModels\AddonsViewModel.cs" />
<Compile Include="ViewModels\DesignData\DesignMainViewModel.cs" />
<Compile Include="ViewModels\FullscreenAppViewModel.cs" />
Expand Down Expand Up @@ -254,12 +256,15 @@
<Compile Include="Windows\RandomGameSelectWindow.xaml.cs">
<DependentUpon>RandomGameSelectWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\TextInputWindow.xaml.cs">
<DependentUpon>TextInputWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\TextInputWindow.xaml.cs">
<DependentUpon>TextInputWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\LanPartyPasswordWindow.xaml.cs">
<DependentUpon>LanPartyPasswordWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Windows\ProgressWindow.xaml.cs">
<DependentUpon>ProgressWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -591,13 +596,17 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Windows\TextInputWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Windows\MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<Page Include="Windows\TextInputWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Windows\LanPartyPasswordWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Windows\MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ProgressWindow.xaml">
<SubType>Designer</SubType>
Expand Down Expand Up @@ -658,4 +667,4 @@
<PropertyGroup>
<LargeAddressAware>true</LargeAddressAware>
</PropertyGroup>
</Project>
</Project>
Loading