Exemplo n.º 1
0
        public IEnumerable <string> GetDetails()
        {
            List <string> profileDetails = new List <string>();

            profileDetails.Add($"7th Heaven Version: {Sys.AppVersion}\n");

            foreach (ProfileItem item in Items)
            {
                InstalledItem mod = Sys.Library.GetItem(item.ModID);

                if (mod != null)
                {
                    Mod details = mod.CachedDetails;

                    if (details != null)
                    {
                        profileDetails.Add(String.Format("# {0}", details.Name));
                        profileDetails.Add(String.Format("\tID: {0}", details.ID));
                        profileDetails.Add(String.Format("\tVersion: {0}", mod.LatestInstalled.VersionDetails.Version));
                    }
                    else
                    {
                        profileDetails.Add(String.Format("\tModID {0}", mod.ModID));
                    }

                    profileDetails.Add(String.Format("\tIs Active: {0}", item.IsModActive));



                    ModInfo info         = mod.GetModInfo();
                    string  detailFormat = "";

                    if (info != null)
                    {
                        detailFormat = item.GetFormatString(info);
                    }

                    foreach (ProfileSetting config in item.Settings.ToList())
                    {
                        if (info != null)
                        {
                            // extract configuration variable name and name of the selected value from Mod Info
                            ConfigOption configOption = info.Options.FirstOrDefault(o => o.ID == config.ID);
                            string       optionValue  = "";

                            if (configOption == null)
                            {
                                // the option ID may have changed from last time so skip it (that means the active profile item is out of date but opening the configure mod window would refresh it)
                                item.Settings.Remove(config);
                                continue;
                            }

                            if (configOption.Type == OptionType.Bool)
                            {
                                optionValue = (config.Value == 1).ToString();
                            }
                            else
                            {
                                optionValue = $"\"{configOption.Values.Where(o => o.Value == config.Value).Select(o => o.Name).FirstOrDefault()}\"";
                            }


                            string name  = $"\"{configOption.Name}\"";
                            string id    = $"({config.ID})";
                            string value = $"({config.Value})";

                            profileDetails.Add(string.Format(detailFormat, name, id, "=", optionValue, value)); // "=" is passed into string.Format() so all equal signs are aligned using the {2, 2} syntax
                        }
                        else
                        {
                            profileDetails.Add(String.Format("\t{0} = {1}", config.ID, config.Value));
                        }
                    }
                }
            }

            return(profileDetails);
        }