예제 #1
0
        internal static SkinOsu LoadSkinRaw(string skinName)
        {
            SkinOsu skin = new SkinOsu();

            skin.RawName = skinName;

            string iniFilename = Path.Combine(skin.FullPath, @"skin.ini");
            bool   hasIni      = File.Exists(iniFilename);
            bool   isDefault   = skinName == DEFAULT_SKIN;

            if (isDefault || skinName == USER_SKIN || !hasIni)
            {
                skin.Version = SkinOsu.SKIN_VERSION;
            }

#if !DEBUG
            try
            {
#endif
            if (isDefault)
            {
                skin.SkinName   = @" osu!";
                skin.SkinAuthor = @"peppy";
            }
            else if (hasIni)
            {
                skin.Load(iniFilename);
            }
#if !DEBUG
        }

        catch (Exception e)
        {
            NotificationManager.ShowMessageMassive(LocalisationManager.GetString(OsuString.SkinManager_ErrorLoadingConfig), 5000);
            if (!isDefault)
            {
                try
                {
                    File.WriteAllText(Path.Combine(SKINS_FOLDER, skinName, @"error.txt"), e.ToString());
                }
                catch { }
                return(LoadSkinRaw(DEFAULT_SKIN));
            }
        }
#endif

            return(skin);
        }
예제 #2
0
        internal static bool LoadSkin(string skin = null, bool clearCache = false)
        {
            InitializeSkinList();

            bool found = true;

            if (skin == null || Skins.Find(s => s.Equals(skin, StringComparison.CurrentCultureIgnoreCase)) == null)
            {
                found = skin == null;
                skin  = ConfigManager.sSkin;
            }

            bool forceDefault = false;

            if ((GameBase.Mode == OsuModes.Edit || GameBase.TestMode) && ConfigManager.sEditorDefaultSkin)
            {
                skin         = DEFAULT_SKIN;
                forceDefault = true;
            }

            if (!Directory.Exists(Path.Combine(SKINS_FOLDER, skin)))
            {
                skin         = DEFAULT_SKIN;
                forceDefault = true;
            }

            bool isNewSkin = false;

            if (clearCache || Current == null || !skin.Equals(Current.RawName, StringComparison.CurrentCultureIgnoreCase))
            {
                if (Current != null)
                {
                    Debug.Print(@"Skin reloaded");
                }

                TextureManager.ClearSkinCache(true);

                SkinOsu newSkin = LoadSkinRaw(skin);

                if (newSkin != null)
                {
                    isNewSkin = true;
                    Current   = newSkin;

                    if (skin == ConfigManager.sSkin)
                    {
                        CurrentUserSkin = Current;
                    }

                    AudioEngine.ClearSkinCache();

                    if (GameBase.Mode == OsuModes.Play) //todo: check if we actually need to load samples here.
                    {
                        AudioEngine.LoadAllSamples();
                    }
                    else
                    {
                        AudioEngine.LoadPrioritySamples();
                    }
                }
            }

            BeatmapColours.Clear();

            ResetColoursToSkin();

            if (ConfigManager.sUseSkinCursor && Current != CurrentUserSkin && !forceDefault)
            {
                //Special user override.
                SkinOsu tempHolder = Current;

                Current = CurrentUserSkin;
                LoadCursor();
                Current = tempHolder;
            }
            else
            {
                LoadCursor();
            }

            if (isNewSkin)
            {
                OnSkinChanged?.Invoke();
            }

            return(found);
        }
예제 #3
0
 public SkinOsu(SkinOsu fromSkin) : this()
 {
 }