예제 #1
0
        private static void SaveLayout(IEModOptions.LayoutOptions layout)
        {
            layout.TooltipOffset           = TooltipOffset.Value;
            layout.CustomizeButtonPosition = _customizeButton.LocalPosition;
            layout.FormationPosition       = FormationButtonSet.transform.localPosition;
            layout.BuffsSideLeft           = GetAllPortraits().First().Child("StatusEffects").Component <UIAnchor>().side
                                             != UIAnchor.Side.TopRight;
            layout.PartyBarPosition           = PartyPortraitBar.transform.localPosition;
            layout.PartySolidHudPosition      = PartySolidHud.transform.localPosition;
            layout.LogButtonsLeft             = RadioGroup.Component <UIAnchor>().side != UIAnchor.Side.TopRight;
            layout.HudPosition                = ActionBarTrimB.transform.localPosition;
            layout.AbilitiesBarPosition       = AbilitiesBar.transform.localPosition;
            layout.LeftHudBarPosition         = ButtonsLeft.transform.localPosition;
            layout.RightHudBarPosition        = ButtonsRight.transform.localPosition;
            layout.ClockPosition              = TimeWidget.transform.localPosition;
            layout.HudHorizontal              = ButtonsLeft.Component <UIGrid>().arrangement != UIGrid.Arrangement.Vertical;
            layout.UsingCustomTextures        = Attack.Child("Icon").Component <UISprite>().atlas.spriteMaterial.mainTexture != DefaultActionBarAtlas;
            layout.PortraitHighlightsDisabled = !GetAllPortraits().First().Child("StupidPanelBack").activeSelf;
            layout.ButtonsBackground          = ButtonsLeft.ChildPath("#0/Background").activeSelf;
            layout.HudTextureHidden           = !ActionBarTrimB.activeSelf;
            layout.LogPosition                = ConsoleWindow.transform.localPosition;
            layout.PartyBarHorizontal         = mod_UIPartyPortrait.IsVertical;

            layout.FramePath = SelectedFrame.Value;
        }
예제 #2
0
        internal static void LoadLayout(IEModOptions.LayoutOptions newLayout)
        {
            Initialize();
            var buffsChanged = newLayout.BuffsSideLeft;

            foreach (var portrait in GetAllPortraits())
            {
                var statusEffects = portrait.Child("StatusEffects");
                var uiAnchor      = statusEffects.Component <UIAnchor>();
                uiAnchor.side        = buffsChanged ? UIAnchor.Side.TopLeft : UIAnchor.Side.TopRight;
                uiAnchor.pixelOffset = new Vector2(buffsChanged ? -27f : 3f, 0f);                 // default is (3,0)
                statusEffects.Component <UIGrid>().Reposition();
            }
            FormationButtonSet.transform.localPosition = newLayout.FormationPosition;
            PartyPortraitBar.transform.localPosition   = newLayout.PartyBarPosition;
            PartySolidHud.transform.localPosition      = newLayout.PartySolidHudPosition;
            _customizeButton.LocalPosition             = newLayout.CustomizeButtonPosition;
            if (newLayout.BuffsSideLeft != (RadioGroup.Component <UIAnchor>().side == UIAnchor.Side.TopRight))
            {
                var blop = new GameObject();
                SetLogButtonsAlignment(blop);
            }
            ActionBar.Child("trimB").transform.localPosition = newLayout.HudPosition;
            AbilitiesBar.transform.localPosition             = newLayout.AbilitiesBarPosition;
            ConsoleWindow.transform.localPosition            = newLayout.LogPosition;

            SetLogButtonsAlignment(newLayout.LogButtonsLeft);
            ButtonsLeft.transform.localPosition  = newLayout.LeftHudBarPosition;
            ButtonsRight.transform.localPosition = newLayout.RightHudBarPosition;
            TimeWidget.transform.localPosition   = newLayout.ClockPosition;

            var leftUiGrid = ButtonsLeft.Component <UIGrid>();

            leftUiGrid.arrangement = newLayout.HudHorizontal ? UIGrid.Arrangement.Horizontal : UIGrid.Arrangement.Vertical;
            leftUiGrid.Reposition();

            var rightUiGrid = ButtonsRight.Component <UIGrid>();

            rightUiGrid.arrangement = newLayout.HudHorizontal ? UIGrid.Arrangement.Vertical : UIGrid.Arrangement.Horizontal;
            rightUiGrid.Reposition();

            ActionBarTrimB.gameObject.SetActive(!newLayout.HudTextureHidden);

            mod_UIPartyPortrait.IsVertical = newLayout.PartyBarHorizontal;

            if (ButtonsLeft.ChildPath("#0/Background").gameObject.activeSelf != newLayout.ButtonsBackground)
            {
                SetButtonsBackgroundActive();
            }

            ReplaceAtlas(newLayout.UsingCustomTextures);

            SetPortraitHighlight(!newLayout.PortraitHighlightsDisabled);

            SelectedFrame.Value = newLayout.FramePath;
            //not sure why, but the tooltip offset only updates correctly if we do this last.
            TooltipOffset.Value = newLayout.TooltipOffset;
        }
예제 #3
0
        public static void Initialize()
        {
            //Note that the game will destroy the UI when you go to the main menu, so we'll have to rebuild it.
            //The best way to check if we need to initialize everything seem to be the following, though it's strange messy.
            if (IsInitialized)
            {
                return;
            }

            //This is the 'Customize UI' button that lets you customize the UI.
            _customizeButton = new QuickButton(UIPartyPortraitBar.Instance.transform.parent)
            {
                Caption       = "Customize UI",
                Name          = "CustomizeUI",
                LocalPosition = new Vector3(903.5f, 76.2f, 0f),
                LocalScale    = new Vector3(0.7f, 0.7f, 1f)
            };

            _customizeButton.Click += x => {
                SaveLayout(IEModOptions.Layout);
                ShowInterface(!IsInterfaceVisible);
            };

            DefaultActionBarAtlas =
                Attack.Child(0).Component <UISprite>().atlas.spriteMaterial.mainTexture;

            //these may break in future version changes, but I doubt they'll break much.
            //since changing them will probably break some of the developer's code as well
            //to fix them, dump the UICamera hierarchy to file and see which names changed.
            //using Child(string) also tells you which names are broken because it throws an exception if it can't find something,
            //instead of silently returning null and letting you figure out where the problem came from.
            if (DefaultLayout == null)
            {
                DefaultLayout = new IEModOptions.LayoutOptions();
                SaveLayout(DefaultLayout);
            }



            // turning off BB-version label in the upper right corner, cause it's annoying when you want to move portraits there
            UiCamera.Child("BBVersion").gameObject.SetActive(false);

            // UIAnchors on the ActionBarWindow that prevent it from being moved... (it's related to the partybar somehow?)
            // HUD -> Bottom -> ActionBarWindow -> destroy 3 UIAnchors
            foreach (var comp in ActionBarWindow.Components <UIAnchor>())
            {
                GameUtilities.DestroyComponent(comp);
            }

            var component = ConsoleWindow.Component <UIAnchor>();

            if (component)
            {
                GameUtilities.DestroyComponent(component);
            }

            // disable the minimize buttons for the log and the actionbar
            Bottom.Child("ConsoleMinimize").SetActive(false);
            Bottom.Child("ActionBarMinimize").gameObject.SetActive(false);

            // this UIPanel used to hide the clock when it was moved from far away from its original position
            // HUD -> Bottom -> ActionBarWindow -> ActionBarExpandedAnchor -> UIPanel
            ActionBarWindow.Component <UIPanel>().clipping = UIDrawCall.Clipping.None;

            // detaches the "GAME PAUSED" and "SLOW MO" from the Clock panel, to which it was attached for some reason...
            var gamePausedAnchors = UiCamera.Child("GamePaused").Components <UIAnchor>();

            gamePausedAnchors[0].widgetContainer = Hud.Component <UIPanel>().widgets[0];
            gamePausedAnchors[1].DisableY        = true;
            var slowMoAnchors = UiCamera.Child("GameSpeed").Components <UIAnchor>();

            slowMoAnchors[0].widgetContainer = Hud.Component <UIPanel>().widgets[0];
            slowMoAnchors[1].DisableY        = true;
            PartyBar.AddChild(new GameObject("IsInitialized"));
        }