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; }
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; }
private static void SetHudOrientation(bool horizontal) { var buttonsLeft_grid = ButtonsLeft.Component <UIGrid>(); buttonsLeft_grid.arrangement = horizontal ? UIGrid.Arrangement.Horizontal : UIGrid.Arrangement.Vertical; buttonsLeft_grid.Reposition(); //rather amusingly, the right hud already has orientation by default... it just looks horizontal. :) var buttonsRight_grid = ButtonsRight.Component <UIGrid>(); buttonsRight_grid.arrangement = horizontal ? UIGrid.Arrangement.Vertical : UIGrid.Arrangement.Horizontal; buttonsRight_grid.Reposition(); }
private static void CreateInterface() { var quickFactory = new QuickFactory(UIPartyPortraitBar.Instance.transform.parent); Action <QuickButton, GameObject> addDragObject = (o, target) => { var collider = o.Collider; collider.AddComponent <UIDragObject>().target = target.transform; }; var initialPos = new Vector3(905, 487, -6); DragPartyBar = quickFactory.Button("Drag Party Bar", localPos: initialPos); addDragObject(DragPartyBar, UIPartyPortraitBar.Instance.gameObject); addDragObject(DragPartyBar, PartySolidHud); var choices = Directory.GetFiles(@"PillarsOfEternity_Data\Managed\iemod\frames", string.Format("*{0}x{1}.png", Screen.width, Screen.height)).Select( path => new DropdownChoice <string>(GetFrameNameFromPath(path), path)).ToList(); choices.Insert(0, new DropdownChoice <string>("(none)", "")); var controlFactory = quickFactory; var layer = 14; FrameDropdown = new QuickDropdown <string>(quickFactory.CurrentParent) { Layer = layer, LocalPosition = new Vector3(392.6f, 622.7f, -6.0f), LabelText = "Custom Frame:", LabelWidth = 150, Width = 300, Options = choices }; FrameDropdown.SelectedValue.Bind(SelectedFrame); BlockClicking.Apply(FrameDropdown); DragHugBgr = controlFactory.Button("Drag Hud Bgr", localPos: initialPos.Plus(y: 50f)); DragHugBgr.LocalPosition = initialPos.Plus(y: 50f); DragHugBgr.Layer = layer; addDragObject(DragHugBgr, ActionBarTrimB); DragLog = controlFactory.Button("Drag Log", localPos: initialPos.Plus(y: 100f)); DragLog.Layer = layer; addDragObject(DragLog, ConsoleWindow); DragAbilitiesBar = controlFactory.Button("Drag Abilities", localPos: initialPos.Plus(y: -50f)); DragAbilitiesBar.Layer = layer; addDragObject(DragAbilitiesBar, AbilitiesBar); ToggleLogButtons = controlFactory.Button("T. Log Buttons Side", localPos: initialPos.Plus(x: 400f, y: -50f)); ToggleLogButtons.Layer = layer; ToggleLogButtons.Click += x => SetLogButtonsAlignment(RadioGroup.Component <UIAnchor>().side != UIAnchor.Side.TopLeft); ToggleHudOrientation = controlFactory.Button("T. Hud Horiz/Vert", localPos: initialPos.Plus(400f)); ToggleHudOrientation.Layer = layer; ToggleHudOrientation.Click += x => SetHudOrientation(ButtonsLeft.Component <UIGrid>().arrangement == UIGrid.Arrangement.Vertical); DragHudPanelLeft = controlFactory.Button("Drag Hud Panel 1", localPos: initialPos.Plus(y: -150f)); DragHudPanelLeft.Layer = layer; addDragObject(DragHudPanelLeft, ButtonsLeft); DragHudPanelRight = controlFactory.Button("Drag Hud Panel 2", localPos: initialPos.Plus(y: -200f)); DragHudPanelRight.Layer = layer; addDragObject(DragHudPanelRight, ButtonsRight); DragClock = controlFactory.Button("Drag Clock", localPos: initialPos.Plus(y: -100f)); DragClock.Layer = layer; addDragObject(DragClock, TimeWidget); ToggleHudBgr = controlFactory.Button("T. Hud Background", localPos: initialPos.Plus(400f, 50f)); ToggleHudBgr.Layer = layer; ToggleHudBgr.Click += x => ActionBarTrimB.SetActive(!ActionBarTrimB.gameObject.activeSelf); TooltipOffsetCheckbox = new QuickCheckbox("TooltipOffsetChbox", controlFactory.CurrentParent) { Label = "Tooltip Offset", Layer = layer, LocalPosition = FrameDropdown.LocalPosition.Plus(x: -110, y: -50) }; //UnityPrinter.HierarchyPrinter.Print(TooltipOffsetCheckbox.GameObject); TooltipOffsetCheckbox.IsChecked.Bind(TooltipOffset); TogglePartyOrientation = controlFactory.Button("T. Party Horiz/Vert", localPos: initialPos.Plus(400f, 100f)); TogglePartyOrientation.Layer = layer; TogglePartyOrientation.Click += _ => mod_UIPartyPortrait.IsVertical = !mod_UIPartyPortrait.IsVertical; ToggleBuffsSide = controlFactory.Button("Toggle Buffs Side", localPos: initialPos.Plus(400f, 150f)); ToggleBuffsSide.Layer = layer; ToggleBuffsSide.Click += x => SetBuffSide(); DragFormationBar = controlFactory.Button("Drag Formation Bar", localPos: initialPos.Plus(y: -250f)); DragFormationBar.Layer = layer; addDragObject(DragFormationBar, FormationButtonSet); ToggleButtonsBgr = controlFactory.Button("T. Buttons Background", localPos: initialPos.Plus(400f, -100f)); ToggleButtonsBgr.Click += x => SetButtonsBackgroundActive(); ToggleButtonsBgr.Layer = layer; TogglePortraitHighlights = controlFactory.Button("T. Portrait Highlight", localPos: initialPos.Plus(400f, -150f)); TogglePortraitHighlights.Click += x => SetPortraitHighlight(); TogglePortraitHighlights.Layer = layer; ToggleCustomTextures = controlFactory.Button("T. Custom Textures", localPos: initialPos.Plus(400f, -200f)); ToggleCustomTextures.Click += x => SetCustomTexturesActive(); ToggleCustomTextures.Layer = layer; SaveBtn = controlFactory.Button("Save & Close", localPos: initialPos.Plus(-140f, 250f)); SaveBtn.Layer = layer; SaveBtn.Click += x => { SaveLayout(IEModOptions.Layout); ShowInterface(false); }; CancelBtn = controlFactory.Button("Reset to Prev", localPos: initialPos.Plus(140f, 250f)); CancelBtn.Layer = layer; CancelBtn.Click += x => { LoadLayout(IEModOptions.Layout); }; UseDefaultUIBtn = controlFactory.Button("Reset to Default", localPos: initialPos.Plus(400f, 350f)); UseDefaultUIBtn.Layer = layer; UseDefaultUIBtn.Click += x => { LoadLayout(DefaultLayout); }; }