示例#1
0
        static void Main(string[] args)
        {
            appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            dataManager = new DataManager(ClientLanguage.English);

            var t = Task.Run(() =>
            {
                // The executing directory of this program needs a directory junction to the FFXIV sqpack folder so that Lumina can find the files
                // (You can also copy the files over, but it is around 45GB of data)
                dataManager.Initialize(appDataPath + @"\XIVLauncher\addon\Hooks");
            });

            t.Wait();

            plugin   = new ChatExtenderPlugin();
            config   = new ChatExtenderPluginConfiguration();
            renderUI = plugin.GetType().GetMethod("RenderUI", BindingFlags.NonPublic | BindingFlags.Instance);
            onChat   = plugin.GetType().GetMethod("Chat_OnChatMessage", BindingFlags.NonPublic | BindingFlags.Instance);


            var tab = new TabBase();

            tab.Title = "New Tab";
            tabs.Add(tab);
            activeTab = tab;

            tab.EnabledChannels = new Dictionary <string, BoolRef>();
            tab.ShowChannelTag  = new Dictionary <string, BoolRef>();

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

            var configWindow = plugin.GetType().GetField("configWindow", BindingFlags.NonPublic | BindingFlags.Instance);

            var messagePaths = Directory.GetFiles(appDataPath + @"\XIVLauncher\installedPlugins\ChatExtender\2.0.2.4\Payloads\All\2020\09\11");

            messages = messagePaths.Select(x =>
            {
                var a = JsonConvert.DeserializeObject <OnChatMessageArgs>(File.ReadAllText(x), new JsonSerializerSettings
                {
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects,
                    TypeNameHandling           = TypeNameHandling.Auto,
                    ConstructorHandling        = ConstructorHandling.AllowNonPublicDefaultConstructor
                });

                foreach (var payload in a.Sender.Payloads)
                {
                    payload.DataResolver = dataManager;
                }
                foreach (var payload in a.Message.Payloads)
                {
                    payload.DataResolver = dataManager;
                }

                return(a);
            });
            //.Where(x => x.Sender.Payloads.Count() > 0);
            //.Where(x => x.Type == XivChatType.Party);
            messageEnumerator = messages.GetEnumerator();

            using (var scene = SimpleImGuiScene.CreateOverlay(RendererFactory.RendererBackend.DirectX11))
            {
                scene.Window.OnSDLEvent += (ref SDL_Event sdlEvent) =>
                {
                    if (sdlEvent.type == SDL_EventType.SDL_KEYDOWN && sdlEvent.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_ESCAPE)
                    {
                        scene.ShouldQuit = true;
                    }
                    if (sdlEvent.type == SDL_EventType.SDL_KEYDOWN && sdlEvent.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_SPACE)
                    {
                        SendMessage();
                    }
                };

                var addFonts = plugin.GetType().GetMethod("AddFonts", BindingFlags.NonPublic | BindingFlags.Instance);
                addFonts.Invoke(plugin, new object[] { });

                configWindow.SetValue(plugin, true);

                plugin.Alpha = 1;

                scene.Renderer.ClearColor = new Vector4(0, 0, 0, 1);
                scene.OnBuildUI          += Display;
                scene.Run();
            }

            var messageList = messages.ToList();
        }
示例#2
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());
            }
        }
示例#3
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;
        }
示例#4
0
        public void Initialize(DalamudPluginInterface pluginInterface)
        {
            // Initializing plugin, hooking into chat.
            this.pluginInterface = pluginInterface;
            Configuration        = pluginInterface.GetPluginConfig() as ChatExtenderPluginConfiguration ?? new ChatExtenderPluginConfiguration();

            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
            { 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
            { logColour = Configuration.LogColour.ToArray(); }
            catch (Exception)
            { PluginLog.LogError("No LogColour to load!"); }

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

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

            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 List <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 List <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");
            }

            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;

            //ImGui.GetIO().Fonts.Build();
        }