public static void set_data2(BMSong song) { name.Text = song.SongName; artist.Text = song.artist; creator.Text = "Difficulties :"; List <BMDifficulty> bmdiff = new List <BMDifficulty>(); foreach (BMDifficulty diff in song.difficulty) { string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); string filename = "scores"; string dbPath = Path.Combine(path, filename); Ini ini = new Ini(dbPath); int last_score = int.Parse(ini.GetValue(diff.bmid.ToString(), "score", "0")); int last_combo = int.Parse(ini.GetValue(diff.bmid.ToString(), "maxmm", "0")); int last_acc = (int)float.Parse(ini.GetValue(diff.bmid.ToString(), "acc", "0"), new CultureInfo("en-US")); BMDifficulty newdiff = new BMDifficulty(diff.path, diff.difficulty, diff.highscore, diff.acc, diff.bmid); newdiff.liststring = "Score : " + last_score; newdiff.liststring2 = "Combo : " + last_combo; bmdiff.Add(newdiff); } lstview.BeginRefresh(); lstview.ItemsSource = bmdiff; lstview.EndRefresh(); lstview.SelectedItem = bmdiff[0]; cursong = song; }
public BeatmapInfoPage() { button.Clicked += delegate { BMDifficulty diff = lstview.SelectedItem as BMDifficulty; if (diff != null) { mania4key_v2.Game1.osu_path = diff.path; if (lyb_rhythmdroid.Game1.mediaPlayer != null) { lyb_rhythmdroid.Game1.mediaPlayer.Reset(); } Forms.Context.StartActivity(typeof(testandroid1.Activity1)); } else { DisplayAlert("Error", "Make sure you select the difficulty before starting the game!", "Ok"); } }; this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { name, artist, creator, lstview, button } }; }
public ButtonDemoPage() { Label header = new Label { Text = "lyb!mania 4k", Font = Font.BoldSystemFontOfSize(50), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start }; string path = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Personal); string filename = "beatmaps"; string ininame = "scores"; string dbPath = Path.Combine(path, filename); string dbPath2 = Path.Combine(path, ininame); List <BMSong> bmlists = new List <BMSong>(); bool taskdone = true; int u = 0; try { using (StreamReader sr = new StreamReader(dbPath)) { while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] lines = line.Split(new[] { ":::" }, StringSplitOptions.None); name.Add(lines[0]); fullpath[u] = lines[1]; dir[u] = lines[2]; AudioFilename[u] = lines[3]; AudioPreview[u] = int.Parse(lines[4]); string title = lines[5]; string artist = lines[6]; int bmid = int.Parse(lines[9]); string creator = lines[7]; string ver = lines[8]; Ini ini = new Ini(dbPath2); //bmlists.Add(new bmlist(title, artist + " (" + creator + ")", ver, "High Score : " + ini.GetValue(bmid.ToString(), "score", "Not Yet Played"))); bool found = false; for (int i = 0; i < bmlists.Count; i++) { if (bmlists[i].SongName == title) { found = true; var difficulty_to_add = new BMDifficulty(lines[1], lines[8], ini.GetValue(bmid.ToString(), "score", "0"), ini.GetValue(bmid.ToString(), "acc", "0"), bmid); bmlists[i].difficulty.Add(difficulty_to_add); break; } } if (!found) { var difficulty_to_add = new BMDifficulty(lines[1], lines[8], ini.GetValue(bmid.ToString(), "score", "0"), ini.GetValue(bmid.ToString(), "acc", "0"), bmid); var list_to_add = new List <BMDifficulty>(); list_to_add.Add(difficulty_to_add); bmlists.Add(new BMSong(title, artist, list_to_add, bmid, lines[3], int.Parse(lines[4]), lines[2])); } u++; } } } catch { } list.ItemsSource = bmlists; Button button2 = new Button { Text = "Refresh", HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End }; Button button = new Button { Text = "Start Game!", Font = Font.SystemFontOfSize(NamedSize.Large), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.End }; //button.Clicked += OnButtonClicked; list.ItemSelected += Lst_ItemSelected; button.Clicked += delegate { //ManagedBass.Bass.Free(); mania4key_v2.Game1.osu_path = fullpath[index]; if (lyb_rhythmdroid.Game1.mediaPlayer != null) { lyb_rhythmdroid.Game1.mediaPlayer.Reset(); } Forms.Context.StartActivity(typeof(testandroid1.Activity1)); }; button2.Clicked += delegate { list.ItemsSource = null; list.SelectedItem = null; list.BeginRefresh(); name.Clear(); bmlists.Clear(); if (!Directory.Exists((OptionsPage.osupath_uri.Text))) { Directory.CreateDirectory(OptionsPage.osupath_uri.Text); } Task.Factory.StartNew(() => { try { var fileList1 = new DirectoryInfo("/sdcard/Download/").GetFiles("*.osz", SearchOption.AllDirectories); int counters = 0; foreach (var files in fileList1) { counters++; string strSourcePath = files.FullName; string thefilename = Path.GetFileNameWithoutExtension(files.FullName); string strDestFolderPath = OptionsPage.osupath_uri.Text + thefilename; System.IO.Directory.CreateDirectory(strDestFolderPath); using (ZipInputStream s = new ZipInputStream(File.OpenRead(strSourcePath))) { ZipEntry theEntry; while ((theEntry = s.NextEntry) != null) { string directoryName = Path.GetDirectoryName(theEntry.Name); string fileName = Path.GetFileName(theEntry.Name); directoryName = Path.Combine(strDestFolderPath, directoryName); if (directoryName.Length > 0) { Directory.CreateDirectory(directoryName); } if (fileName != String.Empty) { using (FileStream streamWriter = File.Create(Path.Combine(strDestFolderPath, theEntry.Name))) { int size = 2048; byte[] data = new byte[size]; while (true) { size = s.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } } } } } System.IO.File.Delete(strSourcePath); } } catch { } var fileList = new DirectoryInfo(OptionsPage.osupath_uri.Text).GetFiles("*.osu", SearchOption.AllDirectories); int counter = 0; int _audiostuff = 0; foreach (var files in fileList) { using (StreamReader sr = new StreamReader(files.FullName)) { try { int a = 0; string line; string title = ""; string artist = ""; int bmid = 0; string creator = ""; string ver = ""; while ((line = sr.ReadLine()) != "[HitObjects]") { if (line.Contains("AudioFilename") == true) { AudioFilename[_audiostuff] = line.Replace("AudioFilename: ", ""); } if (line.Contains("PreviewTime") == true) { AudioPreview[_audiostuff] = int.Parse(line.Replace("PreviewTime: ", "")); } if (line.Contains("Title:") == true) { title = line.Replace("Title:", ""); } if (line.Contains("Artist:") == true) { artist = line.Replace("Artist:", ""); } if (line.Contains("Creator:") == true) { creator = line.Replace("Creator:", ""); } if (line.Contains("Version:") == true) { ver = line.Replace("Version:", ""); } if (line.Contains("BeatmapID:") == true) { string temp = line.Replace("BeatmapID:", ""); bmid = int.Parse(temp); } } bool check = false; while ((line = sr.ReadLine()) != null) { string[] lines = line.Split(','); int i = int.Parse(lines[0]); if (i != 0) { if ((i == 64) || (i == 192) || (i == 320) || (i == 448)) { check = true; } else { check = false; } } } if (check == true) { fullpath[counter] = files.FullName; dir[counter] = files.DirectoryName + "/"; string ii = files.ToString(); ii = ii.Replace(dir[counter], ""); ii = ii.Replace(".osu", ""); name.Add(ii); Ini ini = new Ini(dbPath2); //bmlists.Add(new bmlist(title, artist + "(" + creator + ")", ver, "High Score : " + ini.GetValue(bmid.ToString(), "score", "Not Yet Played"))); bool found = false; for (int i = 0; i < bmlists.Count; i++) { if (bmlists[i].SongName == title) { found = true; var difficulty_to_add = new BMDifficulty(files.FullName, ver, ini.GetValue(bmid.ToString(), "score", "0"), ini.GetValue(bmid.ToString(), "acc", "0"), bmid); bmlists[i].difficulty.Add(difficulty_to_add); break; } } if (!found) { var difficulty_to_add = new BMDifficulty(files.FullName, ver, ini.GetValue(bmid.ToString(), "score", "0"), ini.GetValue(bmid.ToString(), "acc", "0"), bmid); var list_to_add = new List <BMDifficulty>(); list_to_add.Add(difficulty_to_add); bmlists.Add(new BMSong(title, artist, list_to_add, bmid, AudioFilename[_audiostuff], (AudioPreview[_audiostuff]), dir[counter])); } tofile[counter] = ii + ":::" + fullpath[counter] + ":::" + dir[counter] + ":::" + AudioFilename[_audiostuff] + ":::" + AudioPreview[_audiostuff] + ":::" + title + ":::" + artist + ":::" + creator + ":::" + ver + ":::" + bmid.ToString(); counter++; _audiostuff++; } } catch { } } } path = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Personal); filename = "beatmaps"; dbPath = Path.Combine(path, filename); u = 0; using (StreamWriter sr = new StreamWriter(dbPath)) { foreach (string s in name) { sr.WriteLine(tofile[u]); u++; } } }).ContinueWith(task => { //list.ItemsSource = name; list.ItemsSource = bmlists; list.EndRefresh(); if (bmlists.Count == 0) { DisplayAlert("Warning", "No Beatmaps Detected, Please read the help page on how to import beatmap.", "Ok"); } path = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Personal); filename = "scores"; dbPath = Path.Combine(path, filename); }, TaskScheduler.FromCurrentSynchronizationContext()); }; // Accomodate iPhone status bar. this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); // Build the page. this.Content = new StackLayout { Children = { list, button2 } }; }