コード例 #1
0
ファイル: PingPlugin.cs プロジェクト: ShadyWhite/PingPlugin
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;

            var getBaseUIObjScan    = this.pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
            var getUI2ObjByNameScan = this.pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

            this.getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(getBaseUIObjScan);
            this.getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(getUI2ObjByNameScan);
            this.chatLogObject   = this.getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog");

            this.config = (PingConfiguration)this.pluginInterface.GetPluginConfig() ?? new PingConfiguration();
            this.config.Initialize(this.pluginInterface);

            this.pingTracker = new AggregatePingTracker(this.config,
                                                        new ComponentModelPingTracker(this.config),
                                                        new Win32APIPingTracker(this.config));

            this.pluginInterface.Framework.OnUpdateEvent += OnFrameworkUpdate;

            this.ui = new PingUI(this.pingTracker, this.config);

            this.pluginInterface.UiBuilder.OnOpenConfigUi += (sender, e) => this.ui.ConfigVisible = true;
            this.pluginInterface.UiBuilder.OnBuildUi      += this.ui.BuildUi;

            AddCommandHandlers();
        }
コード例 #2
0
        public unsafe void Initialize(DalamudPluginInterface pluginInterface)
        {
            setNamePlatePtr = pluginInterface.TargetModuleScanner.ScanText("48 89 5C 24 ?? 48 89 6C 24 ?? 56 57 41 54 41 56 41 57 48 83 EC 40 44 0F B6 E2");
            setNamePlate    = new SetNamePlate(setNamePlateFunc);
            try
            { setNamePlateHook = new Hook <SetNamePlate>(setNamePlatePtr, setNamePlate, this); setNamePlateHook.Enable(); }
            catch (Exception e)
            { PluginLog.Log("BAD 1\n" + e.ToString()); }


            scaleIconPtr = pluginInterface.TargetModuleScanner.ScanText("8B 81 ?? ?? ?? ?? A8 01 75 ?? F3 0F 10 41 ?? 0F 2E C1 7A ?? 75 ?? F3 0F 10 41 ?? 0F 2E C2 7A ?? 74 ?? 83 C8 01 89 81 ?? ?? ?? ?? F3 0F 10 05 ?? ?? ?? ??");
            scaleIcon    = Marshal.GetDelegateForFunctionPointer <scaleIconFunc>(scaleIconPtr);

            var GetBaseUIObject = pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
            var GetUI2ObjByName = pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

            getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(GetBaseUIObject);
            getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(GetUI2ObjByName);

            this.pluginInterface = pluginInterface;
            Configuration        = pluginInterface.GetPluginConfig() as Config ?? new Config();

            role    = Configuration.Role;
            enabled = Configuration.Enabled;
            scaler  = Configuration.Scale;
            xAdjust = Configuration.XAdjust;
            yAdjust = Configuration.YAdjust;

            this.pluginInterface.CommandManager.AddHandler("/jicons", new CommandInfo(Command)
            {
                HelpMessage = "Opens Job Icons config."
            });

            baseUIObject     = getBaseUIObj();
            baseUiProperties = Marshal.ReadIntPtr(baseUIObject, 0x20);

            UIModulePtr      = Marshal.ReadIntPtr(pluginInterface.Framework.Address.BaseAddress, 0x29F8);
            UI3DModule       = Marshal.ReadIntPtr(UIModulePtr, 0xA62C0);
            RaptureAtkModule = (RaptureAtkModule *)(Marshal.ReadIntPtr(pluginInterface.Framework.Address.BaseAddress, 0x29F8) + 0xB3780).ToPointer();

            nameplateUIPtr = getUI2ObjByName(baseUiProperties, "NamePlate", 1);
            if (nameplateUIPtr != IntPtr.Zero)
            {
                npObjArray = ((AddonNamePlate *)nameplateUIPtr)->NamePlateObjectArray;
            }


            this.pluginInterface.UiBuilder.OnOpenConfigUi += ConfigWindow;
            this.pluginInterface.UiBuilder.OnBuildUi      += DrawWindow;
        }
コード例 #3
0
ファイル: Dev.cs プロジェクト: Haplo064/Dev
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;
            Configuration        = pluginInterface.GetPluginConfig() as Config ?? new Config();
            this.pluginInterface.UiBuilder.OnBuildUi += DrawWindow;

            this.pluginInterface.UiBuilder.OnOpenConfigUi += ConfigWindow;
            this.pluginInterface.CommandManager.AddHandler("/dev", new CommandInfo(Command)
            {
                HelpMessage = ""
            });
            this.pluginInterface.CommandManager.AddHandler("/devc", new CommandInfo(CommandC)
            {
                HelpMessage = ""
            });


            //**********************************
            //**         DEV FROM HERE        **
            //**********************************

            scan1 = pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
            scan2 = pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

            funcPtr = pluginInterface.TargetModuleScanner.Module.BaseAddress + 0x4cd440;

            ukFunc     = new UnknownFunc(ukFuncFunc);
            ukFuncHook = new Hook <UnknownFunc>(funcPtr, ukFunc, this);

            getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(scan1);
            getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(scan2);
            chatLog         = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
            chatLogStuff    = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
            chatLogPanel_0  = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);

            chatLogPosition = new float[2];


            PluginLog.Log(chatLog.ToString());
        }
コード例 #4
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            var imagePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Chat_Box_A.png");

            goatImage = pluginInterface.UiBuilder.LoadImage(imagePath);


            // Initializing plugin, hooking into chat.
            this.pluginInterface = pluginInterface;
            Configuration        = pluginInterface.GetPluginConfig() as ChatExtenderPluginConfiguration ?? new ChatExtenderPluginConfiguration();
            this.pluginInterface.UiBuilder.OnBuildFonts += AddFont;
            this.pluginInterface.UiBuilder.RebuildFonts();


            //Hooks for FFXIV ChatBox
            scan1 = pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
            scan2 = pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

            getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(scan1);
            getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(scan2);
            chatLog         = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
            chatLogStuff    = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
            chatLogPanel_0  = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
            chatLogPosition = new float[2];

            tab_ind       = UintCol(255, 50, 70, 50);
            tab_ind_text  = UintCol(255, 150, 150, 150);
            tab_norm      = UintCol(255, 50, 50, 50);
            tab_norm_text = UintCol(255, 150, 150, 150);
            tab_sel       = UintCol(255, 90, 90, 90);
            tab_sel_text  = UintCol(255, 250, 255, 255);

            try
            { allowTranslation = Configuration.AllowTranslation; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Translation setting!");
                allowTranslation = false;
            }

            try
            { bubblesWindow = Configuration.BubblesWindow; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load BubbleWindow setting!");
                bubblesWindow = false;
            }

            try
            { hourTime = Configuration.HourTime; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Hour Time Config!");
                bubblesWindow = false;
            }

            try
            { rTr = Configuration.RTr.ToString(); }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load right Translate Surround!");
            }

            try
            { lTr = Configuration.LTr.ToString(); }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load left Translate Surround!");
            }

            try
            { chanColour = Configuration.ChanColour.ToArray(); }
            catch (Exception)
            { PluginLog.LogError("No ChanColour to load!"); }

            try
            { bubbleEnable = Configuration.BubbleEnable.ToArray(); }
            catch (Exception)
            { PluginLog.LogError("No BubbleEnable to load!"); }

            try
            { logColour = Configuration.LogColour.ToArray(); }
            catch (Exception)
            { PluginLog.LogError("No LogColour to load!"); }

            try
            { bubbleColour = Configuration.BubbleColour.ToArray(); }
            catch (Exception)
            { PluginLog.LogError("No BubbleColour to load!"); }

            try
            { injectChat = Configuration.Inject; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Inject Status!");
                injectChat = false;
            }

            try
            { fontShadow = Configuration.FontShadow; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Font Shadow!");
                fontShadow = false;
            }

            try
            {
                if (Configuration.BubbleTime.HasValue)
                {
                    bubbleTime = Configuration.BubbleTime.Value;
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load BubbleTime!");
                bubbleTime = 15;
            }

            try
            {
                if (Configuration.Translator.HasValue)
                {
                    translator = Configuration.Translator.Value;
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Translator Choice!");
                translator = 1;
            }

            try
            {
                if (Configuration.FontSize.HasValue)
                {
                    fontsize = Configuration.FontSize.Value;
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Font Size!");
                fontsize = 15;
            }

            try
            { yandex = Configuration.YandexKey.ToString(); }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Yandex Key!");
                yandex = "";
            }

            try
            { chatWindow = Configuration.Extender; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Extender Choice!");
                chatWindow = false;
            }

            try
            { alpha = Configuration.Alpha; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Alpha!");
                alpha = 0.2f;
            }

            try
            { no_move = Configuration.NoMove; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load NoMove Config!");
                no_move = false;
            }

            try
            { no_resize = Configuration.NoResize; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load NoMove Config!");
                no_resize = false;
            }

            try
            { no_mouse = Configuration.NoMouse; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load NoMouse Config!");
                no_mouse = false;
            }

            try
            {
                high     = Configuration.High;
                tempHigh = String.Join(",", high.highlights);
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Highlighter");
                high = new Highlighter();
            }

            try
            {
                if (high.highlights.Length < 1)
                {
                    high = new Highlighter();
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Highlighter");
                high = new Highlighter();
            }


            try
            { no_mouse2 = Configuration.NoMouse2; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load NoMouse2 Config!");
                no_mouse2 = false;
            }

            try
            { no_scrollbar = Configuration.NoScrollBar; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load ScrollBar Config!");
                no_scrollbar = false;
            }

            try
            {
                if (Configuration.Space_Hor.HasValue)
                {
                    space_hor = Configuration.Space_Hor.Value;
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Horizontal Spacing!");
                space_hor = 4;
            }

            try
            {
                if (Configuration.Space_Ver.HasValue)
                {
                    space_ver = Configuration.Space_Ver.Value;
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Vertical Spacing!");
                space_ver = 0;
            }

            try
            {
                if (Configuration.TimeColour.Z > 0)
                {
                    timeColour = Configuration.TimeColour;
                }
                else
                {
                    timeColour = new Num.Vector4(255, 255, 255, 255);
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Time Colour!");
                timeColour = new Num.Vector4(255, 255, 255, 255);
            }

            try
            {
                if (Configuration.NameColour.Z > 0)
                {
                    nameColour = Configuration.NameColour;
                }
                else
                {
                    nameColour = new Num.Vector4(255, 255, 255, 255);
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to Load Name Colour!");
                nameColour = new Num.Vector4(255, 255, 255, 255);
            }

            //TODO: try/catch this?
            if (Configuration.Items == null)
            {
                //Serilog.Log.Information("Null DynTab List");
                items.Add(new DynTab("XXX", new ConcurrentQueue <ChatText>(), true));
            }
            else
            {
                //Serilog.Log.Information("Not Null DynTab List");
                if (Configuration.Items.Count == 0)
                {
                    //Serilog.Log.Information("Empty DynTab List");
                    items.Add(new DynTab("YYY", new ConcurrentQueue <ChatText>(), true));
                }
                else
                {
                    //Serilog.Log.Information("Normal DynTab List");
                    items = Configuration.Items.ToList();
                }
            }

            if (items[0].Config.Length == 3)
            {
                foreach (TabBase item in items)
                {
                    bool[] temp = { false, false, false, false, false, false, false, false, false, false };
                    temp[0]     = item.Config[0];
                    temp[1]     = item.Config[1];
                    temp[2]     = item.Config[2];
                    item.Config = temp;
                }
            }

            if (items[0].Filter == null)
            {
                foreach (TabBase item in items)
                {
                    item.Filter   = "";
                    item.FilterOn = false;
                }
            }

            try
            {
                if (Configuration.Items[0].Logs.Length < Channels.Length)
                {
                    int            l        = 0;
                    List <TabBase> templist = new List <TabBase>();
                    foreach (TabBase items in Configuration.Items)
                    {
                        TabBase temp = new TabBase();
                        temp.AutoScroll = items.AutoScroll;
                        temp.Chat       = items.Chat;
                        temp.Config     = items.Config;
                        temp.Enabled    = items.Enabled;
                        temp.Scroll     = items.Scroll;
                        temp.Title      = items.Title;
                        int i = 0;
                        foreach (bool set in items.Logs)
                        {
                            //PluginLog.Log(i.ToString());
                            temp.Logs[i] = set;
                            i++;
                        }
                        //PluginLog.Log("bool length:" + temp.Logs.Length.ToString());
                        templist.Add(temp);
                        l++;
                    }

                    items = templist;

                    Num.Vector4[] logColour_temp =
                    {
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255)
                    };

                    int j = 0;
                    foreach (Num.Vector4 vec in logColour)
                    {
                        logColour_temp[j] = vec;
                        j++;
                    }
                    logColour = logColour_temp;

                    Num.Vector4[] chanColour_temp =
                    {
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255),
                        new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255), new Num.Vector4(255, 255, 255, 255)
                    };

                    int k = 0;
                    foreach (Num.Vector4 vec in chanColour)
                    {
                        chanColour_temp[k] = vec;
                        k++;
                    }
                    chanColour = chanColour_temp;
                }
            }
            catch (Exception)
            {
                PluginLog.Log("Fresh install, no log to fix!");
            }

            //Adding in Chans
            try
            {
                if (Configuration.Items[0].Chans.Length < Channels.Length)
                {
                    int            l        = 0;
                    List <TabBase> templist = new List <TabBase>();
                    foreach (TabBase items in Configuration.Items)
                    {
                        TabBase temp = new TabBase();
                        temp.AutoScroll = items.AutoScroll;
                        temp.Chat       = items.Chat;
                        temp.Config     = items.Config;
                        temp.Enabled    = items.Enabled;
                        temp.Scroll     = items.Scroll;
                        temp.Title      = items.Title;
                        temp.Logs       = items.Logs.ToArray();
                        temp.Chans      =
                            new bool[] {
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true, true,
                            true, true, true, true
                        };
                        templist.Add(temp);
                        l++;
                    }

                    items = templist;
                }
            }
            catch (Exception)
            {
                PluginLog.Log("Fresh install, no Chans to fix!");
            }

            try
            {
                if (Configuration.Chan.Length > 30)
                {
                    Chan = Configuration.Chan.ToArray();
                }
            }
            catch (Exception)
            {
                PluginLog.Log("No Chan list to load");
            }

            if (translator == 0)
            {
                translator = 1;
            }

            SaveConfig();

            TransY.Make("https://translate.yandex.net/api/v1.5/tr.json/translate", Configuration.YandexKey);

            // Set up command handlers
            this.pluginInterface.CommandManager.AddHandler("/cht", new CommandInfo(OnTranslateCommand)
            {
                HelpMessage = "Open config with '/cht c', and the extender with '/cht w'"
            });

            this.pluginInterface.Framework.Gui.Chat.OnChatMessage += Chat_OnChatMessage;
            this.pluginInterface.UiBuilder.OnBuildUi      += ChatUI;
            this.pluginInterface.UiBuilder.OnOpenConfigUi += Chat_ConfigWindow;
            this.pluginInterface.UiBuilder.OnBuildUi      += ChatBubbles;
        }
コード例 #5
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            try
            {
                // Initializing plugin, hooking into chat.
                this.pluginInterface = pluginInterface;
                config = pluginInterface.GetPluginConfig() as ChatExtenderPluginConfiguration ?? new ChatExtenderPluginConfiguration();
                this.pluginInterface.UiBuilder.OnBuildFonts += AddFonts;
                this.pluginInterface.UiBuilder.RebuildFonts();

                //Hooks for FFXIV ChatBox
                scan1 = pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
                scan2 = pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

                getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(scan1);
                getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(scan2);
                chatLog         = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
                chatLogStuff    = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
                chatLogPanel_0  = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
                chatLogPosition = new float[2];

                if (config.ChannelSettings == null)
                {
                    config.ChannelSettings = ChannelSettingsTable;
                }
                else
                {
                    foreach (var key in ChannelSettingsTable.Keys)
                    {
                        if (config.ChannelSettings.ContainsKey(key))
                        {
                            ChannelSettingsTable[key].Update(config.ChannelSettings[key]);
                        }
                    }

                    config.ChannelSettings = ChannelSettingsTable;
                }

                if (config.Tabs == null || config.Tabs.Count == 0)
                {
                    TabBase newTab = new TabBase
                    {
                        Title   = "New Tab",
                        Enabled = true
                    };
                    tabs = new List <TabBase> {
                        newTab
                    };
                    config.Tabs = tabs;
                }
                else
                {
                    tabs = config.Tabs;
                }

                foreach (var tab in config.Tabs)
                {
                    if (tab.EnabledChannels == null)
                    {
                        tab.EnabledChannels = new Dictionary <string, BoolRef>();
                    }
                    if (tab.ShowChannelTag == null)
                    {
                        tab.ShowChannelTag = new Dictionary <string, BoolRef>();
                    }

                    foreach (var key in ChannelSettingsTable.Keys)
                    {
                        var channelName = ChannelSettingsTable[key].Name;
                        if (!tab.EnabledChannels.ContainsKey(channelName))
                        {
                            tab.EnabledChannels.Add(channelName, false);
                        }
                        if (!tab.ShowChannelTag.ContainsKey(channelName))
                        {
                            tab.ShowChannelTag.Add(channelName, true);
                        }
                    }
                }

                SaveConfig();

                // Set up command handlers
                this.pluginInterface.CommandManager.AddHandler("/cht", new CommandInfo(OnTranslateCommand)
                {
                    HelpMessage = "Open config with '/cht c', and the extender with '/cht w'"
                });

                this.pluginInterface.Framework.Gui.Chat.OnChatMessage += Chat_OnChatMessage;
                this.pluginInterface.UiBuilder.OnBuildUi      += ChatUI;
                this.pluginInterface.UiBuilder.OnOpenConfigUi += Chat_ConfigWindow;
            }
            catch (Exception e)
            {
                ErrorLog(e.ToString());
            }
        }
コード例 #6
0
        //public Lumina.Excel.ExcelSheet<Lumina.Excel.Generated> actionSheet;


        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            diffH_s = col2_s.Hue - col1_s.Hue;
            diffS_s = col2_s.Saturation - col1_s.Saturation;
            diffB_s = col2_s.Brightness - col1_s.Brightness;

            this.pluginInterface = pluginInterface;
            Configuration        = pluginInterface.GetPluginConfig() as Config ?? new Config();


            scan1 = pluginInterface.TargetModuleScanner.ScanText("E8 ?? ?? ?? ?? 41 b8 01 00 00 00 48 8d 15 ?? ?? ?? ?? 48 8b 48 20 e8 ?? ?? ?? ?? 48 8b cf");
            scan2 = pluginInterface.TargetModuleScanner.ScanText("e8 ?? ?? ?? ?? 48 8b cf 48 89 87 ?? ?? 00 00 e8 ?? ?? ?? ?? 41 b8 01 00 00 00");

            getBaseUIObj    = Marshal.GetDelegateForFunctionPointer <GetBaseUIObjDelegate>(scan1);
            getUI2ObjByName = Marshal.GetDelegateForFunctionPointer <GetUI2ObjByNameDelegate>(scan2);

            castBar = IntPtr.Zero;
            IntPtr baseUi = getBaseUIObj();

            if (baseUi != IntPtr.Zero)
            {
                IntPtr baseUiProperties = Marshal.ReadIntPtr(baseUi, 0x20);
                if (baseUiProperties != IntPtr.Zero)
                {
                    castBar = getUI2ObjByName(baseUiProperties, "_CastBar", 1);
                }
            }

            this.pluginInterface.UiBuilder.OnBuildUi      += DrawWindow;
            this.pluginInterface.UiBuilder.OnOpenConfigUi += ConfigWindow;
            this.pluginInterface.CommandManager.AddHandler("/slc", new CommandInfo(Command)
            {
                HelpMessage = ""
            });

            //actionSheet = pluginInterface.Data.GetExcelSheet<Lumina.Excel.GeneratedSheets.Action>();

            try
            { enabled = Configuration.Enabled; }
            catch (Exception)
            {
                PluginLog.LogError("Failed to set Enabled");
                enabled = false;
            }

            try
            {
                if (Configuration.SlideTime.HasValue)
                {
                    slideTime = Configuration.SlideTime.Value;
                }
                else
                {
                    slideTime = 50;
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to set SlideTime");
                slideTime = 50;
            }

            try
            {
                if (Configuration.SlideCol != null)
                {
                    slideCol = Configuration.SlideCol;
                }
                else
                {
                    slideCol = new Num.Vector4(1.0f, 1.0f, 1.0f, 1.0f);
                }
            }
            catch (Exception)
            {
                PluginLog.LogError("Failed to set SlideCol");
                slideCol = new Num.Vector4(1.0f, 1.0f, 1.0f, 1.0f);
            }
        }