private void Configuration_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.WindowsShutDown || DialogResult == DialogResult.Cancel) { OsuMain.ExitImmediately(); } }
private void ErrorDialog_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing || e.CloseReason == CloseReason.WindowsShutDown) { OsuMain.ExitImmediately(); } }
public override void Initialize() { BeatmapManager.Initialize(); BeatmapManager.DatabaseSerialize(); if (!(ConfigManager.sSaveUsername && ConfigManager.sSavePassword)) { TopMostMessageBox.Show(LocalisationManager.GetString(OsuString.Tournament_MessageRememberCredentials)); OsuMain.ExitImmediately(); return; } int connectPeriod = 10000; while (!BanchoClient.Connected && (connectPeriod -= 50) > 0) { Thread.Sleep(50); } if (!BanchoClient.Connected) { TopMostMessageBox.Show(LocalisationManager.GetString(OsuString.Tournament_ClientCouldNotConnect)); OsuMain.ExitImmediately(); return; } #if !DEBUG if ((BanchoClient.Permission & Permissions.Tournament) == 0) { TopMostMessageBox.Show(LocalisationManager.GetString(OsuString.Tournament_MessageNoAccess)); OsuMain.ExitImmediately(); return; } #endif initializeSprites(); clients = new TournamentClientManager(this, spriteManager); Lobby = new TournamentLobby(this, spriteManager, 1.01f); base.Initialize(); StateChanged += stateChanged; State = TourneyState.Idle; }
public override void Initialize() { if (!(ConfigManager.sSaveUsername && ConfigManager.sSavePassword)) { TopMostMessageBox.Show("Please make sure you have the \"Remember Username\" and \"Remember Password\" boxes checked in the options."); OsuMain.ExitImmediately(); return; } int connectPeriod = 10000; while (!BanchoClient.Connected && (connectPeriod -= 50) > 0) { Thread.Sleep(50); } if (!BanchoClient.Connected) { TopMostMessageBox.Show("The drawings client could not connect. Please check your internet connection."); OsuMain.ExitImmediately(); return; } if (!File.Exists(TEAMS_FILENAME)) { TopMostMessageBox.Show("drawings.txt not found."); OsuMain.ExitImmediately(); return; } #if !DEBUG if ((BanchoClient.Permission & Permissions.Tournament) == 0) { TopMostMessageBox.Show("You do not have access to the drawings client. Please contact [email protected]."); OsuMain.ExitImmediately(); return; } #endif initializeSprites(); reset(true); base.Initialize(); }
void update(object sender, DoWorkEventArgs e) { init(); try { #if Public ReleaseStream stream = ReleaseStream.Stable40; #else ReleaseStream stream = ReleaseStream.CuttingEdge; #endif bool hasFramework = File.Exists(@"OpenTK.dll"); List <string> files = new List <string>(Directory.GetFiles(Environment.CurrentDirectory)); bool useCurrentDirectory = File.Exists(@"osu!.cfg") || files.Count == 1; if (!hasFramework) { retry_with_default: if (!useCurrentDirectory) { installPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"osu!"); label.Click += chooseFolder; int seconds = 10; while (seconds > 0) { setText(string.Format(LocalisationManager.GetString(OsuString.Maintenance_InstallationPath) + '\n' + LocalisationManager.GetString(OsuString.Maintenance_InstallationPath2), installPath, seconds), true); Thread.Sleep(1000); seconds--; while (installPath == null) { Thread.Sleep(100); } } label.Click -= chooseFolder; } retry: if (installPath != Environment.CurrentDirectory) { string installExecutable = Path.Combine(installPath, @"osu!.exe"); try { if (!Directory.Exists(installPath)) { Directory.CreateDirectory(installPath); } try { File.Delete(installExecutable); } catch (IOException) { //ignore IOExceptions for now } byte[] executable = File.ReadAllBytes(OsuMain.FullPath); using (FileStream fs = File.Create(installExecutable)) fs.Write(executable, 0, executable.Length); } catch (UnauthorizedAccessException) { if (!OsuMain.IsElevated) { if (OsuMain.Elevate(@"-allowuserwrites " + installPath, true)) { goto retry; } else { //error occurred while elevating. try again using the default path. goto retry_with_default; } } } Process.Start(installExecutable); OsuMain.ExitImmediately(); } } try { if (hasFramework) { stream = ConfigManager.sReleaseStream.Value; } } catch (Exception ex) { OsuMain.Repair(true, ex); } setText(string.Empty); tryAgain: setProgress(); if (hasFramework) //force a complete check. { ConfigManager.ResetHashes(); } CommonUpdater.Check(delegate(UpdateStates s) { }, stream); while (true) { switch (CommonUpdater.State) { case UpdateStates.Checking: setText(CommonUpdater.GetStatusString(), detailedTextImportant); setProgress(); Thread.Sleep(20); continue; case UpdateStates.Updating: setText(CommonUpdater.GetStatusString()); setProgress(CommonUpdater.Percentage); Thread.Sleep(20); continue; case UpdateStates.Completed: case UpdateStates.NeedsRestart: setText(LocalisationManager.GetString(OsuString.CommonUpdater_Updated)); break; case UpdateStates.NoUpdate: setText(LocalisationManager.GetString(OsuString.CommonUpdater_Updated), true); Thread.Sleep(1000); break; case UpdateStates.Error: CommonUpdater.Reset(); setProgress(); setText(LocalisationManager.GetString(OsuString.Maintenance_ErrorOccurred), true); Thread.Sleep(5000); goto tryAgain; default: break; } break; } if (!OsuMain.IsWine && !hasFramework) { //create desktop/start menu shortcuts only once per install ShellLinkHelper.Create(icon_path_desktop, Path.Combine(Environment.CurrentDirectory, @"osu!.exe"), @"osu!"); ShellLinkHelper.Create(icon_path_startmenu, Path.Combine(Environment.CurrentDirectory, @"osu!.exe"), @"osu!"); } instance.Dispose(); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(@"Error occured (please report this!):\n\n" + ex.ToString()); } }
public static pTexture FromNewResourceStore(string filename, TextureAtlas atlas = null) { bool highResolution = GameBase.UseHighResolutionSprites; if (highResolution) { filename += @"@2x"; } using (Bitmap b = osu_gameplay.ResourcesStore.ResourceManager.GetObject(filename) as Bitmap) if (b != null) { pTexture tex = FromBitmap(b, atlas); if (highResolution) { tex.DpiScale = 2; } return(tex); } //dll modification checks using (Bitmap b = osu_ui.ResourcesStore.ResourceManager.GetObject(filename) as Bitmap) if (b != null) { bool valid = true; switch (filename) { //case @"menu-osu": // valid &= b.GetPixel(320 / 2, 320 / 2) == System.Drawing.Color.FromArgb(255, 255, 190, 219); // valid &= b.GetPixel(220 / 2, 220 / 2) == System.Drawing.Color.FromArgb(255, 255, 199, 227); // valid &= b.GetPixel(420 / 2, 420 / 2) == System.Drawing.Color.FromArgb(255, 255, 245, 249); // break; //case @"menu-osu@2x": // valid &= b.GetPixel(320, 320) == System.Drawing.Color.FromArgb(255, 255, 190, 220); // valid &= b.GetPixel(220, 220) == System.Drawing.Color.FromArgb(255, 255, 199, 227); // valid &= b.GetPixel(420, 420) == System.Drawing.Color.FromArgb(255, 255, 245, 249); // break; //case @"menu-background": // valid &= b.GetPixel(0, 0) == System.Drawing.Color.FromArgb(243, 0, 206, 255); // valid &= b.GetPixel(400 / 2, 400 / 2) == System.Drawing.Color.FromArgb(255, 0, 165, 255); // valid &= b.GetPixel(1552 / 2, 1024 / 2) == System.Drawing.Color.FromArgb(255, 0, 144, 255); // break; //case @"menu-background@2x": // valid &= b.GetPixel(0, 0) == System.Drawing.Color.FromArgb(228, 1, 206, 255); // valid &= b.GetPixel(400, 400) == System.Drawing.Color.FromArgb(255, 0, 165, 255); // valid &= b.GetPixel(1552, 1024) == System.Drawing.Color.FromArgb(255, 0, 144, 255); // break; } if (!valid) { #if DEBUG throw new Exception(@"DLL modification checks need updating"); #else OsuMain.ExitImmediately(); #endif } pTexture tex = FromBitmap(b, atlas); if (highResolution) { tex.DpiScale = 2; } return(tex); } return(null); }