Ejemplo n.º 1
0
        public AGSButton(string id, Resolver resolver) : base(id, resolver)
        {            
            _uIEvents = AddComponent<IUIEvents>();            
            _skinComponent = AddComponent<ISkinComponent>();            
            _hasRoom = AddComponent<IHasRoom>();            
            _animationContainer = AddComponent<IAnimationContainer>();            
            _inObjectTree = AddComponent<IInObjectTree>();            
            _collider = AddComponent<ICollider>();            
            _visibleComponent = AddComponent<IVisibleComponent>();            
            _enabledComponent = AddComponent<IEnabledComponent>();            
            _customProperties = AddComponent<ICustomPropertiesComponent>();            
            _drawableInfo = AddComponent<IDrawableInfo>();            
            _hotspotComponent = AddComponent<IHotspotComponent>();            
            _shaderComponent = AddComponent<IShaderComponent>();            
            _translateComponent = AddComponent<ITranslateComponent>();            
            _imageComponent = AddComponent<IImageComponent>();            
            _scaleComponent = AddComponent<IScaleComponent>();            
            _rotateComponent = AddComponent<IRotateComponent>();            
            _pixelPerfectComponent = AddComponent<IPixelPerfectComponent>();            
            _textComponent = AddComponent<ITextComponent>();            
            _buttonComponent = AddComponent<IButtonComponent>();
			beforeInitComponents(resolver);            
			InitComponents();
            afterInitComponents(resolver);            
        }
Ejemplo n.º 2
0
 public AGSButton(string id, Resolver resolver) : base(id, resolver)
 {
     _uIEvents              = AddComponent <IUIEvents>();
     _skinComponent         = AddComponent <ISkinComponent>();
     _hasRoom               = AddComponent <IHasRoom>();
     _animationContainer    = AddComponent <IAnimationContainer>();
     _inObjectTree          = AddComponent <IInObjectTree>();
     _collider              = AddComponent <ICollider>();
     _visibleComponent      = AddComponent <IVisibleComponent>();
     _enabledComponent      = AddComponent <IEnabledComponent>();
     _customProperties      = AddComponent <ICustomPropertiesComponent>();
     _drawableInfo          = AddComponent <IDrawableInfo>();
     _hotspotComponent      = AddComponent <IHotspotComponent>();
     _shaderComponent       = AddComponent <IShaderComponent>();
     _translateComponent    = AddComponent <ITranslateComponent>();
     _imageComponent        = AddComponent <IImageComponent>();
     _scaleComponent        = AddComponent <IScaleComponent>();
     _rotateComponent       = AddComponent <IRotateComponent>();
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     _textComponent         = AddComponent <ITextComponent>();
     _buttonComponent       = AddComponent <IButtonComponent>();
     _modelMatrixComponent  = AddComponent <IModelMatrixComponent>();
     beforeInitComponents(resolver);
     InitComponents();
     afterInitComponents(resolver);
 }
		public void Setup(IButtonComponent component) {

			var tipButton = component as ButtonWithTipComponent;
			if (tipButton == null) return;

			if (this.IsChanged(ParameterFlag.P13) == true) tipButton.keyTooltipNormal = this.keyTooltipNormal;
			if (this.IsChanged(ParameterFlag.P14) == true) tipButton.keyTooltipDisabled = this.keyTooltipDisabled;
			if (this.IsChanged(ParameterFlag.P15) == true) tipButton.tipShowPriority = this.tipShowPriority;

		}
Ejemplo n.º 4
0
 public AGSButton(string id, Resolver resolver) : base(id, resolver)
 {
     _uIEvents = AddComponent <IUIEvents>();
     Bind <IUIEvents>(c => _uIEvents = c, _ => {});
     _skinComponent = AddComponent <ISkinComponent>();
     Bind <ISkinComponent>(c => _skinComponent = c, _ => {});
     _hasRoomComponent = AddComponent <IHasRoomComponent>();
     Bind <IHasRoomComponent>(c => _hasRoomComponent = c, _ => {});
     _animationComponent = AddComponent <IAnimationComponent>();
     Bind <IAnimationComponent>(c => _animationComponent = c, _ => {});
     _inObjectTreeComponent = AddComponent <IInObjectTreeComponent>();
     Bind <IInObjectTreeComponent>(c => _inObjectTreeComponent = c, _ => {});
     _colliderComponent = AddComponent <IColliderComponent>();
     Bind <IColliderComponent>(c => _colliderComponent = c, _ => {});
     _visibleComponent = AddComponent <IVisibleComponent>();
     Bind <IVisibleComponent>(c => _visibleComponent = c, _ => {});
     _enabledComponent = AddComponent <IEnabledComponent>();
     Bind <IEnabledComponent>(c => _enabledComponent = c, _ => {});
     _customPropertiesComponent = AddComponent <ICustomPropertiesComponent>();
     Bind <ICustomPropertiesComponent>(c => _customPropertiesComponent = c, _ => {});
     _drawableInfoComponent = AddComponent <IDrawableInfoComponent>();
     Bind <IDrawableInfoComponent>(c => _drawableInfoComponent = c, _ => {});
     _shaderComponent = AddComponent <IShaderComponent>();
     Bind <IShaderComponent>(c => _shaderComponent = c, _ => {});
     _translateComponent = AddComponent <ITranslateComponent>();
     Bind <ITranslateComponent>(c => _translateComponent = c, _ => {});
     _imageComponent = AddComponent <IImageComponent>();
     Bind <IImageComponent>(c => _imageComponent = c, _ => {});
     _borderComponent = AddComponent <IBorderComponent>();
     Bind <IBorderComponent>(c => _borderComponent = c, _ => { });
     _scaleComponent = AddComponent <IScaleComponent>();
     Bind <IScaleComponent>(c => _scaleComponent = c, _ => {});
     _rotateComponent = AddComponent <IRotateComponent>();
     Bind <IRotateComponent>(c => _rotateComponent = c, _ => {});
     _pixelPerfectComponent = AddComponent <IPixelPerfectComponent>();
     Bind <IPixelPerfectComponent>(c => _pixelPerfectComponent = c, _ => {});
     _modelMatrixComponent = AddComponent <IModelMatrixComponent>();
     Bind <IModelMatrixComponent>(c => _modelMatrixComponent = c, _ => {});
     _boundingBoxComponent = AddComponent <IBoundingBoxComponent>();
     Bind <IBoundingBoxComponent>(c => _boundingBoxComponent = c, _ => {});
     _worldPositionComponent = AddComponent <IWorldPositionComponent>();
     Bind <IWorldPositionComponent>(c => _worldPositionComponent = c, _ => {});
     _textComponent = AddComponent <ITextComponent>();
     Bind <ITextComponent>(c => _textComponent = c, _ => {});
     _buttonComponent = AddComponent <IButtonComponent>();
     Bind <IButtonComponent>(c => _buttonComponent = c, _ => {});
     beforeInitComponents(resolver);
     InitComponents();
     afterInitComponents(resolver);
 }
Ejemplo n.º 5
0
        public void OnSelect(int index)
        {
            if (this.previousDot != null)
            {
                this.previousDot.SetEnabled();
            }

            var button = this.GetItem <IButtonComponent>(index);

            if (button != null)
            {
                this.previousDot = button;
                button.SetDisabled();
            }
        }
		public void Setup(IButtonComponent component) {
			
			if (this.IsChanged(ParameterFlag.P1) == true) component.SetEnabledState(this.interactableByDefault);
			if (this.IsChanged(ParameterFlag.P2) == true) {

				component.SetCallback(() => this.callback.Invoke());

			}
			
			if (this.IsChanged(ParameterFlag.P3) == true) component.SetHoverState(this.hoverIsActive);
			if (this.IsChanged(ParameterFlag.P4) == true) component.SetHoverOnAnyPointerState(this.hoverOnAnyPointerState);

			if (this.IsChanged(ParameterFlag.P5) == true) {
				
				component.SetCallbackHover((state) => {
					
					if (state == true) {
						
						this.hoverInCallback.Invoke();
						
					}
					
				});

			}

			if (this.IsChanged(ParameterFlag.P6) == true) {

				component.SetCallbackHover((state) => {

					if (state == false) {

						this.hoverOutCallback.Invoke();

					}

				});

			}
			
			if (this.IsChanged(ParameterFlag.P7) == true) component.SetSFX(PointerEventState.Click, this.sfxOnClick);
			if (this.IsChanged(ParameterFlag.P8) == true) component.SetSFX(PointerEventState.Enter, this.sfxOnEnter);
			if (this.IsChanged(ParameterFlag.P9) == true) component.SetSFX(PointerEventState.Leave, this.sfxOnLeave);
			if (this.IsChanged(ParameterFlag.P10) == true) component.SetHoverOnAnyButtonState(this.hoverOnAnyButtonState);
			if (this.IsChanged(ParameterFlag.P11) == true) component.SetSelectByDefault(this.selectByDefault);
			if (this.IsChanged(ParameterFlag.P12) == true) component.SetNavigationMode(this.navigationMode);

		}
Ejemplo n.º 7
0
        public void Select(int index, bool closePopup = true)
        {
            if (index < 0)
            {
                this.label.SetText(string.Empty);
                this.selectedIndex = -1;
                return;
            }

            IButtonComponent prevText = null;

            if (this.selectedIndex >= 0)
            {
                prevText = this.items.GetItem <IButtonComponent>(this.selectedIndex);
            }
            var text = this.items.GetItem <ITextComponent>(index);

            this.selectedIndex = index;
            this.label.SetText(text.GetText());

            if (prevText != null)
            {
                prevText.SetEnabled();
            }

            var selectable = text as IButtonComponent;

            if (selectable != null)
            {
                selectable.SetDisabled();
            }

            if (closePopup == true)
            {
                this.SetState(opened: false, immediately: false);
            }

            if (this.callback != null)
            {
                this.callback.Invoke();
            }
            if (this.callbackButton != null)
            {
                this.callbackButton.Invoke(this.GetItem <ITextComponent>(index) as ButtonComponent);
            }
        }
Ejemplo n.º 8
0
        public WindowComponentNavigation GetNavigation(bool interactableOnly, System.Func <WindowComponentNavigation, WindowComponentNavigation> getter)
        {
            var item = getter.Invoke(this);

            if (interactableOnly == true)
            {
                while (item != null)
                {
                    IButtonComponent button = null;
                    if (item is LinkerComponent)
                    {
                        button = (item as LinkerComponent).Get <IButtonComponent>();
                    }
                    else
                    {
                        button = item as IButtonComponent;
                    }

                    if (button == null || button.IsInteractable() == false)
                    {
                        item = getter.Invoke(item);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (item == null)
            {
                // search in root element
                if (this.rootComponent != null && this.rootComponent is IWindowNavigation)
                {
                    item = (this.rootComponent as IWindowNavigation).GetNavigation(interactableOnly, getter);
                }
            }

            return(item);
        }
Ejemplo n.º 9
0
        public void Setup(IButtonComponent component)
        {
            var tipButton = component as ButtonWithTipComponent;

            if (tipButton == null)
            {
                return;
            }

            if (this.IsChanged(ParameterFlag.P13) == true)
            {
                tipButton.keyTooltipNormal = this.keyTooltipNormal;
            }
            if (this.IsChanged(ParameterFlag.P14) == true)
            {
                tipButton.keyTooltipDisabled = this.keyTooltipDisabled;
            }
            if (this.IsChanged(ParameterFlag.P15) == true)
            {
                tipButton.tipShowPriority = this.tipShowPriority;
            }
        }
Ejemplo n.º 10
0
        private void CreateConnectUi()
        {
            // Now we can start adding individual components to our UI
            // Keep track of current x and y of objects we want to place
            var x = 1920f - 210.0f;
            var y = 1080f - 75.0f;

            new TextComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 30),
                "Multiplayer",
                FontManager.UIFontRegular,
                24
                );

            y -= 30;

            new DividerComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 1)
                );

            y -= 30;

            new TextComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 30),
                "Join Server",
                FontManager.UIFontRegular,
                18
                );

            y -= 40;

            _addressInput = new HiddenInputComponent(
                _connectGroup,
                new Vector2(x, y),
                _modSettings.JoinAddress,
                "IP Address"
                );

            y -= 40;

            var joinPort = _modSettings.JoinPort;

            _portInput = new InputComponent(
                _connectGroup,
                new Vector2(x, y),
                joinPort == -1 ? "" : joinPort.ToString(),
                "Port",
                characterValidation: InputField.CharacterValidation.Integer
                );

            y -= 40;

            var username = _modSettings.Username;

            _usernameInput = new InputComponent(
                _connectGroup,
                new Vector2(x, y),
                username,
                "Username"
                );

            y -= 40;

            var clientSettingsButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Settings"
                );

            clientSettingsButton.SetOnPress(() => {
                _connectGroup.SetActive(false);
                _clientSettingsGroup.SetActive(true);
            });

            y -= 40;

            _connectButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Connect"
                );
            _connectButton.SetOnPress(OnConnectButtonPressed);

            _disconnectButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Disconnect"
                );
            _disconnectButton.SetOnPress(OnDisconnectButtonPressed);
            _disconnectButton.SetActive(false);

            y -= 40;

            _clientFeedbackText = new TextComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 30),
                "",
                FontManager.UIFontBold,
                15
                );
            _clientFeedbackText.SetActive(false);

            y -= 30;

            new DividerComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 1)
                );

            y -= 30;

            new TextComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 30),
                "Host Server",
                FontManager.UIFontRegular,
                18
                );

            y -= 40;

            var serverSettingsButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Host Settings"
                );

            serverSettingsButton.SetOnPress(() => {
                _connectGroup.SetActive(false);
                _serverSettingsGroup.SetActive(true);
            });

            y -= 40;

            _startButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Start Hosting"
                );
            _startButton.SetOnPress(OnStartButtonPressed);

            _stopButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Stop Hosting"
                );
            _stopButton.SetOnPress(OnStopButtonPressed);
            _stopButton.SetActive(false);

            y -= 40;

            _serverFeedbackText = new TextComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(200, 30),
                "",
                FontManager.UIFontBold,
                15
                );
            _serverFeedbackText.SetActive(false);

            // Register a callback for when the connection is successful or failed or disconnects
            _clientManager.RegisterOnDisconnect(OnClientDisconnect);
            _clientManager.RegisterOnConnect(OnSuccessfulConnect);
            _clientManager.RegisterOnConnectFailed(OnFailedConnect);
        }
Ejemplo n.º 11
0
        public virtual T AddItem <T>(Navigation.Mode navigationMode, bool navigationInverse) where T : IComponent
        {
            if (this.source == null)
            {
                return(default(T));
            }

            var instance = this.GetInstance(this.Count());

            if (instance == null)
            {
                return(default(T));
            }

            if (this.scrollRect != null && this.scrollRect.content != null)
            {
                instance.SetParent(this.scrollRect.content, setTransformAsSource: false);
            }
            else if (this.content != null)
            {
                instance.SetParent(this.content.transform, setTransformAsSource: false);
            }

            if (instance is LinkerComponent)
            {
                //instance.OnInit();
                instance.gameObject.SetActive(true);
                instance = (instance as LinkerComponent).Get <WindowComponent>();
            }

            if (instance != null)
            {
                instance.gameObject.SetActive(true);
            }

            #region Navigation
            if (this.lastSelectableInstance != instance)
            {
                if (navigationMode != Navigation.Mode.None)
                {
                    var selectableComp = instance as IButtonComponent;
                    if (selectableComp != null)
                    {
                        var selectable = selectableComp.GetSelectable();
                        if (selectable != null)
                        {
                            var nav = selectable.navigation;

                            if (navigationMode == Navigation.Mode.Automatic)
                            {
                                nav.mode = Navigation.Mode.Automatic;

                                selectable.navigation = nav;
                            }
                            else
                            {
                                nav.mode = Navigation.Mode.Explicit;

                                if (navigationMode == Navigation.Mode.Vertical ||
                                    navigationMode == Navigation.Mode.Horizontal)
                                {
                                    var prevSelectableComp = this.lastSelectableInstance;
                                    if (prevSelectableComp != null)
                                    {
                                        var prevSelectable = prevSelectableComp.GetSelectable();
                                        if (prevSelectable != null)
                                        {
                                            nav               = new Navigation();
                                            nav.mode          = Navigation.Mode.Explicit;
                                            nav.selectOnDown  = selectable.navigation.selectOnDown;
                                            nav.selectOnLeft  = selectable.navigation.selectOnLeft;
                                            nav.selectOnRight = selectable.navigation.selectOnRight;
                                            nav.selectOnUp    = selectable.navigation.selectOnUp;

                                            if (navigationInverse == false)
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnLeft = prevSelectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnDown = prevSelectable;
                                                }
                                            }
                                            else
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnRight = prevSelectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnUp = prevSelectable;
                                                }
                                            }
                                            selectable.navigation = nav;

                                            nav               = new Navigation();
                                            nav.mode          = Navigation.Mode.Explicit;
                                            nav.selectOnDown  = prevSelectable.navigation.selectOnDown;
                                            nav.selectOnLeft  = prevSelectable.navigation.selectOnLeft;
                                            nav.selectOnRight = prevSelectable.navigation.selectOnRight;
                                            nav.selectOnUp    = prevSelectable.navigation.selectOnUp;

                                            if (navigationInverse == false)
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnRight = selectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnUp = selectable;
                                                }
                                            }
                                            else
                                            {
                                                if (navigationMode == Navigation.Mode.Horizontal)
                                                {
                                                    nav.selectOnLeft = selectable;
                                                }
                                                else
                                                {
                                                    nav.selectOnDown = selectable;
                                                }
                                            }
                                            prevSelectable.navigation = nav;
                                        } // Last selectable found
                                    }     // Last component not null
                                }         // Vertical or Horizontal
                            }             // Mode not Auto
                        }                 // Selectable found
                    }                     // Component not null

                    this.lastSelectableInstance = selectableComp;
                }                 // Navigation not None
            }
            #endregion

            this.Refresh();

            this.OnNewItem(instance);

            return((T)(instance as IComponent));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Create the connection UI.
        /// </summary>
        private void CreateConnectUi()
        {
            // Now we can start adding individual components to our UI
            // Keep track of current x and y of objects we want to place
            var x = 1920f - 210f;
            var y = 1080f - 100f;

            const float labelHeight = 20f;
            const float logoHeight  = 74f;

            new ImageComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(240f, logoHeight),
                TextureManager.HkmpLogo
                );

            y -= logoHeight / 2f + 20f;

            new TextComponent(
                _connectGroup,
                new Vector2(x + TextIndentWidth, y),
                new Vector2(212f, labelHeight),
                "Username",
                UiManager.NormalFontSize,
                alignment: TextAnchor.MiddleLeft
                );

            y -= labelHeight + 14f;

            _usernameInput = new InputComponent(
                _connectGroup,
                new Vector2(x, y),
                _modSettings.Username,
                "Username",
                characterLimit: 20
                );

            y -= InputComponent.DefaultHeight + 20f;

            new TextComponent(
                _connectGroup,
                new Vector2(x + TextIndentWidth, y),
                new Vector2(212f, labelHeight),
                "Server IP and port",
                UiManager.NormalFontSize,
                alignment: TextAnchor.MiddleLeft
                );

            y -= labelHeight + 14f;

            _addressInput = new IpInputComponent(
                _connectGroup,
                new Vector2(x, y),
                _modSettings.ConnectAddress,
                "IP Address"
                );

            y -= InputComponent.DefaultHeight + 8f;

            var joinPort = _modSettings.ConnectPort;

            _portInput = new PortInputComponent(
                _connectGroup,
                new Vector2(x, y),
                joinPort == -1 ? "" : joinPort.ToString(),
                "Port"
                );

            y -= InputComponent.DefaultHeight + 20f;

            _connectionButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                ConnectText
                );
            _connectionButton.SetOnPress(OnConnectButtonPressed);

            y -= ButtonComponent.DefaultHeight + 8f;

            _serverButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                StartHostingText
                );
            _serverButton.SetOnPress(OnStartButtonPressed);

            y -= ButtonComponent.DefaultHeight + 8f;

            var settingsButton = new ButtonComponent(
                _connectGroup,
                new Vector2(x, y),
                "Settings"
                );

            settingsButton.SetOnPress(() => {
                _connectGroup.SetActive(false);
                _settingsGroup.SetActive(true);
            });

            y -= ButtonComponent.DefaultHeight + 8f;

            _feedbackText = new TextComponent(
                _connectGroup,
                new Vector2(x, y),
                new Vector2(240f, labelHeight),
                new Vector2(0.5f, 1f),
                "",
                UiManager.SubTextFontSize,
                alignment: TextAnchor.UpperCenter
                );
            _feedbackText.SetActive(false);
        }
        public virtual void Setup(IButtonComponent component)
        {
            if (this.IsChanged(ParameterFlag.P1) == true)
            {
                component.SetEnabledState(this.interactableByDefault);
            }

            if (this.IsChanged(ParameterFlag.P3) == true)
            {
                component.SetHoverState(this.hoverIsActive);
            }
            if (this.IsChanged(ParameterFlag.P4) == true)
            {
                component.SetHoverOnAnyPointerState(this.hoverOnAnyPointerState);
            }

            if (this.IsChanged(ParameterFlag.P5) == true)
            {
                component.SetCallbackHover((state) => {
                    if (state == true)
                    {
                        this.hoverInCallback.Invoke();
                    }
                });
            }

            if (this.IsChanged(ParameterFlag.P6) == true)
            {
                component.SetCallbackHover((state) => {
                    if (state == false)
                    {
                        this.hoverOutCallback.Invoke();
                    }
                });
            }

            if (this.IsChanged(ParameterFlag.P7) == true)
            {
                component.SetSFX(PointerEventState.Click, this.sfxOnClick);
            }
            if (this.IsChanged(ParameterFlag.P8) == true)
            {
                component.SetSFX(PointerEventState.Enter, this.sfxOnEnter);
            }
            if (this.IsChanged(ParameterFlag.P9) == true)
            {
                component.SetSFX(PointerEventState.Leave, this.sfxOnLeave);
            }
            if (this.IsChanged(ParameterFlag.P10) == true)
            {
                component.SetHoverOnAnyButtonState(this.hoverOnAnyButtonState);
            }
            if (this.IsChanged(ParameterFlag.P11) == true)
            {
                component.SetSelectByDefault(this.selectByDefault);
            }
            if (this.IsChanged(ParameterFlag.P12) == true)
            {
                component.SetNavigationMode(this.navigationMode);
            }
        }