public async Task <Launcher.Launcher> LaunchGame(string id, bool offline = true) { AuthResult authResult; if (offline) { authResult = new AuthResult(BmclCore.Config); } else { authResult = await BmclCore.AuthManager.Login(BmclCore.Config.Username, BmclCore.Config.GetPassword()); if (!authResult.IsSuccess) { MessageBox.Show(null, authResult.Message, MessageBoxButton.OK); return(null); } } if (_launcher != null) { throw new AnotherGameRunningException(_launcher); } var game = GetVersion(id); if (game == null) { throw new NoSuchVersionException(id); } _launcher = new Launcher.Launcher(game, authResult, BmclCore.Config); _launcher.OnGameExit += (sender, info, exitcode) => _launcher = null; _launcher.OnGameStart += LauncherOnGameStart; return(_launcher); }
public DatabaseUpdate(Launcher.Launcher otLauncher) { InitializeComponent(); run = new RunMysql(); _fileCopy = new FileCopyOverWrite(); Application.EnableVisualStyles(); _launcher = otLauncher; DisableCloseButton(); Start(); }
public async Task <Launcher.Launcher> LaunchGame(string id, bool offline = true) { AuthResult authResult; if (offline) { authResult = new AuthResult(BmclCore.Config); } else { authResult = await BmclCore.AuthManager.Login(BmclCore.Config.Username, BmclCore.Config.GetPassword()); if (!authResult.IsSuccess) { var authname = "BMCL"; if (BmclCore.AuthManager.GetCurrectAuth() is IBmclAuthPlugin) { var plugin = BmclCore.AuthManager.GetCurrectAuth() as IBmclAuthPlugin; authname = plugin?.GetName(); } MessageBox.Show(BmclCore.MainWindow, authResult.Message, authname, MessageBoxButton.OK); return(null); } } if (_launcher != null) { throw new AnotherGameRunningException(_launcher); } var game = GetVersion(id); if (game == null) { throw new NoSuchVersionException(id); } _launcher = new Launcher.Launcher(game, authResult, BmclCore.Config); _launcher.OnLaunchError += (launcher, exception) => _launcher = null; _launcher.OnGameExit += (sender, info, exitcode) => _launcher = null; _launcher.OnGameStart += LauncherOnGameStart; return(_launcher); }
private void Launch() { WriteLog("Starting launcher..."); try { var ln = new Launcher.Launcher {Size = Size, WindowState = WindowState, Location = Location}; CheckLauncherProfiles(); Hide(); ln.Log.Text = Log.Text; ln.AllowReconstruct.ToggleState = (bool)Configuration.Resources["enableReconstruction"] ? ToggleState.On : ToggleState.Off; ln.EnableMinecraftLogging.ToggleState = (bool)Configuration.Updates["enableMinecraftUpdateAlerts"] ? ToggleState.On : ToggleState.Off; ln.UseGamePrefix.ToggleState = (bool)Configuration.Logging["useGamePrefix"] ? ToggleState.On : ToggleState.Off; ln.AllowUpdateVersions.ToggleState = (bool)Configuration.Updates["checkVersionsUpdate"] ? ToggleState.On : ToggleState.Off; ln.EnableMinecraftUpdateAlerts.ToggleState = (bool)Configuration.Updates["enableMinecraftUpdateAlerts"] ? ToggleState.On : ToggleState.Off; ln.radCheckBox1.ToggleState = (bool)Configuration.Updates["checkProgramUpdate"] ? ToggleState.On : ToggleState.Off; ln.usingAssets.Text = (string)Configuration.Resources["assetsDir"]; ln.Show(); } catch (Exception ex) { LoggingConfiguration.LoggingBox = Log; CrashPanel.Visible = true; WriteLog("Во время чтения файла профилей возникла ошибка:\n" + ex + "\n\n#######\nВозможное решение: Удалите " + Variables.ProfileJsonFile + ". Если у вас есть какая-либо ценная информация в этом файле, то сделайте бэкап"); } }
public AnotherGameRunningException(Launcher.Launcher launcher) : base(LangManager.Translate("AnotherGameRunningException", launcher.VersionInfo.Id)) { Launcher = launcher; }