private ButtonAnimation getAnimation(IBorderComponent container, ButtonAnimation animation) { if (animation.Border == null || container == null || container.Border == null) { return(animation); } ButtonAnimation newAnimation = new ButtonAnimation(animation.Animation, animation.Image, _factory.Borders.Multiple(container.Border, animation.Border), animation.TextConfig, animation.Tint); return(newAnimation); }
public AGSCharacter(string id, Resolver resolver, IOutfit outfit) : base(id, resolver) { _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, _ => {}); _faceDirectionComponent = AddComponent <IFaceDirectionComponent>(); Bind <IFaceDirectionComponent>(c => _faceDirectionComponent = c, _ => {}); _outfitComponent = AddComponent <IOutfitComponent>(); Bind <IOutfitComponent>(c => _outfitComponent = c, _ => {}); _inventoryComponent = AddComponent <IInventoryComponent>(); Bind <IInventoryComponent>(c => _inventoryComponent = c, _ => {}); _followComponent = AddComponent <IFollowComponent>(); Bind <IFollowComponent>(c => _followComponent = c, _ => {}); _hotspotComponent = AddComponent <IHotspotComponent>(); Bind <IHotspotComponent>(c => _hotspotComponent = c, _ => {}); beforeInitComponents(resolver, outfit); InitComponents(); afterInitComponents(resolver, outfit); }
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); }
public override void Init(IEntity entity) { base.Init(entity); _entity = entity; entity.Bind <ITextComponent>(c => { _textComponent = c; c.PropertyChanged += onTextPropertyChanged; }, c => { _textComponent = null; c.PropertyChanged -= onTextPropertyChanged; }); entity.Bind <IUIEvents>(c => { _uiEvents = c; c.MouseDown.Subscribe(onMouseDown); c.LostFocus.Subscribe(onMouseDownOutside); }, c => { _uiEvents = null; c.MouseDown.Unsubscribe(onMouseDown); c.LostFocus.Unsubscribe(onMouseDownOutside); }); entity.Bind <IInObjectTreeComponent>(c => _tree = c, _ => _tree = null); entity.Bind <IHasRoomComponent>(c => _room = c, _ => _room = null); entity.Bind <IVisibleComponent>(c => _visibleComponent = c, _ => _visibleComponent = null); _caretFlashCounter = (int)CaretFlashDelay; _withCaret = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, config: new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText)); _withCaret.Pivot = new PointF(0f, 0f); _withCaret.TextBackgroundVisible = false; entity.Bind <IImageComponent>(c => _imageComponent = c, _ => _imageComponent = null); entity.Bind <IBorderComponent>(c => _borderComponent = c, _ => _borderComponent = null); entity.Bind <IDrawableInfoComponent>(c => { _drawableComponent = c; c.PropertyChanged += onDrawableChanged; onRenderLayerChanged(); }, c => { c.PropertyChanged -= onDrawableChanged; _drawableComponent = null; }); _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute); }
public override void Init() { base.Init(); Entity.Bind <IAnimationComponent>(c => _animation = c, _ => _animation = null); Entity.Bind <ITextComponent>(c => _text = c, _ => _text = null); Entity.Bind <IImageComponent>(c => _image = c, _ => _image = null); Entity.Bind <IBorderComponent>(c => _border = c, _ => _border = null); Entity.Bind <IUIEvents>(c => { _events = c; c.MouseEnter.Subscribe(onMouseEnter); c.MouseLeave.Subscribe(onMouseLeave); c.MouseUp.Subscribe(onMouseUp); }, c => { _events = null; c.MouseEnter.Unsubscribe(onMouseEnter); c.MouseLeave.Unsubscribe(onMouseLeave); c.MouseUp.Unsubscribe(onMouseUp); }); }
private void selectObject(ITreeStringNode node) { var obj = node.Properties.Entities.GetValue(Fields.Entity); _inspector.Inspector.Show(obj); var visibleComponent = obj.GetComponent <IVisibleComponent>(); var image = obj.GetComponent <IImageComponent>(); var borderComponent = obj.GetComponent <IBorderComponent>(); if (image != null && borderComponent != null) { _lastSelectedBorder = borderComponent; IBorderStyle border = null; border = borderComponent.Border; _lastObjectBorder = border; IBorderStyle hoverBorder = AGSBorders.Gradient(new FourCorners <Color>(Colors.Yellow, Colors.Yellow.WithAlpha(150), Colors.Yellow.WithAlpha(150), Colors.Yellow), 1, true); if (border == null) { borderComponent.Border = hoverBorder; } else { borderComponent.Border = AGSBorders.Multiple(border, hoverBorder); } if (image.Opacity == 0) { _lastOpacity = image.Opacity; _lastSelectedMaskImage = image; image.Opacity = 100; } } if (visibleComponent != null) { _lastMaskVisible = visibleComponent.Visible; _lastSelectedMaskVisible = visibleComponent; visibleComponent.Visible = true; } }
private void unselect() { var lastSelectedBorder = _lastSelectedBorder; var lastSelectedMaskVisible = _lastSelectedMaskVisible; var lastSelectedMaskImage = _lastSelectedMaskImage; if (lastSelectedBorder != null) { lastSelectedBorder.Border = _lastObjectBorder; } if (lastSelectedMaskVisible != null) { lastSelectedMaskVisible.Visible = _lastMaskVisible; } if (lastSelectedMaskImage != null) { lastSelectedMaskImage.Opacity = _lastOpacity; } _lastSelectedBorder = null; _lastObjectBorder = null; _lastMaskVisible = false; _lastOpacity = 0; }
public static void StartAnimation(this ButtonAnimation button, IAnimationComponent animationComponent, ITextComponent textComponent, IImageComponent imageComponent, IBorderComponent borderComponent) { if (button == null) { return; } var animation = button.Animation; if (animation != null && animation.Frames.Count > 0) { animationComponent?.StartAnimation(animation); } var border = button.Border; if (border != null && borderComponent != null) { borderComponent.Border = border; } var textConfig = button.TextConfig; if (textConfig != null && textComponent != null) { textComponent.TextConfig = textConfig; } if (imageComponent != null) { var image = button.Image; if (image != null) { imageComponent.Image = image; } var tint = button.Tint; if (tint != null) { imageComponent.Tint = tint.Value; } } }