Пример #1
0
        private void VerifyBoxes(TabBase tab, RegistryHelper reg, bool inverse, OpenTarget target, Tabs.GlobalState consoleVersion)
        {
            // get the key for the current target
            RegistryKey consoleKey = reg.GetMatchingKey(target);

            // hold the parent console key in case we need to look things up for specifics.
            RegistryKey parentConsoleKey = reg.GetMatchingKey(OpenTarget.Defaults);

            // include the global checkbox in the set for verification purposes
            IEnumerable <CheckBoxMeta> boxes = tab.GetCheckboxesForVerification();

            AutoHelpers.LogInvariant("Testing target: {0} in inverse {1} mode", target.ToString(), inverse.ToString());

            // If we're opened as specifics, remove all global only boxes from the test set
            if (target == OpenTarget.Specifics)
            {
                AutoHelpers.LogInvariant("Reducing");
                boxes = boxes.Where(box => !box.IsGlobalOnly);
            }

            foreach (CheckBoxMeta meta in boxes)
            {
                int?storedValue = consoleKey.GetValue(meta.ValueName) as int?;

                string boxName = AutoHelpers.FormatInvariant("Box: {0}", meta.ValueName);

                // if we're in specifics mode, we might have a null and if so, we check the parent value
                if (target == OpenTarget.Specifics)
                {
                    if (storedValue == null)
                    {
                        AutoHelpers.LogInvariant("Specific setting missing. Checking defaults.");
                        storedValue = parentConsoleKey.GetValue(meta.ValueName) as int?;
                    }
                }
                else
                {
                    Verify.IsNotNull(storedValue, boxName);
                }

                if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property)
                {
                    AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName);
                }
                else
                {
                    // A box can be inverse if checking it means false in the registry.
                    // This method can be inverse if we're turning off the boxes and expecting it to be on.
                    // Therefore, a box will be false if it's checked and supposed to be off. Or if it's unchecked and supposed to be on.
                    if ((meta.IsInverse && !inverse) || (!meta.IsInverse && inverse))
                    {
                        Verify.IsFalse(storedValue.Value.DwordToBool(), boxName);
                    }
                    else
                    {
                        Verify.IsTrue(storedValue.Value.DwordToBool(), boxName);
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// アクティブタブの切り替え
 /// </summary>
 public void SetActiveTab(TabBase tab)
 {
     for (int i = 0; i < this.tabList.Count; i++)
     {
         this.tabList[i].SetActive(this.tabList[i] == tab);
     }
 }
Пример #3
0
        /// <summary>
        /// This event triggers when a tab is dragged outside the bonds of the tab control panel.
        /// We can use it to create a docking tab control.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChromeTabControl_TabDraggedOutsideBonds(object sender, TabDragEventArgs e)
        {
            TabBase draggedTab = e.Tab as TabBase;

            if (draggedTab is TabClass3)
            {
                return;                                                                        //As an example, we don't want out TabClass3 to form new windows, so we stop it here.
            }
            DockingWindow win = _openWindows.FirstOrDefault(x => x.DataContext == draggedTab); //check if it's already open

            if (win == null)                                                                   //If not, create a new one
            {
                win = new DockingWindow();

                win.Title            = draggedTab.TabName;
                win.DataContext      = draggedTab;
                win.Closed          += win_Closed;
                win.Loaded          += win_Loaded;
                win.LocationChanged += win_LocationChanged;
                win.Tag              = e.CursorPosition;
                win.Left             = e.CursorPosition.X - win.Width + 200;
                win.Top              = e.CursorPosition.Y - 20;
                win.Show();
            }
            else
            {
                Debug.WriteLine(DateTime.Now.ToShortTimeString() + " got window");
                MoveWindow(win, e.CursorPosition);
            }
            this._openWindows.Add(win);
            Debug.WriteLine(e.CursorPosition);
        }
Пример #4
0
        private async Task OpenListTabAction(long id)
        {
            if (id == 0)
            {
                return;
            }
            var     surrogateKey = GetTabIndex();
            TabBase tab          = null;

            try
            {
                tab = await TabFactory.CreateListTab(id, surrogateKey);
            }
            catch
            {
                ListProvider.Id.Value = 0;
                return;
            }
            AddTab(tab);
            if (ListReloadTimeCalclator == null)
            {
                var targetCnt = Tabs.Count() == 0
                    ? 1
                    : Tabs.Count(t => t.GetType() == typeof(TabList));
                ListReloadTimeCalclator = CalcReloadTimeList.GetInstance(targetCnt, tab.Limit);
                tab.RefleshTimer(ListReloadTimeCalclator.CalcReloadTime(tab.Limit));
            }
            else
            {
                tab.RefleshTimer(ListReloadTimeCalclator.AddTab(tab.Limit));
            }
            ListProvider.Id.Value = 0;
        }
Пример #5
0
 private void AddTab(TabBase tab)
 {
     lock (Tabs)
     {
         Tabs.Add(tab);
         SelectTabByVM(tab.SurrogateKey);
     }
     tab.Reloaded += HandleReloaded;
 }
Пример #6
0
    private void CloseTab2(TabBase thetab)
    {
      if (thetab == null) return;

      thetab.Close();

      if (thetab is TabTaxForm && btnReturns.IsChecked)
        ReturnForms.txtSequenceNumber.Focus();
    }
Пример #7
0
        private void TabControl_ContainerItemPreparedForOverride(object sender, ContainerOverrideEventArgs e)
        {
            e.Handled = true;
            TabBase viewModel = e.Model as TabBase;

            if (e.TabItem != null && viewModel != null)
            {
                e.TabItem.IsPinned = viewModel.IsPinned;
            }
        }
Пример #8
0
        private void TabControl_TabDraggedOutsideBonds(object sender, TabDragEventArgs e)
        {
            TabBase draggedTab = e.Tab as TabBase;

            if (TryDragTabToWindow(e.CursorPosition, draggedTab))
            {
                //Set Handled to true to tell the tab control that we have dragged the tab to a window, and the tab should be closed.
                e.Handled = true;
            }
        }
Пример #9
0
        private void VerifySliders(TabBase tab, RegistryHelper reg, SliderMeta.ExpectedPosition expected, OpenTarget target, Tabs.GlobalState consoleVersion)
        {
            // get the key for the current target
            RegistryKey consoleKey = reg.GetMatchingKey(target);

            // hold the parent console key in case we need to look things up for specifics.
            RegistryKey parentConsoleKey = reg.GetMatchingKey(OpenTarget.Defaults);

            IEnumerable <SliderMeta> sliders = tab.GetSlidersForVerification();

            foreach (SliderMeta meta in sliders)
            {
                int?storedValue = consoleKey.GetValue(meta.ValueName) as int?;

                string sliderName = AutoHelpers.FormatInvariant("Slider: {0}", meta.ValueName);

                if (target == OpenTarget.Specifics)
                {
                    if (storedValue == null)
                    {
                        AutoHelpers.LogInvariant("Specific setting missing. Checking defaults.");
                        storedValue = parentConsoleKey.GetValue(meta.ValueName) as int?;
                    }
                }
                else
                {
                    Verify.IsNotNull(storedValue, sliderName);
                }

                int transparency = 0;

                switch (expected)
                {
                case SliderMeta.ExpectedPosition.Maximum:
                    transparency = meta.GetMaximum();
                    break;

                case SliderMeta.ExpectedPosition.Minimum:
                    transparency = meta.GetMinimum();
                    break;

                default:
                    throw new NotImplementedException();
                }

                if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property)
                {
                    AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName);
                }
                else
                {
                    Verify.AreEqual(storedValue.Value, RescaleSlider(transparency), sliderName);
                }
            }
        }
Пример #10
0
        private void VerifySliders(TabBase tab, ShortcutHelper shortcut, SliderMeta.ExpectedPosition expected, Tabs.GlobalState consoleVersion)
        {
            IEnumerable <SliderMeta> sliders = tab.GetSlidersForVerification();

            // collect up properties that we need to retrieve keys for
            IEnumerable <SliderMeta>         propSliders = sliders.Where(slider => slider.PropKey != null);
            IEnumerable <Wtypes.PROPERTYKEY> keys        = propSliders.Select(slider => slider.PropKey).Cast <Wtypes.PROPERTYKEY>();

            // fetch data for keys
            IDictionary <Wtypes.PROPERTYKEY, object> propertyData = shortcut.GetFromPropertyStore(keys);

            // enumerate each slider and validate data
            foreach (SliderMeta meta in sliders)
            {
                string sliderName = AutoHelpers.FormatInvariant("Slider: {0}", meta.ValueName);

                Wtypes.PROPERTYKEY key = (Wtypes.PROPERTYKEY)meta.PropKey;

                short value = (short)propertyData[key];

                int transparency = 0;

                switch (expected)
                {
                case SliderMeta.ExpectedPosition.Maximum:
                    transparency = meta.GetMaximum();
                    break;

                case SliderMeta.ExpectedPosition.Minimum:
                    transparency = meta.GetMinimum();
                    break;

                default:
                    throw new NotImplementedException();
                }

                if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property)
                {
                    AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName);
                }
                else
                {
                    Verify.AreEqual(value, RescaleSlider(transparency), sliderName);
                }
            }
        }
Пример #11
0
        //We use this to keep track of where the window is on the screen, so we can dock it later
        private void win_LocationChanged(object sender, EventArgs e)
        {
            Window win = (Window)sender;

            if (!win.IsLoaded)
            {
                return;
            }
            W32Point pt = new W32Point();

            if (!Win32.GetCursorPos(ref pt))
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            Point absoluteScreenPos = new Point(pt.X, pt.Y);

            var windowUnder = FindWindowUnderThisAt(win, absoluteScreenPos);

            if (windowUnder != null && windowUnder.Equals(this))
            {
                Point            relativePoint = this.PointFromScreen(absoluteScreenPos);                                 //The screen position relative to the main window
                FrameworkElement element       = this.MyChromeTabControl.InputHitTest(relativePoint) as FrameworkElement; //Hit test against the tab control

                if (element != null)
                {
                    ////test if the mouse is over the tab panel or a tab item.
                    if (CanInsertTabItem(element))
                    {
                        TabBase             dockedWindowVM = (TabBase)win.DataContext;
                        ViewModelMainWindow mainWindowVm   = (ViewModelMainWindow)this.DataContext;

                        mainWindowVm.ItemCollection.Add(dockedWindowVM);

                        win.Close();

                        mainWindowVm.SelectedTab = dockedWindowVM;

                        //We run this method on the tab control for it to grab the tab and position it at the mouse, ready to move again.
                        this.MyChromeTabControl.GrabTab(dockedWindowVM);
                    }
                }
            }
        }
Пример #12
0
    public void callback_switchTab(int newTab)
    {
        if (this.currentTab != null)  // False only on open
        {
            this.currentTab.onTabClose();
            this.currentTab.gameObject.SetActive(false);
        }

        // Only switch if the target tab is different.
        TabBase newTabObj = (EnumTab)newTab == EnumTab.INVENTORY ? this.itemTab : this.craftingTab;

        if (newTabObj != this.currentTab)
        {
            this.currentTab = newTabObj;

            this.currentTab.gameObject.SetActive(true);
            this.currentTab.onTabOpen();
        }
    }
Пример #13
0
 protected override bool TryDockWindow(Point position, TabBase dockedWindowVM)
 {
     //Hit test against the tab control
     if (MyChromeTabControlWithCustomStyle.InputHitTest(position) is FrameworkElement element)
     {
         ////test if the mouse is over the tab panel or a tab item.
         if (CanInsertTabItem(element))
         {
             //TabBase dockedWindowVM = (TabBase)win.DataContext;
             ViewModelExampleBase vm = (ViewModelExampleBase)DataContext;
             vm.ItemCollection.Add(dockedWindowVM);
             vm.SelectedTab = dockedWindowVM;
             //We run this method on the tab control for it to grab the tab and position it at the mouse, ready to move again.
             MyChromeTabControlWithCustomStyle.GrabTab(dockedWindowVM);
             return(true);
         }
     }
     return(false);
 }
Пример #14
0
        private void VerifyBoxes(TabBase tab, ShortcutHelper shortcut, bool inverse, Tabs.GlobalState consoleVersion)
        {
            IEnumerable <CheckBoxMeta> boxes = tab.GetCheckboxesForVerification();

            // collect up properties that we need to retrieve keys for
            IEnumerable <CheckBoxMeta>       propBoxes = boxes.Where(box => box.PropKey != null);
            IEnumerable <Wtypes.PROPERTYKEY> keys      = propBoxes.Select(box => box.PropKey).Cast <Wtypes.PROPERTYKEY>();

            // fetch data for keys
            IDictionary <Wtypes.PROPERTYKEY, object> propertyData = shortcut.GetFromPropertyStore(keys);

            // enumerate each box and validate the data
            foreach (CheckBoxMeta meta in propBoxes)
            {
                string boxName = AutoHelpers.FormatInvariant("Box: {0}", meta.ValueName);

                Wtypes.PROPERTYKEY key = (Wtypes.PROPERTYKEY)meta.PropKey;

                bool?value = (bool?)propertyData[key];

                Verify.IsNotNull(value, boxName);

                if (consoleVersion == Tabs.GlobalState.ConsoleV1 && meta.IsV2Property)
                {
                    AutoHelpers.LogInvariant("Skipping validation of v2 property {0} after switching to v1 console.", meta.ValueName);
                }
                else
                {
                    // A box can be inverse if checking it means false in the registry.
                    // This method can be inverse if we're turning off the boxes and expecting it to be on.
                    // Therefore, a box will be false if it's checked and supposed to be off. Or if it's unchecked and supposed to be on.
                    if ((meta.IsInverse && !inverse) || (!meta.IsInverse && inverse))
                    {
                        Verify.IsFalse(value.Value, boxName);
                    }
                    else
                    {
                        Verify.IsTrue(value.Value, boxName);
                    }
                }
            }
        }
        private void OnCellSelected(SegmentedControl control, int index)
        {
            _currentTab.Visible = false;

            if (_tabs[index] == null)
            {
                switch (index)
                {
                case 1:
                    _tabs[index] = new QuickFiltersTab(_container);
                    break;

                case 2:
                    _tabs[index] = new InfoTab(_container);
                    break;
                }
            }

            _tabs[index].Visible = true;
            _currentTab          = _tabs[index];
        }
Пример #16
0
        protected bool TryDragTabToWindow(Point position, TabBase draggedTab)
        {
            if (draggedTab is TabClass3)
            {
                return(false);//As an example, we don't want TabClass3 to form new windows, so we stop it here.
            }
            if (draggedTab.IsPinned)
            {
                return(false);                                                                //We don't want pinned tabs to be draggable either.
            }
            DockingWindow win = OpenWindows.FirstOrDefault(x => x.DataContext == draggedTab); //check if it's already open

            if (win == null)                                                                  //If not, create a new one
            {
                win = new DockingWindow
                {
                    Title       = draggedTab?.TabName,
                    DataContext = draggedTab
                };

                win.Closed          += win_Closed;
                win.Loaded          += win_Loaded;
                win.LocationChanged += win_LocationChanged;
                win.Tag              = position;
                var scale = VisualTreeHelper.GetDpi(this);
                win.Left = position.X / scale.DpiScaleX - win.Width / 2;
                win.Top  = position.Y / scale.DpiScaleY - 10;

                win.Show();
            }
            else
            {
                Debug.WriteLine(DateTime.Now.ToShortTimeString() + " got window");
                MoveWindow(win, position);
            }
            OpenWindows.Add(win);
            return(true);
        }
Пример #17
0
        private List <TabBase> CopyItems(List <TabBase> items)
        {
            List <TabBase> clone = new List <TabBase>();

            foreach (TabBase tabs in items)
            {
                if (tabs.Enabled)
                {
                    TabBase babyClone = new TabBase();
                    babyClone.AutoScroll = tabs.AutoScroll;
                    babyClone.Chat       = tabs.Chat;
                    babyClone.Config     = tabs.Config.ToArray();
                    babyClone.Enabled    = tabs.Enabled;
                    babyClone.Logs       = tabs.Logs.ToArray();
                    babyClone.Scroll     = tabs.Scroll;
                    babyClone.Title      = tabs.Title.ToString();
                    babyClone.Filter     = tabs.Filter.ToString();
                    babyClone.FilterOn   = tabs.FilterOn;
                    clone.Add(babyClone);
                }
            }
            return(clone);
        }
Пример #18
0
        private void RenderChatArea(TabBase tab, ImGuiWindowFlags chat_sub_window_flags)
        {
            float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();

            if (!tab.FilterOn)
            {
                footer = 0;
            }

            ImGui.BeginChild("scrolling", new Vector2(0, -footer), false, chat_sub_window_flags);

            tab.ComputeNewLineSum();

            var lines         = tab.FilteredLogs;
            var cumulativeSum = tab.GetCumulativeLineSum();
            var lineHeight    = ImGui.CalcTextSize("M").Y;
            var linesInWindow = (int)(ImGui.GetContentRegionAvail().Y / lineHeight);

            var totalLines = cumulativeSum.LastOrDefault() - linesInWindow; // offset to adjust scrolling area height

            var totalLineHeight = totalLines * lineHeight;
            var scrollPercent   = ImGui.GetScrollMaxY() == 0 ? 0 : ImGui.GetScrollY() / ImGui.GetScrollMaxY();
            var lineStartIndex  = (int)(Math.Max(0, (totalLines - linesInWindow)) * scrollPercent);


            var initialY = ImGui.GetCursorPosY();
            var initialX = ImGui.GetCursorPosX();

            ImGui.SetCursorPosY(totalLineHeight);
            ImGui.SetCursorPosY(initialY);

            var startIndex = BinaryFind(cumulativeSum, lineStartIndex, 0, cumulativeSum.Count());

            startIndex = Math.Max(0, startIndex - linesInWindow);

            var startY = initialY + (startIndex == 0 ? 0 : cumulativeSum[startIndex - 1]) * lineHeight;

            ImGui.SetCursorPosY(startY);

            for (int i = startIndex; i < startIndex + 3 * linesInWindow && i < lines.Count(); i++)
            {
                var textLogEntry = lines[i];
                var textLines    = textLogEntry.GetLines();
                var currentY     = ImGui.GetCursorPosY();

                if (textLogEntry.line.Sender != null)
                {
                    textLogEntry.line.Sender.IsHovered = false;
                }
                foreach (var text in textLogEntry.Text)
                {
                    text.IsHovered = false;
                }

                // Pre-pass for highlight boxes
                ImGui.PushFont(outlineFont);
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0, 0, 0));
                foreach (var line in textLines)
                {
                    foreach (var str in line)
                    {
                        ImGui.Text(str.Text);
                        ImGui.SameLine();

                        if (str.SourcePayloadContainer != null)
                        {
                            str.SourcePayloadContainer.IsHovered |= ImGui.IsItemHovered(ImGuiHoveredFlags.RectOnly);
                        }
                    }
                    ImGui.SetCursorPosX(initialX);
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + lineHeight);
                }

                ImGui.PopStyleColor();
                ImGui.PopFont();

                ImGui.SetCursorPosY(currentY);
                var buttonId = 0;
                foreach (var line in textLines)
                {
                    ImGui.PushFont(outlineFont);
                    ImGui.SetCursorPosX(initialX);
                    ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0, 0, 0));

                    // Draw highlight boxes
                    foreach (var str in line)
                    {
                        var cursorPos = ImGui.GetCursorPos();
                        var textSize  = ImGui.CalcTextSize(str.Text);

                        if (str.SourcePayloadContainer != null && str.SourcePayloadContainer.IsHovered)
                        {
                            ImGui.PushStyleColor(ImGuiCol.Button, str.SourcePayloadContainer.highlightColor);
                            ImGui.PushStyleColor(ImGuiCol.ButtonHovered, str.SourcePayloadContainer.highlightColor);
                            ImGui.PushStyleColor(ImGuiCol.ButtonActive, str.SourcePayloadContainer.highlightColor);
                            ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 0);
                            if (ImGui.Button($"##{buttonId++}", textSize))
                            {
                                Task.Run(() =>
                                {
                                    ProcessLinkClick(str.SourcePayloadContainer.Payload);
                                });
                            }
                            ImGui.PopStyleVar();
                            ImGui.PopStyleColor();
                            ImGui.PopStyleColor();
                            ImGui.PopStyleColor();
                        }

                        ImGui.SetCursorPos(cursorPos);
                        ImGui.Text(str.Text);
                        ImGui.SameLine();
                    }
                    ImGui.PopStyleColor();

                    // Draw outline
                    ImGui.SetCursorPosX(initialX);
                    foreach (var str in line)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, str.ReferenceShadowColor?.Color ?? str.ShadowColor);
                        ImGui.Text(str.Text);
                        ImGui.PopStyleColor();
                        ImGui.SameLine();
                    }
                    ImGui.PopFont();

                    ImGui.SetCursorPosX(initialX);
                    ImGui.PushFont(font);
                    foreach (var str in line)
                    {
                        ImGui.PushStyleColor(ImGuiCol.Text, str.ReferenceColor?.Color ?? str.Color);
                        ImGui.Text(str.Text);
                        ImGui.PopStyleColor();
                        ImGui.SameLine();
                    }
                    ImGui.PopFont();
                    ImGui.SetCursorPosX(initialX);
                    ImGui.SetCursorPosY(ImGui.GetCursorPosY() + lineHeight);
                }
            }

            if (tab.ScrollOnce == true)
            {
                ImGui.SetScrollHereY();
                tab.ScrollOnce = false;
            }

            ImGui.EndChild();

            if (tab.FilterOn)
            {
                if (ImGui.InputText("Filter Text", ref tab.Filter, 999))
                {
                    tab.UpdateFilteredLines();
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Only show lines with this text.");
                }
            }
        }
Пример #19
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;
        }
        public BottomScreen()
        {
            _floatingScreen = FloatingScreen.CreateFloatingScreen(new Vector2(DefaultXSize, DefaultYSize), false, new Vector3(1.5f, 0.05f, 1.5f), Quaternion.Euler(50f, 0f, 0f));
            (_floatingScreen.transform as RectTransform).pivot = new Vector2(1f, 0f);

            // this is needed to fix HoverHint position issues that occur because of the change in pivot done to the floating screen
            var wrapperCanvasGO = new GameObject("Wrapper", typeof(RectTransform), typeof(Canvas), typeof(VRGraphicRaycaster), typeof(SetMainCameraToCanvas));
            var rt = wrapperCanvasGO.transform as RectTransform;

            rt.SetParent(_floatingScreen.transform, false);
            rt.anchorMin = Vector2.zero;
            rt.anchorMax = Vector2.one;
            rt.sizeDelta = Vector2.zero;

            var cameraSetter = wrapperCanvasGO.GetComponent <SetMainCameraToCanvas>();

            cameraSetter.SetField("_canvas", wrapperCanvasGO.GetComponent <Canvas>());
            cameraSetter.SetField("_mainCamera", Resources.FindObjectsOfTypeAll <MainCamera>().FirstOrDefault(camera => camera.camera?.stereoTargetEye != StereoTargetEyeMask.None) ?? Resources.FindObjectsOfTypeAll <MainCamera>().FirstOrDefault());

            _outlineImage                = new GameObject("Outline").AddComponent <Image>();
            _outlineImage.color          = OutlineColour;
            _outlineImage.material       = UIUtilities.NoGlowMaterial;
            _outlineImage.type           = Image.Type.Sliced;
            _outlineImage.sprite         = Resources.FindObjectsOfTypeAll <Sprite>().LastOrDefault(x => x.name == "RoundRectSmallStroke");
            _outlineImage.preserveAspect = true;

            _outlineImage.rectTransform.SetParent(wrapperCanvasGO.transform, false);
            _outlineImage.rectTransform.anchorMin = Vector2.zero;
            _outlineImage.rectTransform.anchorMax = Vector2.one;
            _outlineImage.rectTransform.sizeDelta = Vector2.zero;

            var hlg = new GameObject("HorizontalLayoutGroup").AddComponent <HorizontalLayoutGroup>();

            hlg.spacing                = 3.5f;
            hlg.padding                = new RectOffset(2, 2, 1, 1);
            hlg.childAlignment         = TextAnchor.MiddleCenter;
            hlg.childForceExpandWidth  = false;
            hlg.childForceExpandHeight = false;

            rt = hlg.transform as RectTransform;
            rt.SetParent(wrapperCanvasGO.transform, false);
            rt.anchorMin = new Vector2(1f, 0f);
            rt.anchorMax = new Vector2(1f, 0f);
            rt.pivot     = new Vector2(1f, 0f);
            rt.sizeDelta = new Vector2(DefaultXSize, DefaultYSize);

            // icon
            _iconImage                = new GameObject("Icon").AddComponent <Image>();
            _iconImage.material       = UIUtilities.NoGlowMaterial;
            _iconImage.sprite         = BSUIUtilities.LoadSpriteFromResources("EnhancedSearchAndFilters.Assets.bars.png");
            _iconImage.preserveAspect = true;

            var le = _iconImage.gameObject.AddComponent <LayoutElement>();

            le.preferredWidth  = 4.5f;
            le.preferredHeight = 4.5f;

            _iconImage.rectTransform.SetParent(rt, false);

            // text
            _text           = BeatSaberUI.CreateText(rt, "OPTIONS", Vector2.zero, Vector2.zero);
            _text.fontSize  = 4.4f;
            _text.alignment = TextAlignmentOptions.Center;

            // this needs to be the last child, otherwise the outline image will capture all the controller raycasts first
            UIUtilities.ParseBSML("EnhancedSearchAndFilters.UI.Views.BottomScreen.BottomScreenView.bsml", wrapperCanvasGO, this);

            _hoverEventHandler = _floatingScreen.gameObject.AddComponent <EnterExitEventHandler>();
            _hoverEventHandler.PointerEntered += delegate()
            {
                if (_revealAnimation != null)
                {
                    return;
                }
                else if (_contractAnimation != null)
                {
                    UnityCoroutineHelper.Stop(_contractAnimation);
                    _contractAnimation = null;
                }

                _expandAnimation = UnityCoroutineHelper.Start(ExpandAnimationCoroutine());
            };
            _hoverEventHandler.PointerExited += delegate()
            {
                if (_revealAnimation != null)
                {
                    return;
                }

                bool immediate = false;
                if (_expandAnimation != null)
                {
                    UnityCoroutineHelper.Stop(_expandAnimation);
                    _expandAnimation = null;
                    immediate        = true;
                }
                else if (_contractAnimation != null)
                {
                    UnityCoroutineHelper.Stop(_contractAnimation);
                    _contractAnimation = null;
                }

                _contractAnimation = UnityCoroutineHelper.Start(ContractAnimationCoroutine(immediate));
            };

            var sortModeTab = new SortModeTab(_container);

            sortModeTab.SortButtonPressed += () => SortButtonPressed?.Invoke();
            sortModeTab.Visible            = true;

            _currentTab = sortModeTab;
            _tabs[0]    = sortModeTab;
            Logger.log.Notice($"finished constructor, currentTab?={_currentTab == null}");

            HideScreen(true);
        }
Пример #21
0
        private void CheckWritebacksVerifyValues(bool isRegMode, RegistryHelper reg, ShortcutHelper shortcut, OpenTarget target, TabBase tab, SliderMeta.ExpectedPosition sliderExpected, bool checkboxValue, Tabs.GlobalState consoleVersion)
        {
            if (isRegMode)
            {
                VerifyBoxes(tab, reg, checkboxValue, target, consoleVersion);
                VerifySliders(tab, reg, sliderExpected, target, consoleVersion);
            }
            else
            {
                // Have to wait for shortcut to get written.
                // There isn't really an event to know when this occurs, so just wait.
                Globals.WaitForTimeout();

                VerifyBoxes(tab, shortcut, checkboxValue, consoleVersion);
                VerifySliders(tab, shortcut, sliderExpected, consoleVersion);
            }
        }
Пример #22
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());
            }
        }
Пример #23
0
        private void RenderConfigWindow()
        {
            if (configWindow)
            {
                ImGui.SetNextWindowSize(new Vector2(300, 500), ImGuiCond.FirstUseEver);
                ImGui.Begin("Chat Config", ref configWindow);
                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();

                if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                {
                    if (ImGui.BeginTabItem("Config"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10);

                        ImGui.Columns(3);

                        ImGui.Checkbox("Show Chat Extender", ref config.ShowChatWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("24 Hour Time", ref config.HourTime);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Switch to 24 Hour (Military) time.");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Hide Scrollbar", ref config.NoScrollBar);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Shows ScrollBar");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("Lock Window Position", ref config.NoMove);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the position of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Size", ref config.NoResize);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the size of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Tab Bar", ref config.NoMouse);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Tab Bar of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Chat", ref config.NoMouse2);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Chat Extension chatbox");
                        }


                        ImGui.Columns(1);

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 30);
                        ImGui.SliderFloat("Chat Extender Alpha", ref config.Alpha, 0.001f, 0.999f);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the Alpha of the Chat Extender");
                        }

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 50);
                        ImGui.Checkbox("Debug", ref debug);
                        if (debug)
                        {
                            ImGui.Checkbox("Output Error Json", ref outputErrorJsons);
                            ImGui.Checkbox("Output All Json", ref outputAllJsons);
                            ImGui.Text($"Lines in chat buffer: {chatBuffer.Count()}");
                            ImGui.Text($"Lines in current filter: {activeTab.FilteredLogs.Count()}");
                        }

                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Channels"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                        ImGui.Columns(4);
                        ImGui.Text("Setting"); ImGui.NextColumn();
                        ImGui.Text("Example"); ImGui.NextColumn();
                        ImGui.Text("Color 1"); ImGui.NextColumn();
                        ImGui.Text("Color 2"); ImGui.NextColumn();

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();
                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();
                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();
                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();

                        ImGui.Text("Time"); ImGui.NextColumn();

                        var cursorPos = ImGui.GetCursorPos();
                        ImGui.PushFont(outlineFont);
                        ImGui.TextColored(config.TimeShadowColor, "[12:00]");
                        ImGui.PopFont();

                        ImGui.SetCursorPos(cursorPos);
                        ImGui.PushFont(font);
                        ImGui.TextColored(config.TimeColor, "[12:00]");
                        ImGui.PopFont();

                        ImGui.NextColumn();


                        ImGui.ColorEdit4("Time Color", ref config.TimeColorRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();

                        ImGui.ColorEdit4("Time Outline Color", ref config.TimeColorShadowRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();

                        foreach (var key in ChannelSettingsTable.Keys)
                        {
                            var channelSettings = ChannelSettingsTable[key];
                            ImGui.PushItemWidth(50);
                            ImGui.InputText(channelSettings.Name, ref channelSettings.ShortName, 8); ImGui.NextColumn();
                            ImGui.PopItemWidth();

                            cursorPos = ImGui.GetCursorPos();
                            ImGui.PushFont(outlineFont);
                            ImGui.TextColored(channelSettings.OutlineColor, "[" + channelSettings.Name + "]");
                            ImGui.PopFont();
                            ImGui.SetCursorPos(cursorPos);

                            ImGui.PushFont(font);
                            ImGui.TextColored(channelSettings.FontColor, "[" + channelSettings.Name + "]"); ImGui.NextColumn();
                            ImGui.PopFont();

                            ImGui.ColorEdit4(channelSettings.Name + " Font Color", ref channelSettings.FontColorRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            ImGui.ColorEdit4(channelSettings.Name + " Outline Color", ref channelSettings.OutlineColorRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        }

                        ImGui.Columns(1);
                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Tabs"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                        if (ImGui.Button("Add New Tab"))
                        {
                            int i = 1;
                            while (tabs.Any(x => x.Title == $"New Tab ({i})"))
                            {
                                i++;
                            }

                            tabs.Add(new TabBase
                            {
                                Title   = $"New Tab ({i})",
                                Enabled = true
                            });
                            tempTitle = "Title";
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Add a new Tab to the Chat Extender");
                        }

                        if (ImGui.TreeNode("Tab Order"))
                        {
                            ImGui.Columns(3);
                            ImGui.Text("Tab"); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();

                            for (int i = 0; i < tabs.Count; i++)
                            {
                                ImGui.Text(tabs[i].Title); ImGui.NextColumn();
                                if (i > 0)
                                {
                                    if (ImGui.Button("^##" + i.ToString()))
                                    {
                                        TabBase temp = tabs[i];
                                        tabs.RemoveAt(i);
                                        tabs.Insert(i - 1, temp);
                                    }
                                }
                                ImGui.NextColumn();
                                if (i < tabs.Count - 1)
                                {
                                    if (ImGui.Button("v##" + i.ToString()))
                                    {
                                        TabBase temp = tabs[i];
                                        tabs.RemoveAt(i);
                                        tabs.Insert(i + 1, temp);
                                    }
                                }
                                ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            ImGui.TreePop();
                        }

                        ImGui.Separator();
                        foreach (var tab in tabs)
                        {
                            if (ImGui.TreeNode(tab.Title))
                            {
                                float footer2 = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                ImGui.BeginChild("scrolling", new Vector2(0, -footer2), false);
                                ImGui.InputText("##Tab Name", ref tempTitle, bufSize);
                                ImGui.SameLine();
                                if (ImGui.Button("Set Tab Title"))
                                {
                                    if (tempTitle.Length == 0)
                                    {
                                        tempTitle += ".";
                                    }

                                    while (CheckDupe(tabs, tempTitle))
                                    {
                                        tempTitle += ".";
                                    }

                                    tab.Title = tempTitle;
                                    tempTitle = "Title";
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Change the title of the Tab");
                                }

                                ImGui.Columns(4);

                                ImGui.Checkbox("Time Stamp", ref tab.Timestamps);
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Show Timestamps in this Tab");
                                }
                                ImGui.NextColumn();
                                ImGui.Checkbox("Channel", ref tab.ShowChannelTagAll);
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Show the Channel the message came from");
                                }
                                ImGui.NextColumn();
                                ImGui.Checkbox("AutoScroll", ref tab.AutoScroll);
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Enable the Chat to scroll automatically on a new message");
                                }
                                ImGui.NextColumn();
                                if (ImGui.Checkbox("Enable Filter", ref tab.FilterOn))
                                {
                                    tab.UpdateFilteredLines();
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Enable Filtering of text");
                                }
                                ImGui.NextColumn();
                                ImGui.Columns(1);


                                //TODO: Add a confirm prompt

                                if (tabs.Count > 1)
                                {
                                    if (ImGui.Button("Delete Tab"))
                                    {
                                        tab.Enabled = false;
                                        tabs        = tabs.Where(x => x.Enabled).ToList();
                                        if (!activeTab.Enabled)
                                        {
                                            activeTab = tabs[0];
                                        }
                                    }
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Removes Tab");
                                }


                                ImGui.Columns(2);
                                ImGui.Text("Channel"); ImGui.NextColumn();
                                if (tab.ShowChannelTagAll)
                                {
                                    ImGui.Text("Show Short");
                                }
                                else
                                {
                                    ImGui.Text("");
                                }
                                ImGui.NextColumn();

                                foreach (var channelId in ChannelSettingsTable.Keys)
                                {
                                    var channelSettings = ChannelSettingsTable[channelId];
                                    var channelName     = channelSettings.Name;

                                    ImGui.PushStyleColor(ImGuiCol.Text, channelSettings.FontColor);

                                    if (ImGui.Checkbox("[" + channelSettings.Name + "]", ref tab.EnabledChannels[channelName].Value) && tab == activeTab)
                                    {
                                        tab.UpdateFilteredLines();
                                    }
                                    ImGui.NextColumn();

                                    if (tab.ShowChannelTagAll)
                                    {
                                        if (ImGui.Checkbox(channelSettings.ShortName, ref tab.ShowChannelTag[channelSettings.Name].Value))
                                        {
                                            tab.needsRecomputeCumulativeLengths = true;
                                        }
                                    }
                                    else
                                    {
                                        ImGui.Text("");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.PopStyleColor();
                                }

                                ImGui.Columns(1);
                                ImGui.EndChild();
                                ImGui.TreePop();
                            }
                        }
                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Font"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                        ImGui.Columns(1);
                        ImGui.PushItemWidth(124);
                        ImGui.InputFloat("Font Size", ref config.FontSize); ImGui.SameLine();
                        ImGui.PopItemWidth();
                        if (ImGui.SmallButton("Apply"))
                        {
                            UpdateFonts();
                        }

                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (debug)
                    {
                        if (ImGui.BeginTabItem("Style Editor"))
                        {
                            ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                            ImGui.ShowStyleEditor();
                            ImGui.EndChild();
                            ImGui.EndTabItem();
                        }
                    }
                }

                ImGui.EndTabBar();

                if (ImGui.Button("Save and Close Config"))
                {
                    SaveConfig();

                    configWindow = false;
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                }
                ImGui.End();
            }
        }
Пример #24
0
        private void ChatUI()
        {
            ImGuiWindowFlags chat_window_flags     = 0;
            ImGuiWindowFlags chat_sub_window_flags = 0;

            if (no_titlebar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoTitleBar;
            }
            if (no_scrollbar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (no_scrollbar)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (!no_menu)
            {
                chat_window_flags |= ImGuiWindowFlags.MenuBar;
            }
            if (no_move)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMove;
            }
            if (no_resize)
            {
                chat_window_flags |= ImGuiWindowFlags.NoResize;
            }
            if (no_collapse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoCollapse;
            }
            if (no_nav)
            {
                chat_window_flags |= ImGuiWindowFlags.NoNav;
            }
            if (no_mouse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }
            if (no_mouse2)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }



            if (chatWindow)
            {
                if (flickback)
                {
                    no_mouse  = false;
                    flickback = false;
                }
                ImGui.SetNextWindowSize(new Num.Vector2(200, 100), ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowBgAlpha(alpha);
                ImGui.Begin("Another Window", ref chatWindow, chat_window_flags);
                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                {
                    int loop = 0;
                    foreach (var tab in items)
                    {
                        if (tab.Enabled)
                        {
                            //WIP

                            if (tab.sel)
                            {
                                ImGui.PushStyleColor(ImGuiCol.Tab, tab_sel);
                                ImGui.PushStyleColor(ImGuiCol.Text, tab_sel_text);
                                tab.sel = false;
                            }
                            else if (tab.msg)
                            {
                                ImGui.PushStyleColor(ImGuiCol.Tab, tab_ind);
                                ImGui.PushStyleColor(ImGuiCol.Text, tab_ind_text);
                            }
                            else
                            {
                                ImGui.PushStyleColor(ImGuiCol.Tab, tab_norm);
                                ImGui.PushStyleColor(ImGuiCol.Text, tab_norm_text);
                            }



                            if (ImGui.BeginTabItem(tab.Title))
                            {
                                tab.sel = true;
                                float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Num.Vector2(space_hor, space_ver));
                                ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer), false, chat_sub_window_flags);


                                foreach (ChatText line in tab.Chat)
                                {
                                    if (tab.FilterOn)
                                    {
                                        if (ContainsText(line.Text, tab.Filter))
                                        {
                                            if (tab.Config[0])
                                            {
                                                ImGui.TextColored(timeColour, line.Time + " "); ImGui.SameLine();
                                            }
                                            if (tab.Config[1] && tab.Chans[ConvertForArray(line.Channel)])
                                            {
                                                ImGui.TextColored(chanColour[ConvertForArray(line.Channel)], line.ChannelShort + " "); ImGui.SameLine();
                                            }
                                            if (line.Sender.Length > 0)
                                            {
                                                ImGui.TextColored(nameColour, line.Sender + ":"); ImGui.SameLine();
                                            }

                                            int count = 0;
                                            foreach (TextTypes textTypes in line.Text)
                                            {
                                                if (textTypes.Type == PayloadType.RawText)
                                                {
                                                    ImGui.PushStyleColor(ImGuiCol.Text, logColour[line.ChannelColour]);
                                                    Wrap(textTypes.Text);
                                                    ImGui.PopStyleColor();
                                                }

                                                if (textTypes.Type == PayloadType.MapLink)
                                                {
                                                    if (ImGui.GetContentRegionAvail().X - 5 - ImGui.CalcTextSize(textTypes.Text).X < 0)
                                                    {
                                                        ImGui.Text("");
                                                    }
                                                    if (ImGui.SmallButton(textTypes.Text))
                                                    {
                                                        this.pluginInterface.Framework.Gui.OpenMapWithMapLink((Dalamud.Game.Chat.SeStringHandling.Payloads.MapLinkPayload)textTypes.Payload);
                                                    }
                                                }

                                                if (count < (line.Text.Count - 1))
                                                {
                                                    ImGui.SameLine(); count++;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (tab.Config[0])
                                        {
                                            ImGui.TextColored(timeColour, line.Time + " "); ImGui.SameLine();
                                        }
                                        if (tab.Config[1] && tab.Chans[ConvertForArray(line.Channel)])
                                        {
                                            ImGui.TextColored(chanColour[ConvertForArray(line.Channel)], line.ChannelShort + " "); ImGui.SameLine();
                                        }
                                        if (line.Sender.Length > 0)
                                        {
                                            ImGui.TextColored(nameColour, line.Sender + ":"); ImGui.SameLine();
                                        }

                                        int count = 0;
                                        foreach (TextTypes textTypes in line.Text)
                                        {
                                            if (textTypes.Type == PayloadType.RawText)
                                            {
                                                ImGui.PushStyleColor(ImGuiCol.Text, logColour[line.ChannelColour]);
                                                Wrap(textTypes.Text);
                                                ImGui.PopStyleColor();
                                            }

                                            if (textTypes.Type == PayloadType.MapLink)
                                            {
                                                if (ImGui.GetContentRegionAvail().X - 5 - ImGui.CalcTextSize(textTypes.Text).X < 0)
                                                {
                                                    ImGui.Text("");
                                                }
                                                if (ImGui.SmallButton(textTypes.Text))
                                                {
                                                    this.pluginInterface.Framework.Gui.OpenMapWithMapLink((Dalamud.Game.Chat.SeStringHandling.Payloads.MapLinkPayload)textTypes.Payload);
                                                }
                                            }

                                            if (count < (line.Text.Count - 1))
                                            {
                                                ImGui.SameLine();
                                                count++;
                                            }
                                        }
                                    }
                                }
                                if (tab.Scroll == true)
                                {
                                    ImGui.SetScrollHereY();
                                    tab.Scroll = false;
                                }
                                ImGui.PopStyleVar();
                                ImGui.EndChild();

                                if (tab.FilterOn)
                                {
                                    ImGui.InputText("Filter Text", ref tab.Filter, 999);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Only show lines with this text.");
                                    }
                                }

                                if (no_mouse2 && !no_mouse)
                                {
                                    Num.Vector2 vMin = ImGui.GetWindowContentRegionMin();
                                    Num.Vector2 vMax = ImGui.GetWindowContentRegionMax();

                                    vMin.X += ImGui.GetWindowPos().X;
                                    vMin.Y += ImGui.GetWindowPos().Y + 22;
                                    vMax.X += ImGui.GetWindowPos().X - 22;
                                    vMax.Y += ImGui.GetWindowPos().Y;

                                    if (ImGui.IsMouseHoveringRect(vMin, vMax))
                                    {
                                        no_mouse = true; flickback = true;
                                    }
                                }
                                tab.msg = false;
                                ImGui.EndTabItem();
                            }
                            ImGui.PopStyleColor();
                            ImGui.PopStyleColor();
                        }
                        loop++;
                    }
                    ImGui.EndTabBar();
                    ImGui.End();
                }
            }



            if (configWindow)
            {
                //ImGui.PushFont(font);

                ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver);
                ImGui.Begin("Chat Config", ref configWindow);
                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;
                if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                {
                    if (ImGui.BeginTabItem("Config"))
                    {
                        float footer1 = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                        ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer1), false);
                        ImGui.Text("");

                        ImGui.Columns(3);

                        ImGui.Checkbox("Show Chat Extender", ref chatWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Checkbox("Scrollbar", ref no_scrollbar);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Shows ScrollBar");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Position", ref no_move);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the position of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Size", ref no_resize);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the size of the Chat Extender");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("ClickThrough Tab Bar", ref no_mouse);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Tab Bar of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Chat", ref no_mouse2);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Chat Extension chatbox");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Columns(1);
                        ImGui.SliderFloat("Chat Extender Alpha", ref alpha, 0.001f, 0.999f);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the Alpha of the Chat Extender");
                        }
                        ImGui.Text("");

                        ImGui.Text("");
                        ImGui.Text("Highlight Example");
                        HighlightText();
                        ImGui.InputText("##HighlightText", ref tempHigh, 999); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Will highlight EXACT matches only. Seperate words with [,].");
                        }
                        ImGui.SameLine();
                        if (ImGui.Button("Apply"))
                        {
                            high.highlights = tempHigh.Split(',');
                        }
                        ImGui.Columns(4);
                        ImGui.SliderInt("Alpha", ref high.htA, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Blue", ref high.htB, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Green", ref high.htG, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Red", ref high.htR, 0, 255); ImGui.NextColumn();
                        ImGui.Columns(1);
                        ImGui.Text("");

                        ImGui.Columns(1);

                        if (ImGui.Button("Save and Close Config"))
                        {
                            SaveConfig();

                            configWindow = false;
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                        }
                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }


                    if (ImGui.BeginTabItem("Colours"))
                    {
                        ImGui.Columns(4);
                        ImGui.Text("Example"); ImGui.NextColumn();
                        ImGui.Text("Colour 1"); ImGui.NextColumn();
                        ImGui.Text("Colour 2"); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.TextColored(timeColour, "[12:00]"); ImGui.NextColumn();
                        ImGui.ColorEdit4("Time Colour", ref timeColour, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.TextColored(nameColour, "Mr E"); ImGui.NextColumn();
                        ImGui.ColorEdit4("Name Colour", ref nameColour, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        for (int i = 0; i < (Channels.Length); i++)
                        {
                            ImGui.InputText("##Tab Name" + i.ToString(), ref Chan[i], 99); ImGui.NextColumn();
                            ImGui.TextColored(chanColour[i], "[" + Channels[i] + "]"); ImGui.SameLine(); ImGui.TextColored(logColour[i], "Text"); ImGui.NextColumn();
                            ImGui.ColorEdit4(Channels[i] + " Colour1", ref chanColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            ImGui.ColorEdit4(Channels[i] + " Colour2", ref logColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        }
                        ImGui.Columns(1);

                        if (ImGui.Button("Save and Close Config"))
                        {
                            SaveConfig();

                            configWindow = false;
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                        }

                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Tabs"))
                    {
                        if (ImGui.Button("Add New Tab"))
                        {
                            tempTitle = "New";

                            while (CheckDupe(items, tempTitle))
                            {
                                tempTitle += ".";
                            }

                            items.Add(new DynTab(tempTitle, new List <ChatText>(), true));
                            tempTitle = "Title";
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Add a new Tab to the Chat Extender");
                        }

                        if (ImGui.TreeNode("Tab Order"))
                        {
                            ImGui.Columns(3);
                            ImGui.Text("Tab"); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();

                            List <TabBase> temp_clone = new List <TabBase>();
                            temp_clone = CopyItems(items);
                            for (int i = 0; i < (items.Count); i++)
                            {
                                ImGui.Text(items[i].Title); ImGui.NextColumn();
                                if (i > 0)
                                {
                                    if (ImGui.Button("^##" + i.ToString()))
                                    {
                                        TabBase mover = temp_clone[i];
                                        temp_clone.RemoveAt(i);
                                        temp_clone.Insert(i - 1, mover);
                                    }
                                }
                                ImGui.NextColumn();
                                if (i < items.Count - 1)
                                {
                                    if (ImGui.Button("v##" + i.ToString()))
                                    {
                                        TabBase mover = temp_clone[i];
                                        temp_clone.RemoveAt(i);
                                        temp_clone.Insert(i + 1, mover);
                                    }
                                }
                                ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            items = CopyItems(temp_clone);
                            ImGui.TreePop();
                        }


                        foreach (var tab in items)
                        {
                            if (tab.Enabled)
                            {
                                if (ImGui.TreeNode(tab.Title))
                                {
                                    float footer2 = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                    ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer2), false);
                                    ImGui.InputText("##Tab Name", ref tempTitle, bufSize);
                                    ImGui.SameLine();
                                    if (ImGui.Button("Set Tab Title"))
                                    {
                                        if (tempTitle.Length == 0)
                                        {
                                            tempTitle += ".";
                                        }

                                        while (CheckDupe(items, tempTitle))
                                        {
                                            tempTitle += ".";
                                        }

                                        tab.Title = tempTitle;
                                        tempTitle = "Title";
                                    }
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Change the title of the Tab");
                                    }

                                    ImGui.Columns(3);

                                    ImGui.Checkbox("Time Stamp", ref tab.Config[0]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Show Timestamps in this Tab");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Channel", ref tab.Config[1]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Show the Channel the message came from");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Translate", ref tab.Config[2]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable Japanese -> English translation");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.Checkbox("AutoScroll", ref tab.AutoScroll);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable the Chat to scroll automatically on a new message");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Save to file", ref tab.Config[3]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Write this tab to '\\My Documents\\FFXIV_ChatExtender\\Logs\\<YYYYMMDD>_TAB.txt");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Enable Filter", ref tab.FilterOn);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable Filtering of text");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.Columns(1);

                                    ImGui.Text("");


                                    //TODO: Add a confirm prompt

                                    if (EnabledTabs(items) > 1)
                                    {
                                        if (ImGui.Button("Delete Tab"))
                                        {
                                            tab.Enabled = false;
                                        }
                                    }
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Removes Tab");
                                    }



                                    ImGui.Columns(2);
                                    ImGui.Text("Channel"); ImGui.NextColumn();
                                    if (tab.Config[1])
                                    {
                                        ImGui.Text("Show Short");
                                    }
                                    else
                                    {
                                        ImGui.Text("");
                                    }
                                    ImGui.NextColumn();

                                    for (int i = 0; i < (Channels.Length); i++)
                                    {
                                        ImGui.PushStyleColor(ImGuiCol.Text, chanColour[i]);
                                        ImGui.Checkbox("[" + Channels[i] + "]", ref tab.Logs[i]); ImGui.NextColumn();
                                        if (tab.Config[1])
                                        {
                                            ImGui.Checkbox(Chan[i], ref tab.Chans[i]);
                                        }
                                        else
                                        {
                                            ImGui.Text("");
                                        }
                                        ImGui.NextColumn();
                                        ImGui.PopStyleColor();
                                    }
                                    ImGui.Columns(1);
                                    ImGui.EndChild();
                                }
                            }
                        }

                        if (ImGui.Button("Save and Close Config"))
                        {
                            SaveConfig();

                            configWindow = false;
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                        }

                        ImGui.EndTabItem();
                    }


                    if (ImGui.BeginTabItem("Translator"))
                    {
                        ImGui.Checkbox("Inject Translation", ref injectChat);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Inject translated text into the normal FFXIV Chatbox");
                        }

                        ImGui.Text("Surrounds of Translated text");
                        ImGui.PushItemWidth(24);
                        ImGui.InputText("##Left", ref lTr, 3); ImGui.SameLine();
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the characters on the left of Translated text");
                        }
                        ImGui.PopItemWidth();
                        ImGui.Text("Translation"); ImGui.SameLine();
                        ImGui.PushItemWidth(24);
                        ImGui.InputText("##Right", ref rTr, 3);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the characters on the right of Translated text");
                        }
                        ImGui.PopItemWidth();
                        ImGui.Text("");
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Font"))
                    {
                        ImGui.Columns(3);
                        ImGui.InputInt("H Spacing", ref space_hor);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Horizontal spacing of chat text");
                        }
                        ImGui.NextColumn();
                        ImGui.InputInt("V Spacing", ref space_ver);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Vertical spacing of cha text");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Columns(1);

                        ImGui.EndTabItem();
                    }
                }

                ImGui.EndTabBar();
                ImGui.EndChild();

                //ImGui.PopFont();
            }
        }
Пример #25
0
        private void ChatUI()
        {
            if (nulled)
            {
                sleep--;
                if (sleep > 0)
                {
                    return;
                }

                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);

                if (chatLog != IntPtr.Zero)
                {
                    chatLogPanel_0 = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLogPanel_0", 1);
                    chatLogStuff   = Marshal.ReadIntPtr(chatLog, 0xc8);
                }
            }

            if (pluginInterface.ClientState.LocalPlayer == null || getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1) == IntPtr.Zero)
            {
                if (getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1) == IntPtr.Zero)
                {
                    sleep          = 1000;
                    nulled         = true;
                    chatLogStuff   = IntPtr.Zero;
                    chatLog        = IntPtr.Zero;
                    chatLogPanel_0 = IntPtr.Zero;
                }
            }
            else
            {
                nulled = false;
            }

            if (nulled)
            {
                return;
            }

            ImGuiWindowFlags chat_window_flags     = 0;
            ImGuiWindowFlags chat_sub_window_flags = 0;

            if (no_titlebar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoTitleBar;
            }
            if (no_scrollbar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (no_scrollbar)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (!no_menu)
            {
                chat_window_flags |= ImGuiWindowFlags.MenuBar;
            }
            if (no_move)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMove;
            }
            if (no_resize)
            {
                chat_window_flags |= ImGuiWindowFlags.NoResize;
            }
            if (no_collapse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoCollapse;
            }
            if (no_nav)
            {
                chat_window_flags |= ImGuiWindowFlags.NoNav;
            }
            if (no_mouse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }
            if (no_mouse2)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }


            //otherwise update all the values
            if (chatLogStuff != IntPtr.Zero)
            {
                var chatLogProperties = Marshal.ReadIntPtr(chatLog, 0xC8);
                Marshal.Copy(chatLogProperties + 0x44, chatLogPosition, 0, 2);
                Width   = Marshal.ReadInt16(chatLogProperties + 0x90);
                Height  = Marshal.ReadInt16(chatLogProperties + 0x92);
                Alpha   = Marshal.ReadByte(chatLogProperties + 0x73);
                BoxHide = Marshal.ReadByte(chatLogProperties + 0x182);
            }
            //Get initial hooks in
            else
            {
                chatLog = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLog", 1);
                if (chatLog != IntPtr.Zero)
                {
                    chatLogPanel_0 = getUI2ObjByName(Marshal.ReadIntPtr(getBaseUIObj(), 0x20), "ChatLogPanel_0", 1);
                    chatLogStuff   = Marshal.ReadIntPtr(chatLog, 0xc8);
                }
            }

            if (!skipfont)
            {
                if (font.IsLoaded())
                {
                    ImGui.PushFont(font);
                    if (hideWithChat & Alpha.ToString() != "0")
                    {
                        if (chatWindow)
                        {
                            if (flickback)
                            {
                                no_mouse  = false;
                                flickback = false;
                            }
                            ImGui.SetNextWindowSize(new Num.Vector2(200, 100), ImGuiCond.FirstUseEver);
                            ImGui.SetNextWindowBgAlpha(alpha);
                            ImGui.Begin("Another Window", ref chatWindow, chat_window_flags);
                            ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                            if (overrideChat)
                            {
                                ImGui.SetWindowPos(new Num.Vector2(chatLogPosition[0] + 15, chatLogPosition[1] + 10));
                                ImGui.SetWindowSize(new Num.Vector2(Width - 27, Height - 75));
                                //Marshal.WriteByte(chatLogPanel_0 + 0x182, BoxOff);
                            }
                            else
                            {
                                //Marshal.WriteByte(chatLogPanel_0 + 0x182, BoxOn);
                            }

                            if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                            {
                                int loop = 0;
                                foreach (var tab in items)
                                {
                                    if (tab.Enabled)
                                    {
                                        //WIP

                                        if (tab.sel)
                                        {
                                            ImGui.PushStyleColor(ImGuiCol.Tab, tab_sel);
                                            ImGui.PushStyleColor(ImGuiCol.Text, tab_sel_text);
                                            tab.sel = false;
                                        }
                                        else if (tab.msg)
                                        {
                                            ImGui.PushStyleColor(ImGuiCol.Tab, tab_ind);
                                            ImGui.PushStyleColor(ImGuiCol.Text, tab_ind_text);
                                        }
                                        else
                                        {
                                            ImGui.PushStyleColor(ImGuiCol.Tab, tab_norm);
                                            ImGui.PushStyleColor(ImGuiCol.Text, tab_norm_text);
                                        }



                                        if (ImGui.BeginTabItem(tab.Title))
                                        {
                                            tab.sel = true;

                                            float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                            if (!tab.FilterOn)
                                            {
                                                footer = 0;
                                            }
                                            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Num.Vector2(space_hor, space_ver));
                                            ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer), false, chat_sub_window_flags);


                                            foreach (ChatText line in tab.Chat)
                                            {
                                                if (tab.FilterOn)
                                                {
                                                    if (ContainsText(line.Text, tab.Filter))
                                                    {
                                                        if (tab.Config[0])
                                                        {
                                                            if (fontShadow)
                                                            {
                                                                ShadowFont(line.Time + " ");
                                                            }
                                                            ImGui.TextColored(timeColour, line.Time + " "); ImGui.SameLine();
                                                        }
                                                        if (tab.Config[1] && tab.Chans[ConvertForArray(line.Channel)])
                                                        {
                                                            if (fontShadow)
                                                            {
                                                                ShadowFont(line.ChannelShort + " ");
                                                            }
                                                            ImGui.TextColored(chanColour[ConvertForArray(line.Channel)], line.ChannelShort + " "); ImGui.SameLine();
                                                        }
                                                        if (line.Sender.Length > 0)
                                                        {
                                                            if (fontShadow)
                                                            {
                                                                ShadowFont(line.Sender + ":");
                                                            }
                                                            ImGui.TextColored(nameColour, line.Sender + ":"); ImGui.SameLine();
                                                        }

                                                        int count = 0;
                                                        foreach (TextTypes textTypes in line.Text)
                                                        {
                                                            if (textTypes.Type == PayloadType.RawText)
                                                            {
                                                                ImGui.PushStyleColor(ImGuiCol.Text, logColour[line.ChannelColour]);
                                                                Wrap(textTypes.Text);
                                                                ImGui.PopStyleColor();
                                                            }

                                                            if (textTypes.Type == PayloadType.MapLink)
                                                            {
                                                                if (ImGui.GetContentRegionAvail().X - 5 - ImGui.CalcTextSize(textTypes.Text).X < 0)
                                                                {
                                                                    ImGui.Text("");
                                                                }
                                                                if (ImGui.SmallButton(textTypes.Text))
                                                                {
                                                                    this.pluginInterface.Framework.Gui.OpenMapWithMapLink((Dalamud.Game.Chat.SeStringHandling.Payloads.MapLinkPayload)textTypes.Payload);
                                                                }
                                                            }

                                                            if (count < (line.Text.Count - 1))
                                                            {
                                                                ImGui.SameLine(); count++;
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    if (tab.Config[0])
                                                    {
                                                        if (fontShadow)
                                                        {
                                                            ShadowFont(line.Time + " ");
                                                        }
                                                        ImGui.TextColored(timeColour, line.Time + " "); ImGui.SameLine();
                                                    }
                                                    if (tab.Config[1] && tab.Chans[ConvertForArray(line.Channel)])
                                                    {
                                                        if (fontShadow)
                                                        {
                                                            ShadowFont(line.ChannelShort + " ");
                                                        }
                                                        ImGui.TextColored(chanColour[ConvertForArray(line.Channel)], line.ChannelShort + " "); ImGui.SameLine();
                                                    }
                                                    if (line.Sender.Length > 0)
                                                    {
                                                        if (fontShadow)
                                                        {
                                                            ShadowFont(line.Sender + ":");
                                                        }
                                                        ImGui.TextColored(nameColour, line.Sender + ":"); ImGui.SameLine();
                                                    }

                                                    int count = 0;
                                                    foreach (TextTypes textTypes in line.Text)
                                                    {
                                                        if (textTypes.Type == PayloadType.RawText)
                                                        {
                                                            ImGui.PushStyleColor(ImGuiCol.Text, logColour[line.ChannelColour]);
                                                            Wrap(textTypes.Text);
                                                            ImGui.PopStyleColor();
                                                        }

                                                        if (textTypes.Type == PayloadType.MapLink)
                                                        {
                                                            if (ImGui.GetContentRegionAvail().X - 5 - ImGui.CalcTextSize(textTypes.Text).X < 0)
                                                            {
                                                                ImGui.Text("");
                                                            }
                                                            if (ImGui.SmallButton(textTypes.Text))
                                                            {
                                                                this.pluginInterface.Framework.Gui.OpenMapWithMapLink((Dalamud.Game.Chat.SeStringHandling.Payloads.MapLinkPayload)textTypes.Payload);
                                                            }
                                                        }

                                                        if (count < (line.Text.Count - 1))
                                                        {
                                                            ImGui.SameLine();
                                                            count++;
                                                        }
                                                    }
                                                }
                                            }
                                            if (tab.Scroll == true)
                                            {
                                                ImGui.SetScrollHereY();
                                                tab.Scroll = false;
                                            }
                                            ImGui.PopStyleVar();
                                            ImGui.EndChild();

                                            if (tab.FilterOn)
                                            {
                                                ImGui.InputText("Filter Text", ref tab.Filter, 999);
                                                if (ImGui.IsItemHovered())
                                                {
                                                    ImGui.SetTooltip("Only show lines with this text.");
                                                }
                                            }

                                            if (no_mouse2 && !no_mouse)
                                            {
                                                Num.Vector2 vMin = ImGui.GetWindowContentRegionMin();
                                                Num.Vector2 vMax = ImGui.GetWindowContentRegionMax();

                                                vMin.X += ImGui.GetWindowPos().X;
                                                vMin.Y += ImGui.GetWindowPos().Y + 22;
                                                vMax.X += ImGui.GetWindowPos().X - 22;
                                                vMax.Y += ImGui.GetWindowPos().Y;

                                                if (ImGui.IsMouseHoveringRect(vMin, vMax))
                                                {
                                                    no_mouse = true; flickback = true;
                                                }
                                            }
                                            tab.msg = false;
                                            ImGui.EndTabItem();
                                        }
                                        ImGui.PopStyleColor();
                                        ImGui.PopStyleColor();
                                    }
                                    loop++;
                                }
                                ImGui.EndTabBar();
                                ImGui.End();
                            }
                        }
                    }
                    ImGui.PopFont();
                }
            }



            if (configWindow)
            {
                ImGui.SetNextWindowSize(new Num.Vector2(300, 500), ImGuiCond.FirstUseEver);
                ImGui.Begin("Chat Config", ref configWindow);
                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer), false);

                if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                {
                    if (ImGui.BeginTabItem("Config"))
                    {
                        ImGui.Text("");

                        ImGui.Columns(3);

                        ImGui.Checkbox("Show Chat Extender", ref chatWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Enable Translations", ref allowTranslation);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable Translations from JPN to ENG");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Chat Bubbles", ref bubblesWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable Chat Bubbles");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("24 Hour Time", ref hourTime);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Switch to 24 Hour (Military) time.");
                        }
                        ImGui.NextColumn();

                        //ImGui.Checkbox("Hide with FFXIV Chat", ref hideWithChat);
                        //if (ImGui.IsItemHovered()) { ImGui.SetTooltip("Spoopy"); }
                        ImGui.Text("");
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Checkbox("Hide Scrollbar", ref no_scrollbar);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Shows ScrollBar");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Position", ref no_move);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the position of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Size", ref no_resize);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the size of the Chat Extender");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("ClickThrough Tab Bar", ref no_mouse);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Tab Bar of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Chat", ref no_mouse2);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Chat Extension chatbox");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();

                        ImGui.Columns(1);
                        ImGui.SliderFloat("Chat Extender Alpha", ref alpha, 0.001f, 0.999f);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the Alpha of the Chat Extender");
                        }
                        ImGui.Text("");

                        ImGui.Text("");
                        ImGui.Text("Highlight Example");
                        HighlightText();
                        ImGui.InputText("##HighlightText", ref tempHigh, 999); if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Will highlight EXACT matches only. Seperate words with [,].");
                        }
                        ImGui.SameLine();
                        if (ImGui.Button("Apply"))
                        {
                            high.highlights = tempHigh.Split(',');
                        }
                        ImGui.Columns(4);
                        ImGui.SliderInt("Alpha", ref high.htA, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Blue", ref high.htB, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Green", ref high.htG, 0, 255); ImGui.NextColumn();
                        ImGui.SliderInt("Red", ref high.htR, 0, 255); ImGui.NextColumn();
                        ImGui.Columns(1);
                        ImGui.Text("");

                        ImGui.Columns(1);


                        ImGui.EndTabItem();
                    }


                    if (ImGui.BeginTabItem("Channels"))
                    {
                        ImGui.Columns(4);
                        ImGui.Text("Example"); ImGui.NextColumn();
                        ImGui.Text("Colour 1"); ImGui.NextColumn();
                        ImGui.Text("Colour 2"); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.TextColored(timeColour, "[12:00]"); ImGui.NextColumn();
                        ImGui.ColorEdit4("Time Colour", ref timeColour, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.TextColored(nameColour, "Player Names"); ImGui.NextColumn();
                        ImGui.ColorEdit4("Name Colour", ref nameColour, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        ImGui.Text(""); ImGui.NextColumn();
                        for (int i = 0; i < (Channels.Length); i++)
                        {
                            ImGui.InputText("##Tab Name" + i.ToString(), ref Chan[i], 99); ImGui.NextColumn();
                            ImGui.TextColored(chanColour[i], "[" + Channels[i] + "]"); ImGui.SameLine(); ImGui.TextColored(logColour[i], "Text"); ImGui.NextColumn();
                            ImGui.ColorEdit4(Channels[i] + " Colour1", ref chanColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            ImGui.ColorEdit4(Channels[i] + " Colour2", ref logColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        }
                        ImGui.Columns(1);
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Tabs"))
                    {
                        if (ImGui.Button("Add New Tab"))
                        {
                            tempTitle = "New";

                            while (CheckDupe(items, tempTitle))
                            {
                                tempTitle += ".";
                            }

                            items.Add(new DynTab(tempTitle, new ConcurrentQueue <ChatText>(), true));
                            tempTitle = "Title";
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Add a new Tab to the Chat Extender");
                        }

                        if (ImGui.TreeNode("Tab Order"))
                        {
                            ImGui.Columns(3);
                            ImGui.Text("Tab"); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();

                            List <TabBase> temp_clone = new List <TabBase>();
                            temp_clone = CopyItems(items);
                            for (int i = 0; i < (items.Count); i++)
                            {
                                ImGui.Text(items[i].Title); ImGui.NextColumn();
                                if (i > 0)
                                {
                                    if (ImGui.Button("^##" + i.ToString()))
                                    {
                                        TabBase mover = temp_clone[i];
                                        temp_clone.RemoveAt(i);
                                        temp_clone.Insert(i - 1, mover);
                                    }
                                }
                                ImGui.NextColumn();
                                if (i < items.Count - 1)
                                {
                                    if (ImGui.Button("v##" + i.ToString()))
                                    {
                                        TabBase mover = temp_clone[i];
                                        temp_clone.RemoveAt(i);
                                        temp_clone.Insert(i + 1, mover);
                                    }
                                }
                                ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            items = CopyItems(temp_clone);
                            ImGui.TreePop();
                        }

                        ImGui.Separator();
                        foreach (var tab in items)
                        {
                            if (tab.Enabled)
                            {
                                if (ImGui.TreeNode(tab.Title))
                                {
                                    float footer2 = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                    ImGui.BeginChild("scrolling", new Num.Vector2(0, -footer2), false);
                                    ImGui.InputText("##Tab Name", ref tempTitle, bufSize);
                                    ImGui.SameLine();
                                    if (ImGui.Button("Set Tab Title"))
                                    {
                                        if (tempTitle.Length == 0)
                                        {
                                            tempTitle += ".";
                                        }

                                        while (CheckDupe(items, tempTitle))
                                        {
                                            tempTitle += ".";
                                        }

                                        tab.Title = tempTitle;
                                        tempTitle = "Title";
                                    }
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Change the title of the Tab");
                                    }

                                    ImGui.Columns(3);

                                    ImGui.Checkbox("Time Stamp", ref tab.Config[0]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Show Timestamps in this Tab");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Channel", ref tab.Config[1]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Show the Channel the message came from");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Translate", ref tab.Config[2]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable Japanese -> English translation");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.Checkbox("AutoScroll", ref tab.AutoScroll);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable the Chat to scroll automatically on a new message");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Save to file", ref tab.Config[3]);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Write this tab to '\\My Documents\\FFXIV_ChatExtender\\Logs\\<YYYYMMDD>_TAB.txt");
                                    }
                                    ImGui.NextColumn();
                                    ImGui.Checkbox("Enable Filter", ref tab.FilterOn);
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Enable Filtering of text");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.Columns(1);

                                    ImGui.Text("");


                                    //TODO: Add a confirm prompt

                                    if (EnabledTabs(items) > 1)
                                    {
                                        if (ImGui.Button("Delete Tab"))
                                        {
                                            tab.Enabled = false;
                                        }
                                    }
                                    if (ImGui.IsItemHovered())
                                    {
                                        ImGui.SetTooltip("Removes Tab");
                                    }



                                    ImGui.Columns(2);
                                    ImGui.Text("Channel"); ImGui.NextColumn();
                                    if (tab.Config[1])
                                    {
                                        ImGui.Text("Show Short");
                                    }
                                    else
                                    {
                                        ImGui.Text("");
                                    }
                                    ImGui.NextColumn();

                                    for (int i = 0; i < (Channels.Length); i++)
                                    {
                                        ImGui.PushStyleColor(ImGuiCol.Text, chanColour[i]);
                                        ImGui.Checkbox("[" + Channels[i] + "]", ref tab.Logs[i]); ImGui.NextColumn();
                                        if (tab.Config[1])
                                        {
                                            ImGui.Checkbox(Chan[i], ref tab.Chans[i]);
                                        }
                                        else
                                        {
                                            ImGui.Text("");
                                        }
                                        ImGui.NextColumn();
                                        ImGui.PopStyleColor();
                                    }
                                    ImGui.Columns(1);
                                    ImGui.EndChild();
                                    ImGui.TreePop();
                                }
                            }
                        }
                        ImGui.EndTabItem();
                    }

                    if (allowTranslation)
                    {
                        if (ImGui.BeginTabItem("Translator"))
                        {
                            ImGui.Checkbox("Inject Translation", ref injectChat);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Inject translated text into the normal FFXIV Chatbox");
                            }

                            ImGui.Text("Surrounds of Translated text");
                            ImGui.PushItemWidth(24);
                            ImGui.InputText("##Left", ref lTr, 3); ImGui.SameLine();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Alter the characters on the left of Translated text");
                            }
                            ImGui.PopItemWidth();
                            ImGui.Text("Translation"); ImGui.SameLine();
                            ImGui.PushItemWidth(24);
                            ImGui.InputText("##Right", ref rTr, 3);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Alter the characters on the right of Translated text");
                            }
                            ImGui.PopItemWidth();
                            ImGui.Text("");
                            ImGui.EndTabItem();

                            ImGui.InputText("Yandex Key", ref yandex, 999);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Key to allow the translator to use the Yandex service");
                            }

                            ImGui.Text("Translator");
                            if (translator == 1)
                            {
                                ImGui.Text("[Google] is set.");
                                if (ImGui.Button("Switch to Yandex"))
                                {
                                    translator = 2;
                                }
                            }

                            if (translator == 2)
                            {
                                ImGui.Text("[Yandex] is set.");
                                if (ImGui.Button("Switch to Google"))
                                {
                                    translator = 1;
                                }
                            }
                            ImGui.EndTabItem();
                        }
                    }

                    if (ImGui.BeginTabItem("Font"))
                    {
                        ImGui.Columns(3);
                        ImGui.PushItemWidth(124);
                        ImGui.InputInt("H Space", ref space_hor);
                        ImGui.PopItemWidth();
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Horizontal spacing of chat text");
                        }
                        ImGui.NextColumn();
                        ImGui.PushItemWidth(124);
                        ImGui.InputInt("V Space", ref space_ver);
                        ImGui.PopItemWidth();
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Vertical spacing of cha text");
                        }
                        ImGui.NextColumn();
                        ImGui.Text("");
                        ImGui.NextColumn();
                        ImGui.Columns(1);
                        ImGui.PushItemWidth(124);
                        ImGui.InputInt("Font Size", ref fontsize); ImGui.SameLine();
                        ImGui.PopItemWidth();
                        if (ImGui.SmallButton("Apply"))
                        {
                            UpdateFont();
                        }
                        ImGui.Checkbox("Font Shadow", ref fontShadow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("WARNING! This is a large tax on processing.\nIf you encounter slowdown, disable this!");
                        }
                        ImGui.EndTabItem();
                    }
                    if (bubblesWindow)
                    {
                        if (ImGui.BeginTabItem("Bubbles"))
                        {
                            ImGui.Columns(3);
                            //ImGui.Checkbox("Debug", ref drawDebug);
                            ImGui.Checkbox("Displacement Up", ref boolUp); ImGui.NextColumn();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("When bubbles collide, move the newest one Up instead of Down.");
                            }
                            //ImGui.InputFloat("MinH", ref minH);
                            //ImGui.InputFloat("MaxH", ref maxH);
                            ImGui.Checkbox("Show Channel", ref bubblesChannel); ImGui.NextColumn();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Show Channel in the bubble.");
                            }
                            ImGui.PushItemWidth(80);
                            ImGui.InputInt("Duration", ref bubbleTime);
                            ImGui.PopItemWidth(); ImGui.NextColumn();
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip("Seconds the bubbles exist for.");
                            }
                            //ImGui.InputInt("X Disp", ref xDisp);
                            //ImGui.InputInt("Y Disp", ref yDisp);
                            //ImGui.InputInt("X Cut", ref xCut);
                            //ImGui.InputInt("Y Cut", ref yCut);
                            //ImGui.ColorEdit4("Bubble Colour", ref bubbleColor, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel);
                            //ImGui.InputFloat("Rounding", ref bubbleRounding);
                            ImGui.Separator();
                            ImGui.Text("Channel"); ImGui.NextColumn();
                            ImGui.Text("Enabled"); ImGui.NextColumn();
                            ImGui.Text("Colour"); ImGui.NextColumn();
                            for (int i = 0; i < (Channels.Length); i++)
                            {
                                ImGui.Text(Channels[i]); ImGui.SameLine(); ImGui.NextColumn();
                                ImGui.Checkbox("##" + Channels[i], ref bubbleEnable[i]); ImGui.NextColumn();
                                ImGui.ColorEdit4(Channels[i] + " ColourBubble", ref bubbleColour[i], ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            ImGui.EndTabItem();
                        }
                    }
                }

                ImGui.EndTabBar();
                ImGui.EndChild();

                if (ImGui.Button("Save and Close Config"))
                {
                    SaveConfig();

                    configWindow = false;
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                }
                ImGui.End();
            }
        }
Пример #26
0
 protected abstract bool TryDockWindow(Point position, TabBase dockedWindowVM);
Пример #27
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();
        }
Пример #28
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();
        }