Beispiel #1
0
        public InventoryUIEntity(
            IGameUIFactory gameUIFactory,
            IViewportMode viewportMode,
            ISkin skin)
            : base(skin)
        {
            this.m_ViewportMode = viewportMode;
            this.SidebarWidth = 300;

            this.m_InventoryManager = gameUIFactory.CreateInventoryManager();

            this.m_SplitHorizontal = new HorizontalContainer();
            this.m_LeftBar = gameUIFactory.CreateLeftBar();
            this.m_CentreContainer = new VerticalContainer();
            this.m_RightBar = gameUIFactory.CreateRightBar();
            this.m_StatusBarSpacing = new HorizontalContainer();
            this.m_StatusBar = gameUIFactory.CreateStatusBar();

            this.m_RightBar.SetChild(this.m_InventoryManager);

            this.m_SplitHorizontal.AddChild(this.m_LeftBar, "0");
            this.m_SplitHorizontal.AddChild(this.m_CentreContainer, "*");
            this.m_SplitHorizontal.AddChild(this.m_RightBar, "0");
            this.m_StatusBarSpacing.AddChild(new EmptyContainer(), "*");
            this.m_StatusBarSpacing.AddChild(this.m_StatusBar, "640");
            this.m_StatusBarSpacing.AddChild(new EmptyContainer(), "*");
            this.m_CentreContainer.AddChild(new EmptyContainer(), "*");
            this.m_CentreContainer.AddChild(this.m_StatusBarSpacing, "64");

            this.Canvas = new Canvas();
            this.Canvas.SetChild(this.m_SplitHorizontal);
        }
Beispiel #2
0
        public MenuWorld(ISkin skin, IWorldFactory worldFactory, IAssetManagerProvider assetManagerProvider, I2DRenderUtilities twodRenderUtilities)
        {
            this.m_2DRenderUtilities = twodRenderUtilities;

            this.m_LogoTexture = assetManagerProvider.GetAssetManager().Get<TextureAsset>("texture.Logo");

            this.m_WorldFactory = worldFactory;

            this.Entities = new List<IEntity>();

            var startServer = new Button();
            startServer.Text = "Start Server";
            startServer.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(false, IPAddress.Any));
            };

            var ipAddressTextBox = new TextBox();

            var joinGame = new Button();
            joinGame.Text = "Join Game";
            joinGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.SwitchWorld<IWorldFactory>(
                    x => x.CreateLobbyWorld(true, IPAddress.Parse(ipAddressTextBox.Text)));
            };

            var exitGame = new Button();
            exitGame.Text = "Exit Game";
            exitGame.Click += (sender, e) =>
            {
                this.m_LastGameContext.Game.Exit();
            };

            var vertical = new VerticalContainer();
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Perspective" }, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(startServer, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(new Label { Text = "Server IP address:" }, "20");
            vertical.AddChild(ipAddressTextBox, "20");
            vertical.AddChild(joinGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");
            vertical.AddChild(exitGame, "25");
            vertical.AddChild(new EmptyContainer(), "*");

            var horizontal = new HorizontalContainer();
            horizontal.AddChild(new EmptyContainer(), "*");
            horizontal.AddChild(vertical, "250");
            horizontal.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();
            canvas.SetChild(horizontal);

            this.Entities.Add(new CanvasEntity(skin, canvas));
        }
Beispiel #3
0
        public MultiplayerWorld(ISkin skin)
        {
            this.Entities = new List<IEntity>();

            this.m_ServersListView = new ListView();
            this.m_ServersListView.AddChild(new ServerListItem { Text = "Loading servers...", Valid = false });
            this.m_ServersListView.SelectedItemChanged += this.ServersListViewOnSelectedItemChanged;

            var backButton = new Button { Text = "Back" };
            backButton.Click += (sender, args) => this.m_GameContext.SwitchWorld<TitleWorld>();

            var buttonContainer = new HorizontalContainer();
            buttonContainer.AddChild(new EmptyContainer(), "*");
            buttonContainer.AddChild(backButton, "100");
            buttonContainer.AddChild(new EmptyContainer(), "*");

            var verticalContainer = new VerticalContainer();
            verticalContainer.AddChild(new EmptyContainer(), "*");
            verticalContainer.AddChild(this.m_ServersListView, "370");
            verticalContainer.AddChild(new EmptyContainer(), "10");
            verticalContainer.AddChild(buttonContainer, "24");
            verticalContainer.AddChild(new EmptyContainer(), "*");

            var horizontalContainer = new HorizontalContainer();
            horizontalContainer.AddChild(new EmptyContainer(), "*");
            horizontalContainer.AddChild(verticalContainer, "300");
            horizontalContainer.AddChild(new EmptyContainer(), "*");

            var canvas = new Canvas();
            canvas.SetChild(horizontalContainer);

            this.m_CanvasEntity = new CanvasEntity(skin, canvas);

            this.m_QueryServersThread = new Thread(this.QueryServers) { Name = "Query Servers", IsBackground = true };
            this.m_QueryServersThread.Start();
        }
Beispiel #4
0
 /// <summary>
 /// The draw horizontal container.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 /// <param name="horizontalContainer">
 /// The horizontal container.
 /// </param>
 public void DrawHorizontalContainer(
     IRenderContext context, 
     Rectangle layout, 
     HorizontalContainer horizontalContainer)
 {
 }
        public AssetManagerLayout(
            IAssetManagerProvider assetManagerProvider,
            I2DRenderUtilities renderUtilities,
            IAssetLoader[] loaders,
            CanvasEntity canvasEntity)
        {
            this.m_CanvasEntity = canvasEntity;

            var toolbarContainer = new HorizontalContainer();
            toolbarContainer.AddChild(new SingleContainer(), "*");
            toolbarContainer.AddChild(this.Bake = new Button { Text = "Bake" }, "50");
            toolbarContainer.AddChild(this.MarkDirty = new Button { Text = "Mark Dirty" }, "80");

            var assetContainer = new VerticalContainer();
            assetContainer.AddChild(toolbarContainer, "20");
            assetContainer.AddChild(this.EditorContainer = new SingleContainer(), "*");

            var contentContainer = new HorizontalContainer();
            contentContainer.AddChild(this.AssetTree = new TreeView(), "210");
            contentContainer.AddChild(assetContainer, "*");

            var menuContainer = new VerticalContainer();
            menuContainer.AddChild(this.MainMenu = new MainMenu(assetManagerProvider, renderUtilities), "24");
            menuContainer.AddChild(contentContainer, "*");
            menuContainer.AddChild(this.Status = new Label { Text = "..." }, "24");
            this.SetChild(menuContainer);

            var exitItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Exit" };
            var bakeAllItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Bake All" };
            var assetManagerMenuItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Asset Manager" };
            exitItem.Click += (sender, e) =>
            {
                if (this.ExitClick != null)
                    this.ExitClick(sender, e);
            };
            bakeAllItem.Click += (sender, e) =>
            {
                if (this.BakeAllClick != null)
                    this.BakeAllClick(sender, e);
                (bakeAllItem.Parent as MenuItem).Active = false;
            };
            assetManagerMenuItem.AddChild(bakeAllItem);
            assetManagerMenuItem.AddChild(exitItem);
            this.MainMenu.AddChild(assetManagerMenuItem);

            var newAssetMenuItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = "Create New..." };
            foreach (var loader in loaders.Where(x => x.CanNew()))
            {
                var createNewMenuItem = new MenuItem(assetManagerProvider, renderUtilities) { Text = loader.GetType().Name };
                createNewMenuItem.Click += (sender, e) =>
                {
                    if (this.PromptWindow == null)
                    {
                        this.PromptForCreation(loader.GetType().Name, (_, _2) =>
                        {
                            if (this.CreateNameEntered != null)
                                this.CreateNameEntered(this, new CreateEventArgs(loader));
                        });
                    }
                };
                newAssetMenuItem.AddChild(createNewMenuItem);
            }
            this.MainMenu.AddChild(newAssetMenuItem);
        }
        public void PromptForCreation(string createType, EventHandler submit)
        {
            this.PromptName = new TextBox();

            var label = new Label();
            label.Text = "Enter the name of the new " + createType + ":";

            var form = new Form();
            form.AddControl("Name: ", this.PromptName);

            var submitButton = new Button();
            submitButton.Text = "Create";
            submitButton.Click += (sender, e) =>
            {
                submit(sender, e);
                this.m_CanvasEntity.Windows.Remove(this.PromptWindow);
                this.PromptWindow = null;
                this.PromptName = null;
            };

            var cancelButton = new Button();
            cancelButton.Text = "Cancel";
            cancelButton.Click += (sender, e) =>
            {
                this.m_CanvasEntity.Windows.Remove(this.PromptWindow);
                this.PromptWindow = null;
                this.PromptName = null;
            };

            var horizontalContainer = new HorizontalContainer();
            horizontalContainer.AddChild(submitButton, "50%");
            horizontalContainer.AddChild(cancelButton, "50%");

            var verticalContainer = new VerticalContainer();
            verticalContainer.AddChild(label, "24");
            verticalContainer.AddChild(form, "*");
            verticalContainer.AddChild(horizontalContainer, "24");

            this.PromptWindow = new Window();
            this.PromptWindow.Modal = true;
            this.PromptWindow.Bounds = new Microsoft.Xna.Framework.Rectangle(
                (int)this.m_CanvasEntity.Width / 2 - 150,
                (int)this.m_CanvasEntity.Height / 2 - 75,
                300,
                150);
            this.PromptWindow.SetChild(verticalContainer);
            this.m_CanvasEntity.Windows.Add(this.PromptWindow);

            this.MainMenu.Active = false;
            foreach (var item in this.MainMenu.Children.Cast<MenuItem>())
                item.Active = false;
        }
Beispiel #7
0
 /// <summary>
 /// The draw horizontal container.
 /// </summary>
 /// <param name="context">
 /// The context.
 /// </param>
 /// <param name="layout">
 /// The layout.
 /// </param>
 /// <param name="horizontalContainer">
 /// The horizontal container.
 /// </param>
 public void DrawHorizontalContainer(
     IRenderContext context,
     Rectangle layout,
     HorizontalContainer horizontalContainer)
 {
 }
Beispiel #8
0
        public IContainer Process(XmlNode node, Action <UserInterfaceBehaviourEvent, object> eventCallback, out Action <XmlNode, IContainer> processChild)
        {
            IContainer container;

            switch (node?.Attributes?["type"]?.Value)
            {
            case "horizontal":
                var horizontalContainer = new HorizontalContainer();
                processChild = (childNode, childContainer) =>
                {
                    horizontalContainer.AddChild(childContainer, childNode?.Attributes?["width"]?.Value ?? "*");
                };
                container = horizontalContainer;
                break;

            case "vertical":
                var verticalContainer = new VerticalContainer();
                processChild = (childNode, childContainer) =>
                {
                    verticalContainer.AddChild(childContainer, childNode?.Attributes?["height"]?.Value ?? "*");
                };
                container = verticalContainer;
                break;

            case "single":
                var singleContainer = new SingleContainer();
                processChild = (childNode, childContainer) =>
                {
                    singleContainer.SetChild(childContainer);
                };
                container = singleContainer;
                break;

            case "scrollable":
                var scrollableContainer = new ScrollableContainer();
                processChild = (childNode, childContainer) =>
                {
                    scrollableContainer.SetChild(childContainer);
                };
                container = scrollableContainer;
                break;

            case "relative":
                var relativeContainer = new RelativeContainer();
                processChild = (childNode, childContainer) =>
                {
                    relativeContainer.AddChild(childContainer, new Rectangle(
                                                   GetAttribute(childNode, "x"),
                                                   GetAttribute(childNode, "y"),
                                                   GetAttribute(childNode, "width"),
                                                   GetAttribute(childNode, "height")));
                };
                container = relativeContainer;
                break;

            case "adjusted":
                var adjustedContainer = new AdjustedContainer(new Point(
                                                                  GetAttribute(node, "anchorX"),
                                                                  GetAttribute(node, "anchorY")));
                processChild = (childNode, childContainer) =>
                {
                    adjustedContainer.AddChild(childContainer, new Rectangle(
                                                   GetAttribute(childNode, "x"),
                                                   GetAttribute(childNode, "y"),
                                                   GetAttribute(childNode, "width"),
                                                   GetAttribute(childNode, "height")));
                };
                container = adjustedContainer;
                break;

            case "empty":
                container    = new EmptyContainer();
                processChild = (childNode, childContainer) => { };
                break;

            default:
                processChild = (childNode, childContainer) => { };
                return(null);
            }

            return(container);
        }
        public AugmentedBoardGameWorld(
            I2DRenderUtilities twoDRenderUtilities,
            IAssetManagerProvider assetManagerProvider,
            IEntityFactory entityFactory)
        {
            this.Entities = new List<IEntity>();

            _renderUtilities = twoDRenderUtilities;
            _assetManager = assetManagerProvider.GetAssetManager();
            _defaultFont = this._assetManager.Get<FontAsset>("font.Default");

            var canvasEntity = entityFactory.CreateCanvasEntity();

            var pointThresholdTextBox = new TextBox();
            var minPoints = new TextBox();
            var maxPoints = new TextBox();
            var alpha = new TextBox();
            var deviceWidth = new TextBox();
            var deviceHeight = new TextBox();
            var nextColor = new Button() {Text = "Show Next Color "};
            var showDiagnostics = new Button() { Text = "Show Diagnostics" };
            var showBoard = new Button() { Text = "Show Board" };
            var nextDevice = new Button() { Text = "Next Device" };
            var deviceName = new TextBox();
            _fullscreen = new Button() { Text = "Fullscreen 1080" };

            var camera640x480 = new Button() { Text = "Camera 640x480" };
            camera640x480.Click += (sender, args) =>
            {
                deviceWidth.Text = "640";
                deviceHeight.Text = "480";
            };
            var camera720p = new Button() { Text = "Camera 720p" };
            camera720p.Click += (sender, args) =>
            {
                deviceWidth.Text = "1080";
                deviceHeight.Text = "720";
            };
            var camera1080p = new Button() { Text = "Camera 1080p" };
            camera1080p.Click += (sender, args) =>
            {
                deviceWidth.Text = "1920";
                deviceHeight.Text = "1080";
            };

            var pointThresholdEntry = new HorizontalContainer();
            pointThresholdEntry.AddChild(new Label() { Text = "Point Threshold: "}, "100");
            pointThresholdEntry.AddChild(pointThresholdTextBox, "*");

            var minPointsEntry = new HorizontalContainer();
            minPointsEntry.AddChild(new Label() { Text = "Min. Points: " }, "100");
            minPointsEntry.AddChild(minPoints, "*");

            var maxPointsEntry = new HorizontalContainer();
            maxPointsEntry.AddChild(new Label() { Text = "Max. Points: " }, "100");
            maxPointsEntry.AddChild(maxPoints, "*");

            var renderAlphaEntry = new HorizontalContainer();
            renderAlphaEntry.AddChild(new Label() { Text = "Render Alpha: " }, "100");
            renderAlphaEntry.AddChild(alpha, "*");

            var deviceWidthEntry = new HorizontalContainer();
            deviceWidthEntry.AddChild(new Label() { Text = "Device Width: " }, "100");
            deviceWidthEntry.AddChild(deviceWidth, "*");

            var deviceHeightEntry = new HorizontalContainer();
            deviceHeightEntry.AddChild(new Label() { Text = "Device Height: " }, "100");
            deviceHeightEntry.AddChild(deviceHeight, "*");

            var vert = new VerticalContainer();
            vert.AddChild(pointThresholdEntry, "24");
            vert.AddChild(minPointsEntry, "24");
            vert.AddChild(maxPointsEntry, "24");
            vert.AddChild(renderAlphaEntry, "24");
            vert.AddChild(nextColor, "24");
            vert.AddChild(showDiagnostics, "48");
            vert.AddChild(showBoard, "48");
            vert.AddChild(nextDevice, "48");
            vert.AddChild(deviceName, "24");
            vert.AddChild(deviceWidthEntry, "24");
            vert.AddChild(deviceHeightEntry, "24");
            vert.AddChild(_fullscreen, "48");
            vert.AddChild(camera640x480, "48");
            vert.AddChild(camera720p, "48");
            vert.AddChild(camera1080p, "48");

            var hor = new HorizontalContainer();
            hor.AddChild(new EmptyContainer(), "*");
            hor.AddChild(vert, "200");

            var canvas = new Canvas();
            canvas.SetChild(hor);

            canvasEntity.Canvas = canvas;

            var webcamEntity = entityFactory.CreateWebcamEntity(deviceName, deviceWidth, deviceHeight);
            var detectorEntity = entityFactory.CreateDetectorEntity(webcamEntity);
            detectorEntity.X = 0;
            detectorEntity.Y = 0;
            var boardAnalyzerEntity = entityFactory.CreateBoardAnalyzerEntity(detectorEntity, pointThresholdTextBox, minPoints, maxPoints);
            var boardRendererEntity = entityFactory.CreateBoardRendererEntity(boardAnalyzerEntity, webcamEntity, alpha);

            nextColor.Click += (sender, args) =>
            {
                detectorEntity.NextColor();
            };
            showDiagnostics.Click += (sender, args) =>
            {
                alpha.Text = "0";
            };
            showBoard.Click += (sender, args) =>
            {
                alpha.Text = "1";
            };
            nextDevice.Click += (sender, args) =>
            {
                webcamEntity.NextDevice();
            };

            _hasSetupFullscreenButton = false;

            this.Entities.Add(webcamEntity);
            this.Entities.Add(detectorEntity);
            this.Entities.Add(boardAnalyzerEntity);
            this.Entities.Add(canvasEntity);
            this.Entities.Add(boardRendererEntity);
        }