From 873f177f08dc7c4fe2d7e50bbe7709df98e238d3 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Wed, 27 Aug 2008 14:58:32 +0000 Subject: rename Screen part2 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1306 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 1368 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1368 insertions(+) create mode 100644 src/screens/UScreenEditSub.pas (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas new file mode 100644 index 00000000..2d98f6bc --- /dev/null +++ b/src/screens/UScreenEditSub.pas @@ -0,0 +1,1368 @@ +unit UScreenEditSub; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} +{$I switches.inc} + +uses + UMenu, + UMusic, + SDL, + SysUtils, + UFiles, + UTime, + USongs, + USong, + UIni, + ULog, + UTexture, + UMenuText, + UEditorLyrics, + Math, + gl, + {$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; + TextNLength: integer; + TextNTon: integer; + TextNText: integer; + CurrentNote: 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; + + Lyric: TEditorLyrics; + + procedure NewBeat; + procedure DivideBPM; + procedure MultiplyBPM; + 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; + constructor Create; override; + procedure onShow; override; + function ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; override; + function ParseInputEditText(PressedKey: Cardinal; CharCode: WideChar; 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; CharCode: WideChar; PressedDown: Boolean): Boolean; +var + SDL_ModState: Word; + R: real; +begin + Result := true; + + if TextEditMode then begin + Result := ParseInputEditText(PressedKey, CharCode, 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 + // check normal keys + case WideCharUpperCase(CharCode)[1] of + 'Q': + begin + Result := false; + Exit; + end; + 'S': + begin + // Save Song + if SDL_ModState = KMOD_LSHIFT then + SaveSong(CurrentSong, Lines[0], CurrentSong.Path + CurrentSong.FileName, true) + else + SaveSong(CurrentSong, Lines[0], CurrentSong.Path + CurrentSong.FileName, false); + + {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then + // Save Song + SaveSongDebug(CurrentSong, Lines[0], 'C:\song.asm', false);} + + Exit; + end; + 'D': + begin + // Divide lengths by 2 + DivideBPM; + Exit; + end; + 'M': + begin + // Multiply lengths by 2 + MultiplyBPM; + Exit; + end; + '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; + + Exit; + end; + 'V': + begin + // Paste text + if SDL_ModState = KMOD_LCTRL then begin + if Lines[0].Line[Lines[0].Current].HighNote >= Lines[0].Line[CopySrc].HighNote then + PasteText + else + Log.LogStatus('PasteText: invalid range', 'TScreenEditSub.ParseInput'); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Lines[0].Current); + end; + end; + 'T': + begin + // Fixes timings between sentences + FixTimings; + Exit; + end; + 'P': + begin + if SDL_ModState = 0 then + begin + // Play Sentence + Click := true; + AudioPlayback.Stop; + R := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[0].Start); + if R <= AudioPlayback.Length then + begin + AudioPlayback.Position := R; + PlayStopTime := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].End_); + PlaySentence := true; + AudioPlayback.Play; + LastClick := -100; + end; + end + else if SDL_ModState = KMOD_LSHIFT then + begin + PlaySentenceMidi := true; + + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[0].Start); + MidiStop := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].End_); + + LastClick := -100; + end + else if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL then + begin + PlaySentenceMidi := true; + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[0].Start); + MidiStop := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].End_); + LastClick := -100; + + PlaySentence := true; + Click := true; + AudioPlayback.Stop; + AudioPlayback.Position := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[0].Start)+0{-0.10}; + PlayStopTime := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].End_)+0; + AudioPlayback.Play; + LastClick := -100; + end; + Exit; + end; + + // Golden Note Patch + 'G': + begin + if (Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType = ntGolden) then + Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal + else + Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntGolden; + + Exit; + end; + + // Freestyle Note Patch + 'F': + begin + if (Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType = ntFreestyle) then + Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal + else + Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntFreestyle; + + Exit; + end; + end; + + // check special keys + case PressedKey of + SDLK_ESCAPE, + SDLK_BACKSPACE : + begin + FadeTo(@ScreenSong); + end; + + SDLK_BACKQUOTE: + begin + // Increase Note Length (same as Alt + Right) + Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then + Inc(Lines[0].Line[Lines[0].Current].End_); + end; + + SDLK_EQUALS: + begin + // Increase BPM + if SDL_ModState = 0 then + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 5) + 1) / 5; // (1/20) + if SDL_ModState = KMOD_LSHIFT then + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM + 4; // (1/1) + if SDL_ModState = KMOD_LCTRL then + 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 + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 5) - 1) / 5; + if SDL_ModState = KMOD_LSHIFT then + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM - 4; + if SDL_ModState = KMOD_LCTRL then + CurrentSong.BPM[0].BPM := Round((CurrentSong.BPM[0].BPM * 25) - 1) / 25; + end; + + SDLK_4: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Lines[0].Current); + CopySentence(CopySrc+1, Lines[0].Current+1); + CopySentence(CopySrc+2, Lines[0].Current+2); + CopySentence(CopySrc+3, Lines[0].Current+3); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Lines[0].Current, 4); + end; + end; + SDLK_5: + begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + CopySentence(CopySrc, Lines[0].Current); + CopySentence(CopySrc+1, Lines[0].Current+1); + CopySentence(CopySrc+2, Lines[0].Current+2); + CopySentence(CopySrc+3, Lines[0].Current+3); + CopySentence(CopySrc+4, Lines[0].Current+4); + end; + + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + CopySentences(CopySrc, Lines[0].Current, 5); + end; + end; + + SDLK_9: + begin + // Decrease GAP + if SDL_ModState = 0 then + CurrentSong.GAP := CurrentSong.GAP - 10; + if SDL_ModState = KMOD_LSHIFT then + CurrentSong.GAP := CurrentSong.GAP - 1000; + end; + SDLK_0: + begin + // Increase GAP + if SDL_ModState = 0 then + CurrentSong.GAP := CurrentSong.GAP + 10; + if SDL_ModState = KMOD_LSHIFT then + CurrentSong.GAP := CurrentSong.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 CurrentNote > 0 then + DivideSentence; + end; + + if SDL_ModState = KMOD_LSHIFT then begin + // Join next sentence with current + if Lines[0].Current < Lines[0].High then + JoinSentence; + end; + + if SDL_ModState = KMOD_LCTRL then begin + // divide note + DivideNote; + end; + + end; + + SDLK_F4: + begin + // Enter Text Edit Mode + TextEditMode := true; + end; + + SDLK_SPACE: + begin + // Play Sentence + PlaySentenceMidi := false; // stop midi + PlaySentence := true; + Click := false; + AudioPlayback.Stop; + AudioPlayback.Position := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + PlayStopTime := (GetTimeFromBeat( + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length)); + 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 + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Inc(CurrentNote); + if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then CurrentNote := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lyric.Selected := CurrentNote; + end; + + // ctrl + right + if SDL_ModState = KMOD_LCTRL then begin + if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then begin + Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + if CurrentNote = 0 then begin + Inc(Lines[0].Line[Lines[0].Current].Start); + end; + end; + end; + + // shift + right + if SDL_ModState = KMOD_LSHIFT then begin + Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + if CurrentNote = 0 then begin + Inc(Lines[0].Line[Lines[0].Current].Start); + end; + if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then + Inc(Lines[0].Line[Lines[0].Current].End_); + end; + + // alt + right + if SDL_ModState = KMOD_LALT then begin + Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then + Inc(Lines[0].Line[Lines[0].Current].End_); + 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 + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Dec(CurrentNote); + if CurrentNote = -1 then CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lyric.Selected := CurrentNote; + end; + + // ctrl + left + if SDL_ModState = KMOD_LCTRL then begin + Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + if CurrentNote = 0 then begin + Dec(Lines[0].Line[Lines[0].Current].Start); + end; + end; + + // shift + left + if SDL_ModState = KMOD_LSHIFT then begin + Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + + // resizing sentences + if CurrentNote = 0 then begin + Dec(Lines[0].Line[Lines[0].Current].Start); + end; + + if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then + Dec(Lines[0].Line[Lines[0].Current].End_); + + end; + + // alt + left + if SDL_ModState = KMOD_LALT then begin + if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then begin + Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then + Dec(Lines[0].Line[Lines[0].Current].End_); + 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 {$IFDEF UseMIDIPort} + MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); + PlaySentenceMidi := false; + {$endif} + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Inc(Lines[0].Current); + CurrentNote := 0; + if Lines[0].Current > Lines[0].High then Lines[0].Current := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := 0; + AudioPlayback.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 + {$IFDEF UseMIDIPort} + MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); + PlaySentenceMidi := false; + {$endif} + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Dec(Lines[0].Current); + CurrentNote := 0; + if Lines[0].Current = -1 then Lines[0].Current := Lines[0].High; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := 0; + AudioPlayback.Stop; + PlaySentence := false; + end; + + // increase tone + if SDL_ModState = KMOD_LCTRL then begin + TransposeNote(1); + end; + end; + + end; // case + end; + end; // if +end; + +function TScreenEditSub.ParseInputEditText(PressedKey: Cardinal; CharCode: WideChar; 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 + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text := + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text + CharCode; + end; + SDLK_BACKSPACE: + begin + Delete(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text, + Length(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text), 1); + end; + SDLK_RIGHT: + begin + // right + if SDL_ModState = 0 then begin + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Inc(CurrentNote); + if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then CurrentNote := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lyric.Selected := CurrentNote; + end; + end; + SDLK_LEFT: + begin + // left + if SDL_ModState = 0 then begin + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Dec(CurrentNote); + if CurrentNote = -1 then CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lyric.Selected := CurrentNote; + end; + end; + end; + end; +end; + +procedure TScreenEditSub.NewBeat; +begin + // click +{ for Pet := 0 to Lines[0].Line[Lines[0].Current].HighNut do + if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = Czas.AktBeat) then begin + // old} +// Music.PlayClick; +end; + +procedure TScreenEditSub.DivideBPM; +var + C: integer; + N: integer; +begin + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM / 2; + for C := 0 to Lines[0].High do begin + Lines[0].Line[C].Start := Lines[0].Line[C].Start div 2; + Lines[0].Line[C].End_ := Lines[0].Line[C].End_ div 2; + for N := 0 to Lines[0].Line[C].HighNote do begin + Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start div 2; + Lines[0].Line[C].Note[N].Length := Round(Lines[0].Line[C].Note[N].Length / 2); + end; // N + end; // C +end; + +procedure TScreenEditSub.MultiplyBPM; +var + C: integer; + N: integer; +begin + CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM * 2; + for C := 0 to Lines[0].High do begin + Lines[0].Line[C].Start := Lines[0].Line[C].Start * 2; + Lines[0].Line[C].End_ := Lines[0].Line[C].End_ * 2; + for N := 0 to Lines[0].Line[C].HighNote do begin + Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start * 2; + Lines[0].Line[C].Note[N].Length := Lines[0].Line[C].Note[N].Length * 2; + end; // N + end; // C +end; + +procedure TScreenEditSub.LyricsCapitalize; +var + C: integer; + N: integer; // temporary + S: string; +begin + // temporary +{ for C := 0 to Lines[0].High do + for N := 0 to Lines[0].Line[C].HighNut do + Lines[0].Line[C].Note[N].Text := AnsiLowerCase(Lines[0].Line[C].Note[N].Text);} + + for C := 0 to Lines[0].High do begin + S := AnsiUpperCase(Copy(Lines[0].Line[C].Note[0].Text, 1, 1)); + S := S + Copy(Lines[0].Line[C].Note[0].Text, 2, Length(Lines[0].Line[C].Note[0].Text)-1); + Lines[0].Line[C].Note[0].Text := S; + end; // C +end; + +procedure TScreenEditSub.LyricsCorrectSpaces; +var + C: integer; + N: integer; +begin + for C := 0 to Lines[0].High do begin + // correct starting spaces in the first word + while Copy(Lines[0].Line[C].Note[0].Text, 1, 1) = ' ' do + Lines[0].Line[C].Note[0].Text := Copy(Lines[0].Line[C].Note[0].Text, 2, 100); + + // move spaces on the start to the end of the previous note + for N := 1 to Lines[0].Line[C].HighNote do begin + while (Copy(Lines[0].Line[C].Note[N].Text, 1, 1) = ' ') do begin + Lines[0].Line[C].Note[N].Text := Copy(Lines[0].Line[C].Note[N].Text, 2, 100); + Lines[0].Line[C].Note[N-1].Text := Lines[0].Line[C].Note[N-1].Text + ' '; + end; + end; // N + + // correct '-' to '- ' + for N := 0 to Lines[0].Line[C].HighNote do begin + if Lines[0].Line[C].Note[N].Text = '-' then + Lines[0].Line[C].Note[N].Text := '- '; + end; // N + + // add space to the previous note when the current word is '- ' + for N := 1 to Lines[0].Line[C].HighNote do begin + if Lines[0].Line[C].Note[N].Text = '- ' then + Lines[0].Line[C].Note[N-1].Text := Lines[0].Line[C].Note[N-1].Text + ' '; + end; // N + + // correct too many spaces at the end of note + for N := 0 to Lines[0].Line[C].HighNote do begin + while Copy(Lines[0].Line[C].Note[N].Text, Length(Lines[0].Line[C].Note[N].Text)-1, 2) = ' ' do + Lines[0].Line[C].Note[N].Text := Copy(Lines[0].Line[C].Note[N].Text, 1, Length(Lines[0].Line[C].Note[N].Text)-1); + end; // N + + // and correct if there is no space at the end of sentence + N := Lines[0].Line[C].HighNote; + if Copy(Lines[0].Line[C].Note[N].Text, Length(Lines[0].Line[C].Note[N].Text), 1) <> ' ' then + Lines[0].Line[C].Note[N].Text := Lines[0].Line[C].Note[N].Text + ' '; + + end; // C +end; + +procedure TScreenEditSub.FixTimings; +var + C: integer; + S: integer; + Min: integer; + Max: integer; +begin + for C := 1 to Lines[0].High do begin + with Lines[0].Line[C-1] do begin + Min := Note[HighNote].Start + Note[HighNote].Length; + Max := Lines[0].Line[C].Note[0].Start; + 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 + + Lines[0].Line[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; +begin + // increase sentence length by 1 + CLen := Length(Lines[0].Line); + SetLength(Lines[0].Line, CLen + 1); + Inc(Lines[0].Number); + Inc(Lines[0].High); + + // move needed sentences to one forward. newly has the copy of divided sentence + CStart := Lines[0].Current; + for C := CLen-1 downto CStart do + Lines[0].Line[C+1] := Lines[0].Line[C]; + + // clear and set new sentence + CNew := CStart + 1; + NStart := CurrentNote; + Lines[0].Line[CNew].Start := Lines[0].Line[CStart].Note[NStart].Start; + Lines[0].Line[CNew].Lyric := ''; + Lines[0].Line[CNew].LyricWidth := 0; + Lines[0].Line[CNew].End_ := 0; + Lines[0].Line[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure + Lines[0].Line[CNew].HighNote := -1; + SetLength(Lines[0].Line[CNew].Note, 0); + + // move right notes to new sentences + NHigh := Lines[0].Line[CStart].HighNote; + for N := NStart to NHigh do begin + // increase sentence counters + with Lines[0].Line[CNew] do + begin + Inc(HighNote); + SetLength(Note, HighNote + 1); + Note[HighNote] := Note[N]; + End_ := Note[HighNote].Start + Note[HighNote].Length; + + if Note[HighNote].Tone < BaseNote then + BaseNote := Note[HighNote].Tone; + end; + end; + + // clear old notes and set sentence counters + Lines[0].Line[CStart].HighNote := NStart - 1; + Lines[0].Line[CStart].End_ := Lines[0].Line[CStart].Note[NStart-1].Start + + Lines[0].Line[CStart].Note[NStart-1].Length; + SetLength(Lines[0].Line[CStart].Note, Lines[0].Line[CStart].HighNote + 1); + + Lines[0].Current := Lines[0].Current + 1; + CurrentNote := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lyric.AddLine(Lines[0].Current); +end; + +procedure TScreenEditSub.JoinSentence; +var + C: integer; + N: integer; + NStart: integer; + NDst: integer; +begin + C := Lines[0].Current; + + // set new sentence + NStart := Lines[0].Line[C].HighNote + 1; + Lines[0].Line[C].HighNote := Lines[0].Line[C].HighNote + Lines[0].Line[C+1].HighNote + 1; + SetLength(Lines[0].Line[C].Note, Lines[0].Line[C].HighNote + 1); + + // move right notes to new sentences + for N := 0 to Lines[0].Line[C+1].HighNote do begin + NDst := NStart + N; + Lines[0].Line[C].Note[NDst] := Lines[0].Line[C+1].Note[N]; + end; + + // increase sentence counters + NDst := Lines[0].Line[C].HighNote; + Lines[0].Line[C].End_ := Lines[0].Line[C].Note[NDst].Start + + Lines[0].Line[C].Note[NDst].Length; + + // move needed sentences to one backward. + for C := Lines[0].Current + 1 to Lines[0].High - 1 do + Lines[0].Line[C] := Lines[0].Line[C+1]; + + // increase sentence length by 1 + SetLength(Lines[0].Line, Length(Lines[0].Line) - 1); + Dec(Lines[0].Number); + Dec(Lines[0].High); +end; + +procedure TScreenEditSub.DivideNote; +var + C: integer; + N: integer; +begin + C := Lines[0].Current; + + with Lines[0].Line[C] do + begin + Inc(HighNote); + SetLength(Note, HighNote + 1); + + // we copy all notes including selected one + for N := HighNote downto CurrentNote+1 do begin + Note[N] := Note[N-1]; + end; + + // me slightly modify new note + Note[CurrentNote].Length := 1; + Inc(Note[CurrentNote+1].Start); + Dec(Note[CurrentNote+1].Length); + Note[CurrentNote+1].Text := '- '; + Note[CurrentNote+1].Color := 0; + end; +end; + +procedure TScreenEditSub.DeleteNote; +var + C: integer; + N: integer; + NLen: integer; +begin + C := Lines[0].Current; + + //Do Not delete Last Note + if (Lines[0].High > 0) OR (Lines[0].Line[C].HighNote > 0) then + begin + + // we copy all notes from the next to the selected one + for N := CurrentNote+1 to Lines[0].Line[C].HighNote do begin + Lines[0].Line[C].Note[N-1] := Lines[0].Line[C].Note[N]; + end; + + Dec(Lines[0].Line[C].HighNote); + if (Lines[0].Line[C].HighNote >= 0) then + begin + SetLength(Lines[0].Line[C].Note, Lines[0].Line[C].HighNote + 1); + + // me slightly modify new note + if CurrentNote > Lines[0].Line[C].HighNote then + Dec(CurrentNote); + + Lines[0].Line[C].Note[CurrentNote].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 Lines[0].High do + Lines[0].Line[N-1] := Lines[0].Line[N]; + + //Delete Last Sentence + SetLength(Lines[0].Line, Lines[0].High); + Lines[0].High := High(Lines[0].Line); + Lines[0].Number := Length(Lines[0].Line); + + CurrentNote := 0; + if (C > 0) then + Lines[0].Current := C - 1 + else + Lines[0].Current := 0; + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + end; + end; +end; + +procedure TScreenEditSub.TransposeNote(Transpose: integer); +begin + Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone, Transpose); +end; + +procedure TScreenEditSub.ChangeWholeTone(Tone: integer); +var + C: integer; + N: integer; +begin + for C := 0 to Lines[0].High do begin + Lines[0].Line[C].BaseNote := Lines[0].Line[C].BaseNote + Tone; + for N := 0 to Lines[0].Line[C].HighNote do + Lines[0].Line[C].Note[N].Tone := Lines[0].Line[C].Note[N].Tone + Tone; + end; +end; + +procedure TScreenEditSub.MoveAllToEnd(Move: integer); +var + C: integer; + N: integer; + NStart: integer; +begin + for C := Lines[0].Current to Lines[0].High do begin + NStart := 0; + if C = Lines[0].Current then NStart := CurrentNote; + for N := NStart to Lines[0].Line[C].HighNote do begin + Inc(Lines[0].Line[C].Note[N].Start, Move); // move note start + + if N = 0 then begin // fix beginning + Inc(Lines[0].Line[C].Start, Move); + end; + + if N = Lines[0].Line[C].HighNote then // fix ending + Inc(Lines[0].Line[C].End_, Move); + + end; // for + end; // for +end; + +procedure TScreenEditSub.MoveTextToRight; +var + C: integer; + N: integer; + NHigh: integer; +begin +{ C := Lines[0].Current; + + for N := Lines[0].Line[C].HighNut downto 1 do begin + Lines[0].Line[C].Note[N].Text := Lines[0].Line[C].Note[N-1].Text; + end; // for + + Lines[0].Line[C].Note[0].Text := '- ';} + + C := Lines[0].Current; + NHigh := Lines[0].Line[C].HighNote; + + // last word + Lines[0].Line[C].Note[NHigh].Text := Lines[0].Line[C].Note[NHigh-1].Text + Lines[0].Line[C].Note[NHigh].Text; + + // other words + for N := NHigh - 1 downto CurrentNote + 1 do begin + Lines[0].Line[C].Note[N].Text := Lines[0].Line[C].Note[N-1].Text; + end; // for + Lines[0].Line[C].Note[CurrentNote].Text := '- '; +end; + +procedure TScreenEditSub.MarkSrc; +begin + CopySrc := Lines[0].Current; +end; + +procedure TScreenEditSub.PasteText; +var + C: integer; + N: integer; +begin + C := Lines[0].Current; + + for N := 0 to Lines[0].Line[CopySrc].HighNote do + Lines[0].Line[C].Note[N].Text := Lines[0].Line[CopySrc].Note[N].Text; +end; + +procedure TScreenEditSub.CopySentence(Src, Dst: integer); +var + N: integer; + Time1: integer; + Time2: integer; + TD: integer; +begin + Time1 := Lines[0].Line[Src].Note[0].Start; + Time2 := Lines[0].Line[Dst].Note[0].Start; + TD := Time2-Time1; + + SetLength(Lines[0].Line[Dst].Note, Lines[0].Line[Src].HighNote + 1); + Lines[0].Line[Dst].HighNote := Lines[0].Line[Src].HighNote; + for N := 0 to Lines[0].Line[Src].HighNote do begin + Lines[0].Line[Dst].Note[N].Text := Lines[0].Line[Src].Note[N].Text; + Lines[0].Line[Dst].Note[N].Length := Lines[0].Line[Src].Note[N].Length; + Lines[0].Line[Dst].Note[N].Tone := Lines[0].Line[Src].Note[N].Tone; + Lines[0].Line[Dst].Note[N].Start := Lines[0].Line[Src].Note[N].Start + TD; + end; + N := Lines[0].Line[Src].HighNote; + Lines[0].Line[Dst].End_ := Lines[0].Line[Dst].Note[N].Start + Lines[0].Line[Dst].Note[N].Length; +end; + +procedure TScreenEditSub.CopySentences(Src, Dst, Num: integer); +var + C: integer; +begin + // create place for new sentences + SetLength(Lines[0].Line, Lines[0].Number + Num - 1); + + // moves sentences next to the destination + for C := Lines[0].High downto Dst + 1 do begin + Lines[0].Line[C + Num - 1] := Lines[0].Line[C]; + end; + + // prepares new sentences: sets sentence start and create first note + for C := 1 to Num-1 do begin + Lines[0].Line[Dst + C].Start := Lines[0].Line[Dst + C - 1].Note[0].Start + + (Lines[0].Line[Src + C].Note[0].Start - Lines[0].Line[Src + C - 1].Note[0].Start); + SetLength(Lines[0].Line[Dst + C].Note, 1); + Lines[0].Line[Dst + C].HighNote := 0; + Lines[0].Line[Dst + C].Note[0].Start := Lines[0].Line[Dst + C].Start; + Lines[0].Line[Dst + C].Note[0].Length := 1; + Lines[0].Line[Dst + C].End_ := Lines[0].Line[Dst + C].Start + 1; + end; + + // increase counters + Lines[0].Number := Lines[0].Number + Num - 1; + Lines[0].High := Lines[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'), TEXTURE_TYPE_COLORIZED); + AddText(40, 17, 1, 6, 1, 1, 1, 'Line'); + TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0'); + + // Note + AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), TEXTURE_TYPE_COLORIZED); + 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('MainBar'), TEXTURE_TYPE_COLORIZED); + AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('MainBar'), TEXTURE_TYPE_COLORIZED); + 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'); + TextNLength := 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 + inherited; + + Log.LogStatus('Initializing', 'TEditScreen.onShow'); + Lyric := TEditorLyrics.Create; + + ResetSingTemp; + + try + //Check if File is XML + if copy(CurrentSong.FileName,length(CurrentSong.FileName)-3,4) = '.xml' + then Error := not CurrentSong.LoadXMLSong() + else Error := not CurrentSong.LoadSong(); + 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 := CurrentSong.Title; + Text[TextArtist].Text := CurrentSong.Artist; + Text[TextMp3].Text := CurrentSong.Mp3; + + Lines[0].Current := 0; + CurrentNote := 0; + Lines[0].Line[0].Note[0].Color := 1; + AudioPlayback.Open(CurrentSong.Path + CurrentSong.Mp3); + //Set Down Music Volume for Better hearability of Midi Sounds + //Music.SetVolume(0.4); + + 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.AddLine(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 + {$IFDEF UseMIDIPort} + MidiPos := USTime.GetTime - MidiTime + MidiStart; + + + // stop the music + if (MidiPos > MidiStop) then begin + MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); + PlaySentenceMidi := false; + end; + {$ENDIF} + + // click + AktBeat := Floor(GetMidBeat(MidiPos - CurrentSong.GAP / 1000)); + Text[TextDebug].Text := IntToStr(AktBeat); + + if AktBeat <> LastClick then begin + for Pet := 0 to Lines[0].Line[Lines[0].Current].HighNote do + if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = AktBeat) then + begin + + + LastClick := AktBeat; + {$IFDEF UseMIDIPort} + if Pet > 0 then + MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[Pet-1].Tone + 60, 127); + MidiOut.PutShort($91, Lines[0].Line[Lines[0].Current].Note[Pet].Tone + 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(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 Lines[0].Line[Lines[0].Current].HighNote do + if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = AktBeat) then + begin + AudioPlayback.PlaySound( SoundLib.Click ); + LastClick := AktBeat; + end; + end; + end; // click + end; // if PlaySentence + + + Text[TextSentence].Text := IntToStr(Lines[0].Current + 1) + ' / ' + IntToStr(Lines[0].Number); + Text[TextNote].Text := IntToStr(CurrentNote + 1) + ' / ' + IntToStr(Lines[0].Line[Lines[0].Current].HighNote + 1); + + // Song info + 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 + begin + // Note info + Text[TextNStart].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + Text[TextNLength].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + Text[TextNTon].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone) + ' ( ' + GetNoteName(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone) + ' )'; + Text[TextNText].Text := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text; + 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); + EditDrawLine(40, 405, 760, 0, 15); + end; + + // draw text + Lyric.Draw; + + Result := true; +end; + +procedure TScreenEditSub.onHide; +begin + {$IFDEF UseMIDIPort} + MidiOut.Close; + MidiOut.Free; + {$ENDIF} + Lyric.Free; + //Music.SetVolume(1.0); +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 f16756422a5dbb24ce1b751bb9e2bb1de4f19713 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 23 Sep 2008 21:17:50 +0000 Subject: added file headers git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1404 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 2d98f6bc..09951e28 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1,3 +1,28 @@ +{* UltraStar Deluxe - Karaoke Game + * + * UltraStar Deluxe is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + *} + unit UScreenEditSub; interface -- cgit v1.2.3 From 2f768387f3849699320229a5b756db78af1207a2 Mon Sep 17 00:00:00 2001 From: tobigun Date: Sun, 19 Oct 2008 16:24:59 +0000 Subject: The size given to TextGL.SetSize() now expresses the size in pixel (formerly it was 1/3 of the pixel-size). For theme and plugin compatibility the following functions multiply the size with 3: - UScreenSingModi.Print - TTheme.ThemeLoadText - TTheme.ThemeLoadSelectSlide TODO: Convert the themes/plugins and remove the "*3" git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1459 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 09951e28..3eefc680 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1115,30 +1115,30 @@ begin inherited Create; SetLength(Player, 1); - // linijka + // line AddStatic(20, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), TEXTURE_TYPE_COLORIZED); - AddText(40, 17, 1, 6, 1, 1, 1, 'Line'); - TextSentence := AddText(120, 14, 1, 8, 0, 0, 0, '0 / 0'); + AddText(40, 17, 1, 18, 1, 1, 1, 'Line'); + TextSentence := AddText(120, 14, 1, 24, 0, 0, 0, '0 / 0'); // Note AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), TEXTURE_TYPE_COLORIZED); - AddText(242, 17, 1, 6, 1, 1, 1, 'Note'); - TextNote := AddText(320, 14, 1, 8, 0, 0, 0, '0 / 0'); + AddText(242, 17, 1, 18, 1, 1, 1, 'Note'); + TextNote := AddText(320, 14, 1, 24, 0, 0, 0, '0 / 0'); // file info AddStatic(150, 50, 500, 150, 0, 0, 0, Skin.GetTextureFileName('MainBar'), TEXTURE_TYPE_COLORIZED); AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('MainBar'), TEXTURE_TYPE_COLORIZED); - 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'); + AddText(180, 65, 0, 24, 0, 0, 0, 'Title:'); + AddText(180, 90, 0, 24, 0, 0, 0, 'Artist:'); + AddText(180, 115, 0, 24, 0, 0, 0, 'Mp3:'); + AddText(180, 140, 0, 24, 0, 0, 0, 'BPM:'); + AddText(180, 165, 0, 24, 0, 0, 0, 'GAP:'); + + TextTitle := AddText(250, 65, 0, 24, 0, 0, 0, 'a'); + TextArtist := AddText(250, 90, 0, 24, 0, 0, 0, 'b'); + TextMp3 := AddText(250, 115, 0, 24, 0, 0, 0, 'c'); + TextBPM := AddText(250, 140, 0, 24, 0, 0, 0, 'd'); + TextGAP := AddText(250, 165, 0, 24, 0, 0, 0, 'e'); { AddInteraction(2, TextTitle); AddInteraction(2, TextArtist); @@ -1147,15 +1147,15 @@ begin 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:'); + AddText(20, 190, 0, 24, 0, 0, 0, 'Start:'); + AddText(20, 215, 0, 24, 0, 0, 0, 'Duration:'); + AddText(20, 240, 0, 24, 0, 0, 0, 'Tone:'); + AddText(20, 265, 0, 24, 0, 0, 0, 'Text:'); - TextNStart := AddText(120, 190, 0, 8, 0, 0, 0, 'a'); - TextNLength := 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'); + TextNStart := AddText(120, 190, 0, 24, 0, 0, 0, 'a'); + TextNLength := AddText(120, 215, 0, 24, 0, 0, 0, 'b'); + TextNTon := AddText(120, 240, 0, 24, 0, 0, 0, 'c'); + TextNText := AddText(120, 265, 0, 24, 0, 0, 0, 'd'); // debug TextDebug := AddText(30, 550, 0, 8, 0, 0, 0, ''); @@ -1209,7 +1209,7 @@ begin Lyric.X := 400; Lyric.Y := 500; Lyric.Align := 1; - Lyric.Size := 14; + Lyric.Size := 42; Lyric.ColR := 0; Lyric.ColG := 0; Lyric.ColB := 0; -- cgit v1.2.3 From 6585afce2ccd8e7c5ccb3bb3599d4723b00a0433 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 28 Oct 2008 20:16:05 +0000 Subject: some compiler warnings/hints removed git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1485 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 3eefc680..167d94b4 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -93,7 +93,6 @@ type Lyric: TEditorLyrics; - procedure NewBeat; procedure DivideBPM; procedure MultiplyBPM; procedure LyricsCapitalize; @@ -669,14 +668,15 @@ begin end; end; +{ procedure TScreenEditSub.NewBeat; begin - // click -{ for Pet := 0 to Lines[0].Line[Lines[0].Current].HighNut do - if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = Czas.AktBeat) then begin - // old} -// Music.PlayClick; + // click + for Pet := 0 to Lines[0].Line[Lines[0].Current].HighNut do + if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = Czas.AktBeat) then + Music.PlayClick; end; +} procedure TScreenEditSub.DivideBPM; var @@ -713,7 +713,7 @@ end; procedure TScreenEditSub.LyricsCapitalize; var C: integer; - N: integer; // temporary + //N: integer; // temporary S: string; begin // temporary @@ -925,7 +925,6 @@ procedure TScreenEditSub.DeleteNote; var C: integer; N: integer; - NLen: integer; begin C := Lines[0].Current; @@ -1230,9 +1229,6 @@ end; function TScreenEditSub.Draw: boolean; var - Min: integer; - Sec: integer; - Tekst: string; Pet: integer; AktBeat: integer; begin -- cgit v1.2.3 From d33f56a40d9e8325a2782f90bb253dece5127c5f Mon Sep 17 00:00:00 2001 From: tobigun Date: Mon, 3 Nov 2008 14:53:17 +0000 Subject: All comments are English now (Polish ones have been translated) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1498 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 167d94b4..963d50de 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -434,10 +434,6 @@ begin begin end; - SDLK_LCTRL: - begin - end; - SDLK_DELETE: begin if SDL_ModState = KMOD_LCTRL then begin -- cgit v1.2.3 From d73dd340314b2d23ac569ffa1a66532beba1b74f Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Tue, 25 Nov 2008 13:16:18 +0000 Subject: formatting git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1525 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 265 ++++++++++++++++++++++++++--------------- 1 file changed, 169 insertions(+), 96 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 963d50de..949dffae 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -57,7 +57,7 @@ type TScreenEditSub = class(TMenu) private //Variable is True if no Song is loaded - Error: Boolean; + Error: boolean; TextNote: integer; TextSentence: integer; @@ -111,14 +111,14 @@ type procedure CopySentence(Src, Dst: integer); procedure CopySentences(Src, Dst, Num: integer); //Note Name Mod - function GetNoteName(Note: Integer): String; + function GetNoteName(Note: integer): string; public Tex_Background: TTexture; FadeOut: boolean; constructor Create; override; procedure onShow; override; - function ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; override; - function ParseInputEditText(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; + function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; + function ParseInputEditText(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; function Draw: boolean; override; procedure onHide; override; end; @@ -134,22 +134,25 @@ uses // Method for input parsing. If False is returned, GetNextWindow // should be checked to know the next window to load; -function TScreenEditSub.ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; +function TScreenEditSub.ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; var SDL_ModState: Word; R: real; begin Result := true; - if TextEditMode then begin + if TextEditMode then + begin Result := ParseInputEditText(PressedKey, CharCode, PressedDown); - end else begin + 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 - // check normal keys + if (PressedDown) then // Key Down + begin // check normal keys case WideCharUpperCase(CharCode)[1] of 'Q': begin @@ -201,14 +204,16 @@ begin 'V': begin // Paste text - if SDL_ModState = KMOD_LCTRL then begin + if SDL_ModState = KMOD_LCTRL then + begin if Lines[0].Line[Lines[0].Current].HighNote >= Lines[0].Line[CopySrc].HighNote then PasteText else Log.LogStatus('PasteText: invalid range', 'TScreenEditSub.ParseInput'); end; - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then + begin CopySentence(CopySrc, Lines[0].Current); end; end; @@ -327,20 +332,23 @@ begin SDLK_4: begin - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then + begin CopySentence(CopySrc, Lines[0].Current); CopySentence(CopySrc+1, Lines[0].Current+1); CopySentence(CopySrc+2, Lines[0].Current+2); CopySentence(CopySrc+3, Lines[0].Current+3); end; - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then + begin CopySentences(CopySrc, Lines[0].Current, 4); end; end; SDLK_5: begin - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then + begin CopySentence(CopySrc, Lines[0].Current); CopySentence(CopySrc+1, Lines[0].Current+1); CopySentence(CopySrc+2, Lines[0].Current+2); @@ -348,7 +356,8 @@ begin CopySentence(CopySrc+4, Lines[0].Current+4); end; - if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then begin + if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then + begin CopySentences(CopySrc, Lines[0].Current, 5); end; end; @@ -390,19 +399,22 @@ begin SDLK_SLASH: begin - if SDL_ModState = 0 then begin + if SDL_ModState = 0 then + begin // Insert start of sentece if CurrentNote > 0 then DivideSentence; end; - if SDL_ModState = KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LSHIFT then + begin // Join next sentence with current - if Lines[0].Current < Lines[0].High then + if Lines[0].Current < Lines[0].High then JoinSentence; end; - if SDL_ModState = KMOD_LCTRL then begin + if SDL_ModState = KMOD_LCTRL then + begin // divide note DivideNote; end; @@ -436,7 +448,8 @@ begin SDLK_DELETE: begin - if SDL_ModState = KMOD_LCTRL then begin + if SDL_ModState = KMOD_LCTRL then + begin // moves text to right in current sentence DeleteNote; end; @@ -451,29 +464,36 @@ begin SDLK_RIGHT: begin // right - if SDL_ModState = 0 then begin + if SDL_ModState = 0 then + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(CurrentNote); - if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then CurrentNote := 0; + if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then + CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; // ctrl + right - if SDL_ModState = KMOD_LCTRL then begin - if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then begin + if SDL_ModState = KMOD_LCTRL then + begin + if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); - if CurrentNote = 0 then begin + if CurrentNote = 0 then + begin Inc(Lines[0].Line[Lines[0].Current].Start); end; end; end; // shift + right - if SDL_ModState = KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LSHIFT then + begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); - if CurrentNote = 0 then begin + if CurrentNote = 0 then + begin Inc(Lines[0].Line[Lines[0].Current].Start); end; if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then @@ -481,14 +501,16 @@ begin end; // alt + right - if SDL_ModState = KMOD_LALT then begin + if SDL_ModState = KMOD_LALT then + begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then Inc(Lines[0].Line[Lines[0].Current].End_); end; // alt + ctrl + shift + right = move all from cursor to right - if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then + begin MoveAllToEnd(1); end; @@ -497,29 +519,35 @@ begin SDLK_LEFT: begin // left - if SDL_ModState = 0 then begin + if SDL_ModState = 0 then + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(CurrentNote); - if CurrentNote = -1 then CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + if CurrentNote = -1 then + CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; // ctrl + left - if SDL_ModState = KMOD_LCTRL then begin + if SDL_ModState = KMOD_LCTRL the + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); - if CurrentNote = 0 then begin + if CurrentNote = 0 then + begin Dec(Lines[0].Line[Lines[0].Current].Start); end; end; // shift + left - if SDL_ModState = KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LSHIFT then + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); // resizing sentences - if CurrentNote = 0 then begin + if CurrentNote = 0 then + begin Dec(Lines[0].Line[Lines[0].Current].Start); end; @@ -529,8 +557,10 @@ begin end; // alt + left - if SDL_ModState = KMOD_LALT then begin - if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then begin + if SDL_ModState = KMOD_LALT then + begin + if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then Dec(Lines[0].Line[Lines[0].Current].End_); @@ -538,7 +568,8 @@ begin end; // alt + ctrl + shift + right = move all from cursor to left - if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then begin + if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then + begin MoveAllToEnd(-1); end; @@ -548,7 +579,8 @@ begin begin // skip to next sentence - if SDL_ModState = 0 then begin {$IFDEF UseMIDIPort} + if SDL_ModState = 0 then + begin {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; {$endif} @@ -566,7 +598,8 @@ begin end; // decrease tone - if SDL_ModState = KMOD_LCTRL then begin + if SDL_ModState = KMOD_LCTRL then + begin TransposeNote(-1); end; @@ -576,7 +609,8 @@ begin begin // skip to previous sentence - if SDL_ModState = 0 then begin + if SDL_ModState = 0 then + begin {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; @@ -585,7 +619,8 @@ begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(Lines[0].Current); CurrentNote := 0; - if Lines[0].Current = -1 then Lines[0].Current := Lines[0].High; + if Lines[0].Current = -1 then + Lines[0].Current := Lines[0].High; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.AddLine(Lines[0].Current); @@ -595,7 +630,8 @@ begin end; // increase tone - if SDL_ModState = KMOD_LCTRL then begin + if SDL_ModState = KMOD_LCTRL then + begin TransposeNote(1); end; end; @@ -605,7 +641,7 @@ begin end; // if end; -function TScreenEditSub.ParseInputEditText(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; +function TScreenEditSub.ParseInputEditText(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; var SDL_ModState: Word; begin @@ -615,7 +651,7 @@ begin SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); - If (PressedDown) Then + if (PressedDown) then begin // Key Down case PressedKey of @@ -641,10 +677,12 @@ begin SDLK_RIGHT: begin // right - if SDL_ModState = 0 then begin + if SDL_ModState = 0 then + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(CurrentNote); - if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then CurrentNote := 0; + if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then + CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; @@ -652,10 +690,12 @@ begin SDLK_LEFT: begin // left - if SDL_ModState = 0 then begin + if SDL_ModState = 0 then + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(CurrentNote); - if CurrentNote = -1 then CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + if CurrentNote = -1 then + CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; @@ -680,11 +720,12 @@ var N: integer; begin CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM / 2; - for C := 0 to Lines[0].High do begin - Lines[0].Line[C].Start := Lines[0].Line[C].Start div 2; - Lines[0].Line[C].End_ := Lines[0].Line[C].End_ div 2; + for C := 0 to Lines[0].High do + begin + Lines[0].Line[C].Start := Lines[0].Line[C].Start div 2; + Lines[0].Line[C].End_ := Lines[0].Line[C].End_ div 2; for N := 0 to Lines[0].Line[C].HighNote do begin - Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start div 2; + Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start div 2; Lines[0].Line[C].Note[N].Length := Round(Lines[0].Line[C].Note[N].Length / 2); end; // N end; // C @@ -696,11 +737,13 @@ var N: integer; begin CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM * 2; - for C := 0 to Lines[0].High do begin - Lines[0].Line[C].Start := Lines[0].Line[C].Start * 2; - Lines[0].Line[C].End_ := Lines[0].Line[C].End_ * 2; - for N := 0 to Lines[0].Line[C].HighNote do begin - Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start * 2; + for C := 0 to Lines[0].High do + begin + Lines[0].Line[C].Start := Lines[0].Line[C].Start * 2; + Lines[0].Line[C].End_ := Lines[0].Line[C].End_ * 2; + for N := 0 to Lines[0].Line[C].HighNote do + begin + Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start * 2; Lines[0].Line[C].Note[N].Length := Lines[0].Line[C].Note[N].Length * 2; end; // N end; // C @@ -717,7 +760,8 @@ begin for N := 0 to Lines[0].Line[C].HighNut do Lines[0].Line[C].Note[N].Text := AnsiLowerCase(Lines[0].Line[C].Note[N].Text);} - for C := 0 to Lines[0].High do begin + for C := 0 to Lines[0].High do + begin S := AnsiUpperCase(Copy(Lines[0].Line[C].Note[0].Text, 1, 1)); S := S + Copy(Lines[0].Line[C].Note[0].Text, 2, Length(Lines[0].Line[C].Note[0].Text)-1); Lines[0].Line[C].Note[0].Text := S; @@ -729,33 +773,39 @@ var C: integer; N: integer; begin - for C := 0 to Lines[0].High do begin + for C := 0 to Lines[0].High do + begin // correct starting spaces in the first word while Copy(Lines[0].Line[C].Note[0].Text, 1, 1) = ' ' do Lines[0].Line[C].Note[0].Text := Copy(Lines[0].Line[C].Note[0].Text, 2, 100); // move spaces on the start to the end of the previous note - for N := 1 to Lines[0].Line[C].HighNote do begin - while (Copy(Lines[0].Line[C].Note[N].Text, 1, 1) = ' ') do begin + for N := 1 to Lines[0].Line[C].HighNote do + begin + while (Copy(Lines[0].Line[C].Note[N].Text, 1, 1) = ' ') do + begin Lines[0].Line[C].Note[N].Text := Copy(Lines[0].Line[C].Note[N].Text, 2, 100); Lines[0].Line[C].Note[N-1].Text := Lines[0].Line[C].Note[N-1].Text + ' '; end; end; // N // correct '-' to '- ' - for N := 0 to Lines[0].Line[C].HighNote do begin + for N := 0 to Lines[0].Line[C].HighNote do + begin if Lines[0].Line[C].Note[N].Text = '-' then Lines[0].Line[C].Note[N].Text := '- '; end; // N // add space to the previous note when the current word is '- ' - for N := 1 to Lines[0].Line[C].HighNote do begin + for N := 1 to Lines[0].Line[C].HighNote do + begin if Lines[0].Line[C].Note[N].Text = '- ' then Lines[0].Line[C].Note[N-1].Text := Lines[0].Line[C].Note[N-1].Text + ' '; end; // N // correct too many spaces at the end of note - for N := 0 to Lines[0].Line[C].HighNote do begin + for N := 0 to Lines[0].Line[C].HighNote do + begin while Copy(Lines[0].Line[C].Note[N].Text, Length(Lines[0].Line[C].Note[N].Text)-1, 2) = ' ' do Lines[0].Line[C].Note[N].Text := Copy(Lines[0].Line[C].Note[N].Text, 1, Length(Lines[0].Line[C].Note[N].Text)-1); end; // N @@ -775,8 +825,10 @@ var Min: integer; Max: integer; begin - for C := 1 to Lines[0].High do begin - with Lines[0].Line[C-1] do begin + for C := 1 to Lines[0].High do + begin + with Lines[0].Line[C-1] do + begin Min := Note[HighNote].Start + Note[HighNote].Length; Max := Lines[0].Line[C].Note[0].Start; case (Max - Min) of @@ -830,7 +882,8 @@ begin // move right notes to new sentences NHigh := Lines[0].Line[CStart].HighNote; - for N := NStart to NHigh do begin + for N := NStart to NHigh do + begin // increase sentence counters with Lines[0].Line[CNew] do begin @@ -871,7 +924,8 @@ begin SetLength(Lines[0].Line[C].Note, Lines[0].Line[C].HighNote + 1); // move right notes to new sentences - for N := 0 to Lines[0].Line[C+1].HighNote do begin + for N := 0 to Lines[0].Line[C+1].HighNote do + begin NDst := NStart + N; Lines[0].Line[C].Note[NDst] := Lines[0].Line[C+1].Note[N]; end; @@ -904,7 +958,8 @@ begin SetLength(Note, HighNote + 1); // we copy all notes including selected one - for N := HighNote downto CurrentNote+1 do begin + for N := HighNote downto CurrentNote+1 do + begin Note[N] := Note[N-1]; end; @@ -929,7 +984,8 @@ begin begin // we copy all notes from the next to the selected one - for N := CurrentNote+1 to Lines[0].Line[C].HighNote do begin + for N := CurrentNote+1 to Lines[0].Line[C].HighNote do + begin Lines[0].Line[C].Note[N-1] := Lines[0].Line[C].Note[N]; end; @@ -977,7 +1033,8 @@ var C: integer; N: integer; begin - for C := 0 to Lines[0].High do begin + for C := 0 to Lines[0].High do + begin Lines[0].Line[C].BaseNote := Lines[0].Line[C].BaseNote + Tone; for N := 0 to Lines[0].Line[C].HighNote do Lines[0].Line[C].Note[N].Tone := Lines[0].Line[C].Note[N].Tone + Tone; @@ -990,13 +1047,17 @@ var N: integer; NStart: integer; begin - for C := Lines[0].Current to Lines[0].High do begin + for C := Lines[0].Current to Lines[0].High do + begin NStart := 0; - if C = Lines[0].Current then NStart := CurrentNote; - for N := NStart to Lines[0].Line[C].HighNote do begin + if C = Lines[0].Current then + NStart := CurrentNote; + for N := NStart to Lines[0].Line[C].HighNote do + begin Inc(Lines[0].Line[C].Note[N].Start, Move); // move note start - if N = 0 then begin // fix beginning + if N = 0 then + begin // fix beginning Inc(Lines[0].Line[C].Start, Move); end; @@ -1028,7 +1089,8 @@ begin Lines[0].Line[C].Note[NHigh].Text := Lines[0].Line[C].Note[NHigh-1].Text + Lines[0].Line[C].Note[NHigh].Text; // other words - for N := NHigh - 1 downto CurrentNote + 1 do begin + for N := NHigh - 1 downto CurrentNote + 1 do + begin Lines[0].Line[C].Note[N].Text := Lines[0].Line[C].Note[N-1].Text; end; // for Lines[0].Line[C].Note[CurrentNote].Text := '- '; @@ -1052,10 +1114,10 @@ end; procedure TScreenEditSub.CopySentence(Src, Dst: integer); var - N: integer; - Time1: integer; - Time2: integer; - TD: integer; + N: integer; + Time1: integer; + Time2: integer; + TD: integer; begin Time1 := Lines[0].Line[Src].Note[0].Start; Time2 := Lines[0].Line[Dst].Note[0].Start; @@ -1063,7 +1125,8 @@ begin SetLength(Lines[0].Line[Dst].Note, Lines[0].Line[Src].HighNote + 1); Lines[0].Line[Dst].HighNote := Lines[0].Line[Src].HighNote; - for N := 0 to Lines[0].Line[Src].HighNote do begin + for N := 0 to Lines[0].Line[Src].HighNote do + begin Lines[0].Line[Dst].Note[N].Text := Lines[0].Line[Src].Note[N].Text; Lines[0].Line[Dst].Note[N].Length := Lines[0].Line[Src].Note[N].Length; Lines[0].Line[Dst].Note[N].Tone := Lines[0].Line[Src].Note[N].Tone; @@ -1081,12 +1144,14 @@ begin SetLength(Lines[0].Line, Lines[0].Number + Num - 1); // moves sentences next to the destination - for C := Lines[0].High downto Dst + 1 do begin + for C := Lines[0].High downto Dst + 1 do + begin Lines[0].Line[C + Num - 1] := Lines[0].Line[C]; end; // prepares new sentences: sets sentence start and create first note - for C := 1 to Num-1 do begin + for C := 1 to Num-1 do + begin Lines[0].Line[Dst + C].Start := Lines[0].Line[Dst + C - 1].Note[0].Start + (Lines[0].Line[Src + C].Note[0].Start - Lines[0].Line[Src + C - 1].Note[0].Start); SetLength(Lines[0].Line[Dst + C].Note, 1); @@ -1168,9 +1233,10 @@ begin try //Check if File is XML - if copy(CurrentSong.FileName,length(CurrentSong.FileName)-3,4) = '.xml' - then Error := not CurrentSong.LoadXMLSong() - else Error := not CurrentSong.LoadSong(); + if copy(CurrentSong.FileName,length(CurrentSong.FileName)-3,4) = '.xml' then + Error := not CurrentSong.LoadXMLSong() + else + Error := not CurrentSong.LoadSong(); except Error := True; end; @@ -1182,7 +1248,8 @@ begin ScreenPopupError.ShowPopup (Language.Translate('ERROR_CORRUPT_SONG')); Exit; end - else begin + else + begin {$IFDEF UseMIDIPort} MidiOut := TMidiOutput.Create(nil); if Ini.Debug = 1 then @@ -1231,13 +1298,15 @@ begin glClearColor(1,1,1,1); // midi music - if PlaySentenceMidi then begin + if PlaySentenceMidi then + begin {$IFDEF UseMIDIPort} MidiPos := USTime.GetTime - MidiTime + MidiStart; // stop the music - if (MidiPos > MidiStop) then begin + if (MidiPos > MidiStop) then + begin MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; end; @@ -1247,7 +1316,8 @@ begin AktBeat := Floor(GetMidBeat(MidiPos - CurrentSong.GAP / 1000)); Text[TextDebug].Text := IntToStr(AktBeat); - if AktBeat <> LastClick then begin + if AktBeat <> LastClick then + begin for Pet := 0 to Lines[0].Line[Lines[0].Current].HighNote do if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = AktBeat) then begin @@ -1266,7 +1336,8 @@ begin end; // if PlaySentenceMidi // mp3 music - if PlaySentence then begin + if PlaySentence then + begin // stop the music if (AudioPlayback.Position > PlayStopTime) then begin @@ -1275,11 +1346,13 @@ begin end; // click - if (Click) and (PlaySentence) then begin + if (Click) and (PlaySentence) then + begin // 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 + if AktBeat <> LastClick then + begin for Pet := 0 to Lines[0].Line[Lines[0].Current].HighNote do if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = AktBeat) then begin @@ -1340,8 +1413,8 @@ begin //Music.SetVolume(1.0); end; -function TScreenEditSub.GetNoteName(Note: Integer): String; -var N1, N2: Integer; +function TScreenEditSub.GetNoteName(Note: integer): string; +var N1, N2: integer; begin if (Note > 0) then begin -- cgit v1.2.3 From 65a64b2404ae4e7c4c5e75724e25a1189c29c3ad Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Wed, 26 Nov 2008 21:38:59 +0000 Subject: replace integer by enumeration type alignment git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1526 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 949dffae..873d7185 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -530,7 +530,7 @@ begin end; // ctrl + left - if SDL_ModState = KMOD_LCTRL the + if SDL_ModState = KMOD_LCTRL then begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); @@ -1270,7 +1270,7 @@ begin Lyric.Clear; Lyric.X := 400; Lyric.Y := 500; - Lyric.Align := 1; + Lyric.Align := center; Lyric.Size := 42; Lyric.ColR := 0; Lyric.ColG := 0; -- cgit v1.2.3 From d826e9135078f7fa719046069ce10da1e382bfc3 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 27 Nov 2008 21:50:41 +0000 Subject: some more formatting git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1530 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 65 +++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 32 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 873d7185..07113363 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -33,25 +33,25 @@ interface {$I switches.inc} uses - UMenu, - UMusic, - SDL, - SysUtils, - UFiles, - UTime, - USongs, - USong, - UIni, - ULog, - UTexture, - UMenuText, - UEditorLyrics, - Math, - gl, - {$IFDEF UseMIDIPort} - MidiOut, - {$ENDIF} - UThemes; + UMenu, + UMusic, + SDL, + SysUtils, + UFiles, + UTime, + USongs, + USong, + UIni, + ULog, + UTexture, + UMenuText, + UEditorLyrics, + Math, + gl, + {$IFDEF UseMIDIPort} + MidiOut, + {$ENDIF} + UThemes; type TScreenEditSub = class(TMenu) @@ -80,18 +80,18 @@ type CopySrc: integer; {$IFDEF UseMIDIPort} - MidiOut: TMidiOutput; + MidiOut: TMidiOutput; {$endif} - MidiStart: real; - MidiStop: real; - MidiTime: real; - MidiPos: real; - MidiLastNote: integer; + MidiStart: real; + MidiStop: real; + MidiTime: real; + MidiPos: real; + MidiLastNote: integer; - TextEditMode: boolean; + TextEditMode: boolean; - Lyric: TEditorLyrics; + Lyric: TEditorLyrics; procedure DivideBPM; procedure MultiplyBPM; @@ -588,7 +588,8 @@ begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(Lines[0].Current); CurrentNote := 0; - if Lines[0].Current > Lines[0].High then Lines[0].Current := 0; + if Lines[0].Current > Lines[0].High then + Lines[0].Current := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.AddLine(Lines[0].Current); @@ -724,7 +725,8 @@ begin begin Lines[0].Line[C].Start := Lines[0].Line[C].Start div 2; Lines[0].Line[C].End_ := Lines[0].Line[C].End_ div 2; - for N := 0 to Lines[0].Line[C].HighNote do begin + for N := 0 to Lines[0].Line[C].HighNote do + begin Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start div 2; Lines[0].Line[C].Note[N].Length := Round(Lines[0].Line[C].Note[N].Length / 2); end; // N @@ -1076,7 +1078,8 @@ var begin { C := Lines[0].Current; - for N := Lines[0].Line[C].HighNut downto 1 do begin + for N := Lines[0].Line[C].HighNut downto 1 do + begin Lines[0].Line[C].Note[N].Text := Lines[0].Line[C].Note[N-1].Text; end; // for @@ -1427,8 +1430,6 @@ begin N2 := -1; end; - - case N1 of 0: Result := 'c'; 1: Result := 'c#'; -- cgit v1.2.3 From 8f2fc12d58f248a7b548c4919c640500c7a4524d Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 28 Feb 2009 20:56:12 +0000 Subject: Some cleanup done moved ScoreFactor to UMusic removed unused field TLines.LyricWidth removed unused field TSong.Category removed some weird and useless code from songloading procedures songloading simplified, commented parts that are difficult to understand some changes to score calculation that assure not more nor less than 10000 Points are gainable. after many tests I could not find any bug in score calculation, at least after these changes. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1610 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 07113363..d30781fe 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -876,9 +876,8 @@ begin NStart := CurrentNote; Lines[0].Line[CNew].Start := Lines[0].Line[CStart].Note[NStart].Start; Lines[0].Line[CNew].Lyric := ''; - Lines[0].Line[CNew].LyricWidth := 0; Lines[0].Line[CNew].End_ := 0; - Lines[0].Line[CNew].BaseNote := 0; // 0.5.0: we modify it later in this procedure + Lines[0].Line[CNew].BaseNote := 0;//High(Integer); // TODO: High (Integer) will causes a memory exception later in this procedure. Weird! Lines[0].Line[CNew].HighNote := -1; SetLength(Lines[0].Line[CNew].Note, 0); @@ -905,6 +904,16 @@ begin Lines[0].Line[CStart].Note[NStart-1].Length; SetLength(Lines[0].Line[CStart].Note, Lines[0].Line[CStart].HighNote + 1); + //recalculate BaseNote of the divided Sentence + with Lines[0].Line[CStart] do + begin + BaseNote := High(Integer); + + For N := 0 to HighNote do + if Note[N].Tone < BaseNote then + BaseNote := Note[N].Tone; + end; + Lines[0].Current := Lines[0].Current + 1; CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; -- cgit v1.2.3 From f469075a0335399c753ae5d2d362047dedf116b1 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sat, 7 Mar 2009 21:14:14 +0000 Subject: final cleanup of Umain. Creation of UNote git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1627 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index d30781fe..bdf85028 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -128,7 +128,7 @@ implementation uses UGraphic, UDraw, - UMain, + UNote, USkins, ULanguage; -- cgit v1.2.3 From 442fe6a73506979404f2d1f7bb2c2cffa4b69054 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Mon, 6 Apr 2009 22:17:39 +0000 Subject: bring the type align to our coding standards git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1658 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index bdf85028..8d4d7f28 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1282,7 +1282,7 @@ begin Lyric.Clear; Lyric.X := 400; Lyric.Y := 500; - Lyric.Align := center; + Lyric.Align := atCenter; Lyric.Size := 42; Lyric.ColR := 0; Lyric.ColG := 0; -- cgit v1.2.3 From c7f5d683c1eae49e30ee42a76557661f57311b9e Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sat, 25 Apr 2009 10:09:59 +0000 Subject: Cosmetics. No code change git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1694 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 98 +++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 50 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 8d4d7f28..3e1f3c1c 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -132,11 +132,11 @@ uses USkins, ULanguage; -// Method for input parsing. If False is returned, GetNextWindow +// Method for input parsing. If false is returned, GetNextWindow // should be checked to know the next window to load; function TScreenEditSub.ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; var - SDL_ModState: Word; + SDL_ModState: word; R: real; begin Result := true; @@ -205,7 +205,7 @@ begin begin // Paste text if SDL_ModState = KMOD_LCTRL then - begin + begin if Lines[0].Line[Lines[0].Current].HighNote >= Lines[0].Line[CopySrc].HighNote then PasteText else @@ -213,7 +213,7 @@ begin end; if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then - begin + begin CopySentence(CopySrc, Lines[0].Current); end; end; @@ -333,7 +333,7 @@ begin SDLK_4: begin if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then - begin + begin CopySentence(CopySrc, Lines[0].Current); CopySentence(CopySrc+1, Lines[0].Current+1); CopySentence(CopySrc+2, Lines[0].Current+2); @@ -341,14 +341,14 @@ begin end; if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then - begin + begin CopySentences(CopySrc, Lines[0].Current, 4); end; end; SDLK_5: begin if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT then - begin + begin CopySentence(CopySrc, Lines[0].Current); CopySentence(CopySrc+1, Lines[0].Current+1); CopySentence(CopySrc+2, Lines[0].Current+2); @@ -357,7 +357,7 @@ begin end; if SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT + KMOD_LALT then - begin + begin CopySentences(CopySrc, Lines[0].Current, 5); end; end; @@ -400,21 +400,21 @@ begin SDLK_SLASH: begin if SDL_ModState = 0 then - begin + begin // Insert start of sentece if CurrentNote > 0 then DivideSentence; end; if SDL_ModState = KMOD_LSHIFT then - begin + begin // Join next sentence with current if Lines[0].Current < Lines[0].High then JoinSentence; end; if SDL_ModState = KMOD_LCTRL then - begin + begin // divide note DivideNote; end; @@ -449,7 +449,7 @@ begin SDLK_DELETE: begin if SDL_ModState = KMOD_LCTRL then - begin + begin // moves text to right in current sentence DeleteNote; end; @@ -465,24 +465,24 @@ begin begin // right if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(CurrentNote); if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then - CurrentNote := 0; + CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; // ctrl + right if SDL_ModState = KMOD_LCTRL then - begin + begin if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); if CurrentNote = 0 then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Start); end; end; @@ -490,10 +490,10 @@ begin // shift + right if SDL_ModState = KMOD_LSHIFT then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); if CurrentNote = 0 then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Start); end; if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then @@ -502,7 +502,7 @@ begin // alt + right if SDL_ModState = KMOD_LALT then - begin + begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then Inc(Lines[0].Line[Lines[0].Current].End_); @@ -510,7 +510,7 @@ begin // alt + ctrl + shift + right = move all from cursor to right if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then - begin + begin MoveAllToEnd(1); end; @@ -520,34 +520,34 @@ begin begin // left if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(CurrentNote); if CurrentNote = -1 then - CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; // ctrl + left if SDL_ModState = KMOD_LCTRL then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = 0 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Start); end; end; // shift + left if SDL_ModState = KMOD_LSHIFT then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); // resizing sentences if CurrentNote = 0 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Start); end; @@ -558,9 +558,9 @@ begin // alt + left if SDL_ModState = KMOD_LALT then - begin + begin if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then - begin + begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then Dec(Lines[0].Line[Lines[0].Current].End_); @@ -569,7 +569,7 @@ begin // alt + ctrl + shift + right = move all from cursor to left if SDL_ModState = KMOD_LALT + KMOD_LCTRL + KMOD_LSHIFT then - begin + begin MoveAllToEnd(-1); end; @@ -580,7 +580,7 @@ begin // skip to next sentence if SDL_ModState = 0 then - begin {$IFDEF UseMIDIPort} + begin {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; {$endif} @@ -589,7 +589,7 @@ begin Inc(Lines[0].Current); CurrentNote := 0; if Lines[0].Current > Lines[0].High then - Lines[0].Current := 0; + Lines[0].Current := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.AddLine(Lines[0].Current); @@ -600,7 +600,7 @@ begin // decrease tone if SDL_ModState = KMOD_LCTRL then - begin + begin TransposeNote(-1); end; @@ -611,7 +611,7 @@ begin // skip to previous sentence if SDL_ModState = 0 then - begin + begin {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; @@ -621,7 +621,7 @@ begin Dec(Lines[0].Current); CurrentNote := 0; if Lines[0].Current = -1 then - Lines[0].Current := Lines[0].High; + Lines[0].Current := Lines[0].High; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.AddLine(Lines[0].Current); @@ -632,7 +632,7 @@ begin // increase tone if SDL_ModState = KMOD_LCTRL then - begin + begin TransposeNote(1); end; end; @@ -644,7 +644,7 @@ end; function TScreenEditSub.ParseInputEditText(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; var - SDL_ModState: Word; + SDL_ModState: word; begin // used when in Text Edit Mode Result := true; @@ -679,11 +679,11 @@ begin begin // right if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(CurrentNote); if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then - CurrentNote := 0; + CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; @@ -692,11 +692,11 @@ begin begin // left if SDL_ModState = 0 then - begin + begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Dec(CurrentNote); if CurrentNote = -1 then - CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; + CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Lyric.Selected := CurrentNote; end; @@ -877,7 +877,7 @@ begin Lines[0].Line[CNew].Start := Lines[0].Line[CStart].Note[NStart].Start; Lines[0].Line[CNew].Lyric := ''; Lines[0].Line[CNew].End_ := 0; - Lines[0].Line[CNew].BaseNote := 0;//High(Integer); // TODO: High (Integer) will causes a memory exception later in this procedure. Weird! + Lines[0].Line[CNew].BaseNote := 0;//High(integer); // TODO: High (integer) will causes a memory exception later in this procedure. Weird! Lines[0].Line[CNew].HighNote := -1; SetLength(Lines[0].Line[CNew].Note, 0); @@ -907,9 +907,9 @@ begin //recalculate BaseNote of the divided Sentence with Lines[0].Line[CStart] do begin - BaseNote := High(Integer); + BaseNote := High(integer); - For N := 0 to HighNote do + for N := 0 to HighNote do if Note[N].Tone < BaseNote then BaseNote := Note[N].Tone; end; @@ -991,7 +991,7 @@ begin C := Lines[0].Current; //Do Not delete Last Note - if (Lines[0].High > 0) OR (Lines[0].Line[C].HighNote > 0) then + if (Lines[0].High > 0) or (Lines[0].Line[C].HighNote > 0) then begin // we copy all notes from the next to the selected one @@ -1181,7 +1181,6 @@ begin CopySentence(Src + C, Dst + C); end; - constructor TScreenEditSub.Create; begin inherited Create; @@ -1250,7 +1249,7 @@ begin else Error := not CurrentSong.LoadSong(); except - Error := True; + Error := true; end; if Error then @@ -1315,7 +1314,6 @@ begin {$IFDEF UseMIDIPort} MidiPos := USTime.GetTime - MidiTime + MidiStart; - // stop the music if (MidiPos > MidiStop) then begin @@ -1334,7 +1332,6 @@ begin if (Lines[0].Line[Lines[0].Current].Note[Pet].Start = AktBeat) then begin - LastClick := AktBeat; {$IFDEF UseMIDIPort} if Pet > 0 then @@ -1426,7 +1423,8 @@ begin end; function TScreenEditSub.GetNoteName(Note: integer): string; -var N1, N2: integer; +var + N1, N2: integer; begin if (Note > 0) then begin -- cgit v1.2.3 From 917901e8e33438c425aef50a0a7417f32d77b760 Mon Sep 17 00:00:00 2001 From: s_alexander Date: Mon, 9 Nov 2009 00:27:55 +0000 Subject: merged unicode branch (r1931) into trunk git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1939 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 155 +++++++++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 53 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 3e1f3c1c..00e62c16 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -116,11 +116,11 @@ type Tex_Background: TTexture; FadeOut: boolean; constructor Create; override; - procedure onShow; override; - function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; - function ParseInputEditText(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; + procedure OnShow; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; + function ParseInputEditText(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; function Draw: boolean; override; - procedure onHide; override; + procedure OnHide; override; end; implementation @@ -130,14 +130,44 @@ uses UDraw, UNote, USkins, - ULanguage; + ULanguage, + UTextEncoding, + UUnicodeUtils, + UPath; + + +procedure OnSaveEncodingError(Value: boolean; Data: Pointer); +var + SResult: TSaveSongResult; + FilePath: IPath; + Success: boolean; +begin + Success := false; + if (Value) then + begin + CurrentSong.Encoding := encUTF8; + FilePath := CurrentSong.Path.Append(CurrentSong.FileName); + // create backup file + FilePath.CopyFile(Path(FilePath.ToUTF8 + '.ansi.bak'), false); + // store in UTF-8 encoding + SResult := SaveSong(CurrentSong, Lines[0], FilePath, + boolean(Data)); + Success := (SResult = ssrOK); + end; + + if (Success) then + ScreenPopupInfo.ShowPopup(Language.Translate('INFO_FILE_SAVED')) + else + ScreenPopupError.ShowPopup(Language.Translate('ERROR_SAVE_FILE_FAILED')); +end; // Method for input parsing. If false is returned, GetNextWindow // should be checked to know the next window to load; -function TScreenEditSub.ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; +function TScreenEditSub.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var SDL_ModState: word; R: real; + SResult: TSaveSongResult; begin Result := true; @@ -152,40 +182,47 @@ begin + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); if (PressedDown) then // Key Down - begin // check normal keys - case WideCharUpperCase(CharCode)[1] of - 'Q': + begin + // check normal keys + case UCS4UpperCase(CharCode) of + Ord('Q'): begin Result := false; Exit; end; - 'S': + Ord('S'): begin // Save Song - if SDL_ModState = KMOD_LSHIFT then - SaveSong(CurrentSong, Lines[0], CurrentSong.Path + CurrentSong.FileName, true) + SResult := SaveSong(CurrentSong, Lines[0], CurrentSong.Path.Append(CurrentSong.FileName), + (SDL_ModState = KMOD_LSHIFT)); + if (SResult = ssrOK) then + begin + ScreenPopupInfo.ShowPopup(Language.Translate('INFO_FILE_SAVED')); + end + else if (SResult = ssrEncodingError) then + begin + ScreenPopupCheck.ShowPopup(Language.Translate('ENCODING_ERROR_ASK_FOR_UTF8'), OnSaveEncodingError, + Pointer(SDL_ModState = KMOD_LSHIFT), true); + end else - SaveSong(CurrentSong, Lines[0], CurrentSong.Path + CurrentSong.FileName, false); - - {if SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL + KMOD_LALT then - // Save Song - SaveSongDebug(CurrentSong, Lines[0], 'C:\song.asm', false);} - + begin + ScreenPopupError.ShowPopup(Language.Translate('ERROR_SAVE_FILE_FAILED')); + end; Exit; end; - 'D': + Ord('D'): begin // Divide lengths by 2 DivideBPM; Exit; end; - 'M': + Ord('M'): begin // Multiply lengths by 2 MultiplyBPM; Exit; end; - 'C': + Ord('C'): begin // Capitalize letter at the beginning of line if SDL_ModState = 0 then @@ -201,7 +238,7 @@ begin Exit; end; - 'V': + Ord('V'): begin // Paste text if SDL_ModState = KMOD_LCTRL then @@ -217,13 +254,13 @@ begin CopySentence(CopySrc, Lines[0].Current); end; end; - 'T': + Ord('T'): begin // Fixes timings between sentences FixTimings; Exit; end; - 'P': + Ord('P'): begin if SDL_ModState = 0 then begin @@ -269,8 +306,8 @@ begin Exit; end; - // Golden Note Patch - 'G': + // Golden Note + Ord('G'): begin if (Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType = ntGolden) then Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal @@ -280,8 +317,8 @@ begin Exit; end; - // Freestyle Note Patch - 'F': + // Freestyle Note + Ord('F'): begin if (Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType = ntFreestyle) then Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal @@ -580,10 +617,11 @@ begin // skip to next sentence if SDL_ModState = 0 then - begin {$IFDEF UseMIDIPort} + begin + {$IFDEF UseMIDIPort} MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); PlaySentenceMidi := false; - {$endif} + {$ENDIF} Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; Inc(Lines[0].Current); @@ -642,7 +680,7 @@ begin end; // if end; -function TScreenEditSub.ParseInputEditText(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; +function TScreenEditSub.ParseInputEditText(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; var SDL_ModState: word; begin @@ -653,7 +691,16 @@ begin + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT {+ KMOD_CAPS}); if (PressedDown) then - begin // Key Down + begin + // check normal keys + if (IsPrintableChar(CharCode)) then + begin + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text := + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text + UCS4ToUTF8String(CharCode); + Exit; + end; + + // check special keys case PressedKey of SDLK_ESCAPE: @@ -665,15 +712,10 @@ 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 - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text := - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text + CharCode; - end; SDLK_BACKSPACE: begin - Delete(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text, - Length(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text), 1); + UTF8Delete(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text, + LengthUTF8(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text), 1); end; SDLK_RIGHT: begin @@ -758,9 +800,11 @@ var S: string; begin // temporary -{ for C := 0 to Lines[0].High do + { + for C := 0 to Lines[0].High do for N := 0 to Lines[0].Line[C].HighNut do - Lines[0].Line[C].Note[N].Text := AnsiLowerCase(Lines[0].Line[C].Note[N].Text);} + Lines[0].Line[C].Note[N].Text := UTF8LowerCase(Lines[0].Line[C].Note[N].Text); + } for C := 0 to Lines[0].High do begin @@ -1085,14 +1129,16 @@ var N: integer; NHigh: integer; begin -{ C := Lines[0].Current; + { + C := Lines[0].Current; for N := Lines[0].Line[C].HighNut downto 1 do begin Lines[0].Line[C].Note[N].Text := Lines[0].Line[C].Note[N-1].Text; end; // for - Lines[0].Line[C].Note[0].Text := '- ';} + Lines[0].Line[C].Note[0].Text := '- '; + } C := Lines[0].Current; NHigh := Lines[0].Line[C].HighNote; @@ -1233,21 +1279,24 @@ begin end; -procedure TScreenEditSub.onShow; +procedure TScreenEditSub.OnShow; +var + FileExt: IPath; begin inherited; - Log.LogStatus('Initializing', 'TEditScreen.onShow'); + Log.LogStatus('Initializing', 'TEditScreen.OnShow'); Lyric := TEditorLyrics.Create; ResetSingTemp; try - //Check if File is XML - if copy(CurrentSong.FileName,length(CurrentSong.FileName)-3,4) = '.xml' then - Error := not CurrentSong.LoadXMLSong() - else - Error := not CurrentSong.LoadSong(); + //Check if File is XML + FileExt := CurrentSong.FileName.GetExtension; + if FileExt.ToUTF8 = '.xml' then + Error := not CurrentSong.LoadXMLSong() + else + Error := not CurrentSong.LoadSong(); except Error := true; end; @@ -1269,12 +1318,12 @@ begin {$ENDIF} Text[TextTitle].Text := CurrentSong.Title; Text[TextArtist].Text := CurrentSong.Artist; - Text[TextMp3].Text := CurrentSong.Mp3; + Text[TextMp3].Text := CurrentSong.Mp3.ToUTF8; Lines[0].Current := 0; CurrentNote := 0; Lines[0].Line[0].Note[0].Color := 1; - AudioPlayback.Open(CurrentSong.Path + CurrentSong.Mp3); + AudioPlayback.Open(CurrentSong.Path.Append(CurrentSong.Mp3)); //Set Down Music Volume for Better hearability of Midi Sounds //Music.SetVolume(0.4); @@ -1412,7 +1461,7 @@ begin Result := true; end; -procedure TScreenEditSub.onHide; +procedure TScreenEditSub.OnHide; begin {$IFDEF UseMIDIPort} MidiOut.Close; -- cgit v1.2.3 From ec75bc2b03e707c479f3605ffc1a8d9fe38c165b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 17 Nov 2009 15:25:54 +0000 Subject: header tags that are not supported are written to the end of the songheader when saving in editor fixed header reader ending in infinite loop when there is a header line w/o Colon git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1943 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 00e62c16..04407005 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1296,7 +1296,12 @@ begin if FileExt.ToUTF8 = '.xml' then Error := not CurrentSong.LoadXMLSong() else - Error := not CurrentSong.LoadSong(); + begin + // reread header with custom tags + Error := not CurrentSong.Analyse(true); + if not Error then + Error := not CurrentSong.LoadSong; + end; except Error := true; end; -- cgit v1.2.3 From 735a5b67345e2888de89d89b4f31b4d48c06f9ec Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 24 Nov 2009 20:04:01 +0000 Subject: use second players color to indicate selected note in editor git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1960 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 04407005..609a689b 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -503,11 +503,11 @@ begin // right if SDL_ModState = 0 then begin - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Inc(CurrentNote); if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then CurrentNote := 0; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.Selected := CurrentNote; end; @@ -558,11 +558,11 @@ begin // left if SDL_ModState = 0 then begin - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Dec(CurrentNote); if CurrentNote = -1 then CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.Selected := CurrentNote; end; @@ -623,12 +623,12 @@ begin PlaySentenceMidi := false; {$ENDIF} - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Inc(Lines[0].Current); CurrentNote := 0; if Lines[0].Current > Lines[0].High then Lines[0].Current := 0; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.AddLine(Lines[0].Current); Lyric.Selected := 0; @@ -655,12 +655,12 @@ begin PlaySentenceMidi := false; {$endif} - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Dec(Lines[0].Current); CurrentNote := 0; if Lines[0].Current = -1 then Lines[0].Current := Lines[0].High; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.AddLine(Lines[0].Current); Lyric.Selected := 0; @@ -722,11 +722,11 @@ begin // right if SDL_ModState = 0 then begin - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Inc(CurrentNote); if CurrentNote > Lines[0].Line[Lines[0].Current].HighNote then CurrentNote := 0; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.Selected := CurrentNote; end; end; @@ -735,11 +735,11 @@ begin // left if SDL_ModState = 0 then begin - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 0; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; Dec(CurrentNote); if CurrentNote = -1 then CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.Selected := CurrentNote; end; end; @@ -960,7 +960,7 @@ begin Lines[0].Current := Lines[0].Current + 1; CurrentNote := 0; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.AddLine(Lines[0].Current); end; @@ -1023,7 +1023,7 @@ begin Inc(Note[CurrentNote+1].Start); Dec(Note[CurrentNote+1].Length); Note[CurrentNote+1].Text := '- '; - Note[CurrentNote+1].Color := 0; + Note[CurrentNote+1].Color := 1; end; end; @@ -1053,7 +1053,7 @@ begin if CurrentNote > Lines[0].Line[C].HighNote then Dec(CurrentNote); - Lines[0].Line[C].Note[CurrentNote].Color := 1; + Lines[0].Line[C].Note[CurrentNote].Color := 2; end //Last Note of current Sentence Deleted - > Delete Sentence else @@ -1073,7 +1073,7 @@ begin else Lines[0].Current := 0; - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 1; + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; end; end; end; @@ -1327,7 +1327,7 @@ begin Lines[0].Current := 0; CurrentNote := 0; - Lines[0].Line[0].Note[0].Color := 1; + Lines[0].Line[0].Note[0].Color := 2; AudioPlayback.Open(CurrentSong.Path.Append(CurrentSong.Mp3)); //Set Down Music Volume for Better hearability of Midi Sounds //Music.SetVolume(0.4); -- cgit v1.2.3 From b17406af2d096cb1db7eb193118dff0c48f4761b Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Tue, 22 Dec 2009 18:56:20 +0000 Subject: fix: divide sentence in editor leaded to crash update of authors.txt and copyright.txt git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2053 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 609a689b..10584ce8 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -934,7 +934,7 @@ begin begin Inc(HighNote); SetLength(Note, HighNote + 1); - Note[HighNote] := Note[N]; + Note[HighNote] := Lines[0].Line[CStart].Note[N]; End_ := Note[HighNote].Start + Note[HighNote].Length; if Note[HighNote].Tone < BaseNote then -- cgit v1.2.3 From fe89b3386a77be606a54128af3a5a55250691554 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 14 Mar 2010 19:27:47 +0000 Subject: editor: changed design, added infobar, changed key-mapping git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2194 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 332 ++++++++++++++++++++++++++++++++++------- 1 file changed, 274 insertions(+), 58 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 10584ce8..3e7bd134 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -56,6 +56,7 @@ uses type TScreenEditSub = class(TMenu) private + AktBeat: integer; //Variable is True if no Song is loaded Error: boolean; @@ -110,6 +111,8 @@ type procedure PasteText; procedure CopySentence(Src, Dst: integer); procedure CopySentences(Src, Dst, Num: integer); + procedure DrawStatics; + procedure DrawInfoBar(x, y, w, h: integer); //Note Name Mod function GetNoteName(Note: integer): string; public @@ -184,13 +187,13 @@ begin if (PressedDown) then // Key Down begin // check normal keys - case UCS4UpperCase(CharCode) of - Ord('Q'): + case PressedKey of + SDLK_Q: begin Result := false; Exit; end; - Ord('S'): + SDLK_S: begin // Save Song SResult := SaveSong(CurrentSong, Lines[0], CurrentSong.Path.Append(CurrentSong.FileName), @@ -210,19 +213,25 @@ begin end; Exit; end; - Ord('D'): + SDLK_D: begin // Divide lengths by 2 - DivideBPM; - Exit; + if (SDL_ModState = KMOD_LSHIFT) then + begin + DivideBPM; + Exit; + end; end; - Ord('M'): + SDLK_M: begin // Multiply lengths by 2 - MultiplyBPM; - Exit; + if (SDL_ModState = KMOD_LSHIFT) then + begin + MultiplyBPM; + Exit; + end; end; - Ord('C'): + SDLK_C: begin // Capitalize letter at the beginning of line if SDL_ModState = 0 then @@ -238,7 +247,7 @@ begin Exit; end; - Ord('V'): + SDLK_V: begin // Paste text if SDL_ModState = KMOD_LCTRL then @@ -254,13 +263,13 @@ begin CopySentence(CopySrc, Lines[0].Current); end; end; - Ord('T'): + SDLK_T: begin // Fixes timings between sentences FixTimings; Exit; end; - Ord('P'): + SDLK_P: begin if SDL_ModState = 0 then begin @@ -307,7 +316,7 @@ begin end; // Golden Note - Ord('G'): + SDLK_G: begin if (Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType = ntGolden) then Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal @@ -318,7 +327,7 @@ begin end; // Freestyle Note - Ord('F'): + SDLK_F: begin if (Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType = ntFreestyle) then Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal @@ -761,15 +770,17 @@ procedure TScreenEditSub.DivideBPM; var C: integer; N: integer; -begin + +begin CurrentSong.BPM[0].BPM := CurrentSong.BPM[0].BPM / 2; + for C := 0 to Lines[0].High do begin Lines[0].Line[C].Start := Lines[0].Line[C].Start div 2; Lines[0].Line[C].End_ := Lines[0].Line[C].End_ div 2; for N := 0 to Lines[0].Line[C].HighNote do begin - Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start div 2; + Lines[0].Line[C].Note[N].Start := Lines[0].Line[C].Note[N].Start div 2; Lines[0].Line[C].Note[N].Length := Round(Lines[0].Line[C].Note[N].Length / 2); end; // N end; // C @@ -1227,55 +1238,258 @@ begin CopySentence(Src + C, Dst + C); end; +procedure TScreenEditSub.DrawStatics; +var + x, y, w, h: Integer; +begin + //Theme: + //bg + glDisable(GL_BLEND); + + x := 0; + y := 0; + w := 800; + h := 600; + glColor4f(0.3, 0.5, 0.6, 1); + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + // Line + glColor4f(0.9, 0.9, 0.9, 1); + x := 20; + y := 5; + w := 200; + h := 40; + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + // Note + x := 260; + y := 5; + w := 200; + h := 40; + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + // some borders + x := 20; + y := 55; + w := 760; + h := 236; + glColor4f(0.9, 0.9, 0.9, 1); + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + glColor4f(0, 0, 0, 1); + glLineWidth(2); + glBegin(GL_LINE_LOOP); + glVertex2f(x-1, y-1); + glVertex2f(x+w+1, y-1); + glVertex2f(x+w+1, y+h+1); + glVertex2f(x-1, y+h+1); + glEnd; + + x := 20; + y := 305; + w := 760; + h := 135; + glColor4f(0.9, 0.9, 0.9, 1); + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + glColor4f(0, 0, 0, 1); + glLineWidth(2); + glBegin(GL_LINE_LOOP); + glVertex2f(x-1, y-1); + glVertex2f(x+w+1, y-1); + glVertex2f(x+w+1, y+h+1); + glVertex2f(x-1, y+h+1); + glEnd; + + x := 20; + y := 500; + w := 760; + h := 40; + glColor4f(0.9, 0.9, 0.9, 1); + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + glColor4f(0, 0, 0, 1); + glLineWidth(2); + glBegin(GL_LINE_LOOP); + glVertex2f(x-1, y-1); + glVertex2f(x+w+1, y-1); + glVertex2f(x+w+1, y+h+1); + glVertex2f(x-1, y+h+1); + glEnd; + + glLineWidth(1); +end; + +procedure TScreenEditSub.DrawInfoBar(x, y, w, h: integer); +var + start, end_: integer; + ww: integer; + + pos: real; + br: real; + + line, note: integer; + numLines, numNotes: integer; + +begin + numLines := Length(Lines[0].Line); + + if(numLines=0) then + Exit; + + start := Lines[0].Line[0].Start; + end_ := Lines[0].Line[numLines-1].End_; + ww := end_ - start; + + glColor4f(0, 0, 0, 1); + glDisable(GL_BLEND); + glLineWidth(2); + glBegin(GL_LINE_LOOP); + glVertex2f(x-1, y-1); + glVertex2f(x+w+1, y-1); + glVertex2f(x+w+1, y+h+1); + glVertex2f(x-1, y+h+1); + glEnd; + + glColor4f(0.9, 0.9, 0.9, 1); + glbegin(gl_quads); + glVertex2f(x, y); + glVertex2f(x, y+h); + glVertex2f(x+w, y+h); + glVertex2f(x+w, y); + glEnd; + + + for line := 0 to numLines - 1 do + begin + if (line = Lines[0].Current) and not (PlaySentence or PlaySentenceMidi) then + glColor4f(0.4, 0.4, 0, 1) + else + glColor4f(1, 0.6, 0, 1); + + + start := Lines[0].Line[line].Note[0].Start; + end_ := Lines[0].Line[line].Note[Lines[0].Line[line].HighNote].Start+ + Lines[0].Line[line].Note[Lines[0].Line[line].HighNote].Length; + + pos := start/ww*w; + br := (end_-start)/ww*w; + + glbegin(gl_quads); + glVertex2f(x+pos, y); + glVertex2f(x+pos, y+h); + glVertex2f(x+pos+br, y+h); + glVertex2f(x+pos+br, y); + glEnd; + { + numNotes := Length(Lines[0].Line[line].Nuta); + + for note := 0 to numNotes - 1 do + begin + + end; } + end; + + if(PlaySentence or PlaySentenceMidi) then + begin + glColor4f(0, 0, 0, 0.5); + pos := 0; + br := AktBeat/ww*w; + if (br>w) then + br := w; + end else + begin + glColor4f(1, 0, 0, 1); + pos := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start/ww*w; + br := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length/ww*w; + if (br<1) then + br := 1; + end; + + glEnable(GL_BLEND); + glbegin(gl_quads); + glVertex2f(x+pos, y); + glVertex2f(x+pos, y+h); + glVertex2f(x+pos+br, y+h); + glVertex2f(x+pos+br, y); + glEnd; + glDisable(GL_BLEND); + + glLineWidth(1); +end; + constructor TScreenEditSub.Create; begin inherited Create; SetLength(Player, 1); // line - AddStatic(20, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), TEXTURE_TYPE_COLORIZED); - AddText(40, 17, 1, 18, 1, 1, 1, 'Line'); - TextSentence := AddText(120, 14, 1, 24, 0, 0, 0, '0 / 0'); + AddText(40, 14, 1, 24, 0, 0, 0, 'Line:'); + TextSentence := AddText(110, 14, 1, 24, 0, 0, 0, '0 / 0'); + // Note - AddStatic(220, 10, 80, 30, 0, 0, 0, Skin.GetTextureFileName('ButtonF'), TEXTURE_TYPE_COLORIZED); - AddText(242, 17, 1, 18, 1, 1, 1, 'Note'); - TextNote := AddText(320, 14, 1, 24, 0, 0, 0, '0 / 0'); + AddText(282, 14, 1, 24, 0, 0, 0, 'Note:'); + TextNote := AddText(360, 14, 1, 24, 0, 0, 0, '0 / 0'); // file info - AddStatic(150, 50, 500, 150, 0, 0, 0, Skin.GetTextureFileName('MainBar'), TEXTURE_TYPE_COLORIZED); - AddStatic(151, 52, 498, 146, 1, 1, 1, Skin.GetTextureFileName('MainBar'), TEXTURE_TYPE_COLORIZED); - AddText(180, 65, 0, 24, 0, 0, 0, 'Title:'); - AddText(180, 90, 0, 24, 0, 0, 0, 'Artist:'); - AddText(180, 115, 0, 24, 0, 0, 0, 'Mp3:'); - AddText(180, 140, 0, 24, 0, 0, 0, 'BPM:'); - AddText(180, 165, 0, 24, 0, 0, 0, 'GAP:'); - - TextTitle := AddText(250, 65, 0, 24, 0, 0, 0, 'a'); - TextArtist := AddText(250, 90, 0, 24, 0, 0, 0, 'b'); - TextMp3 := AddText(250, 115, 0, 24, 0, 0, 0, 'c'); - TextBPM := AddText(250, 140, 0, 24, 0, 0, 0, 'd'); - TextGAP := AddText(250, 165, 0, 24, 0, 0, 0, 'e'); - -{ AddInteraction(2, TextTitle); - AddInteraction(2, TextArtist); - AddInteraction(2, TextMp3); - AddInteraction(2, TextBPM); - AddInteraction(2, TextGAP);} + AddText(30, 65, 0, 24, 0, 0, 0, 'Title:'); + AddText(30, 90, 0, 24, 0, 0, 0, 'Artist:'); + AddText(30, 115, 0, 24, 0, 0, 0, 'Mp3:'); + AddText(30, 140, 0, 24, 0, 0, 0, 'BPM:'); + AddText(30, 165, 0, 24, 0, 0, 0, 'GAP:'); + + TextTitle := AddText(180, 65, 0, 24, 0, 0, 0, 'a'); + TextArtist := AddText(180, 90, 0, 24, 0, 0, 0, 'b'); + TextMp3 := AddText(180, 115, 0, 24, 0, 0, 0, 'c'); + TextBPM := AddText(180, 140, 0, 24, 0, 0, 0, 'd'); + TextGAP := AddText(180, 165, 0, 24, 0, 0, 0, 'e'); // note info - AddText(20, 190, 0, 24, 0, 0, 0, 'Start:'); - AddText(20, 215, 0, 24, 0, 0, 0, 'Duration:'); - AddText(20, 240, 0, 24, 0, 0, 0, 'Tone:'); - AddText(20, 265, 0, 24, 0, 0, 0, 'Text:'); + AddText(30, 190, 0, 24, 0, 0, 0, 'Start:'); + AddText(30, 215, 0, 24, 0, 0, 0, 'Duration:'); + AddText(30, 240, 0, 24, 0, 0, 0, 'Tone:'); + AddText(30, 265, 0, 24, 0, 0, 0, 'Text:'); //AddText(500, 265, 0, 8, 0, 0, 0, 'VideoGap:'); + + TextNStart := AddText(180, 190, 0, 24, 0, 0, 0, 'a'); + TextNLength := AddText(180, 215, 0, 24, 0, 0, 0, 'b'); + TextNTon := AddText(180, 240, 0, 24, 0, 0, 0, 'c'); + TextNText := AddText(180, 265, 0, 24, 0, 0, 0, 'd'); - TextNStart := AddText(120, 190, 0, 24, 0, 0, 0, 'a'); - TextNLength := AddText(120, 215, 0, 24, 0, 0, 0, 'b'); - TextNTon := AddText(120, 240, 0, 24, 0, 0, 0, 'c'); - TextNText := AddText(120, 265, 0, 24, 0, 0, 0, 'd'); + //TextVideoGap := AddText(600, 265, 0, 24, 0, 0, 0, 'e'); // debug - TextDebug := AddText(30, 550, 0, 8, 0, 0, 0, ''); + TextDebug := AddText(30, 550, 0, 27, 0, 0, 0, ''); end; @@ -1358,8 +1572,8 @@ end; function TScreenEditSub.Draw: boolean; var Pet: integer; - AktBeat: integer; begin + glClearColor(1,1,1,1); // midi music @@ -1449,15 +1663,17 @@ begin Text[TextNText].Text := Text[TextNText].Text + '|'; // draw static menu - inherited Draw; - + DrawStatics; + DrawInfoBar(20, 460, 760, 20); + //inherited Draw; + DrawFG; // draw notes - SingDrawNoteLines(20, 300, 780, 15); + SingDrawNoteLines(20, 305, 780, 15); //Error Drawing when no Song is loaded if not Error then begin - SingDrawBeatDelimeters(40, 300, 760, 0); - EditDrawLine(40, 405, 760, 0, 15); + SingDrawBeatDelimeters(40, 305, 760, 0); + EditDrawLine(40, 410, 760, 0, 15); end; // draw text @@ -1517,4 +1733,4 @@ begin end; end; -end. +end. \ No newline at end of file -- cgit v1.2.3 From db313885eef67372bcbbca56173755f39b40ecfa Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 14 Mar 2010 20:01:10 +0000 Subject: editor: changed TextEditMode and some other improvements git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2196 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 44 +++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 3e7bd134..d15f2b19 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -91,6 +91,7 @@ type MidiLastNote: integer; TextEditMode: boolean; + editText: UTF8String; //backup of current text in text-edit-mode Lyric: TEditorLyrics; @@ -200,7 +201,8 @@ begin (SDL_ModState = KMOD_LSHIFT)); if (SResult = ssrOK) then begin - ScreenPopupInfo.ShowPopup(Language.Translate('INFO_FILE_SAVED')); + //ScreenPopupInfo.ShowPopup(Language.Translate('INFO_FILE_SAVED')); + Text[TextDebug].Text := Language.Translate('INFO_FILE_SAVED'); end else if (SResult = ssrEncodingError) then begin @@ -213,6 +215,20 @@ begin end; Exit; end; + + SDLK_R: //reload + begin + AudioPlayback.Stop; + {$IFDEF UseMIDIPort} + MidiOut.Close; + MidiOut.Free; + {$ENDIF} + Lyric.Free; + + onShow; + Text[TextDebug].Text := 'song reloaded'; //TODO: Language.Translate('SONG_RELOADED'); + end; + SDLK_D: begin // Divide lengths by 2 @@ -470,6 +486,7 @@ begin SDLK_F4: begin // Enter Text Edit Mode + editText := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text; TextEditMode := true; end; @@ -706,15 +723,20 @@ begin begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text + UCS4ToUTF8String(CharCode); + + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := CurrentNote; Exit; end; // check special keys case PressedKey of - SDLK_ESCAPE: begin - FadeTo(@ScreenSong); + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text := editText; + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := CurrentNote; + TextEditMode := false; end; SDLK_F4, SDLK_RETURN: begin @@ -725,6 +747,8 @@ begin begin UTF8Delete(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text, LengthUTF8(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text), 1); + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := CurrentNote; end; SDLK_RIGHT: begin @@ -737,6 +761,7 @@ begin CurrentNote := 0; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.Selected := CurrentNote; + editText := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text; end; end; SDLK_LEFT: @@ -750,6 +775,7 @@ begin CurrentNote := Lines[0].Line[Lines[0].Current].HighNote; Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; Lyric.Selected := CurrentNote; + editText := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text; end; end; end; @@ -1454,13 +1480,13 @@ begin SetLength(Player, 1); // line - AddText(40, 14, 1, 24, 0, 0, 0, 'Line:'); - TextSentence := AddText(110, 14, 1, 24, 0, 0, 0, '0 / 0'); + AddText(40, 11, 1, 30, 0, 0, 0, 'Line:'); + TextSentence := AddText(110, 11, 1, 30, 0, 0, 0, '0 / 0'); // Note - AddText(282, 14, 1, 24, 0, 0, 0, 'Note:'); - TextNote := AddText(360, 14, 1, 24, 0, 0, 0, '0 / 0'); + AddText(282, 11, 1, 30, 0, 0, 0, 'Note:'); + TextNote := AddText(360, 11, 1, 30, 0, 0, 0, '0 / 0'); // file info AddText(30, 65, 0, 24, 0, 0, 0, 'Title:'); @@ -1499,6 +1525,10 @@ var begin inherited; + AudioPlayback.Stop; + PlaySentence := false; + PlaySentenceMidi := false; + Log.LogStatus('Initializing', 'TEditScreen.OnShow'); Lyric := TEditorLyrics.Create; -- cgit v1.2.3 From e00075a45818a861c61416832985c316227dd420 Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 14 Mar 2010 20:06:21 +0000 Subject: editor: deleted old midi debug entry git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2197 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index d15f2b19..6e9cbebf 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1561,8 +1561,6 @@ begin 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 := CurrentSong.Title; -- cgit v1.2.3 From 78a47758dba94287de090a0721d2f138f7a055b8 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 19 May 2010 13:05:12 +0000 Subject: reimplemented missing single note midi playback (Shift + Space) and single note mp3 + midi playback (CTRL + Shift + Space) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2385 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 6e9cbebf..7956b127 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -492,17 +492,34 @@ begin SDLK_SPACE: begin - // Play Sentence - PlaySentenceMidi := false; // stop midi - PlaySentence := true; - Click := false; - AudioPlayback.Stop; - AudioPlayback.Position := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); - PlayStopTime := (GetTimeFromBeat( - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start + - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length)); - AudioPlayback.Play; - LastClick := -100; + if (SDL_ModState = 0) or (SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL) then + begin + // Play Sentence + PlaySentenceMidi := false; // stop midi + PlaySentence := true; + Click := false; + AudioPlayback.Stop; + AudioPlayback.Position := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + PlayStopTime := (GetTimeFromBeat( + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length)); + AudioPlayback.Play; + LastClick := -100; + end; + + if (SDL_ModState = KMOD_LSHIFT) or (SDL_ModState = KMOD_LSHIFT or KMOD_LCTRL) then + begin + // Play Midi + PlaySentenceMidi := true; + + MidiTime := USTime.GetTime; + MidiStart := GetTimeFromBeat(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + MidiStop := GetTimeFromBeat( + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + + LastClick := -100; + end; end; SDLK_RETURN: -- cgit v1.2.3 From 8e8d377291ba226116fe82141f955c8d07dfbcdb Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 10 Jun 2010 20:01:52 +0000 Subject: changes to divide note - split note in the center - use "~" instead of dash as lyrics for the new note - update lyric display after split git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2479 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 7956b127..425036b0 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1072,13 +1072,21 @@ begin Note[N] := Note[N-1]; end; - // me slightly modify new note - Note[CurrentNote].Length := 1; - Inc(Note[CurrentNote+1].Start); - Dec(Note[CurrentNote+1].Length); - Note[CurrentNote+1].Text := '- '; + // Note[Cur] and Note[Cur + 1] is identical at this point + // modify first note + Note[CurrentNote].Length := Note[CurrentNote+1].Length div 2 + Note[CurrentNote+1].Length mod 2; + + // 2nd note + Note[CurrentNote+1].Start := Note[CurrentNote].Start + Note[CurrentNote].Length; + Note[CurrentNote+1].Length := Note[CurrentNote + 1].Length div 2; + + Note[CurrentNote+1].Text := '~'; Note[CurrentNote+1].Color := 1; end; + + // update lyric display + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := CurrentNote; end; procedure TScreenEditSub.DeleteNote; -- cgit v1.2.3 From ac102e54fc6f7232c9cace99bffeb2d79f7de86b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 11 Jun 2010 16:43:50 +0000 Subject: fix display bug after deleting last note of a line in editor Only delete sentence if there are at least 2 left git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2489 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 69 ++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 30 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 425036b0..7f664fc6 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -530,7 +530,7 @@ begin begin if SDL_ModState = KMOD_LCTRL then begin - // moves text to right in current sentence + // deletes current note DeleteNote; end; end; @@ -1097,9 +1097,8 @@ begin C := Lines[0].Current; //Do Not delete Last Note - if (Lines[0].High > 0) or (Lines[0].Line[C].HighNote > 0) then + if (Lines[0].Line[C].HighNote > 0) then begin - // we copy all notes from the next to the selected one for N := CurrentNote+1 to Lines[0].Line[C].HighNote do begin @@ -1107,37 +1106,47 @@ begin end; Dec(Lines[0].Line[C].HighNote); - if (Lines[0].Line[C].HighNote >= 0) then - begin - SetLength(Lines[0].Line[C].Note, Lines[0].Line[C].HighNote + 1); - // me slightly modify new note - if CurrentNote > Lines[0].Line[C].HighNote then - Dec(CurrentNote); - - Lines[0].Line[C].Note[CurrentNote].Color := 2; - end - //Last Note of current Sentence Deleted - > Delete Sentence - else + SetLength(Lines[0].Line[C].Note, Lines[0].Line[C].HighNote + 1); + + // last note was deleted + if (CurrentNote > Lines[0].Line[C].HighNote) then begin - //Move all Sentences after the current to the Left - for N := C+1 to Lines[0].High do - Lines[0].Line[N-1] := Lines[0].Line[N]; - - //Delete Last Sentence - SetLength(Lines[0].Line, Lines[0].High); - Lines[0].High := High(Lines[0].Line); - Lines[0].Number := Length(Lines[0].Line); - - CurrentNote := 0; - if (C > 0) then - Lines[0].Current := C - 1 - else - Lines[0].Current := 0; - - Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; + // select new last note + CurrentNote := Lines[0].Line[C].HighNote; + + // correct Line ending + with Lines[0].Line[C] do + End_ := Note[HighNote].Start + Note[HighNote].Length; end; + + Lines[0].Line[C].Note[CurrentNote].Color := 2; + end + // Last Note of current Sentence Deleted - > Delete Sentence + // if there are more than two left + else if (Lines[0].High > 1) then + begin + //Move all Sentences after the current to the Left + for N := C+1 to Lines[0].High do + Lines[0].Line[N-1] := Lines[0].Line[N]; + + //Delete Last Sentence + SetLength(Lines[0].Line, Lines[0].High); + Lines[0].High := High(Lines[0].Line); + Lines[0].Number := Length(Lines[0].Line); + + CurrentNote := 0; + if (C > 0) then + Lines[0].Current := C - 1 + else + Lines[0].Current := 0; + + Lines[0].Line[Lines[0].Current].Note[CurrentNote].Color := 2; end; + + // update lyric display + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := CurrentNote; end; procedure TScreenEditSub.TransposeNote(Transpose: integer); -- cgit v1.2.3 From 059a6898f9ab5069bd0bf5424b0590d1900325b3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 11 Jun 2010 17:03:18 +0000 Subject: fix display of "InfoBar" for songs whose first note doesn't start at beat zero git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2490 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index 7f664fc6..b3300a77 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -1413,6 +1413,7 @@ end; procedure TScreenEditSub.DrawInfoBar(x, y, w, h: integer); var start, end_: integer; + SongStart, SongEnd: integer; ww: integer; pos: real; @@ -1427,9 +1428,9 @@ begin if(numLines=0) then Exit; - start := Lines[0].Line[0].Start; - end_ := Lines[0].Line[numLines-1].End_; - ww := end_ - start; + SongStart := Lines[0].Line[0].Note[0].Start; + SongEnd := Lines[0].Line[numLines-1].End_; + ww := SongEnd - SongStart; glColor4f(0, 0, 0, 1); glDisable(GL_BLEND); @@ -1462,7 +1463,7 @@ begin end_ := Lines[0].Line[line].Note[Lines[0].Line[line].HighNote].Start+ Lines[0].Line[line].Note[Lines[0].Line[line].HighNote].Length; - pos := start/ww*w; + pos := (start - SongStart)/ww*w; br := (end_-start)/ww*w; glbegin(gl_quads); @@ -1484,13 +1485,13 @@ begin begin glColor4f(0, 0, 0, 0.5); pos := 0; - br := AktBeat/ww*w; + br := (AktBeat - SongStart)/ww*w; if (br>w) then br := w; end else begin glColor4f(1, 0, 0, 1); - pos := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start/ww*w; + pos := (Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start - SongStart)/ww*w; br := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length/ww*w; if (br<1) then br := 1; -- cgit v1.2.3 From 71e640f2d6707821a90bb91e6de38a2bc37d52a8 Mon Sep 17 00:00:00 2001 From: tobigun Date: Fri, 11 Jun 2010 22:21:51 +0000 Subject: use MidiCons: use MIDI_NOTEOFF/NOTEON constants instead of cryptic hex-numbers git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2493 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index b3300a77..ea80d778 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -50,6 +50,7 @@ uses gl, {$IFDEF UseMIDIPort} MidiOut, + MidiCons, {$ENDIF} UThemes; @@ -662,7 +663,9 @@ begin if SDL_ModState = 0 then begin {$IFDEF UseMIDIPort} - MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); + MidiOut.PutShort(MIDI_NOTEOFF or 1, + Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, + 127); PlaySentenceMidi := false; {$ENDIF} @@ -694,7 +697,9 @@ begin if SDL_ModState = 0 then begin {$IFDEF UseMIDIPort} - MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); + MidiOut.PutShort(MIDI_NOTEOFF or 1, + Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, + 127); PlaySentenceMidi := false; {$endif} @@ -1472,13 +1477,6 @@ begin glVertex2f(x+pos+br, y+h); glVertex2f(x+pos+br, y); glEnd; - { - numNotes := Length(Lines[0].Line[line].Nuta); - - for note := 0 to numNotes - 1 do - begin - - end; } end; if(PlaySentence or PlaySentenceMidi) then @@ -1628,7 +1626,7 @@ begin end; -// Interaction := 0; + //Interaction := 0; TextEditMode := false; end; @@ -1648,7 +1646,9 @@ begin // stop the music if (MidiPos > MidiStop) then begin - MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, 127); + MidiOut.PutShort(MIDI_NOTEOFF or 1, + Lines[0].Line[Lines[0].Current].Note[MidiLastNote].Tone + 60, + 127); PlaySentenceMidi := false; end; {$ENDIF} @@ -1666,8 +1666,14 @@ begin LastClick := AktBeat; {$IFDEF UseMIDIPort} if Pet > 0 then - MidiOut.PutShort($81, Lines[0].Line[Lines[0].Current].Note[Pet-1].Tone + 60, 127); - MidiOut.PutShort($91, Lines[0].Line[Lines[0].Current].Note[Pet].Tone + 60, 127); + begin + MidiOut.PutShort(MIDI_NOTEOFF or 1, + Lines[0].Line[Lines[0].Current].Note[Pet-1].Tone + 60, + 127); + end; + MidiOut.PutShort(MIDI_NOTEON or 1, + Lines[0].Line[Lines[0].Current].Note[Pet].Tone + 60, + 127); MidiLastNote := Pet; {$ENDIF} @@ -1688,7 +1694,7 @@ begin // click if (Click) and (PlaySentence) then begin -// AktBeat := Floor(CurrentSong.BPM[0].BPM * (Music.Position - CurrentSong.GAP / 1000) / 60); + //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 @@ -1715,10 +1721,10 @@ begin if not Error then begin // Note info - Text[TextNStart].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); - Text[TextNLength].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); - Text[TextNTon].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone) + ' ( ' + GetNoteName(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone) + ' )'; - Text[TextNText].Text := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text; + Text[TextNStart].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); + Text[TextNLength].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); + Text[TextNTon].Text := IntToStr(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone) + ' ( ' + GetNoteName(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Tone) + ' )'; + Text[TextNText].Text := Lines[0].Line[Lines[0].Current].Note[CurrentNote].Text; end; // Text Edit Mode -- cgit v1.2.3 From a2e64c7366f8a726d3979eda17cf1480bfc1e685 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 14 Jun 2010 09:24:27 +0000 Subject: minor editor fix: update lyrics after toggling freestyle git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2523 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index ea80d778..afefbb5f 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -350,6 +350,10 @@ begin Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntNormal else Lines[0].Line[Lines[0].Current].Note[CurrentNote].NoteType := ntFreestyle; + + // update lyrics + Lyric.AddLine(Lines[0].Current); + Lyric.Selected := CurrentNote; Exit; end; -- cgit v1.2.3 From 3fdda014a70495b13bdda669af8d4880c999bb47 Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Thu, 8 Jul 2010 13:57:07 +0000 Subject: more consistent use of modifier key for moving notes and enables on macs, where CTRL does not work. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2575 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index afefbb5f..ee811a6a 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -687,7 +687,7 @@ begin end; // decrease tone - if SDL_ModState = KMOD_LCTRL then + if SDL_ModState = KMOD_LSHIFT then begin TransposeNote(-1); end; @@ -721,7 +721,7 @@ begin end; // increase tone - if SDL_ModState = KMOD_LCTRL then + if SDL_ModState = KMOD_LSHIFT then begin TransposeNote(1); end; -- cgit v1.2.3 From 1fac8d24a0b62ec7ee4ac128758015edd929033e Mon Sep 17 00:00:00 2001 From: k-m_schindler Date: Sun, 11 Jul 2010 22:44:50 +0000 Subject: enable editor keys for macosx changing start and end of notes. CTRL does not work. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2577 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenEditSub.pas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/screens/UScreenEditSub.pas') diff --git a/src/screens/UScreenEditSub.pas b/src/screens/UScreenEditSub.pas index ee811a6a..fb3f04ce 100644 --- a/src/screens/UScreenEditSub.pas +++ b/src/screens/UScreenEditSub.pas @@ -560,7 +560,7 @@ begin end; // ctrl + right - if SDL_ModState = KMOD_LCTRL then + if (SDL_ModState = KMOD_LCTRL) or (SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT) then begin if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then begin @@ -586,7 +586,7 @@ begin end; // alt + right - if SDL_ModState = KMOD_LALT then + if (SDL_ModState = KMOD_LALT) or (SDL_ModState = KMOD_LALT + KMOD_LSHIFT) then begin Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); if CurrentNote = Lines[0].Line[Lines[0].Current].HighNote then @@ -615,7 +615,7 @@ begin end; // ctrl + left - if SDL_ModState = KMOD_LCTRL then + if (SDL_ModState = KMOD_LCTRL) or (SDL_ModState = KMOD_LCTRL + KMOD_LSHIFT) then begin Dec(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Start); Inc(Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length); @@ -642,7 +642,7 @@ begin end; // alt + left - if SDL_ModState = KMOD_LALT then + if (SDL_ModState = KMOD_LALT) or (SDL_ModState = KMOD_LALT + KMOD_LSHIFT) then begin if Lines[0].Line[Lines[0].Current].Note[CurrentNote].Length > 1 then begin -- cgit v1.2.3