public bool showVersionInfoPopup(bool force = false)
 {
     if (needShowPopup || force)
     {
         try
         {
             UIComponent uIComponent = UIView.library.ShowModal("ExceptionPanel");
             if (uIComponent != null)
             {
                 Cursor.lockState = CursorLockMode.None;
                 Cursor.visible   = true;
                 BindPropertyByKey component = uIComponent.GetComponent <BindPropertyByKey>();
                 if (component != null)
                 {
                     string title = "Service Vehicles Manager v" + version;
                     string notes = ResourceLoader.loadResourceString("UI.VersionNotes.txt");
                     string text  = "Service Vehicles Manager was updated! Release notes:\r\n\r\n" + notes;
                     string img   = "IconMessage";
                     component.SetProperties(TooltipHelper.Format(new string[]
                     {
                         "title",
                         title,
                         "message",
                         text,
                         "img",
                         img
                     }));
                     needShowPopup            = false;
                     currentSaveVersion.value = fullVersion;
                     return(true);
                 }
                 return(false);
             }
             else
             {
                 SVMUtils.doLog("PANEL NOT FOUND!!!!");
                 return(false);
             }
         }
         catch (Exception e)
         {
             SVMUtils.doErrorLog("showVersionInfoPopup ERROR {0} {1}", e.GetType(), e.Message);
         }
     }
     return(false);
 }
Exemple #2
0
        private void BackupSettings_Load(object sender, EventArgs e)
        {
            Dock = DockStyle.Fill;
            cbDontWantBackups.Checked = _settings.GetLocal().OptOutOfBackups;
            buttonLogin.Enabled       = !_settings.GetLocal().OptOutOfBackups;


            // Allows 2nd column to auto-size to the width of the column heading
            // Source: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.columnheader.width
            buddyList.Columns[1].Width = -2;


            UpdateUi();
            this.FormClosing += (_, __) => {
                _tooltipHelper?.Dispose();
                _tooltipHelper = null;
            };
        }
Exemple #3
0
        protected void ClearTestResults(TreeView treeView)
        {
            foreach (TreeNode node in mColouredNodes)
            {
                node.ToolTipText = TooltipHelper.CreateTestTooltip((TestInfo)node.Tag, null);
                node.ForeColor   = treeView.ForeColor;
                node.NodeFont    = treeView.Font;
            }

            foreach (var node in mGroupNodes)
            {
                node.Collapse();
            }

            mColouredNodes.Clear();

            SelectedTest = null;
        }
            public static void ValidateAndSetupDoors()
            {
                List <ulong> removeSim = new List <ulong>();

                foreach (ObjectGuid guid in new List <ObjectGuid>(GoHere.Settings.mDoorSettings.Keys))
                {
                    DoorSettings settings = GoHere.Settings.mDoorSettings[guid];

                    if (Simulator.GetProxy(guid) != null && settings.SettingsValid)
                    {
                        foreach (KeyValuePair <ulong, long> sims in settings.mSimsRecentlyLetThrough)
                        {
                            if (!settings.WasSimRecentlyLetThrough(sims.Key))
                            {
                                removeSim.Add(sims.Key);
                            }
                            else if (MiniSimDescription.Find(sims.Key) == null)
                            {
                                removeSim.Add(sims.Key);
                            }
                        }

                        foreach (ulong sim in removeSim)
                        {
                            settings.mSimsRecentlyLetThrough.Remove(sim);
                        }

                        GoHere.Settings.AddOrUpdateDoorSettings(guid, settings, false);

                        Door door = GameObject.GetObject(guid) as Door;

                        if (door != null)
                        {
                            RegisterRoomListeners(door.LotCurrent);
                        }

                        continue;
                    }

                    GoHere.Settings.mDoorSettings.Remove(guid);
                }

                TooltipHelper.AddListener(typeof(Door), Type.GetType("NRaas.GoHereSpace.Helpers.DoorPortalComponentEx,NRaasGoHere").GetMethod("SceneWindow_Hover"));
            }
Exemple #5
0
        protected void AddTestNode(TestInfo testInfo, TreeNode parentNode)
        {
            TreeNode node = parentNode.Nodes.Add(testInfo.GetNameString());

            node.ToolTipText      = TooltipHelper.CreateTestTooltip(testInfo, null);
            node.ImageKey         = GetImageKey(testInfo, false);
            node.SelectedImageKey = node.ImageKey;
            node.Tag = testInfo;

            if (!mTestNodes.ContainsKey(testInfo))
            {
                mTestNodes.Add(testInfo, new List <TreeNode> {
                    node
                });
            }
            else
            {
                mTestNodes[testInfo].Add(node);
            }
        }
Exemple #6
0
        public static void NotifyDownload(PrefabInfo prefab)
        {
            Profiler.Info("Notify user of new prefab: {0}", prefab.name);
            var list = UIView.GetAView().GetComponentsInChildren <ChirpPanel>();

            if (list.Count() > 0)
            {
                var panel = list[0];
                panel.AddMessage(new ChirperMessage(prefab));

                var msgsPanel = panel.GetFieldValue <UIScrollablePanel>("m_Container");
                var msgPanel  = msgsPanel.components[msgsPanel.components.Count() - 1];
                var msgButton = (UILabel)msgPanel.components[1];
                msgButton.clipChildren = false;

                var button = msgButton.AddUIComponent <UIButton>();
                button.height           = 75; button.width = 75;
                button.relativePosition = new Vector3(5, 20);
                button.objectUserData   = prefab;
                button.atlas            = prefab.m_Atlas;
                button.normalFgSprite   = prefab.m_Thumbnail;
                button.focusedFgSprite  = prefab.m_Thumbnail + "Focused";
                button.hoveredFgSprite  = prefab.m_Thumbnail + "Hovered";
                button.pressedFgSprite  = prefab.m_Thumbnail + "Pressed";
                button.disabledFgSprite = prefab.m_Thumbnail + "Disabled";

                if (prefab.m_Thumbnail == null || prefab.m_Thumbnail == "")
                {
                    button.normalFgSprite = "ToolbarIconProps";
                }

                string      localizedTooltip = prefab.GetLocalizedTooltip();
                int         hashCode         = TooltipHelper.GetHashCode(localizedTooltip);
                UIComponent tooltipBox       = GeneratedPanel.GetTooltipBox(hashCode);

                button.tooltip    = localizedTooltip;
                button.tooltipBox = tooltipBox;

                button.eventClick += PrefabButtonClicked;
            }
        }
Exemple #7
0
 public static void DisplayMessage(string str1, string str2, string str3)
 {
     try
     {
         var uiComponent = UIView.library.ShowModal("ExceptionPanel");
         if ((UnityEngine.Object)uiComponent != (UnityEngine.Object)null)
         {
             Cursor.lockState = CursorLockMode.None;
             Cursor.visible   = true;
             var component = uiComponent.GetComponent <BindPropertyByKey>();
             if (component != null)
             {
                 component.SetProperties(TooltipHelper.Format("title", str1, "message", str2, "img", str3));
             }
         }
     }
     catch (Exception ex)
     {
         Logger.LogException(ex);
     }
 }
        private static bool DrawBuildingButtonOnPanel(BuildingInfo prefab, UIScrollablePanel panel)
        {
            int _UIBaseHeight = 109;

            var BuildingButton = panel.AddUIComponent <UIButton>();

            BuildingButton.size  = new Vector2(_UIBaseHeight, 100);  //apply settings to building buttons.
            BuildingButton.atlas = prefab.m_Atlas;

            BuildingButton.normalFgSprite   = prefab.m_Thumbnail;
            BuildingButton.focusedFgSprite  = prefab.m_Thumbnail + "Focused";
            BuildingButton.hoveredFgSprite  = prefab.m_Thumbnail + "Hovered";
            BuildingButton.pressedFgSprite  = prefab.m_Thumbnail + "Pressed";
            BuildingButton.disabledFgSprite = prefab.m_Thumbnail + "Disabled";

            if (prefab.m_Thumbnail == null || prefab.m_Thumbnail == "")
            {
                BuildingButton.normalFgSprite = "ToolbarIconProps";
            }

            BuildingButton.objectUserData      = prefab;
            BuildingButton.horizontalAlignment = UIHorizontalAlignment.Center;
            BuildingButton.verticalAlignment   = UIVerticalAlignment.Middle;
            BuildingButton.pivot = UIPivotPoint.TopCenter;

            //if ( Category == "education" )
            //    BuildingButton.verticalAlignment = UIVerticalAlignment.Bottom;

            string      localizedTooltip = prefab.GetLocalizedTooltip();
            int         hashCode         = TooltipHelper.GetHashCode(localizedTooltip);
            UIComponent tooltipBox       = GeneratedPanel.GetTooltipBox(hashCode);

            BuildingButton.tooltipAnchor = UITooltipAnchor.Anchored;
            BuildingButton.isEnabled     = true;
            BuildingButton.tooltip       = localizedTooltip;
            BuildingButton.tooltipBox    = tooltipBox;
            BuildingButton.eventClick   += UI.PrefabButtonClicked;
            return(true);
        }
Exemple #9
0
        public void SetupElements(GameObjectViewComponent view, bool primary, bool secondary)
        {
            if (this.IsInitialized)
            {
                return;
            }
            if (this.HealthAmount >= this.MaxHealthAmount && this.SecondaryHealthAmount >= this.SecondaryMaxHealthAmount)
            {
                this.TeardownElements();
                return;
            }
            this.IsInitialized = true;
            if (primary && TooltipHelper.WouldOverlapAnotherTooltip(view))
            {
                return;
            }
            this.secondaryOnly = (secondary && !primary);
            UXController uXController = Service.Get <UXController>();
            string       text         = "HealthSlider" + view.MainGameObject.GetInstanceID().ToString();

            if (primary)
            {
                this.slider = uXController.MiscElementsManager.CreateHealthSlider(text, uXController.WorldUIParent, false);
                if (this.slider != null)
                {
                    this.slider.Value = 1f;
                    this.tooltipHelper.SetupElements(view, this.slider, 0f, true, true);
                }
            }
            if (secondary)
            {
                this.secondarySlider = uXController.MiscElementsManager.CreateHealthSlider("s_" + text, uXController.WorldUIParent, true);
                if (this.secondarySlider != null)
                {
                    this.secondarySlider.Value = 1f;
                    this.secondaryTooltipHelper.SetupElements(view, this.secondarySlider, 1f, true, false);
                }
            }
        }
Exemple #10
0
        public SettingsWindow(
            CefBrowserHandler cefBrowserHandler,
            TooltipHelper tooltipHelper,
            Action itemViewUpdateTrigger,
            IPlayerItemDao playerItemDao,
            GDTransferFile[] modFilter,
            TransferStashService transferStashService,
            TransferStashService2 transferStashService2,
            LanguagePackPicker languagePackPicker,
            SettingsService settings, GrimDawnDetector grimDawnDetector, DarkMode darkModeToggler, AutomaticUpdateChecker automaticUpdateChecker)
        {
            InitializeComponent();
            _controller                 = new SettingsController(settings);
            this._cefBrowserHandler     = cefBrowserHandler;
            this._tooltipHelper         = tooltipHelper;
            this._itemViewUpdateTrigger = itemViewUpdateTrigger;
            this._playerItemDao         = playerItemDao;
            this._modFilter             = modFilter;
            this._transferStashService  = transferStashService;
            this._transferStashService2 = transferStashService2;
            _languagePackPicker         = languagePackPicker;
            _settings               = settings;
            _grimDawnDetector       = grimDawnDetector;
            _darkModeToggler        = darkModeToggler;
            _automaticUpdateChecker = automaticUpdateChecker;

            _controller.BindCheckbox(cbMinimizeToTray);

            _controller.BindCheckbox(cbTransferAnyMod);
            _controller.BindCheckbox(cbSecureTransfers);
            _controller.BindCheckbox(cbShowRecipesAsItems);
            _controller.BindCheckbox(cbHideSkills);
            _controller.LoadDefaults();

            // TODO: Write out the settingscontroller and add logic for updating showskills config

            linkCheckForUpdates.Visible = Environment.Is64BitOperatingSystem;
            pbAutomaticUpdates.Visible  = Environment.Is64BitOperatingSystem;
        }
        private void AddTestNode(Profile profile, TestInfo testInfo, TreeNode parentNode)
        {
            RequirementLevel requirementLevel = testInfo.FeatureUnderTest.GetInfo().Requirement[profile];

            TreeNode node = parentNode.Nodes.Add(testInfo.GetNameString());

            node.ToolTipText      = TooltipHelper.CreateTestTooltip(testInfo, null);
            node.ImageKey         = GetTestImage(requirementLevel);
            node.SelectedImageKey = node.ImageKey;
            node.Tag = testInfo;

            if (!mTestNodes.ContainsKey(testInfo))
            {
                mTestNodes.Add(testInfo, new List <TreeNode> {
                    node
                });
            }
            else
            {
                mTestNodes[testInfo].Add(node);
            }
        }
Exemple #12
0
        public SettingsWindow(
            IItemTagDao itemTagDao,
            TooltipHelper tooltipHelper,
            Action itemViewUpdateTrigger,
            IDatabaseSettingDao settingsDao,
            IDatabaseItemDao itemDao,
            IPlayerItemDao playerItemDao,
            ArzParser parser,
            GDTransferFile[] modFilter,
            StashManager stashManager, ParsingService parsingService)
        {
            InitializeComponent();
            this._tooltipHelper         = tooltipHelper;
            this._itemViewUpdateTrigger = itemViewUpdateTrigger;
            this._settingsDao           = settingsDao;
            this._itemDao       = itemDao;
            this._playerItemDao = playerItemDao;
            this._parser        = parser;
            this._modFilter     = modFilter;
            this._stashManager  = stashManager;
            _parsingService     = parsingService;
            _itemTagDao         = itemTagDao;

            _controller.BindCheckbox(cbMinimizeToTray);

            _controller.BindCheckbox(cbMergeDuplicates);
            _controller.BindCheckbox(cbTransferAnyMod);
            _controller.BindCheckbox(cbSecureTransfers);
            _controller.BindCheckbox(cbShowRecipesAsItems);
            _controller.BindCheckbox(cbAutoUpdateModSettings);
            //_controller.BindCheckbox(cbInstalootDisabled);
            _controller.BindCheckbox(cbInstaTransfer);
            _controller.BindCheckbox(cbAutoSearch);
            _controller.BindCheckbox(cbDisplaySkills);
            _controller.LoadDefaults();

            cbInstalootEnabled.Checked = (InstalootSettingType)Properties.Settings.Default.InstalootSetting == InstalootSettingType.Enabled;
        }
Exemple #13
0
        private void UpdateUnitList()
        {
            if (!IsHandleCreated)
            {
                return;
            }

            mIsUnitListUpdating = true;

            this.InvokeIfRequired((() =>
            {
                lVUnits.Items.Clear();

                foreach (Unit unit in UnitSet.GetUnits())
                {
                    var item = new ListViewItem();
                    item.SubItems.Add((lVUnits.Items.Count + 1).ToString(CultureInfo.InvariantCulture));

                    item.SubItems.Add(unit.Name);
                    item.SubItems.Add(unit.Mac);
                    item.SubItems.Add(unit.Ip);
                    item.SubItems.Add(GetFeatureListString(unit));
                    item.SubItems.Add(unit.Type.GetDescription());

                    item.Checked = !unit.IsIgnored;
                    item.ToolTipText = TooltipHelper.CreateDeviceTooltip(unit as Device);

                    bool isChecked = item.Checked;
                    item.ForeColor = isChecked ? Settings.Default.CheckedUnitColor : Settings.Default.UnitColor;

                    lVUnits.Items.Add(item);
                }
            }));

            mIsUnitListUpdating = false;
        }
        public static void UpdateTooltipPatch(TooltipVM tooltipVM, Hero hero)
        {
            try
            {
                if (hero.Clan is null || !SettingsHelper.SubSystemEnabled(SubSystemType.LoyaltyTooltips, hero.Clan))
                {
                    return;
                }

                if (hero.Clan.Kingdom != null && hero.Clan.Kingdom.RulingClan != hero.Clan && hero == hero.Clan.Leader)
                {
                    int RelationWithLiege = hero.GetRelation(hero.Clan.Kingdom.Ruler);
                    tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipRelationHeader(hero.Clan.Kingdom.Ruler), RelationWithLiege.ToString("N0"), 0, RelationWithLiege < -10 ? Colors.Red : RelationWithLiege > 10 ? Colors.Green : TooltipHelper.DefaultTooltipColor, false, TooltipProperty.TooltipPropertyFlags.None));

                    LoyaltyManager.GetLoyaltyTooltipInfo(hero.Clan, out string LoyaltyText, out Color LoyaltyTextColor);
                    tooltipVM.TooltipPropertyList.Add(new TooltipProperty(TooltipHelper.GetTooltipLoyaltyHeader(), LoyaltyText, 0, LoyaltyTextColor, false, TooltipProperty.TooltipPropertyFlags.None));
                }
            }
            catch (Exception ex)
            {
                MethodInfo?methodInfo = MethodBase.GetCurrentMethod() as MethodInfo;
                DebugHelper.HandleException(ex, methodInfo, "Harmony patch for TooltipVMExtensions.UpdateTooltip");
            }
        }
Exemple #15
0
        public void Search()
        {
            PrefabInfo current = null;

            UIScrollPanelItem.ItemData selected = null;
            if (scrollPanel.selectedItem != null)
            {
                current = scrollPanel.selectedItem.asset.prefab;
            }

            string text = "";

            Asset.AssetType type = Asset.AssetType.All;

            if (input != null)
            {
                text = input.text;
                type = (Asset.AssetType)typeFilter.selectedIndex;

                if (!FindIt.isRicoEnabled && type >= Asset.AssetType.Rico)
                {
                    type++;
                }
            }

            List <Asset> matches = AssetTagList.instance.Find(text, type);

            scrollPanel.Clear();
            foreach (Asset asset in matches)
            {
                if (asset.prefab != null)
                {
                    // filter custom/vanilla assets
                    if (workshopFilter != null && vanillaFilter != null)
                    {
                        if ((asset.prefab.m_isCustomContent && !workshopFilter.isChecked) || (!asset.prefab.m_isCustomContent && !vanillaFilter.isChecked))
                        {
                            continue;
                        }
                    }

                    UIScrollPanelItem.ItemData data = new UIScrollPanelItem.ItemData();
                    data.name    = asset.title;
                    data.tooltip = Asset.GetLocalizedTooltip(asset.prefab, data.name);

                    data.tooltipBox = GeneratedPanel.GetTooltipBox(TooltipHelper.GetHashCode(data.tooltip));
                    data.asset      = asset;

                    scrollPanel.itemsData.Add(data);

                    if (asset.prefab == current)
                    {
                        selected = data;
                    }
                }
            }

            scrollPanel.DisplayAt(0);
            scrollPanel.selectedItem = selected;

            if (scrollPanel.selectedItem != null)
            {
                FindIt.SelectPrefab(scrollPanel.selectedItem.asset.prefab);
            }
            else
            {
                ToolsModifierControl.SetTool <DefaultTool>();
            }
        }
Exemple #16
0
        public void Search()
        {
            PrefabInfo current = null;

            UIScrollPanelItem.ItemData selected = null;
            if (scrollPanel.selectedItem != null)
            {
                current = scrollPanel.selectedItem.asset.prefab;
            }

            string          text = "";
            DropDownOptions type = DropDownOptions.All;

            if (input != null)
            {
                text = input.text;
                type = (DropDownOptions)typeFilter.selectedIndex;

                if (!FindIt.isRicoEnabled && type >= DropDownOptions.Rico)
                {
                    type += 2;
                }
            }

            // set up prop categories for props generated by Elektrix's TVP mod. Need the TVP Patch mod
            if (FindIt.isTVPPatchEnabled && !AssetTagList.instance.isTVPPatchModProcessed)
            {
                AssetTagList.instance.SetTVPProps();
            }

            // extra size check for growable
            if (type == DropDownOptions.Growable)
            {
                // if switch back from rico with size > 4, default size = all
                if (UISearchBox.instance.buildingSizeFilterIndex.x > 4)
                {
                    UISearchBox.instance.sizeFilterX.selectedIndex = 0;
                }
                if (UISearchBox.instance.buildingSizeFilterIndex.y > 4)
                {
                    UISearchBox.instance.sizeFilterY.selectedIndex = 0;
                }
            }

            matches = AssetTagList.instance.Find(text, type);

            // sort by used/unused instance count
            if (Settings.showInstancesCounter && Settings.instanceCounterSort != 0)
            {
                if (Settings.instanceCounterSort == 1)
                {
                    if (Settings.includePOinstances)
                    {
                        matches = matches.OrderByDescending(s => (s.instanceCount + s.poInstanceCount)).ToList();
                    }
                    else
                    {
                        matches = matches.OrderByDescending(s => s.instanceCount).ToList();
                    }
                }
                else
                {
                    if (Settings.includePOinstances)
                    {
                        matches = matches.OrderBy(s => (s.instanceCount + s.poInstanceCount)).ToList();
                    }
                    else
                    {
                        matches = matches.OrderBy(s => s.instanceCount).ToList();
                    }
                }
            }

            // sort by most recently downloaded
            else if (!Settings.useRelevanceSort)
            {
                matches = matches.OrderByDescending(s => s.downloadTime).ToList();
            }
            // sort by relevance, same as original Find It
            else
            {
                // sort network by ui priority instead
                if (UISearchBox.instance?.typeFilter.selectedIndex == 1)
                {
                    matches = matches.OrderBy(s => s.uiPriority).ToList();
                }
                else
                {
                    text = text.ToLower().Trim();
                    // if search input box is not empty, sort by score
                    if (!text.IsNullOrWhiteSpace())
                    {
                        float maxScore = 0;
                        foreach (Asset assetItr in matches)
                        {
                            if (assetItr.score > 0)
                            {
                                maxScore = assetItr.score;
                                break;
                            }
                        }
                        if (maxScore > 0)
                        {
                            matches = matches.OrderByDescending(s => s.score).ToList();
                        }
                        else
                        {
                            matches = matches.OrderBy(s => s.title).ToList();
                        }
                    }
                    // if seach input box is empty, sort by asset title
                    else
                    {
                        matches = matches.OrderBy(s => s.title).ToList();
                    }
                }
            }

            scrollPanel.Clear();
            searchResultList.Clear();
            foreach (Asset asset in matches)
            {
                if (asset.prefab != null)
                {
                    UIScrollPanelItem.ItemData data = new UIScrollPanelItem.ItemData();
                    data.name       = asset.title;// + "_" + asset.steamID;
                    data.tooltip    = Asset.GetLocalizedTooltip(asset, asset.prefab, data.name);
                    data.tooltipBox = GeneratedPanel.GetTooltipBox(TooltipHelper.GetHashCode(data.tooltip));
                    data.asset      = asset;

                    scrollPanel.itemsData.Add(data);
                    searchResultList.Add(data.name);
                    if (asset.prefab == current)
                    {
                        selected = data;
                    }
                }
            }

            scrollPanel.DisplayAt(0);
            scrollPanel.selectedItem = selected;

            if (scrollPanel.selectedItem != null)
            {
                FindIt.SelectPrefab(scrollPanel.selectedItem.asset.prefab);
            }
            else
            {
                ToolsModifierControl.SetTool <DefaultTool>();
            }
        }
Exemple #17
0
        void DrawBuildingButton(BuildingInfo BuildingPrefab, string type)
        {
            try
            {
                BuildingButton = new UIButton(); //draw button on appropriate panel.
                if (type == "reslow")
                {
                    BuildingButton = BuildingPanels[0].AddUIComponent <UIButton>();
                }
                if (type == "reshigh")
                {
                    BuildingButton = BuildingPanels[1].AddUIComponent <UIButton>();
                }
                if (type == "comlow")
                {
                    BuildingButton = BuildingPanels[2].AddUIComponent <UIButton>();
                }
                if (type == "comhigh")
                {
                    BuildingButton = BuildingPanels[3].AddUIComponent <UIButton>();
                }
                if (type == "office")
                {
                    BuildingButton = BuildingPanels[4].AddUIComponent <UIButton>();
                }
                if (type == "industrial")
                {
                    BuildingButton = BuildingPanels[5].AddUIComponent <UIButton>();
                }
                if (type == "farming")
                {
                    BuildingButton = BuildingPanels[6].AddUIComponent <UIButton>();
                }
                if (type == "oil")
                {
                    BuildingButton = BuildingPanels[8].AddUIComponent <UIButton>();
                }
                if (type == "forest")
                {
                    BuildingButton = BuildingPanels[7].AddUIComponent <UIButton>();
                }
                if (type == "ore")
                {
                    BuildingButton = BuildingPanels[9].AddUIComponent <UIButton>();
                }
                if (type == "leisure")
                {
                    if (Util.isADinstalled())
                    {
                        BuildingButton = BuildingPanels[10].AddUIComponent <UIButton>();
                    }
                    else
                    {
                        BuildingButton = BuildingPanels[3].AddUIComponent <UIButton>();
                    }
                }
                if (type == "tourist")
                {
                    if (Util.isADinstalled())
                    {
                        BuildingButton = BuildingPanels[11].AddUIComponent <UIButton>();
                    }
                    else
                    {
                        BuildingButton = BuildingPanels[3].AddUIComponent <UIButton>();
                    }
                }

                BuildingButton.size  = new Vector2(109, 100); //apply settings to building buttons.
                BuildingButton.atlas = BuildingPrefab.m_Atlas;



                if (BuildingPrefab.m_Thumbnail == null || BuildingPrefab.m_Thumbnail == "")
                {
                    BuildingButton.normalFgSprite = "ToolbarIconProps";
                }
                else
                {
                    BuildingButton.normalFgSprite   = BuildingPrefab.m_Thumbnail;
                    BuildingButton.focusedFgSprite  = BuildingPrefab.m_Thumbnail + "Focused";
                    BuildingButton.hoveredFgSprite  = BuildingPrefab.m_Thumbnail + "Hovered";
                    BuildingButton.pressedFgSprite  = BuildingPrefab.m_Thumbnail + "Pressed";
                    BuildingButton.disabledFgSprite = BuildingPrefab.m_Thumbnail + "Disabled";
                }

                BuildingButton.objectUserData      = BuildingPrefab;
                BuildingButton.horizontalAlignment = UIHorizontalAlignment.Center;
                BuildingButton.verticalAlignment   = UIVerticalAlignment.Middle;
                BuildingButton.pivot = UIPivotPoint.TopCenter;

                string      localizedTooltip = BuildingPrefab.GetLocalizedTooltip();
                int         hashCode         = TooltipHelper.GetHashCode(localizedTooltip);
                UIComponent tooltipBox       = GeneratedPanel.GetTooltipBox(hashCode);

                BuildingButton.tooltipAnchor    = UITooltipAnchor.Anchored;
                BuildingButton.isEnabled        = enabled;
                BuildingButton.tooltip          = localizedTooltip;
                BuildingButton.tooltipBox       = tooltipBox;
                BuildingButton.eventClick      += (sender, e) => BuildingBClicked(sender, e, BuildingPrefab);
                BuildingButton.eventMouseHover += (sender, e) => BuildingBHovered(sender, e, BuildingPrefab);
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
        }
Exemple #18
0
 public SupportViewComponent()
 {
     this.buildingTooltip = null;
     this.State           = SupportViewComponentState.Dormant;
     this.tooltipHelper   = new TooltipHelper();
 }
Exemple #19
0
        void EndTouchRowResizing()
        {
            IsWorking           = false;
            IsTouchResizingRows = false;
            HitTestInformation savedHitTestInformation = GetHitInfo();

            if ((savedHitTestInformation.HitPoint.Y == MousePosition.Y) || !_DoTouchResizing)
            {
                TooltipHelper.CloseTooltip();
                _resizingTracker.Visibility = Visibility.Collapsed;
            }
            else
            {
                RowLayout viewportResizingRowLayoutFromYForTouch = null;
                switch (savedHitTestInformation.HitTestType)
                {
                case HitTestType.Corner:
                    viewportResizingRowLayoutFromYForTouch = GetColumnHeaderRowLayoutModel().FindRow(savedHitTestInformation.HeaderInfo.ResizingRow);
                    if (viewportResizingRowLayoutFromYForTouch != null)
                    {
                        double              num6    = (_resizingTracker.Y1 - viewportResizingRowLayoutFromYForTouch.Y) - viewportResizingRowLayoutFromYForTouch.Height;
                        int                 row     = viewportResizingRowLayoutFromYForTouch.Row;
                        double              size    = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.ColumnHeader.Rows[row].ActualHeight + (num6 / ((double)ZoomFactor)))));
                        RowResizeExtent[]   rows    = new RowResizeExtent[] { new RowResizeExtent(row, row) };
                        RowResizeUndoAction command = new RowResizeUndoAction(ActiveSheet, rows, size, true);
                        DoCommand(command);
                    }
                    break;

                case HitTestType.RowHeader:
                {
                    viewportResizingRowLayoutFromYForTouch = GetViewportResizingRowLayoutFromYForTouch(savedHitTestInformation.RowViewportIndex, savedHitTestInformation.HitPoint.Y);
                    bool flag = false;
                    if ((viewportResizingRowLayoutFromYForTouch == null) && (savedHitTestInformation.RowViewportIndex == 0))
                    {
                        viewportResizingRowLayoutFromYForTouch = GetViewportResizingRowLayoutFromYForTouch(-1, savedHitTestInformation.HitPoint.Y);
                    }
                    if (((viewportResizingRowLayoutFromYForTouch == null) && (savedHitTestInformation.HeaderInfo != null)) && (savedHitTestInformation.HeaderInfo.ResizingRow >= 0))
                    {
                        viewportResizingRowLayoutFromYForTouch = GetViewportRowLayoutModel(savedHitTestInformation.RowViewportIndex).FindRow(savedHitTestInformation.HeaderInfo.ResizingRow);
                    }
                    if ((viewportResizingRowLayoutFromYForTouch == null) && ((savedHitTestInformation.RowViewportIndex == -1) || (savedHitTestInformation.RowViewportIndex == 0)))
                    {
                        viewportResizingRowLayoutFromYForTouch = GetColumnHeaderResizingRowLayoutFromYForTouch(savedHitTestInformation.HitPoint.Y);
                        flag = true;
                    }
                    if (viewportResizingRowLayoutFromYForTouch != null)
                    {
                        double num      = (_resizingTracker.Y1 - viewportResizingRowLayoutFromYForTouch.Y) - viewportResizingRowLayoutFromYForTouch.Height;
                        int    firstRow = viewportResizingRowLayoutFromYForTouch.Row;
                        double num3     = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.Rows[firstRow].ActualHeight + (num / ((double)ZoomFactor)))));
                        if (flag)
                        {
                            RowResizeExtent[]   extentArray2 = new RowResizeExtent[] { new RowResizeExtent(firstRow, firstRow) };
                            RowResizeUndoAction action2      = new RowResizeUndoAction(ActiveSheet, extentArray2, num3, true);
                            DoCommand(action2);
                            break;
                        }
                        List <RowResizeExtent> list = new List <RowResizeExtent>();
                        if (ActiveSheet.IsSelected(firstRow, -1))
                        {
                            foreach (CellRange range in ActiveSheet.Selections)
                            {
                                if (range.Column == -1)
                                {
                                    int num4 = (range.Row == -1) ? 0 : range.Row;
                                    int num5 = ((range.Row == -1) && (range.RowCount == -1)) ? ActiveSheet.RowCount : range.RowCount;
                                    list.Add(new RowResizeExtent(num4, (num4 + num5) - 1));
                                }
                            }
                        }
                        else
                        {
                            list.Add(new RowResizeExtent(firstRow, firstRow));
                        }
                        RowResizeExtent[] extentArray = new RowResizeExtent[list.Count];
                        list.CopyTo(extentArray);
                        RowResizeUndoAction action = new RowResizeUndoAction(ActiveSheet, extentArray, num3, false);
                        DoCommand(action);
                    }
                    break;
                }
                }
                TooltipHelper.CloseTooltip();
                _resizingTracker.Visibility = Visibility.Collapsed;
                _DoTouchResizing            = false;
            }
        }
Exemple #20
0
        void EndTouchColumnResizing()
        {
            IsWorking = false;
            IsTouchResizingColumns = false;
            HitTestInformation savedHitTestInformation = GetHitInfo();

            if ((savedHitTestInformation.HitPoint.X == MousePosition.X) || !_DoTouchResizing)
            {
                TooltipHelper.CloseTooltip();
                _resizingTracker.Visibility = Visibility.Collapsed;
            }
            else
            {
                ColumnLayout viewportResizingColumnLayoutFromXForTouch;
                switch (savedHitTestInformation.HitTestType)
                {
                case HitTestType.Corner:
                    viewportResizingColumnLayoutFromXForTouch = GetRowHeaderColumnLayoutModel().FindColumn(savedHitTestInformation.HeaderInfo.ResizingColumn);
                    if (viewportResizingColumnLayoutFromXForTouch != null)
                    {
                        double num6   = (_resizingTracker.X1 - viewportResizingColumnLayoutFromXForTouch.X) - viewportResizingColumnLayoutFromXForTouch.Width;
                        int    column = viewportResizingColumnLayoutFromXForTouch.Column;
                        double size   = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.RowHeader.Columns[column].ActualWidth + (num6 / ((double)ZoomFactor)))));
                        ColumnResizeExtent[]   columns = new ColumnResizeExtent[] { new ColumnResizeExtent(column, column) };
                        ColumnResizeUndoAction command = new ColumnResizeUndoAction(ActiveSheet, columns, size, true);
                        DoCommand(command);
                    }
                    break;

                case HitTestType.ColumnHeader:
                {
                    viewportResizingColumnLayoutFromXForTouch = GetViewportResizingColumnLayoutFromXForTouch(savedHitTestInformation.ColumnViewportIndex, savedHitTestInformation.HitPoint.X);
                    bool flag = false;
                    if (viewportResizingColumnLayoutFromXForTouch == null)
                    {
                        viewportResizingColumnLayoutFromXForTouch = GetViewportColumnLayoutModel(savedHitTestInformation.ColumnViewportIndex).FindColumn(savedHitTestInformation.HeaderInfo.ResizingColumn);
                        if ((viewportResizingColumnLayoutFromXForTouch == null) && (savedHitTestInformation.ColumnViewportIndex == 0))
                        {
                            viewportResizingColumnLayoutFromXForTouch = GetViewportResizingColumnLayoutFromXForTouch(-1, savedHitTestInformation.HitPoint.X);
                        }
                        if ((viewportResizingColumnLayoutFromXForTouch == null) && ((savedHitTestInformation.ColumnViewportIndex == 0) || (savedHitTestInformation.ColumnViewportIndex == -1)))
                        {
                            viewportResizingColumnLayoutFromXForTouch = GetRowHeaderResizingColumnLayoutFromXForTouch(savedHitTestInformation.HitPoint.X);
                            flag = true;
                        }
                    }
                    if (viewportResizingColumnLayoutFromXForTouch != null)
                    {
                        double num  = (_resizingTracker.X1 - viewportResizingColumnLayoutFromXForTouch.X) - viewportResizingColumnLayoutFromXForTouch.Width;
                        int    num2 = viewportResizingColumnLayoutFromXForTouch.Column;
                        double num3 = Math.Ceiling(Math.Max((double)0.0, (double)(ActiveSheet.Columns[num2].ActualWidth + (num / ((double)ZoomFactor)))));
                        if (!flag)
                        {
                            List <ColumnResizeExtent> list = new List <ColumnResizeExtent>();
                            if (ActiveSheet.IsSelected(-1, num2))
                            {
                                foreach (CellRange range in ActiveSheet.Selections)
                                {
                                    if (range.Row == -1)
                                    {
                                        int firstColumn = (range.Column == -1) ? 0 : range.Column;
                                        int num5        = ((range.Column == -1) && (range.ColumnCount == -1)) ? ActiveSheet.ColumnCount : range.ColumnCount;
                                        list.Add(new ColumnResizeExtent(firstColumn, (firstColumn + num5) - 1));
                                    }
                                }
                            }
                            else
                            {
                                list.Add(new ColumnResizeExtent(num2, num2));
                            }
                            ColumnResizeExtent[] extentArray = new ColumnResizeExtent[list.Count];
                            list.CopyTo(extentArray);
                            ColumnResizeUndoAction action = new ColumnResizeUndoAction(ActiveSheet, extentArray, num3, false);
                            DoCommand(action);
                        }
                        else
                        {
                            ColumnResizeExtent[]   extentArray2 = new ColumnResizeExtent[] { new ColumnResizeExtent(num2, num2) };
                            ColumnResizeUndoAction action2      = new ColumnResizeUndoAction(ActiveSheet, extentArray2, num3, true);
                            DoCommand(action2);
                        }
                    }
                    break;
                }
                }
                TooltipHelper.CloseTooltip();
                _resizingTracker.Visibility = Visibility.Collapsed;
                _DoTouchResizing            = false;
            }
        }
        protected override void OnGUIConnected()
        {
            if (this.Hierarchy.inspectableTypes == null)
            {
                if (this.Hierarchy.IsChannelBlocked(this.GetHashCode()) == true)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F));
                        GUILayout.Label("Loading types...");

                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.Label("Types not loaded.", GeneralStyles.BigCenterText);
                    Rect r2 = GUILayoutUtility.GetLastRect();
                    EditorGUIUtility.AddCursorRect(r2, MouseCursor.Link);

                    if (Event.current.type == EventType.MouseDown && r2.Contains(Event.current.mousePosition) == true)
                    {
                        XGUIHighlightManager.Highlight(NGRemoteStaticInspectorWindow.Title + ".Load");
                    }
                }

                return;
            }

            if (this.style == null)
            {
                this.style           = new GUIStyle(EditorStyles.label);
                this.style.alignment = TextAnchor.MiddleLeft;
                this.style.fontSize  = 15;
            }

            this.bodyRect    = GUILayoutUtility.GetLastRect();
            this.bodyRect.y += this.bodyRect.height;

            if (this.tabTypes.Count > 0 && this.Hierarchy.inspectableTypes != null)
            {
                float totalWidth = -NGRemoteStaticInspectorWindow.Spacing;

                for (int i = 0; i < this.tabTypes.Count; i++)
                {
                    Utility.content.text = this.Hierarchy.inspectableTypes[this.tabTypes[i]].name;
                    totalWidth          += GeneralStyles.ToolbarButton.CalcSize(Utility.content).x + NGRemoteStaticInspectorWindow.Spacing;
                }

                this.scrollPositionTabs.allowedMouseArea = new Rect(0F, this.bodyRect.y, this.position.width, 22F);
                this.scrollPositionTabs.SetPosition(0F, this.bodyRect.y);
                this.scrollPositionTabs.SetSize(this.position.width);
                this.scrollPositionTabs.RealWidth = totalWidth;
                this.scrollPositionTabs.OnGUI();

                this.bodyRect.y += this.scrollPositionTabs.MaxHeight;

                Rect r3 = bodyRect;
                r3.height = 18F;
                r3.y     += 2F;
                r3.x      = -this.scrollPositionTabs.Offset;

                for (int i = 0; i < this.tabTypes.Count; i++)
                {
                    ClientType type = this.Hierarchy.inspectableTypes[this.tabTypes[i]];

                    Utility.content.text = type.name;
                    if (type.@namespace != null)
                    {
                        Utility.content.tooltip = type.@namespace + '.' + type.name;
                    }
                    else
                    {
                        Utility.content.tooltip = null;
                    }
                    r3.width = GeneralStyles.ToolbarButton.CalcSize(Utility.content).x;

                    if (GUI.Button(r3, type.name, GeneralStyles.ToolbarButton) == true)
                    {
                        if (Event.current.button == 2)
                        {
                            this.tabTypes.RemoveAt(i);
                        }

                        this.Hierarchy.WatchTypes(this, type.typeIndex);
                        this.selectedType = type;
                        this.selectedType.LoadInspectableTypeStaticMembers(this.Hierarchy.Client, this.Hierarchy);

                        Utility.content.tooltip = null;

                        return;
                    }

                    if (this.selectedType == this.Hierarchy.inspectableTypes[this.tabTypes[i]])
                    {
                        Utility.DrawUnfillRect(r3, NGRemoteStaticInspectorWindow.SelectedTabOutline);
                    }

                    if (Utility.content.tooltip != null)
                    {
                        TooltipHelper.Label(r3, Utility.content.tooltip);
                    }

                    r3.x += r3.width + NGRemoteStaticInspectorWindow.Spacing;
                }

                Utility.content.tooltip = null;

                this.bodyRect.y += 20F + 2F;
            }

            float maxY = this.bodyRect.yMax;
            Rect  r    = new Rect();

            if (this.showTypes == true && this.Hierarchy.inspectableTypes != null)
            {
                if (Event.current.type == EventType.MouseMove)
                {
                    this.Repaint();
                }

                this.bodyRect.height = this.position.height - this.bodyRect.y;
                this.viewRect        = new Rect(0F, 0F, 0F, this.CountTypes() * (NGRemoteStaticInspectorWindow.Spacing + NGRemoteStaticInspectorWindow.TypeHeight) - NGRemoteStaticInspectorWindow.Spacing);

                this.bodyRect.height -= this.contentHeight;

                if (this.viewRect.height < 100F)
                {
                    if (this.bodyRect.height > this.viewRect.height)
                    {
                        this.bodyRect.height = this.viewRect.height;
                    }
                }

                maxY = this.bodyRect.yMax;

                this.scrollPositionTypes = GUI.BeginScrollView(this.bodyRect, this.scrollPositionTypes, this.viewRect);
                {
                    r.width  = this.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F);
                    r.height = NGRemoteStaticInspectorWindow.TypeHeight;

                    int i = 0;

                    if (this.viewRect.height > this.bodyRect.height)
                    {
                        i   = (int)(this.scrollPositionTypes.y / (NGRemoteStaticInspectorWindow.Spacing + r.height));
                        r.y = i * (NGRemoteStaticInspectorWindow.Spacing + r.height);
                    }

                    r.xMin += 5F;

                    foreach (ClientType type in this.EachType(i--))
                    {
                        r.height = NGRemoteStaticInspectorWindow.TypeHeight;
                        ++i;

                        if (r.y + r.height + NGRemoteStaticInspectorWindow.Spacing <= this.scrollPositionTypes.y)
                        {
                            r.y += r.height + NGRemoteStaticInspectorWindow.Spacing;
                            continue;
                        }

                        GUI.Box(r, "");

                        if (Event.current.type == EventType.Repaint)
                        {
                            if (this.selectedType == type)
                            {
                                Utility.DrawUnfillRect(r, NGRemoteStaticInspectorWindow.SelectedTypeOutline);
                            }

                            if (r.Contains(Event.current.mousePosition) == true)
                            {
                                r.x      -= 2F;
                                r.y      -= 2F;
                                r.width  += 4F;
                                r.height += 4F;
                                Utility.DrawUnfillRect(r, NGRemoteStaticInspectorWindow.HoveredTypeOutline);
                                r.x      += 2F;
                                r.y      += 2F;
                                r.width  -= 4F;
                                r.height -= 4F;
                            }
                        }
                        else if (Event.current.type == EventType.MouseDown &&
                                 r.Contains(Event.current.mousePosition) == true)
                        {
                            this.Hierarchy.WatchTypes(this, type.typeIndex);
                            this.selectedType = type;
                            this.selectedType.LoadInspectableTypeStaticMembers(this.Hierarchy.Client, this.Hierarchy);

                            if (this.tabTypes.Contains(type.typeIndex) == false)
                            {
                                this.tabTypes.Insert(0, type.typeIndex);
                            }
                        }

                        r.height = 22F;
                        GUI.Label(r, type.name, this.style);
                        r.y += 18F;

                        r.height = 15F;
                        GUI.Label(r, type.@namespace, GeneralStyles.SmallLabel);
                        r.y += 14F + NGRemoteStaticInspectorWindow.Spacing;

                        if (r.y - this.scrollPositionTypes.y > this.bodyRect.height)
                        {
                            break;
                        }
                    }
                }
                GUI.EndScrollView();

                this.bodyRect.y = maxY;
            }

            bool doubleClickResize = false;

            if (this.showTypes == true)
            {
                float minHeight = GUI.skin.label.CalcHeight(Utility.content, this.bodyRect.width);

                // Handle splitter bar.
                this.bodyRect.height = NGRemoteStaticInspectorWindow.ContentSplitterHeight;
                GUI.Box(this.bodyRect, "");
                EditorGUIUtility.AddCursorRect(this.bodyRect, MouseCursor.ResizeVertical);

                if (this.draggingSplitterBar == true &&
                    Event.current.type == EventType.MouseDrag)
                {
                    this.contentHeight = Mathf.Clamp(this.originContentHeight + this.originPositionY - Event.current.mousePosition.y,
                                                     NGRemoteStaticInspectorWindow.MinContentHeight, this.position.height - NGRemoteStaticInspectorWindow.MaxContentHeightLeft);
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseDown &&
                         this.bodyRect.Contains(Event.current.mousePosition) == true)
                {
                    this.originPositionY     = Event.current.mousePosition.y;
                    this.originContentHeight = this.contentHeight;
                    this.draggingSplitterBar = true;
                    Event.current.Use();
                }
                else if (this.draggingSplitterBar == true &&
                         Event.current.type == EventType.MouseUp)
                {
                    // Auto adjust height on left click or double click.
                    if (this.bodyRect.Contains(Event.current.mousePosition) == true &&
                        (Event.current.button == 1 ||
                         (this.lastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup &&
                          Mathf.Abs(this.originPositionY - Event.current.mousePosition.y) < 5F)))
                    {
                        // 7F of margin, dont know why it is required. CalcHeight seems to give bad result.
                        this.contentHeight = Mathf.Clamp(minHeight + 7F,
                                                         NGRemoteStaticInspectorWindow.MinContentHeight, this.position.height - NGRemoteStaticInspectorWindow.MaxContentHeightLeft);
                        doubleClickResize = true;
                    }

                    this.lastClickTime       = EditorApplication.timeSinceStartup;
                    this.draggingSplitterBar = false;
                    Event.current.Use();
                }

                this.bodyRect.height = this.position.height - this.bodyRect.y;

                if (this.bodyRect.height > this.position.height - NGRemoteStaticInspectorWindow.MaxContentHeightLeft)
                {
                    this.contentHeight = this.position.height - NGRemoteStaticInspectorWindow.MaxContentHeightLeft;
                }

                // Smoothly stay at the minimum if not critical under the critical threshold.
                if (this.contentHeight < NGRemoteStaticInspectorWindow.MinContentHeight)
                {
                    this.contentHeight = NGRemoteStaticInspectorWindow.MinContentHeight;
                }

                this.bodyRect.y += NGRemoteStaticInspectorWindow.TitleSpacing;
            }

            if (this.selectedType != null)
            {
                Utility.content.text = this.selectedType.name;
                this.bodyRect.height = GeneralStyles.Title1.CalcHeight(Utility.content, this.position.width);

                bool isPinned = false;
                Rect starRect = this.bodyRect;

                starRect.x      = 5F;
                starRect.y     += 3F;
                starRect.width  = 12F;
                starRect.height = 14F;

                EditorGUIUtility.AddCursorRect(starRect, MouseCursor.Link);

                for (int i = 0; i < this.tabTypes.Count; i++)
                {
                    if (this.Hierarchy.inspectableTypes[this.tabTypes[i]] == this.selectedType)
                    {
                        isPinned = true;
                        break;
                    }
                }

                if (Event.current.type == EventType.MouseDown &&
                    starRect.Contains(Event.current.mousePosition) == true)
                {
                    if (isPinned == true)
                    {
                        for (int i = 0; i < this.tabTypes.Count; i++)
                        {
                            if (this.Hierarchy.inspectableTypes[this.tabTypes[i]] == this.selectedType)
                            {
                                this.tabTypes.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < this.Hierarchy.inspectableTypes.Length; i++)
                        {
                            if (this.Hierarchy.inspectableTypes[i] == this.selectedType)
                            {
                                this.tabTypes.Insert(0, i);
                                break;
                            }
                        }
                    }

                    Event.current.Use();
                    return;
                }

                if (isPinned == true)
                {
                    Color c = GUI.color;
                    GUI.color = Color.yellow;
                    GUI.DrawTexture(starRect, this.starIcon);
                    GUI.color = c;
                }
                else
                {
                    GUI.DrawTexture(starRect, this.starIcon);
                }

                this.bodyRect.xMin += 20F;
                if (string.IsNullOrEmpty(this.selectedType.@namespace) == false)
                {
                    GUI.Label(this.bodyRect, this.selectedType.name + " (" + this.selectedType.@namespace + ")", GeneralStyles.Title1);
                }
                else
                {
                    GUI.Label(this.bodyRect, this.selectedType.name, GeneralStyles.Title1);
                }
                this.bodyRect.xMin -= 20F;

                this.bodyRect.y += this.bodyRect.height + NGRemoteStaticInspectorWindow.TitleSpacing;

                ClientStaticMember[] members = this.selectedType.members;

                if (members != null)
                {
                    viewRect.height = 0F;

                    try
                    {
                        for (int i = 0; i < members.Length; i++)
                        {
                            viewRect.height += ClientComponent.MemberSpacing + members[i].GetHeight(this);
                        }

                        // Remove last spacing.
                        if (viewRect.height > ClientComponent.MemberSpacing)
                        {
                            viewRect.height -= ClientComponent.MemberSpacing;
                        }

                        if (doubleClickResize == true)
                        {
                            this.contentHeight = Mathf.Clamp(viewRect.height + this.bodyRect.height + NGRemoteStaticInspectorWindow.TitleSpacing + NGRemoteStaticInspectorWindow.TitleSpacing,
                                                             NGRemoteStaticInspectorWindow.MinContentHeight, this.position.height - NGRemoteStaticInspectorWindow.MaxContentHeightLeft);
                        }

                        this.bodyRect.height = this.position.height - this.bodyRect.y;

                        this.scrollPositionMembers = GUI.BeginScrollView(this.bodyRect, this.scrollPositionMembers, viewRect);
                        {
                            r.x     = 0F;
                            r.y     = 0F;
                            r.width = this.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F);

                            ++EditorGUI.indentLevel;
                            for (int i = 0; i < members.Length; i++)
                            {
                                float height = members[i].GetHeight(this);

                                if (r.y + height + ClientComponent.MemberSpacing <= this.scrollPositionMembers.y)
                                {
                                    r.y += height + ClientComponent.MemberSpacing;
                                    continue;
                                }

                                r.height = height;

                                if (Event.current.type == EventType.MouseDown &&
                                    r.Contains(Event.current.mousePosition) == true &&
                                    Event.current.button == 1)
                                {
                                    this.forceMemberEditable          = members[i];
                                    this.Hierarchy.PacketInterceptor += this.CatchFieldUpdatePacket;

                                    Utility.RegisterIntervalCallback(() =>
                                    {
                                        this.forceMemberEditable          = null;
                                        this.Hierarchy.PacketInterceptor -= this.CatchFieldUpdatePacket;
                                    }, NGRemoteStaticInspectorWindow.ForceMemberEditableTickDuration, 1);
                                }

                                EditorGUI.BeginDisabledGroup(!members[i].isEditable && (this.forceMemberEditable != members[i]));
                                members[i].Draw(r, this);
                                EditorGUI.EndDisabledGroup();

                                r.y += height + ClientComponent.MemberSpacing;
                                if (r.y - this.scrollPositionMembers.y > this.bodyRect.height)
                                {
                                    break;
                                }
                            }
                            --EditorGUI.indentLevel;
                        }
                        GUI.EndScrollView();
                    }
                    catch (Exception ex)
                    {
                        this.errorPopup.exception = ex;
                    }
                }
                else
                {
                    this.bodyRect.height = 32F;
                    EditorGUI.HelpBox(this.bodyRect, "Data not available yet.", MessageType.Info);

                    this.Repaint();
                }
            }

            TooltipHelper.PostOnGUI();
        }
        protected virtual void  OnGUI()
        {
            EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar);
            {
                this.showTypes = GUILayout.Toggle(this.showTypes, "", GeneralStyles.ToolbarDropDown, GUILayoutOptionPool.Width(20F));

                EditorGUI.BeginChangeCheck();
                this.searchKeywords = EditorGUILayout.TextField(this.searchKeywords, GeneralStyles.ToolbarSearchTextField, GUILayoutOptionPool.ExpandWidthTrue);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.showTypes      = true;
                    this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' ');
                    this.RefreshFilter();
                }

                if (GUILayout.Button("", GeneralStyles.ToolbarSearchCancelButton) == true)
                {
                    this.searchKeywords = string.Empty;
                    this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' ');
                    GUI.FocusControl(null);
                    this.RefreshFilter();
                }
            }
            EditorGUILayout.EndHorizontal();

            if (this.errorPopup.exception != null)
            {
                this.errorPopup.OnGUILayout();
            }

            if (this.typeNameStyle == null)
            {
                this.typeNameStyle           = new GUIStyle(EditorStyles.label);
                this.typeNameStyle.alignment = TextAnchor.MiddleLeft;
                this.typeNameStyle.fontSize  = 15;
            }

            this.bodyRect    = GUILayoutUtility.GetLastRect();
            this.bodyRect.y += this.bodyRect.height;

            if (this.tabTypes.Count > 0 && NGStaticInspectorWindow.staticTypes != null)
            {
                float totalWidth = -NGStaticInspectorWindow.Spacing;

                for (int i = 0; i < this.tabTypes.Count; i++)
                {
                    Utility.content.text = NGStaticInspectorWindow.staticTypes[this.tabTypes[i]].Name;
                    totalWidth          += GeneralStyles.ToolbarButton.CalcSize(Utility.content).x + NGStaticInspectorWindow.Spacing;
                }

                this.scrollPositionTabs.allowedMouseArea = new Rect(0F, this.bodyRect.y, this.position.width, 22F);
                this.scrollPositionTabs.SetPosition(0F, this.bodyRect.y);
                this.scrollPositionTabs.SetSize(this.position.width);
                this.scrollPositionTabs.RealWidth = totalWidth;
                this.scrollPositionTabs.OnGUI();

                this.bodyRect.y += this.scrollPositionTabs.MaxHeight;

                Rect r3 = bodyRect;
                r3.height = 18F;
                r3.y     += 2F;
                r3.x      = -this.scrollPositionTabs.Offset;

                for (int i = 0; i < this.tabTypes.Count; i++)
                {
                    Type   type       = NGStaticInspectorWindow.staticTypes[this.tabTypes[i]];
                    string name       = type.Name;
                    string @namespace = type.Namespace;

                    Utility.content.text = name;
                    if (@namespace != null)
                    {
                        Utility.content.tooltip = @namespace + '.' + name;
                    }
                    else
                    {
                        Utility.content.tooltip = null;
                    }
                    r3.width = GeneralStyles.ToolbarButton.CalcSize(Utility.content).x;

                    if (GUI.Button(r3, name, GeneralStyles.ToolbarButton) == true)
                    {
                        if (Event.current.button == 2)
                        {
                            this.tabTypes.RemoveAt(i);
                        }

                        this.selectedType = type;

                        Utility.content.tooltip = null;

                        return;
                    }

                    if (this.selectedType == NGStaticInspectorWindow.staticTypes[this.tabTypes[i]])
                    {
                        Utility.DrawUnfillRect(r3, NGStaticInspectorWindow.SelectedTabOutline);
                    }

                    if (Utility.content.tooltip != null)
                    {
                        TooltipHelper.Label(r3, Utility.content.tooltip);
                    }

                    r3.x += r3.width + NGStaticInspectorWindow.Spacing;
                }

                Utility.content.tooltip = null;

                this.bodyRect.y += 20F + 2F;
            }

            float maxY = this.bodyRect.yMax;
            Rect  r    = new Rect();

            if (this.showTypes == true && NGStaticInspectorWindow.staticTypes != null)
            {
                if (Event.current.type == EventType.MouseMove)
                {
                    this.Repaint();
                }

                this.bodyRect.height = this.position.height - this.bodyRect.y;
                this.viewRect        = new Rect(0F, 0F, 0F, this.CountTypes() * (NGStaticInspectorWindow.Spacing + NGStaticInspectorWindow.TypeHeight) - NGStaticInspectorWindow.Spacing);

                this.bodyRect.height -= this.contentHeight;

                if (this.viewRect.height < 100F)
                {
                    if (this.bodyRect.height > this.viewRect.height)
                    {
                        this.bodyRect.height = this.viewRect.height;
                    }
                }

                maxY = this.bodyRect.yMax;

                this.scrollPositionTypes = GUI.BeginScrollView(this.bodyRect, this.scrollPositionTypes, this.viewRect);
                {
                    r.width  = this.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F);
                    r.height = NGStaticInspectorWindow.TypeHeight;

                    int i = 0;

                    if (this.viewRect.height > this.bodyRect.height)
                    {
                        i   = (int)(this.scrollPositionTypes.y / (NGStaticInspectorWindow.Spacing + r.height));
                        r.y = i * (NGStaticInspectorWindow.Spacing + r.height);
                    }

                    r.xMin += 5F;

                    foreach (Type type in this.EachType(i--))
                    {
                        r.height = NGStaticInspectorWindow.TypeHeight;
                        ++i;

                        if (r.y + r.height + NGStaticInspectorWindow.Spacing <= this.scrollPositionTypes.y)
                        {
                            r.y += r.height + NGStaticInspectorWindow.Spacing;
                            continue;
                        }

                        GUI.Box(r, "");

                        if (Event.current.type == EventType.Repaint)
                        {
                            if (this.selectedType == type)
                            {
                                Utility.DrawUnfillRect(r, NGStaticInspectorWindow.SelectedTypeOutline);
                            }

                            if (r.Contains(Event.current.mousePosition) == true)
                            {
                                r.x      -= 2F;
                                r.y      -= 2F;
                                r.width  += 4F;
                                r.height += 4F;
                                Utility.DrawUnfillRect(r, NGStaticInspectorWindow.HoveredTypeOutline);
                                r.x      += 2F;
                                r.y      += 2F;
                                r.width  -= 4F;
                                r.height -= 4F;
                            }
                        }
                        else if (Event.current.type == EventType.MouseDown &&
                                 r.Contains(Event.current.mousePosition) == true)
                        {
                            this.Repaint();

                            if (Event.current.button != 2)
                            {
                                this.selectedType = type;
                            }

                            if (string.IsNullOrEmpty(this.searchKeywords) == false)
                            {
                                i = this.filteredTypes[i];
                            }

                            if (Event.current.button != 0 && this.tabTypes.Contains(i) == false)
                            {
                                this.tabTypes.Insert(0, i);
                            }
                            break;
                        }

                        r.height = 22F;
                        GUI.Label(r, type.Name, this.typeNameStyle);
                        r.y += 18F;

                        r.height = 15F;
                        GUI.Label(r, type.Namespace, GeneralStyles.SmallLabel);
                        r.y += 14F + NGStaticInspectorWindow.Spacing;

                        if (r.y - this.scrollPositionTypes.y > this.bodyRect.height)
                        {
                            break;
                        }
                    }

                    r.xMin -= 5F;
                }
                GUI.EndScrollView();

                this.bodyRect.y = maxY;
            }

            bool doubleClickResize = false;

            if (this.showTypes == true)
            {
                float minHeight = GUI.skin.label.CalcHeight(Utility.content, this.bodyRect.width);

                // Handle splitter bar.
                this.bodyRect.height = NGStaticInspectorWindow.SplitterHeight;
                GUI.Box(this.bodyRect, "");
                EditorGUIUtility.AddCursorRect(this.bodyRect, MouseCursor.ResizeVertical);

                if (this.draggingSplitterBar == true &&
                    Event.current.type == EventType.MouseDrag)
                {
                    this.contentHeight = Mathf.Clamp(this.originContentHeight + this.originPositionY - Event.current.mousePosition.y,
                                                     NGStaticInspectorWindow.MinContentHeight, this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft);
                    Event.current.Use();
                }
                else if (Event.current.type == EventType.MouseDown &&
                         this.bodyRect.Contains(Event.current.mousePosition) == true)
                {
                    this.originPositionY     = Event.current.mousePosition.y;
                    this.originContentHeight = this.contentHeight;
                    this.draggingSplitterBar = true;
                    Event.current.Use();
                }
                else if (this.draggingSplitterBar == true &&
                         Event.current.type == EventType.MouseUp)
                {
                    // Auto adjust height on left click or double click.
                    if (this.bodyRect.Contains(Event.current.mousePosition) == true &&
                        (Event.current.button == 1 ||
                         (this.lastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup &&
                          Mathf.Abs(this.originPositionY - Event.current.mousePosition.y) < 5F)))
                    {
                        // 7F of margin, dont know why it is required. CalcHeight seems to give bad result.
                        this.contentHeight = Mathf.Clamp(minHeight + 7F,
                                                         NGStaticInspectorWindow.MinContentHeight, this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft);
                        doubleClickResize = true;
                    }

                    this.lastClickTime       = EditorApplication.timeSinceStartup;
                    this.draggingSplitterBar = false;
                    Event.current.Use();
                }

                this.bodyRect.height = this.position.height - this.bodyRect.y;

                if (this.bodyRect.height > this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft)
                {
                    this.contentHeight = this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft;
                }

                // Smoothly stay at the minimum if not critical under the critical threshold.
                if (this.contentHeight < NGStaticInspectorWindow.MinContentHeight)
                {
                    this.contentHeight = NGStaticInspectorWindow.MinContentHeight;
                }

                this.bodyRect.y += NGStaticInspectorWindow.TitleSpacing;
            }

            if (this.selectedType != null)
            {
                Utility.content.text = this.selectedType.Name;
                this.bodyRect.height = GeneralStyles.Title1.CalcHeight(Utility.content, this.position.width);

                bool isPinned = false;
                Rect starRect = this.bodyRect;

                starRect.x      = 5F;
                starRect.y     += 3F;
                starRect.width  = 12F;
                starRect.height = 14F;

                EditorGUIUtility.AddCursorRect(starRect, MouseCursor.Link);

                for (int i = 0; i < this.tabTypes.Count; i++)
                {
                    if (NGStaticInspectorWindow.staticTypes[this.tabTypes[i]] == this.selectedType)
                    {
                        isPinned = true;
                        break;
                    }
                }

                if (Event.current.type == EventType.MouseDown &&
                    starRect.Contains(Event.current.mousePosition) == true)
                {
                    if (isPinned == true)
                    {
                        for (int i = 0; i < this.tabTypes.Count; i++)
                        {
                            if (NGStaticInspectorWindow.staticTypes[this.tabTypes[i]] == this.selectedType)
                            {
                                this.tabTypes.RemoveAt(i);
                                break;
                            }
                        }
                    }
                    else
                    {
                        for (int i = 0; i < NGStaticInspectorWindow.staticTypes.Length; i++)
                        {
                            if (NGStaticInspectorWindow.staticTypes[i] == this.selectedType)
                            {
                                this.tabTypes.Insert(0, i);
                                break;
                            }
                        }
                    }

                    Event.current.Use();
                    return;
                }

                if (isPinned == true)
                {
                    Color c = GUI.color;
                    GUI.color = Color.yellow;
                    GUI.DrawTexture(starRect, this.starIcon);
                    GUI.color = c;
                }
                else
                {
                    GUI.DrawTexture(starRect, this.starIcon);
                }

                this.bodyRect.xMin += 20F;
                if (string.IsNullOrEmpty(this.selectedType.Namespace) == false)
                {
                    GUI.Label(this.bodyRect, this.selectedType.Name + " (" + this.selectedType.Namespace + ")", GeneralStyles.Title1);
                }
                else
                {
                    GUI.Label(this.bodyRect, this.selectedType.Name, GeneralStyles.Title1);
                }
                this.bodyRect.xMin -= 20F;

                this.bodyRect.y += this.bodyRect.height + NGStaticInspectorWindow.TitleSpacing;

                MemberDrawer[] members = this.GetMembers(this.selectedType);

                viewRect.height = 0F;

                try
                {
                    for (int i = 0; i < members.Length; i++)
                    {
                        try
                        {
                            if (members[i].exception != null)
                            {
                                viewRect.height += NGStaticInspectorWindow.Spacing + 16F;
                            }
                            else
                            {
                                viewRect.height += NGStaticInspectorWindow.Spacing + members[i].typeDrawer.GetHeight(members[i].fieldModifier.GetValue(null));
                            }
                        }
                        catch (Exception ex)
                        {
                            members[i].exception = ex;
                        }
                    }

                    // Remove last spacing.
                    if (viewRect.height > NGStaticInspectorWindow.Spacing)
                    {
                        viewRect.height -= NGStaticInspectorWindow.Spacing;
                    }

                    if (doubleClickResize == true)
                    {
                        this.contentHeight = Mathf.Clamp(viewRect.height + this.bodyRect.height + NGStaticInspectorWindow.TitleSpacing + NGStaticInspectorWindow.TitleSpacing,
                                                         NGStaticInspectorWindow.MinContentHeight, this.position.height - NGStaticInspectorWindow.MaxContentHeightLeft);
                    }

                    this.bodyRect.height = this.position.height - this.bodyRect.y;

                    this.scrollPositionMembers = GUI.BeginScrollView(this.bodyRect, this.scrollPositionMembers, viewRect);
                    {
                        r.width = this.position.width - (viewRect.height > this.bodyRect.height ? 16F : 0F) - 8F;
                        r.y     = 0F;

                        ++EditorGUI.indentLevel;
                        for (int i = 0; i < members.Length; i++)
                        {
                            if (members[i].exception != null)
                            {
                                r.height = 16F;
                                using (ColorContentRestorer.Get(Color.red))
                                    EditorGUI.LabelField(r, members[i].fieldModifier.Name, "Property raised an exception");
                                r.y += r.height + NGStaticInspectorWindow.Spacing;
                                continue;
                            }

                            object instance = members[i].fieldModifier.GetValue(null);
                            float  height   = members[i].typeDrawer.GetHeight(instance);

                            if (r.y + height + NGStaticInspectorWindow.Spacing <= this.scrollPositionMembers.y)
                            {
                                r.y += height + NGStaticInspectorWindow.Spacing;
                                continue;
                            }

                            r.height = height;

                            if (Event.current.type == EventType.MouseDown &&
                                r.Contains(Event.current.mousePosition) == true &&
                                Event.current.button == 1)
                            {
                                NGStaticInspectorWindow.forceMemberEditable = members[i];
                                this.Repaint();

                                Utility.RegisterIntervalCallback(() =>
                                {
                                    NGStaticInspectorWindow.forceMemberEditable = null;
                                }, NGStaticInspectorWindow.ForceMemberEditableTickDuration, 1);
                            }

                            EditorGUI.BeginDisabledGroup(!members[i].isEditable && NGStaticInspectorWindow.forceMemberEditable != members[i]);
                            EditorGUI.BeginChangeCheck();
                            object value = members[i].typeDrawer.OnGUI(r, instance);
                            if (EditorGUI.EndChangeCheck() == true)
                            {
                                if (members[i].isEditable == true)
                                {
                                    members[i].fieldModifier.SetValue(null, value);
                                }
                            }
                            EditorGUI.EndDisabledGroup();

                            r.y += height + NGStaticInspectorWindow.Spacing;
                            if (r.y - this.scrollPositionMembers.y > this.bodyRect.height)
                            {
                                break;
                            }
                        }
                        --EditorGUI.indentLevel;
                    }
                    GUI.EndScrollView();
                }
                catch (Exception ex)
                {
                    this.errorPopup.exception = ex;
                }
            }

            TooltipHelper.PostOnGUI();
        }