diff options
-rw-r--r-- | src/screens/UScreenCredits.pas | 3 | ||||
-rw-r--r-- | src/screens/UScreenMain.pas | 36 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/screens/UScreenCredits.pas b/src/screens/UScreenCredits.pas index a428cb15..b87af6bd 100644 --- a/src/screens/UScreenCredits.pas +++ b/src/screens/UScreenCredits.pas @@ -187,7 +187,8 @@ begin case PressedKey of SDLK_ESCAPE, - SDLK_BACKSPACE : + SDLK_BACKSPACE, + SDLK_RETURN : begin FadeTo(@ScreenMain); AudioPlayback.PlaySound(SoundLib.Back); diff --git a/src/screens/UScreenMain.pas b/src/screens/UScreenMain.pas index 8bb9365b..777922de 100644 --- a/src/screens/UScreenMain.pas +++ b/src/screens/UScreenMain.pas @@ -44,6 +44,10 @@ uses type TScreenMain = class(TMenu) + private + { ticks when the user interacted, used to start credits + after a period of time w/o user interaction } + UserInteractionTicks: cardinal; public TextDescription: integer; TextDescriptionLong: integer; @@ -51,11 +55,17 @@ type constructor Create; override; function ParseInput(PressedKey: Cardinal; CharCode: UCS4Char; PressedDown: boolean): boolean; override; + function ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; override; procedure OnShow; override; procedure SetInteraction(Num: integer); override; procedure SetAnimationProgress(Progress: real); override; + function Draw: boolean; override; end; +const + { start credits after 30 seconds w/o interaction } + TicksUntilCredits = 30 * 1000; + implementation uses @@ -78,6 +88,9 @@ var begin Result := true; + { reset user interaction timer } + UserInteractionTicks := SDL_GetTicks; + SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT); @@ -205,6 +218,15 @@ begin end; end; +function TScreenMain.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean; +begin + // default mouse behaviour + Result := inherited ParseMouse(MouseButton, BtnDown, X, Y); + + { reset user interaction timer } + UserInteractionTicks := SDL_GetTicks; +end; + constructor TScreenMain.Create; begin inherited Create; @@ -239,6 +261,20 @@ begin * at the moment there is no better place for this *} Party.Clear; + + { reset user interaction timer } + UserInteractionTicks := SDL_GetTicks; +end; + +function TScreenMain.Draw: boolean; +begin + Result := inherited Draw; + + { start credits after a period w/o user interaction } + if (UserInteractionTicks + TicksUntilCredits < SDL_GetTicks) then + begin + FadeTo(@ScreenCredits, SoundLib.Start); + end; end; procedure TScreenMain.SetInteraction(Num: integer); |