From 6cdcfb402ce738dfc77b008fcb98fd1cda691eb5 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 19 Apr 2007 18:53:22 +0000 Subject: Added Statistic Screens to C0de and to Theme Moved some Translated Strings from UScreenPartyOptions to UTheme to use it with the Statistic Screens, too. Fixed use of /n Tag istead of the correct \n git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@118 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenStatDetail.pas | 254 ++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 Game/Code/Screens/UScreenStatDetail.pas (limited to 'Game/Code/Screens/UScreenStatDetail.pas') diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas new file mode 100644 index 00000000..dc4a0f1f --- /dev/null +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -0,0 +1,254 @@ +unit UScreenStatDetail; + +interface + +uses + UMenu, SDL, SysUtils, UDisplay, UMusic, UIni, UThemes; + +type + TScreenStatDetail = class(TMenu) + public + Typ: Byte; + Page: CardinaL; + Count: Byte; + Reversed: Boolean; + + TotEntrys: Cardinal; + TotPages: Cardinal; + + + constructor Create; override; + function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; override; + procedure onShow; override; + procedure SetAnimationProgress(Progress: real); override; + + procedure SetTitle; + Procedure SetPage(NewPage: Cardinal); + end; + +implementation + +{Stat Screens: + 0 - Best Scores + 1 - Best Singers + 2 - Most sung Songs + 3 - Most popular Band +} + +uses UGraphic, UDataBase, ULanguage, math, ULog; + +function TScreenStatDetail.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean; +begin + Result := true; + If (PressedDown) Then + begin // Key Down + case PressedKey of + SDLK_Q: + begin + Result := false; + end; + SDLK_ESCAPE: + begin + Music.PlayBack; + FadeTo(@ScreenStatMain); + end; + SDLK_RETURN: + begin + if Interaction = 0 then begin + //Next Page + SetPage(Page+1); + end; + + if Interaction = 1 then begin + //Previous Page + if (Page > 0) then + SetPage(Page-1); + end; + + if Interaction = 2 then begin + //Reverse Order + Reversed := not Reversed; + SetPage(Page); + end; + + if Interaction = 3 then begin + Music.PlayBack; + FadeTo(@ScreenStatMain); + end; + end; + SDLK_LEFT: + begin + InteractPrev; + end; + SDLK_RIGHT: + begin + InteractNext; + end; + SDLK_UP: + begin + InteractPrev; + end; + SDLK_DOWN: + begin + InteractNext; + end; + end; + end; +end; + +constructor TScreenStatDetail.Create; +var + I: integer; +begin + inherited Create; + + AddBackground(Theme.StatDetail.Background.Tex); + + AddButton(Theme.StatDetail.ButtonNext); + if (Length(Button[0].Text)=0) then + AddButtonText(14, 20, Language.Translate('STAT_NEXT')); + + AddButton(Theme.StatDetail.ButtonPrev); + if (Length(Button[1].Text)=0) then + AddButtonText(14, 20, Language.Translate('STAT_PREV')); + + AddButton(Theme.StatDetail.ButtonReverse); + if (Length(Button[2].Text)=0) then + AddButtonText(14, 20, Language.Translate('STAT_REVERSE')); + + AddButton(Theme.StatDetail.ButtonExit); + if (Length(Button[3].Text)=0) then + AddButtonText(14, 20, Theme.Options.Description[7]); + + for I := 0 to High(Theme.StatDetail.TextList) do + AddText(Theme.StatDetail.TextList[I]); + + Count := Length(Theme.StatDetail.TextList); + + AddText(Theme.StatDetail.TextDescription); + AddText(Theme.StatDetail.TextPage); + + for I := 0 to High(Theme.StatDetail.Static) do + AddStatic(Theme.StatDetail.Static[I]); + + for I := 0 to High(Theme.StatDetail.Text) do + AddText(Theme.StatDetail.Text[I]); + + + + Interaction := 0; + Typ := 0; +end; + +procedure TScreenStatDetail.onShow; +begin + //Set Tot Entrys and PAges + TotEntrys := DataBase.GetTotalEntrys(Typ); + TotPages := Ceil(TotEntrys / Count); + //Show correct Title + SetTitle; + //Show First Page + Reversed := False; + SetPage(0); +end; + +procedure TScreenStatDetail.SetTitle; +begin + //Set Title + Case Reversed of + True: Text[Count].Text := Theme.StatDetail.DescriptionR[Typ]; + False: Text[Count].Text := Theme.StatDetail.Description[Typ]; + end; +end; + +Procedure TScreenStatDetail.SetPage(NewPage: Cardinal); +var + Result: AStatResult; + I: Integer; + FormatStr: String; + PerPage: Byte; +begin + SetLength(Result, Count); + if (Database.GetStats(Result, Typ, Count, NewPage, Reversed)) then + begin + Page := NewPage; + + FormatStr := Theme.StatDetail.FormatStr[Typ]; + + //refresh Texts + For I := 0 to Count-1 do + begin + try + case Typ of + 0:begin //Best Scores + //Set Texts + if (Result[I].Score>0) then + Text[I].Text := Format(FormatStr, [Result[I].Singer, + Result[I].Score, + Theme.ILevel[Result[I].Difficulty], + Result[I].SongArtist, + Result[I].SongTitle]) + else + Text[I].Text := ''; + end; + + 1:begin //Best Singers + //Set Texts + if (Result[I].AverageScore>0) then + Text[I].Text := Format(FormatStr, [Result[I].Player, + Result[I].AverageScore]) + else + Text[I].Text := ''; + end; + + 2:begin //Popular Songs + //Set Texts + if (Result[I].Artist<>'') then + Text[I].Text := Format(FormatStr, [Result[I].Artist, + Result[I].Title, + Result[I].TimesSung]) + else + Text[I].Text := ''; + end; + + 3:begin //Popular Bands + //Set Texts + if (Result[I].ArtistName<>'') then + Text[I].Text := Format(FormatStr, [Result[I].ArtistName, + Result[I].TimesSungtot]) + else + Text[I].Text := ''; + end; + end; + except + on E: EConvertError do + Log.LogError('Error Parsing FormatString in UScreenStatDetail: ' + E.Message); + end; + end; + + if (Page + 1 = TotPages) AND (TotEntrys Mod Count <> 0) then + PerPage := (TotEntrys Mod Count) + else + PerPage := Count; + + Text[Count+1].Text := Format(Theme.StatDetail.PageStr, [Page + 1, + TotPages, + PerPage, + TotEntrys]); + + //Show correct Title + SetTitle; + + end; + +end; + + +procedure TScreenStatDetail.SetAnimationProgress(Progress: real); +var I: Integer; +begin + For I := 0 to high(Button) do + Button[I].Texture.ScaleW := Progress; +end; + +end. -- cgit v1.2.3 From bda4fa8e57ca63a1d591433f120b4226d6a5d327 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 29 Apr 2007 17:50:29 +0000 Subject: Added 2 new Buttons to ScreenMain: Multi and Stats Updated Language Fiels to Fit with new Buttons Some CodeClean Up in Menu Class and in Screens Some minor Bug fixes I forgot about Added ability to group Buttons within a Screen New Theme Object: ButtonCollection: Same Attributes as a Button Plus FirstChild: Defining the First Button in the Group. For Example: SingSolo is 1, SingMulti Button is 2, in ScreenMain Added Attribute to Theme Button: Parent: Number of the assigned Group, 0 for no Group Used new Abilitys in MainScreen git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@149 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenStatDetail.pas | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'Game/Code/Screens/UScreenStatDetail.pas') diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas index dc4a0f1f..1461a9da 100644 --- a/Game/Code/Screens/UScreenStatDetail.pas +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -102,7 +102,15 @@ var begin inherited Create; - AddBackground(Theme.StatDetail.Background.Tex); + for I := 0 to High(Theme.StatDetail.TextList) do + AddText(Theme.StatDetail.TextList[I]); + + Count := Length(Theme.StatDetail.TextList); + + AddText(Theme.StatDetail.TextDescription); + AddText(Theme.StatDetail.TextPage); + + LoadFromTheme(Theme.StatDetail); AddButton(Theme.StatDetail.ButtonNext); if (Length(Button[0].Text)=0) then @@ -120,22 +128,6 @@ begin if (Length(Button[3].Text)=0) then AddButtonText(14, 20, Theme.Options.Description[7]); - for I := 0 to High(Theme.StatDetail.TextList) do - AddText(Theme.StatDetail.TextList[I]); - - Count := Length(Theme.StatDetail.TextList); - - AddText(Theme.StatDetail.TextDescription); - AddText(Theme.StatDetail.TextPage); - - for I := 0 to High(Theme.StatDetail.Static) do - AddStatic(Theme.StatDetail.Static[I]); - - for I := 0 to High(Theme.StatDetail.Text) do - AddText(Theme.StatDetail.Text[I]); - - - Interaction := 0; Typ := 0; end; -- cgit v1.2.3 From 3043d3db91c3a541881aa951bbd4f8ccb5e3ce40 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 5 Sep 2007 12:35:19 +0000 Subject: modified ParseInput so Backspace will perform same function as ESC in most screens ( Except where text input is required, and backspace is used for text input ) This has been done, so that when used with Windows Media Center IR Remotes ( needs SDL 1.2 dll at runtime ) users can navigate throug the game without sitting in front of the PC keyboard. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@370 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenStatDetail.pas | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'Game/Code/Screens/UScreenStatDetail.pas') diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas index 1461a9da..9dc6c525 100644 --- a/Game/Code/Screens/UScreenStatDetail.pas +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -47,7 +47,9 @@ begin begin Result := false; end; - SDLK_ESCAPE: + + SDLK_ESCAPE, + SDLK_BACKSPACE : begin Music.PlayBack; FadeTo(@ScreenStatMain); -- cgit v1.2.3 From 44554c7908f7e2405a249331f00a35703f5939c2 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 11 Oct 2007 12:02:20 +0000 Subject: Added IAudioPlayback Interface and implementation for BASS. Created "AudioPlayback" Global Singleton, which removed the need for the "Music" Global variable. This was done because global singleton objects are a recognized better "design pattern" achieving the same thing as global variables, but in a nicer way. I will be working to a) separate IAudioPlayback in to separate "Playback" and "Input" Interfaces b) build a FFMpeg class that implements IAudioPlayback git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@504 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenStatDetail.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenStatDetail.pas') diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas index 9dc6c525..1310b127 100644 --- a/Game/Code/Screens/UScreenStatDetail.pas +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -51,7 +51,7 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE : begin - Music.PlayBack; + AudioPlayback.PlayBack; FadeTo(@ScreenStatMain); end; SDLK_RETURN: @@ -74,7 +74,7 @@ begin end; if Interaction = 3 then begin - Music.PlayBack; + AudioPlayback.PlayBack; FadeTo(@ScreenStatMain); end; end; -- cgit v1.2.3 From 391d30716d48dc709f6444b19c008e82311623b9 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 1 Nov 2007 19:34:40 +0000 Subject: Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux. Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenStatDetail.pas | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Game/Code/Screens/UScreenStatDetail.pas') diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas index 1310b127..414055f9 100644 --- a/Game/Code/Screens/UScreenStatDetail.pas +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -2,6 +2,8 @@ unit UScreenStatDetail; interface +{$I switches.inc} + uses UMenu, SDL, SysUtils, UDisplay, UMusic, UIni, UThemes; -- cgit v1.2.3 From dee94f5dae9e6b5ae6c7b54a12a567745abc8dc3 Mon Sep 17 00:00:00 2001 From: tobigun Date: Tue, 5 Feb 2008 20:36:19 +0000 Subject: General: - cleanup and adaption of SingDrawOscilloscope Portaudio/SDL audio output: - stuttering in portaudio output has been fixed (SDL_MixBuffers cannot be used without initializing the SDL audio stuff first, so it is not usable with portaudio. Now SDL is used for audio-output instead of portaudio (although the file-name is UAudioPlayback_Portaudio.pas at the moment). - cleaner file closing - volume adjustment UMusic: - cleanup of the audio-interfaces - introduced TNoteType = (ntFreestyle, ntNormal, ntGolden) - some bug-fixes - introduced TSoundLibrary. This is library for all in-game sounds used by USDX. Instead of calling AudioPlayer.PlaySwoosh you should call AudioPlayer.PlaySound(SoundLib.Swoosh) now. You might call SoundLib.Swoosh.Play too, but this is not recommended at the moment because SoundLib.Swoosh could be nil if the file was not found. The SoundLibrary approach is much cleaner than the previous one. The AudioPlayer does not have to specify a Play... and Stop... method for every available sound anymore. In addition it is not an AudioPlayers responsibility to init the in-game sounds. URecord: - polish to english translation of some variables - CaptureSoundLeft/Right is CaptureChannel[0/1] now - TSoundCardInput -> TAudioInputDeviceSource - TGenericSoundCard.Input -> TGenericSoundCard.Source - autocorrelation algorithm more readable now - Clean-up of the audio-input interface - moved cloned code of the input-classes to one base class (TAudioInputBase) - Cleaner finalization - Start-/StopCapture will not crash anymore in the recording-options menu - Fixed several bugs in the autocorrelation stuff (e.g. wrong usage of $10000) - SzczytJest (now ToneValid) was not used correctly. ToneValid is set to true if a valid tone was found (= the sound was louder than the threshold -> no background noise). If i remember correctly the sound was accepted although the tone was invalid. So the old data was used although noone was singing. This resulted in some sort of ghost-singer effect. UIni: - moved TIni.Card to TScreenOptionsRecord.Card because it is not stored in the ini-file and will not be in the future. - TIni.CardList ist now TIni.InputDeviceConfig. The name cardlist was misleading because it just specifies input- but no output-devices. In addition a soundcard can have multiple input-devices (at least in linux). - bugfix on InputDeviceConfig (formerly CardList) usage. USDX expected that the indices of the corresponding elements in TIni.InputDeviceConfig[] and TAudioInputProcessor.Device[] were the same. This is wrong. If device 2 was defined at first place in the ini and device 1 at the second, the indices of the two arrays didn't match (they were swapped) erroneously. To fix this and to support the item listed below the index to TIni.InputDeviceConfig[] is now stored in TAudioInputDevice.CfgIndex. NOTE: InputDeviceConfig[] contains configurations of non-available (unplugged) devices. Iterate over TAudioInputProcessor.Device[] for available devices. - configurations of external devices that are not plugged in will not be deleted anymore. - multiple definitions of one device in the ini-file will not crash USDX anymore - CardList[I].ChannelL/R now are InputDeviceConfig[I].ChannelToPlayerMap[0/1]. I think the new name is more intuitive because it maps a channel to a player number. Now the both vars are joint to one array. Now it is possible to use loops to process them and we might support more than two input channels on one device in the future (if such devices exist) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@827 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Screens/UScreenStatDetail.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Screens/UScreenStatDetail.pas') diff --git a/Game/Code/Screens/UScreenStatDetail.pas b/Game/Code/Screens/UScreenStatDetail.pas index 414055f9..d793baf0 100644 --- a/Game/Code/Screens/UScreenStatDetail.pas +++ b/Game/Code/Screens/UScreenStatDetail.pas @@ -53,7 +53,7 @@ begin SDLK_ESCAPE, SDLK_BACKSPACE : begin - AudioPlayback.PlayBack; + AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenStatMain); end; SDLK_RETURN: @@ -76,7 +76,7 @@ begin end; if Interaction = 3 then begin - AudioPlayback.PlayBack; + AudioPlayback.PlaySound(SoundLib.Back); FadeTo(@ScreenStatMain); end; end; -- cgit v1.2.3