From 5ed6620bad808381fce94f2cd67ee911b4d45bff Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 21 Mar 2007 19:19:04 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 1236 ++++++++++++++++++++++++++++++++++ 1 file changed, 1236 insertions(+) create mode 100644 Game/Code/Screens/UScreenEditSub.pas (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas new file mode 100644 index 00000000..7bdbac0d --- /dev/null +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -0,0 +1,1236 @@ +unit UScreenEditSub; + +interface + +uses UMenu, UMusic, SDL, SysUtils, UPliki, UTime, USongs, UIni, ULog, USmpeg, UTexture, UMenuText, + ULyrics, Math, OpenGL12, UThemes, MidiOut; + +type + TScreenEditSub = class(TMenu) + private + TextNote: integer; + TextSentence: integer; + TextTitle: integer; + TextArtist: integer; + TextMp3: integer; + TextBPM: integer; + TextGAP: integer; + TextDebug: integer; + TextNStart: integer; + TextNDlugosc: integer; + TextNTon: integer; + TextNText: integer; + AktNuta: integer; + PlaySentence: boolean; + PlaySentenceMidi: boolean; + PlayStopTime: real; + LastClick: integer; + Click: boolean; + CopySrc: integer; + + MidiOut: TMidiOutput; + MidiStart: real; + MidiStop: real; + MidiTime: real; + MidiPos: real; + MidiLastNote: integer; + + TextEditMode: boolean; + + procedure NewBeat; + procedure CzesciDivide; + procedure CzesciMultiply; + procedure LyricsCapitalize; + procedure LyricsCorrectSpaces; + procedure FixTimings; + procedure DivideSentence; + procedure JoinSentence; + procedure DivideNote; + procedure DeleteNote; + procedure TransposeNote(Transpose: integer); + procedure ChangeWholeTone(Tone: integer); + procedure MoveAllToEnd(Move: integer); + procedure MoveTextToRight; + procedure MarkSrc; + procedure PasteText; + procedure CopySentence(Src, Dst: integer); + procedure CopySentences(Src, Dst, Num: integer); + public + Tex_Background: TTexture; + FadeOut: boolean; + Path: string; + FileName: string; + constructor Create(Back: String); override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; + function Draw: boolean; override; + procedure onHide; override; + end; + +implementation +uses UGraphic, UDraw, UMain, USkins; + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenEditSub.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; + R: real; +begin + Result := true; + + if TextEditMode then begin + Result := ParseInputEditText(PressedKey, ScanCode, PressedDown); + end else begin + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); + + If (PressedDown) then begin // Key Down + case PressedKey of + SDLK_ESCAPE: + begin + FadeTo(@ScreenSong); + end; + + SDLK_Q: + begin + Result := false; + end; + + SDLK_BACKQUOTE: + begin + // Increase Note Length (same as Alt + Right) + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + SDLK_EQUALS: + begin + // Increase BPM + if SDL_ModState = 0 then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) + if SDL_ModState = KMOD_LSHIFT then + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM + 4; // (1/1) + if SDL_ModState = KMOD_LCTRL then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) + 1) / 25; // (1/100) + end; + + SDLK_MINUS: + begin + // Decrease BPM + if SDL_ModState = 0 then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) - 1) / 5; + if SDL_ModState = KMOD_LSHIFT then + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM - 4; + if SDL_ModState = KMOD_LCTRL then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) - 1) / 25; + end; + + SDLK_0: + begin + // Increase GAP + if SDL_ModState = 0 then + AktSong.GAP := AktSong.GAP + 10; + if SDL_ModState = KMOD_LSHIFT then + AktSong.GAP := AktSong.GAP + 1000; + end; + + SDLK_9: + begin + // Decrease GAP + if SDL_ModState = 0 then + AktSong.GAP := AktSong.GAP - 10; + if SDL_ModState = KMOD_LSHIFT then + AktSong.GAP := AktSong.GAP - 1000; + end; + + SDLK_KP_PLUS: + begin + // Increase tone of all notes + if SDL_ModState = 0 then + ChangeWholeTone(1); + if SDL_ModState = KMOD_LSHIFT then + ChangeWholeTone(12); + end; + + SDLK_KP_MINUS: + begin + // Decrease tone of all notes + if SDL_ModState = 0 then + ChangeWholeTone(-1); + if SDL_ModState = KMOD_LSHIFT then + ChangeWholeTone(-12); + end; + + SDLK_SLASH: + begin + if SDL_ModState = 0 then begin + // Insert start of sentece + if AktNuta > 0 then + DivideSentence; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + // Join next sentence with current + if Czesci[0].Akt < Czesci[0].High then + JoinSentence; + end; + + if SDL_ModState = KMOD_LCTRL then begin + // divide note + DivideNote; + end; + + end; + + SDLK_S: + begin + if SDL_ModState = 0 then + // Save Song + SaveSong(AktSong, Czesci[0], Path + FileName, false); + + if SDL_ModState = KMOD_LSHIFT then + // Save Song + SaveSong(AktSong, Czesci[0], Path + FileName, true); + + if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then + // Save Song + SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false); + + end; + + SDLK_D: + begin + // Divide lengths by 2 + CzesciDivide; + end; + + SDLK_M: + begin + // Multiply lengths by 2 + CzesciMultiply; + end; + + SDLK_C: + begin + // Capitalize letter at the beginning of line + if SDL_ModState = 0 then + LyricsCapitalize; + + // Correct spaces + if SDL_ModState = KMOD_LSHIFT then + LyricsCorrectSpaces; + + // Copy sentence + if SDL_ModState = KMOD_LCTRL then + MarkSrc; + end; + + SDLK_V: + begin + // Paste text + if SDL_ModState = KMOD_LCTRL then begin + if Czesci[0].Czesc[Czesci[0].Akt].IlNut >= Czesci[0].Czesc[CopySrc].IlNut then + PasteText + else + beep; + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + end; + end; + + SDLK_4: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + CopySentence(CopySrc+1, Czesci[0].Akt+1); + CopySentence(CopySrc+2, Czesci[0].Akt+2); + CopySentence(CopySrc+3, Czesci[0].Akt+3); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Czesci[0].Akt, 4); + end; + end; + SDLK_5: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + CopySentence(CopySrc+1, Czesci[0].Akt+1); + CopySentence(CopySrc+2, Czesci[0].Akt+2); + CopySentence(CopySrc+3, Czesci[0].Akt+3); + CopySentence(CopySrc+4, Czesci[0].Akt+4); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Czesci[0].Akt, 5); + end; + end; + + SDLK_T: + begin + // Fixes timings between sentences + FixTimings; + end; + + SDLK_F4: + begin + // Enter Text Edit Mode + TextEditMode := true; + end; + + SDLK_P: + begin + if SDL_ModState = 0 then begin + // Play Sentence + Click := true; + Music.Stop; + R := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + if R <= Music.Length then begin + Music.MoveTo(R); + PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + PlaySentence := true; + Music.Play; + LastClick := -100; + end; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + PlaySentenceMidi := true; + + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + + LastClick := -100; + end; + if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL then begin + PlaySentenceMidi := true; + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + LastClick := -100; + + PlaySentence := true; + Click := true; + Music.Stop; + Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); + PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec)+0; + Music.Play; + LastClick := -100; + end; + end; + + SDLK_SPACE: + begin + // Play Sentence + PlaySentenceMidi := false; // stop midi + PlaySentence := true; + Click := false; + Music.Stop; + Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); + PlayStopTime := (GetTimeFromBeat( + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); + Music.Play; + LastClick := -100; + end; + + SDLK_RETURN: + begin + end; + + SDLK_LCTRL: + begin + end; + + SDLK_DELETE: + begin + if SDL_ModState = KMOD_LCTRL then begin + // moves text to right in current sentence + DeleteNote; + end; + end; + + SDLK_PERIOD: + begin + // moves text to right in current sentence + MoveTextToRight; + end; + + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(AktNuta); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + + // ctrl + right + if SDL_ModState = KMOD_LCTRL then begin + if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + if AktNuta = 0 then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + end; + end; + + // shift + right + if SDL_ModState = KMOD_LSHIFT then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + if AktNuta = 0 then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + // alt + right + if SDL_ModState = KMOD_LALT then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + // alt + ctrl + shift + right = move all from cursor to right + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + MoveAllToEnd(1); + end; + + end; + + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(AktNuta); + if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + + // ctrl + left + if SDL_ModState = KMOD_LCTRL then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = 0 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); + Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + end; + + // shift + left + if SDL_ModState = KMOD_LSHIFT then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + + // resizing sentences + if AktNuta = 0 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); + Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + + end; + + // alt + left + if SDL_ModState = KMOD_LALT then begin + if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + end; + + // alt + ctrl + shift + right = move all from cursor to left + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + MoveAllToEnd(-1); + end; + + end; + + SDLK_DOWN: + begin + // skip to next sentence + if SDL_ModState = 0 then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(Czesci[0].Akt); + AktNuta := 0; + if Czesci[0].Akt > Czesci[0].High then Czesci[0].Akt := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + + Lyric.AddCzesc(Czesci[0].Akt); + Lyric.Selected := 0; + Music.Stop; + PlaySentence := false; + end; + + // decrease tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(-1); + end; + + end; + + SDLK_UP: + begin + // skip to previous sentence + if SDL_ModState = 0 then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(Czesci[0].Akt); + AktNuta := 0; + if Czesci[0].Akt = -1 then Czesci[0].Akt := Czesci[0].High; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + + Lyric.AddCzesc(Czesci[0].Akt); + Lyric.Selected := 0; + Music.Stop; + PlaySentence := false; + end; + + // increase tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(1); + end; + end; + + // Golden Note Patch + SDLK_G: + begin + case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of + 0: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; + 1: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; + 2: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; + end; // case + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; + end; + + // Freestyle Note Patch + SDLK_F: + begin + case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of + 0: + begin; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; + end; + 1,2: + begin; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := True; + end; + end; // case + + end; + + + end; + end; + end; // if +end; + +function TScreenEditSub.ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; +begin + // used when in Text Edit Mode + Result := true; + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); + + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_ESCAPE: + begin + FadeTo(@ScreenSong); + end; + SDLK_F4, SDLK_RETURN: + begin + // Exit Text Edit Mode + TextEditMode := false; + end; + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL: + begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst := + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst + chr(ScanCode); + end; + SDLK_BACKSPACE: + begin + Delete(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst, + Length(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst), 1); + end; + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(AktNuta); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + end; + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(AktNuta); + if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + end; + end; + end; +end; + +procedure TScreenEditSub.NewBeat; +begin + // click +{ for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = Czas.AktBeat) then begin + // old} +// Music.PlayClick; +end; + +procedure TScreenEditSub.CzesciDivide; +var + C: integer; + N: integer; +begin + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM / 2; + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start div 2; + Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote div 2; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec div 2; + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start div 2; + Czesci[0].Czesc[C].Nuta[N].Dlugosc := Round(Czesci[0].Czesc[C].Nuta[N].Dlugosc / 2); + end; // N + end; // C +end; + +procedure TScreenEditSub.CzesciMultiply; +var + C: integer; + N: integer; +begin + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM * 2; + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start * 2; + Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote * 2; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec * 2; + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start * 2; + Czesci[0].Czesc[C].Nuta[N].Dlugosc := Czesci[0].Czesc[C].Nuta[N].Dlugosc * 2; + end; // N + end; // C +end; + +procedure TScreenEditSub.LyricsCapitalize; +var + C: integer; + N: integer; // temporary + S: string; +begin + // temporary +{ for C := 0 to Czesci[0].High do + for N := 0 to Czesci[0].Czesc[C].HighNut do + Czesci[0].Czesc[C].Nuta[N].Tekst := AnsiLowerCase(Czesci[0].Czesc[C].Nuta[N].Tekst);} + + for C := 0 to Czesci[0].High do begin + S := AnsiUpperCase(Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1)); + S := S + Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, Length(Czesci[0].Czesc[C].Nuta[0].Tekst)-1); + Czesci[0].Czesc[C].Nuta[0].Tekst := S; + end; // C +end; + +procedure TScreenEditSub.LyricsCorrectSpaces; +var + C: integer; + N: integer; +begin + for C := 0 to Czesci[0].High do begin + // correct starting spaces in the first word + while Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1) = ' ' do + Czesci[0].Czesc[C].Nuta[0].Tekst := Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, 100); + + // move spaces on the start to the end of the previous note + for N := 1 to Czesci[0].Czesc[C].HighNut do begin + while (Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, 1) = ' ') do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 2, 100); + Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; + end; + end; // N + + // correct '-' to '- ' + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + if Czesci[0].Czesc[C].Nuta[N].Tekst = '-' then + Czesci[0].Czesc[C].Nuta[N].Tekst := '- '; + end; // N + + // add space to the previous note when the current word is '- ' + for N := 1 to Czesci[0].Czesc[C].HighNut do begin + if Czesci[0].Czesc[C].Nuta[N].Tekst = '- ' then + Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; + end; // N + + // correct too many spaces at the end of note + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + while Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1, 2) = ' ' do + Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1); + end; // N + + // and correct if there is no space at the end of sentence + N := Czesci[0].Czesc[C].HighNut; + if Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst), 1) <> ' ' then + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N].Tekst + ' '; + + end; // C +end; + +procedure TScreenEditSub.FixTimings; +var + C: integer; + S: integer; + Min: integer; + Max: integer; +begin + for C := 1 to Czesci[0].High do begin + with Czesci[0].Czesc[C-1] do begin + Min := Nuta[HighNut].Start + Nuta[HighNut].Dlugosc; + Max := Czesci[0].Czesc[C].StartNote; + case (Max - Min) of + 0: S := Max; + 1: S := Max; + 2: S := Max - 1; + 3..3: S := Max - 2; + 4..10000: S := Min + 2; // poczatek + 2 + end; // case + + Czesci[0].Czesc[C].Start := S; + end; // with + end; // for +end; + +procedure TScreenEditSub.DivideSentence; +var + C: integer; + CStart: integer; + CNew: integer; + CLen: integer; + N: integer; + NStart: integer; + NHigh: integer; + NNewL: integer; +begin + // increase sentence length by 1 + CLen := Length(Czesci[0].Czesc); + SetLength(Czesci[0].Czesc, CLen + 1); + Inc(Czesci[0].Ilosc); + Inc(Czesci[0].High); + + // move needed sentences to one forward. newly has the copy of divided sentence + CStart := Czesci[0].Akt; + for C := CLen-1 downto CStart do + Czesci[0].Czesc[C+1] := Czesci[0].Czesc[C]; + + // clear and set new sentence + CNew := CStart + 1; + NStart := AktNuta; + Czesci[0].Czesc[CNew].Start := Czesci[0].Czesc[CStart].Nuta[NStart].Start; + Czesci[0].Czesc[CNew].StartNote := Czesci[0].Czesc[CStart].Nuta[NStart].Start; + Czesci[0].Czesc[CNew].Lyric := ''; + Czesci[0].Czesc[CNew].LyricWidth := 0; + Czesci[0].Czesc[CNew].Koniec := 0; + Czesci[0].Czesc[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure + Czesci[0].Czesc[CNew].IlNut := 0; + Czesci[0].Czesc[CNew].HighNut := -1; + SetLength(Czesci[0].Czesc[CNew].Nuta, 0); + + // move right notes to new sentences + NHigh := Czesci[0].Czesc[CStart].HighNut; + for N := NStart to NHigh do begin + NNewL := Czesci[0].Czesc[CNew].IlNut; + SetLength(Czesci[0].Czesc[CNew].Nuta, NNewL + 1); + Czesci[0].Czesc[CNew].Nuta[NNewL] := Czesci[0].Czesc[CStart].Nuta[N]; + + // increase sentence counters + Inc(Czesci[0].Czesc[CNew].IlNut); + Inc(Czesci[0].Czesc[CNew].HighNut); + Czesci[0].Czesc[CNew].Koniec := Czesci[0].Czesc[CNew].Nuta[NNewL].Start + + Czesci[0].Czesc[CNew].Nuta[NNewL].Dlugosc; + end; + + // clear old notes and set sentence counters + Czesci[0].Czesc[CStart].HighNut := NStart - 1; + Czesci[0].Czesc[CStart].IlNut := Czesci[0].Czesc[CStart].HighNut + 1; + Czesci[0].Czesc[CStart].Koniec := Czesci[0].Czesc[CStart].Nuta[NStart-1].Start + + Czesci[0].Czesc[CStart].Nuta[NStart-1].Dlugosc; + SetLength(Czesci[0].Czesc[CStart].Nuta, Czesci[0].Czesc[CStart].IlNut); + + // 0.5.0: modify BaseNote + Czesci[0].Czesc[CNew].BaseNote := 120; + for N := 0 to Czesci[0].Czesc[CNew].IlNut do + if Czesci[0].Czesc[CNew].Nuta[N].Ton < Czesci[0].Czesc[CNew].BaseNote then + Czesci[0].Czesc[CNew].BaseNote := Czesci[0].Czesc[CNew].Nuta[N].Ton; + + Czesci[0].Akt := Czesci[0].Akt + 1; + AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.AddCzesc(Czesci[0].Akt); + +end; + +procedure TScreenEditSub.JoinSentence; +var + C: integer; + N: integer; + NStart: integer; + NDst: integer; +begin + C := Czesci[0].Akt; + + // set new sentence + NStart := Czesci[0].Czesc[C].IlNut; + Czesci[0].Czesc[C].IlNut := Czesci[0].Czesc[C].IlNut + Czesci[0].Czesc[C+1].IlNut; + Czesci[0].Czesc[C].HighNut := Czesci[0].Czesc[C].HighNut + Czesci[0].Czesc[C+1].IlNut; + SetLength(Czesci[0].Czesc[C].Nuta, Czesci[0].Czesc[C].IlNut); + + // move right notes to new sentences + for N := 0 to Czesci[0].Czesc[C+1].HighNut do begin + NDst := NStart + N; + Czesci[0].Czesc[C].Nuta[NDst] := Czesci[0].Czesc[C+1].Nuta[N]; + end; + + // increase sentence counters + NDst := Czesci[0].Czesc[C].HighNut; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Nuta[NDst].Start + + Czesci[0].Czesc[C].Nuta[NDst].Dlugosc; + + // move needed sentences to one backward. + for C := Czesci[0].Akt + 1 to Czesci[0].High - 1 do + Czesci[0].Czesc[C] := Czesci[0].Czesc[C+1]; + + // increase sentence length by 1 + SetLength(Czesci[0].Czesc, Length(Czesci[0].Czesc) - 1); + Dec(Czesci[0].Ilosc); + Dec(Czesci[0].High); +end; + +procedure TScreenEditSub.DivideNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Czesci[0].Akt; + + NLen := Czesci[0].Czesc[C].IlNut + 1; + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Inc(Czesci[0].Czesc[C].HighNut); + Inc(Czesci[0].Czesc[C].IlNut); + + // we copy all notes including selected one + for N := Czesci[0].Czesc[C].HighNut downto AktNuta+1 do begin + Czesci[0].Czesc[C].Nuta[N] := Czesci[0].Czesc[C].Nuta[N-1]; + end; + + // me slightly modify new note + Czesci[0].Czesc[C].Nuta[AktNuta].Dlugosc := 1; + Inc(Czesci[0].Czesc[C].Nuta[AktNuta+1].Start); + Dec(Czesci[0].Czesc[C].Nuta[AktNuta+1].Dlugosc); + Czesci[0].Czesc[C].Nuta[AktNuta+1].Tekst := '- '; + Czesci[0].Czesc[C].Nuta[AktNuta+1].Color := 0; +end; + +procedure TScreenEditSub.DeleteNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Czesci[0].Akt; + + // we copy all notes from the next to the selected one + for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; + end; + + NLen := Czesci[0].Czesc[C].IlNut - 1; + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Dec(Czesci[0].Czesc[C].HighNut); + Dec(Czesci[0].Czesc[C].IlNut); + + + // me slightly modify new note + if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); + Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; +end; + +procedure TScreenEditSub.TransposeNote(Transpose: integer); +begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton, Transpose); +end; + +procedure TScreenEditSub.ChangeWholeTone(Tone: integer); +var + C: integer; + N: integer; +begin + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].BaseNote := Czesci[0].Czesc[C].BaseNote + Tone; + for N := 0 to Czesci[0].Czesc[C].HighNut do + Czesci[0].Czesc[C].Nuta[N].Ton := Czesci[0].Czesc[C].Nuta[N].Ton + Tone; + end; +end; + +procedure TScreenEditSub.MoveAllToEnd(Move: integer); +var + C: integer; + N: integer; + NStart: integer; +begin + for C := Czesci[0].Akt to Czesci[0].High do begin + NStart := 0; + if C = Czesci[0].Akt then NStart := AktNuta; + for N := NStart to Czesci[0].Czesc[C].HighNut do begin + Inc(Czesci[0].Czesc[C].Nuta[N].Start, Move); // move note start + + if N = 0 then begin // fix beginning + Inc(Czesci[0].Czesc[C].Start, Move); + Inc(Czesci[0].Czesc[C].StartNote, Move); + end; + + if N = Czesci[0].Czesc[C].HighNut then // fix ending + Inc(Czesci[0].Czesc[C].Koniec, Move); + + end; // for + end; // for +end; + +procedure TScreenEditSub.MoveTextToRight; +var + C: integer; + N: integer; + NHigh: integer; +begin +{ C := Czesci[0].Akt; + + for N := Czesci[0].Czesc[C].HighNut downto 1 do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; + end; // for + + Czesci[0].Czesc[C].Nuta[0].Tekst := '- ';} + + C := Czesci[0].Akt; + NHigh := Czesci[0].Czesc[C].HighNut; + + // last word + Czesci[0].Czesc[C].Nuta[NHigh].Tekst := Czesci[0].Czesc[C].Nuta[NHigh-1].Tekst + Czesci[0].Czesc[C].Nuta[NHigh].Tekst; + + // other words + for N := NHigh - 1 downto AktNuta + 1 do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; + end; // for + Czesci[0].Czesc[C].Nuta[AktNuta].Tekst := '- '; +end; + +procedure TScreenEditSub.MarkSrc; +begin + CopySrc := Czesci[0].Akt; +end; + +procedure TScreenEditSub.PasteText; +var + C: integer; + N: integer; +begin + C := Czesci[0].Akt; + + for N := 0 to Czesci[0].Czesc[CopySrc].HighNut do + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[CopySrc].Nuta[N].Tekst; +end; + +procedure TScreenEditSub.CopySentence(Src, Dst: integer); +var + N: integer; + Time1: integer; + Time2: integer; + TD: integer; +begin + Time1 := Czesci[0].Czesc[Src].Nuta[0].Start; + Time2 := Czesci[0].Czesc[Dst].Nuta[0].Start; + TD := Time2-Time1; + + SetLength(Czesci[0].Czesc[Dst].Nuta, Czesci[0].Czesc[Src].IlNut); + Czesci[0].Czesc[Dst].IlNut := Czesci[0].Czesc[Src].IlNut; + Czesci[0].Czesc[Dst].HighNut := Czesci[0].Czesc[Src].HighNut; + for N := 0 to Czesci[0].Czesc[Src].HighNut do begin + Czesci[0].Czesc[Dst].Nuta[N].Tekst := Czesci[0].Czesc[Src].Nuta[N].Tekst; + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc := Czesci[0].Czesc[Src].Nuta[N].Dlugosc; + Czesci[0].Czesc[Dst].Nuta[N].Ton := Czesci[0].Czesc[Src].Nuta[N].Ton; + Czesci[0].Czesc[Dst].Nuta[N].Start := Czesci[0].Czesc[Src].Nuta[N].Start + TD; + end; + N := Czesci[0].Czesc[Src].HighNut; + Czesci[0].Czesc[Dst].Koniec := Czesci[0].Czesc[Dst].Nuta[N].Start + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc; +end; + +procedure TScreenEditSub.CopySentences(Src, Dst, Num: integer); +var + C: integer; +begin + // create place for new sentences + SetLength(Czesci[0].Czesc, Czesci[0].Ilosc + Num - 1); + + // moves sentences next to the destination + for C := Czesci[0].High downto Dst + 1 do begin + Czesci[0].Czesc[C + Num - 1] := Czesci[0].Czesc[C]; + end; + + // prepares new sentences: sets sentence start and create first note + for C := 1 to Num-1 do begin + Czesci[0].Czesc[Dst + C].Start := Czesci[0].Czesc[Dst + C - 1].StartNote + + (Czesci[0].Czesc[Src + C].StartNote - Czesci[0].Czesc[Src + C - 1].StartNote); + SetLength(Czesci[0].Czesc[Dst + C].Nuta, 1); + Czesci[0].Czesc[Dst + C].IlNut := 1; + Czesci[0].Czesc[Dst + C].HighNut := 0; + Czesci[0].Czesc[Dst + C].Nuta[0].Start := Czesci[0].Czesc[Dst + C].Start; + Czesci[0].Czesc[Dst + C].Nuta[0].Dlugosc := 1; + Czesci[0].Czesc[Dst + C].StartNote := Czesci[0].Czesc[Dst + C].Start; + Czesci[0].Czesc[Dst + C].Koniec := Czesci[0].Czesc[Dst + C].Start + 1; + end; + + // increase counters + Czesci[0].Ilosc := Czesci[0].Ilosc + Num - 1; + Czesci[0].High := Czesci[0].High + Num - 1; + + for C := 0 to Num-1 do + CopySentence(Src + C, Dst + C); +end; + + +constructor TScreenEditSub.Create(Back: String); +begin + inherited Create(Back); + SetLength(Player, 1); + + // linijka + AddStatic(20, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); + AddText(40, 17, 1, 6, 1, 1, 1, 'Line'); + TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // nuta + AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); + AddText(242, 17, 1, 6, 1, 1, 1, 'Note'); + TextNote := AddText(320, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // file info + AddStatic(150, 50, 500, 150, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddText(180, 65, 0, 8, 0, 0, 0, 'Title:'); + AddText(180, 90, 0, 8, 0, 0, 0, 'Artist:'); + AddText(180, 115, 0, 8, 0, 0, 0, 'Mp3:'); + AddText(180, 140, 0, 8, 0, 0, 0, 'BPM:'); + AddText(180, 165, 0, 8, 0, 0, 0, 'GAP:'); + + TextTitle := AddText(250, 65, 0, 8, 0, 0, 0, 'a'); + TextArtist := AddText(250, 90, 0, 8, 0, 0, 0, 'b'); + TextMp3 := AddText(250, 115, 0, 8, 0, 0, 0, 'c'); + TextBPM := AddText(250, 140, 0, 8, 0, 0, 0, 'd'); + TextGAP := AddText(250, 165, 0, 8, 0, 0, 0, 'e'); + +{ AddInteraction(2, TextTitle); + AddInteraction(2, TextArtist); + AddInteraction(2, TextMp3); + AddInteraction(2, TextBPM); + AddInteraction(2, TextGAP);} + + // note info + AddText(20, 190, 0, 8, 0, 0, 0, 'Start:'); + AddText(20, 215, 0, 8, 0, 0, 0, 'Duration:'); + AddText(20, 240, 0, 8, 0, 0, 0, 'Tone:'); + AddText(20, 265, 0, 8, 0, 0, 0, 'Text:'); + + TextNStart := AddText(120, 190, 0, 8, 0, 0, 0, 'a'); + TextNDlugosc := AddText(120, 215, 0, 8, 0, 0, 0, 'b'); + TextNTon := AddText(120, 240, 0, 8, 0, 0, 0, 'c'); + TextNText := AddText(120, 265, 0, 8, 0, 0, 0, 'd'); + + // debug + TextDebug := AddText(30, 550, 0, 8, 0, 0, 0, ''); + +end; + +procedure TScreenEditSub.onShow; +begin + Log.LogStatus('Initializing', 'TEditScreen.onShow'); + + MidiOut := TMidiOutput.Create(nil); + if Ini.Debug = 1 then + MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table + MidiOut.Open; + + + + CzyscNuty; + if WczytajCzesci(Path + FileName) = false then +// if WczytajCzesci(SongPath + 'Zapis.txt') = false then + Text[TextTitle].Text := 'Error loading file' + else begin + Text[TextTitle].Text := AktSong.Title; + Text[TextArtist].Text := AktSong.Artist; + Text[TextMp3].Text := AktSong.Mp3; + + Czesci[0].Akt := 0; + AktNuta := 0; + Czesci[0].Czesc[0].Nuta[0].Color := 1; + + Music.Open(Path + AktSong.Mp3); + + Lyric.Clear; + Lyric.X := 400; + Lyric.Y := 500; + Lyric.Align := 1; + Lyric.Size := 14; + Lyric.ColR := 0; + Lyric.ColG := 0; + Lyric.ColB := 0; + Lyric.ColSR := Skin_FontHighlightR; + Lyric.ColSG := Skin_FontHighlightG; + Lyric.ColSB := Skin_FontHighlightB; + Lyric.Style := 0; + Lyric.AddCzesc(0); + Lyric.Selected := 0; + + NotesH := 7; + NotesW := 4; + + end; + +// Interaction := 0; + TextEditMode := false; +end; + +function TScreenEditSub.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Pet: integer; + AktBeat: integer; +begin + glClearColor(1,1,1,1); + + // midi music + if PlaySentenceMidi then begin + MidiPos := USTime.GetTime - MidiTime + MidiStart; + + // stop the music + if (MidiPos > MidiStop) then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + end; + + // click + AktBeat := Floor(GetMidBeat(MidiPos - AktSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin + + LastClick := AktBeat; + if Pet > 0 then + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet-1].Ton + 60, 127); + MidiOut.PutShort($91, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Ton + 60, 127); + MidiLastNote := Pet; + + end; + end; + end; // if PlaySentenceMidi + + // mp3 music + if PlaySentence then begin + // stop the music + if (Music.Position > PlayStopTime) then begin + Music.Stop; + PlaySentence := false; + end; + + // click + if (Click) and (PlaySentence) then begin +// AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); + AktBeat := Floor(GetMidBeat(Music.Position - AktSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin + Music.PlayClick; + LastClick := AktBeat; + end; + end; + end; // click + end; // if PlaySentence + + + Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); + Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); + + // Song info + Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); + Text[TextGAP].Text := FloatToStr(AktSong.GAP); + + // Note info + Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton); + Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; + + // Text Edit Mode + if TextEditMode then + Text[TextNText].Text := Text[TextNText].Text + '|'; + + // draw static menu + inherited Draw; + + // draw notes + SingDrawNoteLines(20, 300, 780, 15); + SingDrawBeatDelimeters(40, 300, 760, 0); + EditDrawCzesc(40, 405, 760, 0, 15); + + // draw text + Lyric.Draw; + +end; + +procedure TScreenEditSub.onHide; +begin + MidiOut.Close; + MidiOut.Free; +end; + +end. -- cgit v1.2.3 From e558c05847fc836ceecbfe9de67af36b84f2b367 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 25 Mar 2007 15:23:10 +0000 Subject: ScreenEditSub: Automatically set down music playback-volume to hear the Midi Sounds better. Also Show Note Names in Editor (e.g. c, d'', F#) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@36 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 41 ++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 7bdbac0d..52cd0b26 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -55,6 +55,8 @@ type procedure PasteText; procedure CopySentence(Src, Dst: integer); procedure CopySentences(Src, Dst, Num: integer); + //Note Name Mod + function GetNoteName(Note: Integer): String; public Tex_Background: TTexture; FadeOut: boolean; @@ -1110,7 +1112,9 @@ begin Czesci[0].Czesc[0].Nuta[0].Color := 1; Music.Open(Path + AktSong.Mp3); - + //Set Down Music Volume for Better hearability of Midi Sounds + Music.SetVolume(40); + Lyric.Clear; Lyric.X := 400; Lyric.Y := 500; @@ -1207,7 +1211,7 @@ begin // Note info Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton); + Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' ( ' + GetNoteName(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' )'; Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; // Text Edit Mode @@ -1231,6 +1235,39 @@ procedure TScreenEditSub.onHide; begin MidiOut.Close; MidiOut.Free; + Music.SetVolume(100); +end; + +function TScreenEditSub.GetNoteName(Note: Integer): String; +var N1, N2: Integer; +begin + N1 := Note mod 12; + N2 := Note div 12; + + case N1 of + 0: Result := 'c'; + 1: Result := 'c#'; + 2: Result := 'd'; + 3: Result := 'd#'; + 4: Result := 'e'; + 5: Result := 'f'; + 6: Result := 'f#'; + 7: Result := 'g'; + 8: Result := 'g#'; + 9: Result := 'a'; + 10: Result := 'b'; + 11: Result := 'h'; + end; + + case N2 of + 0: Result := UpperCase(Result); //Normal Uppercase Note, 1: Normal lowercase Note + 2: Result := Result + ''''; //One Striped + 3: Result := Result + ''''''; //Two Striped + 4: Result := Result + ''''''''; //etc. + 5: Result := Result + ''''''''''; + 6: Result := Result + ''''''''''''; + 7: Result := Result + ''''''''''''''; + end; end; end. -- cgit v1.2.3 From 9d01c8801db29d6ff3d64ef81b84321549d84688 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 5 Apr 2007 21:09:52 +0000 Subject: Added Advanced Screen and Options in TIni Options working now only for Effect Perfect and Effect Golden. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@65 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 52cd0b26..6094edd1 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -1096,6 +1096,8 @@ begin MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table MidiOut.Open; + //MidiOut.SetVolume(65535, 65535); + CzyscNuty; @@ -1113,7 +1115,7 @@ begin Music.Open(Path + AktSong.Mp3); //Set Down Music Volume for Better hearability of Midi Sounds - Music.SetVolume(40); + //Music.SetVolume(40); Lyric.Clear; Lyric.X := 400; -- cgit v1.2.3 From bda4fa8e57ca63a1d591433f120b4226d6a5d327 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 29 Apr 2007 17:50:29 +0000 Subject: Added 2 new Buttons to ScreenMain: Multi and Stats Updated Language Fiels to Fit with new Buttons Some CodeClean Up in Menu Class and in Screens Some minor Bug fixes I forgot about Added ability to group Buttons within a Screen New Theme Object: ButtonCollection: Same Attributes as a Button Plus FirstChild: Defining the First Button in the Group. For Example: SingSolo is 1, SingMulti Button is 2, in ScreenMain Added Attribute to Theme Button: Parent: Number of the assigned Group, 0 for no Group Used new Abilitys in MainScreen git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@149 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 6094edd1..a665ba1c 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -62,7 +62,7 @@ type FadeOut: boolean; Path: string; FileName: string; - constructor Create(Back: String); override; + constructor Create; override; procedure onShow; override; function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; function ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; @@ -1035,9 +1035,9 @@ begin end; -constructor TScreenEditSub.Create(Back: String); +constructor TScreenEditSub.Create; begin - inherited Create(Back); + inherited Create; SetLength(Player, 1); // linijka -- cgit v1.2.3 From 4a731514163a14bd3a9222d99707880b56772663 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 16 May 2007 19:19:35 +0000 Subject: all SongFile Loading and Saving procedures moved to UFiles. Added Some Tolerance in Song File Loading and Song Header Loading. Fix: Programm doesn't Crash anymore when a coruppted Song is loaded for Singing or Editing. Now Jump back to SongScreen and show an Error Message. Also Party Mode is not Interupted, a new Song will be selected automatically. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@197 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 79 +++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 32 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index a665ba1c..a0adef2c 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -2,12 +2,15 @@ unit UScreenEditSub; interface -uses UMenu, UMusic, SDL, SysUtils, UPliki, UTime, USongs, UIni, ULog, USmpeg, UTexture, UMenuText, +uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, USmpeg, UTexture, UMenuText, ULyrics, Math, OpenGL12, UThemes, MidiOut; type TScreenEditSub = class(TMenu) private + //Variable is True if no SOng is loaded + Error: Boolean; + TextNote: integer; TextSentence: integer; TextTitle: integer; @@ -71,7 +74,7 @@ type end; implementation -uses UGraphic, UDraw, UMain, USkins; +uses UGraphic, UDraw, UMain, USkins, ULanguage; // Method for input parsing. If False is returned, GetNextWindow // should be checked to know the next window to load; @@ -190,17 +193,15 @@ begin SDLK_S: begin - if SDL_ModState = 0 then - // Save Song - SaveSong(AktSong, Czesci[0], Path + FileName, false); - + // Save Song if SDL_ModState = KMOD_LSHIFT then - // Save Song - SaveSong(AktSong, Czesci[0], Path + FileName, true); + SaveSong(AktSong, Czesci[0], Path + FileName, true) + else + SaveSong(AktSong, Czesci[0], Path + FileName, false); - if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then + {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then // Save Song - SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false); + SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false);} end; @@ -1091,20 +1092,26 @@ procedure TScreenEditSub.onShow; begin Log.LogStatus('Initializing', 'TEditScreen.onShow'); - MidiOut := TMidiOutput.Create(nil); - if Ini.Debug = 1 then - MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table - MidiOut.Open; - - //MidiOut.SetVolume(65535, 65535); - - + try + ResetSingTemp; + Error := not LoadSong(Path + FileName); + except + Error := True; + end; - CzyscNuty; - if WczytajCzesci(Path + FileName) = false then -// if WczytajCzesci(SongPath + 'Zapis.txt') = false then - Text[TextTitle].Text := 'Error loading file' + if Error then + begin + //Error Loading Song -> Go back to Song Screen and Show some Error Message + FadeTo(@ScreenSong); + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end else begin + MidiOut := TMidiOutput.Create(nil); + if Ini.Debug = 1 then + MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table + MidiOut.Open; + Text[TextTitle].Text := AktSong.Title; Text[TextArtist].Text := AktSong.Artist; Text[TextMp3].Text := AktSong.Mp3; @@ -1201,7 +1208,7 @@ begin end; end; // click end; // if PlaySentence - + Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); @@ -1210,23 +1217,31 @@ begin Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); Text[TextGAP].Text := FloatToStr(AktSong.GAP); - // Note info - Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); - Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' ( ' + GetNoteName(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' )'; - Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; + //Error reading Variables when no Song is loaded + if not Error then + begin + // Note info + Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' ( ' + GetNoteName(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' )'; + Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; + end; // Text Edit Mode if TextEditMode then - Text[TextNText].Text := Text[TextNText].Text + '|'; + Text[TextNText].Text := Text[TextNText].Text + '|'; // draw static menu inherited Draw; // draw notes SingDrawNoteLines(20, 300, 780, 15); - SingDrawBeatDelimeters(40, 300, 760, 0); - EditDrawCzesc(40, 405, 760, 0, 15); + //Error Drawing when no Song is loaded + if not Error then + begin + SingDrawBeatDelimeters(40, 300, 760, 0); + EditDrawCzesc(40, 405, 760, 0, 15); + end; // draw text Lyric.Draw; @@ -1237,7 +1252,7 @@ procedure TScreenEditSub.onHide; begin MidiOut.Close; MidiOut.Free; - Music.SetVolume(100); + //Music.SetVolume(100); end; function TScreenEditSub.GetNoteName(Note: Integer): String; -- cgit v1.2.3 From e0c4de18cabd3f1f27376afe389cdd4470ee198d Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 25 Jun 2007 12:24:53 +0000 Subject: Fixed wrong sentence timings (T in Editor) when last note of a sentence and first note of the next sentence overlap. Fixed 2 Bugs in Midi Converter: Notes were added more than once to txt when the save Button is pressed multiple times Notes are added more than once when open is pressed multiple time Added sentence start calculating to Midi Converter git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@267 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index a0adef2c..8a5eaab8 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -730,8 +730,12 @@ begin 0: S := Max; 1: S := Max; 2: S := Max - 1; - 3..3: S := Max - 2; - 4..10000: S := Min + 2; // poczatek + 2 + 3: S := Max - 2; + else + if ((Max - Min) > 4) then + S := Min + 2 + else + S := Max; end; // case Czesci[0].Czesc[C].Start := S; -- cgit v1.2.3 From dce08a8771098ac1a56dd4548202454ab268e951 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 3 Jul 2007 14:56:15 +0000 Subject: Fixed a bug in EditorSub that causes a crash when the last note of a sentence was deleted. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@273 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 53 ++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 12 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 8a5eaab8..9e84462d 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -882,20 +882,49 @@ var begin C := Czesci[0].Akt; - // we copy all notes from the next to the selected one - for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin - Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; - end; - - NLen := Czesci[0].Czesc[C].IlNut - 1; - SetLength(Czesci[0].Czesc[C].Nuta, NLen); - Dec(Czesci[0].Czesc[C].HighNut); - Dec(Czesci[0].Czesc[C].IlNut); + //Do Not delete Last Note + if (Czesci[0].High > 0) OR (Czesci[0].Czesc[C].HighNut > 0) then + begin + // we copy all notes from the next to the selected one + for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; + end; - // me slightly modify new note - if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); - Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; + NLen := Czesci[0].Czesc[C].IlNut - 1; + + if (NLen > 0) then + begin + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Dec(Czesci[0].Czesc[C].HighNut); + Dec(Czesci[0].Czesc[C].IlNut); + + + // me slightly modify new note + if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); + Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; + end + //Last Note of current Sentence Deleted - > Delete Sentence + else + begin + //Move all Sentences after the current to the Left + for N := C+1 to Czesci[0].High do + Czesci[0].Czesc[N-1] := Czesci[0].Czesc[N]; + + //Delete Last Sentence + SetLength(Czesci[0].Czesc, Czesci[0].High); + Czesci[0].High := High(Czesci[0].Czesc); + Czesci[0].Ilosc := Length(Czesci[0].Czesc); + + AktNuta := 0; + if (C > 0) then + Czesci[0].Akt := C - 1 + else + Czesci[0].Akt := 0; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + end; + end; end; procedure TScreenEditSub.TransposeNote(Transpose: integer); -- cgit v1.2.3 From a65e818d0a8ecac47b7710e8546897e271d0ca44 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 15 Jul 2007 17:21:12 +0000 Subject: Fixed a bug in Note Name convertation git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@297 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 9e84462d..9ca45f55 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -1291,8 +1291,18 @@ end; function TScreenEditSub.GetNoteName(Note: Integer): String; var N1, N2: Integer; begin - N1 := Note mod 12; - N2 := Note div 12; + if (Note > 0) then + begin + N1 := Note mod 12; + N2 := Note div 12; + end + else + begin + N1 := (Note + (-Trunc(Note/12)+1)*12) mod 12; + N2 := -1; + end; + + case N1 of 0: Result := 'c'; -- cgit v1.2.3 From 3043d3db91c3a541881aa951bbd4f8ccb5e3ce40 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 5 Sep 2007 12:35:19 +0000 Subject: modified ParseInput so Backspace will perform same function as ESC in most screens ( Except where text input is required, and backspace is used for text input ) This has been done, so that when used with Windows Media Center IR Remotes ( needs SDL 1.2 dll at runtime ) users can navigate throug the game without sitting in front of the PC keyboard. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@370 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 9ca45f55..1d5cc66d 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -94,7 +94,9 @@ begin If (PressedDown) then begin // Key Down case PressedKey of - SDLK_ESCAPE: + + SDLK_ESCAPE, + SDLK_BACKSPACE : begin FadeTo(@ScreenSong); end; @@ -565,7 +567,9 @@ begin If (PressedDown) Then begin // Key Down case PressedKey of - SDLK_ESCAPE: + + SDLK_ESCAPE, + SDLK_BACKSPACE : begin FadeTo(@ScreenSong); end; -- cgit v1.2.3 From addda3536d0d82714e826994b3a10c6b468c3252 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 5 Sep 2007 14:45:42 +0000 Subject: Fixed two Bugs in KeyDown Handling that causes that the code could not be compiled. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@373 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 1d5cc66d..948ff2cc 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -568,8 +568,7 @@ begin begin // Key Down case PressedKey of - SDLK_ESCAPE, - SDLK_BACKSPACE : + SDLK_ESCAPE: begin FadeTo(@ScreenSong); end; -- cgit v1.2.3 From 247cbdca4eb8af228fa1753f1185e85077b5befa Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 7 Sep 2007 21:09:02 +0000 Subject: UScreenSing.pas, UScreenSingModi.pas: removed Uffmpeg and USmpeg, added UVideo UGraphic.pas: prepared for possible loading animation UGraphicClasses.pas, ULCD.pas, ULight.pas, UMain.pas, USkins.pas, UDisplay.pas, UMenuButton.pas, UMenuSelect.pas, UMenuSelectSlide.pas, UMenuStatic.pas, UScreenCredits.pas, UScreenEditSub.pas, UScreenOpen.pas, UScreenPopup.pas: some fixes to get rid of some compiler infos/warnings git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@374 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 948ff2cc..6eef8509 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -2,7 +2,7 @@ unit UScreenEditSub; interface -uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, USmpeg, UTexture, UMenuText, +uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, UTexture, UMenuText, ULyrics, Math, OpenGL12, UThemes, MidiOut; type -- cgit v1.2.3 From 433a1b7339e2bf96f3b0bb4c98b8c799c6540027 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 18 Sep 2007 13:19:20 +0000 Subject: changes in order to compile in lazarus... minor tidy ups and removal of big old comment blocks.. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@394 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 6eef8509..7184b0b6 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -2,8 +2,27 @@ unit UScreenEditSub; interface -uses UMenu, UMusic, SDL, SysUtils, UFiles, UTime, USongs, UIni, ULog, UTexture, UMenuText, - ULyrics, Math, OpenGL12, UThemes, MidiOut; +{$I switches.inc} + +uses + UMenu, + UMusic, + SDL, + SysUtils, + UFiles, + UTime, + USongs, + UIni, + ULog, + UTexture, + UMenuText, + ULyrics, + Math, + OpenGL12, + {$IFDEF UseMIDIPort} + MidiOut, + {$ENDIF} + UThemes; type TScreenEditSub = class(TMenu) @@ -31,7 +50,10 @@ type Click: boolean; CopySrc: integer; + {$IFDEF UseMIDIPort} MidiOut: TMidiOutput; + {$endif} + MidiStart: real; MidiStop: real; MidiTime: real; @@ -470,6 +492,7 @@ begin SDLK_DOWN: begin + {$IFDEF UseMIDIPort} // skip to next sentence if SDL_ModState = 0 then begin MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); @@ -491,11 +514,13 @@ begin if SDL_ModState = KMOD_LCTRL then begin TransposeNote(-1); end; + {$endif} end; SDLK_UP: begin + {$IFDEF UseMIDIPort} // skip to previous sentence if SDL_ModState = 0 then begin MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); @@ -517,6 +542,7 @@ begin if SDL_ModState = KMOD_LCTRL then begin TransposeNote(1); end; + {$endif} end; // Golden Note Patch -- cgit v1.2.3 From 62c82114318ed04ce42617fa9ce2e179834dbda4 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 19 Sep 2007 11:44:10 +0000 Subject: added UCommon ( in classes ) for lazarus... common functions needed for lazarus ( and others ) can be put in here. also this now compiles on lazarus.. ( dosnt link yet... but I dont get any critical compiler errors ) tested to compile in my delphi, and basic functionality is fine. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@395 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 7184b0b6..3843fbf4 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -1169,11 +1169,12 @@ begin Exit; end else begin + {$IFDEF UseMIDIPort} MidiOut := TMidiOutput.Create(nil); if Ini.Debug = 1 then MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table MidiOut.Open; - + {$ENDIF} Text[TextTitle].Text := AktSong.Title; Text[TextArtist].Text := AktSong.Artist; Text[TextMp3].Text := AktSong.Mp3; @@ -1224,11 +1225,13 @@ begin if PlaySentenceMidi then begin MidiPos := USTime.GetTime - MidiTime + MidiStart; + {$IFDEF UseMIDIPort} // stop the music if (MidiPos > MidiStop) then begin MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); PlaySentenceMidi := false; end; + {$ENDIF} // click AktBeat := Floor(GetMidBeat(MidiPos - AktSong.GAP / 1000)); @@ -1236,13 +1239,16 @@ begin if AktBeat <> LastClick then begin for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do - if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then + begin + {$IFDEF UseMIDIPort} LastClick := AktBeat; if Pet > 0 then MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet-1].Ton + 60, 127); MidiOut.PutShort($91, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Ton + 60, 127); MidiLastNote := Pet; + {$ENDIF} end; end; @@ -1312,8 +1318,10 @@ end; procedure TScreenEditSub.onHide; begin + {$IFDEF UseMIDIPort} MidiOut.Close; MidiOut.Free; + {$ENDIF} //Music.SetVolume(100); end; -- cgit v1.2.3 From 26d8c209beba866f111a9d047bf1a70fe245b75d Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 20 Sep 2007 07:19:45 +0000 Subject: new lyrics stuff; it's broken (lyrics don't show) and in "debug" mode (weird stuff going on in the singscreen) but i'm tired of editing conflicts git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@412 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 3843fbf4..93a4892a 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -16,7 +16,7 @@ uses ULog, UTexture, UMenuText, - ULyrics, + ULyrics.bak, Math, OpenGL12, {$IFDEF UseMIDIPort} -- cgit v1.2.3 From 3c41f973b397b718135a7713c7501607812b0192 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Sep 2007 09:42:35 +0000 Subject: renamed Ulyrics.bak.pas hack to Ulyrics_bak.pas for lazarus compatiblity. minor changes to get code base compiling in Lazarus(win) and Delphi git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@415 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 93a4892a..e896d603 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -2,6 +2,10 @@ unit UScreenEditSub; interface +{$IFDEF FPC} + {$MODE DELPHI} +{$ENDIF} + {$I switches.inc} uses @@ -16,7 +20,7 @@ uses ULog, UTexture, UMenuText, - ULyrics.bak, + ULyrics_bak, Math, OpenGL12, {$IFDEF UseMIDIPort} -- cgit v1.2.3 From 50523ba17fcb19d37c54420ec3ea651538121e35 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 20 Sep 2007 10:39:30 +0000 Subject: moved a hack to a more appropriate place git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@417 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 1 + 1 file changed, 1 insertion(+) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index e896d603..22420b26 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -1072,6 +1072,7 @@ procedure TScreenEditSub.CopySentences(Src, Dst, Num: integer); var C: integer; begin + Lyric := TLyric.Create; // create place for new sentences SetLength(Czesci[0].Czesc, Czesci[0].Ilosc + Num - 1); -- cgit v1.2.3 From 44554c7908f7e2405a249331f00a35703f5939c2 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 11 Oct 2007 12:02:20 +0000 Subject: Added IAudioPlayback Interface and implementation for BASS. Created "AudioPlayback" Global Singleton, which removed the need for the "Music" Global variable. This was done because global singleton objects are a recognized better "design pattern" achieving the same thing as global variables, but in a nicer way. I will be working to a) separate IAudioPlayback in to separate "Playback" and "Input" Interfaces b) build a FFMpeg class that implements IAudioPlayback git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@504 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 38 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 22420b26..1dd3fb24 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -320,13 +320,13 @@ begin if SDL_ModState = 0 then begin // Play Sentence Click := true; - Music.Stop; + AudioPlayback.Stop; R := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - if R <= Music.Length then begin - Music.MoveTo(R); + if R <= AudioPlayback.Length then begin + AudioPlayback.MoveTo(R); PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); PlaySentence := true; - Music.Play; + AudioPlayback.Play; LastClick := -100; end; end; @@ -349,10 +349,10 @@ begin PlaySentence := true; Click := true; - Music.Stop; - Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); + AudioPlayback.Stop; + AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec)+0; - Music.Play; + AudioPlayback.Play; LastClick := -100; end; end; @@ -363,12 +363,12 @@ begin PlaySentenceMidi := false; // stop midi PlaySentence := true; Click := false; - Music.Stop; - Music.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); + AudioPlayback.Stop; + AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); PlayStopTime := (GetTimeFromBeat( Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); - Music.Play; + AudioPlayback.Play; LastClick := -100; end; @@ -510,7 +510,7 @@ begin Lyric.AddCzesc(Czesci[0].Akt); Lyric.Selected := 0; - Music.Stop; + AudioPlayback.Stop; PlaySentence := false; end; @@ -538,7 +538,7 @@ begin Lyric.AddCzesc(Czesci[0].Akt); Lyric.Selected := 0; - Music.Stop; + AudioPlayback.Stop; PlaySentence := false; end; @@ -1188,7 +1188,7 @@ begin AktNuta := 0; Czesci[0].Czesc[0].Nuta[0].Color := 1; - Music.Open(Path + AktSong.Mp3); + AudioPlayback.Open(Path + AktSong.Mp3); //Set Down Music Volume for Better hearability of Midi Sounds //Music.SetVolume(40); @@ -1262,20 +1262,22 @@ begin // mp3 music if PlaySentence then begin // stop the music - if (Music.Position > PlayStopTime) then begin - Music.Stop; + if (AudioPlayback.Position > PlayStopTime) then + begin + AudioPlayback.Stop; PlaySentence := false; end; // click if (Click) and (PlaySentence) then begin // AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); - AktBeat := Floor(GetMidBeat(Music.Position - AktSong.GAP / 1000)); + AktBeat := Floor(GetMidBeat(AudioPlayback.Position - AktSong.GAP / 1000)); Text[TextDebug].Text := IntToStr(AktBeat); if AktBeat <> LastClick then begin for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do - if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin - Music.PlayClick; + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then + begin + AudioPlayback.PlayClick; LastClick := AktBeat; end; end; -- cgit v1.2.3 From 391d30716d48dc709f6444b19c008e82311623b9 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 1 Nov 2007 19:34:40 +0000 Subject: Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux. Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 1dd3fb24..d24fdede 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -2,10 +2,6 @@ unit UScreenEditSub; interface -{$IFDEF FPC} - {$MODE DELPHI} -{$ENDIF} - {$I switches.inc} uses -- cgit v1.2.3 From 99955c78f63d1cb0d8bec666bc33953590a74c8a Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 1 Nov 2007 23:22:01 +0000 Subject: fixed failed builds build:USDX-LAZLIN-75 build:USDX-LAZLIN-76 for some reason we can not use {$MODE Delphi} in an included file. ( Probably because of the way the compier scopes this switch to each pas file ) ive had to revert this part of eddies changes. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@548 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 2749 +++++++++++++++++----------------- 1 file changed, 1376 insertions(+), 1373 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index d24fdede..6dcb1f5f 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -1,1373 +1,1376 @@ -unit UScreenEditSub; - -interface - -{$I switches.inc} - -uses - UMenu, - UMusic, - SDL, - SysUtils, - UFiles, - UTime, - USongs, - UIni, - ULog, - UTexture, - UMenuText, - ULyrics_bak, - Math, - OpenGL12, - {$IFDEF UseMIDIPort} - MidiOut, - {$ENDIF} - UThemes; - -type - TScreenEditSub = class(TMenu) - private - //Variable is True if no SOng is loaded - Error: Boolean; - - TextNote: integer; - TextSentence: integer; - TextTitle: integer; - TextArtist: integer; - TextMp3: integer; - TextBPM: integer; - TextGAP: integer; - TextDebug: integer; - TextNStart: integer; - TextNDlugosc: integer; - TextNTon: integer; - TextNText: integer; - AktNuta: integer; - PlaySentence: boolean; - PlaySentenceMidi: boolean; - PlayStopTime: real; - LastClick: integer; - Click: boolean; - CopySrc: integer; - - {$IFDEF UseMIDIPort} - MidiOut: TMidiOutput; - {$endif} - - MidiStart: real; - MidiStop: real; - MidiTime: real; - MidiPos: real; - MidiLastNote: integer; - - TextEditMode: boolean; - - procedure NewBeat; - procedure CzesciDivide; - procedure CzesciMultiply; - procedure LyricsCapitalize; - procedure LyricsCorrectSpaces; - procedure FixTimings; - procedure DivideSentence; - procedure JoinSentence; - procedure DivideNote; - procedure DeleteNote; - procedure TransposeNote(Transpose: integer); - procedure ChangeWholeTone(Tone: integer); - procedure MoveAllToEnd(Move: integer); - procedure MoveTextToRight; - procedure MarkSrc; - procedure PasteText; - procedure CopySentence(Src, Dst: integer); - procedure CopySentences(Src, Dst, Num: integer); - //Note Name Mod - function GetNoteName(Note: Integer): String; - public - Tex_Background: TTexture; - FadeOut: boolean; - Path: string; - FileName: string; - constructor Create; override; - procedure onShow; override; - function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; - function ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; - function Draw: boolean; override; - procedure onHide; override; - end; - -implementation -uses UGraphic, UDraw, UMain, USkins, ULanguage; - -// Method for input parsing. If False is returned, GetNextWindow -// should be checked to know the next window to load; -function TScreenEditSub.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; -var - SDL_ModState: Word; - R: real; -begin - Result := true; - - if TextEditMode then begin - Result := ParseInputEditText(PressedKey, ScanCode, PressedDown); - end else begin - - SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT - + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); - - If (PressedDown) then begin // Key Down - case PressedKey of - - SDLK_ESCAPE, - SDLK_BACKSPACE : - begin - FadeTo(@ScreenSong); - end; - - SDLK_Q: - begin - Result := false; - end; - - SDLK_BACKQUOTE: - begin - // Increase Note Length (same as Alt + Right) - Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then - Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - end; - - SDLK_EQUALS: - begin - // Increase BPM - if SDL_ModState = 0 then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) - if SDL_ModState = KMOD_LSHIFT then - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM + 4; // (1/1) - if SDL_ModState = KMOD_LCTRL then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) + 1) / 25; // (1/100) - end; - - SDLK_MINUS: - begin - // Decrease BPM - if SDL_ModState = 0 then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) - 1) / 5; - if SDL_ModState = KMOD_LSHIFT then - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM - 4; - if SDL_ModState = KMOD_LCTRL then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) - 1) / 25; - end; - - SDLK_0: - begin - // Increase GAP - if SDL_ModState = 0 then - AktSong.GAP := AktSong.GAP + 10; - if SDL_ModState = KMOD_LSHIFT then - AktSong.GAP := AktSong.GAP + 1000; - end; - - SDLK_9: - begin - // Decrease GAP - if SDL_ModState = 0 then - AktSong.GAP := AktSong.GAP - 10; - if SDL_ModState = KMOD_LSHIFT then - AktSong.GAP := AktSong.GAP - 1000; - end; - - SDLK_KP_PLUS: - begin - // Increase tone of all notes - if SDL_ModState = 0 then - ChangeWholeTone(1); - if SDL_ModState = KMOD_LSHIFT then - ChangeWholeTone(12); - end; - - SDLK_KP_MINUS: - begin - // Decrease tone of all notes - if SDL_ModState = 0 then - ChangeWholeTone(-1); - if SDL_ModState = KMOD_LSHIFT then - ChangeWholeTone(-12); - end; - - SDLK_SLASH: - begin - if SDL_ModState = 0 then begin - // Insert start of sentece - if AktNuta > 0 then - DivideSentence; - end; - - if SDL_ModState = KMOD_LSHIFT then begin - // Join next sentence with current - if Czesci[0].Akt < Czesci[0].High then - JoinSentence; - end; - - if SDL_ModState = KMOD_LCTRL then begin - // divide note - DivideNote; - end; - - end; - - SDLK_S: - begin - // Save Song - if SDL_ModState = KMOD_LSHIFT then - SaveSong(AktSong, Czesci[0], Path + FileName, true) - else - SaveSong(AktSong, Czesci[0], Path + FileName, false); - - {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then - // Save Song - SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false);} - - end; - - SDLK_D: - begin - // Divide lengths by 2 - CzesciDivide; - end; - - SDLK_M: - begin - // Multiply lengths by 2 - CzesciMultiply; - end; - - SDLK_C: - begin - // Capitalize letter at the beginning of line - if SDL_ModState = 0 then - LyricsCapitalize; - - // Correct spaces - if SDL_ModState = KMOD_LSHIFT then - LyricsCorrectSpaces; - - // Copy sentence - if SDL_ModState = KMOD_LCTRL then - MarkSrc; - end; - - SDLK_V: - begin - // Paste text - if SDL_ModState = KMOD_LCTRL then begin - if Czesci[0].Czesc[Czesci[0].Akt].IlNut >= Czesci[0].Czesc[CopySrc].IlNut then - PasteText - else - beep; - end; - - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin - CopySentence(CopySrc, Czesci[0].Akt); - end; - end; - - SDLK_4: - begin - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin - CopySentence(CopySrc, Czesci[0].Akt); - CopySentence(CopySrc+1, Czesci[0].Akt+1); - CopySentence(CopySrc+2, Czesci[0].Akt+2); - CopySentence(CopySrc+3, Czesci[0].Akt+3); - end; - - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin - CopySentences(CopySrc, Czesci[0].Akt, 4); - end; - end; - SDLK_5: - begin - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin - CopySentence(CopySrc, Czesci[0].Akt); - CopySentence(CopySrc+1, Czesci[0].Akt+1); - CopySentence(CopySrc+2, Czesci[0].Akt+2); - CopySentence(CopySrc+3, Czesci[0].Akt+3); - CopySentence(CopySrc+4, Czesci[0].Akt+4); - end; - - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin - CopySentences(CopySrc, Czesci[0].Akt, 5); - end; - end; - - SDLK_T: - begin - // Fixes timings between sentences - FixTimings; - end; - - SDLK_F4: - begin - // Enter Text Edit Mode - TextEditMode := true; - end; - - SDLK_P: - begin - if SDL_ModState = 0 then begin - // Play Sentence - Click := true; - AudioPlayback.Stop; - R := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - if R <= AudioPlayback.Length then begin - AudioPlayback.MoveTo(R); - PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - PlaySentence := true; - AudioPlayback.Play; - LastClick := -100; - end; - end; - - if SDL_ModState = KMOD_LSHIFT then begin - PlaySentenceMidi := true; - - MidiTime := USTime.GetTime; - MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - - LastClick := -100; - end; - if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL then begin - PlaySentenceMidi := true; - MidiTime := USTime.GetTime; - MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - LastClick := -100; - - PlaySentence := true; - Click := true; - AudioPlayback.Stop; - AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); - PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec)+0; - AudioPlayback.Play; - LastClick := -100; - end; - end; - - SDLK_SPACE: - begin - // Play Sentence - PlaySentenceMidi := false; // stop midi - PlaySentence := true; - Click := false; - AudioPlayback.Stop; - AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); - PlayStopTime := (GetTimeFromBeat( - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); - AudioPlayback.Play; - LastClick := -100; - end; - - SDLK_RETURN: - begin - end; - - SDLK_LCTRL: - begin - end; - - SDLK_DELETE: - begin - if SDL_ModState = KMOD_LCTRL then begin - // moves text to right in current sentence - DeleteNote; - end; - end; - - SDLK_PERIOD: - begin - // moves text to right in current sentence - MoveTextToRight; - end; - - SDLK_RIGHT: - begin - // right - if SDL_ModState = 0 then begin - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; - Inc(AktNuta); - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - Lyric.Selected := AktNuta; - end; - - // ctrl + right - if SDL_ModState = KMOD_LCTRL then begin - if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin - Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); - if AktNuta = 0 then begin - Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); - Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - end; - end; - end; - - // shift + right - if SDL_ModState = KMOD_LSHIFT then begin - Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); - if AktNuta = 0 then begin - Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); - Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - end; - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then - Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - end; - - // alt + right - if SDL_ModState = KMOD_LALT then begin - Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then - Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - end; - - // alt + ctrl + shift + right = move all from cursor to right - if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin - MoveAllToEnd(1); - end; - - end; - - SDLK_LEFT: - begin - // left - if SDL_ModState = 0 then begin - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; - Dec(AktNuta); - if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - Lyric.Selected := AktNuta; - end; - - // ctrl + left - if SDL_ModState = KMOD_LCTRL then begin - Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); - Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - if AktNuta = 0 then begin - Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); - Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - end; - end; - - // shift + left - if SDL_ModState = KMOD_LSHIFT then begin - Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); - - // resizing sentences - if AktNuta = 0 then begin - Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); - Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); - end; - - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then - Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - - end; - - // alt + left - if SDL_ModState = KMOD_LALT then begin - if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin - Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then - Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); - end; - end; - - // alt + ctrl + shift + right = move all from cursor to left - if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin - MoveAllToEnd(-1); - end; - - end; - - SDLK_DOWN: - begin - {$IFDEF UseMIDIPort} - // skip to next sentence - if SDL_ModState = 0 then begin - MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); - PlaySentenceMidi := false; - - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; - Inc(Czesci[0].Akt); - AktNuta := 0; - if Czesci[0].Akt > Czesci[0].High then Czesci[0].Akt := 0; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - - Lyric.AddCzesc(Czesci[0].Akt); - Lyric.Selected := 0; - AudioPlayback.Stop; - PlaySentence := false; - end; - - // decrease tone - if SDL_ModState = KMOD_LCTRL then begin - TransposeNote(-1); - end; - {$endif} - - end; - - SDLK_UP: - begin - {$IFDEF UseMIDIPort} - // skip to previous sentence - if SDL_ModState = 0 then begin - MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); - PlaySentenceMidi := false; - - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; - Dec(Czesci[0].Akt); - AktNuta := 0; - if Czesci[0].Akt = -1 then Czesci[0].Akt := Czesci[0].High; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - - Lyric.AddCzesc(Czesci[0].Akt); - Lyric.Selected := 0; - AudioPlayback.Stop; - PlaySentence := false; - end; - - // increase tone - if SDL_ModState = KMOD_LCTRL then begin - TransposeNote(1); - end; - {$endif} - end; - - // Golden Note Patch - SDLK_G: - begin - case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of - 0: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; - 1: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; - 2: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; - end; // case - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; - end; - - // Freestyle Note Patch - SDLK_F: - begin - case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of - 0: - begin; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; - end; - 1,2: - begin; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 0; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := True; - end; - end; // case - - end; - - - end; - end; - end; // if -end; - -function TScreenEditSub.ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; -var - SDL_ModState: Word; -begin - // used when in Text Edit Mode - Result := true; - - SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT - + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); - - If (PressedDown) Then - begin // Key Down - case PressedKey of - - SDLK_ESCAPE: - begin - FadeTo(@ScreenSong); - end; - SDLK_F4, SDLK_RETURN: - begin - // Exit Text Edit Mode - TextEditMode := false; - end; - SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL: - begin - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst := - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst + chr(ScanCode); - end; - SDLK_BACKSPACE: - begin - Delete(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst, - Length(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst), 1); - end; - SDLK_RIGHT: - begin - // right - if SDL_ModState = 0 then begin - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; - Inc(AktNuta); - if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - Lyric.Selected := AktNuta; - end; - end; - SDLK_LEFT: - begin - // left - if SDL_ModState = 0 then begin - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; - Dec(AktNuta); - if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - Lyric.Selected := AktNuta; - end; - end; - end; - end; -end; - -procedure TScreenEditSub.NewBeat; -begin - // click -{ for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do - if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = Czas.AktBeat) then begin - // old} -// Music.PlayClick; -end; - -procedure TScreenEditSub.CzesciDivide; -var - C: integer; - N: integer; -begin - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM / 2; - for C := 0 to Czesci[0].High do begin - Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start div 2; - Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote div 2; - Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec div 2; - for N := 0 to Czesci[0].Czesc[C].HighNut do begin - Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start div 2; - Czesci[0].Czesc[C].Nuta[N].Dlugosc := Round(Czesci[0].Czesc[C].Nuta[N].Dlugosc / 2); - end; // N - end; // C -end; - -procedure TScreenEditSub.CzesciMultiply; -var - C: integer; - N: integer; -begin - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM * 2; - for C := 0 to Czesci[0].High do begin - Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start * 2; - Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote * 2; - Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec * 2; - for N := 0 to Czesci[0].Czesc[C].HighNut do begin - Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start * 2; - Czesci[0].Czesc[C].Nuta[N].Dlugosc := Czesci[0].Czesc[C].Nuta[N].Dlugosc * 2; - end; // N - end; // C -end; - -procedure TScreenEditSub.LyricsCapitalize; -var - C: integer; - N: integer; // temporary - S: string; -begin - // temporary -{ for C := 0 to Czesci[0].High do - for N := 0 to Czesci[0].Czesc[C].HighNut do - Czesci[0].Czesc[C].Nuta[N].Tekst := AnsiLowerCase(Czesci[0].Czesc[C].Nuta[N].Tekst);} - - for C := 0 to Czesci[0].High do begin - S := AnsiUpperCase(Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1)); - S := S + Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, Length(Czesci[0].Czesc[C].Nuta[0].Tekst)-1); - Czesci[0].Czesc[C].Nuta[0].Tekst := S; - end; // C -end; - -procedure TScreenEditSub.LyricsCorrectSpaces; -var - C: integer; - N: integer; -begin - for C := 0 to Czesci[0].High do begin - // correct starting spaces in the first word - while Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1) = ' ' do - Czesci[0].Czesc[C].Nuta[0].Tekst := Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, 100); - - // move spaces on the start to the end of the previous note - for N := 1 to Czesci[0].Czesc[C].HighNut do begin - while (Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, 1) = ' ') do begin - Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 2, 100); - Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; - end; - end; // N - - // correct '-' to '- ' - for N := 0 to Czesci[0].Czesc[C].HighNut do begin - if Czesci[0].Czesc[C].Nuta[N].Tekst = '-' then - Czesci[0].Czesc[C].Nuta[N].Tekst := '- '; - end; // N - - // add space to the previous note when the current word is '- ' - for N := 1 to Czesci[0].Czesc[C].HighNut do begin - if Czesci[0].Czesc[C].Nuta[N].Tekst = '- ' then - Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; - end; // N - - // correct too many spaces at the end of note - for N := 0 to Czesci[0].Czesc[C].HighNut do begin - while Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1, 2) = ' ' do - Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1); - end; // N - - // and correct if there is no space at the end of sentence - N := Czesci[0].Czesc[C].HighNut; - if Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst), 1) <> ' ' then - Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N].Tekst + ' '; - - end; // C -end; - -procedure TScreenEditSub.FixTimings; -var - C: integer; - S: integer; - Min: integer; - Max: integer; -begin - for C := 1 to Czesci[0].High do begin - with Czesci[0].Czesc[C-1] do begin - Min := Nuta[HighNut].Start + Nuta[HighNut].Dlugosc; - Max := Czesci[0].Czesc[C].StartNote; - case (Max - Min) of - 0: S := Max; - 1: S := Max; - 2: S := Max - 1; - 3: S := Max - 2; - else - if ((Max - Min) > 4) then - S := Min + 2 - else - S := Max; - end; // case - - Czesci[0].Czesc[C].Start := S; - end; // with - end; // for -end; - -procedure TScreenEditSub.DivideSentence; -var - C: integer; - CStart: integer; - CNew: integer; - CLen: integer; - N: integer; - NStart: integer; - NHigh: integer; - NNewL: integer; -begin - // increase sentence length by 1 - CLen := Length(Czesci[0].Czesc); - SetLength(Czesci[0].Czesc, CLen + 1); - Inc(Czesci[0].Ilosc); - Inc(Czesci[0].High); - - // move needed sentences to one forward. newly has the copy of divided sentence - CStart := Czesci[0].Akt; - for C := CLen-1 downto CStart do - Czesci[0].Czesc[C+1] := Czesci[0].Czesc[C]; - - // clear and set new sentence - CNew := CStart + 1; - NStart := AktNuta; - Czesci[0].Czesc[CNew].Start := Czesci[0].Czesc[CStart].Nuta[NStart].Start; - Czesci[0].Czesc[CNew].StartNote := Czesci[0].Czesc[CStart].Nuta[NStart].Start; - Czesci[0].Czesc[CNew].Lyric := ''; - Czesci[0].Czesc[CNew].LyricWidth := 0; - Czesci[0].Czesc[CNew].Koniec := 0; - Czesci[0].Czesc[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure - Czesci[0].Czesc[CNew].IlNut := 0; - Czesci[0].Czesc[CNew].HighNut := -1; - SetLength(Czesci[0].Czesc[CNew].Nuta, 0); - - // move right notes to new sentences - NHigh := Czesci[0].Czesc[CStart].HighNut; - for N := NStart to NHigh do begin - NNewL := Czesci[0].Czesc[CNew].IlNut; - SetLength(Czesci[0].Czesc[CNew].Nuta, NNewL + 1); - Czesci[0].Czesc[CNew].Nuta[NNewL] := Czesci[0].Czesc[CStart].Nuta[N]; - - // increase sentence counters - Inc(Czesci[0].Czesc[CNew].IlNut); - Inc(Czesci[0].Czesc[CNew].HighNut); - Czesci[0].Czesc[CNew].Koniec := Czesci[0].Czesc[CNew].Nuta[NNewL].Start + - Czesci[0].Czesc[CNew].Nuta[NNewL].Dlugosc; - end; - - // clear old notes and set sentence counters - Czesci[0].Czesc[CStart].HighNut := NStart - 1; - Czesci[0].Czesc[CStart].IlNut := Czesci[0].Czesc[CStart].HighNut + 1; - Czesci[0].Czesc[CStart].Koniec := Czesci[0].Czesc[CStart].Nuta[NStart-1].Start + - Czesci[0].Czesc[CStart].Nuta[NStart-1].Dlugosc; - SetLength(Czesci[0].Czesc[CStart].Nuta, Czesci[0].Czesc[CStart].IlNut); - - // 0.5.0: modify BaseNote - Czesci[0].Czesc[CNew].BaseNote := 120; - for N := 0 to Czesci[0].Czesc[CNew].IlNut do - if Czesci[0].Czesc[CNew].Nuta[N].Ton < Czesci[0].Czesc[CNew].BaseNote then - Czesci[0].Czesc[CNew].BaseNote := Czesci[0].Czesc[CNew].Nuta[N].Ton; - - Czesci[0].Akt := Czesci[0].Akt + 1; - AktNuta := 0; - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - Lyric.AddCzesc(Czesci[0].Akt); - -end; - -procedure TScreenEditSub.JoinSentence; -var - C: integer; - N: integer; - NStart: integer; - NDst: integer; -begin - C := Czesci[0].Akt; - - // set new sentence - NStart := Czesci[0].Czesc[C].IlNut; - Czesci[0].Czesc[C].IlNut := Czesci[0].Czesc[C].IlNut + Czesci[0].Czesc[C+1].IlNut; - Czesci[0].Czesc[C].HighNut := Czesci[0].Czesc[C].HighNut + Czesci[0].Czesc[C+1].IlNut; - SetLength(Czesci[0].Czesc[C].Nuta, Czesci[0].Czesc[C].IlNut); - - // move right notes to new sentences - for N := 0 to Czesci[0].Czesc[C+1].HighNut do begin - NDst := NStart + N; - Czesci[0].Czesc[C].Nuta[NDst] := Czesci[0].Czesc[C+1].Nuta[N]; - end; - - // increase sentence counters - NDst := Czesci[0].Czesc[C].HighNut; - Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Nuta[NDst].Start + - Czesci[0].Czesc[C].Nuta[NDst].Dlugosc; - - // move needed sentences to one backward. - for C := Czesci[0].Akt + 1 to Czesci[0].High - 1 do - Czesci[0].Czesc[C] := Czesci[0].Czesc[C+1]; - - // increase sentence length by 1 - SetLength(Czesci[0].Czesc, Length(Czesci[0].Czesc) - 1); - Dec(Czesci[0].Ilosc); - Dec(Czesci[0].High); -end; - -procedure TScreenEditSub.DivideNote; -var - C: integer; - N: integer; - NLen: integer; -begin - C := Czesci[0].Akt; - - NLen := Czesci[0].Czesc[C].IlNut + 1; - SetLength(Czesci[0].Czesc[C].Nuta, NLen); - Inc(Czesci[0].Czesc[C].HighNut); - Inc(Czesci[0].Czesc[C].IlNut); - - // we copy all notes including selected one - for N := Czesci[0].Czesc[C].HighNut downto AktNuta+1 do begin - Czesci[0].Czesc[C].Nuta[N] := Czesci[0].Czesc[C].Nuta[N-1]; - end; - - // me slightly modify new note - Czesci[0].Czesc[C].Nuta[AktNuta].Dlugosc := 1; - Inc(Czesci[0].Czesc[C].Nuta[AktNuta+1].Start); - Dec(Czesci[0].Czesc[C].Nuta[AktNuta+1].Dlugosc); - Czesci[0].Czesc[C].Nuta[AktNuta+1].Tekst := '- '; - Czesci[0].Czesc[C].Nuta[AktNuta+1].Color := 0; -end; - -procedure TScreenEditSub.DeleteNote; -var - C: integer; - N: integer; - NLen: integer; -begin - C := Czesci[0].Akt; - - //Do Not delete Last Note - if (Czesci[0].High > 0) OR (Czesci[0].Czesc[C].HighNut > 0) then - begin - - // we copy all notes from the next to the selected one - for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin - Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; - end; - - NLen := Czesci[0].Czesc[C].IlNut - 1; - - if (NLen > 0) then - begin - SetLength(Czesci[0].Czesc[C].Nuta, NLen); - Dec(Czesci[0].Czesc[C].HighNut); - Dec(Czesci[0].Czesc[C].IlNut); - - - // me slightly modify new note - if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); - Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; - end - //Last Note of current Sentence Deleted - > Delete Sentence - else - begin - //Move all Sentences after the current to the Left - for N := C+1 to Czesci[0].High do - Czesci[0].Czesc[N-1] := Czesci[0].Czesc[N]; - - //Delete Last Sentence - SetLength(Czesci[0].Czesc, Czesci[0].High); - Czesci[0].High := High(Czesci[0].Czesc); - Czesci[0].Ilosc := Length(Czesci[0].Czesc); - - AktNuta := 0; - if (C > 0) then - Czesci[0].Akt := C - 1 - else - Czesci[0].Akt := 0; - - Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; - end; - end; -end; - -procedure TScreenEditSub.TransposeNote(Transpose: integer); -begin - Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton, Transpose); -end; - -procedure TScreenEditSub.ChangeWholeTone(Tone: integer); -var - C: integer; - N: integer; -begin - for C := 0 to Czesci[0].High do begin - Czesci[0].Czesc[C].BaseNote := Czesci[0].Czesc[C].BaseNote + Tone; - for N := 0 to Czesci[0].Czesc[C].HighNut do - Czesci[0].Czesc[C].Nuta[N].Ton := Czesci[0].Czesc[C].Nuta[N].Ton + Tone; - end; -end; - -procedure TScreenEditSub.MoveAllToEnd(Move: integer); -var - C: integer; - N: integer; - NStart: integer; -begin - for C := Czesci[0].Akt to Czesci[0].High do begin - NStart := 0; - if C = Czesci[0].Akt then NStart := AktNuta; - for N := NStart to Czesci[0].Czesc[C].HighNut do begin - Inc(Czesci[0].Czesc[C].Nuta[N].Start, Move); // move note start - - if N = 0 then begin // fix beginning - Inc(Czesci[0].Czesc[C].Start, Move); - Inc(Czesci[0].Czesc[C].StartNote, Move); - end; - - if N = Czesci[0].Czesc[C].HighNut then // fix ending - Inc(Czesci[0].Czesc[C].Koniec, Move); - - end; // for - end; // for -end; - -procedure TScreenEditSub.MoveTextToRight; -var - C: integer; - N: integer; - NHigh: integer; -begin -{ C := Czesci[0].Akt; - - for N := Czesci[0].Czesc[C].HighNut downto 1 do begin - Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; - end; // for - - Czesci[0].Czesc[C].Nuta[0].Tekst := '- ';} - - C := Czesci[0].Akt; - NHigh := Czesci[0].Czesc[C].HighNut; - - // last word - Czesci[0].Czesc[C].Nuta[NHigh].Tekst := Czesci[0].Czesc[C].Nuta[NHigh-1].Tekst + Czesci[0].Czesc[C].Nuta[NHigh].Tekst; - - // other words - for N := NHigh - 1 downto AktNuta + 1 do begin - Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; - end; // for - Czesci[0].Czesc[C].Nuta[AktNuta].Tekst := '- '; -end; - -procedure TScreenEditSub.MarkSrc; -begin - CopySrc := Czesci[0].Akt; -end; - -procedure TScreenEditSub.PasteText; -var - C: integer; - N: integer; -begin - C := Czesci[0].Akt; - - for N := 0 to Czesci[0].Czesc[CopySrc].HighNut do - Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[CopySrc].Nuta[N].Tekst; -end; - -procedure TScreenEditSub.CopySentence(Src, Dst: integer); -var - N: integer; - Time1: integer; - Time2: integer; - TD: integer; -begin - Time1 := Czesci[0].Czesc[Src].Nuta[0].Start; - Time2 := Czesci[0].Czesc[Dst].Nuta[0].Start; - TD := Time2-Time1; - - SetLength(Czesci[0].Czesc[Dst].Nuta, Czesci[0].Czesc[Src].IlNut); - Czesci[0].Czesc[Dst].IlNut := Czesci[0].Czesc[Src].IlNut; - Czesci[0].Czesc[Dst].HighNut := Czesci[0].Czesc[Src].HighNut; - for N := 0 to Czesci[0].Czesc[Src].HighNut do begin - Czesci[0].Czesc[Dst].Nuta[N].Tekst := Czesci[0].Czesc[Src].Nuta[N].Tekst; - Czesci[0].Czesc[Dst].Nuta[N].Dlugosc := Czesci[0].Czesc[Src].Nuta[N].Dlugosc; - Czesci[0].Czesc[Dst].Nuta[N].Ton := Czesci[0].Czesc[Src].Nuta[N].Ton; - Czesci[0].Czesc[Dst].Nuta[N].Start := Czesci[0].Czesc[Src].Nuta[N].Start + TD; - end; - N := Czesci[0].Czesc[Src].HighNut; - Czesci[0].Czesc[Dst].Koniec := Czesci[0].Czesc[Dst].Nuta[N].Start + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc; -end; - -procedure TScreenEditSub.CopySentences(Src, Dst, Num: integer); -var - C: integer; -begin - Lyric := TLyric.Create; - // create place for new sentences - SetLength(Czesci[0].Czesc, Czesci[0].Ilosc + Num - 1); - - // moves sentences next to the destination - for C := Czesci[0].High downto Dst + 1 do begin - Czesci[0].Czesc[C + Num - 1] := Czesci[0].Czesc[C]; - end; - - // prepares new sentences: sets sentence start and create first note - for C := 1 to Num-1 do begin - Czesci[0].Czesc[Dst + C].Start := Czesci[0].Czesc[Dst + C - 1].StartNote + - (Czesci[0].Czesc[Src + C].StartNote - Czesci[0].Czesc[Src + C - 1].StartNote); - SetLength(Czesci[0].Czesc[Dst + C].Nuta, 1); - Czesci[0].Czesc[Dst + C].IlNut := 1; - Czesci[0].Czesc[Dst + C].HighNut := 0; - Czesci[0].Czesc[Dst + C].Nuta[0].Start := Czesci[0].Czesc[Dst + C].Start; - Czesci[0].Czesc[Dst + C].Nuta[0].Dlugosc := 1; - Czesci[0].Czesc[Dst + C].StartNote := Czesci[0].Czesc[Dst + C].Start; - Czesci[0].Czesc[Dst + C].Koniec := Czesci[0].Czesc[Dst + C].Start + 1; - end; - - // increase counters - Czesci[0].Ilosc := Czesci[0].Ilosc + Num - 1; - Czesci[0].High := Czesci[0].High + Num - 1; - - for C := 0 to Num-1 do - CopySentence(Src + C, Dst + C); -end; - - -constructor TScreenEditSub.Create; -begin - inherited Create; - SetLength(Player, 1); - - // linijka - AddStatic(20, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); - AddText(40, 17, 1, 6, 1, 1, 1, 'Line'); - TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0'); - - // nuta - AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); - AddText(242, 17, 1, 6, 1, 1, 1, 'Note'); - TextNote := AddText(320, 14, 1, 8, 0, 0, 0, '0 / 0'); - - // file info - AddStatic(150, 50, 500, 150, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); - AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); - AddText(180, 65, 0, 8, 0, 0, 0, 'Title:'); - AddText(180, 90, 0, 8, 0, 0, 0, 'Artist:'); - AddText(180, 115, 0, 8, 0, 0, 0, 'Mp3:'); - AddText(180, 140, 0, 8, 0, 0, 0, 'BPM:'); - AddText(180, 165, 0, 8, 0, 0, 0, 'GAP:'); - - TextTitle := AddText(250, 65, 0, 8, 0, 0, 0, 'a'); - TextArtist := AddText(250, 90, 0, 8, 0, 0, 0, 'b'); - TextMp3 := AddText(250, 115, 0, 8, 0, 0, 0, 'c'); - TextBPM := AddText(250, 140, 0, 8, 0, 0, 0, 'd'); - TextGAP := AddText(250, 165, 0, 8, 0, 0, 0, 'e'); - -{ AddInteraction(2, TextTitle); - AddInteraction(2, TextArtist); - AddInteraction(2, TextMp3); - AddInteraction(2, TextBPM); - AddInteraction(2, TextGAP);} - - // note info - AddText(20, 190, 0, 8, 0, 0, 0, 'Start:'); - AddText(20, 215, 0, 8, 0, 0, 0, 'Duration:'); - AddText(20, 240, 0, 8, 0, 0, 0, 'Tone:'); - AddText(20, 265, 0, 8, 0, 0, 0, 'Text:'); - - TextNStart := AddText(120, 190, 0, 8, 0, 0, 0, 'a'); - TextNDlugosc := AddText(120, 215, 0, 8, 0, 0, 0, 'b'); - TextNTon := AddText(120, 240, 0, 8, 0, 0, 0, 'c'); - TextNText := AddText(120, 265, 0, 8, 0, 0, 0, 'd'); - - // debug - TextDebug := AddText(30, 550, 0, 8, 0, 0, 0, ''); - -end; - -procedure TScreenEditSub.onShow; -begin - Log.LogStatus('Initializing', 'TEditScreen.onShow'); - - try - ResetSingTemp; - Error := not LoadSong(Path + FileName); - except - Error := True; - end; - - if Error then - begin - //Error Loading Song -> Go back to Song Screen and Show some Error Message - FadeTo(@ScreenSong); - ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); - Exit; - end - else begin - {$IFDEF UseMIDIPort} - MidiOut := TMidiOutput.Create(nil); - if Ini.Debug = 1 then - MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table - MidiOut.Open; - {$ENDIF} - Text[TextTitle].Text := AktSong.Title; - Text[TextArtist].Text := AktSong.Artist; - Text[TextMp3].Text := AktSong.Mp3; - - Czesci[0].Akt := 0; - AktNuta := 0; - Czesci[0].Czesc[0].Nuta[0].Color := 1; - - AudioPlayback.Open(Path + AktSong.Mp3); - //Set Down Music Volume for Better hearability of Midi Sounds - //Music.SetVolume(40); - - Lyric.Clear; - Lyric.X := 400; - Lyric.Y := 500; - Lyric.Align := 1; - Lyric.Size := 14; - Lyric.ColR := 0; - Lyric.ColG := 0; - Lyric.ColB := 0; - Lyric.ColSR := Skin_FontHighlightR; - Lyric.ColSG := Skin_FontHighlightG; - Lyric.ColSB := Skin_FontHighlightB; - Lyric.Style := 0; - Lyric.AddCzesc(0); - Lyric.Selected := 0; - - NotesH := 7; - NotesW := 4; - - end; - -// Interaction := 0; - TextEditMode := false; -end; - -function TScreenEditSub.Draw: boolean; -var - Min: integer; - Sec: integer; - Tekst: string; - Pet: integer; - AktBeat: integer; -begin - glClearColor(1,1,1,1); - - // midi music - if PlaySentenceMidi then begin - MidiPos := USTime.GetTime - MidiTime + MidiStart; - - {$IFDEF UseMIDIPort} - // stop the music - if (MidiPos > MidiStop) then begin - MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); - PlaySentenceMidi := false; - end; - {$ENDIF} - - // click - AktBeat := Floor(GetMidBeat(MidiPos - AktSong.GAP / 1000)); - Text[TextDebug].Text := IntToStr(AktBeat); - - if AktBeat <> LastClick then begin - for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do - if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then - begin - - {$IFDEF UseMIDIPort} - LastClick := AktBeat; - if Pet > 0 then - MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet-1].Ton + 60, 127); - MidiOut.PutShort($91, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Ton + 60, 127); - MidiLastNote := Pet; - {$ENDIF} - - end; - end; - end; // if PlaySentenceMidi - - // mp3 music - if PlaySentence then begin - // stop the music - if (AudioPlayback.Position > PlayStopTime) then - begin - AudioPlayback.Stop; - PlaySentence := false; - end; - - // click - if (Click) and (PlaySentence) then begin -// AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); - AktBeat := Floor(GetMidBeat(AudioPlayback.Position - AktSong.GAP / 1000)); - Text[TextDebug].Text := IntToStr(AktBeat); - if AktBeat <> LastClick then begin - for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do - if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then - begin - AudioPlayback.PlayClick; - LastClick := AktBeat; - end; - end; - end; // click - end; // if PlaySentence - - - Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); - Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); - - // Song info - Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); - Text[TextGAP].Text := FloatToStr(AktSong.GAP); - - //Error reading Variables when no Song is loaded - if not Error then - begin - // Note info - Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); - Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); - Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' ( ' + GetNoteName(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' )'; - Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; - end; - - // Text Edit Mode - if TextEditMode then - Text[TextNText].Text := Text[TextNText].Text + '|'; - - // draw static menu - inherited Draw; - - // draw notes - SingDrawNoteLines(20, 300, 780, 15); - //Error Drawing when no Song is loaded - if not Error then - begin - SingDrawBeatDelimeters(40, 300, 760, 0); - EditDrawCzesc(40, 405, 760, 0, 15); - end; - - // draw text - Lyric.Draw; - -end; - -procedure TScreenEditSub.onHide; -begin - {$IFDEF UseMIDIPort} - MidiOut.Close; - MidiOut.Free; - {$ENDIF} - //Music.SetVolume(100); -end; - -function TScreenEditSub.GetNoteName(Note: Integer): String; -var N1, N2: Integer; -begin - if (Note > 0) then - begin - N1 := Note mod 12; - N2 := Note div 12; - end - else - begin - N1 := (Note + (-Trunc(Note/12)+1)*12) mod 12; - N2 := -1; - end; - - - - case N1 of - 0: Result := 'c'; - 1: Result := 'c#'; - 2: Result := 'd'; - 3: Result := 'd#'; - 4: Result := 'e'; - 5: Result := 'f'; - 6: Result := 'f#'; - 7: Result := 'g'; - 8: Result := 'g#'; - 9: Result := 'a'; - 10: Result := 'b'; - 11: Result := 'h'; - end; - - case N2 of - 0: Result := UpperCase(Result); //Normal Uppercase Note, 1: Normal lowercase Note - 2: Result := Result + ''''; //One Striped - 3: Result := Result + ''''''; //Two Striped - 4: Result := Result + ''''''''; //etc. - 5: Result := Result + ''''''''''; - 6: Result := Result + ''''''''''''; - 7: Result := Result + ''''''''''''''; - end; -end; - -end. +unit UScreenEditSub; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} +{$I switches.inc} + +uses + UMenu, + UMusic, + SDL, + SysUtils, + UFiles, + UTime, + USongs, + UIni, + ULog, + UTexture, + UMenuText, + ULyrics_bak, + Math, + OpenGL12, + {$IFDEF UseMIDIPort} + MidiOut, + {$ENDIF} + UThemes; + +type + TScreenEditSub = class(TMenu) + private + //Variable is True if no SOng is loaded + Error: Boolean; + + TextNote: integer; + TextSentence: integer; + TextTitle: integer; + TextArtist: integer; + TextMp3: integer; + TextBPM: integer; + TextGAP: integer; + TextDebug: integer; + TextNStart: integer; + TextNDlugosc: integer; + TextNTon: integer; + TextNText: integer; + AktNuta: integer; + PlaySentence: boolean; + PlaySentenceMidi: boolean; + PlayStopTime: real; + LastClick: integer; + Click: boolean; + CopySrc: integer; + + {$IFDEF UseMIDIPort} + MidiOut: TMidiOutput; + {$endif} + + MidiStart: real; + MidiStop: real; + MidiTime: real; + MidiPos: real; + MidiLastNote: integer; + + TextEditMode: boolean; + + procedure NewBeat; + procedure CzesciDivide; + procedure CzesciMultiply; + procedure LyricsCapitalize; + procedure LyricsCorrectSpaces; + procedure FixTimings; + procedure DivideSentence; + procedure JoinSentence; + procedure DivideNote; + procedure DeleteNote; + procedure TransposeNote(Transpose: integer); + procedure ChangeWholeTone(Tone: integer); + procedure MoveAllToEnd(Move: integer); + procedure MoveTextToRight; + procedure MarkSrc; + procedure PasteText; + procedure CopySentence(Src, Dst: integer); + procedure CopySentences(Src, Dst, Num: integer); + //Note Name Mod + function GetNoteName(Note: Integer): String; + public + Tex_Background: TTexture; + FadeOut: boolean; + Path: string; + FileName: string; + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + function ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; + function Draw: boolean; override; + procedure onHide; override; + end; + +implementation +uses UGraphic, UDraw, UMain, USkins, ULanguage; + +// Method for input parsing. If False is returned, GetNextWindow +// should be checked to know the next window to load; +function TScreenEditSub.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; + R: real; +begin + Result := true; + + if TextEditMode then begin + Result := ParseInputEditText(PressedKey, ScanCode, PressedDown); + end else begin + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); + + If (PressedDown) then begin // Key Down + case PressedKey of + + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + FadeTo(@ScreenSong); + end; + + SDLK_Q: + begin + Result := false; + end; + + SDLK_BACKQUOTE: + begin + // Increase Note Length (same as Alt + Right) + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + SDLK_EQUALS: + begin + // Increase BPM + if SDL_ModState = 0 then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) + if SDL_ModState = KMOD_LSHIFT then + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM + 4; // (1/1) + if SDL_ModState = KMOD_LCTRL then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) + 1) / 25; // (1/100) + end; + + SDLK_MINUS: + begin + // Decrease BPM + if SDL_ModState = 0 then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) - 1) / 5; + if SDL_ModState = KMOD_LSHIFT then + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM - 4; + if SDL_ModState = KMOD_LCTRL then + AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) - 1) / 25; + end; + + SDLK_0: + begin + // Increase GAP + if SDL_ModState = 0 then + AktSong.GAP := AktSong.GAP + 10; + if SDL_ModState = KMOD_LSHIFT then + AktSong.GAP := AktSong.GAP + 1000; + end; + + SDLK_9: + begin + // Decrease GAP + if SDL_ModState = 0 then + AktSong.GAP := AktSong.GAP - 10; + if SDL_ModState = KMOD_LSHIFT then + AktSong.GAP := AktSong.GAP - 1000; + end; + + SDLK_KP_PLUS: + begin + // Increase tone of all notes + if SDL_ModState = 0 then + ChangeWholeTone(1); + if SDL_ModState = KMOD_LSHIFT then + ChangeWholeTone(12); + end; + + SDLK_KP_MINUS: + begin + // Decrease tone of all notes + if SDL_ModState = 0 then + ChangeWholeTone(-1); + if SDL_ModState = KMOD_LSHIFT then + ChangeWholeTone(-12); + end; + + SDLK_SLASH: + begin + if SDL_ModState = 0 then begin + // Insert start of sentece + if AktNuta > 0 then + DivideSentence; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + // Join next sentence with current + if Czesci[0].Akt < Czesci[0].High then + JoinSentence; + end; + + if SDL_ModState = KMOD_LCTRL then begin + // divide note + DivideNote; + end; + + end; + + SDLK_S: + begin + // Save Song + if SDL_ModState = KMOD_LSHIFT then + SaveSong(AktSong, Czesci[0], Path + FileName, true) + else + SaveSong(AktSong, Czesci[0], Path + FileName, false); + + {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then + // Save Song + SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false);} + + end; + + SDLK_D: + begin + // Divide lengths by 2 + CzesciDivide; + end; + + SDLK_M: + begin + // Multiply lengths by 2 + CzesciMultiply; + end; + + SDLK_C: + begin + // Capitalize letter at the beginning of line + if SDL_ModState = 0 then + LyricsCapitalize; + + // Correct spaces + if SDL_ModState = KMOD_LSHIFT then + LyricsCorrectSpaces; + + // Copy sentence + if SDL_ModState = KMOD_LCTRL then + MarkSrc; + end; + + SDLK_V: + begin + // Paste text + if SDL_ModState = KMOD_LCTRL then begin + if Czesci[0].Czesc[Czesci[0].Akt].IlNut >= Czesci[0].Czesc[CopySrc].IlNut then + PasteText + else + beep; + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + end; + end; + + SDLK_4: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + CopySentence(CopySrc+1, Czesci[0].Akt+1); + CopySentence(CopySrc+2, Czesci[0].Akt+2); + CopySentence(CopySrc+3, Czesci[0].Akt+3); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Czesci[0].Akt, 4); + end; + end; + SDLK_5: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Czesci[0].Akt); + CopySentence(CopySrc+1, Czesci[0].Akt+1); + CopySentence(CopySrc+2, Czesci[0].Akt+2); + CopySentence(CopySrc+3, Czesci[0].Akt+3); + CopySentence(CopySrc+4, Czesci[0].Akt+4); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Czesci[0].Akt, 5); + end; + end; + + SDLK_T: + begin + // Fixes timings between sentences + FixTimings; + end; + + SDLK_F4: + begin + // Enter Text Edit Mode + TextEditMode := true; + end; + + SDLK_P: + begin + if SDL_ModState = 0 then begin + // Play Sentence + Click := true; + AudioPlayback.Stop; + R := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + if R <= AudioPlayback.Length then begin + AudioPlayback.MoveTo(R); + PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + PlaySentence := true; + AudioPlayback.Play; + LastClick := -100; + end; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + PlaySentenceMidi := true; + + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + + LastClick := -100; + end; + if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL then begin + PlaySentenceMidi := true; + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + MidiStop := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + LastClick := -100; + + PlaySentence := true; + Click := true; + AudioPlayback.Stop; + AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); + PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec)+0; + AudioPlayback.Play; + LastClick := -100; + end; + end; + + SDLK_SPACE: + begin + // Play Sentence + PlaySentenceMidi := false; // stop midi + PlaySentence := true; + Click := false; + AudioPlayback.Stop; + AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); + PlayStopTime := (GetTimeFromBeat( + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); + AudioPlayback.Play; + LastClick := -100; + end; + + SDLK_RETURN: + begin + end; + + SDLK_LCTRL: + begin + end; + + SDLK_DELETE: + begin + if SDL_ModState = KMOD_LCTRL then begin + // moves text to right in current sentence + DeleteNote; + end; + end; + + SDLK_PERIOD: + begin + // moves text to right in current sentence + MoveTextToRight; + end; + + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(AktNuta); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + + // ctrl + right + if SDL_ModState = KMOD_LCTRL then begin + if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + if AktNuta = 0 then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + end; + end; + + // shift + right + if SDL_ModState = KMOD_LSHIFT then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + if AktNuta = 0 then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + // alt + right + if SDL_ModState = KMOD_LALT then begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Inc(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + + // alt + ctrl + shift + right = move all from cursor to right + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + MoveAllToEnd(1); + end; + + end; + + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(AktNuta); + if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + + // ctrl + left + if SDL_ModState = KMOD_LCTRL then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = 0 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); + Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + end; + + // shift + left + if SDL_ModState = KMOD_LSHIFT then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + + // resizing sentences + if AktNuta = 0 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Start); + Dec(Czesci[0].Czesc[Czesci[0].Akt].StartNote); + end; + + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + + end; + + // alt + left + if SDL_ModState = KMOD_LALT then begin + if Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc > 1 then begin + Dec(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].HighNut then + Dec(Czesci[0].Czesc[Czesci[0].Akt].Koniec); + end; + end; + + // alt + ctrl + shift + right = move all from cursor to left + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + MoveAllToEnd(-1); + end; + + end; + + SDLK_DOWN: + begin + {$IFDEF UseMIDIPort} + // skip to next sentence + if SDL_ModState = 0 then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(Czesci[0].Akt); + AktNuta := 0; + if Czesci[0].Akt > Czesci[0].High then Czesci[0].Akt := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + + Lyric.AddCzesc(Czesci[0].Akt); + Lyric.Selected := 0; + AudioPlayback.Stop; + PlaySentence := false; + end; + + // decrease tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(-1); + end; + {$endif} + + end; + + SDLK_UP: + begin + {$IFDEF UseMIDIPort} + // skip to previous sentence + if SDL_ModState = 0 then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(Czesci[0].Akt); + AktNuta := 0; + if Czesci[0].Akt = -1 then Czesci[0].Akt := Czesci[0].High; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + + Lyric.AddCzesc(Czesci[0].Akt); + Lyric.Selected := 0; + AudioPlayback.Stop; + PlaySentence := false; + end; + + // increase tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(1); + end; + {$endif} + end; + + // Golden Note Patch + SDLK_G: + begin + case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of + 0: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; + 1: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 2; + 2: Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; + end; // case + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; + end; + + // Freestyle Note Patch + SDLK_F: + begin + case Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc of + 0: + begin; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 1; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := False; + end; + 1,2: + begin; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Wartosc := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Freestyle := True; + end; + end; // case + + end; + + + end; + end; + end; // if +end; + +function TScreenEditSub.ParseInputEditText(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; +begin + // used when in Text Edit Mode + Result := true; + + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); + + If (PressedDown) Then + begin // Key Down + case PressedKey of + + SDLK_ESCAPE: + begin + FadeTo(@ScreenSong); + end; + SDLK_F4, SDLK_RETURN: + begin + // Exit Text Edit Mode + TextEditMode := false; + end; + SDLK_0..SDLK_9, SDLK_A..SDLK_Z, SDLK_SPACE, SDLK_MINUS, SDLK_EXCLAIM, SDLK_COMMA, SDLK_SLASH, SDLK_ASTERISK, SDLK_QUESTION, SDLK_QUOTE, SDLK_QUOTEDBL: + begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst := + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst + chr(ScanCode); + end; + SDLK_BACKSPACE: + begin + Delete(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst, + Length(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst), 1); + end; + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Inc(AktNuta); + if AktNuta = Czesci[0].Czesc[Czesci[0].Akt].IlNut then AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + end; + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 0; + Dec(AktNuta); + if AktNuta = -1 then AktNuta := Czesci[0].Czesc[Czesci[0].Akt].HighNut; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.Selected := AktNuta; + end; + end; + end; + end; +end; + +procedure TScreenEditSub.NewBeat; +begin + // click +{ for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = Czas.AktBeat) then begin + // old} +// Music.PlayClick; +end; + +procedure TScreenEditSub.CzesciDivide; +var + C: integer; + N: integer; +begin + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM / 2; + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start div 2; + Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote div 2; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec div 2; + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start div 2; + Czesci[0].Czesc[C].Nuta[N].Dlugosc := Round(Czesci[0].Czesc[C].Nuta[N].Dlugosc / 2); + end; // N + end; // C +end; + +procedure TScreenEditSub.CzesciMultiply; +var + C: integer; + N: integer; +begin + AktSong.BPM[0].BPM := AktSong.BPM[0].BPM * 2; + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start * 2; + Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote * 2; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Koniec * 2; + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N].Start := Czesci[0].Czesc[C].Nuta[N].Start * 2; + Czesci[0].Czesc[C].Nuta[N].Dlugosc := Czesci[0].Czesc[C].Nuta[N].Dlugosc * 2; + end; // N + end; // C +end; + +procedure TScreenEditSub.LyricsCapitalize; +var + C: integer; + N: integer; // temporary + S: string; +begin + // temporary +{ for C := 0 to Czesci[0].High do + for N := 0 to Czesci[0].Czesc[C].HighNut do + Czesci[0].Czesc[C].Nuta[N].Tekst := AnsiLowerCase(Czesci[0].Czesc[C].Nuta[N].Tekst);} + + for C := 0 to Czesci[0].High do begin + S := AnsiUpperCase(Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1)); + S := S + Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, Length(Czesci[0].Czesc[C].Nuta[0].Tekst)-1); + Czesci[0].Czesc[C].Nuta[0].Tekst := S; + end; // C +end; + +procedure TScreenEditSub.LyricsCorrectSpaces; +var + C: integer; + N: integer; +begin + for C := 0 to Czesci[0].High do begin + // correct starting spaces in the first word + while Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 1, 1) = ' ' do + Czesci[0].Czesc[C].Nuta[0].Tekst := Copy(Czesci[0].Czesc[C].Nuta[0].Tekst, 2, 100); + + // move spaces on the start to the end of the previous note + for N := 1 to Czesci[0].Czesc[C].HighNut do begin + while (Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, 1) = ' ') do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 2, 100); + Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; + end; + end; // N + + // correct '-' to '- ' + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + if Czesci[0].Czesc[C].Nuta[N].Tekst = '-' then + Czesci[0].Czesc[C].Nuta[N].Tekst := '- '; + end; // N + + // add space to the previous note when the current word is '- ' + for N := 1 to Czesci[0].Czesc[C].HighNut do begin + if Czesci[0].Czesc[C].Nuta[N].Tekst = '- ' then + Czesci[0].Czesc[C].Nuta[N-1].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst + ' '; + end; // N + + // correct too many spaces at the end of note + for N := 0 to Czesci[0].Czesc[C].HighNut do begin + while Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1, 2) = ' ' do + Czesci[0].Czesc[C].Nuta[N].Tekst := Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, 1, Length(Czesci[0].Czesc[C].Nuta[N].Tekst)-1); + end; // N + + // and correct if there is no space at the end of sentence + N := Czesci[0].Czesc[C].HighNut; + if Copy(Czesci[0].Czesc[C].Nuta[N].Tekst, Length(Czesci[0].Czesc[C].Nuta[N].Tekst), 1) <> ' ' then + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N].Tekst + ' '; + + end; // C +end; + +procedure TScreenEditSub.FixTimings; +var + C: integer; + S: integer; + Min: integer; + Max: integer; +begin + for C := 1 to Czesci[0].High do begin + with Czesci[0].Czesc[C-1] do begin + Min := Nuta[HighNut].Start + Nuta[HighNut].Dlugosc; + Max := Czesci[0].Czesc[C].StartNote; + case (Max - Min) of + 0: S := Max; + 1: S := Max; + 2: S := Max - 1; + 3: S := Max - 2; + else + if ((Max - Min) > 4) then + S := Min + 2 + else + S := Max; + end; // case + + Czesci[0].Czesc[C].Start := S; + end; // with + end; // for +end; + +procedure TScreenEditSub.DivideSentence; +var + C: integer; + CStart: integer; + CNew: integer; + CLen: integer; + N: integer; + NStart: integer; + NHigh: integer; + NNewL: integer; +begin + // increase sentence length by 1 + CLen := Length(Czesci[0].Czesc); + SetLength(Czesci[0].Czesc, CLen + 1); + Inc(Czesci[0].Ilosc); + Inc(Czesci[0].High); + + // move needed sentences to one forward. newly has the copy of divided sentence + CStart := Czesci[0].Akt; + for C := CLen-1 downto CStart do + Czesci[0].Czesc[C+1] := Czesci[0].Czesc[C]; + + // clear and set new sentence + CNew := CStart + 1; + NStart := AktNuta; + Czesci[0].Czesc[CNew].Start := Czesci[0].Czesc[CStart].Nuta[NStart].Start; + Czesci[0].Czesc[CNew].StartNote := Czesci[0].Czesc[CStart].Nuta[NStart].Start; + Czesci[0].Czesc[CNew].Lyric := ''; + Czesci[0].Czesc[CNew].LyricWidth := 0; + Czesci[0].Czesc[CNew].Koniec := 0; + Czesci[0].Czesc[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure + Czesci[0].Czesc[CNew].IlNut := 0; + Czesci[0].Czesc[CNew].HighNut := -1; + SetLength(Czesci[0].Czesc[CNew].Nuta, 0); + + // move right notes to new sentences + NHigh := Czesci[0].Czesc[CStart].HighNut; + for N := NStart to NHigh do begin + NNewL := Czesci[0].Czesc[CNew].IlNut; + SetLength(Czesci[0].Czesc[CNew].Nuta, NNewL + 1); + Czesci[0].Czesc[CNew].Nuta[NNewL] := Czesci[0].Czesc[CStart].Nuta[N]; + + // increase sentence counters + Inc(Czesci[0].Czesc[CNew].IlNut); + Inc(Czesci[0].Czesc[CNew].HighNut); + Czesci[0].Czesc[CNew].Koniec := Czesci[0].Czesc[CNew].Nuta[NNewL].Start + + Czesci[0].Czesc[CNew].Nuta[NNewL].Dlugosc; + end; + + // clear old notes and set sentence counters + Czesci[0].Czesc[CStart].HighNut := NStart - 1; + Czesci[0].Czesc[CStart].IlNut := Czesci[0].Czesc[CStart].HighNut + 1; + Czesci[0].Czesc[CStart].Koniec := Czesci[0].Czesc[CStart].Nuta[NStart-1].Start + + Czesci[0].Czesc[CStart].Nuta[NStart-1].Dlugosc; + SetLength(Czesci[0].Czesc[CStart].Nuta, Czesci[0].Czesc[CStart].IlNut); + + // 0.5.0: modify BaseNote + Czesci[0].Czesc[CNew].BaseNote := 120; + for N := 0 to Czesci[0].Czesc[CNew].IlNut do + if Czesci[0].Czesc[CNew].Nuta[N].Ton < Czesci[0].Czesc[CNew].BaseNote then + Czesci[0].Czesc[CNew].BaseNote := Czesci[0].Czesc[CNew].Nuta[N].Ton; + + Czesci[0].Akt := Czesci[0].Akt + 1; + AktNuta := 0; + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + Lyric.AddCzesc(Czesci[0].Akt); + +end; + +procedure TScreenEditSub.JoinSentence; +var + C: integer; + N: integer; + NStart: integer; + NDst: integer; +begin + C := Czesci[0].Akt; + + // set new sentence + NStart := Czesci[0].Czesc[C].IlNut; + Czesci[0].Czesc[C].IlNut := Czesci[0].Czesc[C].IlNut + Czesci[0].Czesc[C+1].IlNut; + Czesci[0].Czesc[C].HighNut := Czesci[0].Czesc[C].HighNut + Czesci[0].Czesc[C+1].IlNut; + SetLength(Czesci[0].Czesc[C].Nuta, Czesci[0].Czesc[C].IlNut); + + // move right notes to new sentences + for N := 0 to Czesci[0].Czesc[C+1].HighNut do begin + NDst := NStart + N; + Czesci[0].Czesc[C].Nuta[NDst] := Czesci[0].Czesc[C+1].Nuta[N]; + end; + + // increase sentence counters + NDst := Czesci[0].Czesc[C].HighNut; + Czesci[0].Czesc[C].Koniec := Czesci[0].Czesc[C].Nuta[NDst].Start + + Czesci[0].Czesc[C].Nuta[NDst].Dlugosc; + + // move needed sentences to one backward. + for C := Czesci[0].Akt + 1 to Czesci[0].High - 1 do + Czesci[0].Czesc[C] := Czesci[0].Czesc[C+1]; + + // increase sentence length by 1 + SetLength(Czesci[0].Czesc, Length(Czesci[0].Czesc) - 1); + Dec(Czesci[0].Ilosc); + Dec(Czesci[0].High); +end; + +procedure TScreenEditSub.DivideNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Czesci[0].Akt; + + NLen := Czesci[0].Czesc[C].IlNut + 1; + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Inc(Czesci[0].Czesc[C].HighNut); + Inc(Czesci[0].Czesc[C].IlNut); + + // we copy all notes including selected one + for N := Czesci[0].Czesc[C].HighNut downto AktNuta+1 do begin + Czesci[0].Czesc[C].Nuta[N] := Czesci[0].Czesc[C].Nuta[N-1]; + end; + + // me slightly modify new note + Czesci[0].Czesc[C].Nuta[AktNuta].Dlugosc := 1; + Inc(Czesci[0].Czesc[C].Nuta[AktNuta+1].Start); + Dec(Czesci[0].Czesc[C].Nuta[AktNuta+1].Dlugosc); + Czesci[0].Czesc[C].Nuta[AktNuta+1].Tekst := '- '; + Czesci[0].Czesc[C].Nuta[AktNuta+1].Color := 0; +end; + +procedure TScreenEditSub.DeleteNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Czesci[0].Akt; + + //Do Not delete Last Note + if (Czesci[0].High > 0) OR (Czesci[0].Czesc[C].HighNut > 0) then + begin + + // we copy all notes from the next to the selected one + for N := AktNuta+1 to Czesci[0].Czesc[C].HighNut do begin + Czesci[0].Czesc[C].Nuta[N-1] := Czesci[0].Czesc[C].Nuta[N]; + end; + + NLen := Czesci[0].Czesc[C].IlNut - 1; + + if (NLen > 0) then + begin + SetLength(Czesci[0].Czesc[C].Nuta, NLen); + Dec(Czesci[0].Czesc[C].HighNut); + Dec(Czesci[0].Czesc[C].IlNut); + + + // me slightly modify new note + if AktNuta > Czesci[0].Czesc[C].HighNut then Dec(AktNuta); + Czesci[0].Czesc[C].Nuta[AktNuta].Color := 1; + end + //Last Note of current Sentence Deleted - > Delete Sentence + else + begin + //Move all Sentences after the current to the Left + for N := C+1 to Czesci[0].High do + Czesci[0].Czesc[N-1] := Czesci[0].Czesc[N]; + + //Delete Last Sentence + SetLength(Czesci[0].Czesc, Czesci[0].High); + Czesci[0].High := High(Czesci[0].Czesc); + Czesci[0].Ilosc := Length(Czesci[0].Czesc); + + AktNuta := 0; + if (C > 0) then + Czesci[0].Akt := C - 1 + else + Czesci[0].Akt := 0; + + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Color := 1; + end; + end; +end; + +procedure TScreenEditSub.TransposeNote(Transpose: integer); +begin + Inc(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton, Transpose); +end; + +procedure TScreenEditSub.ChangeWholeTone(Tone: integer); +var + C: integer; + N: integer; +begin + for C := 0 to Czesci[0].High do begin + Czesci[0].Czesc[C].BaseNote := Czesci[0].Czesc[C].BaseNote + Tone; + for N := 0 to Czesci[0].Czesc[C].HighNut do + Czesci[0].Czesc[C].Nuta[N].Ton := Czesci[0].Czesc[C].Nuta[N].Ton + Tone; + end; +end; + +procedure TScreenEditSub.MoveAllToEnd(Move: integer); +var + C: integer; + N: integer; + NStart: integer; +begin + for C := Czesci[0].Akt to Czesci[0].High do begin + NStart := 0; + if C = Czesci[0].Akt then NStart := AktNuta; + for N := NStart to Czesci[0].Czesc[C].HighNut do begin + Inc(Czesci[0].Czesc[C].Nuta[N].Start, Move); // move note start + + if N = 0 then begin // fix beginning + Inc(Czesci[0].Czesc[C].Start, Move); + Inc(Czesci[0].Czesc[C].StartNote, Move); + end; + + if N = Czesci[0].Czesc[C].HighNut then // fix ending + Inc(Czesci[0].Czesc[C].Koniec, Move); + + end; // for + end; // for +end; + +procedure TScreenEditSub.MoveTextToRight; +var + C: integer; + N: integer; + NHigh: integer; +begin +{ C := Czesci[0].Akt; + + for N := Czesci[0].Czesc[C].HighNut downto 1 do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; + end; // for + + Czesci[0].Czesc[C].Nuta[0].Tekst := '- ';} + + C := Czesci[0].Akt; + NHigh := Czesci[0].Czesc[C].HighNut; + + // last word + Czesci[0].Czesc[C].Nuta[NHigh].Tekst := Czesci[0].Czesc[C].Nuta[NHigh-1].Tekst + Czesci[0].Czesc[C].Nuta[NHigh].Tekst; + + // other words + for N := NHigh - 1 downto AktNuta + 1 do begin + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[C].Nuta[N-1].Tekst; + end; // for + Czesci[0].Czesc[C].Nuta[AktNuta].Tekst := '- '; +end; + +procedure TScreenEditSub.MarkSrc; +begin + CopySrc := Czesci[0].Akt; +end; + +procedure TScreenEditSub.PasteText; +var + C: integer; + N: integer; +begin + C := Czesci[0].Akt; + + for N := 0 to Czesci[0].Czesc[CopySrc].HighNut do + Czesci[0].Czesc[C].Nuta[N].Tekst := Czesci[0].Czesc[CopySrc].Nuta[N].Tekst; +end; + +procedure TScreenEditSub.CopySentence(Src, Dst: integer); +var + N: integer; + Time1: integer; + Time2: integer; + TD: integer; +begin + Time1 := Czesci[0].Czesc[Src].Nuta[0].Start; + Time2 := Czesci[0].Czesc[Dst].Nuta[0].Start; + TD := Time2-Time1; + + SetLength(Czesci[0].Czesc[Dst].Nuta, Czesci[0].Czesc[Src].IlNut); + Czesci[0].Czesc[Dst].IlNut := Czesci[0].Czesc[Src].IlNut; + Czesci[0].Czesc[Dst].HighNut := Czesci[0].Czesc[Src].HighNut; + for N := 0 to Czesci[0].Czesc[Src].HighNut do begin + Czesci[0].Czesc[Dst].Nuta[N].Tekst := Czesci[0].Czesc[Src].Nuta[N].Tekst; + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc := Czesci[0].Czesc[Src].Nuta[N].Dlugosc; + Czesci[0].Czesc[Dst].Nuta[N].Ton := Czesci[0].Czesc[Src].Nuta[N].Ton; + Czesci[0].Czesc[Dst].Nuta[N].Start := Czesci[0].Czesc[Src].Nuta[N].Start + TD; + end; + N := Czesci[0].Czesc[Src].HighNut; + Czesci[0].Czesc[Dst].Koniec := Czesci[0].Czesc[Dst].Nuta[N].Start + Czesci[0].Czesc[Dst].Nuta[N].Dlugosc; +end; + +procedure TScreenEditSub.CopySentences(Src, Dst, Num: integer); +var + C: integer; +begin + Lyric := TLyric.Create; + // create place for new sentences + SetLength(Czesci[0].Czesc, Czesci[0].Ilosc + Num - 1); + + // moves sentences next to the destination + for C := Czesci[0].High downto Dst + 1 do begin + Czesci[0].Czesc[C + Num - 1] := Czesci[0].Czesc[C]; + end; + + // prepares new sentences: sets sentence start and create first note + for C := 1 to Num-1 do begin + Czesci[0].Czesc[Dst + C].Start := Czesci[0].Czesc[Dst + C - 1].StartNote + + (Czesci[0].Czesc[Src + C].StartNote - Czesci[0].Czesc[Src + C - 1].StartNote); + SetLength(Czesci[0].Czesc[Dst + C].Nuta, 1); + Czesci[0].Czesc[Dst + C].IlNut := 1; + Czesci[0].Czesc[Dst + C].HighNut := 0; + Czesci[0].Czesc[Dst + C].Nuta[0].Start := Czesci[0].Czesc[Dst + C].Start; + Czesci[0].Czesc[Dst + C].Nuta[0].Dlugosc := 1; + Czesci[0].Czesc[Dst + C].StartNote := Czesci[0].Czesc[Dst + C].Start; + Czesci[0].Czesc[Dst + C].Koniec := Czesci[0].Czesc[Dst + C].Start + 1; + end; + + // increase counters + Czesci[0].Ilosc := Czesci[0].Ilosc + Num - 1; + Czesci[0].High := Czesci[0].High + Num - 1; + + for C := 0 to Num-1 do + CopySentence(Src + C, Dst + C); +end; + + +constructor TScreenEditSub.Create; +begin + inherited Create; + SetLength(Player, 1); + + // linijka + AddStatic(20, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); + AddText(40, 17, 1, 6, 1, 1, 1, 'Line'); + TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // nuta + AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), 'JPG', 'Font Black'); + AddText(242, 17, 1, 6, 1, 1, 1, 'Note'); + TextNote := AddText(320, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // file info + AddStatic(150, 50, 500, 150, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black'); + AddText(180, 65, 0, 8, 0, 0, 0, 'Title:'); + AddText(180, 90, 0, 8, 0, 0, 0, 'Artist:'); + AddText(180, 115, 0, 8, 0, 0, 0, 'Mp3:'); + AddText(180, 140, 0, 8, 0, 0, 0, 'BPM:'); + AddText(180, 165, 0, 8, 0, 0, 0, 'GAP:'); + + TextTitle := AddText(250, 65, 0, 8, 0, 0, 0, 'a'); + TextArtist := AddText(250, 90, 0, 8, 0, 0, 0, 'b'); + TextMp3 := AddText(250, 115, 0, 8, 0, 0, 0, 'c'); + TextBPM := AddText(250, 140, 0, 8, 0, 0, 0, 'd'); + TextGAP := AddText(250, 165, 0, 8, 0, 0, 0, 'e'); + +{ AddInteraction(2, TextTitle); + AddInteraction(2, TextArtist); + AddInteraction(2, TextMp3); + AddInteraction(2, TextBPM); + AddInteraction(2, TextGAP);} + + // note info + AddText(20, 190, 0, 8, 0, 0, 0, 'Start:'); + AddText(20, 215, 0, 8, 0, 0, 0, 'Duration:'); + AddText(20, 240, 0, 8, 0, 0, 0, 'Tone:'); + AddText(20, 265, 0, 8, 0, 0, 0, 'Text:'); + + TextNStart := AddText(120, 190, 0, 8, 0, 0, 0, 'a'); + TextNDlugosc := AddText(120, 215, 0, 8, 0, 0, 0, 'b'); + TextNTon := AddText(120, 240, 0, 8, 0, 0, 0, 'c'); + TextNText := AddText(120, 265, 0, 8, 0, 0, 0, 'd'); + + // debug + TextDebug := AddText(30, 550, 0, 8, 0, 0, 0, ''); + +end; + +procedure TScreenEditSub.onShow; +begin + Log.LogStatus('Initializing', 'TEditScreen.onShow'); + + try + ResetSingTemp; + Error := not LoadSong(Path + FileName); + except + Error := True; + end; + + if Error then + begin + //Error Loading Song -> Go back to Song Screen and Show some Error Message + FadeTo(@ScreenSong); + ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); + Exit; + end + else begin + {$IFDEF UseMIDIPort} + MidiOut := TMidiOutput.Create(nil); + if Ini.Debug = 1 then + MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table + MidiOut.Open; + {$ENDIF} + Text[TextTitle].Text := AktSong.Title; + Text[TextArtist].Text := AktSong.Artist; + Text[TextMp3].Text := AktSong.Mp3; + + Czesci[0].Akt := 0; + AktNuta := 0; + Czesci[0].Czesc[0].Nuta[0].Color := 1; + + AudioPlayback.Open(Path + AktSong.Mp3); + //Set Down Music Volume for Better hearability of Midi Sounds + //Music.SetVolume(40); + + Lyric.Clear; + Lyric.X := 400; + Lyric.Y := 500; + Lyric.Align := 1; + Lyric.Size := 14; + Lyric.ColR := 0; + Lyric.ColG := 0; + Lyric.ColB := 0; + Lyric.ColSR := Skin_FontHighlightR; + Lyric.ColSG := Skin_FontHighlightG; + Lyric.ColSB := Skin_FontHighlightB; + Lyric.Style := 0; + Lyric.AddCzesc(0); + Lyric.Selected := 0; + + NotesH := 7; + NotesW := 4; + + end; + +// Interaction := 0; + TextEditMode := false; +end; + +function TScreenEditSub.Draw: boolean; +var + Min: integer; + Sec: integer; + Tekst: string; + Pet: integer; + AktBeat: integer; +begin + glClearColor(1,1,1,1); + + // midi music + if PlaySentenceMidi then begin + MidiPos := USTime.GetTime - MidiTime + MidiStart; + + {$IFDEF UseMIDIPort} + // stop the music + if (MidiPos > MidiStop) then begin + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[MidiLastNote].Ton + 60, 127); + PlaySentenceMidi := false; + end; + {$ENDIF} + + // click + AktBeat := Floor(GetMidBeat(MidiPos - AktSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then + begin + + {$IFDEF UseMIDIPort} + LastClick := AktBeat; + if Pet > 0 then + MidiOut.PutShort($81, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet-1].Ton + 60, 127); + MidiOut.PutShort($91, Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Ton + 60, 127); + MidiLastNote := Pet; + {$ENDIF} + + end; + end; + end; // if PlaySentenceMidi + + // mp3 music + if PlaySentence then begin + // stop the music + if (AudioPlayback.Position > PlayStopTime) then + begin + AudioPlayback.Stop; + PlaySentence := false; + end; + + // click + if (Click) and (PlaySentence) then begin +// AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); + AktBeat := Floor(GetMidBeat(AudioPlayback.Position - AktSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + if AktBeat <> LastClick then begin + for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do + if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then + begin + AudioPlayback.PlayClick; + LastClick := AktBeat; + end; + end; + end; // click + end; // if PlaySentence + + + Text[TextSentence].Text := IntToStr(Czesci[0].Akt + 1) + ' / ' + IntToStr(Czesci[0].Ilosc); + Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); + + // Song info + Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); + Text[TextGAP].Text := FloatToStr(AktSong.GAP); + + //Error reading Variables when no Song is loaded + if not Error then + begin + // Note info + Text[TextNStart].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); + Text[TextNDlugosc].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc); + Text[TextNTon].Text := IntToStr(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' ( ' + GetNoteName(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Ton) + ' )'; + Text[TextNText].Text := Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Tekst; + end; + + // Text Edit Mode + if TextEditMode then + Text[TextNText].Text := Text[TextNText].Text + '|'; + + // draw static menu + inherited Draw; + + // draw notes + SingDrawNoteLines(20, 300, 780, 15); + //Error Drawing when no Song is loaded + if not Error then + begin + SingDrawBeatDelimeters(40, 300, 760, 0); + EditDrawCzesc(40, 405, 760, 0, 15); + end; + + // draw text + Lyric.Draw; + +end; + +procedure TScreenEditSub.onHide; +begin + {$IFDEF UseMIDIPort} + MidiOut.Close; + MidiOut.Free; + {$ENDIF} + //Music.SetVolume(100); +end; + +function TScreenEditSub.GetNoteName(Note: Integer): String; +var N1, N2: Integer; +begin + if (Note > 0) then + begin + N1 := Note mod 12; + N2 := Note div 12; + end + else + begin + N1 := (Note + (-Trunc(Note/12)+1)*12) mod 12; + N2 := -1; + end; + + + + case N1 of + 0: Result := 'c'; + 1: Result := 'c#'; + 2: Result := 'd'; + 3: Result := 'd#'; + 4: Result := 'e'; + 5: Result := 'f'; + 6: Result := 'f#'; + 7: Result := 'g'; + 8: Result := 'g#'; + 9: Result := 'a'; + 10: Result := 'b'; + 11: Result := 'h'; + end; + + case N2 of + 0: Result := UpperCase(Result); //Normal Uppercase Note, 1: Normal lowercase Note + 2: Result := Result + ''''; //One Striped + 3: Result := Result + ''''''; //Two Striped + 4: Result := Result + ''''''''; //etc. + 5: Result := Result + ''''''''''; + 6: Result := Result + ''''''''''''; + 7: Result := Result + ''''''''''''''; + end; +end; + +end. -- cgit v1.2.3 From bc01e7c70cf07c9758e09b07af5f788a45297eee Mon Sep 17 00:00:00 2001 From: tobigun Date: Fri, 11 Jan 2008 12:41:51 +0000 Subject: Cleanup: Use the property Position in favor of MoveTo() (MoveTo() will be SetPosition() soon) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@784 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 6dcb1f5f..725dd4e9 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -322,7 +322,7 @@ begin AudioPlayback.Stop; R := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote); if R <= AudioPlayback.Length then begin - AudioPlayback.MoveTo(R); + AudioPlayback.Position := R; PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec); PlaySentence := true; AudioPlayback.Play; @@ -349,7 +349,7 @@ begin PlaySentence := true; Click := true; AudioPlayback.Stop; - AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}); + AudioPlayback.Position := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].StartNote)+0{-0.10}; PlayStopTime := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Koniec)+0; AudioPlayback.Play; LastClick := -100; @@ -363,7 +363,7 @@ begin PlaySentence := true; Click := false; AudioPlayback.Stop; - AudioPlayback.MoveTo(GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start)); + AudioPlayback.Position := GetTimeFromBeat(Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start); PlayStopTime := (GetTimeFromBeat( Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Start + Czesci[0].Czesc[Czesci[0].Akt].Nuta[AktNuta].Dlugosc)); -- cgit v1.2.3 From e74bd57c12f470257111c1c0530fb38f0fd34414 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 12 Jan 2008 12:31:43 +0000 Subject: bunch of smaller changes... some changes to song loading... Record global changed to singleton object started implementing mic volume display in Settings-Record hope this dosnt break anything.. :P git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@789 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 51 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 725dd4e9..57d6777e 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -15,6 +15,7 @@ uses UFiles, UTime, USongs, + USong, UIni, ULog, UTexture, @@ -143,40 +144,40 @@ begin begin // Increase BPM if SDL_ModState = 0 then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) if SDL_ModState = KMOD_LSHIFT then - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM + 4; // (1/1) + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM + 4; // (1/1) if SDL_ModState = KMOD_LCTRL then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) + 1) / 25; // (1/100) + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 25) + 1) / 25; // (1/100) end; SDLK_MINUS: begin // Decrease BPM if SDL_ModState = 0 then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 5) - 1) / 5; + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 5) - 1) / 5; if SDL_ModState = KMOD_LSHIFT then - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM - 4; + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM - 4; if SDL_ModState = KMOD_LCTRL then - AktSong.BPM[0].BPM := Round((AktSong.BPM[0].BPM * 25) - 1) / 25; + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 25) - 1) / 25; end; SDLK_0: begin // Increase GAP if SDL_ModState = 0 then - AktSong.GAP := AktSong.GAP + 10; + CurrentSong.GAP := CurrentSong.GAP + 10; if SDL_ModState = KMOD_LSHIFT then - AktSong.GAP := AktSong.GAP + 1000; + CurrentSong.GAP := CurrentSong.GAP + 1000; end; SDLK_9: begin // Decrease GAP if SDL_ModState = 0 then - AktSong.GAP := AktSong.GAP - 10; + CurrentSong.GAP := CurrentSong.GAP - 10; if SDL_ModState = KMOD_LSHIFT then - AktSong.GAP := AktSong.GAP - 1000; + CurrentSong.GAP := CurrentSong.GAP - 1000; end; SDLK_KP_PLUS: @@ -222,13 +223,13 @@ begin begin // Save Song if SDL_ModState = KMOD_LSHIFT then - SaveSong(AktSong, Czesci[0], Path + FileName, true) + SaveSong(CurrentSong, Czesci[0], Path + FileName, true) else - SaveSong(AktSong, Czesci[0], Path + FileName, false); + SaveSong(CurrentSong, Czesci[0], Path + FileName, false); {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then // Save Song - SaveSongDebug(AktSong, Czesci[0], 'C:\song.asm', false);} + SaveSongDebug(CurrentSong, Czesci[0], 'C:\song.asm', false);} end; @@ -656,7 +657,7 @@ var C: integer; N: integer; begin - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM / 2; + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM / 2; for C := 0 to Czesci[0].High do begin Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start div 2; Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote div 2; @@ -673,7 +674,7 @@ var C: integer; N: integer; begin - AktSong.BPM[0].BPM := AktSong.BPM[0].BPM * 2; + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM * 2; for C := 0 to Czesci[0].High do begin Czesci[0].Czesc[C].Start := Czesci[0].Czesc[C].Start * 2; Czesci[0].Czesc[C].StartNote := Czesci[0].Czesc[C].StartNote * 2; @@ -1160,7 +1161,7 @@ begin try ResetSingTemp; - Error := not LoadSong(Path + FileName); +// Error := not LoadSong(Path + FileName); // todo - JB come back to this except Error := True; end; @@ -1179,15 +1180,15 @@ begin MidiOut.ProductName := 'Microsoft GS Wavetable SW Synth'; // for my kxproject without midi table MidiOut.Open; {$ENDIF} - Text[TextTitle].Text := AktSong.Title; - Text[TextArtist].Text := AktSong.Artist; - Text[TextMp3].Text := AktSong.Mp3; + Text[TextTitle].Text := CurrentSong.Title; + Text[TextArtist].Text := CurrentSong.Artist; + Text[TextMp3].Text := CurrentSong.Mp3; Czesci[0].Akt := 0; AktNuta := 0; Czesci[0].Czesc[0].Nuta[0].Color := 1; - AudioPlayback.Open(Path + AktSong.Mp3); + AudioPlayback.Open(Path + CurrentSong.Mp3); //Set Down Music Volume for Better hearability of Midi Sounds //Music.SetVolume(40); @@ -1238,7 +1239,7 @@ begin {$ENDIF} // click - AktBeat := Floor(GetMidBeat(MidiPos - AktSong.GAP / 1000)); + AktBeat := Floor(GetMidBeat(MidiPos - CurrentSong.GAP / 1000)); Text[TextDebug].Text := IntToStr(AktBeat); if AktBeat <> LastClick then begin @@ -1269,8 +1270,8 @@ begin // click if (Click) and (PlaySentence) then begin -// AktBeat := Floor(AktSong.BPM[0].BPM * (Music.Position - AktSong.GAP / 1000) / 60); - AktBeat := Floor(GetMidBeat(AudioPlayback.Position - AktSong.GAP / 1000)); +// AktBeat := Floor(CurrentSong.BPM[0].BPM * (Music.Position - CurrentSong.GAP / 1000) / 60); + AktBeat := Floor(GetMidBeat(AudioPlayback.Position - CurrentSong.GAP / 1000)); Text[TextDebug].Text := IntToStr(AktBeat); if AktBeat <> LastClick then begin for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do @@ -1288,8 +1289,8 @@ begin Text[TextNote].Text := IntToStr(AktNuta + 1) + ' / ' + IntToStr(Czesci[0].Czesc[Czesci[0].Akt].IlNut); // Song info - Text[TextBPM].Text := FloatToStr(AktSong.BPM[0].BPM / 4); - Text[TextGAP].Text := FloatToStr(AktSong.GAP); + Text[TextBPM].Text := FloatToStr(CurrentSong.BPM[0].BPM / 4); + Text[TextGAP].Text := FloatToStr(CurrentSong.GAP); //Error reading Variables when no Song is loaded if not Error then -- cgit v1.2.3 From dee94f5dae9e6b5ae6c7b54a12a567745abc8dc3 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 20:36:19 +0000 Subject: General: - cleanup and adaption of SingDrawOscilloscope Portaudio/SDL audio output: - stuttering in portaudio output has been fixed (SDL_MixBuffers cannot be used without initializing the SDL audio stuff first, so it is not usable with portaudio. Now SDL is used for audio-output instead of portaudio (although the file-name is UAudioPlayback_Portaudio.pas at the moment). - cleaner file closing - volume adjustment UMusic: - cleanup of the audio-interfaces - introduced TNoteType = (ntFreestyle, ntNormal, ntGolden) - some bug-fixes - introduced TSoundLibrary. This is library for all in-game sounds used by USDX. Instead of calling AudioPlayer.PlaySwoosh you should call AudioPlayer.PlaySound(SoundLib.Swoosh) now. You might call SoundLib.Swoosh.Play too, but this is not recommended at the moment because SoundLib.Swoosh could be nil if the file was not found. The SoundLibrary approach is much cleaner than the previous one. The AudioPlayer does not have to specify a Play... and Stop... method for every available sound anymore. In addition it is not an AudioPlayers responsibility to init the in-game sounds. URecord: - polish to english translation of some variables - CaptureSoundLeft/Right is CaptureChannel[0/1] now - TSoundCardInput -> TAudioInputDeviceSource - TGenericSoundCard.Input -> TGenericSoundCard.Source - autocorrelation algorithm more readable now - Clean-up of the audio-input interface - moved cloned code of the input-classes to one base class (TAudioInputBase) - Cleaner finalization - Start-/StopCapture will not crash anymore in the recording-options menu - Fixed several bugs in the autocorrelation stuff (e.g. wrong usage of $10000) - SzczytJest (now ToneValid) was not used correctly. ToneValid is set to true if a valid tone was found (= the sound was louder than the threshold -> no background noise). If i remember correctly the sound was accepted although the tone was invalid. So the old data was used although noone was singing. This resulted in some sort of ghost-singer effect. UIni: - moved TIni.Card to TScreenOptionsRecord.Card because it is not stored in the ini-file and will not be in the future. - TIni.CardList ist now TIni.InputDeviceConfig. The name cardlist was misleading because it just specifies input- but no output-devices. In addition a soundcard can have multiple input-devices (at least in linux). - bugfix on InputDeviceConfig (formerly CardList) usage. USDX expected that the indices of the corresponding elements in TIni.InputDeviceConfig[] and TAudioInputProcessor.Device[] were the same. This is wrong. If device 2 was defined at first place in the ini and device 1 at the second, the indices of the two arrays didn't match (they were swapped) erroneously. To fix this and to support the item listed below the index to TIni.InputDeviceConfig[] is now stored in TAudioInputDevice.CfgIndex. NOTE: InputDeviceConfig[] contains configurations of non-available (unplugged) devices. Iterate over TAudioInputProcessor.Device[] for available devices. - configurations of external devices that are not plugged in will not be deleted anymore. - multiple definitions of one device in the ini-file will not crash USDX anymore - CardList[I].ChannelL/R now are InputDeviceConfig[I].ChannelToPlayerMap[0/1]. I think the new name is more intuitive because it maps a channel to a player number. Now the both vars are joint to one array. Now it is possible to use loops to process them and we might support more than two input channels on one device in the future (if such devices exist) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@827 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 57d6777e..4d971c63 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -1277,7 +1277,7 @@ begin for Pet := 0 to Czesci[0].Czesc[Czesci[0].Akt].HighNut do if (Czesci[0].Czesc[Czesci[0].Akt].Nuta[Pet].Start = AktBeat) then begin - AudioPlayback.PlayClick; + AudioPlayback.PlaySound(SoundLib.Click); LastClick := AktBeat; end; end; -- cgit v1.2.3 From b4371d97f409af8ab9dc942c39f143ae400854da Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 21:43:57 +0000 Subject: bugfix to get the editor working again. Path and FileName have not been set. In addtion LoadSong was not used to actually load the song. Jay or some other dev: please revise the changes. The Lyric var is not set too, so it crashes on Lyric.Clear in TScreenEditSub.onShow. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@829 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenEditSub.pas | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Game/Code/Screens/UScreenEditSub.pas') diff --git a/Game/Code/Screens/UScreenEditSub.pas b/Game/Code/Screens/UScreenEditSub.pas index 4d971c63..60e27245 100644 --- a/Game/Code/Screens/UScreenEditSub.pas +++ b/Game/Code/Screens/UScreenEditSub.pas @@ -89,8 +89,6 @@ type public Tex_Background: TTexture; FadeOut: boolean; - Path: string; - FileName: string; constructor Create; override; procedure onShow; override; function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; @@ -223,9 +221,9 @@ begin begin // Save Song if SDL_ModState = KMOD_LSHIFT then - SaveSong(CurrentSong, Czesci[0], Path + FileName, true) + SaveSong(CurrentSong, Czesci[0], CurrentSong.Path + CurrentSong.FileName, true) else - SaveSong(CurrentSong, Czesci[0], Path + FileName, false); + SaveSong(CurrentSong, Czesci[0], CurrentSong.Path + CurrentSong.FileName, false); {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then // Save Song @@ -1159,9 +1157,10 @@ procedure TScreenEditSub.onShow; begin Log.LogStatus('Initializing', 'TEditScreen.onShow'); + ResetSingTemp; + try - ResetSingTemp; -// Error := not LoadSong(Path + FileName); // todo - JB come back to this + Error := not CurrentSong.LoadSong(); except Error := True; end; @@ -1188,7 +1187,7 @@ begin AktNuta := 0; Czesci[0].Czesc[0].Nuta[0].Color := 1; - AudioPlayback.Open(Path + CurrentSong.Mp3); + AudioPlayback.Open(CurrentSong.Path + CurrentSong.Mp3); //Set Down Music Volume for Better hearability of Midi Sounds //Music.SetVolume(40); -- cgit v1.2.3