Beispiel #1
0
        public static bool LoadPartymodeTheme(int partyModeID)
        {
            Debug.Assert(partyModeID >= 0);
            CTheme theme = _Themes.FirstOrDefault(th => th.PartyModeID == partyModeID && th.Name == CConfig.Config.Theme.Theme);

            if (theme != null)
            {
                if (theme.Load())
                {
                    CurrentThemes.Add(partyModeID, theme);
                    return(true);
                }
                theme.Unload();
                CLog.LogError("Failed to load theme " + theme + " for partymode! Removing...", true);
                _Themes.Remove(theme);
            }
            theme = _Themes.First(th => th.PartyModeID == partyModeID && th.Name == CSettings.DefaultName);
            if (theme.Load())
            {
                CurrentThemes.Add(partyModeID, theme);
                return(true);
            }
            CLog.LogError("Failed to load default theme for partymode! Unloading partymode!", true);
            foreach (CPartyTheme th in _Themes.Where(th => th.PartyModeID == partyModeID))
            {
                th.Unload();
            }
            _Themes.RemoveAll(th => th.PartyModeID == partyModeID);
            return(false);
        }
Beispiel #2
0
        /// <summary>
        ///     Loads the currently selected theme trying all others if current theme failed loading<br />
        ///     Therefore CConfig.Theme/Skin might be changed!<br />
        ///     Closes the program on failure!
        /// </summary>
        public static void Load()
        {
            CTheme theme = _Themes.FirstOrDefault(th => th is CBaseTheme && th.Name == CConfig.Config.Theme.Theme) ?? _Themes.FirstOrDefault(th => th is CBaseTheme);

            while (theme != null)
            {
                if (theme.Load())
                {
                    break;
                }
                theme.Unload();
                CLog.LogError("Failed to load theme " + theme + "! Removing...", true);
                _Themes.Remove(theme);
                theme = _Themes.FirstOrDefault(th => th is CBaseTheme);
            }
            CurrentThemes.Add(-1, theme);
            if (theme == null)
            {
                CLog.LogError("No themes found! Cannot continue!", true, true);
            }
            else
            {
                CConfig.Config.Theme.Theme = theme.Name;
                CConfig.Config.Theme.Skin  = theme.CurrentSkin.Name;
                int[] ids = _Themes.Select(th => th.PartyModeID).Distinct().ToArray();
                foreach (int id in ids.Where(id => id >= 0))
                {
                    LoadPartymodeTheme(id);
                }
            }
        }