/// <summary> /// Shows a float count as stars. Used as star difficulty display. /// </summary> /// <param name="maxstars">Maximum amount of stars to display.</param> public StarCounter(int maxstars) { MaxStars = Math.Max(maxstars, 0); Children = new Drawable[] { starContainer = new Container { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, } }; starContainer.Width = MaxStars * StarSize + Math.Max(MaxStars - 1, 0) * StarSpacing; starContainer.Height = StarSize; for (int i = 0; i < MaxStars; i++) { TextAwesome star = new TextAwesome { Icon = FontAwesome.fa_star, Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, TextSize = StarSize, Scale = new Vector2(minStarScale), Alpha = minStarAlpha, Position = new Vector2((StarSize + StarSpacing) * i + (StarSize + StarSpacing) / 2, 0), }; //todo: user Container<T> once we have it. stars.Add(star); starContainer.Add(star); } }
public Dialog(Drawable drawable, VariableSet variables = null) : base("CountTool", variables) { var hbox = new HBox(false, 12) {BorderWidth = 12}; VBox.PackStart(hbox, true, true, 0); var preview = new Preview(drawable, _coordinates); hbox.PackStart(preview, true, true, 0); var sw = new ScrolledWindow(); hbox.Add(sw); var store = new TreeStore(typeof(Coordinate<int>)); for (int i = 0; i < 10; i++) { var coordinate = new Coordinate<int>(10 * i, 10 * i); _coordinates.Add(coordinate); store.AppendValues(coordinate); } var view = new TreeView(store); sw.Add(view); var textRenderer = new CellRendererText(); view.AppendColumn("X", textRenderer, new TreeCellDataFunc(RenderX)); view.AppendColumn("Y", textRenderer, new TreeCellDataFunc(RenderY)); }
public MaintenanceSection() { content.Spacing = new Vector2(0, 5); Children = new Drawable[] { new OsuButton { RelativeSizeAxes = Axes.X, Text = "Delete all unranked maps", }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Repair folder permissions", }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Mark all maps as played", }, new OsuButton { RelativeSizeAxes = Axes.X, Text = "Run osu! updater", }, new SpriteText { Text = "TODO: osu version here", Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }, }; }
public ChannelDisplay(Channel channel) { this.channel = channel; newMessages(channel.Messages); channel.NewMessagesArrived += newMessages; RelativeSizeAxes = Axes.Both; Children = new Drawable[] { new SpriteText { Text = channel.Name, TextSize = 50, Alpha = 0.3f, Anchor = Anchor.Centre, Origin = Anchor.Centre }, new ScrollContainer { Children = new Drawable[] { flow = new FlowContainer { Direction = FlowDirection.VerticalOnly, RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Spacing = new Vector2(1, 1) } } } }; }
// --- UnLoad end ---// // --- Drawable start ---// public void AddDrawing(Drawable d) { lock (drawings) { drawings.Add(d); } }
public void Draw(Graphics g, Drawable d) { int pi = 0; for (int i = 0; i < d.NumDrawables; i++) { int drawType = d.DrawableType(i); if (drawType == Constants.Graphics.DRAW_NOTHING) continue; int numPts = Constants.Graphics.DRAW_PT_LOOKUP_TABLE[drawType]; Color4 c = d.DrawableColor(i); pen.Color = Color.FromArgb(c.ToArgb()); for (int j = 0; j < numPts; j++) p[j] = scale * d.GetPoint(pi++); switch (drawType) { case Constants.Graphics.DRAW_NOTHING: break; case Constants.Graphics.DRAW_POINT: g.DrawRectangle(pen, p[0].X - 1f, p[0].Y - 1f, 2f, 2f); break; case Constants.Graphics.DRAW_LINE: g.DrawLine(pen, p[0].X, p[0].Y, p[1].X, p[1].Y); break; case Constants.Graphics.DRAW_CIRCLE: g.DrawEllipse(pen, p[0].X, p[0].Y, (p[1].X - p[0].X), (p[1].Y - p[0].Y)); break; } } }
public void Render(BoolMatrix boolMatrix, PixelFetcher pf, Drawable drawable) { var dimensions = drawable.Dimensions; RenderDrop(boolMatrix, pf, dimensions); RenderShadow(pf, drawable, dimensions); }
public static Point Collide(Drawable a, Drawable b, int dx, int dy) { Rectangle bbt = b.GetBound(); Rectangle ab = a.GetBound(); Rectangle bb = b.GetBound(); bb.X += dx; bb.Y += dy; Rectangle cc = Rectangle.Intersect(ab, bb); if (cc.IsEmpty) { //Rectangle un = Rectangle.Union(bb, bbt); //Rectangle uc = Rectangle.Intersect(ab, un); //if (uc.IsEmpty) // return Point.Empty; //// Incompleted return Point.Empty; //Rectangle abb = a.GetBound(); //abb.X += -dx; //abb.Y += -dy; //Point gp = GetPoint(bb, ab, abb, Rectangle.Intersect(abb, bb), -dx, -dy); //return new Point(gp.X, gp.Y); } else { return GetPoint(ab, bb, bbt, cc, dx, dy); } }
public MainMenu() { background = new BackgroundModeDefault(); Children = new Drawable[] { new ParallaxContainer { ParallaxAmount = 0.01f, Children = new Drawable[] { buttons = new ButtonSystem() { OnChart = delegate { Push(new ChartListing()); }, OnDirect = delegate { Push(new OnlineListing()); }, OnEdit = delegate { Push(new EditSongSelect()); }, OnSolo = delegate { Push(new PlaySongSelect()); }, OnMulti = delegate { Push(new Lobby()); }, OnTest = delegate { Push(new TestBrowser()); }, OnExit = delegate { Exit(); }, } } } }; }
public override void Render(Drawable window, Widget widget, Rectangle cell_area, Rectangle expose_area, StateType cell_state, IPhoto photo) { string text = GetRenderText (photo); var layout = new Pango.Layout (widget.PangoContext); layout.SetText (text); Rectangle layout_bounds; layout.GetPixelSize (out layout_bounds.Width, out layout_bounds.Height); layout_bounds.Y = cell_area.Y; layout_bounds.X = cell_area.X + (cell_area.Width - layout_bounds.Width) / 2; if (layout_bounds.IntersectsWith (expose_area)) { Style.PaintLayout (widget.Style, window, cell_state, true, expose_area, widget, "IconView", layout_bounds.X, layout_bounds.Y, layout); } }
protected override void Render (Drawable window, Widget widget, Rectangle background_area, Rectangle cell_area, Rectangle expose_area, CellRendererState flags) { int width = 0, height = 0, x_offset = 0, y_offset = 0; StateType state; GetSize (widget, ref cell_area, out x_offset, out y_offset, out width, out height); if (widget.HasFocus) state = StateType.Active; else state = StateType.Normal; width -= (int) this.Xpad * 2; height -= (int) this.Ypad * 2; //FIXME: Style.PaintBox needs some customization so that if you pass it //a Gdk.Rectangle.Zero it gives a clipping area big enough to draw //everything Gdk.Rectangle clipping_area = new Gdk.Rectangle ((int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), width - 1, height - 1); Style.PaintBox (widget.Style, (Gdk.Window) window, StateType.Normal, ShadowType.In, clipping_area, widget, "trough", (int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), width - 1, height - 1); Gdk.Rectangle clipping_area2 = new Gdk.Rectangle ((int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), (int) (width * Percentage), height - 1); Style.PaintBox (widget.Style, (Gdk.Window) window, state, ShadowType.Out, clipping_area2, widget, "bar", (int) (cell_area.X + x_offset + this.Xpad), (int) (cell_area.Y + y_offset + this.Ypad), (int) (width * Percentage), height - 1); }
public Dialog(Image image, Drawable drawable, SliceData sliceData) : base(_("Slice Tool"), _("SliceTool"), IntPtr.Zero, 0, null, _("SliceTool"), Stock.SaveAs, (Gtk.ResponseType) 2, Stock.Save, (Gtk.ResponseType) 3, Stock.Close, ResponseType.Close) { _image = image; _drawable = drawable; _sliceData = sliceData; SetTitle(null); var vbox = new VBox(false, 12) {BorderWidth = 12}; VBox.PackStart(vbox, true, true, 0); var hbox = new HBox(); vbox.PackStart(hbox, true, true, 0); var preview = CreatePreview(drawable, sliceData); var toolbox = Preview.CreateToolbox(sliceData); hbox.PackStart(toolbox, false, true, 0); hbox.PackStart(preview, true, true, 0); hbox = new HBox(); vbox.PackStart(hbox, true, true, 0); hbox.PackStart(new CoordinatesDisplay(Preview), false, false, 0); hbox = new HBox(false, 24); vbox.PackStart(hbox, true, true, 0); var properties = new CellPropertiesFrame(sliceData.Rectangles); hbox.PackStart(properties, false, true, 0); vbox = new VBox(false, 12); hbox.PackStart(vbox, false, true, 0); var rollover = new RolloversFrame(sliceData); vbox.PackStart(rollover, false, true, 0); _format = new Format(sliceData.Rectangles); _format.Extension = System.IO.Path.GetExtension(image.Name).ToLower(); vbox.PackStart(_format, false, true, 0); vbox = new VBox(false, 12); hbox.PackStart(vbox, false, true, 0); var save = new SaveSettingsButton(this, sliceData); vbox.PackStart(save, false, true, 0); var load = new LoadSettingsButton(this, sliceData); vbox.PackStart(load, false, true, 0); var preferences = new PreferencesButton(_("Preferences"), Preview); vbox.PackStart(preferences, false, true, 0); sliceData.Rectangles.SelectedRectangleChanged += delegate {Redraw();}; sliceData.Init(drawable); }
public override NodeActionState StartAction(Drawable target) { DrawNode node = target as DrawNode; if (node == null) throw new ArgumentException("Send signal can be started only on DrawNode"); return new SendSignalActionState(node, this); }
private void load(OsuConfigManager config) { Children = new Drawable[] { new CheckBoxOption { LabelText = "Integrate with Yahoo! status display", Bindable = config.GetBindable<bool>(OsuConfig.YahooIntegration) }, new CheckBoxOption { LabelText = "Integrate with MSN Live status display", Bindable = config.GetBindable<bool>(OsuConfig.MsnIntegration) }, new CheckBoxOption { LabelText = "Automatically start osu!direct downloads", Bindable = config.GetBindable<bool>(OsuConfig.AutomaticDownload) }, new CheckBoxOption { LabelText = "Prefer no-video downloads", Bindable = config.GetBindable<bool>(OsuConfig.AutomaticDownloadNoVideo) }, }; }
public Preview(Drawable drawable, SliceData sliceData) { MaxSize = drawable.Dimensions; ExposeEvent += delegate {sliceData.Draw(Renderer);}; Realized += delegate { var gc = new Gdk.GC(GdkWindow); Renderer = new PreviewRenderer(this, gc, drawable.Dimensions); Draw(drawable); }; SizeAllocated += delegate {Draw(drawable);}; Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionHintMask | EventMask.PointerMotionMask | EventMask.LeaveNotifyMask; ButtonPressEvent += (o, args) => { var c = new IntCoordinate((int) args.Event.X, (int) args.Event.Y); Func.GetActualFunc(c).OnButtonPress(o, args); }; MotionNotifyEvent += (o, args) => { GdkWindow.Cursor = Func.GetCursor(GetXY(args)); }; Func = new SelectFunc(sliceData, this); }
public void RemoveDrawable(int layer, Drawable d) { if (mLayers[layer] == null) return; mLayers[layer].Remove(d); }
public HitExplosion(OsuJudgementInfo judgement, OsuHitObject h = null) { this.judgement = judgement; AutoSizeAxes = Axes.Both; Origin = Anchor.Centre; Direction = FlowDirection.VerticalOnly; Spacing = new Vector2(0, 2); Position = (h?.EndPosition ?? Vector2.Zero) + judgement.PositionOffset; Children = new Drawable[] { line1 = new SpriteText { Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Text = judgement.Score.GetDescription(), Font = @"Venera", TextSize = 16, }, line2 = new SpriteText { Text = judgement.Combo.GetDescription(), Font = @"Venera", TextSize = 11, } }; }
public void AddDrawable(int layer, Drawable d) { if (mLayers[layer] == null) mLayers[layer] = new List<Drawable>(); mLayers[layer].Add(d); }
private void load(OsuConfigManager config) { // NOTE: Compatability mode omitted Children = new Drawable[] { // TODO: this needs to be a custom dropdown at some point new DropdownOption<FrameSync> { LabelText = "Frame limiter", Bindable = config.GetBindable<FrameSync>(OsuConfig.FrameSync) }, new CheckBoxOption { LabelText = "Show FPS counter", Bindable = config.GetBindable<bool>(OsuConfig.FpsCounter), }, new CheckBoxOption { LabelText = "Reduce dropped frames", Bindable = config.GetBindable<bool>(OsuConfig.ForceFrameFlush), }, new CheckBoxOption { LabelText = "Detect performance issues", Bindable = config.GetBindable<bool>(OsuConfig.DetectPerformanceIssues), }, }; }
public override void OnLoad(EventArgs args) { base.OnLoad(args); Camera = new Camera(); _bg = new Image(new PointF(0, 0), new SizeF(1024, 768), "assets/gfx/background/menubg.png") { Camera = Camera }; _charactersButton = new Button(new PointF(100, 200), new SizeF(250, 100), "assets/gfx/buttons/play.png", () => { _game.SwitchScreen("Chars"); _music.Stop(); }) {Camera = Camera}; _optionsButton = new Button( new PointF(100, 350), new SizeF(250, 100), "assets/gfx/buttons/options.png", () => { if (!_game.FormManager.HasForm<OptionsForm>()) { _game.FormManager.OpenOrGetForm<OptionsForm>().Run(); } }) {Camera = Camera}; _exitButton = new Button(new PointF(100, 500), new SizeF(250, 100), "assets/gfx/buttons/exit.png", () => _game.Exit()) {Camera = Camera}; }
public Renderer(VariableSet variables, Drawable drawable) : base(variables) { _drawable = drawable; const double lensAngle = 70.0; const double earthRadius = 6375.0; var amplitudes = new double[]{1.0, 0.5, 0.25, 0.125, 0.0625, 0.03125, 0.05, 0.05, 0.04, 0.0300}; _width = drawable.Width; _height = drawable.Height; _clouds = new Perlin3D(10, 16.0, amplitudes, (int) GetValue<UInt32>("seed")); _cameraDistance = _width * 0.5 / Math.Tan(lensAngle * Math.PI / 180.0); _intSunX = (int) Math.Round((_width - 1) * GetValue<double>("sun_x")); _intSunY = (int) Math.Round((_height - 1) * GetValue<double>("sun_y")); _horizonColor2 = FromScreen("horizon_color"); _skyColor2 = FromScreen("sky_color"); _sunColor2 = FromScreen("sun_color"); _cloudColor2 = FromScreen("cloud_color"); _shadowColor2 = FromScreen("shadow_color"); var tilt = new TMatrix(GetValue<double>("tilt"), 1); var rotation = new TMatrix(GetValue<double>("rotation"), 2); _transform = TMatrix.Combine(tilt, rotation); _cameraLocation = new Vector3(0.0, earthRadius + 0.2, 0.0); }
public override void OnLoad(EventArgs args) { base.OnLoad(args); Camera = new Camera(); _bg = new Image(new PointF(0, 0), new SizeF(1024, 768), "assets/gfx/background/menubg.png") { Camera = Camera }; _biscuitText = new Text(size => new PointF((1024f / 2f) - (size.Width / 2f), (768f / 2f) - (size.Height / 2f)), string.Format("Biscuit Dev Build {0}", _game.Version), shadow: true, colour: Color4.White) { Camera = Camera }; _startText = new Text(size => new PointF((1024f / 2f) - (size.Width / 2f), (768f / 2f) - (size.Height / 2f) + 50), "Press escape to begin", shadow: true, colour: Color4.Orange) {Camera = Camera}; _menuMusic = AudioManager.LoadFromFile(Resources.MENU_MUSIC); _menuMusic.Play(true, true); }
private void load(OsuConfigManager config) { Children = new Drawable[] { new SpriteText { Text = "Resolution: TODO dropdown" }, new CheckBoxOption { LabelText = "Fullscreen mode", Bindable = config.GetBindable<bool>(OsuConfig.Fullscreen), }, new CheckBoxOption { LabelText = "Letterboxing", Bindable = config.GetBindable<bool>(OsuConfig.Letterboxing), }, new SliderOption<int> { LabelText = "Horizontal position", Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.LetterboxPositionX) }, new SliderOption<int> { LabelText = "Vertical position", Bindable = (BindableInt)config.GetBindable<int>(OsuConfig.LetterboxPositionY) }, }; }
public OptionsSidebar() { RelativeSizeAxes = Axes.Y; InternalChildren = new Drawable[] { new Box { Colour = Color4.Black, RelativeSizeAxes = Axes.Both, }, new SidebarScrollContainer { Children = new [] { content = new FlowContainer { Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, AutoSizeAxes = Axes.Y, RelativeSizeAxes = Axes.X, Direction = FlowDirection.VerticalOnly } } }, }; }
/// <summary> /// This method is called when the sprite is told to draw /// itself on the window. /// </summary> public override void Render( Drawable dest, GC gc) { // Draw it out drawable.Render(dest, gc, state); }
public Preview(Drawable drawable, CoordinateList<int> coordinates) : base(drawable) { _coordinates = coordinates; PreviewArea area = Area; area.Events = EventMask.ButtonPressMask | EventMask.ButtonReleaseMask | EventMask.PointerMotionHintMask | EventMask.PointerMotionMask | EventMask.LeaveNotifyMask; ButtonPressEvent += (sender, args) => { // Fix me: calculate real-world coordinates _coordinates.Add(new Coordinate<int>((int) args.Event.X, (int) args.Event.Y)); }; ExposeEvent += delegate { var layout = new Pango.Layout(area.PangoContext); layout.FontDescription = FontDescription.FromString("Tahoma 16"); int i = 0; foreach (var coordinate in _coordinates) { layout.SetMarkup(String.Format("{0}", i)); // Fix me: transfer from real-world coordinates area.GdkWindow.DrawLayout(Style.TextGC(StateType.Normal), coordinate.X, coordinate.Y, layout); i++; } }; }
public void Render(Image image, Drawable drawable) { var newImage = GetImageFromGoogleCharts(drawable.Dimensions); if (newImage != null) { Display.Reconnect(image, newImage); } }
public override NodeActionState StartAction(Drawable target) { var sprite = target as Sprite; if (sprite == null) throw new ArgumentException("Animation action support only Sprite"); return new AnimateActionState(sprite, this); }
public Widget() : base() { prop = new WidgetProperties(); drawable = new Drawable(); InitializeConstraint(); InitializeBase(); }
public GameplaySection() { Children = new Drawable[] { new GeneralGameplayOptions(), new SongSelectGameplayOptions(), }; }
protected internal override void AddInternal(Drawable drawable) => AddInternal(drawable, true);
internal override DrawModule CreateDrawModule(Drawable drawable, GameContext context) { return(new W3dProjectileStreamDraw()); }
public override void Apply(Drawable d) { base.Apply(d); d.Position = new Vector2(d.InternalPosition.X, CurrentValue); }
// Forward all internal management to shakeContainer. // This is a bit ugly but we don't have the concept of InternalContent so it'll have to do for now. (https://github.com/ppy/osu-framework/issues/1690) protected override void AddInternal(Drawable drawable) => shakeContainer.Add(drawable);
public virtual bool TriggerOnFocusLost(Drawable drawable) { return(true); }
public ChannelListItem(Channel channel) { this.channel = channel; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; Action = () => { (channel.Joined ? OnRequestLeave : OnRequestJoin)?.Invoke(channel); }; Children = new Drawable[] { new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Direction = FillDirection.Horizontal, Children = new Drawable[] { new Container { Children = new[] { joinedCheckmark = new SpriteIcon { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, Icon = FontAwesome.fa_check_circle, Size = new Vector2(text_size), Shadow = false, Margin = new MarginPadding { Right = 10f }, }, }, }, new Container { Width = channel_width, AutoSizeAxes = Axes.Y, Children = new[] { name = new OsuSpriteText { Text = channel.ToString(), TextSize = text_size, Font = @"Exo2.0-Bold", Shadow = false, }, }, }, new Container { RelativeSizeAxes = Axes.X, Width = 0.7f, AutoSizeAxes = Axes.Y, Margin = new MarginPadding { Left = width_padding }, Children = new[] { topic = new OsuSpriteText { Text = channel.Topic, TextSize = text_size, Font = @"Exo2.0-SemiBold", Shadow = false, }, }, }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Margin = new MarginPadding { Left = width_padding }, Spacing = new Vector2(3f, 0f), Children = new Drawable[] { new SpriteIcon { Icon = FontAwesome.fa_user, Size = new Vector2(text_size - 2), Shadow = false, Margin = new MarginPadding { Top = 1 }, }, new OsuSpriteText { Text = @"0", TextSize = text_size, Font = @"Exo2.0-SemiBold", Shadow = false, }, }, }, }, }, }; }
protected override int Compare(Drawable x, Drawable y) => CompareReverseChildID(x, y);
private void clickDrawable(Drawable d) { InputManager.MoveMouseTo(d); InputManager.Click(MouseButton.Left); }
public SimpleDividerItemDecoration(Context context) { _divider = ContextCompat.GetDrawable(context, Resource.Drawable.toolsLineDivider); }
private void load(OverlayColourProvider colourProvider) { Height = 150; InternalChildren = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = colourProvider.Background5, }, new FillFlowContainer { Direction = FillDirection.Horizontal, Margin = new MarginPadding { Left = UserProfileOverlay.CONTENT_X_MARGIN }, Height = avatar_size, AutoSizeAxes = Axes.X, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Children = new Drawable[] { avatar = new UpdateableAvatar(isInteractive: false, showGuestOnNull: false) { Size = new Vector2(avatar_size), Masking = true, CornerRadius = avatar_size * 0.25f, }, new Container { RelativeSizeAxes = Axes.Y, AutoSizeAxes = Axes.X, Padding = new MarginPadding { Left = 10 }, Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Children = new Drawable[] { usernameText = new OsuSpriteText { Font = OsuFont.GetFont(size: 24, weight: FontWeight.Regular) }, openUserExternally = new ExternalLinkButton { Margin = new MarginPadding { Left = 5 }, Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, }, } }, titleText = new OsuSpriteText { Font = OsuFont.GetFont(size: 18, weight: FontWeight.Regular) }, } }, new FillFlowContainer { Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Direction = FillDirection.Vertical, AutoSizeAxes = Axes.Both, Children = new Drawable[] { supporterTag = new SupporterIcon { Height = 20, Margin = new MarginPadding { Top = 5 } }, new Box { RelativeSizeAxes = Axes.X, Height = 1.5f, Margin = new MarginPadding { Top = 10 }, Colour = colourProvider.Light1, }, new FillFlowContainer { AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Top = 5 }, Direction = FillDirection.Horizontal, Children = new Drawable[] { userFlag = new UpdateableFlag { Size = new Vector2(30, 20), ShowPlaceholderOnNull = false, }, userCountryText = new OsuSpriteText { Font = OsuFont.GetFont(size: 17.5f, weight: FontWeight.Regular), Margin = new MarginPadding { Left = 10 }, Origin = Anchor.CentreLeft, Anchor = Anchor.CentreLeft, Colour = colourProvider.Light1, } } }, } } } } } }, userStats = new FillFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, AutoSizeAxes = Axes.Y, Width = 300, Margin = new MarginPadding { Right = UserProfileOverlay.CONTENT_X_MARGIN }, Padding = new MarginPadding { Vertical = 15 }, Spacing = new Vector2(0, 2) } }; User.BindValueChanged(user => updateUser(user.NewValue)); }
private void load() { if (hitEvents == null || hitEvents.Count == 0) { return; } int[] bins = new int[total_timing_distribution_bins]; double binSize = Math.Ceiling(hitEvents.Max(e => Math.Abs(e.TimeOffset)) / timing_distribution_bins); // Prevent div-by-0 by enforcing a minimum bin size binSize = Math.Max(1, binSize); foreach (var e in hitEvents) { int binOffset = (int)(e.TimeOffset / binSize); bins[timing_distribution_centre_bin_index + binOffset]++; } int maxCount = bins.Max(); var bars = new Drawable[total_timing_distribution_bins]; for (int i = 0; i < bars.Length; i++) { bars[i] = new Bar { Height = Math.Max(0.05f, (float)bins[i] / maxCount) } } ; Container axisFlow; InternalChild = new GridContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Width = 0.8f, Content = new[] { new Drawable[] { new GridContainer { RelativeSizeAxes = Axes.Both, Content = new[] { bars } } }, new Drawable[] { axisFlow = new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y } }, }, RowDimensions = new[] { new Dimension(), new Dimension(GridSizeMode.AutoSize), } }; // Our axis will contain one centre element + 5 points on each side, each with a value depending on the number of bins * bin size. double maxValue = timing_distribution_bins * binSize; double axisValueStep = maxValue / axis_points; axisFlow.Add(new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "0", Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold) }); for (int i = 1; i <= axis_points; i++) { double axisValue = i * axisValueStep; float position = (float)(axisValue / maxValue); float alpha = 1f - position * 0.8f; axisFlow.Add(new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativePositionAxes = Axes.X, X = -position / 2, Alpha = alpha, Text = axisValue.ToString("-0"), Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold) }); axisFlow.Add(new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativePositionAxes = Axes.X, X = position / 2, Alpha = alpha, Text = axisValue.ToString("+0"), Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold) }); } }
public TouchHoldProgressPiece() { OsuColour colours = new OsuColour(); ProgressBindable.BindValueChanged(p => { redProgress.Current.Value = Math.Min(p.NewValue, .25); yellowProgress.Current.Value = Math.Min(p.NewValue, .50); greenProgress.Current.Value = Math.Min(p.NewValue, .75); blueProgress.Current.Value = p.NewValue; }); Origin = Anchor.Centre; Anchor = Anchor.Centre; Masking = true; BorderColour = Color4.White; BorderThickness = 3; Alpha = .8f; Size = new Vector2(110); CornerRadius = 27.5f; Rotation = 45; InternalChildren = new Drawable[] { new Container { Origin = Anchor.Centre, Anchor = Anchor.Centre, RelativeSizeAxes = Axes.Both, Size = new Vector2(2), Rotation = -45f, Children = new Drawable[] { blueProgress = new CircularProgress { Anchor = Anchor.Centre, Origin = Anchor.Centre, InnerRadius = 1, Size = Vector2.One, RelativeSizeAxes = Axes.Both, Current = { Value = 0 }, Colour = colours.Blue }, greenProgress = new CircularProgress { Anchor = Anchor.Centre, Origin = Anchor.Centre, InnerRadius = 1, Size = Vector2.One, RelativeSizeAxes = Axes.Both, Current = { Value = 0 }, Colour = colours.Green }, yellowProgress = new CircularProgress { Anchor = Anchor.Centre, Origin = Anchor.Centre, InnerRadius = 1, Size = Vector2.One, RelativeSizeAxes = Axes.Both, Current = { Value = 0 }, Colour = colours.Yellow, }, redProgress = new CircularProgress { Anchor = Anchor.Centre, Origin = Anchor.Centre, InnerRadius = 1, Size = Vector2.One, RelativeSizeAxes = Axes.Both, Current = { Value = 0 }, Colour = colours.Red, }, } } }; }
public virtual bool TriggeOnKeyUp(Drawable drawable) { return(true); }
public override bool Invalidate(Invalidation invalidation = Invalidation.All, Drawable source = null, bool shallPropagate = true) { t1.Text = (Padding.Top > 0 ? $"p{Padding.Top}" : string.Empty) + (Margin.Top > 0 ? $"m{Margin.Top}" : string.Empty); t2.Text = (Padding.Right > 0 ? $"p{Padding.Right}" : string.Empty) + (Margin.Right > 0 ? $"m{Margin.Right}" : string.Empty); t3.Text = (Padding.Bottom > 0 ? $"p{Padding.Bottom}" : string.Empty) + (Margin.Bottom > 0 ? $"m{Margin.Bottom}" : string.Empty); t4.Text = (Padding.Left > 0 ? $"p{Padding.Left}" : string.Empty) + (Margin.Left > 0 ? $"m{Margin.Left}" : string.Empty); return(base.Invalidate(invalidation, source, shallPropagate)); }
public override void Apply(Drawable d) { base.Apply(d); d.Size = CurrentValue; }
public override void Draw() { Drawable.Draw(this); }
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable);
private void load(OsuColour colours) { BeatmapSelectButton beatmapButton; ModDisplay modDisplay; InternalChildren = new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Masking = true, Children = new Drawable[] { new HeaderBackgroundSprite { RelativeSizeAxes = Axes.Both }, new Box { RelativeSizeAxes = Axes.Both, Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)), }, } }, new Box { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Height = 1, Colour = colours.Yellow }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING + OsuScreen.HORIZONTAL_OVERFLOW_PADDING }, Children = new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Padding = new MarginPadding { Top = 20 }, Direction = FillDirection.Vertical, Children = new Drawable[] { new BeatmapTypeInfo(), modDisplay = new ModDisplay { Scale = new Vector2(0.75f), DisplayUnrankedText = false }, } }, new Container { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, Width = 200, Padding = new MarginPadding { Vertical = 10 }, Child = beatmapButton = new BeatmapSelectButton { RelativeSizeAxes = Axes.Both, Height = 1, }, }, Tabs = new MatchTabControl { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X }, }, }, }; CurrentMods.BindValueChanged(m => modDisplay.Current.Value = m, true); beatmapButton.Action = () => RequestBeatmapSelection?.Invoke(); }
private void load(OsuColour colours) { Masking = true; CornerRadius = 5; InternalChildren = new Drawable[] { new Box { Name = "Gray Background", RelativeSizeAxes = Axes.Both, Colour = colours.Gray4 }, new GridContainer { RelativeSizeAxes = Axes.Both, Content = new[] { new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { new Box { Name = "Black Background", RelativeSizeAxes = Axes.Both, Colour = Color4.Black }, new TickSliderBar(beatDivisor, BindableBeatDivisor.VALID_DIVISORS) { RelativeSizeAxes = Axes.Both, } } } }, new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = colours.Gray4 }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = 5 }, Child = new GridContainer { RelativeSizeAxes = Axes.Both, Content = new[] { new Drawable[] { new DivisorButton { Icon = FontAwesome.fa_chevron_left, Action = beatDivisor.Previous }, new DivisorText(beatDivisor), new DivisorButton { Icon = FontAwesome.fa_chevron_right, Action = beatDivisor.Next } }, }, ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, 20), new Dimension(), new Dimension(GridSizeMode.Absolute, 20) } } } } } }, new Drawable[] { new TextFlowContainer(s => s.TextSize = 14) { Padding = new MarginPadding { Horizontal = 15 }, Text = "beat snap divisor", RelativeSizeAxes = Axes.X, TextAnchor = Anchor.TopCentre }, } }, RowDimensions = new[] { new Dimension(GridSizeMode.Absolute, 30), new Dimension(GridSizeMode.Absolute, 25), } } }; }
private void load(LadderInfo ladder, Storage storage) { this.ladder = ladder; RelativeSizeAxes = Axes.Both; InternalChildren = new Drawable[] { new TourneyVideo("schedule") { RelativeSizeAxes = Axes.Both, Loop = true, }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding(100) { Bottom = 50 }, Children = new Drawable[] { new GridContainer { RelativeSizeAxes = Axes.Both, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize), new Dimension(), }, Content = new[] { new Drawable[] { new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Children = new Drawable[] { new DrawableTournamentHeaderText(), new Container { Margin = new MarginPadding { Top = 40 }, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { Colour = Colour4.White, Size = new Vector2(50, 10), }, new TournamentSpriteTextWithBackground("Schedule") { X = 60, Scale = new Vector2(0.8f) } } }, } }, }, new Drawable[] { mainContainer = new Container { RelativeSizeAxes = Axes.Both, } } } } } }, }; }
public ModPanel(Mod mod) { Mod = mod; RelativeSizeAxes = Axes.X; Height = 42; // all below properties are applied to `Content` rather than the `ModPanel` in its entirety // to allow external components to set these properties on the panel without affecting // its "internal" appearance. Content.Masking = true; Content.CornerRadius = CORNER_RADIUS; Content.BorderThickness = 2; Content.Shear = new Vector2(ShearedOverlayContainer.SHEAR, 0); Children = new Drawable[] { Background = new Box { RelativeSizeAxes = Axes.Both }, SwitchContainer = new Container { RelativeSizeAxes = Axes.Y, Child = new ModSwitchSmall(mod) { Anchor = Anchor.Centre, Origin = Anchor.Centre, Active = { BindTarget = Active }, Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0), Scale = new Vector2(HEIGHT / ModSwitchSmall.DEFAULT_SIZE) } }, MainContentContainer = new Container { RelativeSizeAxes = Axes.Both, Child = new Container { RelativeSizeAxes = Axes.Both, Masking = true, CornerRadius = CORNER_RADIUS, Children = new Drawable[] { TextBackground = new Box { RelativeSizeAxes = Axes.Both }, TextFlow = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Horizontal = 17.5f, Vertical = 4 }, Direction = FillDirection.Vertical, Children = new[] { new OsuSpriteText { Text = mod.Name, Font = OsuFont.TorusAlternate.With(size: 18, weight: FontWeight.SemiBold), Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0), Margin = new MarginPadding { Left = -18 * ShearedOverlayContainer.SHEAR } }, new OsuSpriteText { Text = mod.Description, Font = OsuFont.Default.With(size: 12), RelativeSizeAxes = Axes.X, Truncate = true, Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0) } } } } } } }; Action = Active.Toggle; }
/// <summary> /// Sets a drawable for the backspace button. /// </summary> /// <param name="icon"></param> public void SetBackspaceIcon(Drawable icon) { _backspaceButton.SetImageDrawable(icon); }
public override bool UpdateSubTreeMasking(Drawable source, RectangleF maskingBounds) => false;
/// <summary> /// Sets a drawabale for the clear button. /// </summary> /// <param name="icon"></param> public void SetClearIcon(Drawable icon) { _clearButton.SetImageDrawable(icon); }
public UserPanel(User user) { this.user = user; Height = height - status_height; Masking = true; CornerRadius = 5; EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.25f), Radius = 4, }; Children = new Drawable[] { new AsyncLoadWrapper(new UserCoverBackground(user) { RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, FillMode = FillMode.Fill, OnLoadComplete = d => d.FadeInFromZero(200), }) { RelativeSizeAxes = Axes.Both }, new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.Black.Opacity(0.7f), }, new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Padding = new MarginPadding { Top = content_padding, Left = content_padding, Right = content_padding }, Children = new Drawable[] { new UpdateableAvatar { Size = new Vector2(height - status_height - content_padding * 2), User = user, Masking = true, CornerRadius = 5, EdgeEffect = new EdgeEffectParameters { Type = EdgeEffectType.Shadow, Colour = Color4.Black.Opacity(0.25f), Radius = 4, }, }, new Container { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Left = height - status_height - content_padding }, Children = new Drawable[] { new OsuSpriteText { Text = user.Username, TextSize = 18, Font = @"Exo2.0-SemiBoldItalic", }, new FillFlowContainer { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, AutoSizeAxes = Axes.X, Height = 20f, Direction = FillDirection.Horizontal, Spacing = new Vector2(5f, 0f), Children = new Drawable[] { new DrawableFlag(user.Country?.FlagName ?? @"__") { Width = 30f, RelativeSizeAxes = Axes.Y, }, new Container { Width = 40f, RelativeSizeAxes = Axes.Y, }, new CircularContainer { Width = 20f, RelativeSizeAxes = Axes.Y, }, }, }, }, }, }, }, statusBar = new Container { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.X, Alpha = 0f, Children = new Drawable[] { statusBg = new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f, }, new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Spacing = new Vector2(5f, 0f), Children = new[] { new TextAwesome { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Icon = FontAwesome.fa_circle_o, Shadow = true, TextSize = 14, }, statusMessage = new OsuSpriteText { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft, Font = @"Exo2.0-Semibold", }, }, }, }, }, }; }
public virtual bool TriggerOnMouseUp(Drawable drawable) { return(true); }
public Column(int index) { Index = index; RelativeSizeAxes = Axes.Y; Width = column_width; Masking = true; CornerRadius = 5; background = new ColumnBackground { RelativeSizeAxes = Axes.Both }; Container hitTargetContainer; InternalChildren = new Drawable[] { hitTargetContainer = new Container { Name = "Hit target + hit objects", RelativeSizeAxes = Axes.Both, Children = new Drawable[] { hitObjectArea = new ColumnHitObjectArea(HitObjectContainer) { RelativeSizeAxes = Axes.Both, }, explosionContainer = new Container { Name = "Hit explosions", RelativeSizeAxes = Axes.Both } } }, keyArea = new ColumnKeyArea { RelativeSizeAxes = Axes.X, Height = CrossStage.HIT_TARGET_POSITION, }, TopLevelContainer = new Container { RelativeSizeAxes = Axes.Both } }; TopLevelContainer.Add(explosionContainer.CreateProxy()); this.Anchor = Anchor.Centre; switch (Index) { case 0: this.OriginPosition = new Vector2(22, -30); this.Rotation = 90; break; case 1: this.OriginPosition = new Vector2(22, -30); this.Rotation = 180; break; case 2: this.OriginPosition = new Vector2(22, -30); this.Rotation = 0; break; case 3: this.OriginPosition = new Vector2(22, -30); this.Rotation = -90; break; } }
public override void SetImageDrawable(Drawable drawable) { }
private void load(OsuColour colours) { InternalChildren = new Drawable[] { new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Padding = new MarginPadding(20), Spacing = new Vector2(0, 10), Children = new Drawable[] { new OsuSpriteText { Margin = new MarginPadding { Vertical = 10 }, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Font = OsuFont.GetFont(size: 20), Text = "Let's create an account!", }, usernameTextBox = new OsuTextBox { PlaceholderText = "username", RelativeSizeAxes = Axes.X, TabbableContentContainer = this }, usernameDescription = new ErrorTextFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y }, emailTextBox = new OsuTextBox { PlaceholderText = "email address", RelativeSizeAxes = Axes.X, TabbableContentContainer = this }, emailAddressDescription = new ErrorTextFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y }, passwordTextBox = new OsuPasswordTextBox { PlaceholderText = "password", RelativeSizeAxes = Axes.X, TabbableContentContainer = this, }, passwordDescription = new ErrorTextFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y }, new Container { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Children = new Drawable[] { registerShake = new ShakeContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, Child = new SettingsButton { Text = "Register", Margin = new MarginPadding { Vertical = 20 }, Action = performRegistration } } } }, }, }, loadingLayer = new LoadingLayer(true) }; textboxes = new[] { usernameTextBox, emailTextBox, passwordTextBox }; usernameDescription.AddText("This will be your public presence. No profanity, no impersonation. Avoid exposing your own personal details, too!"); emailAddressDescription.AddText("Will be used for notifications, account verification and in the case you forget your password. No spam, ever."); emailAddressDescription.AddText(" Make sure to get it right!", cp => cp.Font = cp.Font.With(Typeface.Torus, weight: FontWeight.Bold)); passwordDescription.AddText("At least "); characterCheckText = passwordDescription.AddText("8 characters long"); passwordDescription.AddText(". Choose something long but also something you will remember, like a line from your favourite song."); passwordTextBox.Current.BindValueChanged(_ => updateCharacterCheckTextColour(), true); characterCheckText.DrawablePartsRecreated += _ => updateCharacterCheckTextColour(); }
public void UpdateDrawable() { if (_button == null || _nativeButton == null) { return; } bool cornerRadiusIsDefault = !_button.IsSet(Button.CornerRadiusProperty) || (_button.CornerRadius == (int)Button.CornerRadiusProperty.DefaultValue || _button.CornerRadius == ButtonDrawable.DefaultCornerRadius); bool backgroundColorIsDefault = !_button.IsSet(VisualElement.BackgroundColorProperty) || _button.BackgroundColor == (Color)VisualElement.BackgroundColorProperty.DefaultValue; bool borderColorIsDefault = !_button.IsSet(Button.BorderColorProperty) || _button.BorderColor == (Color)Button.BorderColorProperty.DefaultValue; bool borderWidthIsDefault = !_button.IsSet(Button.BorderWidthProperty) || _button.BorderWidth == (double)Button.BorderWidthProperty.DefaultValue; if (backgroundColorIsDefault && cornerRadiusIsDefault && borderColorIsDefault && borderWidthIsDefault) { if (!_drawableEnabled) { return; } if (_defaultDrawable != null) { _nativeButton.SetBackground(_defaultDrawable); } _drawableEnabled = false; } else { if (_backgroundDrawable == null) { _backgroundDrawable = new ButtonDrawable(_nativeButton.Context.ToPixels, Forms.GetColorButtonNormal(_nativeButton.Context)); } _backgroundDrawable.Button = _button; _backgroundDrawable.SetPaddingTop(_nativeButton.PaddingTop); if (_drawableEnabled) { return; } if (_defaultDrawable == null) { _defaultDrawable = _nativeButton.Background; } if (Forms.IsLollipopOrNewer) { var rippleColor = _backgroundDrawable.PressedBackgroundColor.ToAndroid(); _rippleDrawable = new RippleDrawable(ColorStateList.ValueOf(rippleColor), _backgroundDrawable, null); _nativeButton.SetBackground(_rippleDrawable); } else { _nativeButton.SetBackground(_backgroundDrawable); } _drawableEnabled = true; } _nativeButton.Invalidate(); }