protected override void Draw(DrawingHandleBase handle) { var screenHandle = (DrawingHandleScreen)handle; var mousePos = IoCManager.Resolve <IInputManager>().MouseScreenPosition; if (_system.UseOrAttackIsDown && _system._timeHeld > AttackTimeThreshold) { var tex = ResC.GetTexture($"/Textures/Objects/Tools/toolbox_r.png"); screenHandle.DrawTextureRect(tex, UIBox2.FromDimensions(mousePos, tex.Size * 2)); } }
public override void Populate() { var humanFacialHairRSIPath = SharedSpriteComponent.TextureRoot / "Mob/human_facial_hair.rsi"; var humanFacialHairRSI = ResC.GetResource <RSIResource>(humanFacialHairRSIPath).RSI; var styles = HairStyles.FacialHairStylesMap.ToList(); styles.Sort(HairStyles.FacialHairStyleComparer); foreach (var(styleName, styleState) in HairStyles.FacialHairStylesMap) { Items.AddItem(styleName, humanFacialHairRSI[styleState].Frame0); } }
public virtual void Populate() { var humanHairRSIPath = SharedSpriteComponent.TextureRoot / "Mobs/Customization/human_hair.rsi"; var humanHairRSI = ResC.GetResource <RSIResource>(humanHairRSIPath).RSI; var styles = HairStyles.HairStylesMap.ToList(); styles.Sort(HairStyles.HairStyleComparer); foreach (var(styleName, styleState) in styles) { Items.AddItem(styleName, humanHairRSI[styleState].Frame0); } }
public StatusControl(BallisticMagazineWeaponComponent parent) { _parent = parent; SizeFlagsHorizontal = SizeFlags.FillExpand; SizeFlagsVertical = SizeFlags.ShrinkCenter; AddChild(new VBoxContainer { SizeFlagsHorizontal = SizeFlags.FillExpand, SizeFlagsVertical = SizeFlags.ShrinkCenter, SeparationOverride = 0, Children = { (_bulletsListTop = new HBoxContainer { SeparationOverride = 0 }), new HBoxContainer { SizeFlagsHorizontal = SizeFlags.FillExpand, Children = { new Control { SizeFlagsHorizontal = SizeFlags.FillExpand, Children = { (_bulletsListBottom = new HBoxContainer { SizeFlagsVertical = SizeFlags.ShrinkCenter, SeparationOverride = 0 }), (_noMagazineLabel = new Label { Text = "No Magazine!", StyleClasses ={ NanoStyle.StyleClassItemStatus } }) } }, (_chamberedBullet = new TextureRect { Texture = ResC.GetTexture("/Textures/UserInterface/status/bullets/chambered.png"), SizeFlagsVertical = SizeFlags.ShrinkCenter, SizeFlagsHorizontal = SizeFlags.ShrinkEnd | SizeFlags.Fill, }) } } } }); }
public void Update() { _chamberedBullet.ModulateSelfOverride = _parent.Chambered ? Color.FromHex("#d7df60") : Color.Black; _bulletsListTop.RemoveAllChildren(); _bulletsListBottom.RemoveAllChildren(); if (_parent.MagazineCount == null) { _noMagazineLabel.Visible = true; return; } var(count, capacity) = _parent.MagazineCount.Value; _noMagazineLabel.Visible = false; string texturePath; if (capacity <= 20) { texturePath = "/Textures/UserInterface/status/bullets/normal.png"; } else if (capacity <= 30) { texturePath = "/Textures/UserInterface/status/bullets/small.png"; } else { texturePath = "/Textures/UserInterface/status/bullets/tiny.png"; } var texture = ResC.GetTexture(texturePath); const int tinyMaxRow = 60; if (capacity > tinyMaxRow) { FillBulletRow(_bulletsListBottom, Math.Min(tinyMaxRow, count), tinyMaxRow, texture); FillBulletRow(_bulletsListTop, Math.Max(0, count - tinyMaxRow), capacity - tinyMaxRow, texture); } else { FillBulletRow(_bulletsListBottom, count, capacity, texture); } }
public void Initialize() { var notoSans12 = new VectorFont(ResC.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 12); var notoSansBold15 = new VectorFont(ResC.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Bold.ttf"), 15); var buttonTexture = ResC.GetResource <TextureResource>("/Textures/UI/button.png"); var windowBackgroundTex = ResC.GetResource <TextureResource>("/Textures/UI/button.png"); var windowBackground = new StyleBoxTexture { Texture = windowBackgroundTex, }; var buttonBase = new StyleBoxTexture { Texture = buttonTexture, }; var lineEditTex = ResC.GetResource <TextureResource>("/Textures/UI/edit.png"); var lineEdit = new StyleBoxTexture { Texture = lineEditTex, }; lineEdit.SetPatchMargin(StyleBox.Margin.All, 3); lineEdit.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5); buttonBase.SetPatchMargin(StyleBox.Margin.All, 10); buttonBase.SetPadding(StyleBox.Margin.All, 1); buttonBase.SetContentMarginOverride(StyleBox.Margin.Vertical, 2); buttonBase.SetContentMarginOverride(StyleBox.Margin.Horizontal, 14); var openRightButtonBase = new StyleBoxTexture(buttonBase) { Texture = new AtlasTexture(buttonTexture, UIBox2.FromDimensions((0, 0), (14, 24))), }; openRightButtonBase.SetPatchMargin(StyleBox.Margin.Right, 0); openRightButtonBase.SetContentMarginOverride(StyleBox.Margin.Right, 8); openRightButtonBase.SetPadding(StyleBox.Margin.Right, 2); var openLeftButtonBase = new StyleBoxTexture(buttonBase) { Texture = new AtlasTexture(buttonTexture, UIBox2.FromDimensions((10, 0), (14, 24))), }; openLeftButtonBase.SetPatchMargin(StyleBox.Margin.Left, 0); openLeftButtonBase.SetContentMarginOverride(StyleBox.Margin.Left, 8); openLeftButtonBase.SetPadding(StyleBox.Margin.Left, 1); var openBothButtonBase = new StyleBoxTexture(buttonBase) { Texture = new AtlasTexture(buttonTexture, UIBox2.FromDimensions((10, 0), (3, 24))), }; openBothButtonBase.SetPatchMargin(StyleBox.Margin.Horizontal, 0); openBothButtonBase.SetContentMarginOverride(StyleBox.Margin.Horizontal, 8); openBothButtonBase.SetPadding(StyleBox.Margin.Right, 2); openBothButtonBase.SetPadding(StyleBox.Margin.Left, 1); Stylesheet = new Stylesheet(new StyleRule[] { new StyleRule( new SelectorElement(null, null, null, null), new[] { new StyleProperty("font", notoSans12), }), new StyleRule(new SelectorElement(typeof(LineEdit), null, null, null), new[] { new StyleProperty(LineEdit.StylePropertyStyleBox, lineEdit), }), Element <Label>().Class(StyleClassLabelHeading) .Prop(Label.StylePropertyFont, notoSansBold15), Element <Label>().Class(StyleClassLabelSubText) .Prop(Label.StylePropertyFont, notoSans12) .Prop(Label.StylePropertyFontColor, Color.White), Element <PanelContainer>().Class(ClassHighDivider) .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = Color.Gray, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2 }), // Shapes for the buttons. Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Prop(ContainerButton.StylePropertyStyleBox, buttonBase), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Class(ButtonOpenRight) .Prop(ContainerButton.StylePropertyStyleBox, openRightButtonBase), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Class(ButtonOpenLeft) .Prop(ContainerButton.StylePropertyStyleBox, openLeftButtonBase), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Class(ButtonOpenBoth) .Prop(ContainerButton.StylePropertyStyleBox, openBothButtonBase), // Colors for the buttons. Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassNormal) .Prop(Control.StylePropertyModulateSelf, ButtonColorDefault), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassHover) .Prop(Control.StylePropertyModulateSelf, ButtonColorHovered), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassPressed) .Prop(Control.StylePropertyModulateSelf, ButtonColorPressed), Element <ContainerButton>().Class(ContainerButton.StyleClassButton) .Pseudo(ContainerButton.StylePseudoClassDisabled) .Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled), // Colors for the caution buttons. Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassNormal) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDefault), Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassHover) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionHovered), Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassPressed) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionPressed), Element <ContainerButton>().Class(ContainerButton.StyleClassButton).Class(ButtonCaution) .Pseudo(ContainerButton.StylePseudoClassDisabled) .Prop(Control.StylePropertyModulateSelf, ButtonColorCautionDisabled), Element <Label>().Class(ContainerButton.StyleClassButton) .Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center), Child() .Parent(Element <Button>().Class(ContainerButton.StylePseudoClassDisabled)) .Child(Element <Label>()) .Prop("font-color", Color.FromHex("#FFFFFF")), }); _userInterfaceManager.Stylesheet = Stylesheet; }
public override void Startup() { var panelTex = ResC.GetTexture("/Nano/button.svg.96dpi.png"); var back = new StyleBoxTexture { Texture = panelTex, Modulate = new Color(32, 32, 48), }; back.SetPatchMargin(StyleBox.Margin.All, 10); Button exitButton; Button reconnectButton; Button retryButton; var address = _gameController.LaunchState.Ss14Address ?? _gameController.LaunchState.ConnectAddress; _control = new Control { Stylesheet = _stylesheetManager.SheetSpace, Children = { new PanelContainer { PanelOverride = back }, new VBoxContainer { SeparationOverride = 0, CustomMinimumSize = (300, 200), Children = { new HBoxContainer { Children = { new MarginContainer { MarginLeftOverride = 8, Children = { new Label { Text = Loc.GetString("Space Station 14"), StyleClasses ={ StyleBase.StyleClassLabelHeading }, VAlign = Label.VAlignMode.Center }, } }, (exitButton = new Button { Text = Loc.GetString("Exit"), SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd | Control.SizeFlags.Expand }), } }, // Line new HighDivider(), new MarginContainer { SizeFlagsVertical = Control.SizeFlags.FillExpand, MarginLeftOverride = 4, MarginRightOverride = 4, MarginTopOverride = 4, Children = { new VBoxContainer { SeparationOverride = 0, Children = { new Control { SizeFlagsVertical = Control.SizeFlags.FillExpand, Children = { (_connectingStatus = new VBoxContainer { SeparationOverride = 0, Children = { new Label { Text = Loc.GetString("Connecting to server..."), Align = Label.AlignMode.Center, }, (_connectStatus = new Label { StyleClasses ={ StyleBase.StyleClassLabelSubText }, Align = Label.AlignMode.Center, }), } }), (_connectFail = new VBoxContainer { Visible = false, SeparationOverride = 0, Children = { (_connectFailReason = new Label { Align = Label.AlignMode.Center }), (retryButton = new Button { Text = "Retry", SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter, SizeFlagsVertical = Control.SizeFlags.Expand | Control.SizeFlags.ShrinkEnd }) } }), (_disconnected = new VBoxContainer { SeparationOverride = 0, Children = { new Label { Text = "Disconnected from server:", Align = Label.AlignMode.Center }, new Label { Text = _baseClient.LastDisconnectReason, Align = Label.AlignMode.Center }, (reconnectButton = new Button { Text = "Reconnect", SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter, SizeFlagsVertical = Control.SizeFlags.Expand | Control.SizeFlags.ShrinkEnd }) } }) } }, // Padding. new Control { CustomMinimumSize = (0, 8) },