public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property) { _property = property; var label = view.TreeItem; AGSTextConfig config = new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText); var textbox = _factory.GetTextBox(id, label.X, label.Y, label.TreeNode.Parent, "", config, width: 100f, height: 20f); textbox.Text = property.Value; textbox.TextBackgroundVisible = false; _textbox = textbox; textbox.RenderLayer = label.RenderLayer; textbox.Z = label.Z; HoverEffect.Add(textbox, Colors.Transparent, Colors.DarkSlateBlue); textbox.OnPressingKey.Subscribe(args => { if (args.PressedKey != Key.Enter) { return; } args.ShouldCancel = true; textbox.IsFocused = false; property.Prop.SetValue(property.Object, textbox.Text); }); }
public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property) { _property = property; var label = view.TreeItem; var config = _enabled ? GameViewColors.TextConfig : GameViewColors.ReadonlyTextConfig; var textbox = _factory.UI.GetTextBox(id, label.X, label.Y, label.TreeNode.Parent, "", config, width: 100f, height: 20f); textbox.Text = property.Value; textbox.TextBackgroundVisible = false; textbox.Enabled = _enabled; if (_enabled) { GameViewColors.AddHoverEffect(textbox); } _textbox = textbox; textbox.RenderLayer = label.RenderLayer; textbox.Z = label.Z; HoverEffect.Add(textbox, Colors.Transparent, Colors.DarkSlateBlue); textbox.OnPressingKey.Subscribe(args => { if (args.PressedKey != Key.Enter) { return; } args.ShouldCancel = true; textbox.IsFocused = false; property.Prop.SetValue(property.Object, textbox.Text); }); textbox.LostFocus.Subscribe(args => { property.Prop.SetValue(property.Object, textbox.Text); }); }
public AGSCheckBox(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>(); _checkboxComponent = AddComponent<ICheckboxComponent>(); beforeInitComponents(resolver); InitComponents(); afterInitComponents(resolver); }
public void AddEditorUI(string id, ITreeNodeView view, IProperty property) { _property = property; var label = view.TreeItem; var combobox = _factory.GetComboBox(id, null, null, null, label.TreeNode.Parent, defaultWidth: 100f, defaultHeight: 25f); _text = combobox.TextBox; _text.TextBackgroundVisible = false; var list = new List <IStringItem>(); Type enumType = property.PropertyType; foreach (var option in Enum.GetValues(enumType)) { list.Add(new AGSStringItem { Text = option.ToString() }); } combobox.DropDownPanelList.Items.AddRange(list); combobox.Z = label.Z; combobox.TextBox.Text = property.ValueString; combobox.TextBox.TextConfig.AutoFit = AutoFit.LabelShouldFitText; if (list.Count > 5) //If more than 5 items in the dropdown, let's have it with textbox suggestions as user might prefer to type for filtering the dropdown { combobox.SuggestMode = ComboSuggest.Enforce; } combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args => { if (_actions.ActionIsExecuting) { return; } _actions.RecordAction(new PropertyAction(property, Enum.Parse(enumType, args.Item.Text), _model)); }); }
internal static IChatMessage RenderClickableCommand(string name, string hoverText = "Click to suggest the command.", string suggestionPrefix = "", ChatColor?color = null) { color ??= ChatColor.Red; var command = name.Contains(" ") ? string.Join(" ", name.Split(" ").Where(x => !x.StartsWith("<"))) + " " : name; if (suggestionPrefix != "") { command = $"{suggestionPrefix.Trim(' ')} {name}"; } var chatMessage = IChatMessage.CreateNew(); chatMessage.Text = $"{color}{(suggestionPrefix != "" ? "" : (!name.StartsWith("/") ? "/" : ""))}{name}"; var clickEvent = ITextComponent.CreateNew(); clickEvent.Action = ETextAction.SuggestCommand; clickEvent.Value = $"{(!command.StartsWith("/") ? "/" : "")}{command}"; chatMessage.ClickEvent = clickEvent; var hoverEvent = ITextComponent.CreateNew(); hoverEvent.Action = ETextAction.ShowText; hoverEvent.Value = $"{hoverText}"; chatMessage.HoverEvent = hoverEvent; return(chatMessage); }
public void AddEditorUI(string id, ITreeNodeView view, InspectorProperty property) { _property = property; var label = view.TreeItem; var combobox = _factory.GetComboBox(id, null, null, null, label.TreeNode.Parent, defaultWidth: 100f, defaultHeight: 25f); _text = combobox.TextBox; _text.TextBackgroundVisible = false; var list = new List <IStringItem>(); Type enumType = property.Prop.PropertyType; foreach (var option in Enum.GetValues(enumType)) { list.Add(new AGSStringItem { Text = option.ToString() }); } combobox.DropDownPanelList.Items.AddRange(list); combobox.Z = label.Z; combobox.TextBox.Text = property.Value; combobox.TextBox.TextConfig.AutoFit = AutoFit.LabelShouldFitText; combobox.DropDownPanelList.OnSelectedItemChanged.Subscribe(args => { property.Prop.SetValue(property.Object, Enum.Parse(enumType, args.Item.Text)); }); }
internal static IChatMessage RenderCommandUsage(string commandUsage, string hoverText = "Click to suggest the command.", ChatColor?color = null) { color ??= ChatColor.Red; var chatMessage = IChatMessage.Simple(""); #region prefix var prefix = IChatMessage.CreateNew(); prefix.Text = $"{color}Usage: "; chatMessage.AddExtra(prefix); #endregion #region usage var usage = IChatMessage.CreateNew(); var commandSuggest = commandUsage.Contains(" ") ? $"{commandUsage.Split(" ").FirstOrDefault()} " : commandUsage; usage.Text = $"{color}{commandUsage}"; var clickEvent = ITextComponent.CreateNew(); clickEvent.Action = ETextAction.SuggestCommand; clickEvent.Value = $"{commandSuggest}"; usage.ClickEvent = clickEvent; var hoverEvent = ITextComponent.CreateNew(); hoverEvent.Action = ETextAction.ShowText; hoverEvent.Value = $"{hoverText}"; usage.HoverEvent = hoverEvent; chatMessage.AddExtra(usage); #endregion return(chatMessage); }
public void Setup(ITextComponent component) { if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P1) == true) component.SetText(this.text); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P15) == true) component.SetText(this.localizationKey); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P2) == true) component.SetTextColor(this.color); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P3) == true) component.SetValueFormat(this.format); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P16) == true) component.SetFullTextFormat(this.fullTextFormat); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P4) == true) component.SetFont(this.font); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P5) == true) component.SetFontSize(this.fontSize); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P6) == true) component.SetFontStyle(this.fontStyle); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P7) == true) component.SetLineSpacing(this.lineSpacing); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P8) == true) component.SetRichText(this.richText); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P9) == true) component.SetTextAlignment(this.alignment); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P10) == true) component.SetTextVerticalOverflow(this.verticalWrap); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P11) == true) component.SetTextHorizontalOverflow(this.horizontalWrap); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P12) == true) component.SetBestFitState(this.bestFit); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P13) == true) component.SetBestFitMinSize(this.bestMinSize); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P14) == true) component.SetBestFitMaxSize(this.bestMaxSize); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P17) == true) component.SetValueAnimate(this.valueAnimate); if (this.IsChanged(ParameterFlag./*{flagPrefix}*/P18) == true) component.SetValueAnimateDuration(this.valueAnimateDuration); }
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); }
private void unsubscribeTextComponent(ITextComponent text) { _customImageSize = null; _customResolutionFactor = null; _text.PropertyChanged -= _onTextChangedCallback; onSomethingChanged(); }
public override void Init(IEntity entity) { base.Init(entity); _textComponent = entity.GetComponent <ITextComponent>(); _imageComponent = entity.GetComponent <IImageComponent>(); _uiEvents = entity.GetComponent <IUIEvents>(); _tree = entity.GetComponent <IInObjectTree>(); _room = entity.GetComponent <IHasRoom>(); var visible = entity.GetComponent <IVisibleComponent>(); _game.Events.OnRepeatedlyExecute.Subscribe((_, __) => { if (!visible.Visible) { IsFocused = false; } }); _caretFlashCounter = (int)CaretFlashDelay; _withCaret = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText)); _withCaret.Anchor = new PointF(0f, 0f); _game.Events.OnBeforeRender.Subscribe(onBeforeRender); _uiEvents.MouseDown.Subscribe(onMouseDown); _uiEvents.LostFocus.Subscribe(onMouseDownOutside); }
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 <IImageComponent>(c => _imageComponent = c, _ => _imageComponent = null); 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); _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute); _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 <IAnimationComponent>(c => { c.PropertyChanged += onAnimationPropertyChanged; _animationComponent = c; updateBorder(); }, c => { c.PropertyChanged -= onAnimationPropertyChanged; _animationComponent = null; updateBorder(); }); entity.Bind <IDrawableInfoComponent>(c => { _drawableComponent = c; c.PropertyChanged += onDrawableChanged; onRenderLayerChanged(); }, c => { c.PropertyChanged -= onDrawableChanged; _drawableComponent = null; }); }
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 IObject ToItem(AGSSerializationContext context) { if (Object == null) { return(null); } ITextComponent textComponent = TextComponent.ToItem(context); ILabel label = context.Factory.UI.GetLabel(Object.ID, textComponent.Text, textComponent.LabelRenderSize.Width, textComponent.LabelRenderSize.Height, 0, 0, textComponent.TextConfig, false); Object.ToItem(context, label); label.Visible = Object.Visible; return(label); }
public void AddEditorUI(string id, ITreeNodeView view, IProperty property) { _property = property; var label = view.TreeItem; var config = _enabled ? GameViewColors.TextboxTextConfig : GameViewColors.ReadonlyTextConfig; if (!_enabled) { var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>(); if (layout != null) { layout.RestrictionList.RestrictionList.Add(id); } } var textbox = _factory.UI.GetTextBox(id, label.X, label.Y, label.TreeNode.Parent, "", config, width: 100f, height: 20f); textbox.Text = property.ValueString; textbox.TextBackgroundVisible = true; textbox.Enabled = _enabled; if (_enabled) { GameViewColors.AddHoverEffect(textbox); } else { textbox.TextBackgroundVisible = false; } _textbox = textbox; textbox.RenderLayer = label.RenderLayer; textbox.Z = label.Z; textbox.OnPressingKey.Subscribe(args => { if (args.PressedKey != Key.Enter) { return; } args.ShouldCancel = true; textbox.IsFocused = false; setString(); }); textbox.LostFocus.Subscribe(args => { textbox.IsFocused = false; setString(); }); }
public override void Init(IEntity entity) { base.Init(entity); _textComponent = entity.GetComponent<ITextComponent>(); _imageComponent = entity.GetComponent<IImageComponent>(); _uiEvents = entity.GetComponent<IUIEvents>(); _tree = entity.GetComponent<IInObjectTree>(); _room = entity.GetComponent<IHasRoom>(); _caretFlashCounter = (int)CaretFlashDelay; _withCaret = _game.Factory.UI.GetLabel(entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, new AGSTextConfig(autoFit: AutoFit.LabelShouldFitText)); _withCaret.Anchor = new PointF(0f, 0f); _game.Events.OnBeforeRender.Subscribe(onBeforeRender); _uiEvents.MouseDown.Subscribe(onMouseDown); _uiEvents.LostFocus.Subscribe(onMouseDownOutside); }
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; } } }
public void AddEditorUI(string id, ITreeNodeView view, IProperty property) { _property = property; var label = view.TreeItem; var combobox = GetCombobox(id, _factory, label.TreeNode.Parent); _text = combobox.TextBox; var list = _getOptions(property); combobox.DropDownPanelList.Items.AddRange(list); combobox.Z = label.Z; combobox.TextBox.Text = property.ValueString.Humanize(); if (list.Count > 5) //If more than 5 items in the dropdown, let's have it with textbox suggestions as user might prefer to type for filtering the dropdown { combobox.SuggestMode = ComboSuggest.Enforce; } var layout = view.HorizontalPanel.GetComponent <ITreeTableRowLayoutComponent>(); if (layout != null) { layout.RestrictionList.RestrictionList.AddRange(new List <string> { combobox.ID }); } Action closeCombobox = () => (combobox.DropDownPanel.ScrollingPanel ?? combobox.DropDownPanel.ContentsPanel).Visible = false; combobox.DropDownPanelList.OnSelectedItemChanging.SubscribeToAsync(async args => { if (_actions.ActionIsExecuting) { return; } var returnValue = await _getValue(args.Item, property, closeCombobox); if (returnValue.ShouldCancel) { args.ShouldCancel = true; return; } _actions.RecordAction(new PropertyAction(property, returnValue.Value, _model)); }); }
public override void Init(IEntity entity) { base.Init(entity); 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 <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); }); }
public async Task TestCmd(ObsidianContext ctx, string arg) { switch (arg) { case "reload": try { Globals.Config = await ConfigManager.LoadConfig(); await ctx.Player.SendMessageAsync($"§aConfig reloaded successfully"); await Broadcaster.StartBroadcasting(); } catch (Exception e) { await ctx.Player.SendMessageAsync($"§cAn error occurred when loading a config. Broadcasting stopped\n{e.Message}"); Broadcaster.StopBroadcasting(); } break; default: case "about": var msg = IChatMessage.CreateNew(); msg.Text = "§aObsidian Announcer §f- §dInterval auto announcement for JSON messages"; var clickComponent = ITextComponent.CreateNew(); clickComponent.Action = ETextAction.OpenUrl; clickComponent.Value = "https://github.com/roxxel/ObsidianAnnouncer"; var hoverComponent = ITextComponent.CreateNew(); hoverComponent.Action = ETextAction.ShowText; hoverComponent.Value = "§aPlugin github repo"; msg.HoverEvent = hoverComponent; msg.ClickEvent = clickComponent; await ctx.Player.SendMessageAsync(msg); break; } }
public override void Init() { base.Init(); Entity.Bind <ITextComponent>(c => { _textComponent = c; c.PropertyChanged += onTextPropertyChanged; }, c => { _textComponent = null; c.PropertyChanged -= onTextPropertyChanged; }); Entity.Bind <IUIEvents>(c => { c.MouseDown.Subscribe(onMouseDown); c.LostFocus.Subscribe(onMouseDownOutside); }, c => { 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 = new Lazy <ILabel>(() => { var label = _game.Factory.UI.GetLabel(Entity.ID + " Caret", "|", 1f, 1f, 0f, 0f, config: _game.Factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText)); label.Pivot = new PointF(0f, 0f); label.TextBackgroundVisible = false; return(label); }); Entity.Bind <IImageComponent>(c => _imageComponent = c, _ => _imageComponent = null); Entity.Bind <IDrawableInfoComponent>(c => _drawableComponent = c, _ => _drawableComponent = null); _game.Events.OnRepeatedlyExecute.Subscribe(onRepeatedlyExecute); }
public void Setup(ITextComponent component) { if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P1) == true) { component.SetText(this.text); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P15) == true) { component.SetText(this.localizationKey); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P2) == true) { component.SetTextColor(this.color); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P3) == true) { component.SetValueFormat(this.format); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P16) == true) { component.SetFullTextFormat(this.fullTextFormat); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P4) == true) { component.SetFont(this.font); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P5) == true) { component.SetFontSize(this.fontSize); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P6) == true) { component.SetFontStyle(this.fontStyle); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P7) == true) { component.SetLineSpacing(this.lineSpacing); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P8) == true) { component.SetRichText(this.richText); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P9) == true) { component.SetTextAlignment(this.alignment); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P10) == true) { component.SetTextVerticalOverflow(this.verticalWrap); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P11) == true) { component.SetTextHorizontalOverflow(this.horizontalWrap); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P12) == true) { component.SetBestFitState(this.bestFit); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P13) == true) { component.SetBestFitMinSize(this.bestMinSize); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P14) == true) { component.SetBestFitMaxSize(this.bestMaxSize); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P17) == true) { component.SetValueAnimate(this.valueAnimate); } if (this.IsChanged(ParameterFlag./*{flagPrefix}*/ P18) == true) { component.SetValueAnimateDuration(this.valueAnimateDuration); } }
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); }
/// <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 override void AfterInit() { Entity.Bind <IDrawableInfoComponent>( c => { _drawable = c; c.PropertyChanged += _onDrawbaleChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onDrawbaleChangedCallback; _drawable = null; onSomethingChanged(); }); Entity.Bind <IHasRoomComponent>( c => { _room = c; refreshAreaScaling(); subscribeRoom(); onSomethingChanged(); }, c => { unsubscribeRoom(c); _room = null; refreshAreaScaling(); onSomethingChanged(); }); Entity.Bind <IScaleComponent>( c => { _scale = c; c.PropertyChanged += _onScaleChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onScaleChangedCallback; _scale = null; onSomethingChanged(); }); Entity.Bind <ITranslateComponent>( c => { _translate = c; c.PropertyChanged += _onTranslateChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onTranslateChangedCallback; _translate = null; onSomethingChanged(); } ); Entity.Bind <IWorldPositionComponent>( c => { _worldPosition = c; c.PropertyChanged += _onWorldPositionChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onWorldPositionChangedCallback; _translate = null; onSomethingChanged(); } ); Entity.Bind <IJumpOffsetComponent>( c => { _jump = c; c.PropertyChanged += _onJumpOffsetChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onJumpOffsetChangedCallback; _jump = null; onSomethingChanged(); } ); Entity.Bind <IRotateComponent>( c => { _rotate = c; c.PropertyChanged += _onRotateChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onRotateChangedCallback; _rotate = null; onSomethingChanged(); } ); Entity.Bind <IImageComponent>( c => { _image = c; c.PropertyChanged += _onImageChangedCallback; onSomethingChanged(); }, c => { c.PropertyChanged -= _onImageChangedCallback; _image = null; onSomethingChanged(); } ); Entity.Bind <ITextComponent>( c => { _text = c; subscribeTextComponent(); }, _ => { unsubscribeTextComponent(); _text = null; } ); Entity.Bind <IInObjectTreeComponent>( c => { _tree = c; _parent = _tree.TreeNode.Parent; _tree.TreeNode.OnParentChanged.Subscribe(_onParentChangedCallback); _parent?.OnMatrixChanged.Subscribe(_onSomethingChangedCallback); onSomethingChanged(); }, c => { c.TreeNode.OnParentChanged.Unsubscribe(_onParentChangedCallback); c.TreeNode.Parent?.OnMatrixChanged.Unsubscribe(_onSomethingChangedCallback); _tree = null; _parent = null; onSomethingChanged(); }); }
public override void Init(IComponent source) { base.Init(source); this.text = source as ITextComponent; }
public void FadeTo(ITextComponent source, string to, float duration, System.Action callback = null) { this.FadeTo <Text>(source, to, duration, this.fadeIfWasNull, callback); }
public static ME.Tweener.Tween <ITextComponent> addTweenCount(this ME.Tweener tweener, ITextComponent textComponent, float duration, long start, long end, TextValueFormat format, System.Action <long> onValue) { return(tweener.addTween(textComponent, duration, 0f, 1f).onUpdate((c, t) => { var value = ME.Math.Lerp(start, end, t); onValue(value); })); }
private void FadeTo <T>(ITextComponent textSource, string to, float duration, bool fadeIfWasNull, System.Action callback) where T : Graphic { var hasSourceText = false; var hasChanged = ((this.source as Text).text != to); if (hasChanged == false) { if (callback != null) { callback.Invoke(); } return; } hasSourceText = (string.IsNullOrEmpty((this.source as Text).text) == false); var copy = this.MakeCopy <T>(this.source.rectTransform); var sourceText = this.source as Text; var copyText = (copy as Text); copyText.material = (this.source.defaultMaterial == this.source.material ? null : this.source.material); copyText.text = to; copyText.horizontalOverflow = sourceText.horizontalOverflow; //HorizontalWrapMode.Overflow; copyText.verticalOverflow = sourceText.verticalOverflow; //VerticalWrapMode.Overflow; copyText.supportRichText = sourceText.supportRichText; copyText.resizeTextForBestFit = sourceText.resizeTextForBestFit; copyText.resizeTextMinSize = sourceText.resizeTextMinSize; copyText.resizeTextMaxSize = sourceText.resizeTextMaxSize; copyText.lineSpacing = sourceText.lineSpacing; copyText.font = sourceText.font; copyText.fontSize = sourceText.fontSize; copyText.fontStyle = sourceText.fontStyle; copyText.alignByGeometry = sourceText.alignByGeometry; copyText.alignment = sourceText.alignment; TweenerGlobal.instance.removeTweens(source, immediately: true); TweenerGlobal.instance.removeTweens(copy, immediately: true); var sourceColor = this.targetColor; if (hasSourceText == true || fadeIfWasNull == true) { copy.color = this.startColor; //new Color(sourceColor.r, sourceColor.g, sourceColor.b, 0f); if (hasSourceText == false) { source.color = this.startColor; //new Color(sourceColor.r, sourceColor.g, sourceColor.b, 0f); } if (this.fadeOutSource == true) { TweenerGlobal.instance.addTweenAlpha(source, duration, 0f).tag(source).ease(ME.Ease.GetByType(this.easeType)); } TweenerGlobal.instance.addTweenAlpha(copy, this.duration, 1f).tag(copy).ease(ME.Ease.GetByType(this.easeType)).onComplete(() => { if (source != null) { source.color = sourceColor; } this.Finalize(source, copy); if (callback != null) { callback.Invoke(); } }).onCancel(() => { if (callback != null) { callback.Invoke(); } }); } else { if (copy != null) { copy.color = sourceColor; } if (source != null) { source.color = sourceColor; } this.Finalize(source, copy); if (callback != null) { callback.Invoke(); } } }
public void Setup(ITextComponent component) { if (this.IsChanged(ParameterFlag.AP1) == true) component.SetText(this.text); if (this.IsChanged(ParameterFlag.AP2) == true) component.SetTextColor(this.color); if (this.IsChanged(ParameterFlag.AP3) == true) component.SetValueFormat(this.format); if (this.IsChanged(ParameterFlag.AP4) == true) component.SetFont(this.font); if (this.IsChanged(ParameterFlag.AP5) == true) component.SetFontSize(this.fontSize); if (this.IsChanged(ParameterFlag.AP6) == true) component.SetFontStyle(this.fontStyle); if (this.IsChanged(ParameterFlag.AP7) == true) component.SetLineSpacing(this.lineSpacing); if (this.IsChanged(ParameterFlag.AP8) == true) component.SetRichText(this.richText); if (this.IsChanged(ParameterFlag.AP9) == true) component.SetTextAlignment(this.alignment); if (this.IsChanged(ParameterFlag.AP10) == true) component.SetTextVerticalOverflow(this.verticalWrap); if (this.IsChanged(ParameterFlag.AP11) == true) component.SetTextHorizontalOverflow(this.horizontalWrap); if (this.IsChanged(ParameterFlag.AP12) == true) component.SetBestFitState(this.bestFit); if (this.IsChanged(ParameterFlag.AP13) == true) component.SetBestFitMinSize(this.bestMinSize); if (this.IsChanged(ParameterFlag.AP14) == true) component.SetBestFitMaxSize(this.bestMaxSize); }