public EditorForm() { var path = !string.IsNullOrWhiteSpace(Program.UserConfig.GameFilesPath) ? Program.UserConfig.GameFilesPath : GameScannnerApi.GetGameFilesRootPath(); try { _gameScannner = GameScannnerApi.InstallGameEditor(Program.UserConfig.IsSteamVersion, path); } catch (Exception) { // } InitializeComponent(); SkinHelperFonts.SetFont(Controls); if (_gameScannner != null && DownloadFileUtils.IsConnectedToInternet()) { if (_gameScannner.QuickScan().GetAwaiter().GetResult()) { Btn_Install_Editor.Enabled = false; btn_Browse.Enabled = true; label2.Text = @"Installed"; label2.ForeColor = Color.Green; _isAutoRun = true; } else { label2.Text = @"Non-Installed Or Outdated"; label2.ForeColor = Color.Red; Btn_Install_Editor.Enabled = true; btn_Browse.Enabled = false; } } else { Btn_Install_Editor.Enabled = true; btn_Browse.Enabled = true; label2.Text = @"Unknow"; label2.ForeColor = Color.OrangeRed; } }
public static async void StartGame(bool isOffline = false) { var pname = Process.GetProcessesByName("spartan"); if (pname.Length > 0) { MsgBox.ShowMessage(@"Game already running!"); return; } //QuickGameScan if (!isOffline || DownloadFileUtils.IsConnectedToInternet()) { try { var gameFilePath = !string.IsNullOrWhiteSpace(Program.UserConfig.GameFilesPath) ? Program.UserConfig.GameFilesPath : GameScannnerApi.GetGameFilesRootPath(); var gameScannner = new GameScannnerApi(gameFilePath, Program.UserConfig.IsSteamVersion); retry: if (!await gameScannner.QuickScan()) { bool success; using (var form = new MsgBoxYesNo( @"Error: Your game files are corrupted or outdated. Click ""Yes"" to run a ""Game Scan"" to fix your game files, or ""No"" to ignore the error (not recommended).") ) { var dr = form.ShowDialog(); if (dr == DialogResult.OK) { using (var form2 = new GameScan()) { form2.ShowDialog(); success = false; } } else { success = true; } } if (!success) { goto retry; } } } catch (Exception ex) { MsgBox.ShowMessage( $"Warning: Error during quick scan. Error message: {ex.Message}", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } //isSteam if (!Program.UserConfig.IsSteamVersion) { var steamApiDll = Path.Combine(Program.UserConfig.GameFilesPath, "steam_api.dll"); if (File.Exists(steamApiDll)) { File.Delete(steamApiDll); } } //MpSettings if (!isOffline && Program.UserConfig.MpSettings != null) { if (Program.UserConfig.MpSettings.ConnectionType == ConnectionType.Wan) { Program.UserConfig.MpSettings.PublicIp = Program.CurrentUser.Ip; if (Program.UserConfig.MpSettings.PortMappingType == PortMappingType.Upnp) { try { await OpenNat.MapPortTask(1000, 1000); } catch (Exception) { Program.UserConfig.MpSettings.PortMappingType = PortMappingType.NatPunch; MsgBox.ShowMessage( "Error: Upnp device not found! \"UPnP Port Mapping\" has been disabled.", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private async void MainForm_Load(object sender, EventArgs e) { //CleanUpFiles try { Misc.CleanUpFiles(Directory.GetCurrentDirectory(), "*.old"); } catch (Exception ex) { MsgBox.ShowMessage( $"Warning: Error during files clean-up. Error message: {ex.Message}", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (!DownloadFileUtils.IsConnectedToInternet()) { return; } //Update Check try { if (await UpdaterForm.GetGitHubVersion() > Assembly.GetExecutingAssembly().GetName().Version) { using (var form = new MsgBoxYesNo( @"An update is avalaible. Click ""Yes"" to install it, or ""No"" to ignore it (not recommended).") ) { var dr = form.ShowDialog(); if (dr == DialogResult.OK) { using (var form2 = new UpdaterForm()) { form2.ShowDialog(); } } } } } catch (Exception ex) { MsgBox.ShowMessage( $"Warning: Error during update check. Error message: {ex.Message}", @"Celeste Fan Project", MessageBoxButtons.OK, MessageBoxIcon.Warning); } //Auto Login if (Program.UserConfig?.LoginInfo == null) { return; } if (!Program.UserConfig.LoginInfo.AutoLogin) { return; } panelManager1.Enabled = false; try { var response = await Program.WebSocketApi.DoLogin(Program.UserConfig.LoginInfo.Email, Program.UserConfig.LoginInfo.Password); if (response.Result) { Program.CurrentUser = response.User; gamerCard1.UserName = Program.CurrentUser.ProfileName; gamerCard1.Rank = $@"{Program.CurrentUser.Rank}"; panelManager1.SelectedPanel = managedPanel1; } } catch (Exception) { // } panelManager1.Enabled = true; }