<commit_before>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;

namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
    public class SpinnerDisc : CircularContainer, IHasAccentColour, IKeyBindingHandler<OsuAction>
    {
        private readonly Spinner spinner;

        public Color4 AccentColour
        {
            get { return background.AccentColour; }
            set { background.AccentColour = value; }
        }

        private readonly SpinnerBackground background;

        private const float idle_alpha = 0.2f;
        private const float tracking_alpha = 0.4f;

        public SpinnerDisc(Spinner s)
        {
            spinner = s;

            RelativeSizeAxes = Axes.Both;

            Children = new Drawable[]
            {
                background = new SpinnerBackground { Alpha = idle_alpha },
            };
        }

        public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;

        private bool tracking;
        public bool Tracking
        {
            get { return tracking; }
            set
            {
                if (value == tracking) return;
                tracking = value;

                background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100);
            }
        }

        private bool complete;
        public bool Complete
        {
            get { return complete; }
            set
            {
                if (value == complete) return;
                complete = value;

                updateCompleteTick();
            }
        }

        private void updateTracking()
        {
            Tracking = mouseHasMainButtonPressed || actionLeftButtonPressed || actionRightButtonPressed;
        }

        protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
        {
            mouseHasMainButtonPressed |= state.Mouse.HasMainButtonPressed;
            updateTracking();
            return base.OnMouseDown(state, args);
        }

        protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
        {
            mouseHasMainButtonPressed &= state.Mouse.HasMainButtonPressed;
            updateTracking();
            return base.OnMouseUp(state, args);
        }

        protected override bool OnMouseMove(InputState state)
        {
            mouseHasMainButtonPressed |= state.Mouse.HasMainButtonPressed;
            mousePosition = Parent.ToLocalSpace(state.Mouse.NativeState.Position);
            updateTracking();
            return base.OnMouseMove(state);
        }

        public bool OnPressed(OsuAction action)
        {
            actionLeftButtonPressed |= action == OsuAction.LeftButton;
            actionRightButtonPressed |= action == OsuAction.RightButton;
            updateTracking();
            return false;
        }

        public bool OnReleased(OsuAction action)
        {
            actionLeftButtonPressed &= action == OsuAction.LeftButton;
            actionRightButtonPressed &= action == OsuAction.RightButton;
            updateTracking();
            return false;
        }

        private Vector2 mousePosition;
        private bool mouseHasMainButtonPressed;
        private bool actionLeftButtonPressed;
        private bool actionRightButtonPressed;

        private float lastAngle;
        private float currentRotation;
        public float RotationAbsolute;

        private int completeTick;

        private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 360));

        private bool rotationTransferred;

        protected override void Update()<commit_msg>Remove unnecessary OnMouseDown/Up from SpinnerDisc<commit_after>﻿// Copyright (c) 2007-2017 ppy Pty Ltd <<EMAIL>>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using System;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;

namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
{
    public class SpinnerDisc : CircularContainer, IHasAccentColour, IKeyBindingHandler<OsuAction>
    {
        private readonly Spinner spinner;

        public Color4 AccentColour
        {
            get { return background.AccentColour; }
            set { background.AccentColour = value; }
        }

        private readonly SpinnerBackground background;

        private const float idle_alpha = 0.2f;
        private const float tracking_alpha = 0.4f;

        public SpinnerDisc(Spinner s)
        {
            spinner = s;

            RelativeSizeAxes = Axes.Both;

            Children = new Drawable[]
            {
                background = new SpinnerBackground { Alpha = idle_alpha },
            };
        }

        public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => true;

        private bool tracking;
        public bool Tracking
        {
            get { return tracking; }
            set
            {
                if (value == tracking) return;
                tracking = value;

                background.FadeTo(tracking ? tracking_alpha : idle_alpha, 100);
            }
        }

        private bool complete;
        public bool Complete
        {
            get { return complete; }
            set
            {
                if (value == complete) return;
                complete = value;

                updateCompleteTick();
            }
        }

        protected override bool OnMouseMove(InputState state)
        {
            mousePosition = Parent.ToLocalSpace(state.Mouse.NativeState.Position);
            return base.OnMouseMove(state);
        }

        public bool OnPressed(OsuAction action)
        {
            actionLeftButtonPressed |= action == OsuAction.LeftButton;
            actionRightButtonPressed |= action == OsuAction.RightButton;
            Tracking = actionLeftButtonPressed || actionRightButtonPressed;
            return false;
        }

        public bool OnReleased(OsuAction action)
        {
            actionLeftButtonPressed &= action == OsuAction.LeftButton;
            actionRightButtonPressed &= action == OsuAction.RightButton;
            Tracking = actionLeftButtonPressed || actionRightButtonPressed;
            return false;
        }

        private Vector2 mousePosition;
        private bool actionLeftButtonPressed;
        private bool actionRightButtonPressed;

        private float lastAngle;
        private float currentRotation;
        public float RotationAbsolute;

        private int completeTick;

        private bool updateCompleteTick() => completeTick != (completeTick = (int)(RotationAbsolute / 360));

        private bool rotationTransferred;

        protected override void Update()
{'fraction_non_alphanumeric': 0.07116839450826562, 'fraction_numerical': 0.005884001120762118, 'mean_word_length': 2.0173288250211328, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1370936', 'n_tokens_mistral': 1841, 'n_tokens_neox': 1736, 'n_words': 432}