/// <summary> /// Initializes a new instance of the <see cref="CheckBoxElement"/> class. /// </summary> public LabelElement() { Label = new ClickableLabel { Size = new Float2(100, 18), HorizontalAlignment = TextAlignment.Near, }; // TODO: auto height for label }
/// <inheritdoc /> public override void Initialize(LayoutElementsContainer layout) { _label = layout.ClickableLabel(GetName(Culture)).CustomControl; _label.RightClick += ShowPicker; var button = new Button { Width = 16.0f, Text = "...", Parent = _label, }; button.SetAnchorPreset(AnchorPresets.MiddleRight, false, true); button.Clicked += ShowPicker; }
public override void Load() { _uiController = new Controller(); CornerAnchor cornerAnchor = new CornerAnchor(); _uiController.Add(cornerAnchor); // Create labels for each scene. for (int i = 0; i < _scenes.Length; i++) { int iCopy = i; ClickableLabel addSceneLabel = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _scenes[i].ToString(), Color.White, Vector3.Zero) { OnClick = () => { Context.LayerManager.Remove(this); Context.LayerManager.Add((Layer)Activator.CreateInstance(_scenes[iCopy]), _scenes[iCopy].ToString(), 1); } }; cornerAnchor.AddChild(addSceneLabel, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); } }
/// <inheritdoc /> protected override void Deinitialize() { _label = null; base.Deinitialize(); }
/// <summary> /// Initializes a new instance of the <see cref="PluginEntry"/> class. /// </summary> /// <param name="plugin">The plugin.</param> /// <param name="category">The category.</param> /// <param name="desc">Plugin description</param> public PluginEntry(Plugin plugin, CategoryEntry category, ref PluginDescription desc) { Plugin = plugin; Category = category; float margin = 4; float iconSize = 64; var iconImage = new Image { Brush = new SpriteBrush(Editor.Instance.Icons.Plugin128), Parent = this, Bounds = new Rectangle(margin, margin, iconSize, iconSize), }; var icon = PluginUtils.TryGetPluginIcon(plugin); if (icon) { iconImage.Brush = new TextureBrush(icon); } Size = new Vector2(300, 100); float tmp1 = iconImage.Right + margin; var nameLabel = new Label { HorizontalAlignment = TextAlignment.Near, AnchorPreset = AnchorPresets.HorizontalStretchTop, Text = desc.Name, Font = new FontReference(Style.Current.FontLarge), Parent = this, Bounds = new Rectangle(tmp1, margin, Width - tmp1 - margin, 28), }; tmp1 = nameLabel.Bottom + margin + 8; var descLabel = new Label { HorizontalAlignment = TextAlignment.Near, VerticalAlignment = TextAlignment.Near, Wrapping = TextWrapping.WrapWords, AnchorPreset = AnchorPresets.HorizontalStretchTop, Text = desc.Description, Parent = this, Bounds = new Rectangle(nameLabel.X, tmp1, nameLabel.Width, Height - tmp1 - margin), }; string versionString = string.Empty; if (desc.IsAlpha) { versionString = "ALPHA "; } else if (desc.IsBeta) { versionString = "BETA "; } versionString += "Version "; versionString += desc.Version != null?desc.Version.ToString() : "1.0"; var versionLabel = new Label { HorizontalAlignment = TextAlignment.Far, VerticalAlignment = TextAlignment.Center, AnchorPreset = AnchorPresets.TopRight, Text = versionString, Parent = this, Bounds = new Rectangle(Width - 140 - margin, margin, 140, 14), }; string url = null; if (!string.IsNullOrEmpty(desc.AuthorUrl)) { url = desc.AuthorUrl; } else if (!string.IsNullOrEmpty(desc.HomepageUrl)) { url = desc.HomepageUrl; } else if (!string.IsNullOrEmpty(desc.RepositoryUrl)) { url = desc.RepositoryUrl; } versionLabel.Font.Font.WaitForLoaded(); var font = versionLabel.Font.GetFont(); var authorWidth = font.MeasureText(desc.Author).X + 8; var authorLabel = new ClickableLabel { HorizontalAlignment = TextAlignment.Far, VerticalAlignment = TextAlignment.Center, AnchorPreset = AnchorPresets.TopRight, Text = desc.Author, Parent = this, Bounds = new Rectangle(Width - authorWidth - margin, versionLabel.Bottom + margin, authorWidth, 14), }; if (url != null) { authorLabel.TextColorHighlighted = Style.Current.BackgroundSelected; authorLabel.DoubleClick = () => Platform.OpenUrl(url); } }
public override void Load() { _sounds = Directory.GetFiles("Assets/SoundPlayer").Where(x => x.Contains(".wav")).Select(x => x.Replace("Assets/", "")).ToArray(); _uiController = new Controller(); CenterAnchor centerAnchor = new CenterAnchor(); _uiController.Add(centerAnchor); _controlButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_playButton), OnClick = () => { SoundLayer layer = Context.SoundManager.GetLayer("main"); if (layer == null) { return; } if (layer.Status == SoundStatus.Playing) { layer.Pause(); } else { layer.Resume(); } } }; centerAnchor.AddChild(_controlButton, new Rectangle(0, Context.Settings.RenderHeight / 2 - 36, 0, 0)); BasicButton loopButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_loopButton) }; loopButton.OnClick = () => { SoundLayer layer = Context.SoundManager.GetLayer("main"); if (layer == null) { return; } layer.Looping = !layer.Looping; loopButton.Tint = layer.Looping ? Color.Green : Color.White; }; centerAnchor.AddChild(loopButton, new Rectangle(-40, Context.Settings.RenderHeight / 2 - 36, 0, 0)); _soundBar = new ScrollInput(Vector3.Zero, new Vector2(Context.Settings.RenderWidth - 40, 10)) { KeepSelectorInside = true, SelectorRatio = 3 }; centerAnchor.AddChild(_soundBar, new Rectangle(0, Context.Settings.RenderHeight / 2 - 10, 0, 0)); _soundBarInfo = new BasicText(Context.AssetLoader.Get <Font>(_defaultFont), 13, "N/A", Color.White, Vector3.Zero); centerAnchor.AddChild(_soundBarInfo, new Rectangle(100, Context.Settings.RenderHeight / 2 - 30, 0, 0)); CornerAnchor cornerAnchor = new CornerAnchor(); _uiController.Add(cornerAnchor); for (int i = 0; i < _sounds.Length; i++) { int iCopy = i; ClickableLabel addSoundText = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _sounds[i], Color.White, Vector3.Zero) { OnClick = () => { if (_append) { Context.SoundManager.PlayQueue(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main"); } else { Context.SoundManager.Play(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main"); } } }; cornerAnchor.AddChild(addSoundText, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); } BasicButton appendButton = new BasicButton(Vector3.Zero, new Vector2(36, 36)) { Texture = Context.AssetLoader.Get <Texture>(_addButton) }; appendButton.OnClick = () => { _append = !_append; appendButton.Tint = _append ? Color.Green : Color.White; }; cornerAnchor.AddChild(appendButton, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0)); PlayerVolumeControl volumeControl = new PlayerVolumeControl(Vector3.Zero, new Vector2(100, 20)); cornerAnchor.AddChild(volumeControl, AnchorLocation.TopRight, new Rectangle(0, 20, 20, 0)); }