private void SetFixedPositionToDefault() { if (FixedPosition.Equals(null)) { FixedPosition = ParentRectTransform; } }
public InventoryCharacterPane(PartyCharacterId activeCharacter, Func <InventoryPage> getPage, Action <InventoryPage> setPage) { _getPage = getPage; var page = _getPage(); _summaryButton = new Button("I") { DoubleFrame = true, IsPressed = page == InventoryPage.Summary }.OnClick(() => setPage(InventoryPage.Summary)); _statsButton = new Button("II") { DoubleFrame = true, IsPressed = page == InventoryPage.Stats }.OnClick(() => setPage(InventoryPage.Stats)); _miscButton = new Button("III") { DoubleFrame = true, IsPressed = page == InventoryPage.Misc }.OnClick(() => setPage(InventoryPage.Misc)); var buttonStack = new FixedPosition( new Rectangle(84, 174, 50, 15), new HorizontalStack( new FixedSize(16, 15, _summaryButton), new FixedSize(16, 15, _statsButton), new FixedSize(16, 15, _miscButton) )); AttachChild(buttonStack); AttachChild(new InventoryActivePageSelector(activeCharacter, getPage)); }
public void FixedPositionsOffsetOverAnchorsCorrectlyCenterCenter() { Button testButton = new Button ( "Test Button", new FixedSize(32.0f, 16.0f), null, "TEST" ); FixedPosition buttonPosition = new FixedPosition ( new Vector2(0.0f, 0.0f), GuiAnchor.BottomRight, GuiAnchor.CenterCenter ); IDictionary <IWidget, IGuiPosition> widgets = new Dictionary <IWidget, IGuiPosition>(); widgets.Add(testButton, buttonPosition); new GuiFrame ( "Test Frame", new FixedSize(256.0f, 384.0f), widgets, null ); Vector2 calculatedPosition = buttonPosition.GetPosition(testButton); Assert.IsWithin(96.0f, calculatedPosition.x, 0.001f); Assert.IsWithin(176.0f, calculatedPosition.y, 0.001f); }
public void FixedPositionConstructorVerification() { Vector2 relativePos = new Vector2(-3.0f, 10.0f); FixedPosition testPosition = new FixedPosition ( relativePos, GuiAnchor.CenterCenter, GuiAnchor.BottomRight ); Assert.AreEqual(testPosition.LocalAnchor, GuiAnchor.CenterCenter); Assert.AreEqual(testPosition.ParentAnchor, GuiAnchor.BottomRight); Assert.AreEqual(testPosition.RelativePosition, relativePos); }
void Rebuild() { foreach (var child in Children) { child.Detach(); } Children.Clear(); var background = new UiFixedPositionElement <SlabId>(SlabId.SLAB, UiConstants.UiExtents); var leftPane = _mode switch { InventoryMode.Character => (IUiElement) new InventoryCharacterPane(_activeCharacter, () => _page), InventoryMode.Merchant => new InventoryChestPane(false), InventoryMode.Chest => new InventoryChestPane(true), InventoryMode.LockedChest => new InventoryLockPane(true), InventoryMode.LockedDoor => new InventoryLockPane(false), _ => throw new InvalidOperationException($"Unexpected inventory mode {_mode}") }; var middlePane = new InventoryMidPane(_activeCharacter, _config.Positions[_activeCharacter]); var rightPane = new InventoryRightPane(_activeCharacter, ExitButtonId, _mode == InventoryMode.Merchant); // var frameDivider = new FrameDivider(135, 0, 4, 192); var leftContainer = new FixedPosition( new Rectangle(0, 0, 135, UiConstants.ActiveAreaExtents.Height), leftPane); var middleContainer = new FixedPosition( new Rectangle(142, 0, 134, UiConstants.ActiveAreaExtents.Height), middlePane); var rightContainer = new FixedPosition( new Rectangle(280, 0, 71, UiConstants.ActiveAreaExtents.Height), rightPane); Exchange .Attach(background) .Attach(leftContainer) .Attach(middleContainer) .Attach(rightContainer) ; Children.Add(background); Children.Add(leftContainer); Children.Add(middleContainer); Children.Add(rightContainer); } }
public void FixedPositionsOffsetOverAnchorsCorrectlyLeftBottom() { Textbox testTextBox = new Textbox ( "Test Box", new FixedSize(184.0f, 48.0f), null, "TEST", true, true ); FixedPosition textBoxPosition = new FixedPosition ( new Vector2(8.0f, 8.0f), GuiAnchor.BottomLeft, GuiAnchor.BottomLeft ); IDictionary <IWidget, IGuiPosition> widgets = new Dictionary <IWidget, IGuiPosition>(); widgets.Add(testTextBox, textBoxPosition); GuiFrame mainFrame = new GuiFrame ( "Test Frame", new FillParent(), widgets, null ); new Window ( "Test Window", new FixedSize(229.0f, 172.0f), new RuntimeGuiManager(false, new Logger()), mainFrame ); Vector2 calculatedPosition = textBoxPosition.GetPosition(testTextBox); Assert.IsWithin(8.0f, calculatedPosition.x, 0.001f); Assert.IsWithin(132.0f, calculatedPosition.y, 0.001f); }
private static void SetFixedBlock(CompilerState state, Paragraph content, FixedPosition position) { var block = new FixedBlock(content) { Position = position }; for (int i = 0; i < state.Document.PageItems.Count; i++) { var item = state.Document.PageItems[i]; if (item is FixedBlock fix && fix.Position == position) { state.Document.PageItems.RemoveAt(i); break; } } state.Document.PageItems.Add(block); }
public StatusBar() : base(DialogPositioning.StatusBar) { On <HoverTextEvent>(e => _hoverSource.Source = e.Source); On <DescriptionTextEvent>(e => _descriptionSource.Source = e.Source); _sprite = AttachChild(new UiSpriteElement(Base.UiBackground.SLAB)); _sprite.SubId = 1; _portraits = new StatusBarPortrait[MaxPortraits]; for (int i = 0; i < _portraits.Length; i++) { _portraits[i] = new StatusBarPortrait(i); AttachChild(_portraits[i]); } var hoverText = new UiText(_hoverSource); var descriptionText = new UiText(_descriptionSource); _hoverTextContainer = AttachChild(new FixedPosition(new Rectangle(181, 196, 177, 10), hoverText)); _descriptionTextContainer = AttachChild(new FixedPosition(new Rectangle(181, 208, 177, 30), descriptionText)); }
public InventorySummaryPage(PartyCharacterId activeMember) { _activeMember = activeMember; var background = new FixedPosition( new Rectangle(0, 26, 135, 144), new UiSprite <SmallPortraitId>((SmallPortraitId)(int)activeMember)); var summarySource = new DynamicText(BuildSummary); var pointsSource = new DynamicText(BuildPoints); var pointsHeadingSource = new DynamicText(BuildPointsHeadings); var frameTheme = new FrameTheme(); var stack = new HorizontalStack( new Padding(4, 0), new VerticalStack( new Padding(0, 4), new ButtonFrame(new FixedSize(125, 41, new Text(summarySource))) { Theme = frameTheme, State = ButtonState.Pressed }, new Padding(0, 80), new ButtonFrame( new FixedSize(125, 41, new HorizontalStack( new Text(pointsHeadingSource), new Padding(5, 0), new FixedSize(41, 41, new Text(pointsSource) )))) { Theme = frameTheme, State = ButtonState.Pressed } ), new Padding(4, 0) ); Children.Add(background); Children.Add(stack); }
private void itemFixed_Click(object sender, EventArgs e) { if (!IsLoadDataSource()) { return; } if (!PublicMethod.Instance.IsExecuteSystemCMD("")) { if (fp == null) { fp = new FixedPosition { WindowState = FormWindowState.Normal, Visible = true }; Application.ShowModelessDialog(fp); } else { fp.Visible = true; fp.WindowState = FormWindowState.Normal; fp.Activate(); } } }
private void RefreshTransforms() { fixedPosition = GetComponentInParent <FixedPosition>(); if (transforms == null) { transforms = new List <Transform>(); } transforms.Clear(); if (!acceptMouseEvents) { return; } if (fixedPosition == null) { // This happens when taking the top exposed // card from the deck, there can be no // stacked cards in this case. transforms.Add(transform); return; } foreach (var card in fixedPosition.GetComponentsInChildren <CardBehaviour>()) { if (card == this) { transforms.Add(card.transform); } else if (transforms.Count > 0) { transforms.Add(card.transform); } } }
// These probably aren't compared but it is not expensive to provide the overrides, // especially given the Reflection issue if they are compared without these, as // described in FxCop rule CA1815. // Omitting getHashCode violates rule: OverrideGetHashCodeOnOverridingEquals. /// <summary> /// Return a hashcode based upon data members. /// </summary> /// <returns></returns> public override int GetHashCode() { return(InnerMargin.GetHashCode() ^ FixedPosition.GetHashCode() ^ Weight.GetHashCode()); }
public NavbarSettings SetFixed(FixedPosition fixedPosition) { Fixed = fixedPosition; return(this); }
private static void SetFixedBlock(CompilerState state, DocumentElement content, FixedPosition position) { var block = new FixedBlock(content) { Position = position }; if (position.HasFlag(FixedPosition.Bottom)) { block.Classes.Add("footer"); } else if (position.HasFlag(FixedPosition.Top)) { block.Classes.Add("header"); } for (int i = 0; i < state.Document.PageItems.Count; i++) { var item = state.Document.PageItems[i]; if (item is FixedBlock fix && fix.Position == position) { state.Document.PageItems.RemoveAt(i); break; } } state.Document.PageItems.Add(block); }
public NavbarSettings SetFixed(FixedPosition fixedPosition) { Fixed = fixedPosition; return this; }