Ejemplo n.º 1
0
        // This will be added as a Postfix to the method which we want to gather stack trace information for
        // it will only effect one method, so we can skip the check, and it will not slow down other profilers
        // because it will only be patched onto one method. There can be extra checks and flexibility in how
        // many frames are grabbed p/s etc. These are to be done when the GUI decisions have been made.

        public static void StacktracePostfix(MethodBase __originalMethod)
        {
            if (++currentTrackedStacktraces < currentGoalTrackedTraces)
            {
                StackTraceRegex.Add(new StackTrace(2, false));
            }
            else
            {
                currentlyTracking = false;
            }
        }
Ejemplo n.º 2
0
        private static void Reset(MethodInfo oldMethod)
        {
            if (oldMethod == null)
            {
                return;
            }

            currentTrace = "";
            StackTraceRegex.Reset();
            currentTrackedStacktraces = 0;
            Modbase.Harmony.CreateProcessor(oldMethod).Unpatch(postfix);
            currentlyTracking = false;
        }
Ejemplo n.º 3
0
        private void ProcessInput(StackTrace stackTrace)
        {
            // Translate our input into the strings we will want to show the user
            var processedString = StackTraceRegex.ProcessString(StackTraceRegex.ExtractStackTraceInformation(stackTrace));

            translatedStringArr = processedString.Split('#');

            // Get patch methods for any methods in the stack trace
            for (int i = 0; i < stackTrace.FrameCount; i++)
            {
                var frameMethod = stackTrace.GetFrame(i).GetMethod();
                methods.Insert(i, new Tuple <MethodInfo, List <Patch> >(frameMethod as MethodInfo, new List <Patch>()));
            }
        }
Ejemplo n.º 4
0
        private static float DrawCheckbox(ref Rect rect, MethodInfo meth)
        {
            var checkBoxWidth = 30.0f + $"Enable for {meth.Name}".GetWidthCached();
            var checkBox      = rect.LeftPartPixels(checkBoxWidth);

            if (DubGUI.Checkbox(checkBox, $"Enable for {meth.Name}", ref currentlyTracking))
            {
                if (currentlyTracking)
                {
                    Modbase.Harmony.Patch(meth, postfix: new HarmonyMethod(postfix));
                    StackTraceRegex.Reset();
                    currentTrace = "";
                    currentTrackedStacktraces = 0;
                }
                else
                {
                    Modbase.Harmony.CreateProcessor(meth).Unpatch(postfix);
                }
            }

            return(checkBoxWidth);
        }