This commit is contained in:
rpa committed 2026-10-12 20:10:00 -04:00
commit 3b59cf7bf1
9 files changed
+409

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
.vs/
**/bin/
**/obj/
*.user
+21
View File
@@ -0,0 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.10.12224.181 stable
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amnesia", "Amnesia\Amnesia.csproj", "{30BDFA5F-32EC-4A63-98CA-C65999A61F6D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30BDFA5F-32EC-4A63-98CA-C65999A61F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30BDFA5F-32EC-4A63-98CA-C65999A61F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30BDFA5F-32EC-4A63-98CA-C65999A61F6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30BDFA5F-32EC-4A63-98CA-C65999A61F6D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+8
View File
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType><TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF><Nullable>enable</Nullable><ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Amnesia</AssemblyName><RootNamespace>Amnesia</RootNamespace>
</PropertyGroup>
<ItemGroup><PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" /></ItemGroup>
</Project>
+44
View File
@@ -0,0 +1,44 @@
<Application x:Class="Amnesia.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml">
<Application.Resources>
<SolidColorBrush x:Key="Bg" Color="#17141c"/>
<SolidColorBrush x:Key="Surface" Color="#2b2632"/>
<SolidColorBrush x:Key="Raised" Color="#38313c"/>
<SolidColorBrush x:Key="Fg" Color="#c9b5af"/>
<SolidColorBrush x:Key="Muted" Color="#8372a0"/>
<SolidColorBrush x:Key="Dim" Color="#625577"/>
<SolidColorBrush x:Key="Accent" Color="#8c79a5"/>
<SolidColorBrush x:Key="Hover" Color="#74608e"/>
<SolidColorBrush x:Key="Line" Color="#433a4f"/>
<Style TargetType="TextBlock"><Setter Property="Foreground" Value="{StaticResource Fg}"/><Setter Property="TextWrapping" Value="Wrap"/></Style>
<Style TargetType="Button">
<Setter Property="Foreground" Value="{StaticResource Fg}"/><Setter Property="Background" Value="{StaticResource Raised}"/>
<Setter Property="BorderBrush" Value="{StaticResource Line}"/><Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="18,12"/><Setter Property="Cursor" Value="Hand"/><Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="Button">
<Border x:Name="Shell" CornerRadius="12" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True"><Setter TargetName="Shell" Property="Background" Value="{StaticResource Hover}"/><Setter TargetName="Shell" Property="BorderBrush" Value="{StaticResource Accent}"/></Trigger>
<Trigger Property="IsKeyboardFocused" Value="True"><Setter TargetName="Shell" Property="BorderBrush" Value="#d5c7eb"/></Trigger>
<Trigger Property="IsPressed" Value="True"><Setter TargetName="Shell" Property="Opacity" Value="0.7"/></Trigger>
<Trigger Property="IsEnabled" Value="False"><Setter TargetName="Shell" Property="Opacity" Value="0.45"/></Trigger>
</ControlTemplate.Triggers>
</ControlTemplate></Setter.Value></Setter>
</Style>
<Style x:Key="Primary" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"><Setter Property="Background" Value="{StaticResource Accent}"/><Setter Property="Foreground" Value="#17141c"/></Style>
<Style TargetType="TextBox">
<Setter Property="Foreground" Value="{StaticResource Fg}"/><Setter Property="Background" Value="{StaticResource Bg}"/><Setter Property="CaretBrush" Value="{StaticResource Accent}"/><Setter Property="SelectionBrush" Value="{StaticResource Accent}"/>
<Setter Property="Padding" Value="14,12"/><Setter Property="BorderBrush" Value="{StaticResource Line}"/><Setter Property="BorderThickness" Value="1"/>
<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="TextBox"><Border x:Name="Frame" CornerRadius="10" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1"><ScrollViewer x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}"/></Border><ControlTemplate.Triggers><Trigger Property="IsKeyboardFocusWithin" Value="True"><Setter TargetName="Frame" Property="BorderBrush" Value="{StaticResource Accent}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
<Style TargetType="PasswordBox">
<Setter Property="Foreground" Value="{StaticResource Fg}"/><Setter Property="Background" Value="{StaticResource Bg}"/><Setter Property="CaretBrush" Value="{StaticResource Accent}"/><Setter Property="Padding" Value="14,12"/>
<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="PasswordBox"><Border x:Name="Frame" CornerRadius="10" Background="{TemplateBinding Background}" BorderBrush="{StaticResource Line}" BorderThickness="1"><ScrollViewer x:Name="PART_ContentHost" Margin="{TemplateBinding Padding}"/></Border><ControlTemplate.Triggers><Trigger Property="IsKeyboardFocusWithin" Value="True"><Setter TargetName="Frame" Property="BorderBrush" Value="{StaticResource Accent}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
<Style TargetType="CheckBox">
<Setter Property="Foreground" Value="{StaticResource Fg}"/><Setter Property="Cursor" Value="Hand"/><Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template"><Setter.Value><ControlTemplate TargetType="CheckBox"><StackPanel Orientation="Horizontal"><Border x:Name="Box" Width="20" Height="20" CornerRadius="6" Background="{StaticResource Bg}" BorderBrush="{StaticResource Line}" BorderThickness="1"><TextBlock x:Name="Tick" Text="✓" Visibility="Collapsed" Foreground="{StaticResource Fg}" HorizontalAlignment="Center"/></Border><ContentPresenter Margin="10,0,0,0" VerticalAlignment="Center"/></StackPanel><ControlTemplate.Triggers><Trigger Property="IsChecked" Value="True"><Setter TargetName="Box" Property="Background" Value="{StaticResource Hover}"/><Setter TargetName="Tick" Property="Visibility" Value="Visible"/></Trigger><Trigger Property="IsKeyboardFocused" Value="True"><Setter TargetName="Box" Property="BorderBrush" Value="#d5c7eb"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter>
</Style>
</Application.Resources>
</Application>
+3
View File
@@ -0,0 +1,3 @@
using System.Windows;
namespace Amnesia;
public partial class App : Application { }
+53
View File
@@ -0,0 +1,53 @@
<Window x:Class="Amnesia.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Amnesia" Width="980" Height="670" MinWidth="880" MinHeight="640" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="CanMinimize" Background="{StaticResource Bg}" FontFamily="Segoe UI Variable, Segoe UI" FontSize="14" Foreground="{StaticResource Fg}">
<Border BorderBrush="{StaticResource Line}" BorderThickness="1"><Grid>
<Grid.RowDefinitions><RowDefinition Height="58"/><RowDefinition/><RowDefinition Height="36"/></Grid.RowDefinitions>
<Grid Background="Transparent" MouseLeftButtonDown="DragTitle"><TextBlock Text="◈ amnesia" FontSize="19" FontWeight="SemiBold" Margin="26,0" VerticalAlignment="Center"/><StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,8,12,8"><Button Content="—" ToolTip="Minimize" Click="Minimize" Padding="16,4" Background="Transparent" BorderThickness="0"/><Button Content="✕" ToolTip="Close" Click="CloseApp" Padding="16,4" Background="Transparent" BorderThickness="0"/></StackPanel></Grid>
<Grid Grid.Row="1" x:Name="LoginView" Margin="26,12,26,8">
<Grid.ColumnDefinitions><ColumnDefinition Width="1.05*"/><ColumnDefinition Width="1*"/></Grid.ColumnDefinitions>
<Border CornerRadius="20" Background="{StaticResource Surface}" Margin="0,0,30,0" ClipToBounds="True"><Grid Margin="30">
<Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition/><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<TextBlock Text="A QUIETER WAY TO PLAY" Foreground="{StaticResource Muted}" FontSize="11" FontWeight="Bold"/>
<Viewbox Grid.Row="1" Margin="20"><Canvas Width="260" Height="240">
<Ellipse Width="232" Height="232" Stroke="#433a4f" StrokeThickness="1" Canvas.Left="14" Canvas.Top="4"/>
<Ellipse Width="192" Height="192" Stroke="#38313c" StrokeThickness="1" Canvas.Left="34" Canvas.Top="24"/>
<Path Data="M130,36 L217,86 130,137 43,86 Z" Fill="#8c79a5"/>
<Path Data="M43,86 L130,137 130,235 43,184 Z" Fill="#625577"/>
<Path Data="M130,137 L217,86 217,184 130,235 Z" Fill="#433a4f"/>
<Path Data="M130,36 L130,137 M43,86 L217,184 M217,86 L43,184" Stroke="#cbb9e7" Opacity="0.17"/>
<Ellipse Width="8" Height="8" Fill="#cbb9e7" Canvas.Left="236" Canvas.Top="85"/>
</Canvas></Viewbox>
<StackPanel Grid.Row="2"><TextBlock Text="Less noise.&#10;More Minecraft." FontSize="34" FontWeight="SemiBold" LineHeight="40"/><TextBlock Text="Your space. Your settings. Your next world." Foreground="{StaticResource Muted}" Margin="0,14,0,0"/></StackPanel>
</Grid></Border>
<StackPanel Grid.Column="1" VerticalAlignment="Center" Margin="10,0,12,0">
<TextBlock Text="WELCOME TO AMNESIA" Foreground="{StaticResource Muted}" FontSize="11" FontWeight="Bold"/>
<TextBlock x:Name="AuthTitle" Text="Welcome back." FontSize="32" FontWeight="SemiBold" Margin="0,8,0,6"/>
<TextBlock x:Name="AuthSubtitle" Text="Sign in to your local launcher account." Foreground="{StaticResource Muted}" Margin="0,0,0,26"/>
<TextBlock Text="Username" Margin="0,0,0,8"/><TextBox x:Name="Username" MaxLength="24" AutomationProperties.Name="Username"/>
<TextBlock Text="Password" Margin="0,18,0,8"/><PasswordBox x:Name="Password" MaxLength="128" AutomationProperties.Name="Password" KeyDown="PasswordKeyDown"/>
<CheckBox x:Name="Remember" Content="Remember me on this PC" Margin="0,18,0,18"/>
<Button x:Name="AuthButton" Content="Sign in →" Style="{StaticResource Primary}" Click="Authenticate"/>
<TextBlock x:Name="AuthError" Foreground="#bc9ba1" MinHeight="40" Margin="0,10,0,0" FontSize="12"/>
<Button x:Name="ModeButton" Content="New here? Create an account" Click="ToggleMode" Background="Transparent" BorderThickness="0" Foreground="{StaticResource Muted}" Padding="8"/>
</StackPanel>
</Grid>
<Grid x:Name="HomeView" Grid.Row="1" Margin="34,16" Visibility="Collapsed">
<Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition/><RowDefinition Height="Auto"/></Grid.RowDefinitions>
<Grid><StackPanel><TextBlock Text="YOUR LAUNCHER" Foreground="{StaticResource Muted}" FontSize="11" FontWeight="Bold"/><TextBlock x:Name="Greeting" FontSize="30" FontWeight="SemiBold" Margin="0,8,0,0"/></StackPanel><StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center"><Button Content="⚙ Settings" Click="OpenSettings" Margin="0,0,10,0"/><Button Content="Sign out" Click="SignOut" Background="Transparent"/></StackPanel></Grid>
<Border Grid.Row="1" Margin="0,28,0,24" CornerRadius="20" Background="{StaticResource Surface}" BorderBrush="{StaticResource Line}" BorderThickness="1"><Grid Margin="32"><Grid.ColumnDefinitions><ColumnDefinition Width="2*"/><ColumnDefinition/></Grid.ColumnDefinitions><StackPanel VerticalAlignment="Center"><TextBlock Text="AMNESIA / MINECRAFT" Foreground="{StaticResource Muted}" FontSize="12" FontWeight="Bold"/><TextBlock Text="Make yourself&#10;at home." FontSize="46" FontWeight="SemiBold" Margin="0,16,0,12"/><TextBlock Text="A little space for your next big adventure." Foreground="{StaticResource Muted}"/><Button Content="Open launcher ↗" Style="{StaticResource Primary}" Click="Launch" HorizontalAlignment="Left" Margin="0,26,0,0"/></StackPanel><Viewbox Grid.Column="1" Margin="16"><Path Data="M75,0 L150,44 150,132 75,176 0,132 0,44 Z M0,44 L75,88 150,44 M75,88 L75,176" Stroke="#8c79a5" StrokeThickness="2" Fill="#38313c"/></Viewbox></Grid></Border>
<Grid Grid.Row="2"><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition/></Grid.ColumnDefinitions><StackPanel><TextBlock Text="PERSONAL BY DEFAULT" Foreground="{StaticResource Muted}" FontSize="11"/><TextBlock Text="Preferences saved on this device" Margin="0,7,0,0"/></StackPanel><StackPanel Grid.Column="1"><TextBlock Text="SESSION" Foreground="{StaticResource Muted}" FontSize="11"/><TextBlock x:Name="SessionLabel" Margin="0,7,0,0"/></StackPanel></Grid>
</Grid>
<TextBlock Grid.Row="2" Text="AMNESIA / LOCAL EDITION Built for your next world." Foreground="{StaticResource Dim}" FontSize="10" Margin="28,0" VerticalAlignment="Center"/>
<Border x:Name="SettingsOverlay" Grid.RowSpan="3" Background="#D917141C" Visibility="Collapsed"><Border Width="570" Padding="30" CornerRadius="20" Background="{StaticResource Surface}" BorderBrush="{StaticResource Line}" BorderThickness="1" VerticalAlignment="Center">
<StackPanel><TextBlock Text="Make it yours." FontSize="28" FontWeight="SemiBold"/><TextBlock Text="Launcher preferences · saved for this Windows user" Foreground="{StaticResource Muted}" Margin="0,6,0,24"/>
<TextBlock Text="Launcher executable" FontWeight="SemiBold"/><TextBlock Text="Select Minecraft Launcher or your own client launcher (.exe)." Foreground="{StaticResource Muted}" FontSize="12" Margin="0,5,0,10"/>
<Grid><Grid.ColumnDefinitions><ColumnDefinition/><ColumnDefinition Width="Auto"/></Grid.ColumnDefinitions><TextBox x:Name="LauncherPath" IsReadOnly="True" AutomationProperties.Name="Launcher path"/><Button Grid.Column="1" Content="Browse" Click="Browse" Margin="10,0,0,0"/></Grid>
<CheckBox x:Name="MinimizeOnLaunch" Content="Minimize Amnesia after opening the launcher" Margin="0,24,0,0"/>
<CheckBox x:Name="ReduceMotion" Content="Reduce motion" Margin="0,18,0,0"/>
<TextBlock Text="Window opacity" FontWeight="SemiBold" Margin="0,24,0,8"/><Slider x:Name="OpacitySlider" Minimum="0.85" Maximum="1" Value="1" TickFrequency="0.01" IsSnapToTickEnabled="True" AutoToolTipPlacement="TopLeft" AutomationProperties.Name="Window opacity"/>
<TextBlock Text="85% — 100%" Foreground="{StaticResource Muted}" FontSize="11" Margin="0,4,0,20"/>
<TextBlock x:Name="SettingsError" Foreground="#bc9ba1" FontSize="12" Margin="0,0,0,12"/>
<Grid><Button Content="Reset defaults" HorizontalAlignment="Left" Click="ResetSettings" Background="Transparent" BorderThickness="0" Padding="0,12"/><StackPanel Orientation="Horizontal" HorizontalAlignment="Right"><Button Content="Cancel" Click="CancelSettings" Margin="0,0,10,0"/><Button Content="Save changes" Click="SaveSettings" Style="{StaticResource Primary}"/></StackPanel></Grid>
</StackPanel>
</Border></Border>
</Grid></Border>
</Window>
+138
View File
@@ -0,0 +1,138 @@
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Animation;
using Amnesia.Services;
using Microsoft.Win32;
namespace Amnesia;
public partial class MainWindow : Window
{
private LocalStore? store;
private Preferences preferences = new();
private Account? current;
private bool register, busy;
private int failures;
private DateTime nextAttempt = DateTime.MinValue;
public MainWindow()
{
InitializeComponent();
Loaded += (_, _) => InitializeSession();
}
private void InitializeSession()
{
try
{
store = new LocalStore();
try { preferences = store.ReadPreferences(); }
catch { AuthError.Text = "Preferences could not be read; using defaults."; }
Opacity = preferences.Opacity;
var account = store.Restore();
if (account is not null) ShowHome(account, true);
else Username.Focus();
}
catch { AuthError.Text = "Unable to read local account data. Check access to %LOCALAPPDATA%\\Amnesia."; AuthButton.IsEnabled = false; }
}
private void Fade(FrameworkElement element)
{
element.BeginAnimation(OpacityProperty, null);
if (preferences.ReduceMotion) { element.Opacity = 1; return; }
element.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(280)) { EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut } });
}
private void ToggleMode(object sender, RoutedEventArgs e)
{
if (busy) return;
register = !register;
AuthTitle.Text = register ? "Your adventure starts." : "Welcome back.";
AuthSubtitle.Text = register ? "Create a local account. Use a unique password." : "Sign in to your local launcher account.";
AuthButton.Content = register ? "Create account →" : "Sign in →";
ModeButton.Content = register ? "Already have an account? Sign in" : "New here? Create an account";
AuthError.Text = ""; Password.Clear(); Username.Focus();
}
private async void Authenticate(object sender, RoutedEventArgs e)
{
if (busy || store is null) return;
if (DateTime.UtcNow < nextAttempt) { AuthError.Text = "Please wait a few seconds before trying again."; return; }
string username = Username.Text.Trim(), password = Password.Password;
if (username.Length == 0 || password.Length == 0) { AuthError.Text = "Enter your username and password."; return; }
busy = true; AuthButton.IsEnabled = ModeButton.IsEnabled = false;
AuthError.Text = "";
try
{
bool creating = register;
var account = await Task.Run(() => creating ? store.Register(username, password) : store.Login(username, password));
bool remember = Remember.IsChecked == true;
string? notice = null;
try { if (remember) store.Remember(account); else store.Forget(); }
catch { notice = "Signed in, but session storage failed. Remember Me may not have been updated."; }
failures = 0; Password.Clear(); ShowHome(account, remember && notice is null);
if (notice is not null) MessageBox.Show(this, notice, "Session storage", MessageBoxButton.OK, MessageBoxImage.Information);
}
catch (ArgumentException ex)
{
AuthError.Text = ex.Message;
if (!register) { failures++; nextAttempt = DateTime.UtcNow.AddSeconds(Math.Min(failures * 2, 30)); }
}
catch { AuthError.Text = "Could not access account storage. Check %LOCALAPPDATA%\\Amnesia."; }
finally { busy = false; AuthButton.IsEnabled = ModeButton.IsEnabled = true; }
}
private void ShowHome(Account account, bool remembered)
{
current = account;
Greeting.Text = $"Welcome, {account.Username}.";
SessionLabel.Text = remembered ? "Remembered on this PC · 30 days" : "Signed in for this session";
LoginView.Visibility = Visibility.Collapsed; HomeView.Visibility = Visibility.Visible;
Fade(HomeView);
}
private void SignOut(object sender, RoutedEventArgs e)
{
try { store?.Forget(); }
catch { MessageBox.Show(this, "Could not clear the saved session. Check access to %LOCALAPPDATA%\\Amnesia before signing out.", "Sign out"); return; }
current = null; Password.Clear(); Remember.IsChecked = false; AuthError.Text = "";
if (register) ToggleMode(sender, e);
HomeView.Visibility = Visibility.Collapsed; LoginView.Visibility = Visibility.Visible;
Fade(LoginView); Username.Focus();
}
private void FillSettings(Preferences p)
{
LauncherPath.Text = p.LauncherPath; MinimizeOnLaunch.IsChecked = p.MinimizeOnLaunch;
ReduceMotion.IsChecked = p.ReduceMotion; OpacitySlider.Value = p.Opacity;
}
private void OpenSettings(object sender, RoutedEventArgs e)
{
FillSettings(preferences); SettingsError.Text = ""; HomeView.IsEnabled = false;
SettingsOverlay.Visibility = Visibility.Visible; Fade(SettingsOverlay); LauncherPath.Focus();
}
private void CancelSettings(object sender, RoutedEventArgs e) { SettingsOverlay.Visibility = Visibility.Collapsed; HomeView.IsEnabled = true; }
private void ResetSettings(object sender, RoutedEventArgs e) { FillSettings(new Preferences()); SettingsError.Text = "Defaults restored in this form. Save to apply."; }
private void Browse(object sender, RoutedEventArgs e)
{
var picker = new OpenFileDialog { Title = "Choose your launcher", Filter = "Windows applications (*.exe)|*.exe", CheckFileExists = true };
if (picker.ShowDialog(this) == true) LauncherPath.Text = picker.FileName;
}
private void SaveSettings(object sender, RoutedEventArgs e)
{
string path = LauncherPath.Text.Trim();
if (path.Length > 0 && (!File.Exists(path) || !path.EndsWith(".exe", StringComparison.OrdinalIgnoreCase))) { SettingsError.Text = "Choose an existing .exe file, or reset the path."; return; }
var p = new Preferences { LauncherPath = path, MinimizeOnLaunch = MinimizeOnLaunch.IsChecked == true, ReduceMotion = ReduceMotion.IsChecked == true, Opacity = OpacitySlider.Value };
try { store!.SavePreferences(p); preferences = p; Opacity = p.Opacity; CancelSettings(sender, e); }
catch { SettingsError.Text = "Unable to save preferences. Check folder permissions."; }
}
private void Launch(object sender, RoutedEventArgs e)
{
if (current is null) return;
if (string.IsNullOrWhiteSpace(preferences.LauncherPath)) { OpenSettings(sender, e); SettingsError.Text = "Choose your launcher executable to get started."; return; }
try
{
if (!File.Exists(preferences.LauncherPath)) throw new FileNotFoundException();
Process.Start(new ProcessStartInfo(preferences.LauncherPath) { UseShellExecute = true, WorkingDirectory = Path.GetDirectoryName(preferences.LauncherPath)! });
if (preferences.MinimizeOnLaunch) WindowState = WindowState.Minimized;
}
catch { MessageBox.Show(this, "The launcher could not be opened. Check the executable selected in Settings.", "Unable to launch", MessageBoxButton.OK, MessageBoxImage.Information); }
}
private void PasswordKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) Authenticate(sender, e); }
private void DragTitle(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && !busy) DragMove(); }
private void Minimize(object sender, RoutedEventArgs e) => WindowState = WindowState.Minimized;
private void CloseApp(object sender, RoutedEventArgs e) { if (!busy) Close(); }
}
+82
View File
@@ -0,0 +1,82 @@
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
namespace Amnesia.Services;
public sealed record Account(string Username, string Salt, string Hash);
public sealed record Session(string Username, string AccountHash, DateTime ExpiresUtc);
public sealed class Preferences
{
public string LauncherPath { get; set; } = "";
public bool MinimizeOnLaunch { get; set; } = true;
public bool ReduceMotion { get; set; }
public double Opacity { get; set; } = 1;
}
// Local launcher accounts only. This is not Minecraft or Microsoft authentication.
public sealed class LocalStore
{
public static readonly string Root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Amnesia");
private static string FilePath(string name) => Path.Combine(Root, name);
private static readonly byte[] Entropy = Encoding.UTF8.GetBytes("Amnesia.LocalSession.v1");
public LocalStore() => Directory.CreateDirectory(Root);
private static void Write(string name, byte[] bytes)
{
string target = FilePath(name), temp = target + "." + Guid.NewGuid().ToString("N") + ".tmp";
try { File.WriteAllBytes(temp, bytes); File.Move(temp, target, true); }
finally { if (File.Exists(temp)) File.Delete(temp); }
}
private List<Account> Accounts() => File.Exists(FilePath("accounts.json"))
? JsonSerializer.Deserialize<List<Account>>(File.ReadAllText(FilePath("accounts.json"))) ?? throw new InvalidDataException("Account data could not be read.")
: new();
public Account Register(string username, string password)
{
if (!Regex.IsMatch(username, @"^[a-zA-Z0-9_]{3,24}$")) throw new ArgumentException("Use 3–24 letters, numbers, or underscores for your username.");
if (password.Length < 8 || password.Length > 128) throw new ArgumentException("Use a password between 8 and 128 characters.");
var accounts = Accounts();
if (accounts.Any(a => a.Username.Equals(username, StringComparison.OrdinalIgnoreCase))) throw new ArgumentException("That username already exists on this PC.");
byte[] salt = RandomNumberGenerator.GetBytes(32);
var account = new Account(username, Convert.ToBase64String(salt), Convert.ToBase64String(Derive(password, salt)));
accounts.Add(account);
Write("accounts.json", JsonSerializer.SerializeToUtf8Bytes(accounts));
return account;
}
private static byte[] Derive(string password, byte[] salt) => Rfc2898DeriveBytes.Pbkdf2(password, salt, 600_000, HashAlgorithmName.SHA256, 32);
public Account Login(string username, string password)
{
var account = Accounts().FirstOrDefault(a => a.Username.Equals(username, StringComparison.OrdinalIgnoreCase));
byte[] salt = account is null ? new byte[32] : Convert.FromBase64String(account.Salt);
byte[] hash = Derive(password, salt);
if (account is null || !CryptographicOperations.FixedTimeEquals(hash, Convert.FromBase64String(account.Hash)))
throw new ArgumentException("The username or password is incorrect.");
return account;
}
public void Remember(Account account)
{
var session = new Session(account.Username, account.Hash, DateTime.UtcNow.AddDays(30));
Write("session.bin", ProtectedData.Protect(JsonSerializer.SerializeToUtf8Bytes(session), Entropy, DataProtectionScope.CurrentUser));
}
public Account? Restore()
{
if (!File.Exists(FilePath("session.bin"))) return null;
try
{
var bytes = ProtectedData.Unprotect(File.ReadAllBytes(FilePath("session.bin")), Entropy, DataProtectionScope.CurrentUser);
var s = JsonSerializer.Deserialize<Session>(bytes);
if (s is null || s.ExpiresUtc <= DateTime.UtcNow) { Forget(); return null; }
return Accounts().FirstOrDefault(a => a.Username == s.Username && a.Hash == s.AccountHash);
}
catch (Exception e) when (e is CryptographicException or JsonException or FormatException) { Forget(); return null; }
}
public void Forget() { if (File.Exists(FilePath("session.bin"))) File.Delete(FilePath("session.bin")); }
public Preferences ReadPreferences()
{
if (!File.Exists(FilePath("preferences.json"))) return new();
var p = JsonSerializer.Deserialize<Preferences>(File.ReadAllText(FilePath("preferences.json"))) ?? new();
p.Opacity = double.IsFinite(p.Opacity) ? Math.Clamp(p.Opacity, .85, 1) : 1;
return p;
}
public void SavePreferences(Preferences p) => Write("preferences.json", JsonSerializer.SerializeToUtf8Bytes(p));
}
+56
View File
@@ -0,0 +1,56 @@
# Amnesia — local launcher edition
A Windows WPF / C# Visual Studio project with a dark purple interface, local account creation and login, encrypted Remember Me, dashboard, and persistent preferences.
## Open and run
1. Extract this entire ZIP to a folder.
2. Open **Amnesia.sln** in Visual Studio 2022 (17.8 or newer) with the **.NET desktop development** workload and **.NET 8 SDK** installed.
3. Allow NuGet to restore System.Security.Cryptography.ProtectedData, then press **F5**.
4. Choose **New here? Create an account**, use a username (3–24 letters, digits, underscores) and a unique password (8–128 characters).
5. Sign in. In Settings, browse to an installed Minecraft Launcher or your own client launcher `.exe`, then Save changes.
There are no preconfigured credentials. Accounts belong to this Windows user on this PC. This is a source project, not a prebuilt EXE.
## Features
- Custom borderless window with draggable title bar, minimize, close, rounded controls, focus rings, and fade transitions.
- Your requested base, surface, raised, foreground, muted, accent, hover, and border colors.
- Salted PBKDF2-HMAC-SHA256 password hashes (600,000 iterations); no plaintext passwords saved.
- Remember Me restores a local session for 30 days. Windows DPAPI protects the session for the current Windows user. Unchecked successful sign-in removes the saved session; Sign out clears it.
- Local login retry delay; account creation and password verification run off the UI thread.
- Persistent executable selection, minimize after launch, reduced motion, and 85–100% window opacity. Cancel discards pending changes; Reset defaults is applied only after Save.
- Open launcher starts the executable chosen by the user; it does not download or install Minecraft.
## Scope
This is a functioning **local launcher account system**, not an online authentication service. It does not sign into Microsoft/Mojang, grant game ownership, inject a client, or provide multiplayer account validation. The chosen Minecraft launcher handles game authentication and launching. No Amnesia game client binaries were supplied or included.
Local accounts are a convenience boundary, not protection against someone who controls the same Windows account or edits the app and its files. For a public multi-user service, replace LocalStore with a server authentication API, expiring/revocable session tokens, and Microsoft OAuth through the supported Minecraft flow. Never collect Microsoft passwords in this form.
## Data and customization
Data lives at `%LOCALAPPDATA%\Amnesia`: accounts.json, session.bin, preferences.json. Treat these files as private. To completely reset local accounts and preferences, close the app and remove that folder (this deletes all local Amnesia accounts).
- `Amnesia/App.xaml`: palette and reusable styles.
- `Amnesia/MainWindow.xaml`: login, dashboard, settings UI.
- `Amnesia/MainWindow.xaml.cs`: navigation and UI behavior.
- `Amnesia/Services/LocalStore.cs`: account hashing, encrypted sessions, persistence.
The UI uses Segoe UI Variable with Segoe UI fallback, so no font download is needed. All visuals are vector geometry.
## Build / publish
In a terminal with the .NET 8 SDK:
```powershell
dotnet build Amnesia.sln -c Release
dotnet publish Amnesia/Amnesia.csproj -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true
```
Find the executable in `Amnesia\bin\Release\net8.0-windows\win-x64\publish`.
## Verification
XML/project structure, event-handler wiring, and archive contents were checked in the generation environment. A Windows/.NET build and visual run were not available there. Run the following smoke checks in Visual Studio before distribution:
1. Create an account; reject duplicate usernames and passwords shorter than eight characters.
2. Sign out, then verify wrong passwords fail and the correct password succeeds.
3. Sign in with Remember Me checked, close/reopen, and confirm the dashboard returns.
4. Sign out, reopen, and confirm the login form returns. Repeat with Remember Me unchecked.
5. Save preferences and reopen; confirm they persist. Verify Cancel leaves saved settings unchanged.
6. Select an installed launcher, launch it, and verify the minimize preference.
7. Test keyboard Tab/Space/Enter, reduced motion, and Windows display scaling.