aboutsummaryrefslogtreecommitdiffstats
path: root/us_maker_edition/src/menu/UDisplay.pas
diff options
context:
space:
mode:
Diffstat (limited to 'us_maker_edition/src/menu/UDisplay.pas')
-rw-r--r--us_maker_edition/src/menu/UDisplay.pas83
1 files changed, 35 insertions, 48 deletions
diff --git a/us_maker_edition/src/menu/UDisplay.pas b/us_maker_edition/src/menu/UDisplay.pas
index e3ec272a..6ec8e2ed 100644
--- a/us_maker_edition/src/menu/UDisplay.pas
+++ b/us_maker_edition/src/menu/UDisplay.pas
@@ -51,12 +51,12 @@ type
ePreDraw: THookableEvent;
eDraw: THookableEvent;
- //fade-to-black-hack
+ // fade-to-black
BlackScreen: boolean;
FadeEnabled: boolean; // true if fading is enabled
FadeFailed: boolean; // true if fading is possible (enough memory, etc.)
- FadeTime: cardinal; // time when fading starts, 0 means that the fade texture must be initialized
+ FadeStartTime: cardinal; // time when fading starts, 0 means that the fade texture must be initialized
DoneOnShow: boolean; // true if passed onShow after fading
FadeTex: array[0..1] of GLuint;
@@ -87,7 +87,7 @@ type
NextScreen: PMenu;
CurrentScreen: PMenu;
- //popup data
+ // popup data
NextScreenWithCheck: Pmenu;
CheckOK: boolean;
@@ -130,12 +130,12 @@ var
const
{ constants for screen transition
time in milliseconds }
- Transition_Fade_Time = 400;
+ FADE_DURATION = 400;
{ 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
+ CURSOR_FADE_IN_TIME = 500; // seconds the fade in effect lasts
+ CURSOR_FADE_OUT_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
@@ -160,14 +160,14 @@ begin
ePreDraw := THookableEvent.Create('Display.PreDraw');
eDraw := THookableEvent.Create('Display.Draw');
- //popup hack
+ // init popup
CheckOK := false;
NextScreen := nil;
NextScreenWithCheck := nil;
BlackScreen := false;
- // fade mod
- FadeTime := 0;
+ // init fade
+ FadeStartTime := 0;
FadeEnabled := (Ini.ScreenFade = 1);
FadeFailed := false;
DoneOnShow := false;
@@ -175,7 +175,7 @@ begin
glGenTextures(2, PGLuint(@FadeTex));
InitFadeTextures();
- //Set LastError for OSD to No Error
+ // set LastError for OSD to No Error
OSD_LastError := 'No Errors';
// software cursor default values
@@ -222,11 +222,6 @@ var
begin
Result := true;
- //We don't need this here anymore,
- //Because the background care about cleaning the buffers
- //glClearColor(1, 1, 1 , 0);
- //glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
-
for S := 1 to Screens do
begin
ScreenAct := S;
@@ -238,8 +233,7 @@ begin
glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH);
- // popup hack
- // check was successful... move on
+ // popup check was successful... move on
if CheckOK then
begin
if assigned(NextScreenWithCheck) then
@@ -260,7 +254,7 @@ begin
ePreDraw.CallHookChain(false);
CurrentScreen.Draw;
- //popup mod
+ // popup
if (ScreenPopupError <> nil) and ScreenPopupError.Visible then
ScreenPopupError.Draw
else if (ScreenPopupInfo <> nil) and ScreenPopupInfo.Visible then
@@ -268,11 +262,11 @@ begin
else if (ScreenPopupCheck <> nil) and ScreenPopupCheck.Visible then
ScreenPopupCheck.Draw;
- // fade mod
- FadeTime := 0;
+ // fade
+ FadeStartTime := 0;
if ((Ini.ScreenFade = 1) and (not FadeFailed)) then
FadeEnabled := true
- else if (Ini.ScreenFade = 0) then
+ else
FadeEnabled := false;
eDraw.CallHookChain(false);
@@ -287,8 +281,8 @@ begin
if (FadeEnabled and not FadeFailed) then
begin
- //Create Fading texture if we're just starting
- if FadeTime = 0 then
+ // create fading texture if we're just starting
+ if FadeStartTime = 0 then
begin
// draw screen that will be faded
ePreDraw.CallHookChain(false);
@@ -319,7 +313,6 @@ begin
Log.LogError('Fading disabled: ' + gluErrorString(glError), 'TDisplay.Draw');
end;
- // blackscreen-hack
if not BlackScreen and (S = 1) and not DoneOnShow then
begin
NextScreen.OnShow;
@@ -329,18 +322,9 @@ begin
// set fade time once on second screen (or first if screens = 1)
if (Screens = 1) or (S = 2) then
- FadeTime := SDL_GetTicks;
+ FadeStartTime := SDL_GetTicks;
end; // end texture creation in first fading step
- {//do some time-based fading
- currentTime := SDL_GetTicks();
- if (currentTime > LastFadeTime+30) and (S = 1) then
- begin
- FadeState := FadeState + 5;
- LastFadeTime := currentTime;
- end; }
-
- // blackscreen-hack
if not BlackScreen then
begin
ePreDraw.CallHookChain(false);
@@ -349,15 +333,16 @@ begin
end
else if ScreenAct = 1 then
begin
+ // draw black screen
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
end;
// and draw old screen over it... slowly fading out
- if (FadeTime = 0) then
+ if (FadeStartTime = 0) then
FadeStateSquare := 0 // for first screen if screens = 2
else
- FadeStateSquare := sqr((SDL_GetTicks - FadeTime) / Transition_Fade_Time);
+ FadeStateSquare := sqr((SDL_GetTicks - FadeStartTime) / FADE_DURATION);
if (FadeStateSquare < 1) then
begin
@@ -392,17 +377,19 @@ begin
//glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
end;
end
-
- // blackscreen hack
+
+ // there is no need to init next screen if it is a black screen
else if not BlackScreen then
begin
NextScreen.OnShow;
end;
- if ((FadeTime + Transition_Fade_Time < SDL_GetTicks) or (not FadeEnabled) or FadeFailed) and ((Screens = 1) or (S = 2)) then
+ if ((FadeStartTime + FADE_DURATION < SDL_GetTicks) or
+ (not FadeEnabled) or FadeFailed) and
+ ((Screens = 1) or (S = 2)) then
begin
// fade out complete...
- FadeTime := 0;
+ FadeStartTime := 0;
DoneOnShow := false;
CurrentScreen.onHide;
CurrentScreen.ShowFinish := false;
@@ -421,7 +408,7 @@ begin
end;
end; // if
-// Draw OSD only on first Screen if Debug Mode is enabled
+ // Draw OSD only on first Screen if Debug Mode is enabled
if ((Ini.Debug = 1) or (Params.Debug)) and (S = 1) then
DrawDebugInformation;
@@ -485,7 +472,7 @@ begin
if (not Cursor_Visible) and (Cursor_LastMove <> 0) 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))
+ Cursor_LastMove := Ticks - round(CURSOR_FADE_IN_TIME * (1 - (Ticks - Cursor_LastMove)/CURSOR_FADE_OUT_TIME))
else
Cursor_LastMove := Ticks;
@@ -533,7 +520,7 @@ begin
begin // draw software cursor
Ticks := SDL_GetTicks;
- if (Cursor_Visible) and (Cursor_LastMove + Cursor_AutoHide_Time <= Ticks) then
+ 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;
@@ -545,17 +532,17 @@ begin
begin
if Cursor_Visible then
begin // fade in
- if (Cursor_LastMove + Cursor_FadeIn_Time <= Ticks) then
+ if (Cursor_LastMove + CURSOR_FADE_IN_TIME <= Ticks) then
Cursor_Fade := false
else
- Alpha := sin((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeIn_Time) * 0.7;
+ Alpha := sin((Ticks - Cursor_LastMove) * 0.5 * pi / CURSOR_FADE_IN_TIME) * 0.7;
end
else
begin //fade out
- if (Cursor_LastMove + Cursor_FadeOut_Time <= Ticks) then
+ if (Cursor_LastMove + CURSOR_FADE_OUT_TIME <= Ticks) then
Cursor_Fade := false
else
- Alpha := cos((Ticks - Cursor_LastMove) * 0.5 * pi / Cursor_FadeOut_Time) * 0.7;
+ Alpha := cos((Ticks - Cursor_LastMove) * 0.5 * pi / CURSOR_FADE_OUT_TIME) * 0.7;
end;
end;