From 1ab628e8ad6c85c8f1b562f10480253ee3e622b7 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 11 Dec 2009 17:34:54 +0000 Subject: merged trunk into lua branch plugin loading is disabled atm because of a bug reading the files (lua may be the reason). Reading the files in usdx and passing the contents to lua may solve this git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@2019 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Lua/src/screens/UScreenSongMenu.pas | 377 ++++++++++++++++++------------------ 1 file changed, 187 insertions(+), 190 deletions(-) (limited to 'Lua/src/screens/UScreenSongMenu.pas') diff --git a/Lua/src/screens/UScreenSongMenu.pas b/Lua/src/screens/UScreenSongMenu.pas index 72be93db..173ac2c8 100644 --- a/Lua/src/screens/UScreenSongMenu.pas +++ b/Lua/src/screens/UScreenSongMenu.pas @@ -45,79 +45,81 @@ uses type TScreenSongMenu = class(TMenu) private - CurMenu: Byte; //Num of the cur. Shown Menu + CurMenu: byte; // num of the cur. shown menu public - Visible: Boolean; //Whether the Menu should be Drawn + Visible: boolean; // whether the menu should be drawn constructor Create; override; - function ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; override; - procedure onShow; override; + function ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; + procedure OnShow; override; function Draw: boolean; override; - procedure MenuShow(sMenu: Byte); + procedure MenuShow(sMenu: byte); procedure HandleReturn; end; const SM_Main = 1; - - SM_PlayList = 64 or 1; - SM_Playlist_Add = 64 or 2; - SM_Playlist_New = 64 or 3; - SM_Playlist_DelItem = 64 or 5; + SM_PlayList = 64 or 1; + SM_Playlist_Add = 64 or 2; + SM_Playlist_New = 64 or 3; - SM_Playlist_Load = 64 or 8 or 1; - SM_Playlist_Del = 64 or 8 or 5; + SM_Playlist_DelItem = 64 or 5; + SM_Playlist_Load = 64 or 8 or 1; + SM_Playlist_Del = 64 or 8 or 5; - SM_Party_Main = 128 or 1; - SM_Party_Joker = 128 or 2; + SM_Party_Main = 128 or 1; + SM_Party_Joker = 128 or 2; var - ISelections: Array of String; - SelectValue: Integer; - + ISelections: array of UTF8String; + SelectValue: integer; implementation -uses UGraphic, - UMain, - UIni, - UTexture, - ULanguage, - UParty, - UPlaylist, - USongs; - -function TScreenSongMenu.ParseInput(PressedKey: Cardinal; CharCode: WideChar; PressedDown: Boolean): Boolean; +uses + UGraphic, + UMain, + UIni, + UTexture, + ULanguage, + UParty, + UPlaylist, + USongs, + UUnicodeUtils; + +function TScreenSongMenu.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; begin Result := true; if (PressedDown) then - begin // Key Down - if (CurMenu = SM_Playlist_New) AND (Interaction=0) then + begin // key down + if (CurMenu = SM_Playlist_New) and (Interaction=0) then begin // check normal keys - case WideCharUpperCase(CharCode)[1] of - '0'..'9', 'A'..'Z', ' ', '-', '_', '!', ',', '<', '/', '*', '?', '''', '"': - begin - Button[Interaction].Text[0].Text := Button[Interaction].Text[0].Text + CharCode; - exit; - end; + if IsAlphaNumericChar(CharCode) or + (CharCode in [Ord(' '), Ord('-'), Ord('_'), Ord('!'), + Ord(','), Ord('<'), Ord('/'), Ord('*'), + Ord('?'), Ord(''''), Ord('"')]) then + begin + Button[Interaction].Text[0].Text := Button[Interaction].Text[0].Text + + UCS4ToUTF8String(CharCode); + exit; end; // check special keys case PressedKey of SDLK_BACKSPACE: begin - Button[Interaction].Text[0].DeleteLastL; + Button[Interaction].Text[0].DeleteLastLetter; exit; end; end; end; // check normal keys - case WideCharUpperCase(CharCode)[1] of - 'Q': + case UCS4UpperCase(CharCode) of + Ord('Q'): begin Result := false; Exit; @@ -127,10 +129,10 @@ begin // check special keys case PressedKey of SDLK_ESCAPE, - SDLK_BACKSPACE : + SDLK_BACKSPACE: begin AudioPlayback.PlaySound(SoundLib.Back); - Visible := False; + Visible := false; end; SDLK_RETURN: @@ -138,8 +140,8 @@ begin HandleReturn; end; - SDLK_DOWN: InteractNext; - SDLK_UP: InteractPrev; + SDLK_DOWN: InteractNext; + SDLK_UP: InteractPrev; SDLK_RIGHT: begin @@ -153,8 +155,8 @@ begin end; SDLK_1: - begin //Jocker - //Use Joker + begin // jocker + // use joker case CurMenu of SM_Party_Main: begin @@ -163,8 +165,8 @@ begin end; end; SDLK_2: - begin //Jocker - //Use Joker + begin // jocker + // use joker case CurMenu of SM_Party_Main: begin @@ -173,8 +175,8 @@ begin end; end; SDLK_3: - begin //Jocker - //Use Joker + begin // jocker + // use joker case CurMenu of SM_Party_Main: begin @@ -189,12 +191,11 @@ end; constructor TScreenSongMenu.Create; begin inherited Create; - - //Create Dummy SelectSlide Entrys + + // create dummy selectslide entrys SetLength(ISelections, 1); ISelections[0] := 'Dummy'; - AddText(Theme.SongMenu.TextMenu); LoadFromTheme(Theme.SongMenu); @@ -217,7 +218,6 @@ begin if (Length(Button[3].Text) = 0) then AddButtonText(14, 20, 'Button 4'); - Interaction := 0; end; @@ -226,27 +226,26 @@ begin Result := inherited Draw; end; -procedure TScreenSongMenu.onShow; +procedure TScreenSongMenu.OnShow; begin inherited; - end; -procedure TScreenSongMenu.MenuShow(sMenu: Byte); +procedure TScreenSongMenu.MenuShow(sMenu: byte); begin - Interaction := 0; //Reset Interaction - Visible := True; //Set Visible - Case sMenu of + Interaction := 0; // reset interaction + Visible := true; // set visible + case sMenu of SM_Main: begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_MAIN'); - Button[0].Visible := True; - Button[1].Visible := True; - Button[2].Visible := True; - Button[3].Visible := True; - SelectsS[0].Visible := False; + Button[0].Visible := true; + Button[1].Visible := true; + Button[2].Visible := true; + Button[3].Visible := true; + SelectsS[0].Visible := false; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAY'); Button[1].Text[0].Text := Language.Translate('SONG_MENU_CHANGEPLAYERS'); @@ -259,11 +258,11 @@ begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST'); - Button[0].Visible := True; - Button[1].Visible := True; - Button[2].Visible := True; - Button[3].Visible := True; - SelectsS[0].Visible := False; + Button[0].Visible := true; + Button[1].Visible := true; + Button[2].Visible := true; + Button[3].Visible := true; + SelectsS[0].Visible := false; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAY'); Button[1].Text[0].Text := Language.Translate('SONG_MENU_CHANGEPLAYERS'); @@ -276,11 +275,11 @@ begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_ADD'); - Button[0].Visible := True; - Button[1].Visible := False; - Button[2].Visible := False; - Button[3].Visible := True; - SelectsS[0].Visible := True; + Button[0].Visible := true; + Button[1].Visible := false; + Button[2].Visible := false; + Button[3].Visible := true; + SelectsS[0].Visible := true; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_ADD_NEW'); Button[3].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_ADD_EXISTING'); @@ -294,9 +293,9 @@ begin end else begin - Button[3].Visible := False; - SelectsS[0].Visible := False; - Button[2].Visible := True; + Button[3].Visible := false; + SelectsS[0].Visible := false; + Button[2].Visible := true; Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NOEXISTING'); end; end; @@ -306,11 +305,11 @@ begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_NEW'); - Button[0].Visible := True; - Button[1].Visible := False; - Button[2].Visible := True; - Button[3].Visible := True; - SelectsS[0].Visible := False; + Button[0].Visible := true; + Button[1].Visible := false; + Button[2].Visible := true; + Button[3].Visible := true; + SelectsS[0].Visible := false; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NEW_UNNAMED'); Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NEW_CREATE'); @@ -322,11 +321,11 @@ begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_DELITEM'); - Button[0].Visible := True; - Button[1].Visible := False; - Button[2].Visible := False; - Button[3].Visible := True; - SelectsS[0].Visible := False; + Button[0].Visible := true; + Button[1].Visible := false; + Button[2].Visible := false; + Button[3].Visible := true; + SelectsS[0].Visible := false; Button[0].Text[0].Text := Language.Translate('SONG_MENU_YES'); Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); @@ -337,13 +336,13 @@ begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_LOAD'); - //Show Delete Curent Playlist Button when Playlist is opened + // show delete curent playlist button when playlist is opened Button[0].Visible := (CatSongs.CatNumShow = -3); - Button[1].Visible := False; - Button[2].Visible := False; - Button[3].Visible := True; - SelectsS[0].Visible := True; + Button[1].Visible := false; + Button[2].Visible := false; + Button[3].Visible := true; + SelectsS[0].Visible := true; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_DELCURRENT'); Button[3].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_LOAD'); @@ -358,9 +357,9 @@ begin end else begin - Button[3].Visible := False; - SelectsS[0].Visible := False; - Button[2].Visible := True; + Button[3].Visible := false; + SelectsS[0].Visible := false; + Button[2].Visible := true; Button[2].Text[0].Text := Language.Translate('SONG_MENU_PLAYLIST_NOEXISTING'); Interaction := 2; end; @@ -371,27 +370,26 @@ begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PLAYLIST_DEL'); - Button[0].Visible := True; - Button[1].Visible := False; - Button[2].Visible := False; - Button[3].Visible := True; - SelectsS[0].Visible := False; + Button[0].Visible := true; + Button[1].Visible := false; + Button[2].Visible := false; + Button[3].Visible := true; + SelectsS[0].Visible := false; Button[0].Text[0].Text := Language.Translate('SONG_MENU_YES'); Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); end; - SM_Party_Main: begin CurMenu := sMenu; Text[0].Text := Language.Translate('SONG_MENU_NAME_PARTY_MAIN'); - Button[0].Visible := True; - Button[1].Visible := False; - Button[2].Visible := False; - Button[3].Visible := True; - SelectsS[0].Visible := False; + Button[0].Visible := true; + Button[1].Visible := false; + Button[2].Visible := false; + Button[3].Visible := true; + SelectsS[0].Visible := false; Button[0].Text[0].Text := Language.Translate('SONG_MENU_PLAY'); //Button[1].Text[0].Text := Language.Translate('SONG_MENU_JOKER'); @@ -411,168 +409,168 @@ begin SelectsS[0].Visible := False; if (Button[0].Visible) then - Button[0].Text[0].Text := String(Party.Teams[0].Name); + Button[0].Text[0].Text := UTF8String(Party.Teams[0].Name); if (Button[1].Visible) then - Button[1].Text[0].Text := String(Party.Teams[1].Name); + Button[1].Text[0].Text := UTF8String(Party.Teams[1].Name); if (Button[2].Visible) then - Button[2].Text[0].Text := String(Party.Teams[2].Name); + Button[2].Text[0].Text := UTF8String(Party.Teams[2].Name); Button[3].Text[0].Text := Language.Translate('SONG_MENU_CANCEL'); - //Set right Interaction + // set right interaction if (not Button[0].Visible) then begin if (not Button[1].Visible) then begin if (not Button[2].Visible) then - begin - Interaction := 4; - end - else Interaction := 2; + Interaction := 4 + else + Interaction := 2; end - else Interaction := 1; + else + Interaction := 1; end; - + end; end; end; procedure TScreenSongMenu.HandleReturn; begin - Case CurMenu of + case CurMenu of SM_Main: begin - Case Interaction of - 0: //Button 1 + case Interaction of + 0: // button 1 begin ScreenSong.StartSong; - Visible := False; + Visible := false; end; - 1: //Button 2 + 1: // button 2 begin - //Select New Players then Sing: + // select new players then sing: ScreenSong.SelectPlayers; - Visible := False; + Visible := false; end; - 2: //Button 3 + 2: // button 3 begin - //Show add to Playlist Menu + // show add to playlist menu MenuShow(SM_Playlist_Add); end; - 3: //SelectSlide 3 + 3: // selectslide 3 begin //Dummy end; - 4: //Button 4 + 4: // button 4 begin ScreenSong.OpenEditor; - Visible := False; + Visible := false; end; end; end; SM_PlayList: begin - Visible := False; - Case Interaction of - 0: //Button 1 + Visible := false; + case Interaction of + 0: // button 1 begin ScreenSong.StartSong; - Visible := False; + Visible := false; end; - 1: //Button 2 + 1: // button 2 begin - //Select New Players then Sing: + // select new players then sing: ScreenSong.SelectPlayers; - Visible := False; + Visible := false; end; - 2: //Button 3 + 2: // button 3 begin - //Show add to Playlist Menu + // show add to playlist menu MenuShow(SM_Playlist_DelItem); end; - 3: //SelectSlide 3 + 3: // selectslide 3 begin - //Dummy + // dummy end; - 4: //Button 4 + 4: // button 4 begin ScreenSong.OpenEditor; - Visible := False; + Visible := false; end; end; end; SM_Playlist_Add: begin - Case Interaction of - 0: //Button 1 + case Interaction of + 0: // button 1 begin MenuShow(SM_Playlist_New); end; - 3: //SelectSlide 3 + 3: // selectslide 3 begin - //Dummy + // dummy end; - 4: //Button 4 + 4: // button 4 begin PlaylistMan.AddItem(ScreenSong.Interaction, SelectValue); - Visible := False; + Visible := false; end; end; end; SM_Playlist_New: begin - Case Interaction of - 0: //Button 1 + case Interaction of + 0: // button 1 begin - //Nothing, Button for Entering Name + // nothing, button for entering name end; - 2: //Button 3 + 2: // button 3 begin - //Create Playlist and Add Song + // create playlist and add song PlaylistMan.AddItem( ScreenSong.Interaction, PlaylistMan.AddPlaylist(Button[0].Text[0].Text)); - Visible := False; + Visible := false; end; - 3: //SelectSlide 3 + 3: // selectslide 3 begin - //Cancel -> Go back to Add screen + // cancel -> go back to add screen MenuShow(SM_Playlist_Add); end; - 4: //Button 4 + 4: // button 4 begin - Visible := False; + Visible := false; end; end; end; SM_Playlist_DelItem: begin - Visible := False; - Case Interaction of - 0: //Button 1 + Visible := false; + case Interaction of + 0: // button 1 begin - //Delete + // delete PlayListMan.DelItem(PlayListMan.GetIndexbySongID(ScreenSong.Interaction)); - Visible := False; + Visible := false; end; - 4: //Button 4 + 4: // button 4 begin MenuShow(SM_Playlist); end; @@ -581,32 +579,32 @@ begin SM_Playlist_Load: begin - Case Interaction of - 0: //Button 1 (Delete Playlist) + case Interaction of + 0: // button 1 (Delete playlist) begin MenuShow(SM_Playlist_Del); end; - 4: //Button 4 + 4: // button 4 begin - //Load Playlist + // load playlist PlaylistMan.SetPlayList(SelectValue); - Visible := False; + Visible := false; end; end; end; SM_Playlist_Del: begin - Visible := False; - Case Interaction of - 0: //Button 1 + Visible := false; + case Interaction of + 0: // button 1 begin - //Delete + // delete PlayListMan.DelPlaylist(PlaylistMan.CurPlayList); - Visible := False; + Visible := false; end; - 4: //Button 4 + 4: // button 4 begin MenuShow(SM_Playlist_Load); end; @@ -615,17 +613,17 @@ begin SM_Party_Main: begin - Case Interaction of - 0: //Button 1 + case Interaction of + 0: // button 1 begin - //Start Singing + // start singing Party.CallAfterSongSelect; - Visible := False; + Visible := false; end; - 4: //Button 4 + 4: // button 4 begin - //Joker + // joker MenuShow(SM_Party_Joker); end; end; @@ -633,29 +631,29 @@ begin SM_Party_Joker: begin - Visible := False; - Case Interaction of - 0: //Button 1 + Visible := false; + case Interaction of + 0: // button 1 begin - //Joker Team 1 + // joker team 1 ScreenSong.DoJoker(0); end; - 1: //Button 2 + 1: // button 2 begin - //Joker Team 2 + // joker team 2 ScreenSong.DoJoker(1); end; - 2: //Button 3 + 2: // button 3 begin - //Joker Team 3 + // joker team 3 ScreenSong.DoJoker(2); end; - 4: //Button 4 + 4: // button 4 begin - //Cancel... (Fo back to old Menu) + // cancel... (go back to old menu) MenuShow(SM_Party_Main); end; end; @@ -664,4 +662,3 @@ begin end; end. - -- cgit v1.2.3