public override void Render(float delta, float mouseX, float mouseY) { var rect = ClientRectangle; IsMouseOver = rect.Contains(mouseX, mouseY); GL.Color3(0.05f, 0.05f, 0.05f); Glu.RenderQuad(rect); GL.Color3(0.2f, 0.2f, 0.2f); Glu.RenderOutline(rect); _alpha = Toggle ? Math.Min(1, _alpha + delta * 8) : Math.Max(0, _alpha - delta * 8); var checkSize = rect.Height * 0.75f * _alpha; var gap = (rect.Height - checkSize) / 2; if (checkSize > 0) { GL.Color4(1f, 0, 1, Math.Pow(_alpha, 4)); Glu.RenderQuad(rect.X + gap, rect.Y + gap, checkSize, checkSize); } var fr = EditorWindow.Instance.FontRenderer; var height = fr.GetHeight(24); GL.Color3(Color.FromArgb(0, 255, 200)); fr.Render(Text, (int)(rect.Right + rect.Height / 4), (int)(rect.Y + rect.Height / 2 - height / 2f), 24); }
protected virtual void RenderTimeline(RectangleF rect) { GL.Color4(Color.FromArgb(Color2[0], Color2[1], Color2[2])); Glu.RenderQuad(rect); GL.Color4(Color.FromArgb(Color2[0], Color2[1], Color2[2])); Glu.RenderOutline(rect); }
protected virtual void RenderTimeline(RectangleF rect) { GL.Color4(1, 0, 1, 0.75f); Glu.RenderQuad(rect); GL.Color4(1, 0, 1, 1f); Glu.RenderOutline(rect); }
public override void Render(float delta, float mouseX, float mouseY) { BPMBox.Render(delta, mouseX, mouseY); OffsetBox.Render(delta, mouseX, mouseY); foreach (var button in Buttons) { button.Render(delta, mouseX, mouseY); } BPMLabel.Render(delta, mouseX, mouseY); OffsetLabel.Render(delta, mouseX, mouseY); var fr = TimingPoints.Instance.FontRenderer; var width = OffsetBox.ClientRectangle.Right - BPMBox.ClientRectangle.Left; var height = ClientRectangle.Height / 2; var x = BPMBox.ClientRectangle.X; var y = BPMLabel.ClientRectangle.Y - height - 10; GL.LineWidth(5); GL.Color3(1f, 1f, 1f); Glu.RenderOutline(x, y, width, height); for (var i = 0; i < GuiTrack.BPMs.Count; i++) { if (i >= ScrollIndex && i < ScrollIndex + 8) { var bpm = GuiTrack.BPMs[i]; var by = y + height / 8 * (i - ScrollIndex); var bpmRect = new RectangleF(x, by, width, height / 8); if (bpmRect.Contains(mouseX, mouseY)) { GL.Color3(0, 0.5f, 1f); } if (i == SelectedIndex) { GL.Color3(0, 1f, 0); } Glu.RenderOutline(x, by, width, height / 8); GL.Color3(1f, 1f, 1f); fr.Render($"BPM: {bpm.bpm}", (int)x + 5, (int)by + 10, (int)(height / 8) - 10); fr.Render($"Offset: {bpm.Ms - GuiTrack.NoteOffset}", (int)(x + 5 + width / 2), (int)by + 10, (int)(height / 8) - 10); } } GL.LineWidth(1); }
private void RenderAutoPlay(Note last, Note next, float cellSize, RectangleF rect, double audioTime) { if (last == null) { last = _startNote; } if (next == null) { next = last; } var timeDiff = next.Ms - last.Ms; var timePos = audioTime - last.Ms; var progress = timeDiff == 0 ? 1 : (float)timePos / timeDiff; progress = (float)Math.Sin(progress * MathHelper.PiOver2); var s = (float)Math.Sin(progress * MathHelper.Pi) * 8 + 16; var lx = rect.X + last.X * cellSize; var ly = rect.Y + last.Y * cellSize; var nx = rect.X + next.X * cellSize; var ny = rect.Y + next.Y * cellSize; var x = cellSize / 2 + lx + (nx - lx) * progress; var y = cellSize / 2 + ly + (ny - ly) * progress; var cx = x - s / 2; var cy = y - s / 2; //something here is the autoplay cursor GL.Color4(1, 1, 1, 0.25f); Glu.RenderQuad(cx, cy, s, s); GL.Color4(1, 1, 1, 1f); GL.LineWidth(2); Glu.RenderOutline(cx, cy, s, s); GL.LineWidth(1); }
public override void Render(float delta, float mouseX, float mouseY) { if (EditorWindow.Instance.GuiScreen is GuiScreenSettings settings) { Color1 = new int[] { 255, 255, 255 }; Color2 = new int[] { 50, 50, 50 }; } else { Color1 = EditorWindow.Instance.Color1; Color2 = EditorWindow.Instance.Color2; } var rect = ClientRectangle; IsMouseOver = rect.Contains(mouseX, mouseY); GL.Color3(0.05f, 0.05f, 0.05f); Glu.RenderQuad(rect); GL.Color3(0.2f, 0.2f, 0.2f); Glu.RenderOutline(rect); _alpha = Toggle ? Math.Min(1, _alpha + delta * 8) : Math.Max(0, _alpha - delta * 8); var checkSize = rect.Height * 0.75f * _alpha; var gap = (rect.Height - checkSize) / 2; if (checkSize > 0) { GL.Color4(Color.FromArgb(255, Color2[0], Color2[1], Color2[2])); Glu.RenderQuad(rect.X + gap, rect.Y + gap, checkSize, checkSize); } var fr = EditorWindow.Instance.FontRenderer; var height = fr.GetHeight(FontSize); GL.Color3(Color.FromArgb(Color1[0], Color1[1], Color1[2])); fr.Render(Text, (int)(rect.Right + rect.Height / 4), (int)(rect.Y + rect.Height / 2 - height / 2f), FontSize); }
public override void Render(float delta, float mouseX, float mouseY) { IsMouseOver = ClientRectangle.Contains(mouseX, mouseY); _alpha = MathHelper.Clamp(_alpha + (IsMouseOver ? 10 : -10) * delta, 0, 1); if (Texture > 0) { if (IsMouseOver) { GL.Color3(0.75f, 0.75f, 0.75f); } else { GL.Color3(1f, 1, 1); } Glu.RenderTexturedQuad(ClientRectangle, 0, 0, 1, 1, Texture); } else { var d = 0.075f * _alpha; GL.Color3(0.1f + d, 0.1f + d, 0.1f + d); Glu.RenderQuad(ClientRectangle); GL.Color3(0.2f + d, 0.2f + d, 0.2f + d); Glu.RenderOutline(ClientRectangle); } var fr = EditorWindow.Instance.FontRenderer; var width = fr.GetWidth(Text, 24); var height = fr.GetHeight(24); GL.Color3(1f, 1, 1); fr.Render(Text, (int)(ClientRectangle.X + ClientRectangle.Width / 2 - width / 2f), (int)(ClientRectangle.Y + ClientRectangle.Height / 2 - height / 2f), 24); }
public override void Render(float delta, float mouseX, float mouseY) { // track transparency var editor = EditorWindow.Instance; int trackdim = EditorSettings.TrackOpacity; int[] Color1 = EditorWindow.Instance.Color1; int[] Color2 = EditorWindow.Instance.Color2; // waveform waveform = EditorSettings.Waveform; GL.Color4(Color.FromArgb(trackdim, 36, 35, 33)); var rect = ClientRectangle; Glu.RenderQuad(rect); GL.Color3(0.2f, 0.2f, 0.2f); Glu.RenderQuad((int)rect.X, (int)rect.Y + rect.Height, (int)rect.Width, 1); var fr = editor.FontRenderer; float cellSize = rect.Height; float noteSize = cellSize * 0.65f; var gap = cellSize - noteSize; double audioTime = editor.MusicPlayer.CurrentTime.TotalMilliseconds; float cubeStep = editor.CubeStep; float posX = (float)audioTime / 1000 * cubeStep; float maxX = (float)editor.MusicPlayer.TotalTime.TotalMilliseconds / 1000f * cubeStep; var zoomLvl = editor.Zoom; float lineSpace = cubeStep * zoomLvl; float lineX = ScreenX - posX; if (lineX < 0) { lineX %= lineSpace; } if (waveform) { GL.Color3(0.35f, 0.35f, 0.35f); GL.PushMatrix(); GL.BindVertexArray(editor.MusicPlayer.WaveModel.VaoID); GL.EnableVertexAttribArray(0); var p = posX / maxX; var total = zoomLvl * maxX; var waveX = -posX + ScreenX + maxX / 2; var scale = maxX; //;total; GL.Translate(waveX, rect.Height * 0.5, 0); GL.Scale(scale / 100000.0, -rect.Height, 1); GL.Translate(-50000, -0.5, 0); GL.LineWidth(2); editor.MusicPlayer.WaveModel.Render(PrimitiveType.LineStrip); GL.LineWidth(1); GL.Translate(50000 * scale, 0.5, 0); GL.Scale(1 / scale * 100000.0, -1.0 / rect.Height, 1); GL.Translate(-waveX, -rect.Height * 0.5, 0); GL.DisableVertexAttribArray(0); GL.BindVertexArray(0); GL.PopMatrix(); } /* * GL.Begin(PrimitiveType.LineStrip); * * for (double x = 0; x < rect.Width + 4; x += 4) * { * var peak = editor.MusicPlayer.GetPeak(audioTime + (x - ScreenX) / cubeStep * 1000) * rect.Height; * * GL.Vertex2(x + 0.5f, rect.Height - peak); * } * GL.End();*/ //render quarters of a second depending on zoom level /* * while (lineSpace > 0 && lineX < rect.Width) * { * GL.Color3(0.85f, 0.85f, 0.85f); * GL.Begin(PrimitiveType.Lines); * GL.Vertex2((int)lineX + 0.5f, rect.Y); * GL.Vertex2((int)lineX + 0.5f, rect.Y + 5); * GL.End(); * * lineX += lineSpace; * }*/ var mouseOver = false; //draw start line GL.LineWidth(2); GL.Color4(Color.FromArgb(Color2[0], Color2[1], Color2[2])); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)(ScreenX - posX), rect.Y); GL.Vertex2((int)(ScreenX - posX), rect.Y + rect.Height); GL.End(); var endLineX = ScreenX - posX + maxX + 1; //draw end line GL.Color4(1f, 0f, 0f, 1); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)endLineX, rect.Y); GL.Vertex2((int)endLineX, rect.Y + rect.Height); GL.End(); GL.LineWidth(1); MouseOverNote = null; MouseOverPoint = null; Note closest = null; var y = rect.Y + gap / 2; _cs.Reset(); for (int i = 0; i < editor.Notes.Count; i++) { Note note = EditorWindow.Instance.Notes[i]; if (editor.GuiScreen is GuiScreenEditor gse) { var offset = 0L; long.TryParse(gse.SfxOffset.Text, out offset); if (note.Ms <= (long)(EditorWindow.Instance.MusicPlayer.CurrentTime.TotalMilliseconds - offset)) { closest = note; } } note.Color = _cs.Next(); var x = Math.Round(ScreenX - posX + note.Ms / 1000f * cubeStep); if (x > rect.Width) { break; } if (x < rect.X - noteSize) { continue; } var alphaMult = 1f; if (audioTime - 1 > note.Ms) //(x <= ScreenX) { alphaMult = 0.35f; } var noteRect = new RectangleF((int)x, (int)y, noteSize, noteSize); var b = MouseOverNote == null && !mouseOver && noteRect.Contains(mouseX, mouseY); if ((b || EditorWindow.Instance.SelectedNotes.Contains(note)) && !EditorWindow.Instance.IsDraggingNoteOnTimeLine) { if (b) { MouseOverNote = note; mouseOver = true; GL.Color3(0, 1, 0.25f); } else { GL.Color3(0, 0.5f, 1); } Glu.RenderOutline((int)(x - 4), (int)(y - 4), (int)(noteSize + 8), (int)(noteSize + 8)); } var c = Color.FromArgb((int)(15 * alphaMult), (int)note.Color.R, (int)note.Color.G, (int)note.Color.B); GL.Color4(c); Glu.RenderQuad((int)x, (int)y, (int)noteSize, (int)noteSize); GL.Color4(note.Color.R, note.Color.G, note.Color.B, alphaMult); Glu.RenderOutline((int)x, (int)y, (int)noteSize, (int)noteSize); var gridGap = 2; for (int j = 0; j < 9; j++) { var indexX = 2 - j % 3; var indexY = 2 - j / 3; var gridX = (int)x + indexX * (9 + gridGap) + 5; var gridY = (int)y + indexY * (9 + gridGap) + 5; if (Math.Round(note.X, 3) == indexX && Math.Round(note.Y, 3) == indexY) { GL.Color4(note.Color.R, note.Color.G, note.Color.B, alphaMult); Glu.RenderQuad(gridX, gridY, 9, 9); } else { GL.Color4(note.Color.R, note.Color.G, note.Color.B, alphaMult * 0.45); Glu.RenderOutline(gridX, gridY, 9, 9); } } var numText = $"{(i + 1):##,###}"; var msText = $"{note.Ms:##,###}"; if (msText == "") { msText = "0"; } GL.Color3(Color.FromArgb(Color1[0], Color1[1], Color1[2])); fr.Render(numText, (int)x + 3, (int)(rect.Y + rect.Height) + 3, 16); GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); fr.Render($"{msText}ms", (int)x + 3, (int)(rect.Y + rect.Height + fr.GetHeight(16)) + 3 + 2, 16); //draw line GL.Color4(1f, 1f, 1f, alphaMult); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)x + 0.5f, rect.Y + rect.Height + 3); GL.Vertex2((int)x + 0.5f, rect.Y + rect.Height + 28); GL.End(); } if (_lastPlayedNote != closest) { _lastPlayedNote = closest; if (closest != null && editor.MusicPlayer.IsPlaying && editor.GuiScreen is GuiScreenEditor gse) { editor.SoundPlayer.Play("hit", gse.SfxVolume.Value / (float)gse.SfxVolume.MaxValue, editor.MusicPlayer.Tempo); } } if (!Settings.Default.LegacyBPM) { for (var i = 0; i < BPMs.Count; i++) { var Bpm = BPMs[i]; double nextoffset = 0; double nextLineX = endLineX; double currentoffset = Bpm.Ms; double offsetint = 60000 / Bpm.bpm / BeatDivisor; if (i + 1 < BPMs.Count) { nextoffset = BPMs[i + 1].Ms; } else { nextoffset = editor.MusicPlayer.TotalTime.TotalMilliseconds * 2; } if (Bpm.bpm > 33) { lineSpace = 60 / Bpm.bpm * cubeStep; var stepSmall = lineSpace / BeatDivisor; lineX = ScreenX - posX + Bpm.Ms / 1000f * cubeStep; if (lineX < 0) { lineX %= lineSpace; } if (i + 1 < BPMs.Count) { nextLineX = ScreenX - posX + nextoffset / 1000f * cubeStep; } if (nextLineX < 0) { nextLineX %= lineSpace; } if (lineSpace > 0 && lineX < rect.Width && lineX > 0) { //draw offset start line GL.Color4(Color.FromArgb(255, 0, 0)); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, 0); GL.Vertex2((int)lineX + 0.5f, rect.Bottom + 56); GL.End(); } //draw timing point info var x = Math.Round(ScreenX - posX + Bpm.Ms / 1000f * cubeStep); var numText = $"{Bpm.bpm:##,###.###}"; if (numText == "") { numText = "0"; } var msText = $"{Bpm.Ms:##,###}"; if (msText == "") { msText = "0"; } GL.Color3(Color.FromArgb(Color1[0], Color1[1], Color1[2])); fr.Render(numText, (int)x + 3, (int)(rect.Y + rect.Height) + 3 + 28, 16); GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); fr.Render($"{msText}ms", (int)x + 3, (int)(rect.Y + rect.Height + fr.GetHeight(16)) + 3 + 2 + 28, 16); //render BPM lines while (lineSpace > 0 && lineX < rect.Width && lineX < endLineX && lineX < nextLineX) { GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, rect.Bottom); GL.Vertex2((int)lineX + 0.5f, rect.Bottom - 11); GL.End(); for (int j = 1; j <= BeatDivisor; j++) { var xo = lineX + j * stepSmall; if (j < BeatDivisor && xo < endLineX && xo < nextLineX) { var half = j == BeatDivisor / 2 && BeatDivisor % 2 == 0; if (half) { GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); } else { GL.Color3(Color.FromArgb(Color1[0], Color1[1], Color1[2])); } GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)xo + 0.5f, rect.Bottom - (half ? 7 : 4)); GL.Vertex2((int)xo + 0.5f, rect.Bottom); GL.End(); } } lineX += lineSpace; } var w = Math.Max(fr.GetWidth($"{Bpm.Ms:##,###}ms", 16), fr.GetWidth($"{Bpm.bpm:##,###}", 16)); var pointRect = new RectangleF((int)x, rect.Bottom, w + 3, 56); var g = MouseOverPoint == null && pointRect.Contains(mouseX, mouseY); if (g || EditorWindow.Instance._draggedPoint == Bpm && !EditorWindow.Instance.IsDraggingPointOnTimeline) { if (g) { MouseOverPoint = Bpm; GL.Color3(0, 1, 0.25f); } else { GL.Color3(0, 0.5f, 1); } Glu.RenderOutline((int)(x - 4), rect.Bottom, w + 3 + 8, 56 + 4); } } } } else { double offsetint = 60000 / Bpm / BeatDivisor; if (Bpm > 33) { lineSpace = 60 / Bpm * cubeStep; var stepSmall = lineSpace / BeatDivisor; lineX = ScreenX - posX + BpmOffset / 1000f * cubeStep; if (lineX < 0) { lineX %= lineSpace; } if (lineSpace > 0 && lineX < rect.Width && lineX > 0) { //draw offset start line GL.Color4(Color.FromArgb(255, 0, 0)); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, 0); GL.Vertex2((int)lineX + 0.5f, rect.Bottom + 56); GL.End(); } //draw timing point info var x = Math.Round(ScreenX - posX + BpmOffset / 1000f * cubeStep); var numText = $"{Bpm:##,###}"; GL.Color3(Color.FromArgb(Color1[0], Color1[1], Color1[2])); fr.Render(numText, (int)x + 3, (int)(rect.Y + rect.Height) + 3 + 28, 16); GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); fr.Render($"{BpmOffset:##,###}ms", (int)x + 3, (int)(rect.Y + rect.Height + fr.GetHeight(16)) + 3 + 2 + 28, 16); //render BPM lines while (lineSpace > 0 && lineX < rect.Width && lineX < endLineX) { GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, rect.Bottom); GL.Vertex2((int)lineX + 0.5f, rect.Bottom - 11); GL.End(); for (int j = 1; j <= BeatDivisor; j++) { var xo = lineX + j * stepSmall; if (j < BeatDivisor && xo < endLineX) { var half = j == BeatDivisor / 2 && BeatDivisor % 2 == 0; if (half) { GL.Color3(Color.FromArgb(Color2[0], Color2[1], Color2[2])); } else { GL.Color3(Color.FromArgb(Color1[0], Color1[1], Color1[2])); } GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)xo + 0.5f, rect.Bottom - (half ? 7 : 4)); GL.Vertex2((int)xo + 0.5f, rect.Bottom); GL.End(); } } lineX += lineSpace; } } } if (editor.GuiScreen is GuiScreenEditor gse1 && gse1.Metronome.Toggle) { //bool bdbool = true; double.TryParse(gse1.SfxOffset.Text, out var offset); var ms = editor.MusicPlayer.CurrentTime.TotalMilliseconds - offset; var bpm = editor.GetCurrentBpm(editor.MusicPlayer.CurrentTime.TotalMilliseconds); int div = BeatDivisor; //1; /*- * if (bdbool) * { * div = BeatDivisor; * } */ double interval = 60000 / bpm.bpm / div; double remainder = (ms - bpm.Ms) % interval; double closestMS = ms - remainder; if (_lastPlayedMS != closestMS && remainder >= 0 && editor.MusicPlayer.IsPlaying) { _lastPlayedMS = closestMS; editor.SoundPlayer.Play("metronome", gse1.SfxVolume.Value / (float)gse1.SfxVolume.MaxValue, editor.MusicPlayer.Tempo); } } //draw screen line GL.Color4(1f, 1, 1, 0.75); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)(rect.X + ScreenX) + 0.5, rect.Y + 4); GL.Vertex2((int)(rect.X + ScreenX) + 0.5, rect.Y + rect.Height - 4); GL.End(); //GL.Color3(1, 1, 1f); //FontRenderer.Print("HELLO", 0, rect.Y + rect.Height + 8); }
public override void Render(float delta, float mouseX, float mouseY) { GL.Color3(0.1f, 0.1f, 0.1f); var rect = ClientRectangle; Glu.RenderQuad(rect); GL.Color3(0.2f, 0.2f, 0.2f); Glu.RenderQuad((int)rect.X, (int)rect.Y + rect.Height, (int)rect.Width, 1); var fr = EditorWindow.Instance.FontRenderer; float cellSize = rect.Height; float noteSize = cellSize * 0.65f; var gap = cellSize - noteSize; float audioTime = (float)EditorWindow.Instance.MusicPlayer.CurrentTime.TotalMilliseconds; float cubeStep = EditorWindow.Instance.CubeStep; float posX = audioTime / 1000 * cubeStep; float maxX = (float)EditorWindow.Instance.MusicPlayer.TotalTime.TotalMilliseconds / 1000f * cubeStep; var zoomLvl = EditorWindow.Instance.Zoom; float lineSpace = cubeStep / zoomLvl; float lineX = ScreenX - posX; if (lineX < 0) { lineX %= lineSpace; } //render quarters of a second depending on zoom level while (lineSpace > 0 && lineX < rect.Width) { GL.Color3(0.85f, 0.85f, 0.85f); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, rect.Y); GL.Vertex2((int)lineX + 0.5f, rect.Y + 5); GL.End(); lineX += lineSpace; } var mouseOver = false; //draw start line GL.LineWidth(2); GL.Color4(0f, 1f, 0f, 1); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)(ScreenX - posX), rect.Y); GL.Vertex2((int)(ScreenX - posX), rect.Y + rect.Height); GL.End(); var endLineX = ScreenX - posX + maxX + 1; //draw end line GL.Color4(1f, 0f, 0f, 1); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)endLineX, rect.Y); GL.Vertex2((int)endLineX, rect.Y + rect.Height); GL.End(); GL.LineWidth(1); MouseOverNote = null; _cs.Reset(); for (int i = 0; i < EditorWindow.Instance.Notes.Count; i++) { Note note = EditorWindow.Instance.Notes[i]; note.Color = _cs.Next(); var x = Math.Round(ScreenX - posX + note.Ms / 1000f * cubeStep); if (x > rect.Width) { break; } if (x < rect.X - noteSize) { continue; } var alphaMult = 1f; if (audioTime - 1 > note.Ms) //(x <= ScreenX) { alphaMult = 0.35f; } var y = rect.Y + gap / 2; var noteRect = new RectangleF((int)x, (int)y, noteSize, noteSize); var b = MouseOverNote == null && !mouseOver && noteRect.Contains(mouseX, mouseY); if ((b || EditorWindow.Instance.SelectedNotes.Contains(note)) && !EditorWindow.Instance.IsDraggingNoteOnTimeLine) { if (b) { MouseOverNote = note; mouseOver = true; GL.Color3(0, 1, 0.25f); } else { GL.Color3(0, 0.5f, 1); } Glu.RenderOutline((int)(x - 4), (int)(y - 4), (int)(noteSize + 8), (int)(noteSize + 8)); } var c = Color.FromArgb((int)(15 * alphaMult), note.Color); GL.Color4(c); Glu.RenderQuad((int)x, (int)y, (int)noteSize, (int)noteSize); GL.Color4(note.Color.R, note.Color.G, note.Color.B, alphaMult); Glu.RenderOutline((int)x, (int)y, (int)noteSize, (int)noteSize); var gridGap = 2; for (int j = 0; j < 9; j++) { var indexX = 2 - j % 3; var indexY = 2 - j / 3; var gridX = (int)x + indexX * (9 + gridGap) + 5; var gridY = (int)y + indexY * (9 + gridGap) + 5; if (note.X == indexX && note.Y == indexY) { GL.Color4(note.Color.R, note.Color.G, note.Color.B, alphaMult); Glu.RenderQuad(gridX, gridY, 9, 9); } else { GL.Color4(note.Color.R, note.Color.G, note.Color.B, alphaMult * 0.45); Glu.RenderOutline(gridX, gridY, 9, 9); } } var numText = $"{(i + 1):##,###}"; GL.Color3(0, 1, 200 / 255f); fr.Render(numText, (int)x + 3, (int)(rect.Y + rect.Height) + 3, 16); GL.Color3(1f, 0, 1); fr.Render($"{note.Ms:##,###}ms", (int)x + 3, (int)(rect.Y + rect.Height + fr.GetHeight(16)) + 3 + 2, 16); //draw line GL.Color4(1f, 1f, 1f, alphaMult); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)x + 0.5f, rect.Y + rect.Height + 3); GL.Vertex2((int)x + 0.5f, rect.Y + rect.Height + 28); GL.End(); } if (Bpm > 33) { lineSpace = 60 / Bpm * cubeStep; var stepSmall = lineSpace / BeatDivisor; lineX = ScreenX - posX + BpmOffset / 1000f * cubeStep; if (lineX < 0) { lineX %= lineSpace; } if (lineSpace > 0 && lineX < rect.Width) { //draw offset start line GL.Color4(0f, 1f, 200 / 255f, 0.5); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, 0); GL.Vertex2((int)lineX + 0.5f, rect.Bottom); GL.End(); } //render BPM lines while (lineSpace > 0 && lineX < rect.Width && lineX < endLineX) { GL.Color3(0, 1f, 0); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)lineX + 0.5f, rect.Bottom); GL.Vertex2((int)lineX + 0.5f, rect.Bottom - 11); GL.End(); for (int j = 1; j <= BeatDivisor; j++) { var xo = lineX + j * stepSmall; if (j < BeatDivisor && xo < endLineX) { var half = j == BeatDivisor / 2 && BeatDivisor % 2 == 0; if (half) { GL.Color3(0.15f, 0.75f, 0); } else { GL.Color3(0, 0.5f, 0.5f); } GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)xo + 0.5f, rect.Bottom - (half ? 7 : 4)); GL.Vertex2((int)xo + 0.5f, rect.Bottom); GL.End(); } } lineX += lineSpace; } } //draw screen line GL.Color4(1f, 1, 1, 0.75); GL.Begin(PrimitiveType.Lines); GL.Vertex2((int)(rect.X + ScreenX) + 0.5, rect.Y + 4); GL.Vertex2((int)(rect.X + ScreenX) + 0.5, rect.Y + rect.Height - 4); GL.End(); //GL.Color3(1, 1, 1f); //FontRenderer.Print("HELLO", 0, rect.Y + rect.Height + 8); }
public override void Render(float delta, float mouseX, float mouseY) { var IsMouseOverr = ClientRectangle.Contains(mouseX, mouseY); if (IsMouseOver && !IsMouseOverr) { OnMouseLeave(mouseX, mouseY); } else if (!IsMouseOver && IsMouseOverr) { OnMouseEnter(mouseX, mouseY); } IsMouseOver = IsMouseOverr; _alpha = MathHelper.Clamp(_alpha + (IsMouseOver ? 10 : -10) * delta, 0, 1); if (Texture > 0) { if (IsMouseOver) { GL.Color3(0.75f, 0.75f, 0.75f); } else { GL.Color3(1f, 1, 1); } Glu.RenderTexturedQuad(ClientRectangle, 0, 0, 1, 1, Texture); } else { if (Alpha != 0) { if (IsMouseOver) { GL.Color4(Color.FromArgb(130, 0, 0, 0)); } else { GL.Color4(Color.FromArgb(Alpha, 0, 0, 0)); } Glu.RenderQuad(ClientRectangle); GL.Color4(Color.FromArgb(Alpha, 0, 0, 0)); Glu.RenderOutline(ClientRectangle); } else { var d = 0.075f * _alpha; GL.Color3(0.1f + d, 0.1f + d, 0.1f + d); Glu.RenderQuad(ClientRectangle); GL.Color3(0.2f + d, 0.2f + d, 0.2f + d); Glu.RenderOutline(ClientRectangle); } } if (Font == "squareo") { fr = EditorWindow.Instance.SquareOFontRenderer; } else if (Font == "square") { fr = EditorWindow.Instance.SquareFontRenderer; } else if (Font == "main") { fr = EditorWindow.Instance.FontRenderer; } var width = fr.GetWidth(Text, (int)ClientRectangle.Height / 2); var height = fr.GetHeight((int)ClientRectangle.Height / 2); GL.Color3(color1, color2, color3); if (!Timings) { fr.Render(Text, (int)(ClientRectangle.X + ClientRectangle.Width / 2 - width / 2f), (int)(ClientRectangle.Y + ClientRectangle.Height / 2 - height / 2f), (int)ClientRectangle.Height / 2); } else { TimingPoints.Instance.FontRenderer.Render(Text, (int)(ClientRectangle.X + ClientRectangle.Width / 2 - width / 2f), (int)(ClientRectangle.Y + ClientRectangle.Height / 2 - height / 2f), (int)ClientRectangle.Height / 2); } }
public override void Render(float delta, float mouseX, float mouseY) { var editor = (GuiScreenEditor)EditorWindow.Instance.GuiScreen; var rect = ClientRectangle; var mouseOver = false; // grid transparency int griddim = EditorSettings.GridOpacity; GL.Color4(Color.FromArgb(griddim, 36, 35, 33)); Glu.RenderQuad(rect.X, rect.Y, rect.Width, rect.Height); var cellSize = rect.Width / 3f; var noteSize = cellSize * 0.75f; var gap = cellSize - noteSize; var audioTime = EditorWindow.Instance.MusicPlayer.CurrentTime.TotalMilliseconds; if (editor.Numpad.Toggle) { if (EditorWindow.Instance.inputState == "keyboard") { EditorWindow.Instance.ChangeKeyMapping("numpad"); } } else { if (EditorWindow.Instance.inputState == "numpad") { EditorWindow.Instance.ChangeKeyMapping("keyboard"); } } GL.Color3(0.2, 0.2, 0.2f); for (float y = 0; y <= 3; y++) { var ly = y * cellSize; Glu.RenderQuad((int)(rect.X), (int)(rect.Y + ly), rect.Width + 1, 1); } for (float x = 0; x <= 3; x++) { var lx = x * cellSize; Glu.RenderQuad((int)(rect.X + lx), (int)(rect.Y), 1, rect.Height + 1); } if (editor.NoteAlign.Value != 1 && editor.QuantumGridLines.Toggle) { GL.Begin(PrimitiveType.Lines); var div = editor.NoteAlign.Value + 1; for (int i = 1; i < div; i++) { //GL.Vertex2(rect.X + rect.Width / div * i, rect.Y); //GL.Vertex2(rect.X + rect.Width / div * i, rect.Y + rect.Height / div * i); GL.Vertex2(rect.X + rect.Width / div * i, rect.Y); GL.Vertex2(rect.X + rect.Width / div * i, rect.Y + rect.Height); GL.Vertex2(rect.X, rect.Y + rect.Height / div * i); GL.Vertex2(rect.X + rect.Width, rect.Y + rect.Height / div * i); } GL.End(); } var fr = EditorWindow.Instance.FontRenderer; GL.Color3(0.2f, 0.2f, 0.2f); foreach (var pair in EditorWindow.Instance.KeyMapping) { if (pair.Key == Key.Y) { continue; } var letter = pair.Key == Key.Z ? "Y/Z" : pair.Key.ToString(); if (letter.Length > 1) { letter = letter.Replace("Keypad", ""); } var tuple = pair.Value; var x = rect.X + tuple.Item1 * cellSize + cellSize / 2; var y = rect.Y + tuple.Item2 * cellSize + cellSize / 2; var width = fr.GetWidth(letter, 38); var height = fr.GetHeight(38); fr.Render(letter, (int)(x - width / 2f), (int)(y - height / 2), 38); } Note last = null; Note next = null; for (var index = 0; index < EditorWindow.Instance.Notes.Count; index++) { var note = EditorWindow.Instance.Notes[index]; var passed = audioTime > note.Ms + 1; var visible = !passed && note.Ms - audioTime <= 750; if (passed) { last = note; } else if (next == null) { next = note; } if (!visible) { if (passed && next != null) { break; } continue; } var x = rect.X + note.X * cellSize + gap / 2; var y = rect.Y + note.Y * cellSize + gap / 2; var progress = (float)Math.Pow(1 - Math.Min(1, (note.Ms - audioTime) / 750.0), 2); var noteRect = new RectangleF(x, y, noteSize, noteSize); OpenTK.Graphics.Color4 colora = new OpenTK.Graphics.Color4(note.Color.R, note.Color.G, note.Color.B, progress * 0.15f); GL.Color4(colora); Glu.RenderQuad(noteRect); OpenTK.Graphics.Color4 color = new OpenTK.Graphics.Color4(note.Color.R, note.Color.G, note.Color.B, progress); GL.Color4(color); Glu.RenderOutline(noteRect); if (editor.ApproachSquares.Toggle) { var outlineSize = 4 + noteSize + noteSize * (1 - progress) * 2; Glu.RenderOutline(x - outlineSize / 2 + noteSize / 2, y - outlineSize / 2 + noteSize / 2, outlineSize, outlineSize); } if (editor.GridNumbers.Toggle) { GL.Color4(1, 1, 1, progress); var s = $"{(index + 1):#,##}"; var w = fr.GetWidth(s, 24); var h = fr.GetHeight(24); fr.Render(s, (int)(noteRect.X + noteRect.Width / 2 - w / 2f), (int)(noteRect.Y + noteRect.Height / 2 - h / 2f), 24); } if (!mouseOver) { MouseOverNote = null; } if (EditorWindow.Instance.SelectedNotes.Contains(note)) { var outlineSize = noteSize + 8; GL.Color4(0, 0.5f, 1f, progress); Glu.RenderOutline(x - outlineSize / 2 + noteSize / 2, y - outlineSize / 2 + noteSize / 2, outlineSize, outlineSize); } if (!mouseOver && noteRect.Contains(mouseX, mouseY)) { MouseOverNote = note; mouseOver = true; GL.Color3(0, 1, 0.25f); Glu.RenderOutline(x - 4, y - 4, noteSize + 8, noteSize + 8); } } //RENDER AUTOPLAY if (editor.Autoplay.Toggle) { RenderAutoPlay(last, next, cellSize, rect, audioTime); } }
public override void Render(float delta, float mouseX, float mouseY) { var editor = (GuiScreenEditor)EditorWindow.Instance.GuiScreen; var rect = ClientRectangle; var mouseOver = false; GL.Color3(0.1f, 0.1f, 0.1f); Glu.RenderQuad(rect.X, rect.Y, rect.Width, rect.Height); var cellSize = rect.Width / 3f; var noteSize = cellSize * 0.75f; var gap = cellSize - noteSize; var audioTime = EditorWindow.Instance.MusicPlayer.CurrentTime.TotalMilliseconds; GL.Color3(0.2, 0.2, 0.2f); for (int y = 0; y <= 3; y++) { var ly = y * cellSize; Glu.RenderQuad((int)(rect.X), (int)(rect.Y + ly), rect.Width + 1, 1); } for (int x = 0; x <= 3; x++) { var lx = x * cellSize; Glu.RenderQuad((int)(rect.X + lx), (int)(rect.Y), 1, rect.Height + 1); } var fr = EditorWindow.Instance.FontRenderer; GL.Color3(0.2f, 0.2f, 0.2f); foreach (var pair in EditorWindow.Instance.KeyMapping) { if (pair.Key == Key.Y) { continue; } var letter = pair.Key == Key.Z ? "Y/Z" : pair.Key.ToString(); var tuple = pair.Value; var x = rect.X + tuple.Item1 * cellSize + cellSize / 2; var y = rect.Y + tuple.Item2 * cellSize + cellSize / 2; var width = fr.GetWidth(letter, 38); var height = fr.GetHeight(38); fr.Render(letter, (int)(x - width / 2f), (int)(y - height / 2), 38); } Note last = null; Note next = null; for (var index = 0; index < EditorWindow.Instance.Notes.Count; index++) { var note = EditorWindow.Instance.Notes[index]; var passed = audioTime > note.Ms + 1; var visible = !passed && note.Ms - audioTime <= 750; if (passed) { last = note; } else if (next == null) { next = note; } if (!visible) { if (passed && next != null) { break; } continue; } var x = rect.X + note.X * cellSize + gap / 2; var y = rect.Y + note.Y * cellSize + gap / 2; var progress = (float)Math.Pow(1 - Math.Min(1, (note.Ms - audioTime) / 750.0), 2); var noteRect = new RectangleF(x, y, noteSize, noteSize); GL.Color4(note.Color.R, note.Color.G, note.Color.B, progress * 0.15f); Glu.RenderQuad(noteRect); GL.Color4(note.Color.R, note.Color.G, note.Color.B, progress); Glu.RenderOutline(noteRect); if (editor.ApproachSquares.Toggle) { var outlineSize = 4 + noteSize + noteSize * (1 - progress) * 2; Glu.RenderOutline(x - outlineSize / 2 + noteSize / 2, y - outlineSize / 2 + noteSize / 2, outlineSize, outlineSize); } if (editor.GridNumbers.Toggle) { GL.Color4(1, 1, 1, progress); var s = $"{(index + 1):#,##}"; var w = fr.GetWidth(s, 24); var h = fr.GetHeight(24); fr.Render(s, (int)(noteRect.X + noteRect.Width / 2 - w / 2f), (int)(noteRect.Y + noteRect.Height / 2 - h / 2f), 24); } if (!mouseOver) { MouseOverNote = null; } if (EditorWindow.Instance.SelectedNotes.Contains(note)) { var outlineSize = noteSize + 8; GL.Color4(0, 0.5f, 1f, progress); Glu.RenderOutline(x - outlineSize / 2 + noteSize / 2, y - outlineSize / 2 + noteSize / 2, outlineSize, outlineSize); } if (!mouseOver && noteRect.Contains(mouseX, mouseY)) { MouseOverNote = note; mouseOver = true; GL.Color3(0, 1, 0.25f); Glu.RenderOutline(x - 4, y - 4, noteSize + 8, noteSize + 8); } } //RENDER AUTOPLAY if (editor.Autoplay.Toggle) { RenderAutoPlay(last, next, cellSize, rect, audioTime); } }