Пример #1
0
        public static string GetFolder(this IMapIdentifiable map, out bool isFromDb, out string freePath)
        {
            if (map.IsMapTemporary())
            {
                var folder = Path.GetDirectoryName(map.FolderName);
                isFromDb = false;
                freePath = map.FolderName;
                return(folder);
            }

            isFromDb = true;
            freePath = null;
            return(map.InOwnDb
                ? Path.Combine(Domain.CustomSongPath, map.FolderName)
                : Path.Combine(Domain.OsuSongPath, map.FolderName));
        }
Пример #2
0
        public BeatmapSettings GetMapFromDb(IMapIdentifiable id)
        {
            try
            {
                if (id.IsMapTemporary())
                {
                    Logger.Debug("需确认加入自定义目录后才可继续");
                }

                var map = ThreadedProvider.Query <BeatmapSettings>(TABLE_MAP,
                                                                   new Where[]
                {
                    ("version", id.Version),
                    ("folder", id.FolderName),
                    ("ownDb", id.InOwnDb)
                },
                                                                   count: 1)
                          .FirstOrDefault();

                if (map == null)
                {
                    var guid = Guid.NewGuid().ToString();
                    ThreadedProvider.Insert(TABLE_MAP, new Dictionary <string, object>()
                    {
                        ["id"]      = guid,
                        ["version"] = id.Version,
                        ["folder"]  = id.FolderName,
                        ["ownDb"]   = id.InOwnDb,
                        ["offset"]  = 0
                    });

                    return(new BeatmapSettings
                    {
                        Id = guid,
                        Version = id.Version,
                        FolderName = id.FolderName,
                        InOwnDb = id.InOwnDb,
                        Offset = 0
                    });
                }

                return(map);
            }