Example #1
0
    public Plugin(
        DalamudPluginInterface pi
        , SigScanner sigScanner
        , ClientState clientState
        , CommandManager commands
        , Condition condition
        , TargetManager targetManager
        , [RequiredVersion("1.0")] GameGui gameGui
        )
    {
        _pluginInterface = pi;
        _config          = GetAndMigrateConfig(pi);
        _clientState     = clientState;
        _commands        = commands;
        _compass         = new Compass(
            condition,
            targetManager,
            gameGui,
            _config
            );

        _clientState.Login  += OnLogin;
        _clientState.Logout += OnLogout;

        _commands.AddHandler(Command, new CommandInfo(CommandHandler)
        {
            HelpMessage =
                string.Format(i18n.command_help_text, PluginName, Command),
            ShowInHelp = true
        });

        DebugCtor(sigScanner);
        if (_pluginInterface.Reason == PluginLoadReason.Installer)
        {
            // NOTE: Centers compass on first install
            SimpleLog.Information("Fresh install of Compass; centering compass, drawing modal.");
            var screenSizeCenterX = (ImGuiHelpers.MainViewport.Size * 0.5f).X;
            _config.ImGuiCompassPosition = _config.ImGuiCompassPosition with {
                X = screenSizeCenterX - _config.ImGuiCompassWidth * 0.5f
            };
            _buildingConfigUi                = true;
            _config.FreshInstall             = true;
            _pluginInterface.UiBuilder.Draw += DrawConfigUi;
        }

        if (_clientState.LocalPlayer is not null)
        {
            OnLogin(null !, null !);
        }
    }