Ejemplo n.º 1
0
        public ThemeModifier(IPlayniteAPI api) : base(api)
        {
            settings = new ThemeModifierSettings(this);


            // Get plugin's location
            string pluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            // Add plugin localization in application ressource.
            PluginLocalization.SetPluginLanguage(pluginFolder, api.ApplicationSettings.Language);
            // Add common in application ressource.
            Common.Load(pluginFolder);
            Common.SetEvent(PlayniteApi);

            // Check version
            if (settings.EnableCheckVersion)
            {
                CheckVersion cv = new CheckVersion();
                cv.Check("ThemeModifier", pluginFolder, api);
            }

            // Init ui interagration
            themeModifierUI = new ThemeModifierUI(api, this.GetPluginUserDataPath(), settings);

            // Theme default
            ThemeDefault          = ThemeClass.GetThemeDefault();
            ThemeDefaultConstants = ThemeClass.GetThemeDefaultConstants(PlayniteApi);

            // Theme actual
            if (ThemeDefaultConstants.Count > 0)
            {
                ThemeActualConstants = ThemeClass.GetThemeActualConstants(settings, PlayniteApi);
            }

#if DEBUG
            logger.Debug($"ThemeModifier [Ignored] - ThemeDefault: {JsonConvert.SerializeObject(ThemeDefault)}");
            logger.Debug($"ThemeModifier [Ignored] - ThemeDefaultConstants: {JsonConvert.SerializeObject(ThemeDefaultConstants)}");
            logger.Debug($"ThemeModifier [Ignored] - ThemeActualConstants: {JsonConvert.SerializeObject(ThemeActualConstants)}");
#endif

            // Add modified values
            if (PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Desktop)
            {
                ThemeClass.SetThemeSettings(settings);
                ThemeClass.SetThemeSettingsConstants(ThemeActualConstants);
            }

            // Features integration
            icoFeatures = new IcoFeatures(pluginFolder);

            // Add event fullScreen
            if (api.ApplicationInfo.Mode == ApplicationMode.Fullscreen)
            {
                EventManager.RegisterClassHandler(typeof(Button), Button.ClickEvent, new RoutedEventHandler(BtFullScreen_ClickEvent));
            }
        }
Ejemplo n.º 2
0
        public override void OnGameSelected(OnGameSelectedEventArgs args)
        {
            try
            {
                if (args.NewValue?.Count == 1)
                {
                    Game GameSelected = args.NewValue[0];

                    List <ItemFeature> itemFeatures = IcoFeatures.GetAvailableItemFeatures(PluginSettings, GameSelected);

                    PluginSettings.Settings.HasData   = itemFeatures.Count > 0;
                    PluginSettings.Settings.DataCount = itemFeatures.Count;
                    PluginSettings.Settings.DataList  = itemFeatures;
                }
            }
            catch (Exception ex)
            {
                Common.LogError(ex, false, true, "LibraryManagement");
            }
        }
        public override void SetData(Game newContext)
        {
            List <ItemFeature> itemFeatures           = IcoFeatures.GetAvailableItemFeatures(PluginSettings, newContext);
            ObservableCollection <ItemList> itemLists = new ObservableCollection <ItemList>();

            itemLists = itemFeatures.Select(x => new ItemList {
                Name = x.NameAssociated, Icon = x.IconString
            }).ToObservable();

            if (PluginSettings.Settings.OneForSameIcon)
            {
                itemFeatures.ForEach(x =>
                {
                    string NewName = string.Empty;
                    itemLists.Where(y => x.IconString == y.Icon)?.ToList().ForEach(y =>
                    {
                        if (!y.Name.Contains(Environment.NewLine))
                        {
                            if (NewName.IsNullOrEmpty())
                            {
                                NewName = y.Name;
                            }
                            else
                            {
                                NewName += Environment.NewLine + y.Name;
                            }
                        }
                    });
                    if (!NewName.IsNullOrEmpty())
                    {
                        itemLists.Where(y => x.IconString == y.Icon)?.ToList().ForEach(y => y.Name = NewName);
                    }
                });

                itemLists = itemLists.DistinctBy(x => x.Icon).ToObservable();
            }

            ControlDataContext.CountItems  = itemLists.Count;
            ControlDataContext.ItemsSource = itemLists;
        }