Beispiel #1
0
        public SQLiteData(SQLiteDataReader data)
        {
            foreach (FieldInfo prop in GetType().GetFields())
            {
                try
                {
                    switch (prop.Name.ToLower())
                    {
                    case "datet":
                        prop.SetValue(this, data[prop.Name.ToLower()].ToString());
                        break;

                    default:
                        prop.SetValue(this, data[prop.Name.ToLower()]);
                        break;
                    }
                }
                catch
                {
                    try
                    {
                        PulsarcLogger.Warning($"Data field in SQLite request could not be set as a {prop.FieldType.Name} : {data[prop.Name.ToLower()]}", LogType.Runtime);
                    }
                    catch
                    {
                        PulsarcLogger.Warning($"Unexpected data field in SQLite request : {prop.Name}", LogType.Runtime);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the current GameplayView with the provided beatmap.
        /// </summary>
        /// <param name="beatmap">The beatmap to play through</param>
        public void Init(Beatmap beatmap)
        {
            try
            {
                if (!beatmap.FullyLoaded)
                {
                    beatmap = BeatmapHelper.Load(beatmap.Path, beatmap.FileName);
                }

                // Reset in case it wasn't properly handled outside
                Reset();

                // Load values gained from config/user settings
                LoadConfig(beatmap);

                // Initialize default variables, parse beatmap
                InitializeVariables(beatmap);

                // Initialize Gameplay variables
                InitializeGameplay(beatmap);

                // Create columns and their hitobjects
                CreateColumns();

                // Sort the hitobjects according to their first appearance for optimizing update/draw
                SortHitObjects();

                if (AutoPlay)
                {
                    LoadAutoPlay();
                }

                // Once everything is loaded, initialize the view
                GetGameplayView().Init();

                // Start audio and gameplay
                StartGameplay();

                // Collect any excess memory to prevent GC from starting soon, avoiding freezes.
                // TODO: disable GC while in gameplay
                GC.Collect();

                Init();
            }
            catch
            {
                // Force quit
                EndGameplay();

                // Give warning
                PulsarcLogger.Warning($"There was an error attempting to load {beatmap.Title}, " +
                                      $"going back to Song Select!");

                // Remove Result Screen
                ScreenManager.RemoveScreen();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Attempts to return the texture found using the folder path and file asset name provided.
 /// </summary>
 /// <param name="path">The folder loaction of the texture.</param>
 /// <param name="asset">The name of the file to load.</param>
 /// <returns>A texture using the image file found, or an uninitialized "Default Texture" if the asset can't be loaded.</returns>
 private static Texture2D LoadTexture(string path, string asset)
 {
     // Try opening as a .png
     try
     {
         return(Texture2D.FromStream(Pulsarc.Graphics.GraphicsDevice, File.Open($"{path}/{asset}.png", FileMode.Open)));
     }
     catch
     {
         // Try opening as a .jpg
         try
         {
             return(Texture2D.FromStream(Pulsarc.Graphics.GraphicsDevice, File.Open($"{path}/{asset}.jpg", FileMode.Open)));
         }
         // Don't load, throw a console error, and return default texture.
         catch
         {
             PulsarcLogger.Warning($"Failed to load {asset} in {path}, make sure it is a .png or .jpg file!", LogType.Runtime);
             return(DefaultTexture);
         }
     }
 }
Beispiel #4
0
        private async void ConvertMaps()
        {
            // Temporary measure for converting intralism or osu!mania beatmaps
            // TODO Make a Converter UI
            if (!converting && !GameplayEngine.Active &&
                Keyboard.GetState().IsKeyDown(Config.Bindings["Convert"]) &&
                ScreenManager.Screens.Peek().GetType().Name == "SongSelection")
            {
                converting = true;
                IBeatmapConverter converter;

                Config.Reload();
                string convertFrom = Config.Get["Converting"]["Game"];
                string toConvert   = Config.Get["Converting"]["Path"];

                // What extension to check for
                string extension;

                switch (convertFrom.ToLower())
                {
                case "mania":
                    converter = new ManiaToPulsarc();
                    extension = "*.osu";
                    break;

                default:
                    converter = new IntralismToPulsarc();
                    extension = "config.txt";
                    break;
                }

                // Get all subfolder names
                string[] directories = Directory.GetDirectories(toConvert);

                // If there is no maps in this folder, and the number of sub-folders is 2 or more,
                // do a Batch Convert
                if (Directory.GetFiles(toConvert, extension).Length == 0 && directories.Length >= 2)
                {
                    for (int i = 0; i < directories.Length; i++)
                    {
                        try
                        {
                            converter.Save(directories[i]);
                        }
                        catch
                        {
                            PulsarcLogger.Warning($"Couldn't convert {directories[i]}");
                        }
                    }
                }
                // Otherwise convert one map
                else
                {
                    try
                    {
                        converter.Save(toConvert);
                    }
                    catch
                    {
                        PulsarcLogger.Warning($"Couldn't convert {toConvert}");
                    }
                }

                ((SongSelection)ScreenManager.Screens.Peek()).RescanBeatmaps();
            }
            else if (converting && Keyboard.GetState().IsKeyUp(Config.Bindings["Convert"]))
            {
                converting = false;
            }
        }