Rewind after pause (don't work atm)

This commit is contained in:
Florian Küpper committed 2013-09-16 20:41:12 +02:00
1 parent 46c12db857
commit 612cc358a3
6 files changed
+142 -18

No files matched your search

+2 -2
View File
@@ -704,7 +704,7 @@ namespace Vocaluxe.Base
/// <param name="args">Parameters</param>
public static void LoadCommandLineParams(string[] args)
{
var spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase);
Regex spliterParam = new Regex(@"-{1,2}|\/", RegexOptions.IgnoreCase);
//Complete argument string
string arguments = args.Aggregate(string.Empty, (current, arg) => current + (arg + " "));
@@ -713,7 +713,7 @@ namespace Vocaluxe.Base
foreach (string text in args)
{
var spliterVal = new Regex(@"\s", RegexOptions.IgnoreCase);
Regex spliterVal = new Regex(@"\s", RegexOptions.IgnoreCase);
//split arg with Spilter-Regex and save in parts
string[] parts = spliterVal.Split(text, 2);
+125 -5
View File
@@ -274,7 +274,16 @@ namespace Vocaluxe.Base
Players[p].NoteDiff = Math.Abs(tone - tonePlayer);
bool hit = Players[p].NoteDiff <= (2 - (int)CProfiles.GetDifficulty(Players[p].ProfileID));
if (hit)
bool alreadySung = false;
if (Players[p].SungLines.Count - 1 == line)
{
if (note < Players[p].SungLines[line].NoteCount)
alreadySung = true;
}
else if (Players[p].SungLines.Count - 1 > line)
alreadySung = true;
if (hit && !alreadySung)
{
// valid
//CSound.RecordSetTone(p, Tone);
@@ -289,8 +298,9 @@ namespace Vocaluxe.Base
if (Players[p].SungLines[line].NoteCount > 0)
{
CSungNote lastNote = Players[p].SungLines[line].LastNote;
if (notes[note].StartBeat == beat || lastNote.EndBeat + 1 != beat || lastNote.Tone != tone || !lastNote.Hit)
Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note], points));
Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note], points, notes[note].NoteType == ENoteType.Golden));
else
{
Players[p].SungLines[line].IncLastNoteLength();
@@ -298,12 +308,12 @@ namespace Vocaluxe.Base
}
}
else
Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note], points));
Players[p].SungLines[line].AddNote(new CSungNote(beat, 1, tone, notes[note], points, notes[note].NoteType == ENoteType.Golden));
Players[p].SungLines[line].LastNote.CheckPerfect();
Players[p].SungLines[line].IsPerfect(lines[line]);
}
else
else //if(!alreadySung)
{
if (Players[p].SungLines[line].NoteCount > 0)
{
@@ -339,12 +349,122 @@ namespace Vocaluxe.Base
double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints;
Players[p].Points += points;
Players[p].PointsLineBonus += points;
Players[p].SungLines[line].BonusPoints = points;
Players[p].SungLines[line].BonusPoints += points;
}
}
}
}
_OldBeatD = ActBeatD;
}
public static void ResetToLastLine(int soundStream, int vidStream)
{
float[] time = GetLastSungLineStart();
ResetToTime(time[0], time[1], soundStream, vidStream);
}
public static void ResetToTime(float time, float nextStart, int soundStream, int vidStream)
{
if (time < 0)
time = 0;
Beat = GetBeatFromTime(time, GetSong().BPM, GetSong().Gap);
CurrentBeat = (int)Math.Floor(Beat);
for (int p = 0; p < _NumPlayer; p++)
{
Players[p].Points = 0;
Players[p].PointsGoldenNotes = 0;
Players[p].PointsLineBonus = 0;
int l = 0;
int deleteLine = 0;
foreach (CSungLine line in Players[p].SungLines)
{
int n = -1;
int deleteNote = 0;
Players[p].PointsLineBonus += line.BonusPoints;
foreach (CSungNote note in line.Notes)
{
if (note.StartBeat < nextStart)
{
if (note.GoldenNote)
Players[p].PointsGoldenNotes += note.Points;
Players[p].Points += note.Points;
}
else if(deleteNote != -1)
deleteNote = n;
n++;
}
while (line.NoteCount > n && n >= 0)
{
if (line.Notes[n].GoldenNote)
Players[p].PointsGoldenNotes -= line.Notes[n].Points;
Players[p].Points -= line.Notes[n].Points;
line.DeleteNote(n);
}
if (line.LastNoteBeat > CurrentBeat && deleteLine == 0)
deleteLine = l;
l++;
}
Players[p].SungLines.RemoveRange(deleteLine, Players[p].SungLines.Count - deleteLine);
}
CSong song = GetSong();
for (int i = 0; i < GetSong().Notes.Voices[0].Lines.Length; i++)
{
CLog.LogError((i + 1) + ". " + song.Notes.Voices[0].Lines[i].NoteCount + " - " + Players[0].SungLines[i].NoteCount);
}
CSound.SetPosition(soundStream, time);
CVideo.Skip(vidStream, time, GetSong().VideoGap);
}
private static float[] GetLastSungLineStart()
{
return GetNoteTimeBeforeBeat(CurrentBeat);
}
private static float[] GetNoteTimeBeforeBeat(int beat)
{
CSong song = GetSong();
int StartBeat = (int)Math.Floor(beat - GetBeatFromTime(CSettings.PauseResetTime, song.BPM, 0f));
int lastStart = 0;
int nextStart = 0;
foreach (CVoice voice in song.Notes.Voices)
{
int lastEnd = 0;
int voiceStart = 0;
int nextStartNote = 0;
foreach (CSongLine line in voice.Lines)
{
foreach (CSongNote note in line.Notes)
{
if (note.StartBeat > StartBeat)
{
nextStartNote = note.StartBeat;
break;
}
else
{
voiceStart = note.StartBeat;
lastEnd = note.EndBeat;
}
}
if (nextStartNote > 0)
break;
}
if (nextStartNote - beat > CSettings.PauseResetTime)
lastStart = beat;
else if (nextStartNote - lastEnd > CSettings.PauseResetTime)
lastStart = nextStartNote - (int)Math.Floor(GetBeatFromTime(CSettings.PauseResetTime, song.BPM, 0f));
if (voiceStart > lastStart)
{
lastStart = voiceStart;
nextStart = nextStartNote;
}
}
return new float[]{GetTimeFromBeats(lastStart, GetSong().BPM), nextStart};
}
}
}
+10 -10
View File
@@ -218,7 +218,7 @@ namespace Vocaluxe.Base
if (_Fading)
{
var fadeTime = (long)(CConfig.FadeTime * 1000);
long fadeTime = (long)(CConfig.FadeTime * 1000);
if ((_FadingTimer.ElapsedMilliseconds < fadeTime) && (CConfig.FadeTime > 0))
{
@@ -349,10 +349,10 @@ namespace Vocaluxe.Base
#region private stuff
private static bool _HandleInputs(CKeys keys, CMouse mouse)
{
var keyEvent = new SKeyEvent();
var mouseEvent = new SMouseEvent();
var inputKeyEvent = new SKeyEvent();
var inputMouseEvent = new SMouseEvent();
SKeyEvent keyEvent = new SKeyEvent();
SMouseEvent mouseEvent = new SMouseEvent();
SKeyEvent inputKeyEvent = new SKeyEvent();
SMouseEvent inputMouseEvent = new SMouseEvent();
bool popupPlayerControlAllowed = _CurrentScreen != EScreens.ScreenOptionsRecord && _CurrentScreen != EScreens.ScreenSing &&
(_CurrentScreen != EScreens.ScreenSong ||
@@ -541,8 +541,8 @@ namespace Vocaluxe.Base
private static bool _HandleInputThemeEditor(CKeys keys, CMouse mouse)
{
var keyEvent = new SKeyEvent();
var mouseEvent = new SMouseEvent();
SKeyEvent keyEvent = new SKeyEvent();
SMouseEvent mouseEvent = new SMouseEvent();
while (keys.PollEvent(ref keyEvent))
{
@@ -598,7 +598,7 @@ namespace Vocaluxe.Base
if (CConfig.DebugLevel == EDebugLevel.TR_CONFIG_OFF)
return;
var debugOutput = new List<string> {CTime.GetFPS().ToString("FPS: 000")};
List<String> debugOutput = new List<string> {CTime.GetFPS().ToString("FPS: 000")};
if (CConfig.DebugLevel >= EDebugLevel.TR_CONFIG_LEVEL1)
{
@@ -627,11 +627,11 @@ namespace Vocaluxe.Base
CFonts.Style = EStyle.Normal;
CFonts.SetFont("Normal");
CFonts.Height = 25;
var gray = new SColorF(1f, 1f, 1f, 0.5f);
SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
float y = 0;
foreach (string txt in debugOutput)
{
var rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), y, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
RectangleF rect = new RectangleF(CSettings.RenderW - CFonts.GetTextWidth(txt), y, CFonts.GetTextWidth(txt), CFonts.GetTextHeight(txt));
CDraw.DrawColor(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, rect.X, rect.Y, CSettings.ZNear);
y += rect.Height;
+1
View File
@@ -142,6 +142,7 @@ namespace Vocaluxe.Base
public const bool TabNavigation = false;
public const float BackgroundMusicFadeTime = 0.5f;
public const float PauseResetTime = 1f;
public static readonly List<string> MusicFileTypes = new List<string>
{
+1
View File
@@ -868,6 +868,7 @@ namespace Vocaluxe.Screens
}
else
{
CGame.ResetToLastLine(_CurrentStream, _CurrentVideo);
_Buttons[_ButtonCancel].Visible = false;
_Buttons[_ButtonContinue].Visible = false;
_Buttons[_ButtonSkip].Visible = false;
+3 -1
View File
@@ -43,14 +43,16 @@ namespace VocaluxeLib.Songs
/// <param name="duration"></param>
/// <param name="tone"></param>
/// <param name="hitNote"></param>
public CSungNote(int startBeat, int duration, int tone, CSongNote hitNote, double points) : this(startBeat, duration, tone)
public CSungNote(int startBeat, int duration, int tone, CSongNote hitNote, double points, bool golden) : this(startBeat, duration, tone)
{
HitNote = hitNote;
Points = points;
GoldenNote = golden;
}
#region Properties
public double Points;
public bool GoldenNote;
// for drawing player notes
public bool Hit
{