From 257854c587f0876a912cfbeb4fe0a30970d25a9b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 31 May 2009 14:10:42 +0000 Subject: merged (experimental) mouse support patch by d0ccrazy some changes to patch - implemented software cursor (texturable) - option to turn of mouse support or switch between hardware and software cursor - hide software cursor if there is no mouse activity for 5 seconds - soft fade in and out for software cursor - some test cursor-textures for deluxe theme (mog pls change these horible looking images) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1789 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UGraphic.pas | 19 ++++- src/base/UIni.pas | 8 ++ src/base/UMain.pas | 76 ++++++++++++----- src/menu/UDisplay.pas | 191 +++++++++++++++++++++++++++++++++++++++++++ src/menu/UMenu.pas | 119 +++++++++++++++++++++++++-- src/screens/UScreenMain.pas | 34 ++------ src/screens/UScreenScore.pas | 10 +++ src/screens/UScreenSing.pas | 10 ++- src/screens/UScreenSong.pas | 23 ++++++ src/screens/UScreenTop5.pas | 10 +++ 10 files changed, 440 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/base/UGraphic.pas b/src/base/UGraphic.pas index 82cb3c50..818e49aa 100644 --- a/src/base/UGraphic.pas +++ b/src/base/UGraphic.pas @@ -199,10 +199,13 @@ var Tex_Score_Ratings : array [0..7] of TTexture; - //Arrows for SelectSlide + // arrows for SelectSlide Tex_SelectS_ArrowL: TTexture; Tex_SelectS_ArrowR: TTexture; - + + // textures for software mouse cursor + Tex_Cursor_Unpressed: TTexture; + Tex_Cursor_Pressed: TTexture; const Skin_BGColorR = 1; Skin_BGColorG = 1; @@ -335,6 +338,13 @@ begin Tex_SelectS_ArrowL := Texture.LoadTexture(Skin.GetTextureFileName('Select_ArrowLeft'), TEXTURE_TYPE_TRANSPARENT, 0); Tex_SelectS_ArrowR := Texture.LoadTexture(Skin.GetTextureFileName('Select_ArrowRight'), TEXTURE_TYPE_TRANSPARENT, 0); + Tex_Cursor_Unpressed := Texture.LoadTexture(Skin.GetTextureFileName('Cursor'), TEXTURE_TYPE_TRANSPARENT, 0); + + if (Skin.GetTextureFileName('Cursor_Pressed') <> '') then + Tex_Cursor_Pressed := Texture.LoadTexture(Skin.GetTextureFileName('Cursor_Pressed'), TEXTURE_TYPE_TRANSPARENT, 0) + else + Tex_Cursor_Pressed.TexNum := 0; + //TimeBar mod Tex_TimeProgress := Texture.LoadTexture(Skin.GetTextureFileName('TimeBar')); //eoa TimeBar mod @@ -492,6 +502,7 @@ begin Log.LogStatus('TDisplay.Create', 'UGraphic.Initialize3D'); Display := TDisplay.Create; + //Display.SetCursor; //Log.BenchmarkEnd(2); Log.LogBenchmark('====> Creating Display', 2); @@ -624,15 +635,15 @@ begin begin Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Full Screen'); screen := SDL_SetVideoMode(W, H, (Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN ); - SDL_ShowCursor(0); end else begin Log.LogStatus('SDL_SetVideoMode', 'Set Video Mode... Windowed'); screen := SDL_SetVideoMode(W, H, 0, SDL_OPENGL or SDL_RESIZABLE); - SDL_ShowCursor(1); end; + SDL_ShowCursor(0); + if (screen = nil) then begin Log.LogCritical('SDL_SetVideoMode Failed', 'Initialize3D'); diff --git a/src/base/UIni.pas b/src/base/UIni.pas index 2c1029f6..a016753e 100644 --- a/src/base/UIni.pas +++ b/src/base/UIni.pas @@ -154,6 +154,7 @@ type // Controller Joypad: integer; + Mouse: integer; procedure Load(); procedure Save(); @@ -246,6 +247,7 @@ const IPartyPopup: array[0..1] of string = ('Off', 'On'); IJoypad: array[0..1] of string = ('Off', 'On'); + IMouse: array[0..2] of string = ('Off', 'Hardware Cursor', 'Software Cursor'); // Recording options IChannelPlayer: array[0..6] of string = ('Off', '1', '2', '3', '4', '5', '6'); @@ -769,6 +771,9 @@ begin // Joypad Joypad := GetArrayIndex(IJoypad, IniFile.ReadString('Controller', 'Joypad', IJoypad[0])); + // Mouse + Mouse := GetArrayIndex(IMouse, IniFile.ReadString('Controller', 'Mouse', IMouse[2])); + LoadPaths(IniFile); IniFile.Free; @@ -908,6 +913,9 @@ begin // Joypad IniFile.WriteString('Controller', 'Joypad', IJoypad[Joypad]); + // Mouse + IniFile.WriteString('Controller', 'Mouse', IMouse[Mouse]); + // Directories (add a template if section is missing) // Note: Value must be ' ' and not '', otherwise no key is generated on Linux if (not IniFile.SectionExists('Directories')) then diff --git a/src/base/UMain.pas b/src/base/UMain.pas index 28ba5afc..3900c877 100644 --- a/src/base/UMain.pas +++ b/src/base/UMain.pas @@ -375,9 +375,26 @@ begin end; end; +procedure DoQuit; +begin + // if question option is enabled then show exit popup + if (Ini.AskbeforeDel = 1) then + begin + Display.CurrentScreen^.CheckFadeTo(nil,'MSG_QUIT_USDX'); + end + else // if ask-for-exit is disabled then simply exit + begin + Display.Fade := 0; + Display.NextScreenWithCheck := nil; + Display.CheckOK := True; + end; +end; + procedure CheckEvents; var Event: TSDL_event; + mouseDown: Boolean; + mouseBtn: Integer; begin if Assigned(Display.NextScreen) then Exit; @@ -391,17 +408,46 @@ begin Display.NextScreenWithCheck := nil; Display.CheckOK := true; end; - SDL_MOUSEBUTTONDOWN: + + SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: begin -{ - with Event.button do + if (Ini.Mouse > 0) then begin - if State = SDL_BUTTON_LEFT then + case Event.type_ of + SDL_MOUSEMOTION: + begin + mouseDown := False; + mouseBtn := 0; + end; + SDL_MOUSEBUTTONDOWN: + begin + mouseDown := True; + mouseBtn := Event.button.button; + end; + SDL_MOUSEBUTTONUP: + begin + mouseDown := False; + mouseBtn := Event.button.button; + end; + end; + + Display.MoveCursor(Event.button.X * 800 / Screen.w, + Event.button.Y * 600 / Screen.h, + mouseDown and ((mouseBtn <> SDL_BUTTON_WHEELDOWN) or (mouseBtn <> SDL_BUTTON_WHEELUP))); + + if (ScreenPopupError <> nil) and (ScreenPopupError.Visible) then + done := not ScreenPopupError.ParseMouse(mouseBtn, mouseDown, Event.button.x, Event.button.y) + else if (ScreenPopupCheck <> nil) and (ScreenPopupCheck.Visible) then + done := not ScreenPopupCheck.ParseMouse(mouseBtn, mouseDown, Event.button.x, Event.button.y) + else begin - // + done := not Display.CurrentScreen^.ParseMouse(mouseBtn, mouseDown, Event.button.x, Event.button.y); + + // if screen wants to exit + if done then + DoQuit; end; end; -} end; SDL_VIDEORESIZE: begin @@ -437,14 +483,14 @@ begin if boolean( Ini.FullScreen ) then begin SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_FULLSCREEN); - SDL_ShowCursor(0); end else begin SDL_SetVideoMode(ScreenW, ScreenH, (Ini.Depth+1) * 16, SDL_OPENGL or SDL_RESIZABLE); - SDL_ShowCursor(1); end; + Display.SetCursor; + glViewPort(0, 0, ScreenW, ScreenH); {$IFEND} end @@ -464,19 +510,7 @@ begin // if screen wants to exit if Done then - begin - // if question option is enabled then show exit popup - if (Ini.AskbeforeDel = 1) then - begin - Display.CurrentScreen^.CheckFadeTo(nil,'MSG_QUIT_USDX'); - end - else // if ask-for-exit is disabled then simply exit - begin - Display.Fade := 0; - Display.NextScreenWithCheck := nil; - Display.CheckOK := true; - end; - end; + DoQuit; end; end; diff --git a/src/menu/UDisplay.pas b/src/menu/UDisplay.pas index 58c416db..10a80c00 100644 --- a/src/menu/UDisplay.pas +++ b/src/menu/UDisplay.pas @@ -60,6 +60,17 @@ type OSD_LastError: string; + { software cursor data } + Cursor_X: Double; + Cursor_Y: Double; + Cursor_Pressed: Boolean; + Cursor_HiddenByScreen: Boolean; // hides software cursor and deactivate auto fade in + + // used for cursor fade out when there is no movement + Cursor_Visible: Boolean; + Cursor_LastMove: Cardinal; + Cursor_Fade: Boolean; + procedure DrawDebugInformation; public NextScreen: PMenu; @@ -78,11 +89,28 @@ type procedure SaveScreenShot; function Draw: boolean; + + { sets SDL_ShowCursor depending on options set in Ini } + procedure SetCursor; + + { called when cursor moves, positioning of software cursor } + procedure MoveCursor(X, Y: Double; Pressed: Boolean); + + + { draws software cursor } + procedure DrawCursor; end; var Display: TDisplay; +const + { constants for software cursor effects + time in milliseconds } + Cursor_FadeIn_Time = 500; // seconds the fade in effect lasts + Cursor_FadeOut_Time = 2000; // seconds the fade out effect lasts + Cursor_AutoHide_Time = 5000; // seconds until auto fade out starts if there is no mouse movement + implementation uses @@ -125,6 +153,15 @@ begin //Set LastError for OSD to No Error OSD_LastError := 'No Errors'; + + // software cursor default values + Cursor_LastMove := SDL_GetTicks; + Cursor_Visible := false; + Cursor_Pressed := false; + Cursor_X := -1; + Cursor_Y := -1; + Cursor_Fade := false; + Cursor_HiddenByScreen := true; end; destructor TDisplay.Destroy; @@ -306,6 +343,160 @@ begin if ((Ini.Debug = 1) or (Params.Debug)) and (S = 1) then DrawDebugInformation; end; // for + + if not BlackScreen then + DrawCursor; +end; + +{ sets SDL_ShowCursor depending on options set in Ini } +procedure TDisplay.SetCursor; + var + Cursor: Integer; +begin + Cursor := 0; + + if (CurrentScreen <> @ScreenSing) or (Cursor_HiddenByScreen) then + begin // hide cursor on singscreen + if (Ini.Mouse = 0) and (Ini.FullScreen = 0) then + // show sdl (os) cursor in window mode even when mouse support is off + Cursor := 1 + else if (Ini.Mouse = 1) then + // show sdl (os) cursor when hardware cursor is selected + Cursor := 1; + + if (Ini.Mouse <> 2) then + Cursor_HiddenByScreen := false; + end + else if (Ini.Mouse <> 2) then + Cursor_HiddenByScreen := true; + + + SDL_ShowCursor(Cursor); + + if (Ini.Mouse = 2) then + begin + if Cursor_HiddenByScreen then + begin + // show software cursor + Cursor_HiddenByScreen := false; + Cursor_Visible := false; + Cursor_Fade := false; + end + else if (CurrentScreen = @ScreenSing) then + begin + // hide software cursor in singscreen + Cursor_HiddenByScreen := true; + Cursor_Visible := false; + Cursor_Fade := false; + end; + end; +end; + +{ called when cursor moves, positioning of software cursor } +procedure TDisplay.MoveCursor(X, Y: Double; Pressed: Boolean); +var + Ticks: Cardinal; +begin + if (Ini.Mouse = 2) and ((X <> Cursor_X) or (Y <> Cursor_Y) or (Pressed <> Cursor_Pressed)) then + begin + Cursor_X := X; + Cursor_Y := Y; + Cursor_Pressed := Pressed; + + Ticks := SDL_GetTicks; + + if not Cursor_Visible then + begin + if (Cursor_Fade) then // we use a trick here to consider progress of fade out + Cursor_LastMove := Ticks - round(Cursor_FadeIn_Time * (1 - (Ticks - Cursor_LastMove)/Cursor_FadeOut_Time)) + else + Cursor_LastMove := Ticks; + + Cursor_Visible := True; + Cursor_Fade := True; + end + else if not Cursor_Fade then + begin + Cursor_LastMove := Ticks; + end; + end; +end; + +{ draws software cursor } +procedure TDisplay.DrawCursor; + var + Alpha: Single; + Ticks: Cardinal; +begin + if (Ini.Mouse = 2) then + begin // draw software cursor + Ticks := SDL_GetTicks; + + if (Cursor_Visible) and (Cursor_LastMove + Cursor_AutoHide_Time <= Ticks) then + begin // start fade out after 5 secs w/o activity + Cursor_Visible := False; + Cursor_LastMove := Ticks; + Cursor_Fade := True; + end; + + // fading + if (Cursor_Fade) then + begin + if (Cursor_Visible) then + begin // fade in + if (Cursor_LastMove + Cursor_FadeIn_Time <= Ticks) then + Cursor_Fade := False + else + Alpha := sin((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeIn_Time) * 0.7; + end + else + begin //fade out + if (Cursor_LastMove + Cursor_FadeOut_Time <= Ticks) then + Cursor_Fade := False + else + Alpha := cos((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeOut_Time) * 0.7; + end; + end; + + // no else if here because we may turn off fade in if block + if not Cursor_Fade then + begin + if Cursor_Visible then + Alpha := 0.7 // alpha when cursor visible and not fading + else + Alpha := 0; // alpha when cursor is hidden + end; + + if (Alpha > 0) and (not Cursor_HiddenByScreen) then + begin + glColor4f(1, 1, 1, Alpha); + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + + if (Cursor_Pressed) and (Tex_Cursor_Pressed.TexNum > 0) then + glBindTexture(GL_TEXTURE_2D, Tex_Cursor_Pressed.TexNum) + else + glBindTexture(GL_TEXTURE_2D, Tex_Cursor_Unpressed.TexNum); + + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex2f(Cursor_X, Cursor_Y); + + glTexCoord2f(0, 1); + glVertex2f(Cursor_X, Cursor_Y + 32); + + glTexCoord2f(1, 1); + glVertex2f(Cursor_X + 32, Cursor_Y + 32); + + glTexCoord2f(1, 0); + glVertex2f(Cursor_X + 32, Cursor_Y); + glEnd; + + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; + end; end; procedure TDisplay.SaveScreenShot; diff --git a/src/menu/UMenu.pas b/src/menu/UMenu.pas index ceb4ac77..7d8bdce8 100644 --- a/src/menu/UMenu.pas +++ b/src/menu/UMenu.pas @@ -35,6 +35,7 @@ interface uses gl, + SDL, SysUtils, UTexture, UMenuStatic, @@ -61,7 +62,7 @@ type ButtonPos: integer; Button: array of TButton; - + SelectsS: array of TSelectSlide; ButtonCollection: array of TButtonCollection; public @@ -72,6 +73,7 @@ type Fade: integer; // fade type ShowFinish: boolean; // true if there is no fade + RightMbESC: boolean; // true to simulate ESC keypress when RMB is pressed destructor Destroy; override; constructor Create; overload; virtual; @@ -82,7 +84,7 @@ type function WideCharUpperCase(wchar: WideChar) : WideString; function WideStringUpperCase(wstring: WideString) : WideString; procedure AddInteraction(Typ, Num: integer); - procedure SetInteraction(Num: integer); + procedure SetInteraction(Num: integer); virtual; property Interaction: integer read SelInteraction write SetInteraction; //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic @@ -145,9 +147,10 @@ type function DrawFG: boolean; virtual; function Draw: boolean; virtual; function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown : boolean): boolean; virtual; - // FIXME: ParseMouse is not implemented in any subclass and not even used anywhere in the code - // -> do this before activation of this method - //function ParseMouse(Typ: integer; X: integer; Y: integer): boolean; virtual; abstract; + function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; virtual; + function InRegion(X1, Y1, W, H, X, Y: real): Boolean; + function InteractAt(X, Y: real): Integer; + function CollectionAt(X, Y: real): Integer; procedure onShow; virtual; procedure onShowFinish; virtual; procedure onHide; virtual; @@ -167,8 +170,11 @@ type end; const - pmMove = 1; - pmClick = 2; + MENU_MDOWN = 8; + MENU_MUP = 0; + + pmMove = 1; + pmClick = 2; pmUnClick = 3; iButton = 0; // interaction type @@ -221,6 +227,8 @@ begin ButtonPos := -1; Background := nil; + + RightMbESC := True; end; { constructor TMenu.Create(Back: string); @@ -1595,6 +1603,103 @@ begin Result := true; end; +function TMenu.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +var + nBut: Integer; +begin + //default mouse parsing: clicking generates return keypress, + // mousewheel selects in select slide + //override ParseMouse to customize + Result := true; + + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then begin + //if RightMbESC is set, send ESC keypress + Result:=ParseInput(SDLK_ESCAPE, #0, True); + end; + + nBut := InteractAt(X, Y); + if nBut >= 0 then begin + //select on mouse-over + if nBut <> Interaction then + SetInteraction(nBut); + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + //click button + Result:=ParseInput(SDLK_RETURN, #0, True); + end; + if (Interactions[nBut].Typ = iSelectS) then begin + //forward/backward in select slide with mousewheel + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then begin + ParseInput(SDLK_RIGHT, #0, true); + end; + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then begin + ParseInput(SDLK_LEFT, #0, true); + end; + end; + end + else begin + nBut := CollectionAt(X, Y); + if nBut >= 0 then begin + //if over button collection, select first child but don't allow click + nBut := ButtonCollection[nBut].FirstChild - 1; + if nBut <> Interaction then + SetInteraction(nBut); + end; + end; +end; + +function TMenu.InRegion(X1, Y1, W, H, X, Y: real): Boolean; +begin + Result:=False; + X1 := X1 * Screen.w/800; + W := W * Screen.w/800; + Y1 := Y1 * Screen.h/600; + H := H * Screen.h/600; + if (X >= X1) and (X <= X1+W) and (Y >= Y1) and (Y <= Y1+H) then + Result := true; +end; + +//takes x,y coordinates and returns the interaction number +//of the control at this position +function TMenu.InteractAt(X, Y: real): Integer; +var + i, nBut: Integer; +begin + Result:=-1; + for i:=Low(Interactions) to High(Interactions) do begin + case Interactions[i].Typ of + iButton:if InRegion(Button[Interactions[i].Num].X, Button[Interactions[i].Num].Y, Button[Interactions[i].Num].W, Button[Interactions[i].Num].H, X, Y) and + Button[Interactions[i].Num].Visible then begin + Result:=i; + exit; + end; + iBCollectionChild:if InRegion(Button[Interactions[i].Num].X, Button[Interactions[i].Num].Y, Button[Interactions[i].Num].W, Button[Interactions[i].Num].H, X, Y) then begin + Result:=i; + exit; + end; + iSelectS:if InRegion(SelectSs[Interactions[i].Num].X, SelectSs[Interactions[i].Num].Y, SelectSs[Interactions[i].Num].W, SelectSs[Interactions[i].Num].H, X, Y) or + InRegion(SelectSs[Interactions[i].Num].TextureSBG.X, SelectSs[Interactions[i].Num].TextureSBG.Y, SelectSs[Interactions[i].Num].TextureSBG.W, SelectSs[Interactions[i].Num].TextureSBG.H, X, Y) then begin + Result:=i; + exit; + end; + end; + end; +end; + +//takes x,y coordinates and returns the button collection id +function TMenu.CollectionAt(X, Y: real): Integer; +var + i, nBut: Integer; +begin + Result:=-1; + for i:=Low(ButtonCollection) to High(ButtonCollection) do begin + if InRegion(ButtonCollection[i].X, ButtonCollection[i].Y, ButtonCollection[i].W, ButtonCollection[i].H, X, Y) and + ButtonCollection[i].Visible then begin + Result:=i; + exit; + end; + end; +end; + procedure TMenu.SetAnimationProgress(Progress: real); begin // nothing diff --git a/src/screens/UScreenMain.pas b/src/screens/UScreenMain.pas index 36cf84b0..a4e6009f 100644 --- a/src/screens/UScreenMain.pas +++ b/src/screens/UScreenMain.pas @@ -52,10 +52,7 @@ type function ParseInput(PressedKey: cardinal; CharCode: widechar; PressedDown: boolean): boolean; override; procedure onShow; override; - procedure InteractNext; override; - procedure InteractPrev; override; - procedure InteractInc; override; - procedure InteractDec; override; + procedure SetInteraction(Num: integer); override; procedure SetAnimationProgress(Progress: real); override; end; @@ -238,36 +235,19 @@ end; procedure TScreenMain.onShow; begin inherited; + + { display cursor (on moved) } + Display.SetCursor; + {** * Start background music *} SoundLib.StartBgMusic; end; -procedure TScreenMain.InteractNext; -begin - inherited InteractNext; - Text[TextDescription].Text := Theme.Main.Description[Interaction]; - Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; -end; - -procedure TScreenMain.InteractPrev; -begin - inherited InteractPrev; - Text[TextDescription].Text := Theme.Main.Description[Interaction]; - Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; -end; - -procedure TScreenMain.InteractDec; -begin - inherited InteractDec; - Text[TextDescription].Text := Theme.Main.Description[Interaction]; - Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; -end; - -procedure TScreenMain.InteractInc; +procedure TScreenMain.SetInteraction(Num: integer); begin - inherited InteractInc; + inherited SetInteraction(Num); Text[TextDescription].Text := Theme.Main.Description[Interaction]; Text[TextDescriptionLong].Text := Theme.Main.DescriptionLong[Interaction]; end; diff --git a/src/screens/UScreenScore.pas b/src/screens/UScreenScore.pas index f3f888b3..a01c7691 100644 --- a/src/screens/UScreenScore.pas +++ b/src/screens/UScreenScore.pas @@ -129,6 +129,7 @@ type constructor Create; override; function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override; procedure onShow; override; procedure onShowFinish; override; function Draw: boolean; override; @@ -191,6 +192,15 @@ begin end; end; +function TScreenScore.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +begin + Result := True; + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + //left-click anywhere sends return + ParseInput(SDLK_RETURN, #0, true); + end; +end; + constructor TScreenScore.Create; var Player: integer; diff --git a/src/screens/UScreenSing.pas b/src/screens/UScreenSing.pas index 4389352a..ae75c74d 100644 --- a/src/screens/UScreenSing.pas +++ b/src/screens/UScreenSing.pas @@ -126,7 +126,8 @@ uses ULanguage, UNote, URecord, - USong; + USong, + UDisplay; // method for input parsing. if false is returned, getnextwindow // should be checked to know the next window to load; @@ -253,6 +254,9 @@ constructor TScreenSing.Create; begin inherited Create; + //too dangerous, a mouse button is quickly pressed by accident + RightMbESC := false; + fShowVisualization := false; fCurrentVideoPlaybackEngine := VideoPlayback; @@ -623,6 +627,9 @@ end; procedure TScreenSing.onShowFinish; begin + // hide cursor on singscreen show + Display.SetCursor; + // start lyrics LyricsState.Resume(); @@ -643,6 +650,7 @@ begin end; Background.OnFinish; + Display.SetCursor; end; function TScreenSing.Draw: boolean; diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index f937b1dc..5e794891 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -119,6 +119,7 @@ type procedure SetScroll5; procedure SetScroll6; function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override; function Draw: boolean; override; procedure GenerateThumbnails(); procedure onShow; override; @@ -737,6 +738,28 @@ begin end; // if (PressedDown) end; +function TScreenSong.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +begin + Result := True; + + if RightMbESC and (MouseButton = SDL_BUTTON_RIGHT) and BtnDown then begin + //if RightMbESC is set, send ESC keypress + Result:=ParseInput(SDLK_ESCAPE, #0, True); + end; + + //song scrolling with mousewheel + if (MouseButton = SDL_BUTTON_WHEELDOWN) and BtnDown then begin + ParseInput(SDLK_RIGHT, #0, true); + end; + if (MouseButton = SDL_BUTTON_WHEELUP) and BtnDown then begin + ParseInput(SDLK_LEFT, #0, true); + end; + //LMB anywhere starts + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + ParseInput(SDLK_RETURN, #0, true); + end; +end; + constructor TScreenSong.Create; var i: integer; diff --git a/src/screens/UScreenTop5.pas b/src/screens/UScreenTop5.pas index 23405ebb..39de61c3 100644 --- a/src/screens/UScreenTop5.pas +++ b/src/screens/UScreenTop5.pas @@ -57,6 +57,7 @@ type constructor Create; override; function ParseInput(PressedKey: cardinal; CharCode: WideChar; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; override; procedure onShow; override; function Draw: boolean; override; end; @@ -103,6 +104,15 @@ begin end; end; +function TScreenTop5.ParseMouse(MouseButton: Integer; BtnDown: Boolean; X, Y: integer): boolean; +begin + Result := True; + if (MouseButton = SDL_BUTTON_LEFT) and BtnDown then begin + //left-click anywhere sends return + ParseInput(SDLK_RETURN, #0, true); + end; +end; + constructor TScreenTop5.Create; var I: integer; -- cgit v1.2.3