Exemplo n.º 1
0
        private void Add_Error(string format, params object[] args)
        {
            string str = DebugHud.Format_Log(format, 1, args);

            Errors.Add(str);
            SLog.Info("[ <b>{0}</b> ] {1}", this.dll_name, str);
            onError?.Invoke();
        }
Exemplo n.º 2
0
        public static string Format_Log(string format, int stack_offset = 0, params object[] args)
        {
            StackFrame frame = new StackFrame(1 + stack_offset, true);
            string     meth  = frame.GetMethod().ReflectedType.FullName;
            string     funct = frame.GetMethod().Name;
            int        line  = frame.GetFileLineNumber();

            string str = String.Format(format, args);

            str = DebugHud.Tag_String(String.Format("{0}  [Function: {1}::{2} @ Line: {3}]", str, meth, funct, line), 1);

            return(str);
        }
Exemplo n.º 3
0
        public static string Format_Exception_Log(Exception ex, int stack_offset = 0)
        {
            string str = null;

            try
            {
                //string trace = new StackTrace(ex, 1 + stack_offset, true).ToString();
                string trace = StackTraceUtility.ExtractStringFromException(ex);
                str = String.Format("{0}\n{1}", ex.Message, trace);
            }
            catch (Exception e)
            {
                write_log("DebugHUD.Format_Exception_Log() THREW AN INTERNAL EXCEPTION!\n{0}\n{1}", e.Message, e.StackTrace);
                str = String.Format("{0}\n{1}", ex.Message, StackTraceUtility.ExtractStackTrace());
            }

            if (ex.InnerException != null)
            {
                str = String.Format("{0}\n{1}", str, ex.InnerException.Message);
            }

            return(DebugHud.Format_Log(str, 2 + stack_offset));//reformat our exception string with an additional stack offset of 1 to make it skip past the function that called THIS format function.
            //return DebugHud.Tag_String(str, stack_offset);
        }
Exemplo n.º 4
0
        public static void init(string hash)
        {
            lock (locker)
            {
                if (Loader.Config != null)
                {
                    return;
                }
                //Application.stackTraceLogType = StackTraceLogType.Full;
                Logging.Logger.Begin(Path.Combine(Application.dataPath, "plugins.log"));

                Stopwatch timer = new Stopwatch();
                timer.Start();

                if (!Loader.Load_Config_Stream())
                {
                    return;
                }

                try
                {
                    DebugHud.Init();
                    TextureHelper.Setup();
                    MaterialHelper.Setup();
                    SiscosHooks.Setup();
                    PluginLoader_Watermark.Setup();
                    MainMenu.Setup();
                    DebugUI.Setup();

                    Setup_Update_Helper();
                    bool ok = Verify_PluginLoader_Hash(hash);
                    if (!ok)
                    {
                        return;
                    }

                    IN_LOADING_PHASE = true;
                    Setup_Plugin_Dir();

                    Check_For_Updates();

                    Setup_Assembly_Resolver();
                    Upgrades.Setup();
                    Assemble_Plugin_List();
                    Load_Config();
                    IN_LOADING_PHASE = false;
                    ResourceExt.map_SR_Icons();

                    plugin_updater = uiControl.Create <Plugin_Update_Viewer>();// This control manages itself and is only able to become visible under certain conditions which it will control. Therefore it needs no var to track it.
                    plugin_updater.Show();

                    dev_tools = uiControl.Create <DevMenu>();
                    //dev_tools.Show();
                    //dev_tools.onShown += (uiWindow w) => { GameTime.Pause(); };
                    //dev_tools.onHidden += (uiWindow w) => { GameTime.Unpause(); };

                    //Misc_Experiments.Find_Common_Classes_For_Idents(new HashSet<Identifiable.Id> { Identifiable.Id.PINK_RAD_LARGO });
                }
                catch (Exception ex)
                {
                    SLog.Error("Exception during PluginLoader initialization!");
                    SLog.Error(ex);
                }
                finally
                {
                    timer.Stop();
                    SLog.Debug("Plugin Loader initialized! Took: {0}ms", timer.ElapsedMilliseconds);
                }
            }
        }
        public static _hook_result call(HOOK_ID hook, object sender, ref object returnValue, object[] args)
        {
            try
            {
#if DEBUG
                SLog.Info("[SiscosHooks] {0}({1})", hook, Get_Arg_String(args));
#endif

                _hook_result result = new _hook_result(args);
                Dictionary <HookUID, Sisco_Hook_Delegate> cb_list;
                bool r = Events.TryGetValue((HOOK_ID)hook, out cb_list);
                if (r == false)
                {
                    return(new _hook_result());           //no abort
                }
                List <HookUID> TRASH = null;

                foreach (KeyValuePair <HookUID, Sisco_Hook_Delegate> kvp in cb_list)
                {
                    try
                    {
                        HookUID UID = kvp.Key;
                        UID.hasFired = true;

                        Sisco_Hook_Delegate act = kvp.Value;
                        if (act == null)
                        {
                            continue;
                        }
                        Sisco_Return ret = act(ref sender, ref result.args, ref returnValue);
                        // If this hook is a singleuse hook then we need to put it in our trashbin so we know to unregister it at the end of this function.
                        if (UID.SingleUse)
                        {
                            if (TRASH == null)
                            {
                                TRASH = new List <HookUID>();
                            }
                            TRASH.Add(UID);
                        }

                        if (ret != null)
                        {
                            if (ret.early_return)
                            {
                                result.abort = true;
                            }
                            if (ret.handled == true)
                            {
                                result.handled = true;
                                break;//cancel all other events
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log(hook, ex.Message);
                        Log(ex.StackTrace);
                    }
                }

                if (TRASH != null)
                {
                    foreach (HookUID uid in TRASH)
                    {
                        try { unregister(uid); } catch (Exception ex) { Log(uid.hook, DebugHud.Format_Exception_Log(ex)); }
                    }
                }

                if (result == null)
                {
                    Log(hook, "Result became NULL somehow!");
                    return(new _hook_result());// we MUST return something other then NULL or the whole game can screw up!
                }

                if (args != null && args.Length != result.args.Length)
                {
                    Log(hook, "The size of Result.args does not match the number of arguments recieved from the function!");
                }

                return(result);
            }
            catch (Exception ex)
            {
                Log(hook, ex.Message);
                Log(ex.StackTrace);
                return(new _hook_result());
            }

            return(new _hook_result());//no abort
        }
Exemplo n.º 6
0
        public static void Log(Exception ex)
        {
            string str = DebugHud.Format_Exception_Log(ex, 1);

            DebugHud.Add_Line(str, true);
        }
Exemplo n.º 7
0
        public static void Log(string format, params object[] args)
        {
            string str = DebugHud.Tag_String(String.Format(format, args), 1);

            DebugHud.Add_Line(str);
        }
Exemplo n.º 8
0
        public static void Log(string format)
        {
            string str = DebugHud.Tag_String(format, 1);

            DebugHud.Add_Line(str);
        }
Exemplo n.º 9
0
        public static void LogSilent(Exception ex)
        {
            string str = DebugHud.Format_Exception_Log(ex, 0);

            DebugHud.write_log(str);
        }
Exemplo n.º 10
0
 public static void LogSilent(string str)
 {
     DebugHud.write_log(str);
 }
Exemplo n.º 11
0
        public static void LogSilent(string format, params object[] args)
        {
            string str = DebugHud.Format_Log(format, 1, args);

            DebugHud.write_log(str);
        }