aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-06-17 14:45:09 +0000
committerwhiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c>2010-06-17 14:45:09 +0000
commitf53aa00aaef03e3c28f4e9b71184ce2668472b38 (patch)
treefc70188981db041981c4f2c2b710989ac6744012
parent588095fb82564c2abf34278e8d0767d92ccb463e (diff)
downloadusdx-f53aa00aaef03e3c28f4e9b71184ce2668472b38.tar.gz
usdx-f53aa00aaef03e3c28f4e9b71184ce2668472b38.tar.xz
usdx-f53aa00aaef03e3c28f4e9b71184ce2668472b38.zip
- enter credits screen after 30 seconds w/o user interaction in main screen
- leave credits screen w/ left / right mouse button, enter, return, escape and backspace git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2536 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r--src/screens/UScreenCredits.pas3
-rw-r--r--src/screens/UScreenMain.pas36
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);