示例#1
0
        private void StockGroupLine()
        {
            foreach (KeyValuePair <Module, ContractGroupDetails> gpair in stockGroupDetails.OrderBy(p => p.Key.Name == "Assembly-CSharp.dll" ? "ZZZ" : p.Key.Name))
            {
                Module module = gpair.Key;
                ContractGroupDetails groupDetails = gpair.Value;

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(groupDetails.expanded ? "-" : "+", expandButtonStyle, GUILayout.Width(20), GUILayout.Height(20)))
                {
                    groupDetails.expanded = !groupDetails.expanded;
                }
                string groupName = module.Name == "Assembly-CSharp.dll" ? "Stock Contracts" : module.Name.Remove(module.Name.Length - 4);
                GUILayout.Label(groupName, groupRegularText, GUILayout.ExpandWidth(true));
                GUILayout.EndHorizontal();

                if (groupDetails.expanded)
                {
                    foreach (KeyValuePair <Type, StockContractDetails> pair in stockContractDetails.Where(p => p.Key.Module == module).OrderBy(p => p.Key.Name))
                    {
                        Type subclass = pair.Key;
                        StockContractDetails details = pair.Value;

                        string hintText;
                        IEnumerable <ContractGroup> disablingGroups = ContractDisabler.DisablingGroups(subclass);
                        if (disablingGroups.Any())
                        {
                            hintText = subclass.Name + " disabled by: " +
                                       string.Join(", ", disablingGroups.Select(g => g == null ? "unknown" : g.displayName).ToArray()) + "\n";
                            hintText += "Click to " + (details.enabled ? "disable " : "re-enable ") + subclass.Name + ".";
                        }
                        else
                        {
                            hintText = "Click to " + (details.enabled ? "disable " : "enable ") + subclass.Name + ".";
                        }

                        GUILayout.BeginHorizontal();
                        GUILayout.Label("", contractRegularText, GUILayout.ExpandWidth(false), GUILayout.Width(32));
                        GUILayout.Label(new GUIContent(subclass.Name, hintText), details.enabled ? contractRegularText : contractDisabledText, GUILayout.ExpandWidth(true));

                        bool newState = GUILayout.Toggle(details.enabled, new GUIContent("", hintText),
                                                         contractToggleStyle, GUILayout.ExpandWidth(false));
                        GUILayout.EndHorizontal();

                        if (newState != details.enabled)
                        {
                            details.enabled = newState;
                            ContractDisabler.SetContractState(subclass, details.enabled);
                        }
                    }
                }
            }
        }
示例#2
0
        private void ContractGroupLine(ContractGroup contractGroup, int indent = 0)
        {
            string identifier = contractGroup == null ? "" : contractGroup.name;

            if (!contractGroupDetails.ContainsKey(identifier))
            {
                contractGroupDetails[identifier] = new ContractGroupDetails(contractGroup);
            }
            ContractGroupDetails details = contractGroupDetails[identifier];

            GUILayout.BeginHorizontal();

            GUILayout.Label("", contractRegularText, GUILayout.ExpandWidth(false), GUILayout.Width((indent + 1) * 16));

            string groupName = contractGroup == null ? "No Group" : contractGroup.displayName;

            GUILayout.Label(groupName, details.enabled ? contractRegularText : contractDisabledText, GUILayout.ExpandWidth(true));
            if (contractGroup != null && contractGroup.parent == null)
            {
                bool enabled = GUILayout.Toggle(details.enabled,
                                                new GUIContent("", "Click to " + (details.enabled ? "disable " : "enable ") + contractGroup.displayName + " contracts."),
                                                contractToggleStyle, GUILayout.ExpandWidth(false));

                if (enabled != details.enabled)
                {
                    details.enabled = enabled;
                    if (enabled)
                    {
                        foreach (KeyValuePair <Type, StockContractDetails> pair in stockContractDetails.
                                 Where(p => ContractDisabler.DisablingGroups(p.Key).Contains(contractGroup)))
                        {
                            pair.Value.enabled = false;
                            ContractDisabler.SetContractState(pair.Key, false);
                        }
                    }
                    else
                    {
                        foreach (KeyValuePair <Type, StockContractDetails> pair in stockContractDetails.
                                 Where(p => ContractDisabler.DisablingGroups(p.Key).Contains(contractGroup) &&
                                       ContractDisabler.DisablingGroups(p.Key).All(g => !IsEnabled(g))))
                        {
                            pair.Value.enabled = true;
                            ContractDisabler.SetContractState(pair.Key, true);
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
        }