Beispiel #1
0
        /// <inheritdoc />
        /// <summary>
        /// </summary>
        /// <param name="panel"></param>
        /// <param name="hitsounds"></param>
        /// <param name="icon"></param>
        /// <param name="name"></param>
        public DrawableHitsound(EditorHitsoundsPanel panel, HitSounds hitsounds, Texture2D icon, string name) : base(UserInterface.BlankBox)
        {
            Panel     = panel;
            Hitsounds = hitsounds;
            Icon      = icon;
            Name      = name;
            Size      = new ScalableVector2(panel.Width, 52);

            CreateSpriteIcon();
            CreateHitsoundName();
            CreateActivatedSprite();

            Panel.SelectedObjectHitsounds.ValueChanged += OnSelectedHitsoundsChanged;
            Clicked += OnClicked;
        }
    protected override void Awake()
    {
        base.Awake();

        CytoidApplication.SetAutoRotation(true);
        CytoidApplication.ResetResolution();

        var ringColorDef    = "#FFFFFF";
        var ringColorAltDef = "#FFFFFF";
        var fillColorDef    = "#6699CC";
        var fillColorAltDef = "#FF3C38";

        SetDefaultPref("main offset", Application.platform == RuntimePlatform.Android ? 0f : 0.1f);
        SetDefaultPref("headset offset", -0.05f);
        SetDefaultPref("show_scanner", true);
        SetDefaultPref("inverse", false);
        SetDefaultPref("ring_color", ringColorDef);
        SetDefaultPref("ring_color_alt", ringColorAltDef);
        SetDefaultPref("fill_color", fillColorDef);
        SetDefaultPref("fill_color_alt", fillColorAltDef);
        SetDefaultPref("hit_sound", "None");

        var list = HitSounds.ToList();

        list.Insert(0, new HitSound {
            Name = "None"
        });
        HitSounds = list.ToArray();
        UpdateHitSound(HitSounds[1], save: false);

        var userHitSound = PlayerPrefs.GetString("hit_sound");

        for (var index = 0; index < HitSounds.Length; index++)
        {
            if (HitSounds[index].Name == userHitSound)
            {
                UpdateHitSound(HitSounds[index]);
                HitSoundIndex = index;
            }
        }

        mainOffsetInput.text          = PlayerPrefs.GetFloat("main offset").ToString();
        headsetOffsetInput.text       = PlayerPrefs.GetFloat("headset offset").ToString();
        earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator");
        largerHitboxesToggle.isOn     = PlayerPrefsExt.GetBool("larger_hitboxes");

        mainOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                mainOffsetInput.text = PlayerPrefs.GetFloat("main offset").ToString();
            }
            else
            {
                PlayerPrefs.SetFloat("main offset", offset);
            }
        });
        chartRelativeOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                chartRelativeOffsetInput.text = ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id)).ToString();
            }
            else
            {
                ZPlayerPrefs.SetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id), offset);
            }
        });
        headsetOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                headsetOffsetInput.text = PlayerPrefs.GetFloat("headset offset").ToString();
            }
            else
            {
                PlayerPrefs.SetFloat("headset offset", offset);
            }
        });

        usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername());
        passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword());

        if (!PlayerPrefs.HasKey("ranked"))
        {
            PlayerPrefsExt.SetBool("ranked", false);
        }

        rankStatusText.text = OnlinePlayer.Authenticated && PlayerPrefsExt.GetBool("ranked") ? "On" : "Off";

        // Initialize background
        blackout.SetActive(false);

        var backgrounds = GameObject.FindGameObjectsWithTag("Background");

        if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene)
        {
            var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene);
            // Destroy local background
            Destroy(localBackground);
            // Setup the persisted background
            BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);
        }
        else // Setup the local background
        {
            BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);
        }

        if (OnlinePlayer.Authenticated && OnlinePlayer.AvatarTexture != null)
        {
            LoadedAvatar = true;
        }

        if (Application.platform == RuntimePlatform.Android)
        {
            headsetOffsetInput.gameObject.SetActive(false);
            LayoutRebuilder.ForceRebuildLayoutImmediate(headsetOffsetInput.transform.parent.GetComponent <RectTransform>());
        }

        EventKit.Subscribe <string>("meta reloaded", OnLevelMetaReloaded);
    }
Beispiel #3
0
 /// <summary>
 /// </summary>
 public EditorActionRemoveHitsoundKeys(EditorRulesetKeys ruleset, List <DrawableEditorHitObject> hitobjects, HitSounds hitsound)
 {
     Ruleset    = ruleset;
     HitObjects = hitobjects;
     Hitsound   = hitsound;
 }
    protected override void Awake()
    {
        base.Awake();

        CytoidApplication.SetAutoRotation(true);

        var userOffsetDef   = Application.platform == RuntimePlatform.Android ? 0.12f : 0.2f;
        var ringColorDef    = "#FFFFFF";
        var ringColorAltDef = "#FFFFFF";
        var fillColorDef    = "#6699CC";
        var fillColorAltDef = "#FF3C38";

        SetDefaultPref("user_offset", userOffsetDef);
        SetDefaultPref("show_scanner", true);
        SetDefaultPref("inverse", false);
        SetDefaultPref("ring_color", ringColorDef);
        SetDefaultPref("ring_color_alt", ringColorAltDef);
        SetDefaultPref("fill_color", fillColorDef);
        SetDefaultPref("fill_color_alt", fillColorAltDef);
        SetDefaultPref("hit_sound", "None");

        var list = HitSounds.ToList();

        list.Insert(0, new HitSound {
            Name = "None", Clip = null
        });
        HitSounds = list.ToArray();
        UpdateHitSound(HitSounds[1], save: false);

        var userHitSound = PlayerPrefs.GetString("hit_sound");

        for (var index = 0; index < HitSounds.Length; index++)
        {
            if (HitSounds[index].Name == userHitSound)
            {
                UpdateHitSound(HitSounds[index]);
                HitSoundIndex = index;
            }
        }

        userOffsetInput.text          = PlayerPrefs.GetFloat("user_offset").ToString();
        showScannerToggle.isOn        = PlayerPrefsExt.GetBool("show_scanner");
        earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator");
        largerHitboxesToggle.isOn     = PlayerPrefsExt.GetBool("larger_hitboxes");
        isInversedToggle.isOn         = PlayerPrefsExt.GetBool("inverse");
        ringColorInput.text           = PlayerPrefs.GetString("ring_color");
        ringColorAltInput.text        = PlayerPrefs.GetString("ring_color_alt");
        fillColorInput.text           = PlayerPrefs.GetString("fill_color");
        fillColorAltInput.text        = PlayerPrefs.GetString("fill_color_alt");

        userOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                userOffsetInput.text = userOffsetDef.ToString();
            }
        });
        overrideOptionsToggle.onValueChanged.AddListener(selected =>
        {
            ZPlayerPrefs.SetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), selected);
        });
        localIsInversedToggle.onValueChanged.AddListener(selected =>
        {
            ZPlayerPrefs.SetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), selected);
        });
        localUserOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                localUserOffsetInput.text = userOffsetInput.text;
            }
            else
            {
                ZPlayerPrefs.SetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel), offset);
            }
        });
        ringColorInput.onEndEdit.AddListener(text =>
        {
            try
            {
                Convert.HexToColor(text);
            }
            catch (Exception)
            {
                ringColorInput.text = ringColorDef;
            }
        });
        ringColorAltInput.onEndEdit.AddListener(text =>
        {
            try
            {
                Convert.HexToColor(text);
            }
            catch (Exception)
            {
                ringColorAltInput.text = ringColorAltDef;
            }
        });
        fillColorInput.onEndEdit.AddListener(text =>
        {
            try
            {
                Convert.HexToColor(text);
            }
            catch (Exception)
            {
                fillColorInput.text = fillColorDef;
            }
        });
        fillColorAltInput.onEndEdit.AddListener(text =>
        {
            try
            {
                Convert.HexToColor(text);
            }
            catch (Exception)
            {
                fillColorAltInput.text = fillColorAltDef;
            }
        });
        usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername());
        passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword());

        if (!PlayerPrefs.HasKey(PreferenceKeys.RankedMode()))
        {
            PlayerPrefsExt.SetBool(PreferenceKeys.RankedMode(), false);
        }

        rankStatusText.text = "Off";

        // Initialize background
        blackout.SetActive(false);

        var backgrounds = GameObject.FindGameObjectsWithTag("Background");

        if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene)
        {
            var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene);
            // Destroy local background
            Destroy(localBackground);
            // Setup the persisted background
            BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);
        }
        else // Setup the local background
        {
            BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);
        }
    }
Beispiel #5
0
 /// <summary>
 ///     使用<seealso cref="HitSounds" />和两个<seealso cref="SampleSets" />构造一个SliderHitSound
 /// </summary>
 /// <param name="hitSound"></param>
 /// <param name="sampleSets"></param>
 /// <param name="additionSampleSet"></param>
 public SliderHitSound(HitSounds hitSound, SampleSets sampleSets, SampleSets additionSampleSet)
 {
     HitSound = hitSound;
     Sound    = new EdgeSound(sampleSets, additionSampleSet);
 }
Beispiel #6
0
 /// <summary>
 ///     使用<seealso cref="HitSounds" />构造一个SliderHitSound
 /// </summary>
 /// <param name="hitSound"></param>
 public SliderHitSound(HitSounds hitSound)
 {
     HitSound = hitSound;
 }
Beispiel #7
0
 /// <summary>
 ///     使用<seealso cref="HitSounds" />和<seealso cref="EdgeSound" />构造一个SliderHitSound
 /// </summary>
 /// <param name="hitSound"></param>
 /// <param name="edgeSound"></param>
 public SliderHitSound(HitSounds hitSound, EdgeSound edgeSound)
 {
     HitSound = hitSound;
     Sound    = edgeSound;
 }
Beispiel #8
0
 /// <summary>
 /// </summary>
 /// <param name="hitsounds"></param>
 public void SetHitSounds(HitSounds hitsounds)
 {
     ThrowUneditableException();
     HitSound = hitsounds;
 }
Beispiel #9
0
        /// <summary>
        ///     将字符串解析为Drumroll
        /// </summary>
        /// <param name="data"></param>
        public void Parse(string data) //(x,y)_,time,type,hitSound,endTime,hitSample
        {
            var info = data.Split(',');

            Position = new OsuPixel(int.Parse(info[0]), int.Parse(info[1]));
            var val = double.Parse(info[2]);

            Offset = double.IsNaN(val) || double.IsInfinity(val) ? 0 : (int)val;
            _type  = int.Parse(info[3]);
            var types = new HitObjectTypesConverter().Convert(_type, out var maybeBestVal);

            if (maybeBestVal != HitObjectTypes.Slider && maybeBestVal != HitObjectTypes.Spinner)
            {
                throw new ArgumentException("该行的数据不适用。");
            }

            if (maybeBestVal == HitObjectTypes.Spinner)
            {
                DrumRollType = DrumRollTypes.Spinner;
                if (!types.Contains(HitObjectTypes.Spinner))
                {
                    throw new ArgumentException("该行的数据不适用。");
                }

                HitSound = new HitSoundsConverter().Convert(int.Parse(info[4]), out _)[0];
                var eval = double.Parse(info[5]);
                EndTime = double.IsNaN(eval) || double.IsInfinity(eval) ? 0 : (int)eval;
                if (info.Length > 6)
                {
                    HitSample = new HitSample(info[6]);
                }
            }

            if (maybeBestVal == HitObjectTypes.Slider)
            {
                DrumRollType = DrumRollTypes.Slider;
                if (!types.Contains(HitObjectTypes.Slider))
                {
                    throw new ArgumentException("该行的数据不适用。");
                }

                HitSound = new HitSoundsConverter().Convert(int.Parse(info[4]), out _)[0];
                var sliderinfo   = info[5];
                var typeAndPoint = sliderinfo.Split('|');
                _curvetype = typeAndPoint[0];
                CurveType  = Slider.GetCurveTypeByString(_curvetype);
                for (var i = 1; i < typeAndPoint.Length; i++)
                {
                    var point = typeAndPoint[i].Split(':');
                    if (point.Length == 2)
                    {
                        var x = int.Parse(point[0]);
                        var y = int.Parse(point[1]);
                        curvePoints.Add(new OsuPixel(x, y));
                    }
                }

                RepeatTime = int.Parse(info[6]);
                Length     = double.Parse(info[7]);
                if (info.Length > 8)
                {
                    var sampleSets         = new List <SampleSets>();
                    var additionSampleSets = new List <SampleSets>();
                    var hitSounds          = new List <HitSounds>();
                    var hitSoundstrs       = info[8].Split('|');
                    foreach (var str in hitSoundstrs)
                    {
                        hitSounds.Add(new HitSoundsConverter().Convert(int.Parse(str), out _)[0]);
                    }
                    if (hitSoundstrs.Length > 0)
                    {
                        StartingHitSound = new SliderHitSound(hitSounds[0]);
                    }
                    if (hitSoundstrs.Length > 1)
                    {
                        DuringHitSound = new SliderHitSound(hitSounds[1]);
                    }
                    if (hitSoundstrs.Length > 2)
                    {
                        EndingHitSound = new SliderHitSound(hitSounds[2]);
                    }
                    if (info.Length > 9)
                    {
                        var sampleSetstrs = info[9].Split('|');
                        foreach (var sampleSetstr in sampleSetstrs)
                        {
                            var samples         = sampleSetstr.Split(':');
                            var sampleSet       = int.Parse(samples[0]);
                            var addionSampleSet = int.Parse(samples[1]);
                            sampleSets.Add((SampleSets)sampleSet);
                            additionSampleSets.Add((SampleSets)addionSampleSet);
                        }

                        if (sampleSets.Count > 1)
                        {
                            StartingHitSound = new SliderHitSound(hitSounds[0],
                                                                  new EdgeSound(sampleSets[0], additionSampleSets[0]));
                        }
                        if (sampleSets.Count > 2)
                        {
                            DuringHitSound = new SliderHitSound(hitSounds[1],
                                                                new EdgeSound(sampleSets[1], additionSampleSets[1]));
                        }
                        if (sampleSets.Count > 3)
                        {
                            EndingHitSound = new SliderHitSound(hitSounds[2],
                                                                new EdgeSound(sampleSets[2], additionSampleSets[2]));
                        }
                    }
                }
            }
        }