From 754d71a59b7d07a12c7e7d198b7fdc3c9e1bdc5e Mon Sep 17 00:00:00 2001 From: brunzelchen Date: Sun, 21 Feb 2010 21:28:52 +0000 Subject: moved and renamed DrawVolume to UDraw.DrawVolumeBar added volume control to score screen, top screen and jumpto menu fixed a bug with VocalRemover when pausing a song git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/1.0.1 Challenge MOD@2137 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/UDraw.pas | 64 +++++++++++++++++++++++-- Game/Code/Classes/UMusic.pas | 1 - Game/Code/Screens/UScreenPartyScore.pas | 3 ++ Game/Code/Screens/UScreenPopup.pas | 21 +------- Game/Code/Screens/UScreenScore.pas | 50 +++++++++++++++++-- Game/Code/Screens/UScreenSing.pas | 58 +++------------------- Game/Code/Screens/UScreenSingModi.pas | 2 +- Game/Code/Screens/UScreenSong.pas | 85 +++++---------------------------- Game/Code/Screens/UScreenSongJumpto.pas | 24 ++++++++++ Game/Code/Screens/UScreenSongMenu.pas | 2 +- Game/Code/Screens/UScreenTop.pas | 42 +++++++++++++++- 11 files changed, 195 insertions(+), 157 deletions(-) diff --git a/Game/Code/Classes/UDraw.pas b/Game/Code/Classes/UDraw.pas index 5b0a284c..d55448ad 100644 --- a/Game/Code/Classes/UDraw.pas +++ b/Game/Code/Classes/UDraw.pas @@ -30,6 +30,9 @@ procedure SingDrawLineBonus( const X, Y: Single; Color: TRGB; Alpha: Single; Tex //Draw Editor NoteLines procedure EditDrawCzesc(Left, Top, Right: real; NrCzesci: integer; Space: integer); +//Draw Volume Bar +procedure DrawVolumeBar(x, y, w, h: Real; Volume: Integer); + type TRecR = record @@ -1457,8 +1460,6 @@ var R: Real; G: Real; B: Real; - A: cardinal; - I: Integer; begin; @@ -1535,7 +1536,7 @@ end; //PhrasenBonus - Line Bonus Mod procedure SingDrawLineBonus( const X, Y: Single; Color: TRGB; Alpha: Single; Text: string; Age: Integer); var -Length, X2: Real; //Length of Text +Length: Real; //Length of Text Size: Integer; //Size of Popup begin if Alpha <> 0 then @@ -1711,5 +1712,62 @@ begin glcolor4f(1,1,1,1); end; +procedure DrawVolumeBar(x, y, w, h: Real; Volume: Integer); +const + step = 5; + +var + txt: PChar; + str: string; + I: integer; + num: integer; + +begin + num := round(100/step); + + for I := 1 to num do + begin + if (I<=round(Volume/step)) then + begin + glColor4f(0.0, 0.8, 0.0, 0.8); + glEnable(GL_BLEND); + glbegin(gl_quads); + glVertex2f(x+(I-1)*(w/num), y); + glVertex2f(x+(I-1)*(w/num), y+h); + glVertex2f(x+(I)*(w/num)-2, y+h); + glVertex2f(x+(I)*(w/num)-2, y); + glEnd; + glDisable(GL_BLEND); + end else + begin + glColor4f(0.7, 0.7, 0.7, 0.6); + glEnable(GL_BLEND); + glbegin(gl_quads); + glVertex2f(x+(I-1)*(w/num), y); + glVertex2f(x+(I-1)*(w/num), y+h); + glVertex2f(x+(I)*(w/num)-2, y+h); + glVertex2f(x+(I)*(w/num)-2, y); + glEnd; + glDisable(GL_BLEND); + end; + end; + + { + //print Text + str := IntToStr(MP3Volume)+ '%'; + + glColor4f(1, 1, 1, 1); + + h := 8; + SetFontStyle(1); + SetFontItalic(false); + SetFontSize(h); + w := glTextWidth(PChar(str)); + + SetFontPos (x+2, y+2); + txt := Addr(str[1]); + glPrint(txt); } +end; + end. diff --git a/Game/Code/Classes/UMusic.pas b/Game/Code/Classes/UMusic.pas index 33e182e3..942c8c81 100644 --- a/Game/Code/Classes/UMusic.pas +++ b/Game/Code/Classes/UMusic.pas @@ -521,7 +521,6 @@ procedure TMusic.Play; begin if Loaded then begin // MediaPlayer.Play; - DSP_VocalRemover:=0; if Loop then BASS_ChannelPlay(Bass, True); // start from beginning... actually bass itself does not loop, nor does this TMusic Class BASS_ChannelPlay(Bass, False); // for setting position before playing end; diff --git a/Game/Code/Screens/UScreenPartyScore.pas b/Game/Code/Screens/UScreenPartyScore.pas index fb6d6022..0979b3ba 100644 --- a/Game/Code/Screens/UScreenPartyScore.pas +++ b/Game/Code/Screens/UScreenPartyScore.pas @@ -162,6 +162,9 @@ begin if not Help.SetHelpID(ID) then Log.LogError('No Entry for Help-ID ' + ID + ' (ScreenPartyScore)'); + if Music.VocalRemoverActivated() then + Music.DisableVocalRemover; + //Get Maxscore MaxScore := 0; for I := 0 to ScreenSingModi.PlayerInfo.NumPlayers - 1 do diff --git a/Game/Code/Screens/UScreenPopup.pas b/Game/Code/Screens/UScreenPopup.pas index 5a8bacc7..417f59bb 100644 --- a/Game/Code/Screens/UScreenPopup.pas +++ b/Game/Code/Screens/UScreenPopup.pas @@ -56,8 +56,6 @@ type TScreenPopupHelp = class(TMenu) private - CurMenu: Byte; //Num of the cur. Shown Menu - TextsGFX: array of TResLine; msg: TTextResult; Rect: TRect; @@ -264,27 +262,15 @@ begin end; procedure TScreenPopupError.onHide; -var i: integer; begin end; procedure TScreenPopupError.ShowPopup(msg: String); -var i: integer; + begin Interaction := 0; //Reset Interaction Visible := True; //Set Visible -{ //dirty hack... Text[0] is invisible for some strange reason - for i:=1 to high(Text) do - if i-1 <= high(msg) then - begin - Text[i].Visible:=True; - Text[i].Text := msg[i-1]; - end - else - begin - Text[i].Visible:=False; - end;} Text[0].Text:=msg; Button[0].Visible := True; @@ -341,8 +327,6 @@ begin end; constructor TScreenPopupHelp.Create; -var - I: integer; begin inherited Create; @@ -355,8 +339,6 @@ end; function TScreenPopupHelp.Draw: boolean; var - msg: TTextResult; - I: integer; abs: real; begin inherited Draw; @@ -392,7 +374,6 @@ begin end; procedure TScreenPopupHelp.onHide; -var i: integer; begin end; diff --git a/Game/Code/Screens/UScreenScore.pas b/Game/Code/Screens/UScreenScore.pas index ce26b448..917e9d04 100644 --- a/Game/Code/Screens/UScreenScore.pas +++ b/Game/Code/Screens/UScreenScore.pas @@ -6,11 +6,18 @@ uses UMenu, SDL, SysUtils, UDisplay, UMusic, USongs, UThemes, ULCD, gl; type + THandler = record + changed: boolean; + change_time: real; + end; + TScreenScore = class(TMenu) const ID='ID_022'; //for help system public + MP3VolumeHandler: THandler; + TextArtist: integer; TextTitle: integer; @@ -59,7 +66,7 @@ type implementation {{$IFDEF TRANSLATE} -uses UGraphic, UScreenSong, UPartyM2, UMenuStatic, UTime, UMain, UIni, ULanguage, UHelp, ULog; +uses UGraphic, UDraw, UScreenSong, UPartyM2, UMenuStatic, UTime, UMain, UIni, ULanguage, UHelp, ULog; {{$ELSE}{ uses UGraphic, UScreenSong, UMenuStatic, UTime, UMain, UIni; {{$ENDIF} @@ -68,6 +75,30 @@ begin Result := true; If (PressedDown) Then begin case PressedKey of + //MP3-Volume Up + SDLK_PAGEUP: + begin + if (ScreenSong.MP3Volume<100) then + begin + ScreenSong.MP3Volume := ScreenSong.MP3Volume+5; + Music.SetMusicVolume(ScreenSong.MP3Volume); + end; + MP3VolumeHandler.changed := true; + MP3VolumeHandler.change_time := 0; + end; + + //MP3-Volume Down + SDLK_PAGEDOWN: + begin + if (ScreenSong.MP3Volume>0) then + begin + ScreenSong.MP3Volume := ScreenSong.MP3Volume-5; + Music.SetMusicVolume(ScreenSong.MP3Volume); + end; + MP3VolumeHandler.changed := true; + MP3VolumeHandler.change_time := 0; + end; + SDLK_TAB: begin ScreenPopupHelp.ShowPopup(); @@ -218,15 +249,15 @@ end; procedure TScreenScore.onShow; var P: integer; // player - PP: integer; // another player variable - S: string; I: integer; - Skip: integer; V: array[1..6] of boolean; // visibility array begin if not Help.SetHelpID(ID) then Log.LogError('No Entry for Help-ID ' + ID + ' (ScreenScore)'); + if Music.VocalRemoverActivated() then + Music.DisableVocalRemover; + // Singstar Fadeout := false; ActualRound:=0; @@ -324,6 +355,7 @@ begin LCD.WriteText(1, Ini.Name[0]); LCD.WriteText(2, 'Score: ' + Text[TextTotalScore[1]].Text); + MP3VolumeHandler.changed := false; StartPreview; end; @@ -337,8 +369,9 @@ var Item: integer; P: integer; - C: integer; begin + Item := 0; + P := 0; if PlayersPlay <= 3 then begin // only for 1 screen mode for P := 0 to PlayersPlay-1 do begin case PlayersPlay of @@ -376,6 +409,13 @@ begin end; inherited Draw; + + if MP3VolumeHandler.changed and (MP3VolumeHandler.change_time+TimeSkip<3) then + begin + MP3VolumeHandler.change_time := MP3VolumeHandler.change_time + TimeSkip; + DrawVolumeBar(10, 530, 780, 12, ScreenSong.MP3Volume); + end else + MP3VolumeHandler.changed := false; end; procedure TScreenScore.FillPlayer(Item, P: integer); diff --git a/Game/Code/Screens/UScreenSing.pas b/Game/Code/Screens/UScreenSing.pas index e7d2fec9..690f2b64 100644 --- a/Game/Code/Screens/UScreenSing.pas +++ b/Game/Code/Screens/UScreenSing.pas @@ -14,7 +14,7 @@ type TScreenSing = class(TMenu) const ID='ID_023'; //for help system - + protected paused: boolean; //Pause Mod PauseTime: Real; @@ -108,7 +108,6 @@ type procedure LoadNextSong; procedure UpdateMedleyStats(medley_end: boolean); procedure DrawMedleyCountdown(); - procedure DrawVolume; end; implementation @@ -336,6 +335,9 @@ begin if not Help.SetHelpID(ID) then Log.LogError('No Entry for Help-ID ' + ID + ' (ScreenSing)'); + if Music.VocalRemoverActivated() then + Music.DisableVocalRemover; + FadeOut := false; // 0.5.0: early 0.5.0 problems were by this line commented AspectHandler.changed := false; @@ -1357,59 +1359,11 @@ begin if MP3VolumeHandler.changed and (MP3VolumeHandler.change_time+TimeSkip<3) then begin MP3VolumeHandler.change_time := MP3VolumeHandler.change_time + TimeSkip; - DrawVolume; + DrawVolumeBar(10, 475, 782, 12, MP3Volume); end else MP3VolumeHandler.changed := false; end; - -procedure TScreenSing.DrawVolume(); -const - step = 5; - -var - txt: PChar; - w, h: real; - str: string; - x, y: real; - I: integer; - num: integer; - -begin - x := 10; - y := 475; - w := 782; - h := 12; - - num := round(100/step); - - for I := 1 to num do - begin - if (I<=round(MP3Volume/step)) then - begin - glColor4f(0.0, 0.8, 0.0, 0.8); - glEnable(GL_BLEND); - glbegin(gl_quads); - glVertex2f(x+(I-1)*(w/num), y); - glVertex2f(x+(I-1)*(w/num), y+h); - glVertex2f(x+(I)*(w/num)-2, y+h); - glVertex2f(x+(I)*(w/num)-2, y); - glEnd; - glDisable(GL_BLEND); - end else - begin - glColor4f(0.7, 0.7, 0.7, 0.6); - glEnable(GL_BLEND); - glbegin(gl_quads); - glVertex2f(x+(I-1)*(w/num), y); - glVertex2f(x+(I-1)*(w/num), y+h); - glVertex2f(x+(I)*(w/num)-2, y+h); - glVertex2f(x+(I)*(w/num)-2, y); - glEnd; - glDisable(GL_BLEND); - end; - end; -end; - + procedure TScreenSing.UpdateMedleyStats(medley_end: boolean); var len, num, I : integer; diff --git a/Game/Code/Screens/UScreenSingModi.pas b/Game/Code/Screens/UScreenSingModi.pas index 708d81ca..f1ab96e5 100644 --- a/Game/Code/Screens/UScreenSingModi.pas +++ b/Game/Code/Screens/UScreenSingModi.pas @@ -714,7 +714,7 @@ end; if MP3VolumeHandler.changed and (MP3VolumeHandler.change_time+TimeSkip<3) then begin MP3VolumeHandler.change_time := MP3VolumeHandler.change_time + TimeSkip; - DrawVolume; + DrawVolumeBar(10, 475, 782, 12, MP3Volume); end else MP3VolumeHandler.changed := false; end; diff --git a/Game/Code/Screens/UScreenSong.pas b/Game/Code/Screens/UScreenSong.pas index 8e8bf2ca..b4ccc795 100644 --- a/Game/Code/Screens/UScreenSong.pas +++ b/Game/Code/Screens/UScreenSong.pas @@ -3,7 +3,7 @@ unit UScreenSong; interface uses - UMenu, TextGL, SDL, UMusic, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, + UMenu, TextGL, SDL, UMusic, UDraw, UFiles, UTime, UDisplay, USongs, SysUtils, ULog, UThemes, UTexture, ULanguage, ULCD, ULight, UIni, UVideo; type @@ -164,7 +164,6 @@ type function getVisibleMedleyArr(MinS: TMedleySource): TVisArr; procedure StartMedley(num: integer; MinS: TMedleySource); procedure DrawAspect; - procedure DrawVolume; function PartyPlayedSong(SongNr: integer): boolean; function PartyPlayedMedley(SongNr: integer): boolean; @@ -180,7 +179,12 @@ uses UGraphic, UMain, Windows, USkins, UHelp, - UDLLManager, UDataBase, UParty, UPartyM2, UPlaylist, UScreenSongMenu; + UDLLManager, + UDataBase, + UParty, + UPartyM2, + UPlaylist, + UScreenSongMenu; // ***** Public methods ****** // function TScreenSong.SongSkipped(SongNr: integer): boolean; @@ -1760,6 +1764,9 @@ var I: Integer; begin + if Music.VocalRemoverActivated() then + Music.DisableVocalRemover; + if SongIndex<>Interaction then Music.Stop; @@ -2203,7 +2210,7 @@ begin if MP3VolumeHandler.changed and (MP3VolumeHandler.change_time+TimeSkip<3) then begin MP3VolumeHandler.change_time := MP3VolumeHandler.change_time + TimeSkip; - DrawVolume; + DrawVolumeBar(10, 530, 780, 12, MP3Volume); end else MP3VolumeHandler.changed := false; @@ -2250,70 +2257,6 @@ begin glPrint(txt); end; -procedure TScreenSong.DrawVolume(); -const - step = 5; - -var - txt: PChar; - w, h: real; - str: string; - x, y: real; - I: integer; - num: integer; - -begin - x := 10; - y := 530; - w := 780; - h := 12; - - num := round(100/step); - - for I := 1 to num do - begin - if (I<=round(MP3Volume/step)) then - begin - glColor4f(0.0, 0.8, 0.0, 0.8); - glEnable(GL_BLEND); - glbegin(gl_quads); - glVertex2f(x+(I-1)*(w/num), y); - glVertex2f(x+(I-1)*(w/num), y+h); - glVertex2f(x+(I)*(w/num)-2, y+h); - glVertex2f(x+(I)*(w/num)-2, y); - glEnd; - glDisable(GL_BLEND); - end else - begin - glColor4f(0.7, 0.7, 0.7, 0.6); - glEnable(GL_BLEND); - glbegin(gl_quads); - glVertex2f(x+(I-1)*(w/num), y); - glVertex2f(x+(I-1)*(w/num), y+h); - glVertex2f(x+(I)*(w/num)-2, y+h); - glVertex2f(x+(I)*(w/num)-2, y); - glEnd; - glDisable(GL_BLEND); - end; - end; - - { - //print Text - str := IntToStr(MP3Volume)+ '%'; - - glColor4f(1, 1, 1, 1); - - h := 8; - SetFontStyle(1); - SetFontItalic(false); - SetFontSize(h); - w := glTextWidth(PChar(str)); - - SetFontPos (x+2, y+2); - txt := Addr(str[1]); - glPrint(txt); } -end; - procedure TScreenSong.SelectNext; var Skip, Skip2: integer; @@ -2394,7 +2337,6 @@ end; procedure TScreenSong.SelectPrev; var Skip: integer; - I: integer; VS: Integer; begin VS := CatSongs.VisibleSongs; @@ -2510,6 +2452,7 @@ end; procedure TScreenSong.SkipTo(Target: Cardinal); // 0.5.0 var I: integer; + begin UnLoadDetailedCover; @@ -2523,9 +2466,6 @@ begin end; procedure TScreenSong.SkipTo2(Target: Cardinal); //new -var - I: integer; - begin UnLoadDetailedCover; @@ -2876,7 +2816,6 @@ end; procedure TScreenSong.SetJoker; var - txt: string; h, x, y: real; ptxt: pchar; begin diff --git a/Game/Code/Screens/UScreenSongJumpto.pas b/Game/Code/Screens/UScreenSongJumpto.pas index 0b643ebc..95610ee9 100644 --- a/Game/Code/Screens/UScreenSongJumpto.pas +++ b/Game/Code/Screens/UScreenSongJumpto.pas @@ -54,6 +54,30 @@ begin end; end; + //MP3-Volume Up + SDLK_PAGEUP: + begin + if (ScreenSong.MP3Volume<100) then + begin + ScreenSong.MP3Volume := ScreenSong.MP3Volume+5; + Music.SetMusicVolume(ScreenSong.MP3Volume); + end; + ScreenSong.MP3VolumeHandler.changed := true; + ScreenSong.MP3VolumeHandler.change_time := 0; + end; + + //MP3-Volume Down + SDLK_PAGEDOWN: + begin + if (ScreenSong.MP3Volume>0) then + begin + ScreenSong.MP3Volume := ScreenSong.MP3Volume-5; + Music.SetMusicVolume(ScreenSong.MP3Volume); + end; + ScreenSong.MP3VolumeHandler.changed := true; + ScreenSong.MP3VolumeHandler.change_time := 0; + end; + SDLK_TAB: begin ScreenPopupHelp.ShowPopup(); diff --git a/Game/Code/Screens/UScreenSongMenu.pas b/Game/Code/Screens/UScreenSongMenu.pas index d2bce394..ccf14978 100644 --- a/Game/Code/Screens/UScreenSongMenu.pas +++ b/Game/Code/Screens/UScreenSongMenu.pas @@ -82,7 +82,7 @@ begin ScreenPopupHelp.ShowPopup(); end; - //MP3-Volume Up + //MP3-Volume Up SDLK_PAGEUP: begin if (ScreenSong.MP3Volume<100) then diff --git a/Game/Code/Screens/UScreenTop.pas b/Game/Code/Screens/UScreenTop.pas index 340fe2ad..e74507b9 100644 --- a/Game/Code/Screens/UScreenTop.pas +++ b/Game/Code/Screens/UScreenTop.pas @@ -6,11 +6,18 @@ uses UMenu, SDL, SysUtils, UDisplay, UMusic, USongs, UThemes, ULCD, ModiSDK; type + THandler = record + changed: boolean; + change_time: real; + end; + TScreenTop = class(TMenu) const ID='ID_029'; //for help system public + MP3VolumeHandler: THandler; + TextLevel: integer; TextArtistTitle: integer; @@ -33,13 +40,37 @@ type implementation -uses UGraphic, UDataBase, UMain, UIni, UPartyM2, DateUtils, UHelp, ULog; +uses UGraphic, UDataBase, UDraw, UMain, UIni, UPartyM2, UTime, DateUtils, UHelp, ULog; function TScreenTop.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; begin Result := true; If (PressedDown) Then begin case PressedKey of + //MP3-Volume Up + SDLK_PAGEUP: + begin + if (ScreenSong.MP3Volume<100) then + begin + ScreenSong.MP3Volume := ScreenSong.MP3Volume+5; + Music.SetMusicVolume(ScreenSong.MP3Volume); + end; + MP3VolumeHandler.changed := true; + MP3VolumeHandler.change_time := 0; + end; + + //MP3-Volume Down + SDLK_PAGEDOWN: + begin + if (ScreenSong.MP3Volume>0) then + begin + ScreenSong.MP3Volume := ScreenSong.MP3Volume-5; + Music.SetMusicVolume(ScreenSong.MP3Volume); + end; + MP3VolumeHandler.changed := true; + MP3VolumeHandler.change_time := 0; + end; + SDLK_TAB: begin ScreenPopupHelp.ShowPopup(); @@ -163,6 +194,8 @@ begin end; Text[TextLevel].Text := IDifficulty[Ini.Difficulty]; + + MP3VolumeHandler.changed := false; end; function TScreenTop.Draw: boolean; @@ -205,6 +238,13 @@ begin end;} inherited Draw; + + if MP3VolumeHandler.changed and (MP3VolumeHandler.change_time+TimeSkip<3) then + begin + MP3VolumeHandler.change_time := MP3VolumeHandler.change_time + TimeSkip; + DrawVolumeBar(10, 530, 780, 12, ScreenSong.MP3Volume); + end else + MP3VolumeHandler.changed := false; end; end. -- cgit v1.2.3