Exemplo n.º 1
0
        public IMEPlugin()
        {
            Config = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            Config.Initialize(PluginInterface);

            this.InGameIMEFunc    = SigScanner.ScanText("40 53 48 83 EC 20 41 C7 00 ?? ?? ?? ??");
            this.IsDirectChatFunc = SigScanner.ScanText("40 56 48 83 EC 30 80 79 1C 00");
            PluginLog.Log($"===== I M E P L U G I N =====");
            PluginLog.Log($"InGameIMEFunc addr:{InGameIMEFunc:X}");
            PluginLog.Log($"IsDirectChatFunc addr:{IsDirectChatFunc:X}");

            this.InGameIMEFuncHook = new Hook <InGameIMEFuncDelegate>(
                InGameIMEFunc,
                new InGameIMEFuncDelegate(InGameIMEFuncDetour)
                );
            this.IsDirectChatFuncHook = new Hook <IsDirectChatFuncDelegate>(
                IsDirectChatFunc,
                new IsDirectChatFuncDelegate(IsDirectChatFuncDetour)
                );

            Gui = new PluginUi(this);

            CommandManager.AddHandler("/imeplugin", new CommandInfo(CommandHandler)
            {
                HelpMessage = "/imeplugin - open the IMEPlugin panel."
            });

            this.InGameIMEFuncHook.Enable();
            this.IsDirectChatFuncHook.Enable();
        }
Exemplo n.º 2
0
        public ChatTranslator()
        {
            _configuration    = PluginInterface.GetPluginConfig() as Config ?? new Config();
            Chat.ChatMessage += Chat_OnChatMessage;

            PluginInterface.UiBuilder.Draw         += TranslatorConfigUi;
            PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;
            CommandManager.AddHandler("/trn", new CommandInfo(Command)
            {
                HelpMessage = "Opens the Chat Translator config menu"
            });
            _uiColours       = Data.Excel.GetSheet <UIColor>();
            _channels        = _configuration.Channels;
            _textColour      = _configuration.TextColour;
            _tranMode        = _configuration.TranMode;
            _languageInt     = _configuration.Lang;
            _whitelist       = _configuration.Whitelist;
            _notSelf         = _configuration.NotSelf;
            _oneChan         = _configuration.OneChan;
            _oneInt          = _configuration.OneInt;
            _chosenLanguages = _configuration.ChosenLanguages;
            _blacklist       = _configuration.Blacklist;

            Thread t = new Thread(new ThreadStart(ThreadProc));

            t.Start();
        }
Exemplo n.º 3
0
        public PennyPincher()
        {
            configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            LoadConfig();

            items      = Data.GetExcelSheet <Item>();
            newRequest = false;

            PluginInterface.UiBuilder.Draw         += DrawWindow;
            PluginInterface.UiBuilder.OpenConfigUi += OpenConfigUi;

            CommandManager.AddHandler(commandName, new CommandInfo(Command)
            {
                HelpMessage = $"Opens the {Name} config menu",
            });

            GameNetwork.NetworkMessage += OnNetworkEvent;

            try
            {
                var ptr = SigScanner.ScanText("E8 ?? ?? ?? ?? 48 85 C0 74 14 83 7B 44 00");
                getFilePtr = Marshal.GetDelegateForFunctionPointer <GetFilePointer>(ptr);
            }
            catch (Exception e)
            {
                getFilePtr = null;
                PluginLog.LogError(e.ToString());
            }
        }
Exemplo n.º 4
0
 private void LoadConfig()
 {
     try
     {
         this.Configuration = PluginInterface.GetPluginConfig() as PluginConfig ?? new PluginConfig();
     }
     catch (Exception ex)
     {
         Logger.LogError("Failed to load config so creating new one.", ex);
         this.Configuration = new PluginConfig();
         this.SaveConfig();
     }
 }
Exemplo n.º 5
0
 public void LoadConfig(bool clearConfig = false)
 {
     try {
         if (clearConfig)
         {
             this.PluginConfig = new RemindMeConfig();
         }
         else
         {
             this.PluginConfig = (RemindMeConfig)PluginInterface.GetPluginConfig() ?? new RemindMeConfig();
         }
         this.PluginConfig.Init(this, PluginInterface);
     } catch (Exception ex) {
         PluginLog.LogError("Failed to load config.");
         PluginLog.LogError(ex.ToString());
         PluginConfig = new RemindMeConfig();
         PluginConfig.Init(this, PluginInterface);
         configLoadException = ex;
     }
 }
Exemplo n.º 6
0
        public XIVComboPlugin()
        {
            CommandManager.AddHandler("/pcombo", new CommandInfo(OnCommandDebugCombo)
            {
                HelpMessage = "Open a window to edit custom combo settings.",
                ShowInHelp  = true
            });

            this.Configuration = PluginInterface.GetPluginConfig() as XIVComboConfiguration ?? new XIVComboConfiguration();
            if (Configuration.Version < 3)
            {
                Configuration.HiddenActions = new List <bool>();
                for (var i = 0; i < Enum.GetValues(typeof(CustomComboPreset)).Length; i++)
                {
                    Configuration.HiddenActions.Add(false);
                }
                Configuration.Version = 3;
            }

            this.iconReplacer = new IconReplacer(TargetModuleScanner, ClientState, this.Configuration);

            this.iconReplacer.Enable();

            PluginInterface.UiBuilder.OpenConfigUi += () => isImguiComboSetupOpen = true;
            PluginInterface.UiBuilder.Draw         += UiBuilder_OnBuildUi;

            /*
             * pluginInterface.Subscribe("PingPlugin", e => {
             *  dynamic msg = e;
             *  iconReplacer.UpdatePing(msg.LastRTT / 2);
             *  PluginLog.Log("Ping was updated to {0} ms", msg.LastRTT / 2);
             *  });
             */
            var values = Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>();

            orderedByClassJob = values.Where(x => x != CustomComboPreset.None && x.GetAttribute <CustomComboInfoAttribute>() != null).OrderBy(x => x.GetAttribute <CustomComboInfoAttribute>().ClassJob).ToArray();
            UpdateConfig();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MBPlugin"/> class.
        /// This is the plugin's entry point.
        /// </summary>
        public MBPlugin()
        {
            this.config = (MBPluginConfig)PluginInterface.GetPluginConfig() ?? new MBPluginConfig();

            this.marketBoardWindow = new MarketBoardWindow(this.config);

            // Set up command handlers
            CommandManager.AddHandler("/pmb", new CommandInfo(this.OnOpenMarketBoardCommand)
            {
                HelpMessage = "Open the market board window.",
            });

            PluginInterface.UiBuilder.Draw += this.BuildMarketBoardUi;

            // Set up context menu
            this.contextMenuBase          = new DalamudContextMenuBase();
            this.inventoryContextMenuItem = new InventoryContextMenuItem(
                new SeString(new TextPayload("Search with Market Board Plugin")), this.OnSelectContextMenuItem);
            this.contextMenuBase.Functions.ContextMenu.OnOpenInventoryContextMenu += this.OnContextMenuOpened;

#if DEBUG
            this.marketBoardWindow.IsOpen = true;
#endif
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlayerTrackPlugin"/> class.
        /// </summary>
        public PlayerTrackPlugin()
        {
            Task.Run(() =>
            {
                try
                {
                    // setup common libs
                    this.localization  = new Localization(PluginInterface, CommandManager);
                    this.BackupManager = new BackupManager(PluginInterface.GetPluginConfigDirectory());
                    this.XivCommon     = new XivCommonBase(Hooks.NamePlates);

                    // load config
                    try
                    {
                        this.Configuration = PluginInterface.GetPluginConfig() as PlayerTrackConfig ??
                                             new PlayerTrackConfig();
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Failed to load config so creating new one.", ex);
                        this.Configuration = new PlayerTrackConfig();
                        this.SaveConfig();
                    }

                    // setup services
                    this.BaseRepository       = new BaseRepository(GetPluginFolder());
                    this.LodestoneService     = new LodestoneService(this);
                    this.ActorManager         = new ActorManager(this);
                    this.CategoryService      = new CategoryService(this);
                    this.EncounterService     = new EncounterService(this);
                    this.PlayerService        = new PlayerService(this);
                    this.VisibilityService    = new VisibilityService(this);
                    this.FCNameColorService   = new FCNameColorService(this);
                    this.PlayerTrackProvider  = new PlayerTrackProvider(PluginInterface, new PlayerTrackAPI(this));
                    this.WindowManager        = new WindowManager(this);
                    this.PluginCommandManager = new PluginCommandManager(this);
                    this.NamePlateManager     = new NamePlateManager(this);

                    // run backup
                    this.backupTimer = new Timer {
                        Interval = this.Configuration.BackupFrequency, Enabled = false
                    };
                    this.backupTimer.Elapsed += this.BackupTimerOnElapsed;
                    var pluginVersion         = Assembly.GetExecutingAssembly().VersionNumber();
                    if (this.Configuration.PluginVersion < pluginVersion)
                    {
                        Logger.LogInfo("Running backup since new version detected.");
                        this.RunUpgradeBackup();
                        this.Configuration.PluginVersion = pluginVersion;
                        this.SaveConfig();
                    }
                    else
                    {
                        this.BackupTimerOnElapsed(this, null);
                    }

                    // migrate if needed
                    var success = Migrator.Migrate(this);
                    if (success)
                    {
                        // special handling for fresh install
                        this.HandleFreshInstall();

                        // reset categories if failed to load
                        if (this.CategoryService.GetCategories().Length == 0)
                        {
                            this.CategoryService.ResetCategories();
                        }

                        // start plugin
                        this.IsDoneLoading       = true;
                        this.backupTimer.Enabled = true;
                        this.VisibilityService.Start();
                        this.FCNameColorService.Start();
                        this.ActorManager.Start();
                        this.WindowManager.AddWindows();
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex, "Failed to initialize plugin.");
                }
            });
        }
Exemplo n.º 9
0
        public Plugin()
        {
            _pluginConfiguration = (PluginConfiguration)(PluginInterface.GetPluginConfig() ?? new PluginConfiguration());

            PluginInterface.UiBuilder.BuildFonts += UiBuilderOnBuildFonts;
            PluginInterface.UiBuilder.RebuildFonts();

            _hudWindowWindow     = new HudWindow(_pluginConfiguration);
            _configurationWindow = new ConfigurationWindow(this, _pluginConfiguration);

            var items = new[]
            {
                "CleanCurves",
                "GlowArc",
                "RivetBar"
            };

            foreach (var item in items)
            {
                LoadStyle(item, Path.Combine(PluginInterface.AssemblyLocation.DirectoryName !, "Styles"), false);
            }

            if (!string.IsNullOrEmpty(_pluginConfiguration.UserStylePath))
            {
                if (!Directory.Exists(_pluginConfiguration.UserStylePath))
                {
                    PluginLog.Error($"{_pluginConfiguration.UserStylePath} was not found.");
                }
                else
                {
                    foreach (var item in Directory.GetDirectories(_pluginConfiguration.UserStylePath))
                    {
                        LoadStyle(item, _pluginConfiguration.UserStylePath, true);
                    }
                }
            }

            if (_pluginConfiguration.IsUserStyle && !UserStyles.ContainsKey(_pluginConfiguration.SelectedStyle))
            {
                _pluginConfiguration.IsUserStyle   = false;
                _pluginConfiguration.SelectedStyle = items[0];
                _pluginConfiguration.Save();
            }

            if (_pluginConfiguration.IsUserStyle)
            {
                _pluginConfiguration.BarImage           = UserStyles[_pluginConfiguration.SelectedStyle][0];
                _pluginConfiguration.BarBackgroundImage =
                    UserStyles[_pluginConfiguration.SelectedStyle][1];
                _pluginConfiguration.BarCastImage           = UserStyles[_pluginConfiguration.SelectedStyle][2];
                _pluginConfiguration.BarCastBackgroundImage =
                    UserStyles[_pluginConfiguration.SelectedStyle][3];
            }
            else
            {
                _pluginConfiguration.BarImage           = Styles[_pluginConfiguration.SelectedStyle][0];
                _pluginConfiguration.BarBackgroundImage =
                    Styles[_pluginConfiguration.SelectedStyle][1];
                _pluginConfiguration.BarCastImage           = Styles[_pluginConfiguration.SelectedStyle][2];
                _pluginConfiguration.BarCastBackgroundImage =
                    Styles[_pluginConfiguration.SelectedStyle][3];
            }

            CommandManager.AddHandler("/pside", new CommandInfo(PluginCommand)
            {
                HelpMessage = "Opens configuration window",
                ShowInHelp  = true
            });

            PluginInterface.UiBuilder.Draw         += UiBuilderOnOnBuildUi;
            PluginInterface.UiBuilder.OpenConfigUi += UiBuilderOnOnOpenConfigUi;
        }
Exemplo n.º 10
0
        public VisibilityPlugin()
        {
            Instance           = this;
            this.Configuration = PluginInterface.GetPluginConfig() as VisibilityConfiguration ??
                                 new VisibilityConfiguration();
            this.Configuration.Init(ClientState.TerritoryType);
            this.PluginLocalization = new Localization(this.Configuration.Language);

            CommandManager.AddHandler(
                PluginCommandName,
                new CommandInfo(this.PluginCommand)
            {
                HelpMessage = this.PluginLocalization.PluginCommandHelpMessage,
                ShowInHelp  = true
            });

            CommandManager.AddHandler(
                VoidCommandName,
                new CommandInfo(this.VoidPlayer)
            {
                HelpMessage = this.PluginLocalization.VoidPlayerHelpMessage,
                ShowInHelp  = true
            });

            CommandManager.AddHandler(
                VoidTargetCommandName,
                new CommandInfo(this.VoidTargetPlayer)
            {
                HelpMessage = this.PluginLocalization.VoidTargetPlayerHelpMessage,
                ShowInHelp  = true
            });

            CommandManager.AddHandler(
                WhitelistCommandName,
                new CommandInfo(this.WhitelistPlayer)
            {
                HelpMessage = this.PluginLocalization.WhitelistPlayerHelpMessage,
                ShowInHelp  = true
            });

            CommandManager.AddHandler(
                WhitelistTargetCommandName,
                new CommandInfo(this.WhitelistTargetPlayer)
            {
                HelpMessage = this.PluginLocalization.WhitelistTargetPlayerHelpMessage,
                ShowInHelp  = true
            });

            this.characterDrawResolver = new CharacterDrawResolver();
            this.characterDrawResolver.Init();

            Framework.Update += this.FrameworkOnOnUpdateEvent;

            PluginInterface.UiBuilder.Draw         += this.BuildUi;
            PluginInterface.UiBuilder.OpenConfigUi += this.OpenConfigUi;
            ChatGui.ChatMessage          += this.OnChatMessage;
            ClientState.TerritoryChanged += this.ClientStateOnTerritoryChanged;

            this.Api         = new VisibilityApi();
            this.IpcProvider = new VisibilityProvider(this.Api);
        }