Exemplo n.º 1
0
        public static void ListSettings(ref ASLSettings Settings)
        {
            int WindowWidth = Console.WindowWidth;

            Console.WriteLine("Start : \t" + Program.Runtime.start);
            Console.WriteLine("Split : \t" + Program.Runtime.split);
            Console.WriteLine("Reset : \t" + Program.Runtime.reset);
            Console.WriteLine();

            for (int i = 0; i < Settings.OrderedSettings.Count; i++)
            {
                string indentation = "";
                if (Settings.OrderedSettings[i].Parent != null)
                {
                    int        count       = 1;
                    ASLSetting tempSetting = Settings.Settings[Settings.OrderedSettings[i].Parent];
                    do
                    {
                        if (tempSetting.Parent == null)
                        {
                            break;
                        }
                        tempSetting = Settings.Settings[tempSetting.Parent];
                        count++;
                    }while (true);
                    indentation = new string('\t', count);
                }
                Console.WriteLine(indentation + Settings.OrderedSettings[i].Label + $" ({i + 1}) ({Settings.OrderedSettings[i].Id}) :" + Environment.NewLine + indentation + "   " + Settings.OrderedSettings[i].Value);
            }
        }
Exemplo n.º 2
0
        public static void SetSetting(ref ASLSetting listSetting, ref ASLSetting dicSetting, bool value, bool log = true)
        {
            listSetting.Value = value;
            dicSetting.Value  = value;

            if (log)
            {
                Console.WriteLine("Set " + listSetting.Id + " to " + value.ToString());
            }
        }
Exemplo n.º 3
0
        public static void SetSettingCommand(ref ASLSettings settings, int id, bool value)
        {
            if (id > settings.OrderedSettings.Count)
            {
                Console.WriteLine("Wrong id, type settings list to get a list of the settings with their ids");
                return;
            }

            ASLSetting listSetting = settings.OrderedSettings[id - 1];
            ASLSetting dicSetting  = settings.Settings[listSetting.Id];

            if (listSetting.Parent == null)
            {
                SetSetting(ref listSetting, ref dicSetting, value);
            }
            else
            {
                Console.WriteLine("This setting has parents, also set them? (y/n)");
                Console.Write("> ");
                ConsoleKey key = Console.ReadKey().Key;
                Console.WriteLine();

                if (key == ConsoleKey.Y)
                {
                    SetSetting(ref listSetting, ref dicSetting, value);

                    ASLSetting tempDicSetting  = settings.Settings[listSetting.Parent];
                    ASLSetting tempListSetting = settings.OrderedSettings.Find(x => x.Id == tempDicSetting.Id);

                    SetSetting(ref tempListSetting, ref tempDicSetting, value);

                    do
                    {
                        if (tempDicSetting.Parent == null)
                        {
                            break;
                        }

                        tempDicSetting  = settings.Settings[tempListSetting.Parent];
                        tempListSetting = settings.OrderedSettings.Find(x => x.Id == tempDicSetting.Id);

                        SetSetting(ref tempListSetting, ref tempDicSetting, value);
                    }while (true);
                }
                else if (key == ConsoleKey.N)
                {
                    SetSetting(ref listSetting, ref dicSetting, value);
                }
                else
                {
                    Console.WriteLine("Other key pressed, defaulting to no");
                    SetSetting(ref listSetting, ref dicSetting, value);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns true only if this setting and all it's parent settings are true.
        /// </summary>
        private bool GetSettingValueRecursive(ASLSetting setting)
        {
            if (!setting.Value)
            {
                return(false);
            }

            if (setting.Parent == null)
            {
                return(setting.Value);
            }

            return(GetSettingValueRecursive(Settings[setting.Parent]));
        }
Exemplo n.º 5
0
        public void AddSetting(string name, bool default_value, string description, string parent)
        {
            if (description == null)
            {
                description = name;
            }
            if (parent != null && !Settings.ContainsKey(parent))
            {
                throw new ArgumentException($"Parent for setting '{name}' is not a setting: {parent}");
            }
            if (Settings.ContainsKey(name))
            {
                throw new ArgumentException($"Setting '{name}' was already added");
            }

            var setting = new ASLSetting(name, default_value, description, parent);

            Settings.Add(name, setting);
            OrderedSettings.Add(setting);
        }
Exemplo n.º 6
0
        public static void SettingInfo(ref ASLSettings settings, int id)
        {
            if (id > settings.OrderedSettings.Count)
            {
                Console.WriteLine("Wrong id, type settings list to get a list of the settings with their ids");
                return;
            }

            ASLSetting setting = settings.OrderedSettings[id - 1];

            string parentString = "None";

            if (setting.Parent != null)
            {
                int count = 1;
                parentString = setting.Parent + " ";
                ASLSetting tempSetting = settings.Settings[setting.Parent];
                do
                {
                    if (tempSetting.Parent == null)
                    {
                        break;
                    }
                    tempSetting = settings.Settings[tempSetting.Parent];
                    count++;
                    parentString += ", " + tempSetting.Parent;
                }while (true);
                parentString += "(" + count + ")";
            }

            Console.WriteLine($"{setting.Label} ({setting.Id}) :" + Environment.NewLine
                              + "Tooltip : " + setting.ToolTip + Environment.NewLine
                              + "Value : " + setting.Value + Environment.NewLine
                              + "Default value : " + setting.DefaultValue + Environment.NewLine
                              + "Parent(s) : " + parentString);
        }