示例#1
0
 public Dialog_DebugOutputMenu()
 {
     forcePause = true;
     foreach (Type item in GenTypes.AllTypesWithAttribute <HasDebugOutputAttribute>())
     {
         MethodInfo[] methods = item.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
         foreach (MethodInfo mi in methods)
         {
             if (mi.TryGetAttribute(out DebugOutputAttribute _))
             {
                 string label  = GenText.SplitCamelCase(mi.Name);
                 Action action = delegate
                 {
                     mi.Invoke(null, null);
                 };
                 CategoryAttribute customAttribute2 = null;
                 string            category         = (!mi.TryGetAttribute(out customAttribute2)) ? "General" : customAttribute2.name;
                 debugOutputs.Add(new DebugOutputOption
                 {
                     label    = label,
                     category = category,
                     action   = action
                 });
             }
         }
     }
     debugOutputs = (from r in debugOutputs
                     orderby r.category, r.label
                     select r).ToList();
 }
 private void GenerateCacheForMethod(MethodInfo method, DebugActionAttribute attribute)
 {
     if (attribute.IsAllowedInCurrentGameState)
     {
         string text = string.IsNullOrEmpty(attribute.name) ? GenText.SplitCamelCase(method.Name) : attribute.name;
         if (attribute.actionType == DebugActionType.ToolMap || attribute.actionType == DebugActionType.ToolMapForPawns || attribute.actionType == DebugActionType.ToolWorld)
         {
             text = "T: " + text;
         }
         string            category          = attribute.category;
         DebugActionOption debugActionOption = default(DebugActionOption);
         debugActionOption.label      = text;
         debugActionOption.category   = category;
         debugActionOption.actionType = attribute.actionType;
         DebugActionOption item = debugActionOption;
         if (attribute.actionType == DebugActionType.ToolMapForPawns)
         {
             item.pawnAction = (Delegate.CreateDelegate(typeof(Action <Pawn>), method) as Action <Pawn>);
         }
         else
         {
             item.action = (Delegate.CreateDelegate(typeof(Action), method) as Action);
         }
         debugActions.Add(item);
     }
 }
示例#3
0
 public Dialog_DebugLogMenu()
 {
     base.forcePause = true;
     MethodInfo[] methods = typeof(DataAnalysisLogger).GetMethods(BindingFlags.Static | BindingFlags.Public);
     foreach (MethodInfo mi in methods)
     {
         if (Current.ProgramState == ProgramState.Playing || !mi.HasAttribute <ModeRestrictionPlay>())
         {
             string name = mi.Name;
             if (name.StartsWith("DoLog_"))
             {
                 string title  = GenText.SplitCamelCase(name.Substring(6));
                 Action action = delegate
                 {
                     mi.Invoke(null, null);
                 };
                 string   text     = "Logs";
                 Category category = null;
                 if (((MemberInfo)mi).TryGetAttribute <Category>(out category))
                 {
                     text = text + " - " + category.name;
                 }
                 this.dataAnalyzerLogs.Add(new ListItem
                 {
                     title    = title,
                     category = text,
                     action   = action
                 });
             }
         }
     }
     this.dataAnalyzerLogs.Sort((ListItem lhs, ListItem rhs) => lhs.category.CompareTo(rhs.category));
 }
 private void DoField(FieldInfo fi)
 {
     if (!fi.IsLiteral)
     {
         string label   = GenText.SplitCamelCase(fi.Name).CapitalizeFirst();
         bool   checkOn = (bool)fi.GetValue(null);
         bool   flag    = checkOn;
         CheckboxLabeledDebug(label, ref checkOn);
         if (checkOn != flag)
         {
             fi.SetValue(null, checkOn);
             fi.DeclaringType.GetMethod(fi.Name + "Toggled", BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null);
         }
     }
 }
示例#5
0
        protected override void DoListingItems()
        {
            string b = null;

            foreach (ListItem dataAnalyzerLog in this.dataAnalyzerLogs)
            {
                ListItem current = dataAnalyzerLog;
                if (current.category != b)
                {
                    base.DoLabel(current.category);
                    b = current.category;
                }
                base.DebugAction(current.title, current.action);
            }
            base.DoGap();
            Text.Font = GameFont.Small;
            base.DoLabel("Tables");
            MethodInfo[] methods = typeof(DataAnalysisTableMaker).GetMethods(BindingFlags.Static | BindingFlags.Public);
            foreach (MethodInfo mi in methods)
            {
                string name = mi.Name;
                if (name.StartsWith("DoTable_"))
                {
                    base.DebugAction(GenText.SplitCamelCase(name.Substring(8)), delegate
                    {
                        mi.Invoke(null, null);
                    });
                }
            }
            base.DoGap();
            base.DoLabel("UI");
            base.DebugAction("Pawn column", delegate
            {
                List <DebugMenuOption> list = new List <DebugMenuOption>();
                List <PawnColumnDef> allDefsListForReading = DefDatabase <PawnColumnDef> .AllDefsListForReading;
                for (int j = 0; j < allDefsListForReading.Count; j++)
                {
                    PawnColumnDef localDef = allDefsListForReading[j];
                    list.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Action, delegate
                    {
                        Find.WindowStack.Add(new Dialog_PawnTableTest(localDef));
                    }));
                }
                Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
            });
        }
示例#6
0
 private void GenerateCacheForMethod(MethodInfo method, DebugOutputAttribute attribute)
 {
     if (!attribute.onlyWhenPlaying || Current.ProgramState == ProgramState.Playing)
     {
         string label  = attribute.name ?? GenText.SplitCamelCase(method.Name);
         Action action = Delegate.CreateDelegate(typeof(Action), method) as Action;
         string text   = attribute.category;
         if (text == null)
         {
             text = "General";
         }
         debugOutputs.Add(new DebugOutputOption
         {
             label    = label,
             category = text,
             action   = action
         });
     }
 }
 private void DoField(FieldInfo fi)
 {
     if (!fi.IsLiteral)
     {
         string label = GenText.SplitCamelCase(fi.Name).CapitalizeFirst();
         bool   flag  = (bool)fi.GetValue(null);
         bool   flag2 = flag;
         base.CheckboxLabeledDebug(label, ref flag);
         if (flag != flag2)
         {
             fi.SetValue(null, flag);
             MethodInfo method = fi.DeclaringType.GetMethod(fi.Name + "Toggled", BindingFlags.Static | BindingFlags.Public);
             if (method != null)
             {
                 method.Invoke(null, null);
             }
         }
     }
 }
        private void DoField_NewTmp(FieldInfo fi, bool highlight)
        {
            if (fi.IsLiteral)
            {
                return;
            }
            string label   = GenText.SplitCamelCase(fi.Name).CapitalizeFirst();
            bool   checkOn = (bool)fi.GetValue(null);
            bool   flag    = checkOn;

            CheckboxLabeledDebug_NewTmp(label, ref checkOn, highlight);
            if (checkOn != flag)
            {
                fi.SetValue(null, checkOn);
                MethodInfo method = fi.DeclaringType.GetMethod(fi.Name + "Toggled", BindingFlags.Static | BindingFlags.Public);
                if (method != null)
                {
                    method.Invoke(null, null);
                }
            }
        }
 public Dialog_DebugOutputMenu()
 {
     this.forcePause = true;
     foreach (Type current in GenTypes.AllTypesWithAttribute <HasDebugOutputAttribute>())
     {
         MethodInfo[] methods = current.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
         for (int i = 0; i < methods.Length; i++)
         {
             MethodInfo           mi = methods[i];
             DebugOutputAttribute debugOutputAttribute;
             if (mi.TryGetAttribute(out debugOutputAttribute))
             {
                 string label  = GenText.SplitCamelCase(mi.Name);
                 Action action = delegate
                 {
                     mi.Invoke(null, null);
                 };
                 CategoryAttribute categoryAttribute = null;
                 string            category;
                 if (mi.TryGetAttribute(out categoryAttribute))
                 {
                     category = categoryAttribute.name;
                 }
                 else
                 {
                     category = "General";
                 }
                 this.debugOutputs.Add(new Dialog_DebugOutputMenu.DebugOutputOption
                 {
                     label    = label,
                     category = category,
                     action   = action
                 });
             }
         }
     }
     this.debugOutputs = (from r in this.debugOutputs
                          orderby r.category, r.label
                          select r).ToList <Dialog_DebugOutputMenu.DebugOutputOption>();
 }
 private string LegibleFieldName(FieldInfo fi)
 {
     return(GenText.SplitCamelCase(fi.Name).CapitalizeFirst());
 }