public ITreeNodeView CreateNode(ITreeStringNode item, IRenderLayer layer) { var buttonWidth = 20f; var buttonHeight = 60f; IAnimation idle = new AGSSingleFrameAnimation(new EmptyImage(buttonWidth, buttonHeight), _factory.Graphics); idle.Sprite.Tint = Colors.Black; IAnimation hovered = new AGSSingleFrameAnimation(new EmptyImage(buttonWidth, buttonHeight), _factory.Graphics); hovered.Sprite.Tint = Colors.Yellow; IAnimation pushed = new AGSSingleFrameAnimation(new EmptyImage(buttonWidth, buttonHeight), _factory.Graphics); pushed.Sprite.Tint = Colors.DarkSlateBlue; int nodeId = Interlocked.Increment(ref _nextNodeId); var itemTextId = (item.Text ?? "") + "_" + nodeId; var parentPanel = _factory.UI.GetPanel("TreeNodeParentPanel_" + itemTextId, 0f, 0f, 0f, 0f, addToUi: false); var horizontalPanel = _factory.UI.GetPanel("TreeNodeHorizontalPanel_" + itemTextId, 0f, 0f, 0f, 0f, parentPanel, false); var expandButton = _factory.UI.GetButton("ExpandButton_" + itemTextId, idle, hovered, pushed, 0f, 0f, horizontalPanel, addToUi: false); var label = _factory.UI.GetLabel("TreeNodeLabel_" + itemTextId, item.Text, 0f, 0f, buttonWidth, 0f, horizontalPanel, new AGSTextConfig(paddingTop: 0f, paddingBottom: 0f, autoFit: AutoFit.LabelShouldFitText), addToUi: false); var verticalPanel = _factory.UI.GetPanel("TreeNodeVerticalPanel_" + itemTextId, 0f, 0f, 0f, 0f, parentPanel, false); horizontalPanel.RenderLayer = layer; verticalPanel.RenderLayer = layer; parentPanel.RenderLayer = layer; expandButton.RenderLayer = layer; label.RenderLayer = layer; expandButton.Z = label.Z - 1; horizontalPanel.Tint = Colors.Transparent; parentPanel.Tint = Colors.Transparent; verticalPanel.Tint = Colors.Transparent; expandButton.Tint = Colors.Transparent; expandButton.TextBackgroundVisible = false; label.Tint = Colors.Transparent; label.TextBackgroundVisible = false; label.Enabled = true; expandButton.IsPixelPerfect = false; horizontalPanel.AddComponent <IBoundingBoxWithChildrenComponent>(); var layout = horizontalPanel.AddComponent <IStackLayoutComponent>(); layout.RelativeSpacing = 1f; layout.Direction = LayoutDirection.Horizontal; layout.StartLayout(); item.PropertyChanged += (sender, e) => { if (e.PropertyName != nameof(ITreeStringNode.Text)) { return; } label.Text = item.Text; }; var nodeView = new AGSTreeNodeView(label, expandButton, parentPanel, verticalPanel, horizontalPanel); return(nodeView); }
public static bool YesNo(string text, string yes = "Yes", string no = "No") { var factory = AGSGame.Game.Factory; IAnimation idle = new AGSSingleFrameAnimation (new EmptyImage (ButtonWidth, ButtonHeight), factory.Graphics); idle.Sprite.Tint = Colors.Black; IAnimation hovered = new AGSSingleFrameAnimation (new EmptyImage (ButtonWidth, ButtonHeight), factory.Graphics); hovered.Sprite.Tint = Colors.Yellow; IAnimation pushed = new AGSSingleFrameAnimation (new EmptyImage (ButtonWidth, ButtonHeight), factory.Graphics); pushed.Sprite.Tint = Colors.DarkSlateBlue; var border = AGSBorders.Gradient(AGSGame.Resolver.Container.Resolve<IGLUtils>(), new FourCorners<Color>(Colors.DarkOliveGreen, Colors.LightGreen, Colors.LightGreen, Colors.DarkOliveGreen), 3f, true); IButton yesButton = factory.UI.GetButton("Dialog Yes Button", idle, hovered, pushed, 0f, 0f, yes, ButtonConfig); IButton noButton = factory.UI.GetButton("Dialog No Button", idle, hovered, pushed, 0f, 0f, no, ButtonConfig); yesButton.Border = border; noButton.Border = border; return Display(text, yesButton, noButton) == yesButton; }
public static async Task <bool> YesNoAsync(string text, string yes = "Yes", string no = "No") { var factory = AGSGame.Game.Factory; IAnimation idle = new AGSSingleFrameAnimation(new EmptyImage(ButtonWidth, ButtonHeight), factory.Graphics); idle.Sprite.Tint = Colors.Black; IAnimation hovered = new AGSSingleFrameAnimation(new EmptyImage(ButtonWidth, ButtonHeight), factory.Graphics); hovered.Sprite.Tint = Colors.Yellow; IAnimation pushed = new AGSSingleFrameAnimation(new EmptyImage(ButtonWidth, ButtonHeight), factory.Graphics); pushed.Sprite.Tint = Colors.DarkSlateBlue; var border = AGSBorders.Gradient(AGSGame.Resolver.Container.Resolve <IGLUtils>(), new FourCorners <Color>(Colors.DarkOliveGreen, Colors.LightGreen, Colors.LightGreen, Colors.DarkOliveGreen), 3f, true); IButton yesButton = factory.UI.GetButton("Dialog Yes Button", idle, hovered, pushed, 0f, 0f, null, yes, ButtonConfig, false); IButton noButton = factory.UI.GetButton("Dialog No Button", idle, hovered, pushed, 0f, 0f, null, no, ButtonConfig, false); yesButton.Border = border; noButton.Border = border; return(await DisplayAsync(text, yesButton, noButton) == yesButton); }
private async Task addLampPosts(IGameFactory factory) { PointF parallaxSpeed = new PointF (1.4f, 1f); AGSRenderLayer parallaxLayer = new AGSRenderLayer (-50, parallaxSpeed); var image = await factory.Graphics.LoadImageAsync(_baseFolder + "lampPost.png"); var singleFrame = new AGSSingleFrameAnimation (image, factory.Graphics); const int numLampPosts = 3; for (int index = 0; index < numLampPosts; index++) { IObject lampPost = factory.Object.GetObject("Lamp Post " + index); lampPost.X = 200f * index + 30f; lampPost.Y = -130f; lampPost.RenderLayer = parallaxLayer; lampPost.StartAnimation(singleFrame); _room.Objects.Add(lampPost); } }