// Use this for initialization void Start() { if (first) { ScoreStore.LoadOffline(); BeatmapStore.LoadAll(); } first = true; PlayButton.onClick.AddListener(() => { Initiate.Fade("SongSelectScene", Color.black, 2f); }); }
static void ImportManiaMap() { string loadPath = EditorUtility.OpenFilePanel("Load Mania File", "", "osu"); if (loadPath == "") { return; //Pressed cancel } Beatmap beatmap = Mania.FromFilePath(loadPath); string path = Path.Combine(BeatmapStore.DefaultSongPath, beatmap.SanitizedName); //Create the songs directory if it doesnt exist if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (beatmap.SongPath != null) { string songPath = Path.Combine(path, "song.wav"); if (!File.Exists(songPath)) { CopySongToLocal(beatmap.SongPath, songPath); } beatmap.SongPath = songPath; } if (beatmap.BackgroundPath != null) { string bgPath = Path.Combine(path, "bg.png"); if (!File.Exists(bgPath)) { CopyBackgroundToLocal(beatmap.BackgroundPath, bgPath); } beatmap.BackgroundPath = bgPath; } BeatmapStore.AddSong(beatmap); }
public static Func <Beatmap> GetSerializer(string fileName, bool upgradeMap = true) { Func <Beatmap> deserializer = null; string version = null; using (StreamReader stream = new StreamReader(fileName)) { string text = stream.ReadToEnd(); //Test Json parsers { JObject jObject; if (Helper.TryParseJObject(text, out jObject)) { version = jObject["version"].Value <string>(); if (version == "1.1") { deserializer = () => Version1_1.Deserialize(jObject); goto end; } else { Debug.Log($"Version {version} is not supported"); goto end; } } } } end: if (upgradeMap && deserializer != null && version != null && m_latestDeserializer != null && version != m_latestDeserializer.Version) { Debug.Log($"Upgrading map from version {version} to {m_latestDeserializer.Version}"); Beatmap map = deserializer.Invoke(); string file = BeatmapStore.GetFileNameForMap(BeatmapStore.GetFolderForMap(map), map); SerializeBeatmap(map, file); deserializer = GetSerializer(file, false); } return(deserializer); }
public void Start() { ScoreStore.LoadOffline(); if (BeatmapStore.Beatmaps == null) { BeatmapStore.LoadAll(); } SongListItemRect = SongListItemPrefab.GetComponent <RectTransform>().rect; ScoreListItemRect = ScoreListItemPrefab.GetComponent <RectTransform>().rect; AddItemsToList( BeatmapStore.Beatmaps.Count, SongListItemPrefab, VerticalSongSelectListPosition, SongListContentTransform, (GameObject songListItem, int index) => { SongListItem item = songListItem.GetComponent <SongListItem>(); item.Load(); item.SetBeatmapInfo(BeatmapStore.Beatmaps[index]); item.SelectedChange(false); } ); if (first) { Selected = UnityEngine.Random.Range(0, BeatmapStore.Beatmaps.Count); } else { Selected = Selected; } isStart = false; first = false; }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); fontStore = new FontStore(new ContentManager(Content.ServiceProvider, Path.Combine(Content.RootDirectory, "Fonts"))); fontStore.Add("Arial"); textureStore = new TextureStore(new ContentManager(Content.ServiceProvider, Path.Combine(Content.RootDirectory, "Textures"))); Texture2D beatSquareTexture = new Texture2D(GraphicsDevice, 1, 1); beatSquareTexture.SetData(new Color[] { Color.White }); textureStore.Add("BeatSquareTexture", beatSquareTexture); beatmapStore = new BeatmapStore("Songs"); BeatmapStoreInfo beatmapStoreInfo = new BeatmapStoreInfoRaw(testBeatmap.Metadata, testBeatmap); beatmapStore.Add(beatmapStoreInfo); beatmapStore.Add(beatmapStoreInfo); beatmapStore.Add(beatmapStoreInfo); beatmapStore.Add(beatmapStoreInfo); beatmapStore.Add(beatmapStoreInfo); beatmapStore.Add(beatmapStoreInfo); settings = new Settings(); DependencyInjectedObject.AddDependency(fontStore); DependencyInjectedObject.AddDependency(textureStore); DependencyInjectedObject.AddDependency(beatmapStore); DependencyInjectedObject.AddDependency(settings); AudioTrack.EngineInit(); AudioTrack.GlobalVolume = 0.5f; //LoadScreen(new PlayingScreen(testBeatmap.Difficulties[0])); LoadScreen(new SongSelect()); }
public Beatmap GetBeatmap() { return(BeatmapStore.DeserializeBeatmap(MapPath)); }