コード例 #1
0
ファイル: UiBuilder.cs プロジェクト: witcheslive/Dalamud
        /// <summary>
        /// Create a new UiBuilder and register it. You do not have to call this manually.
        /// </summary>
        /// <param name="interfaceManager">The interface manager to register on.</param>
        /// <param name="namespaceName">The plugin namespace.</param>
        internal UiBuilder(InterfaceManager interfaceManager, GameGui gameGui, DalamudConfiguration config, string namespaceName)
        {
            this.namespaceName = namespaceName;

            this.interfaceManager         = interfaceManager;
            this.gameGui                  = gameGui;
            this.config                   = config;
            this.interfaceManager.OnDraw += OnDraw;
            this.stopwatch                = new System.Diagnostics.Stopwatch();
        }
コード例 #2
0
ファイル: Dalamud.cs プロジェクト: goaaats/Dalamud
    /// <summary>
    /// Initializes a new instance of the <see cref="Dalamud"/> class.
    /// </summary>
    /// <param name="info">DalamudStartInfo instance.</param>
    /// <param name="loggingLevelSwitch">LoggingLevelSwitch to control Serilog level.</param>
    /// <param name="finishSignal">Signal signalling shutdown.</param>
    /// <param name="configuration">The Dalamud configuration.</param>
    public Dalamud(DalamudStartInfo info, LoggingLevelSwitch loggingLevelSwitch, ManualResetEvent finishSignal, DalamudConfiguration configuration)
    {
        this.ApplyProcessPatch();

        Service <Dalamud> .Set(this);

        Service <DalamudStartInfo> .Set(info);

        Service <DalamudConfiguration> .Set(configuration);

        this.LogLevelSwitch = loggingLevelSwitch;

        this.unloadSignal = new ManualResetEvent(false);
        this.unloadSignal.Reset();

        this.finishUnloadSignal = finishSignal;
        this.finishUnloadSignal.Reset();
    }
コード例 #3
0
    /// <summary>
    /// Initialize all Dalamud subsystems and start running on the main thread.
    /// </summary>
    /// <param name="info">The <see cref="DalamudStartInfo"/> containing information needed to initialize Dalamud.</param>
    private static void RunThread(DalamudStartInfo info)
    {
        if (EnvironmentConfiguration.DalamudWaitForDebugger)
        {
            while (!Debugger.IsAttached)
            {
                Thread.Sleep(100);
            }
        }

        // Setup logger
        var levelSwitch = InitLogging(info.WorkingDirectory);

        // Load configuration first to get some early persistent state, like log level
        var configuration = DalamudConfiguration.Load(info.ConfigurationPath);

        // Set the appropriate logging level from the configuration
#if !DEBUG
        levelSwitch.MinimumLevel = configuration.LogLevel;
#endif

        // Log any unhandled exception.
        AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
        TaskScheduler.UnobservedTaskException      += OnUnobservedTaskException;

        var finishSignal = new ManualResetEvent(false);

        try
        {
            if (info.DelayInitializeMs > 0)
            {
                Log.Information(string.Format("Waiting for {0}ms before starting a session.", info.DelayInitializeMs));
                Thread.Sleep(info.DelayInitializeMs);
            }

            Log.Information(new string('-', 80));
            Log.Information("Initializing a session..");

            // This is due to GitHub not supporting TLS 1.0, so we enable all TLS versions globally
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls;

            if (!Util.IsLinux())
            {
                InitSymbolHandler(info);
            }

            var dalamud = new Dalamud(info, levelSwitch, finishSignal, configuration);
            Log.Information("Starting a session..");

            // Run session
            dalamud.LoadTier1();
            dalamud.WaitForUnload();

            dalamud.Dispose();
        }
        catch (Exception ex)
        {
            Log.Fatal(ex, "Unhandled exception on main thread.");
        }
        finally
        {
            TaskScheduler.UnobservedTaskException      -= OnUnobservedTaskException;
            AppDomain.CurrentDomain.UnhandledException -= OnUnhandledException;

            Log.Information("Session has ended.");
            Log.CloseAndFlush();

            finishSignal.Set();
        }
    }