private void DrawSpinner(BMAPI.v1.HitObjects.SpinnerObject hitObject, float alpha) { float diameter = 384; Vector2 pos = new Vector2(hitObject.Location.X, hitObject.Location.Y); this.spinnerTexture.Draw(pos, diameter, diameter, new Vector2(diameter * 0.5f), new Color(1.0f, 1.0f, 1.0f, alpha)); }
private void DrawSpinner(BMAPI.v1.HitObjects.SpinnerObject hitObject, float alpha) { int diameter = (int)this.Size.Y; Vector2 pos = this.InflateVector(new Vector2(hitObject.Location.X, hitObject.Location.Y)); Rectangle rect = new Rectangle((int)pos.X, (int)pos.Y, diameter, diameter); rect.X -= rect.Width / 2; rect.Y -= rect.Height / 2; this.spriteBatch.Draw(this.spinnerTexture, rect, null, new Color(1.0f, 1.0f, 1.0f, alpha), 0f, Vector2.Zero, SpriteEffects.None, 0.1f); }
private void DrawSpinnerApproachCircle(BMAPI.v1.HitObjects.SpinnerObject hitObject, float alpha, float value) { if (value < 0) { value = 0; } else if (value > 1) { value = 1; } int diameter = (int)(384.0f * (1 - value)); // TODO: flip when hardrock Vector2 pos = new Vector2(hitObject.Location.X, hitObject.Location.Y); this.spinnerTexture.Draw(pos, diameter, diameter, new Vector2(diameter * 0.5f), new Color(1.0f, 1.0f, 1.0f, alpha)); }
private void DrawSpinnerApproachCircle(BMAPI.v1.HitObjects.SpinnerObject hitObject, float alpha, float value) { if (value < 0) { value = 0; } else if (value > 1) { value = 1; } int diameter = (int)(this.spinnerTexture.Width * (1 - value) * 0.9); Vector2 pos = this.InflateVector(new Vector2(hitObject.Location.X, hitObject.Location.Y), true); Rectangle rect = new Rectangle((int)pos.X, (int)pos.Y, diameter, diameter); rect.X -= rect.Width / 2; rect.Y -= rect.Height / 2; this.spriteBatch.Draw(this.spinnerTexture, rect, null, new Color(1.0f, 1.0f, 1.0f, alpha), 0f, Vector2.Zero, SpriteEffects.None, 0.0f); }
private void Draw(bool isBackground) { if (this.Visual_MapInvert) { GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); this.MulFlipMatrix(); } //this.spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied); for (int b = this.nearbyHitObjects.Count - 1; b >= 0; b--) { BMAPI.v1.HitObjects.CircleObject hitObject = this.nearbyHitObjects[b]; // the song time relative to the hitobject start time float diff = (float)(hitObject.StartTime - this.songPlayer.SongTime); // transparency of hitobject float alpha = 1.0f; // a percentage of how open a slider is, 1.0 is closed, 0.0 is open float approachCircleValue = 0.0f; // length in time of hit object (only applies to sliders and spinners) int hitObjectLength = 0; // Use these types if the hitobject is a slider or spinner BMAPI.v1.HitObjects.SliderObject hitObjectAsSlider = null; BMAPI.v1.HitObjects.SpinnerObject hitObjectAsSpinner = null; if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner)) { hitObjectAsSpinner = (BMAPI.v1.HitObjects.SpinnerObject)hitObject; hitObjectLength = (int)(hitObjectAsSpinner.EndTime - hitObjectAsSpinner.StartTime); } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Slider)) { hitObjectAsSlider = (BMAPI.v1.HitObjects.SliderObject)hitObject; hitObjectLength = (int)((hitObjectAsSlider.SegmentEndTime - hitObjectAsSlider.StartTime) * hitObjectAsSlider.RepeatCount); //hitObjectLength = 500; } // for reference: this.approachRate is the time in ms it takes for approach circle to close if (diff < this.approachRate + this.State_FadeTime && diff > -(hitObjectLength + this.State_FadeTime)) { if (diff < -hitObjectLength) { // fade out alpha = 1 - ((diff + hitObjectLength) / -(float)this.State_FadeTime); } else if (!hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner) && diff >= this.approachRate && diff < this.approachRate + this.State_FadeTime) { // fade in alpha = 1 - (diff - this.approachRate) / (float)this.State_FadeTime; } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner)) { // because spinners don't have an approach circle before they appear if (diff >= 0 && diff < this.State_FadeTime) { alpha = 1 - diff / (float)this.State_FadeTime; } else if (diff > 0) { alpha = 0; } } if (diff < this.approachRate + this.State_FadeTime && diff > 0) { // hitcircle percentage from open to closed approachCircleValue = diff / (float)(this.approachRate + this.State_FadeTime); } else if (diff > 0) { approachCircleValue = 1.0f; } if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Circle)) { if (isBackground) { this.DrawHitcircle(hitObject, alpha); } else { this.DrawApproachCircle(hitObject, alpha, approachCircleValue); } } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Slider)) { this.DrawSlider(hitObjectAsSlider, alpha, approachCircleValue, isBackground); } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner)) { if (!isBackground) { this.DrawSpinner(hitObjectAsSpinner, alpha); this.DrawSpinnerApproachCircle(hitObjectAsSpinner, alpha, (float)(this.songPlayer.SongTime - hitObjectAsSpinner.StartTime) / (hitObjectAsSpinner.EndTime - hitObjectAsSpinner.StartTime)); } } } } if (this.Visual_MapInvert) { GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); } if (!isBackground) { bool forceFlip = false; if (this.State_PlaybackMode == 0) { if (MainForm.self.CurrentReplays[this.State_ReplaySelected] != null) { forceFlip = MainForm.self.CurrentReplays[this.State_ReplaySelected].AxisFlip; } if (forceFlip) { GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); this.MulFlipMatrix(); } Vector2 currentPos = Vector2.Zero; Vector2 lastPos = new Vector2(-222, 0); for (int i = 0; i < this.nearbyFrames[this.state_ReplaySelected].Count; i++) { ReplayAPI.ReplayFrame currentFrame = this.nearbyFrames[this.state_ReplaySelected][i]; float alpha = i / (float)this.nearbyFrames[this.state_ReplaySelected].Count; currentPos = new Vector2(currentFrame.X, currentFrame.Y); if (lastPos.X != -222) { this.DrawLine(lastPos, currentPos, new Color(1.0f, 0.0f, 0.0f, alpha)); } Color nodeColor = Color.Gray; if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.K1)) { nodeColor = Color.Cyan; } else if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.K2)) { nodeColor = Color.Magenta; } else if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.M1)) { nodeColor = Color.Lime; } else if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.M2)) { nodeColor = Color.Yellow; } this.nodeTexture.Draw(currentPos - new Vector2(5, 5), Vector2.Zero, nodeColor); lastPos = currentPos; } if (forceFlip) { GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); } } else if (this.State_PlaybackMode == 1) { for (int i = 0; i < 7; i++) { if (this.nearbyFrames[i] != null && this.nearbyFrames[i].Count >= 1) { forceFlip = MainForm.self.CurrentReplays[i].AxisFlip; if (forceFlip) { GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); this.MulFlipMatrix(); } Vector2 cursorPos = this.GetInterpolatedFrame(i); float diameter = 32.0f; this.cursorTexture.Draw(cursorPos, diameter, diameter, new Vector2(diameter * 0.5f), Canvas.Color_Cursor[i]); if (forceFlip) { GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); } } } } if (this.ShowHelp != 0) { GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.Ortho(0.0, 1.0, 1.0, 0.0, 0.0, 1.0); this.helpTexture.Draw(Vector2.Zero, 1.0f, 1.0f, Vector2.Zero, Color.White); GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); } } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(this.State_BackgroundColor); this.spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.NonPremultiplied); for (int b = this.nearbyHitObjects.Count - 1; b >= 0; b--) { BMAPI.v1.HitObjects.CircleObject hitObject = this.nearbyHitObjects[b]; // the song time relative to the hitobject start time float diff = (float)(hitObject.StartTime - this.songPlayer.SongTime); // transparency of hitobject float alpha = 1.0f; // a percentage of how open a slider is, 1.0 is closed, 0.0 is open float approachCircleValue = 0.0f; // length in time of hit object (only applies to sliders and spinners) int hitObjectLength = 0; // Use these types if the hitobject is a slider or spinner BMAPI.v1.HitObjects.SliderObject hitObjectAsSlider = null; BMAPI.v1.HitObjects.SpinnerObject hitObjectAsSpinner = null; if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner)) { hitObjectAsSpinner = (BMAPI.v1.HitObjects.SpinnerObject)hitObject; hitObjectLength = (int)(hitObjectAsSpinner.EndTime - hitObjectAsSpinner.StartTime); } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Slider)) { hitObjectAsSlider = (BMAPI.v1.HitObjects.SliderObject)hitObject; hitObjectLength = (int)((hitObjectAsSlider.SegmentEndTime - hitObjectAsSlider.StartTime) * hitObjectAsSlider.RepeatCount); //hitObjectLength = 500; } // for reference: this.approachRate is the time in ms it takes for approach circle to close if (diff < this.approachRate + this.State_FadeTime && diff > -(hitObjectLength + this.State_FadeTime)) { if (diff < -hitObjectLength) { // fade out alpha = 1 - ((diff + hitObjectLength) / -(float)this.State_FadeTime); } else if (!hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner) && diff >= this.approachRate && diff < this.approachRate + this.State_FadeTime) { // fade in alpha = 1 - (diff - this.approachRate) / (float)this.State_FadeTime; } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner)) { // because spinners don't have an approach circle before they appear if (diff >= 0 && diff < this.State_FadeTime) { alpha = 1 - diff / (float)this.State_FadeTime; } else if (diff > 0) { alpha = 0; } } if (diff < this.approachRate + this.State_FadeTime && diff > 0) { // hitcircle percentage from open to closed approachCircleValue = diff / (float)(this.approachRate + this.State_FadeTime); } else if (diff > 0) { approachCircleValue = 1.0f; } if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Circle)) { this.DrawHitcircle(hitObject, alpha, b); this.DrawApproachCircle(hitObject, alpha, approachCircleValue); } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Slider)) { this.DrawSlider(hitObjectAsSlider, alpha, b, approachCircleValue); } else if (hitObject.Type.HasFlag(BMAPI.v1.HitObjectType.Spinner)) { this.DrawSpinner(hitObjectAsSpinner, alpha); this.DrawSpinnerApproachCircle(hitObjectAsSpinner, alpha, (float)(this.songPlayer.SongTime - hitObjectAsSpinner.StartTime) / (hitObjectAsSpinner.EndTime - hitObjectAsSpinner.StartTime)); } } } if (this.State_PlaybackMode == 0) { Vector2 currentPos = Vector2.Zero; Vector2 lastPos = new Vector2(-222, 0); for (int i = 0; i < this.nearbyFrames[this.state_ReplaySelected].Count; i++) { ReplayAPI.ReplayFrame currentFrame = this.nearbyFrames[this.state_ReplaySelected][i]; float alpha = i / (float)this.nearbyFrames[this.state_ReplaySelected].Count; currentPos = this.InflateVector(new Vector2(currentFrame.X, currentFrame.Y)); bool selected = false; if (this.selectedFrames != null) { selected = this.selectedFrames.Contains(currentFrame); } if (lastPos.X != -222) { Color linecolor; if (selected) { linecolor = Color.White; } else { linecolor = new Color(1.0f, 0.0f, 0.0f, alpha); } this.DrawLine(lastPos, currentPos, linecolor); } Color nodeColor = Color.Gray; if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.K1)) { nodeColor = Color.Cyan; } else if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.K2)) { nodeColor = Color.Magenta; } else if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.M1)) { nodeColor = Color.Lime; } else if (currentFrame.Keys.HasFlag(ReplayAPI.Keys.M2)) { nodeColor = Color.Yellow; } if (!selected) { nodeColor.A = (byte)(alpha * 255); } this.spriteBatch.Draw(this.nodeTexture, currentPos - new Vector2(5, 5), nodeColor); lastPos = currentPos; } if (this.ToolRect.Width != 0 && this.ToolRect.Height != 0) { this.DrawTool(); } } else if (this.State_PlaybackMode == 1) { for (int i = 0; i < 7; i++) { if (this.nearbyFrames[i] != null && this.nearbyFrames[i].Count >= 1) { this.spriteBatch.Draw(this.cursorTexture, this.InflateVector(this.GetInterpolatedFrame(i)) - new Vector2(this.cursorTexture.Width, this.cursorTexture.Height) / 2f, Canvas.Color_Cursor[i]); } } } if (this.ShowHelp != 0) { this.spriteBatch.Draw(this.helpTexture, Vector2.Zero, Color.White); } this.spriteBatch.End(); base.Draw(gameTime); }