Exemplo n.º 1
0
        private int addDependencies(int top = 8)
        {
            int numDeps  = mod.depends?.Count ?? 0;
            int numConfs = mod.conflicts?.Count ?? 0;

            if (numDeps + numConfs > 0)
            {
                int       midL  = Console.WindowWidth / 2 - 1;
                int       h     = Math.Min(11, numDeps + numConfs + 2);
                const int lblW  = 16;
                int       nameW = midL - 2 - lblW - 2;

                AddObject(new ConsoleFrame(
                              1, top, midL, top + h - 1,
                              () => "Dependencies",
                              () => ConsoleTheme.Current.NormalFrameFg,
                              false
                              ));
                if (numDeps > 0)
                {
                    AddObject(new ConsoleLabel(
                                  3, top + 1, 3 + lblW - 1,
                                  () => $"Required ({numDeps}):",
                                  null,
                                  () => ConsoleTheme.Current.DimLabelFg
                                  ));
                    ConsoleTextBox tb = new ConsoleTextBox(
                        3 + lblW, top + 1, midL - 2, top + 1 + numDeps - 1, false,
                        TextAlign.Left,
                        () => ConsoleTheme.Current.MainBg,
                        () => ConsoleTheme.Current.LabelFg
                        );
                    AddObject(tb);
                    foreach (RelationshipDescriptor rd in mod.depends)
                    {
                        tb.AddLine(ScreenObject.FormatExactWidth(
                                       // Show install status
                                       ModListScreen.StatusSymbol(plan.GetModStatus(manager, registry, rd.ToString()))
                                       + rd.ToString(),
                                       nameW
                                       ));
                    }
                }
                if (numConfs > 0)
                {
                    AddObject(new ConsoleLabel(
                                  3, top + 1 + numDeps, 3 + lblW - 1,
                                  () => $"Conflicts ({numConfs}):",
                                  null,
                                  () => ConsoleTheme.Current.DimLabelFg
                                  ));
                    ConsoleTextBox tb = new ConsoleTextBox(
                        3 + lblW, top + 1 + numDeps, midL - 2, top + h - 2, false,
                        TextAlign.Left,
                        () => ConsoleTheme.Current.MainBg,
                        () => ConsoleTheme.Current.LabelFg
                        );
                    AddObject(tb);
                    // FUTURE: Find mods that conflict with this one
                    //         See GUI/MainModList.cs::ComputeConflictsFromModList
                    foreach (RelationshipDescriptor rd in mod.conflicts)
                    {
                        tb.AddLine(ScreenObject.FormatExactWidth(
                                       // Show install status
                                       ModListScreen.StatusSymbol(plan.GetModStatus(manager, registry, rd.ToString()))
                                       + rd.ToString(),
                                       nameW
                                       ));
                    }
                }
                return(top + h - 1);
            }
            return(top - 1);
        }