AddElement() public method

Adds a 2d element to this overlay.
Containers are created and managed using the OverlayManager. A container could be as simple as a square panel, or something more complex like a grid or tree view. Containers group collections of other elements, giving them a relative coordinate space and a common z-order. If you want to attach a gui widget to an overlay, you have to do it via a container.
public AddElement ( OverlayElementContainer element ) : void
element OverlayElementContainer
return void
Ejemplo n.º 1
0
		public void CreateScene()
		{
			TextureUtil.CreateDynamicTextureAndMaterial(
				"OBDynamicTexture",
				"OBDynamicMaterial",
				_browserWidth,
				_browserHeight,
				out _texture,
				out _material);



			
			_panel = (OverlayElementContainer)OverlayManager.Instance.Elements.CreateElement("Panel", "Panels");
			_panel.SetPosition(1, 1);
			_panel.SetDimensions(_browserWidth, _browserHeight);
			_panel.MaterialName = "OBDynamicMaterial";


			_overlay = OverlayManager.Instance.Create("OverlayBrowser");
			_overlay.AddElement(_panel);
			_overlay.Show();

			Core.BrowserManager.BrowserRenderEvent += BrowserManager_BrowserRenderEvent;
			_browserId = Core.BrowserManager.CreateBrowser("http://www.google.com.au", _browserWidth, _browserHeight);
		}
Ejemplo n.º 2
0
 public TopBar(string name, string defaultLocation)
 {
     _name = name;
     _defaultLocation = defaultLocation;
     _topBar = OverlayManager.Instance.Create("Overlays/TopBar/" + _name);
     _topBarElement = CreateTopBarElement();
     SetLocationText(_defaultLocation);
     _topBar.AddElement(_topBarElement);
 }
Ejemplo n.º 3
0
 public MessageDialog(string name, int width)
 {
     _name = name;
     _dialogWidth = width;
     _dialog = OverlayManager.Instance.Create("Overlays/MessageDialog/" + _name);
     _dialogElement = CreateDialogElement();
     _dialog.AddElement(_dialogElement);
     ResizeElement();
 }
Ejemplo n.º 4
0
 public Inventory(string name, float x, float y, int slotCount, int slotCountX, InventoryModel model)
 {
     _name = name;
     _slotCount = slotCount;
     _inventory = OverlayManager.Instance.Create("Overlays/Inventory/" + _name);
     _model = model;
     _modelChangeTimestamp = -1;
     var inventoryElement = CreateOverlayElementContainer(x, y, slotCountX);
     _inventory.AddElement(inventoryElement);
 }
Ejemplo n.º 5
0
        /// <summary>
        ///    Parses a new element
        /// </summary>
        /// <param name="script"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        /// <param name="isContainer"></param>
        /// <param name="overlay"></param>
        /// <param name="isTemplate"></param>
        /// <param name="templateName"></param>
        /// <param name="parent"></param>
        private void ParseNewElement(TextReader script, string type, string name, bool isContainer, Overlay overlay,
                                     bool isTemplate, string templateName, OverlayElementContainer parent)
        {
            string line;
            var    element = OverlayElementManager.Instance.CreateElementFromTemplate(templateName, type, name, isTemplate);

            if (parent != null)
            {
                // add this element to the parent container
                parent.AddChild(element);
            }
            else if (overlay != null)
            {
                overlay.AddElement((OverlayElementContainer)element);
            }

            while ((line = ParseHelper.ReadLine(script)) != null)
            {
                // inore blank lines and comments
                if (line.Length > 0 && (!line.StartsWith("//") && !line.StartsWith("# ")))
                {
                    if (line == "}")
                    {
                        // finished element
                        break;
                    }
                    else
                    {
                        OverlayElementContainer container = null;
                        if (element is OverlayElementContainer)
                        {
                            container = (OverlayElementContainer)element;
                        }
                        if (isContainer && ParseChildren(script, line, overlay, isTemplate, container))
                        {
                            // nested children, so don't reparse it
                        }
                        else
                        {
                            // element attribute
                            ParseElementAttrib(line, overlay, element);
                        }
                    }
                }
            }
        }
        /// <summary>
        ///    Parses a new element
        /// </summary>
        /// <param name="script"></param>
        /// <param name="type"></param>
        /// <param name="name"></param>
        /// <param name="isContainer"></param>
        /// <param name="overlay"></param>
        /// <param name="isTemplate"></param>
        /// <param name="templateName"></param>
        /// <param name="parent"></param>
        private void ParseNewElement(TextReader script, string type, string name, bool isContainer, Overlay overlay, bool isTemplate,
            string templateName, OverlayElementContainer parent)
        {
            string line;
            OverlayElement element = OverlayElementManager.Instance.CreateElementFromTemplate(templateName, type, name, isTemplate);

            if(parent != null) {
                // add this element to the parent container
                parent.AddChild(element);
            }
            else if(overlay != null) {
                overlay.AddElement((OverlayElementContainer)element);
            }

            while((line = ParseHelper.ReadLine(script)) != null) {
                // inore blank lines and comments
                if(line.Length > 0 && !line.StartsWith("//")) {
                    if(line == "}") {
                        // finished element
                        break;
                    }
                    else {
                        if(isContainer && ParseChildren(script, line, overlay, isTemplate, (OverlayElementContainer)element)) {
                            // nested children, so don't reparse it
                        }
                        else {
                            // element attribute
                            ParseElementAttrib(line, overlay, element);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void EnterHandler()
        {
            Globals.UI.ShowMouse();

            if (_topBarView == null)
            {
                _topBarView = new TopBarView("Docked", _baseName);
            }

            if (_interactionView == null)
            {
                _interactionView = new InteractionView("Docked", 320, 500);
            }

            _interactionView.AddHeader("creatures", "CREATURES");
            _interactionView.AddItem("TestInstance", "Portrait", "[RK] Gom", "Guild Master", "Small", "Default", "", () => { InteractionListElementClicked("Creature"); });
            _interactionView.AddItem("TestInstance2", "Portrait", "[RK] Chapelier", "Lord of The Code", "Small", "Default", "", () => { InteractionListElementClicked("Creature"); });
            _interactionView.AddHeader("ships", "SHIPS");
            _interactionView.AddItem("TestShip", "Portrait", "Nautilus", "Small Fighter", "Small", "DefaultShip", "", () => { InteractionListElementClicked("Ship"); });

            if (_leftVerticalBar == null)
            {
                _leftVerticalBar = OverlayManager.Instance.Create("Overlays/LeftVerticalBar/Docked");
                _leftVerticalBarElement = CreateLeftVerticalBarElement();
                _leftVerticalBarElement.AddChildElement(_interactionView.ListElement);
                _interactionView.ListElement.VerticalAlignment = VerticalAlignment.Center;
                _interactionView.ListElement.Top = -(_interactionView.AbsoluteContentHeight / 2);
                _leftVerticalBar.AddElement(_leftVerticalBarElement);
            }

            _topBarView.AddButton("bar", "BAR (F1)", MoveToBar);
            _topBarView.AddButton("shopping", "SHOPS (F2)", MoveToShopping);
            _topBarView.AddButton("hangar", "HANGAR (F3)", MoveToHangar);
            _topBarView.AddButton("leave", "LEAVE (F4)", Leave);

            MoveToHangar();
        }
Ejemplo n.º 8
0
		/// <summary>
		/// Creates backdrop, cursor, and trays.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="window"></param>
		/// <param name="mouse"></param>
		/// <param name="listener"></param>
		public SdkTrayManager( String name, RenderWindow window, SIS.Mouse mouse, ISdkTrayListener listener )
		{
			mName = name;
			mWindow = window;
			this.Mouse = mouse;
			Listener = listener;

			mWidgetPadding = 8;
			mWidgetSpacing = 2;

			OverlayManager om = OverlayManager.Instance;

			String nameBase = mName + "/";
			nameBase.Replace( ' ', '_' );

			// create overlay layers for everything

			this.BackdropLayer = om.Create( nameBase + "BackdropLayer" );
			mTraysLayer = om.Create( nameBase + "WidgetsLayer" );
			mPriorityLayer = om.Create( nameBase + "PriorityLayer" );
			cursorLayer = om.Create( nameBase + "CursorLayer" );
			this.BackdropLayer.ZOrder = 100;
			mTraysLayer.ZOrder = 200;
			mPriorityLayer.ZOrder = 300;
			cursorLayer.ZOrder = 400;

			// make backdrop and cursor overlay containers

			cursor = (OverlayElementContainer)om.Elements.CreateElementFromTemplate( "SdkTrays/Cursor", "Panel", nameBase + "Cursor" );
			cursorLayer.AddElement( cursor );
			backdrop = (OverlayElementContainer)om.Elements.CreateElement( "Panel", nameBase + "Backdrop" );
			this.BackdropLayer.AddElement( backdrop );
			mDialogShade = (OverlayElementContainer)om.Elements.CreateElement( "Panel", nameBase + "DialogShade" );
			mDialogShade.MaterialName = "SdkTrays/Shade";
			mDialogShade.Hide();
			mPriorityLayer.AddElement( mDialogShade );

			String[] trayNames = {
									 "TopLeft", "Top", "TopRight", "Left", "Center", "Right", "BottomLeft", "Bottom", "BottomRight"
								 };

			for ( int i = 0; i < 9; i++ ) // make the real trays
			{
				mTrays[ i ] = (OverlayElementContainer)om.Elements.CreateElementFromTemplate( "SdkTrays/Tray", "BorderPanel", nameBase + trayNames[ i ] + "Tray" );

				mTraysLayer.AddElement( mTrays[ i ] );

				trayWidgetAlign[ i ] = HorizontalAlignment.Center;

				// align trays based on location
				if ( i == (int)TrayLocation.Top || i == (int)TrayLocation.Center || i == (int)TrayLocation.Bottom )
					mTrays[ i ].HorizontalAlignment = HorizontalAlignment.Center;
				if ( i == (int)TrayLocation.Left || i == (int)TrayLocation.Center || i == (int)TrayLocation.Right )
					mTrays[ i ].VerticalAlignment = VerticalAlignment.Center;
				if ( i == (int)TrayLocation.TopRight || i == (int)TrayLocation.Right || i == (int)TrayLocation.BottomRight )
					mTrays[ i ].HorizontalAlignment = HorizontalAlignment.Right;
				if ( i == (int)TrayLocation.BottomLeft || i == (int)TrayLocation.Bottom || i == (int)TrayLocation.BottomRight )
					mTrays[ i ].VerticalAlignment = VerticalAlignment.Bottom;
			}

			// create the null tray for free-floating widgets
			mTrays[ 9 ] = (OverlayElementContainer)om.Elements.CreateElement( "Panel", nameBase + "NullTray" );
			trayWidgetAlign[ 9 ] = HorizontalAlignment.Left;
			mTraysLayer.AddElement( mTrays[ 9 ] );

			for ( int i = 0; i < mWidgets.Length; i++ )
			{
				mWidgets[ i ] = new WidgetList();
			}

			this.AdjustTrays();

			ShowTrays();
			ShowCursor();
		}