public bool Filter_InstallationList(object obj) { BLInstallation v = obj as BLInstallation; if (v == null) { return(false); } else if (!Properties.LauncherSettings.Default.ShowBetas && v.IsBeta) { return(false); } else if (!Properties.LauncherSettings.Default.ShowReleases && !v.IsBeta) { return(false); } else if (!v.DisplayName.Contains(Installations_SearchFilter)) { return(false); } else { return(true); } }
public async void Play(MCProfile p, BLInstallation i, bool KeepLauncherOpen, bool Save = true) { if (i == null) return; i.LastPlayed = DateTime.Now; LauncherModel.Default.Config.Installation_UpdateLP(i); if (Save) { Properties.LauncherSettings.Default.CurrentInstallation = i.InstallationUUID; Properties.LauncherSettings.Default.Save(); } switch (i.Version.DisplayInstallStatus.ToString()) { case "Not installed": var wasCanceled = await Download(i.Version, true); if (!wasCanceled) Launch(); break; case "Installed": Launch(); break; } async void Launch() { var v = i.Version; try { StartLaunch(); await SetInstallationDataPath(p, i); string gameDir = Path.GetFullPath(v.GameDirectory); await ReRegisterPackage(v, gameDir); bool closable = await LaunchGame(v, KeepLauncherOpen); if (!closable) EndLaunch(); } catch { EndLaunch(); } void StartLaunch() { ViewModels.LauncherModel.Default.ShowProgressBar = true; ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.isLaunching; } void EndLaunch() { ViewModels.LauncherModel.Default.ShowProgressBar = false; ViewModels.LauncherModel.Default.CurrentState = ViewModels.LauncherModel.StateChange.None; } } }
private void UpdateEditingFields(BLInstallation i) { IsEditMode = true; InstallationVersionSelect.SelectedItem = Versions.Where(x => x.UUID == i.VersionUUID).FirstOrDefault(); InstallationNameField.Text = i.DisplayName; InstallationDirectoryField.Text = i.DirectoryName; InstallationIconSelect.Init(i.IconPath_Full, i.IsCustomIcon); SelectedUUID = i.InstallationUUID; Header.SetResourceReference(TextBlock.TextProperty, "EditInstallationScreen_AltTitle"); CreateButton.SetResourceReference(Button.ContentProperty, "EditInstallationScreen_AltCreateButton"); }
public EditInstallationScreen(BLInstallation i) { InitializeComponent(); UpdateVersionsComboBox(); UpdateEditingFields(i); }
private async Task SetInstallationDataPath(MCProfile p, BLInstallation i) { await Task.Run(() => { try { string LocalStateFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Packages", MINECRAFT_PACKAGE_FAMILY, "LocalState"); string PackageFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Packages", MINECRAFT_PACKAGE_FAMILY, "LocalState", "games", "com.mojang"); string PackageBakFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Packages", MINECRAFT_PACKAGE_FAMILY, "LocalState", "games", "com.mojang.default"); string ProfileFolder = Path.GetFullPath(LauncherModel.Default.FilepathManager.GetInstallationsFolderPath(p.Name, i.DirectoryName_Full)); if (Directory.Exists(PackageFolder)) { var dir = new DirectoryInfo(PackageFolder); if (!dir.IsSymbolicLink()) dir.MoveTo(PackageBakFolder); else dir.Delete(true); } DirectoryInfo profileDir = Directory.CreateDirectory(ProfileFolder); SymLinkHelper.CreateSymbolicLink(PackageFolder, ProfileFolder, SymLinkHelper.SymbolicLinkType.Directory); DirectoryInfo pkgDir = Directory.CreateDirectory(PackageFolder); DirectoryInfo lsDir = Directory.CreateDirectory(LocalStateFolder); SecurityIdentifier owner = WindowsIdentity.GetCurrent().User; SecurityIdentifier authenticated_users_identity = new SecurityIdentifier("S-1-5-11"); FileSystemAccessRule owner_access_rules = new FileSystemAccessRule(owner, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow); FileSystemAccessRule au_access_rules = new FileSystemAccessRule(authenticated_users_identity, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow); var lsSecurity = lsDir.GetAccessControl(); AuthorizationRuleCollection rules = lsSecurity.GetAccessRules(true, true, typeof(NTAccount)); List<FileSystemAccessRule> needed_rules = new List<FileSystemAccessRule>(); foreach (AccessRule rule in rules) { if (rule.IdentityReference is SecurityIdentifier) { var required_rule = new FileSystemAccessRule(rule.IdentityReference, FileSystemRights.FullControl, rule.InheritanceFlags, rule.PropagationFlags, rule.AccessControlType); needed_rules.Add(required_rule); } } var pkgSecurity = pkgDir.GetAccessControl(); pkgSecurity.SetOwner(owner); pkgSecurity.AddAccessRule(au_access_rules); pkgSecurity.AddAccessRule(owner_access_rules); pkgDir.SetAccessControl(pkgSecurity); var profileSecurity = profileDir.GetAccessControl(); profileSecurity.SetOwner(owner); profileSecurity.AddAccessRule(au_access_rules); profileSecurity.AddAccessRule(owner_access_rules); needed_rules.ForEach(x => profileSecurity.AddAccessRule(x)); profileDir.SetAccessControl(profileSecurity); } catch (Exception e) { ErrorScreenShow.exceptionmsg(e); throw e; } }); Thread.Sleep(1000); }