aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Menu
diff options
context:
space:
mode:
Diffstat (limited to 'Game/Code/Menu')
-rw-r--r--Game/Code/Menu/UDisplay.pas840
-rw-r--r--Game/Code/Menu/UDrawTexture.pas210
-rw-r--r--Game/Code/Menu/UMenuButton.pas1140
-rw-r--r--Game/Code/Menu/UMenuButtonCollection.pas142
-rw-r--r--Game/Code/Menu/UMenuInteract.pas30
-rw-r--r--Game/Code/Menu/UMenuSelect.pas402
-rw-r--r--Game/Code/Menu/UMenuStatic.pas170
7 files changed, 1467 insertions, 1467 deletions
diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas
index 94a63ca9..f27320fb 100644
--- a/Game/Code/Menu/UDisplay.pas
+++ b/Game/Code/Menu/UDisplay.pas
@@ -1,420 +1,420 @@
-unit UDisplay;
-
-interface
-
-{$IFDEF FPC}
- {$MODE Delphi}
-{$ENDIF}
-
-{$I switches.inc}
-
-uses
- ucommon,
- SDL,
- UMenu,
- gl,
- glu,
- SysUtils;
-
-type
- TDisplay = class
- private
- //fade-to-black-hack
- BlackScreen: Boolean;
-
- doFade : Boolean;
- canFade : Boolean;
- myFade : integer;
- lastTime : Cardinal;
- pTexData : Pointer;
- pTex : array[1..2] of glUInt;
-
- FPSCounter : Cardinal;
- LastFPS : Cardinal;
- NextFPSSwap : Cardinal;
-
- OSD_LastError : String;
-
- procedure DrawDebugInformation;
- public
- NextScreen : PMenu;
- CurrentScreen : PMenu;
-
- //popup hack
- NextScreenWithCheck: Pmenu;
- CheckOK : Boolean;
-
- Fade : Real;
-
- constructor Create;
- destructor Destroy; override;
-
- procedure SaveScreenShot;
-
- function Draw: Boolean;
- end;
-
-var
- Display: TDisplay;
-
-implementation
-
-uses
- UImage,
- TextGL,
- ULog,
- UMain,
- UTexture,
- UIni,
- UGraphic,
- UTime,
- UCommandLine;
-
-constructor TDisplay.Create;
-var
- i: integer;
-
-begin
- inherited Create;
-
- //popup hack
- CheckOK := False;
- NextScreen := NIL;
- NextScreenWithCheck := NIL;
- BlackScreen := False;
-
- // fade mod
- myfade:=0;
-
- if Ini.ScreenFade=1 then
- doFade:=True
- else
- doFade:=False;
-
- canFade:=True;
- // generate texture for fading between screens
- GetMem(pTexData, 512*512*4);
-
- if pTexData <> NIL then
- for i:= 1 to 2 do
- begin
-
- glGenTextures(1, @pTex[i] );
-
- if glGetError <> GL_NO_ERROR then
- canFade := False;
-
- glBindTexture(GL_TEXTURE_2D, pTex[i]);
- if glGetError <> GL_NO_ERROR then
- canFade := False;
-
- glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData);
- if glGetError <> GL_NO_ERROR then
- canFade := False;
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- if glGetError <> GL_NO_ERROR then
- canFade := False;
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- if glGetError <> GL_NO_ERROR then
- canFade := False;
- end
- else
- begin
- canFade:=False;
- end;
-
- FreeMem(pTexData);
-
- //Set LastError for OSD to No Error
- OSD_LastError := 'No Errors';
-end;
-
-destructor TDisplay.Destroy;
-begin
- if canFade then
- glDeleteTextures(1,@pTex);
-
- inherited Destroy;
-end;
-
-function TDisplay.Draw: Boolean;
-var
- S: integer;
- Col: Real;
- myFade2: Real;
- currentTime: Cardinal;
- glError: glEnum;
- glErrorStr: String;
-begin
- Result := True;
-
- Col := 1;
- {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then
- Col := 0; }
-
- glClearColor(Col, Col, Col , 0);
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
-
- for S := 1 to Screens do begin
- ScreenAct := S;
-
-// if Screens = 1 then ScreenX := 0;
-// if (Screens = 2) and (S = 1) then ScreenX := -1;
-// if (Screens = 2) and (S = 2) then ScreenX := 1;
- ScreenX := 0;
-
- glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH);
-
- //popup hack
- // check was successful... move on
- if CheckOK then
- begin
- if assigned (NextScreenWithCheck)then
- begin
- NextScreen:=NextScreenWithCheck;
- NextScreenWithCheck := NIL;
- CheckOk:=False;
- end
- else
- begin
- BlackScreen:=True; // end of game - fade to black before exit
- end;
- end;
-
-// CurrentScreen.SetAnimationProgress(1);
- if (not assigned (NextScreen)) and (not BlackScreen) then
- begin
- CurrentScreen.Draw;
-
- //popup mod
- if (ScreenPopupError <> NIL) and ScreenPopupError.Visible then
- ScreenPopupError.Draw
- else if (ScreenPopupCheck <> NIL) and ScreenPopupCheck.Visible then
- ScreenPopupCheck.Draw;
-
- // fade mod
- myfade:=0;
- if (Ini.ScreenFade=1) and canFade then
- doFade:=True
- else if Ini.ScreenFade=0 then
- doFade:=False;
- end
- else
- begin
- // check if we had an initialization error (canfade=false, dofade=true)
- if doFade and not canFade then
- begin
- doFade:=False; //disable fading
-// ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message
- end;
- if doFade and canFade then
- begin
- // fade mod
- //Create Fading texture if we're just starting
- if myfade = 0 then
- begin
- glViewPort(0, 0, 512, 512);
- CurrentScreen.Draw;
- glBindTexture(GL_TEXTURE_2D, pTex[S]);
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);
- glError:=glGetError;
- if (glError <> GL_NO_ERROR) then
- begin
- canFade := False;
- glErrorStr := gluErrorString(glError);
-// ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message
- end;
- glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH);
- // blackscreen-hack
- if not BlackScreen then
- NextScreen.onShow;
-
- lastTime:=SDL_GetTicks();
- if (S=2) or (Screens = 1) then
- myfade:=myfade+1;
- end; // end texture creation in first fading step
-
- //do some time-based fading
- currentTime:=SDL_GetTicks();
- if (currentTime > lastTime+30) and (S=1) then
- begin
- myfade:=myfade+4;
- lastTime:=currentTime;
- end;
-
-// LastFade := Fade; // whatever
-// Fade := Fade -0.999; // start fading out
-
-
-// CurrentScreen.ShowFinish := false; // no purpose?
-
-// CurrentScreen.SetAnimationProgress(Fade-1); // nop?
-
- // blackscreen-hack
- if not BlackScreen then
- NextScreen.Draw // draw next screen
- else if ScreenAct=1 then
- begin
- glClearColor(0, 0, 0 , 0);
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- end;
-
- // and draw old screen over it... slowly fading out
- myfade2:=(myfade*myfade)/10000;
- glBindTexture(GL_TEXTURE_2D, pTex[S]);
- glColor4f(1, 1, 1, (1000-myfade*myfade)/1000); // strange calculation - alpha gets negative... but looks good this way
- glEnable(GL_TEXTURE_2D);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
- glBegin(GL_QUADS);
- glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600);
- glTexCoord2f(0+myfade2,1-myfade2);glVertex2f(0, 0);
- glTexCoord2f(1-myfade2,1-myfade2);glVertex2f(800, 0);
- glTexCoord2f(1-myfade2,0+myfade2);glVertex2f(800, 600);
- glEnd;
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- end
- // blackscreen hack
- else if not BlackScreen then
- begin
- NextScreen.OnShow;
- end;
-
- if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then
- begin // fade out complete...
- myFade:=0;
- CurrentScreen.onHide;
- CurrentScreen.ShowFinish:=False;
- CurrentScreen:=NextScreen;
- NextScreen := nil;
- if not blackscreen then
- begin
- CurrentScreen.onShowFinish;
- CurrentScreen.ShowFinish := true;
- end
- else
- begin
- Result:=False;
- Break;
- end;
- // end of fade mod
- end;
- end; // if
-
- //Draw OSD only on first Screen if Debug Mode is enabled
- if ((Ini.Debug = 1) or (Params.Debug)) and (S=1) then
- DrawDebugInformation;
-
- end; // for
-
- // SDL_GL_SwapBuffers();
-end;
-
-{function TDisplay.Fade(FadeIn : Boolean; Steps : UInt8): UInt8;
-begin
- Self.FadeIn := FadeIn;
- FadeStep := (SizeOf(FadeStep) * $FF) div Steps;
- ActualStep := $FF;
- Result := $FF div FadeStep;
-end;}
-
-procedure TDisplay.SaveScreenShot;
-var
- Num: integer;
- FileName: string;
- ScreenData: PChar;
- Surface: PSDL_Surface;
- Success: boolean;
- Align: integer;
- RowSize: integer;
-begin
- for Num := 1 to 9999 do
- begin
- FileName := IntToStr(Num);
- while Length(FileName) < 4 do
- FileName := '0' + FileName;
- FileName := ScreenshotsPath + 'screenshot' + FileName + '.png';
- if not FileExists(FileName) then
- break
- end;
-
- // we must take the row-alignment (4byte by default) into account
- glGetIntegerv(GL_PACK_ALIGNMENT, @Align);
- // calc aligned row-size
- RowSize := ((ScreenW*3 + (Align-1)) div Align) * Align;
-
- GetMem(ScreenData, RowSize * ScreenH);
- glReadPixels(0, 0, ScreenW, ScreenH, GL_RGB, GL_UNSIGNED_BYTE, ScreenData);
- Surface := SDL_CreateRGBSurfaceFrom(
- ScreenData, ScreenW, ScreenH, 24, RowSize,
- $0000FF, $00FF00, $FF0000, 0);
-
- //Success := WriteJPGImage(FileName, Surface, 95);
- //Success := WriteBMPImage(FileName, Surface);
- Success := WritePNGImage(FileName, Surface);
- if Success then
- ScreenPopupError.ShowPopup('Screenshot saved: ' + ExtractFileName(FileName))
- else
- ScreenPopupError.ShowPopup('Screenshot failed');
-
- SDL_FreeSurface(Surface);
- FreeMem(ScreenData);
-end;
-
-//------------
-// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen
-//------------
-procedure TDisplay.DrawDebugInformation;
-var Ticks: Cardinal;
-begin
- //Some White Background for information
- glEnable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- glColor4f(1, 1, 1, 0.5);
- glBegin(GL_QUADS);
- glVertex2f(690, 44);
- glVertex2f(690, 0);
- glVertex2f(800, 0);
- glVertex2f(800, 44);
- glEnd;
- glDisable(GL_BLEND);
-
- //Set Font Specs
- SetFontStyle(0);
- SetFontSize(7);
- SetFontItalic(False);
- glColor4f(0, 0, 0, 1);
-
- //Calculate FPS
- Ticks := SDL_GetTicks();
- if (Ticks >= NextFPSSwap) then
- begin
- LastFPS := FPSCounter * 4;
- FPSCounter := 0;
- NextFPSSwap := Ticks + 250;
- end;
-
- Inc(FPSCounter);
-
- //Draw Text
-
- //FPS
- SetFontPos(695, 0);
- glPrint (PChar('FPS: ' + InttoStr(LastFPS)));
-
- //RSpeed
- SetFontPos(695, 13);
- glPrint (PChar('RSpeed: ' + InttoStr(Round(1000 * TimeMid))));
-
- //LastError
- SetFontPos(695, 26);
- glColor4f(1, 0, 0, 1);
- glPrint (PChar(OSD_LastError));
-
- glColor4f(1, 1, 1, 1);
-end;
-
-end.
+unit UDisplay;
+
+interface
+
+{$IFDEF FPC}
+ {$MODE Delphi}
+{$ENDIF}
+
+{$I switches.inc}
+
+uses
+ ucommon,
+ SDL,
+ UMenu,
+ gl,
+ glu,
+ SysUtils;
+
+type
+ TDisplay = class
+ private
+ //fade-to-black-hack
+ BlackScreen: Boolean;
+
+ doFade : Boolean;
+ canFade : Boolean;
+ myFade : integer;
+ lastTime : Cardinal;
+ pTexData : Pointer;
+ pTex : array[1..2] of glUInt;
+
+ FPSCounter : Cardinal;
+ LastFPS : Cardinal;
+ NextFPSSwap : Cardinal;
+
+ OSD_LastError : String;
+
+ procedure DrawDebugInformation;
+ public
+ NextScreen : PMenu;
+ CurrentScreen : PMenu;
+
+ //popup hack
+ NextScreenWithCheck: Pmenu;
+ CheckOK : Boolean;
+
+ Fade : Real;
+
+ constructor Create;
+ destructor Destroy; override;
+
+ procedure SaveScreenShot;
+
+ function Draw: Boolean;
+ end;
+
+var
+ Display: TDisplay;
+
+implementation
+
+uses
+ UImage,
+ TextGL,
+ ULog,
+ UMain,
+ UTexture,
+ UIni,
+ UGraphic,
+ UTime,
+ UCommandLine;
+
+constructor TDisplay.Create;
+var
+ i: integer;
+
+begin
+ inherited Create;
+
+ //popup hack
+ CheckOK := False;
+ NextScreen := NIL;
+ NextScreenWithCheck := NIL;
+ BlackScreen := False;
+
+ // fade mod
+ myfade:=0;
+
+ if Ini.ScreenFade=1 then
+ doFade:=True
+ else
+ doFade:=False;
+
+ canFade:=True;
+ // generate texture for fading between screens
+ GetMem(pTexData, 512*512*4);
+
+ if pTexData <> NIL then
+ for i:= 1 to 2 do
+ begin
+
+ glGenTextures(1, @pTex[i] );
+
+ if glGetError <> GL_NO_ERROR then
+ canFade := False;
+
+ glBindTexture(GL_TEXTURE_2D, pTex[i]);
+ if glGetError <> GL_NO_ERROR then
+ canFade := False;
+
+ glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData);
+ if glGetError <> GL_NO_ERROR then
+ canFade := False;
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ if glGetError <> GL_NO_ERROR then
+ canFade := False;
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ if glGetError <> GL_NO_ERROR then
+ canFade := False;
+ end
+ else
+ begin
+ canFade:=False;
+ end;
+
+ FreeMem(pTexData);
+
+ //Set LastError for OSD to No Error
+ OSD_LastError := 'No Errors';
+end;
+
+destructor TDisplay.Destroy;
+begin
+ if canFade then
+ glDeleteTextures(1,@pTex);
+
+ inherited Destroy;
+end;
+
+function TDisplay.Draw: Boolean;
+var
+ S: integer;
+ Col: Real;
+ myFade2: Real;
+ currentTime: Cardinal;
+ glError: glEnum;
+ glErrorStr: String;
+begin
+ Result := True;
+
+ Col := 1;
+ {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then
+ Col := 0; }
+
+ glClearColor(Col, Col, Col , 0);
+ glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
+
+ for S := 1 to Screens do begin
+ ScreenAct := S;
+
+// if Screens = 1 then ScreenX := 0;
+// if (Screens = 2) and (S = 1) then ScreenX := -1;
+// if (Screens = 2) and (S = 2) then ScreenX := 1;
+ ScreenX := 0;
+
+ glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH);
+
+ //popup hack
+ // check was successful... move on
+ if CheckOK then
+ begin
+ if assigned (NextScreenWithCheck)then
+ begin
+ NextScreen:=NextScreenWithCheck;
+ NextScreenWithCheck := NIL;
+ CheckOk:=False;
+ end
+ else
+ begin
+ BlackScreen:=True; // end of game - fade to black before exit
+ end;
+ end;
+
+// CurrentScreen.SetAnimationProgress(1);
+ if (not assigned (NextScreen)) and (not BlackScreen) then
+ begin
+ CurrentScreen.Draw;
+
+ //popup mod
+ if (ScreenPopupError <> NIL) and ScreenPopupError.Visible then
+ ScreenPopupError.Draw
+ else if (ScreenPopupCheck <> NIL) and ScreenPopupCheck.Visible then
+ ScreenPopupCheck.Draw;
+
+ // fade mod
+ myfade:=0;
+ if (Ini.ScreenFade=1) and canFade then
+ doFade:=True
+ else if Ini.ScreenFade=0 then
+ doFade:=False;
+ end
+ else
+ begin
+ // check if we had an initialization error (canfade=false, dofade=true)
+ if doFade and not canFade then
+ begin
+ doFade:=False; //disable fading
+// ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message
+ end;
+ if doFade and canFade then
+ begin
+ // fade mod
+ //Create Fading texture if we're just starting
+ if myfade = 0 then
+ begin
+ glViewPort(0, 0, 512, 512);
+ CurrentScreen.Draw;
+ glBindTexture(GL_TEXTURE_2D, pTex[S]);
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);
+ glError:=glGetError;
+ if (glError <> GL_NO_ERROR) then
+ begin
+ canFade := False;
+ glErrorStr := gluErrorString(glError);
+// ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message
+ end;
+ glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH);
+ // blackscreen-hack
+ if not BlackScreen then
+ NextScreen.onShow;
+
+ lastTime:=SDL_GetTicks();
+ if (S=2) or (Screens = 1) then
+ myfade:=myfade+1;
+ end; // end texture creation in first fading step
+
+ //do some time-based fading
+ currentTime:=SDL_GetTicks();
+ if (currentTime > lastTime+30) and (S=1) then
+ begin
+ myfade:=myfade+4;
+ lastTime:=currentTime;
+ end;
+
+// LastFade := Fade; // whatever
+// Fade := Fade -0.999; // start fading out
+
+
+// CurrentScreen.ShowFinish := false; // no purpose?
+
+// CurrentScreen.SetAnimationProgress(Fade-1); // nop?
+
+ // blackscreen-hack
+ if not BlackScreen then
+ NextScreen.Draw // draw next screen
+ else if ScreenAct=1 then
+ begin
+ glClearColor(0, 0, 0 , 0);
+ glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
+ end;
+
+ // and draw old screen over it... slowly fading out
+ myfade2:=(myfade*myfade)/10000;
+ glBindTexture(GL_TEXTURE_2D, pTex[S]);
+ glColor4f(1, 1, 1, (1000-myfade*myfade)/1000); // strange calculation - alpha gets negative... but looks good this way
+ glEnable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600);
+ glTexCoord2f(0+myfade2,1-myfade2);glVertex2f(0, 0);
+ glTexCoord2f(1-myfade2,1-myfade2);glVertex2f(800, 0);
+ glTexCoord2f(1-myfade2,0+myfade2);glVertex2f(800, 600);
+ glEnd;
+ glDisable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ end
+ // blackscreen hack
+ else if not BlackScreen then
+ begin
+ NextScreen.OnShow;
+ end;
+
+ if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then
+ begin // fade out complete...
+ myFade:=0;
+ CurrentScreen.onHide;
+ CurrentScreen.ShowFinish:=False;
+ CurrentScreen:=NextScreen;
+ NextScreen := nil;
+ if not blackscreen then
+ begin
+ CurrentScreen.onShowFinish;
+ CurrentScreen.ShowFinish := true;
+ end
+ else
+ begin
+ Result:=False;
+ Break;
+ end;
+ // end of fade mod
+ end;
+ end; // if
+
+ //Draw OSD only on first Screen if Debug Mode is enabled
+ if ((Ini.Debug = 1) or (Params.Debug)) and (S=1) then
+ DrawDebugInformation;
+
+ end; // for
+
+ // SDL_GL_SwapBuffers();
+end;
+
+{function TDisplay.Fade(FadeIn : Boolean; Steps : UInt8): UInt8;
+begin
+ Self.FadeIn := FadeIn;
+ FadeStep := (SizeOf(FadeStep) * $FF) div Steps;
+ ActualStep := $FF;
+ Result := $FF div FadeStep;
+end;}
+
+procedure TDisplay.SaveScreenShot;
+var
+ Num: integer;
+ FileName: string;
+ ScreenData: PChar;
+ Surface: PSDL_Surface;
+ Success: boolean;
+ Align: integer;
+ RowSize: integer;
+begin
+ for Num := 1 to 9999 do
+ begin
+ FileName := IntToStr(Num);
+ while Length(FileName) < 4 do
+ FileName := '0' + FileName;
+ FileName := ScreenshotsPath + 'screenshot' + FileName + '.png';
+ if not FileExists(FileName) then
+ break
+ end;
+
+ // we must take the row-alignment (4byte by default) into account
+ glGetIntegerv(GL_PACK_ALIGNMENT, @Align);
+ // calc aligned row-size
+ RowSize := ((ScreenW*3 + (Align-1)) div Align) * Align;
+
+ GetMem(ScreenData, RowSize * ScreenH);
+ glReadPixels(0, 0, ScreenW, ScreenH, GL_RGB, GL_UNSIGNED_BYTE, ScreenData);
+ Surface := SDL_CreateRGBSurfaceFrom(
+ ScreenData, ScreenW, ScreenH, 24, RowSize,
+ $0000FF, $00FF00, $FF0000, 0);
+
+ //Success := WriteJPGImage(FileName, Surface, 95);
+ //Success := WriteBMPImage(FileName, Surface);
+ Success := WritePNGImage(FileName, Surface);
+ if Success then
+ ScreenPopupError.ShowPopup('Screenshot saved: ' + ExtractFileName(FileName))
+ else
+ ScreenPopupError.ShowPopup('Screenshot failed');
+
+ SDL_FreeSurface(Surface);
+ FreeMem(ScreenData);
+end;
+
+//------------
+// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen
+//------------
+procedure TDisplay.DrawDebugInformation;
+var Ticks: Cardinal;
+begin
+ //Some White Background for information
+ glEnable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glColor4f(1, 1, 1, 0.5);
+ glBegin(GL_QUADS);
+ glVertex2f(690, 44);
+ glVertex2f(690, 0);
+ glVertex2f(800, 0);
+ glVertex2f(800, 44);
+ glEnd;
+ glDisable(GL_BLEND);
+
+ //Set Font Specs
+ SetFontStyle(0);
+ SetFontSize(7);
+ SetFontItalic(False);
+ glColor4f(0, 0, 0, 1);
+
+ //Calculate FPS
+ Ticks := SDL_GetTicks();
+ if (Ticks >= NextFPSSwap) then
+ begin
+ LastFPS := FPSCounter * 4;
+ FPSCounter := 0;
+ NextFPSSwap := Ticks + 250;
+ end;
+
+ Inc(FPSCounter);
+
+ //Draw Text
+
+ //FPS
+ SetFontPos(695, 0);
+ glPrint (PChar('FPS: ' + InttoStr(LastFPS)));
+
+ //RSpeed
+ SetFontPos(695, 13);
+ glPrint (PChar('RSpeed: ' + InttoStr(Round(1000 * TimeMid))));
+
+ //LastError
+ SetFontPos(695, 26);
+ glColor4f(1, 0, 0, 1);
+ glPrint (PChar(OSD_LastError));
+
+ glColor4f(1, 1, 1, 1);
+end;
+
+end.
diff --git a/Game/Code/Menu/UDrawTexture.pas b/Game/Code/Menu/UDrawTexture.pas
index 3dddaabc..a7dde18f 100644
--- a/Game/Code/Menu/UDrawTexture.pas
+++ b/Game/Code/Menu/UDrawTexture.pas
@@ -1,105 +1,105 @@
-unit UDrawTexture;
-
-interface
-
-{$I switches.inc}
-
-uses UTexture;
-
-procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real);
-procedure DrawQuad(X, Y, W, H, ColR, ColG, ColB: real);
-procedure DrawTexture(Texture: TTexture);
-
-implementation
-
-uses gl;
-
-procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real);
-begin
- glColor3f(ColR, ColG, ColB);
- glBegin(GL_LINES);
- glVertex2f(x1, y1);
- glVertex2f(x2, y2);
- glEnd;
-end;
-
-procedure DrawQuad(X, Y, W, H, ColR, ColG, ColB: real);
-begin
- glColor3f(ColR, ColG, ColB);
- glBegin(GL_QUADS);
- glVertex2f(x, y);
- glVertex2f(x, y+h);
- glVertex2f(x+w, y+h);
- glVertex2f(x+w, y);
- glEnd;
-end;
-
-procedure DrawTexture(Texture: TTexture);
-var
- x1, x2, x3, x4: real;
- y1, y2, y3, y4: real;
- xt1, xt2, xt3, xt4: real;
- yt1, yt2, yt3, yt4: real;
-begin
- with Texture do begin
- // rysuje paski gracza
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha);
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
- glDepthRange(0, 10);
- glDepthFunc(GL_LEQUAL);
-// glDepthFunc(GL_GEQUAL);
- glEnable(GL_DEPTH_TEST);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-// glBlendFunc(GL_SRC_COLOR, GL_ZERO);
- glBindTexture(GL_TEXTURE_2D, TexNum);
-
- x1 := x;
- x2 := x;
- x3 := x+w*scaleW;
- x4 := x+w*scaleW;
- y1 := y;
- y2 := y+h*scaleH;
- y3 := y+h*scaleH;
- y4 := y;
- if Rot <> 0 then begin
- xt1 := x1 - (x + w/2);
- xt2 := x2 - (x + w/2);
- xt3 := x3 - (x + w/2);
- xt4 := x4 - (x + w/2);
- yt1 := y1 - (y + h/2);
- yt2 := y2 - (y + h/2);
- yt3 := y3 - (y + h/2);
- yt4 := y4 - (y + h/2);
-
- x1 := (x + w/2) + xt1 * cos(Rot) - yt1 * sin(Rot);
- x2 := (x + w/2) + xt2 * cos(Rot) - yt2 * sin(Rot);
- x3 := (x + w/2) + xt3 * cos(Rot) - yt3 * sin(Rot);
- x4 := (x + w/2) + xt4 * cos(Rot) - yt4 * sin(Rot);
-
- y1 := (y + h/2) + yt1 * cos(Rot) + xt1 * sin(Rot);
- y2 := (y + h/2) + yt2 * cos(Rot) + xt2 * sin(Rot);
- y3 := (y + h/2) + yt3 * cos(Rot) + xt3 * sin(Rot);
- y4 := (y + h/2) + yt4 * cos(Rot) + xt4 * sin(Rot);
-
- end;
-
-{ glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex3f(x1, y1, z);
- glTexCoord2f(0, TexH); glVertex3f(x2, y2, z);
- glTexCoord2f(TexW, TexH); glVertex3f(x3, y3, z);
- glTexCoord2f(TexW, 0); glVertex3f(x4, y4, z);
- glEnd;}
-
- glBegin(GL_QUADS);
- glTexCoord2f(TexX1*TexW, TexY1*TexH); glVertex3f(x1, y1, z);
- glTexCoord2f(TexX1*TexW, TexY2*TexH); glVertex3f(x2, y2, z);
- glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x3, y3, z);
- glTexCoord2f(TexX2*TexW, TexY1*TexH); glVertex3f(x4, y4, z);
- glEnd;
- end;
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_TEXTURE_2D);
-end;
-
-end.
+unit UDrawTexture;
+
+interface
+
+{$I switches.inc}
+
+uses UTexture;
+
+procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real);
+procedure DrawQuad(X, Y, W, H, ColR, ColG, ColB: real);
+procedure DrawTexture(Texture: TTexture);
+
+implementation
+
+uses gl;
+
+procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real);
+begin
+ glColor3f(ColR, ColG, ColB);
+ glBegin(GL_LINES);
+ glVertex2f(x1, y1);
+ glVertex2f(x2, y2);
+ glEnd;
+end;
+
+procedure DrawQuad(X, Y, W, H, ColR, ColG, ColB: real);
+begin
+ glColor3f(ColR, ColG, ColB);
+ glBegin(GL_QUADS);
+ glVertex2f(x, y);
+ glVertex2f(x, y+h);
+ glVertex2f(x+w, y+h);
+ glVertex2f(x+w, y);
+ glEnd;
+end;
+
+procedure DrawTexture(Texture: TTexture);
+var
+ x1, x2, x3, x4: real;
+ y1, y2, y3, y4: real;
+ xt1, xt2, xt3, xt4: real;
+ yt1, yt2, yt3, yt4: real;
+begin
+ with Texture do begin
+ // rysuje paski gracza
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+ glDepthRange(0, 10);
+ glDepthFunc(GL_LEQUAL);
+// glDepthFunc(GL_GEQUAL);
+ glEnable(GL_DEPTH_TEST);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+// glBlendFunc(GL_SRC_COLOR, GL_ZERO);
+ glBindTexture(GL_TEXTURE_2D, TexNum);
+
+ x1 := x;
+ x2 := x;
+ x3 := x+w*scaleW;
+ x4 := x+w*scaleW;
+ y1 := y;
+ y2 := y+h*scaleH;
+ y3 := y+h*scaleH;
+ y4 := y;
+ if Rot <> 0 then begin
+ xt1 := x1 - (x + w/2);
+ xt2 := x2 - (x + w/2);
+ xt3 := x3 - (x + w/2);
+ xt4 := x4 - (x + w/2);
+ yt1 := y1 - (y + h/2);
+ yt2 := y2 - (y + h/2);
+ yt3 := y3 - (y + h/2);
+ yt4 := y4 - (y + h/2);
+
+ x1 := (x + w/2) + xt1 * cos(Rot) - yt1 * sin(Rot);
+ x2 := (x + w/2) + xt2 * cos(Rot) - yt2 * sin(Rot);
+ x3 := (x + w/2) + xt3 * cos(Rot) - yt3 * sin(Rot);
+ x4 := (x + w/2) + xt4 * cos(Rot) - yt4 * sin(Rot);
+
+ y1 := (y + h/2) + yt1 * cos(Rot) + xt1 * sin(Rot);
+ y2 := (y + h/2) + yt2 * cos(Rot) + xt2 * sin(Rot);
+ y3 := (y + h/2) + yt3 * cos(Rot) + xt3 * sin(Rot);
+ y4 := (y + h/2) + yt4 * cos(Rot) + xt4 * sin(Rot);
+
+ end;
+
+{ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0); glVertex3f(x1, y1, z);
+ glTexCoord2f(0, TexH); glVertex3f(x2, y2, z);
+ glTexCoord2f(TexW, TexH); glVertex3f(x3, y3, z);
+ glTexCoord2f(TexW, 0); glVertex3f(x4, y4, z);
+ glEnd;}
+
+ glBegin(GL_QUADS);
+ glTexCoord2f(TexX1*TexW, TexY1*TexH); glVertex3f(x1, y1, z);
+ glTexCoord2f(TexX1*TexW, TexY2*TexH); glVertex3f(x2, y2, z);
+ glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x3, y3, z);
+ glTexCoord2f(TexX2*TexW, TexY1*TexH); glVertex3f(x4, y4, z);
+ glEnd;
+ end;
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_TEXTURE_2D);
+end;
+
+end.
diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas
index 2a6861a5..a20811a6 100644
--- a/Game/Code/Menu/UMenuButton.pas
+++ b/Game/Code/Menu/UMenuButton.pas
@@ -1,570 +1,570 @@
-unit UMenuButton;
-
-interface
-
-{$I switches.inc}
-
-uses TextGL, UTexture, gl, UMenuText,SDL;
-
-type
- CButton = class of TButton;
- TButton = class
- protected
- SelectBool: Boolean;
-
- FadeProgress: Real;
- FadeLastTick: Cardinal;
-
- DeSelectW: Real;
- DeSelectH: Real;
- PosX: Real;
- PosY: Real;
-
- constructor Create(); overload;
-
- public
- Text: Array of TText;
- Texture: TTexture; // Button Screen position and size
- Texture2: TTexture; // second texture only used for fading full resolution covers
- //colorized hack
- Colorized: Boolean;
- DeSelectTexture: TTexture; // texture for colorized hack
-
- FadeTex: TTexture; //Texture for beautiful fading
- FadeTexPos: byte; //Pos of the FadeTexture (0: Top, 1: Left, 2: Bottom, 3: Right)
-// Texture2Blend: real; // blending factor for second texture (0=invisible, 1=visible)
- // now uses alpha
-
- DeselectType: integer; // not used yet
- Visible: boolean;
- //Reflection Mod
- Reflection: boolean;
- Reflectionspacing: Real;
- DeSelectReflectionspacing: Real;
-
- //Fade Mod
- Fade: Boolean;
- FadeText: Boolean;
-
- Selectable: boolean;
-
- //No of the Parent Collection, 0 if in no Collection
- Parent: Byte;
-
- SelectColR: real;
- SelectColG: real;
- SelectColB: real;
- SelectInt: real;
- SelectTInt: real;
- //Fade Mod
- SelectW: real;
- SelectH: real;
-
- DeselectColR: real;
- DeselectColG: real;
- DeselectColB: real;
- DeselectInt: real;
- DeselectTInt: real;
-
- procedure SetY(Value: real);
- procedure SetX(Value: real);
- procedure SetW(Value: real);
- procedure SetH(Value: real);
-
- procedure SetSelect(Value: Boolean); virtual;
- property X: real read PosX write SetX;
- property Y: real read PosY write SetY;
- property Z: real read Texture.z write Texture.z;
- property W: real read DeSelectW write SetW;
- property H: real read DeSelectH write SetH;
- property Selected: Boolean read SelectBool write SetSelect;
-
- procedure Draw; virtual;
-
- constructor Create(Textura: TTexture); overload;
- constructor Create(Textura, DSTexture: TTexture); overload;
- destructor Destroy; override;
- end;
-
-implementation
-
-uses SysUtils,
- UDrawTexture;
-
-procedure TButton.SetX(Value: real);
-{var
- dx: real;
- T: integer; // text}
-begin
- {dY := Value - Texture.y;
-
- Texture.X := Value;
-
- for T := 0 to High(Text) do
- Text[T].X := Text[T].X + dY;}
-
- PosX := Value;
- if (FadeTex.TexNum = 0) then
- Texture.X := Value;
-
-end;
-
-procedure TButton.SetY(Value: real);
-{var
- dY: real;
- T: integer; // text}
-begin
- {dY := Value - PosY;
-
-
- for T := 0 to High(Text) do
- Text[T].Y := Text[T].Y + dY;}
-
- PosY := Value;
- if (FadeTex.TexNum = 0) then
- Texture.y := Value;
-end;
-
-procedure TButton.SetW(Value: real);
-begin
- if SelectW = DeSelectW then
- SelectW := Value;
-
- DeSelectW := Value;
-
- if Not Fade then
- begin
- if SelectBool then
- Texture.W := SelectW
- else
- Texture.W := DeSelectW;
- end;
-end;
-
-procedure TButton.SetH(Value: real);
-begin
- if SelectH = DeSelectH then
- SelectH := Value;
-
- DeSelectH := Value;
-
- if Not Fade then
- begin
- if SelectBool then
- Texture.H := SelectH
- else
- Texture.H := DeSelectH;
- end;
-end;
-
-procedure TButton.SetSelect(Value : Boolean);
-var
- T: integer;
-begin
- SelectBool := Value;
- if (Value) then begin
- Texture.ColR := SelectColR;
- Texture.ColG := SelectColG;
- Texture.ColB := SelectColB;
- Texture.Int := SelectInt;
-
- Texture2.ColR := SelectColR;
- Texture2.ColG := SelectColG;
- Texture2.ColB := SelectColB;
- Texture2.Int := SelectInt;
-
- for T := 0 to High(Text) do
- Text[T].Int := SelectTInt;
-
- //Fade Mod
- if Fade then
- begin
- if (FadeProgress <= 0) then
- FadeProgress := 0.125;
- end
- else
- begin
- Texture.W := SelectW;
- Texture.H := SelectH;
- end;
- end else begin
- Texture.ColR := DeselectColR;
- Texture.ColG := DeselectColG;
- Texture.ColB := DeselectColB;
- Texture.Int := DeselectInt;
-
- Texture2.ColR := DeselectColR;
- Texture2.ColG := DeselectColG;
- Texture2.ColB := DeselectColB;
- Texture2.Int := DeselectInt;
-
- for T := 0 to High(Text) do
- Text[T].Int := DeselectTInt;
-
- //Fade Mod
- if Fade then
- begin
- if (FadeProgress >= 1) then
- FadeProgress := 0.875;
- end
- else
- begin
- Texture.W := DeSelectW;
- Texture.H := DeSelectH;
- end;
- end;
-end;
-
-constructor TButton.Create();
-begin
- inherited Create;
- // We initialize all to 0, nil or false
- Visible := true;
- SelectBool := false;
- DeselectType := 0;
- Selectable := true;
- //Reflection Mod
- Reflection := true;
-
- //colorized hack
- Colorized:=False;
-
- // Default
-// SelectInt := 1;
-// DeselectInt := 0.5;
-
-{ SelectColR := 0.5;
- SelectColG := 0.75;
- SelectColB := 0;
- SelectInt := 1;
- SelectTInt := 1;
-
- DeselectColR := 1;
- DeselectColG := 1;
- DeselectColB := 1;
- DeselectInt := 0.5;
- DeselectTInt := 1;}
-
- SelectColR := 1;
- SelectColG := 1;
- SelectColB := 1;
- SelectInt := 1;
- SelectTInt := 1;
-
- DeselectColR := 1;
- DeselectColG := 1;
- DeselectColB := 1;
- DeselectInt := 0.5;
- DeselectTInt := 1;
-
- FadeTex.TexNum := 0;
-
- FadeProgress := 0;
- Fade := False;
- FadeText := False;
- SelectW := DeSelectW;
- SelectH := DeSelectH;
-
- PosX := 0;
- PosY := 0;
-
- Parent := 0;
-end;
-
-// ***** Public methods ****** //
-
-procedure TButton.Draw;
-var
- T: integer;
- Tick: Cardinal;
- Spacing: Real;
-begin
- if Visible then begin
- //Fade Mod
- T:=0;
- if Fade then
- begin
- if (FadeProgress < 1) and (FadeProgress > 0) then
- begin
- Tick := SDL_GetTicks() div 16;
- if (Tick <> FadeLastTick) then
- begin
- FadeLastTick := Tick;
- if SelectBool then
- FadeProgress := FadeProgress + 0.125
- else
- FadeProgress := FadeProgress - 0.125;
-
- if (FadeText) then
- begin
- For T := 0 to high(Text) do
- begin
- Text[T].MoveX := (SelectW - DeSelectW) * FadeProgress;
- Text[T].MoveY := (SelectH - DeSelectH) * FadeProgress;
- end;
- end;
- end;
- end;
- //Method without Fade Texture
- if (FadeTex.TexNum = 0) then
- begin
- Texture.W := DeSelectW + (SelectW - DeSelectW) * FadeProgress;
- Texture.H := DeSelectH + (SelectH - DeSelectH) * FadeProgress;
- DeselectTexture.W := Texture.W;
- DeselectTexture.H := Texture.H;
- end
- else //method with Fade Texture
- begin
- Texture.W := DeSelectW;
- Texture.H := DeSelectH;
- DeselectTexture.W := Texture.W;
- DeselectTexture.H := Texture.H;
-
- FadeTex.ColR := Texture.ColR;
- FadeTex.ColG := Texture.ColG;
- FadeTex.ColB := Texture.ColB;
- FadeTex.Int := Texture.Int;
-
- FadeTex.Z := Texture.Z;
-
- FadeTex.Alpha := Texture.Alpha;
- FadeTex.TexX1 := 0;
- FadeTex.TexX2 := 1;
- FadeTex.TexY1 := 0;
- FadeTex.TexY2 := 1;
-
- Case FadeTexPos of
- 0: //FadeTex on Top
- begin
- //Standard Texture
- Texture.X := PosX;
- Texture.Y := PosY + (SelectH - DeSelectH) * FadeProgress;
- DeselectTexture.X := Texture.X;
- DeselectTexture.Y := Texture.Y;
- //Fade Tex
- FadeTex.X := PosX;
- FadeTex.Y := PosY;
- FadeTex.W := Texture.W;
- FadeTex.H := (SelectH - DeSelectH) * FadeProgress;
- FadeTex.ScaleW := Texture.ScaleW;
- //Some Hack that Fixes a little Space between both Textures
- FadeTex.TexY2 := 0.9;
- end;
- 1: //FadeTex on Left
- begin
- //Standard Texture
- Texture.X := PosX + (SelectW - DeSelectW) * FadeProgress;
- Texture.Y := PosY;
- DeselectTexture.X := Texture.X;
- DeselectTexture.Y := Texture.Y;
- //Fade Tex
- FadeTex.X := PosX;
- FadeTex.Y := PosY;
- FadeTex.H := Texture.H;
- FadeTex.W := (SelectW - DeSelectW) * FadeProgress;
- FadeTex.ScaleH := Texture.ScaleH;
- //Some Hack that Fixes a little Space between both Textures
- FadeTex.TexX2 := 0.9;
- end;
- 2: //FadeTex on Bottom
- begin
- //Standard Texture
- Texture.X := PosX;
- Texture.Y := PosY;
- DeselectTexture.X := Texture.X;
- DeselectTexture.Y := Texture.Y;
- //Fade Tex
- FadeTex.X := PosX;
- FadeTex.Y := PosY + (SelectH - DeSelectH) * FadeProgress;;
- FadeTex.W := Texture.W;
- FadeTex.H := (SelectH - DeSelectH) * FadeProgress;
- FadeTex.ScaleW := Texture.ScaleW;
- //Some Hack that Fixes a little Space between both Textures
- FadeTex.TexY1 := 0.1;
- end;
- 3: //FadeTex on Right
- begin
- //Standard Texture
- Texture.X := PosX;
- Texture.Y := PosY;
- DeselectTexture.X := Texture.X;
- DeselectTexture.Y := Texture.Y;
- //Fade Tex
- FadeTex.X := PosX + (SelectW - DeSelectW) * FadeProgress;
- FadeTex.Y := PosY;
- FadeTex.H := Texture.H;
- FadeTex.W := (SelectW - DeSelectW) * FadeProgress;
- FadeTex.ScaleH := Texture.ScaleH;
- //Some Hack that Fixes a little Space between both Textures
- FadeTex.TexX1 := 0.1;
- end;
- end;
- end;
- end
- else if (FadeText) then
- begin
- Text[T].MoveX := (SelectW - DeSelectW);
- Text[T].MoveY := (SelectH - DeSelectH);
- end;
-
- if SelectBool or (FadeProgress > 0) or not Colorized then
- DrawTexture(Texture)
- else
- DrawTexture(DeselectTexture);
-
- //Draw FadeTex
- if (FadeTex.TexNum > 0) then
- DrawTexture(FadeTex);
-
- if Texture2.Alpha > 0 then begin
- Texture2.ScaleW := Texture.ScaleW;
- Texture2.ScaleH := Texture.ScaleH;
-
- Texture2.X := Texture.X;
- Texture2.Y := Texture.Y;
- Texture2.W := Texture.W;
- Texture2.H := Texture.H;
-
- Texture2.ColR := Texture.ColR;
- Texture2.ColG := Texture.ColG;
- Texture2.ColB := Texture.ColB;
- Texture2.Int := Texture.Int;
-
- Texture2.Z := Texture.Z;
-
- DrawTexture(Texture2);
- end;
-
- //Reflection Mod
- if (Reflection) then // Draw Reflections
- begin
- if (FadeProgress <> 0) AND (FadeProgress <> 1) then
- begin
- Spacing := DeSelectReflectionspacing - (DeSelectReflectionspacing - Reflectionspacing) * FadeProgress;
- end
- else if SelectBool then
- Spacing := Reflectionspacing
- else
- Spacing := DeSelectReflectionspacing;
-
- if SelectBool or not Colorized then
- with Texture do
- begin
- //Bind Tex and GL Attributes
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
-
- glDepthRange(0, 10);
- glDepthFunc(GL_LEQUAL);
- glEnable(GL_DEPTH_TEST);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBindTexture(GL_TEXTURE_2D, TexNum);
-
- //Draw
- glBegin(GL_QUADS);//Top Left
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
- glTexCoord2f(TexX1*TexW, TexY2*TexH);
- glVertex3f(x, y+h*scaleH+ Spacing, z);
-
- //Bottom Left
- glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
- glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5);
- glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z);
-
-
- //Bottom Right
- glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
- glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5);
- glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z);
-
- //Top Right
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
- glTexCoord2f(TexX2*TexW, TexY2*TexH);
- glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z);
- glEnd;
-
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- end else
- with DeselectTexture do
- begin
- //Bind Tex and GL Attributes
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
-
- glDepthRange(0, 10);
- glDepthFunc(GL_LEQUAL);
- glEnable(GL_DEPTH_TEST);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBindTexture(GL_TEXTURE_2D, TexNum);
-
- //Draw
- glBegin(GL_QUADS);//Top Left
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
- glTexCoord2f(TexX1*TexW, TexY2*TexH);
- glVertex3f(x, y+h*scaleH+ Spacing, z);
-
- //Bottom Left
- glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
- glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5);
- glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z);
-
-
- //Bottom Right
- glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
- glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5);
- glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z);
-
- //Top Right
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
- glTexCoord2f(TexX2*TexW, TexY2*TexH);
- glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z);
- glEnd;
-
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- end;
- end;
-
- for T := 0 to High(Text) do begin
- Text[T].Draw;
- end;
- end;
-end;
-
-// ***** ****** //
-
-destructor TButton.Destroy;
-begin
- inherited;
-end;
-
-constructor TButton.Create(Textura: TTexture);
-begin
- Create();
- Texture := Textura;
- DeselectTexture:=Textura;
- Texture.ColR := 0;
- Texture.ColG := 0.5;
- Texture.ColB := 0;
- Texture.Int := 1;
- Colorized:=False;
-end;
-
-constructor TButton.Create(Textura, DSTexture: TTexture);
-begin
- Create();
- Texture := Textura;
- DeselectTexture := DSTexture;
- Texture.ColR := 1;
- Texture.ColG := 1;
- Texture.ColB := 1;
- Texture.Int := 1;
- Colorized:=True;
-end;
-
-end.
+unit UMenuButton;
+
+interface
+
+{$I switches.inc}
+
+uses TextGL, UTexture, gl, UMenuText,SDL;
+
+type
+ CButton = class of TButton;
+ TButton = class
+ protected
+ SelectBool: Boolean;
+
+ FadeProgress: Real;
+ FadeLastTick: Cardinal;
+
+ DeSelectW: Real;
+ DeSelectH: Real;
+ PosX: Real;
+ PosY: Real;
+
+ constructor Create(); overload;
+
+ public
+ Text: Array of TText;
+ Texture: TTexture; // Button Screen position and size
+ Texture2: TTexture; // second texture only used for fading full resolution covers
+ //colorized hack
+ Colorized: Boolean;
+ DeSelectTexture: TTexture; // texture for colorized hack
+
+ FadeTex: TTexture; //Texture for beautiful fading
+ FadeTexPos: byte; //Pos of the FadeTexture (0: Top, 1: Left, 2: Bottom, 3: Right)
+// Texture2Blend: real; // blending factor for second texture (0=invisible, 1=visible)
+ // now uses alpha
+
+ DeselectType: integer; // not used yet
+ Visible: boolean;
+ //Reflection Mod
+ Reflection: boolean;
+ Reflectionspacing: Real;
+ DeSelectReflectionspacing: Real;
+
+ //Fade Mod
+ Fade: Boolean;
+ FadeText: Boolean;
+
+ Selectable: boolean;
+
+ //No of the Parent Collection, 0 if in no Collection
+ Parent: Byte;
+
+ SelectColR: real;
+ SelectColG: real;
+ SelectColB: real;
+ SelectInt: real;
+ SelectTInt: real;
+ //Fade Mod
+ SelectW: real;
+ SelectH: real;
+
+ DeselectColR: real;
+ DeselectColG: real;
+ DeselectColB: real;
+ DeselectInt: real;
+ DeselectTInt: real;
+
+ procedure SetY(Value: real);
+ procedure SetX(Value: real);
+ procedure SetW(Value: real);
+ procedure SetH(Value: real);
+
+ procedure SetSelect(Value: Boolean); virtual;
+ property X: real read PosX write SetX;
+ property Y: real read PosY write SetY;
+ property Z: real read Texture.z write Texture.z;
+ property W: real read DeSelectW write SetW;
+ property H: real read DeSelectH write SetH;
+ property Selected: Boolean read SelectBool write SetSelect;
+
+ procedure Draw; virtual;
+
+ constructor Create(Textura: TTexture); overload;
+ constructor Create(Textura, DSTexture: TTexture); overload;
+ destructor Destroy; override;
+ end;
+
+implementation
+
+uses SysUtils,
+ UDrawTexture;
+
+procedure TButton.SetX(Value: real);
+{var
+ dx: real;
+ T: integer; // text}
+begin
+ {dY := Value - Texture.y;
+
+ Texture.X := Value;
+
+ for T := 0 to High(Text) do
+ Text[T].X := Text[T].X + dY;}
+
+ PosX := Value;
+ if (FadeTex.TexNum = 0) then
+ Texture.X := Value;
+
+end;
+
+procedure TButton.SetY(Value: real);
+{var
+ dY: real;
+ T: integer; // text}
+begin
+ {dY := Value - PosY;
+
+
+ for T := 0 to High(Text) do
+ Text[T].Y := Text[T].Y + dY;}
+
+ PosY := Value;
+ if (FadeTex.TexNum = 0) then
+ Texture.y := Value;
+end;
+
+procedure TButton.SetW(Value: real);
+begin
+ if SelectW = DeSelectW then
+ SelectW := Value;
+
+ DeSelectW := Value;
+
+ if Not Fade then
+ begin
+ if SelectBool then
+ Texture.W := SelectW
+ else
+ Texture.W := DeSelectW;
+ end;
+end;
+
+procedure TButton.SetH(Value: real);
+begin
+ if SelectH = DeSelectH then
+ SelectH := Value;
+
+ DeSelectH := Value;
+
+ if Not Fade then
+ begin
+ if SelectBool then
+ Texture.H := SelectH
+ else
+ Texture.H := DeSelectH;
+ end;
+end;
+
+procedure TButton.SetSelect(Value : Boolean);
+var
+ T: integer;
+begin
+ SelectBool := Value;
+ if (Value) then begin
+ Texture.ColR := SelectColR;
+ Texture.ColG := SelectColG;
+ Texture.ColB := SelectColB;
+ Texture.Int := SelectInt;
+
+ Texture2.ColR := SelectColR;
+ Texture2.ColG := SelectColG;
+ Texture2.ColB := SelectColB;
+ Texture2.Int := SelectInt;
+
+ for T := 0 to High(Text) do
+ Text[T].Int := SelectTInt;
+
+ //Fade Mod
+ if Fade then
+ begin
+ if (FadeProgress <= 0) then
+ FadeProgress := 0.125;
+ end
+ else
+ begin
+ Texture.W := SelectW;
+ Texture.H := SelectH;
+ end;
+ end else begin
+ Texture.ColR := DeselectColR;
+ Texture.ColG := DeselectColG;
+ Texture.ColB := DeselectColB;
+ Texture.Int := DeselectInt;
+
+ Texture2.ColR := DeselectColR;
+ Texture2.ColG := DeselectColG;
+ Texture2.ColB := DeselectColB;
+ Texture2.Int := DeselectInt;
+
+ for T := 0 to High(Text) do
+ Text[T].Int := DeselectTInt;
+
+ //Fade Mod
+ if Fade then
+ begin
+ if (FadeProgress >= 1) then
+ FadeProgress := 0.875;
+ end
+ else
+ begin
+ Texture.W := DeSelectW;
+ Texture.H := DeSelectH;
+ end;
+ end;
+end;
+
+constructor TButton.Create();
+begin
+ inherited Create;
+ // We initialize all to 0, nil or false
+ Visible := true;
+ SelectBool := false;
+ DeselectType := 0;
+ Selectable := true;
+ //Reflection Mod
+ Reflection := true;
+
+ //colorized hack
+ Colorized:=False;
+
+ // Default
+// SelectInt := 1;
+// DeselectInt := 0.5;
+
+{ SelectColR := 0.5;
+ SelectColG := 0.75;
+ SelectColB := 0;
+ SelectInt := 1;
+ SelectTInt := 1;
+
+ DeselectColR := 1;
+ DeselectColG := 1;
+ DeselectColB := 1;
+ DeselectInt := 0.5;
+ DeselectTInt := 1;}
+
+ SelectColR := 1;
+ SelectColG := 1;
+ SelectColB := 1;
+ SelectInt := 1;
+ SelectTInt := 1;
+
+ DeselectColR := 1;
+ DeselectColG := 1;
+ DeselectColB := 1;
+ DeselectInt := 0.5;
+ DeselectTInt := 1;
+
+ FadeTex.TexNum := 0;
+
+ FadeProgress := 0;
+ Fade := False;
+ FadeText := False;
+ SelectW := DeSelectW;
+ SelectH := DeSelectH;
+
+ PosX := 0;
+ PosY := 0;
+
+ Parent := 0;
+end;
+
+// ***** Public methods ****** //
+
+procedure TButton.Draw;
+var
+ T: integer;
+ Tick: Cardinal;
+ Spacing: Real;
+begin
+ if Visible then begin
+ //Fade Mod
+ T:=0;
+ if Fade then
+ begin
+ if (FadeProgress < 1) and (FadeProgress > 0) then
+ begin
+ Tick := SDL_GetTicks() div 16;
+ if (Tick <> FadeLastTick) then
+ begin
+ FadeLastTick := Tick;
+ if SelectBool then
+ FadeProgress := FadeProgress + 0.125
+ else
+ FadeProgress := FadeProgress - 0.125;
+
+ if (FadeText) then
+ begin
+ For T := 0 to high(Text) do
+ begin
+ Text[T].MoveX := (SelectW - DeSelectW) * FadeProgress;
+ Text[T].MoveY := (SelectH - DeSelectH) * FadeProgress;
+ end;
+ end;
+ end;
+ end;
+ //Method without Fade Texture
+ if (FadeTex.TexNum = 0) then
+ begin
+ Texture.W := DeSelectW + (SelectW - DeSelectW) * FadeProgress;
+ Texture.H := DeSelectH + (SelectH - DeSelectH) * FadeProgress;
+ DeselectTexture.W := Texture.W;
+ DeselectTexture.H := Texture.H;
+ end
+ else //method with Fade Texture
+ begin
+ Texture.W := DeSelectW;
+ Texture.H := DeSelectH;
+ DeselectTexture.W := Texture.W;
+ DeselectTexture.H := Texture.H;
+
+ FadeTex.ColR := Texture.ColR;
+ FadeTex.ColG := Texture.ColG;
+ FadeTex.ColB := Texture.ColB;
+ FadeTex.Int := Texture.Int;
+
+ FadeTex.Z := Texture.Z;
+
+ FadeTex.Alpha := Texture.Alpha;
+ FadeTex.TexX1 := 0;
+ FadeTex.TexX2 := 1;
+ FadeTex.TexY1 := 0;
+ FadeTex.TexY2 := 1;
+
+ Case FadeTexPos of
+ 0: //FadeTex on Top
+ begin
+ //Standard Texture
+ Texture.X := PosX;
+ Texture.Y := PosY + (SelectH - DeSelectH) * FadeProgress;
+ DeselectTexture.X := Texture.X;
+ DeselectTexture.Y := Texture.Y;
+ //Fade Tex
+ FadeTex.X := PosX;
+ FadeTex.Y := PosY;
+ FadeTex.W := Texture.W;
+ FadeTex.H := (SelectH - DeSelectH) * FadeProgress;
+ FadeTex.ScaleW := Texture.ScaleW;
+ //Some Hack that Fixes a little Space between both Textures
+ FadeTex.TexY2 := 0.9;
+ end;
+ 1: //FadeTex on Left
+ begin
+ //Standard Texture
+ Texture.X := PosX + (SelectW - DeSelectW) * FadeProgress;
+ Texture.Y := PosY;
+ DeselectTexture.X := Texture.X;
+ DeselectTexture.Y := Texture.Y;
+ //Fade Tex
+ FadeTex.X := PosX;
+ FadeTex.Y := PosY;
+ FadeTex.H := Texture.H;
+ FadeTex.W := (SelectW - DeSelectW) * FadeProgress;
+ FadeTex.ScaleH := Texture.ScaleH;
+ //Some Hack that Fixes a little Space between both Textures
+ FadeTex.TexX2 := 0.9;
+ end;
+ 2: //FadeTex on Bottom
+ begin
+ //Standard Texture
+ Texture.X := PosX;
+ Texture.Y := PosY;
+ DeselectTexture.X := Texture.X;
+ DeselectTexture.Y := Texture.Y;
+ //Fade Tex
+ FadeTex.X := PosX;
+ FadeTex.Y := PosY + (SelectH - DeSelectH) * FadeProgress;;
+ FadeTex.W := Texture.W;
+ FadeTex.H := (SelectH - DeSelectH) * FadeProgress;
+ FadeTex.ScaleW := Texture.ScaleW;
+ //Some Hack that Fixes a little Space between both Textures
+ FadeTex.TexY1 := 0.1;
+ end;
+ 3: //FadeTex on Right
+ begin
+ //Standard Texture
+ Texture.X := PosX;
+ Texture.Y := PosY;
+ DeselectTexture.X := Texture.X;
+ DeselectTexture.Y := Texture.Y;
+ //Fade Tex
+ FadeTex.X := PosX + (SelectW - DeSelectW) * FadeProgress;
+ FadeTex.Y := PosY;
+ FadeTex.H := Texture.H;
+ FadeTex.W := (SelectW - DeSelectW) * FadeProgress;
+ FadeTex.ScaleH := Texture.ScaleH;
+ //Some Hack that Fixes a little Space between both Textures
+ FadeTex.TexX1 := 0.1;
+ end;
+ end;
+ end;
+ end
+ else if (FadeText) then
+ begin
+ Text[T].MoveX := (SelectW - DeSelectW);
+ Text[T].MoveY := (SelectH - DeSelectH);
+ end;
+
+ if SelectBool or (FadeProgress > 0) or not Colorized then
+ DrawTexture(Texture)
+ else
+ DrawTexture(DeselectTexture);
+
+ //Draw FadeTex
+ if (FadeTex.TexNum > 0) then
+ DrawTexture(FadeTex);
+
+ if Texture2.Alpha > 0 then begin
+ Texture2.ScaleW := Texture.ScaleW;
+ Texture2.ScaleH := Texture.ScaleH;
+
+ Texture2.X := Texture.X;
+ Texture2.Y := Texture.Y;
+ Texture2.W := Texture.W;
+ Texture2.H := Texture.H;
+
+ Texture2.ColR := Texture.ColR;
+ Texture2.ColG := Texture.ColG;
+ Texture2.ColB := Texture.ColB;
+ Texture2.Int := Texture.Int;
+
+ Texture2.Z := Texture.Z;
+
+ DrawTexture(Texture2);
+ end;
+
+ //Reflection Mod
+ if (Reflection) then // Draw Reflections
+ begin
+ if (FadeProgress <> 0) AND (FadeProgress <> 1) then
+ begin
+ Spacing := DeSelectReflectionspacing - (DeSelectReflectionspacing - Reflectionspacing) * FadeProgress;
+ end
+ else if SelectBool then
+ Spacing := Reflectionspacing
+ else
+ Spacing := DeSelectReflectionspacing;
+
+ if SelectBool or not Colorized then
+ with Texture do
+ begin
+ //Bind Tex and GL Attributes
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+
+ glDepthRange(0, 10);
+ glDepthFunc(GL_LEQUAL);
+ glEnable(GL_DEPTH_TEST);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBindTexture(GL_TEXTURE_2D, TexNum);
+
+ //Draw
+ glBegin(GL_QUADS);//Top Left
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
+ glTexCoord2f(TexX1*TexW, TexY2*TexH);
+ glVertex3f(x, y+h*scaleH+ Spacing, z);
+
+ //Bottom Left
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
+ glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5);
+ glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z);
+
+
+ //Bottom Right
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
+ glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5);
+ glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z);
+
+ //Top Right
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
+ glTexCoord2f(TexX2*TexW, TexY2*TexH);
+ glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z);
+ glEnd;
+
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+ end else
+ with DeselectTexture do
+ begin
+ //Bind Tex and GL Attributes
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+
+ glDepthRange(0, 10);
+ glDepthFunc(GL_LEQUAL);
+ glEnable(GL_DEPTH_TEST);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBindTexture(GL_TEXTURE_2D, TexNum);
+
+ //Draw
+ glBegin(GL_QUADS);//Top Left
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
+ glTexCoord2f(TexX1*TexW, TexY2*TexH);
+ glVertex3f(x, y+h*scaleH+ Spacing, z);
+
+ //Bottom Left
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
+ glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5);
+ glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z);
+
+
+ //Bottom Right
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
+ glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5);
+ glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z);
+
+ //Top Right
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
+ glTexCoord2f(TexX2*TexW, TexY2*TexH);
+ glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z);
+ glEnd;
+
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+ end;
+ end;
+
+ for T := 0 to High(Text) do begin
+ Text[T].Draw;
+ end;
+ end;
+end;
+
+// ***** ****** //
+
+destructor TButton.Destroy;
+begin
+ inherited;
+end;
+
+constructor TButton.Create(Textura: TTexture);
+begin
+ Create();
+ Texture := Textura;
+ DeselectTexture:=Textura;
+ Texture.ColR := 0;
+ Texture.ColG := 0.5;
+ Texture.ColB := 0;
+ Texture.Int := 1;
+ Colorized:=False;
+end;
+
+constructor TButton.Create(Textura, DSTexture: TTexture);
+begin
+ Create();
+ Texture := Textura;
+ DeselectTexture := DSTexture;
+ Texture.ColR := 1;
+ Texture.ColG := 1;
+ Texture.ColB := 1;
+ Texture.Int := 1;
+ Colorized:=True;
+end;
+
+end.
diff --git a/Game/Code/Menu/UMenuButtonCollection.pas b/Game/Code/Menu/UMenuButtonCollection.pas
index 981452b1..c700c812 100644
--- a/Game/Code/Menu/UMenuButtonCollection.pas
+++ b/Game/Code/Menu/UMenuButtonCollection.pas
@@ -1,71 +1,71 @@
-unit UMenuButtonCollection;
-
-interface
-
-{$I switches.inc}
-
-uses UMenuButton;
-
-type
- //----------------
- //TButtonCollection
- //No Extra Attributes or Functions ATM
- //----------------
- AButton = Array of TButton;
- PAButton = ^AButton;
- TButtonCollection = class(TButton)
- //num of the First Button, that can be Selected
- FirstChild: Byte;
- CountChilds: Byte;
-
- ScreenButton: PAButton;
-
- procedure SetSelect(Value : Boolean); override;
- procedure Draw; override;
- end;
-
-implementation
-
-procedure TButtonCollection.SetSelect(Value : Boolean);
-var I: Integer;
-begin
- inherited;
-
- //Set Visible for Every Button that is a Child of this ButtonCollection
- if (Not Fade) then
- For I := 0 to High(ScreenButton^) do
- if (ScreenButton^[I].Parent = Parent) then
- ScreenButton^[I].Visible := Value;
-end;
-
-procedure TButtonCollection.Draw;
-var I, J: Integer;
-begin
- inherited;
- //If fading is activated, Fade Child Buttons
- if (Fade) then
- begin
- For I := 0 to High(ScreenButton^) do
- if (ScreenButton^[I].Parent = Parent) then
- begin
- if (FadeProgress < 0.5) then
- begin
- ScreenButton^[I].Visible := SelectBool;
-
- For J := 0 to High(ScreenButton^[I].Text) do
- ScreenButton^[I].Text[J].Visible := SelectBool;
- end
- else
- begin
- ScreenButton^[I].Texture.Alpha := (FadeProgress-0.666)*3;
-
- For J := 0 to High(ScreenButton^[I].Text) do
- ScreenButton^[I].Text[J].Alpha := (FadeProgress-0.666)*3;
- end;
- end;
- end;
-end;
-
-
-
-end.
+unit UMenuButtonCollection;
+
+interface
+
+{$I switches.inc}
+
+uses UMenuButton;
+
+type
+ //----------------
+ //TButtonCollection
+ //No Extra Attributes or Functions ATM
+ //----------------
+ AButton = Array of TButton;
+ PAButton = ^AButton;
+ TButtonCollection = class(TButton)
+ //num of the First Button, that can be Selected
+ FirstChild: Byte;
+ CountChilds: Byte;
+
+ ScreenButton: PAButton;
+
+ procedure SetSelect(Value : Boolean); override;
+ procedure Draw; override;
+ end;
+
+implementation
+
+procedure TButtonCollection.SetSelect(Value : Boolean);
+var I: Integer;
+begin
+ inherited;
+
+ //Set Visible for Every Button that is a Child of this ButtonCollection
+ if (Not Fade) then
+ For I := 0 to High(ScreenButton^) do
+ if (ScreenButton^[I].Parent = Parent) then
+ ScreenButton^[I].Visible := Value;
+end;
+
+procedure TButtonCollection.Draw;
+var I, J: Integer;
+begin
+ inherited;
+ //If fading is activated, Fade Child Buttons
+ if (Fade) then
+ begin
+ For I := 0 to High(ScreenButton^) do
+ if (ScreenButton^[I].Parent = Parent) then
+ begin
+ if (FadeProgress < 0.5) then
+ begin
+ ScreenButton^[I].Visible := SelectBool;
+
+ For J := 0 to High(ScreenButton^[I].Text) do
+ ScreenButton^[I].Text[J].Visible := SelectBool;
+ end
+ else
+ begin
+ ScreenButton^[I].Texture.Alpha := (FadeProgress-0.666)*3;
+
+ For J := 0 to High(ScreenButton^[I].Text) do
+ ScreenButton^[I].Text[J].Alpha := (FadeProgress-0.666)*3;
+ end;
+ end;
+ end;
+end;
+
+
+
+end.
diff --git a/Game/Code/Menu/UMenuInteract.pas b/Game/Code/Menu/UMenuInteract.pas
index 78f9bd89..e0b4fa11 100644
--- a/Game/Code/Menu/UMenuInteract.pas
+++ b/Game/Code/Menu/UMenuInteract.pas
@@ -1,16 +1,16 @@
-unit UMenuInteract;
-
-interface
-
-{$I switches.inc}
-
-type
- TInteract = record // for moving thru menu
- Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child
- Num: integer; // number of this item in proper list like buttons, selects
- end;
-
-implementation
-
-end.
+unit UMenuInteract;
+
+interface
+
+{$I switches.inc}
+
+type
+ TInteract = record // for moving thru menu
+ Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child
+ Num: integer; // number of this item in proper list like buttons, selects
+ end;
+
+implementation
+
+end.
\ No newline at end of file
diff --git a/Game/Code/Menu/UMenuSelect.pas b/Game/Code/Menu/UMenuSelect.pas
index 0699868b..a93c4ed0 100644
--- a/Game/Code/Menu/UMenuSelect.pas
+++ b/Game/Code/Menu/UMenuSelect.pas
@@ -1,201 +1,201 @@
-unit UMenuSelect;
-
-interface
-
-{$I switches.inc}
-
-uses TextGL, UTexture, gl, UMenuText;
-
-type
- PSelect = ^TSelect;
- TSelect = class
- private
- SelectBool: boolean;
- public
- // objects
- Text: TText; // Main Text
- TextOpt: array of TText; // Options Text
- Texture: TTexture; // Select Texture
- TextureSBG: TTexture; // Background Selections Texture
- TextureS: array of TTexture; // Selections Texture
- SelectOptInt: integer;
- PData: ^integer;
-
- // for selection and deselection
- // main static
- ColR: real;
- ColG: real;
- ColB: real;
- Int: real;
- DColR: real;
- DColG: real;
- DColB: real;
- DInt: real;
-
- // main text
- TColR: real;
- TColG: real;
- TColB: real;
- TInt: real;
- TDColR: real;
- TDColG: real;
- TDColB: real;
- TDInt: real;
-
- // selection background static
- SBGColR: real;
- SBGColG: real;
- SBGColB: real;
- SBGInt: real;
- SBGDColR: real;
- SBGDColG: real;
- SBGDColB: real;
- SBGDInt: real;
-
- // selection statics
- SColR: real;
- SColG: real;
- SColB: real;
- SInt: real;
- SDColR: real;
- SDColG: real;
- SDColB: real;
- SDInt: real;
-
- // selection text
- STColR: real;
- STColG: real;
- STColB: real;
- STInt: real;
- STDColR: real;
- STDColG: real;
- STDColB: real;
- STDInt: real;
-
- // position and size
- property X: real read Texture.x write Texture.x;
- property Y: real read Texture.y write Texture.y;
- property W: real read Texture.w write Texture.w;
- property H: real read Texture.h write Texture.h;
-// property X2: real read Texture2.x write Texture2.x;
-// property Y2: real read Texture2.y write Texture2.y;
-// property W2: real read Texture2.w write Texture2.w;
-// property H2: real read Texture2.h write Texture2.h;
-
- // procedures
- procedure SetSelect(Value: boolean);
- property Selected: Boolean read SelectBool write SetSelect;
- procedure SetSelectOpt(Value: integer);
- property SelectedOption: integer read SelectOptInt write SetSelectOpt;
- procedure Draw(ButtonAlpha: real);
- constructor Create;
- end;
-
-implementation
-uses UDrawTexture;
-
-// ------------ Select
-constructor TSelect.Create;
-begin
- inherited Create;
- Text := TText.Create;
-end;
-
-procedure TSelect.SetSelect(Value: boolean);
-{var
- SO: integer;}
-begin // default 1, 0.4
- SelectBool := Value;
- if Value then begin
- Texture.ColR := ColR;
- Texture.ColG := ColG;
- Texture.ColB := ColB;
- Texture.Int := Int;
-
- Text.ColR := TColR;
- Text.ColG := TColG;
- Text.ColB := TColB;
- Text.Int := TInt;
-
- TextureSBG.ColR := SBGColR;
- TextureSBG.ColG := SBGColG;
- TextureSBG.ColB := SBGColB;
- TextureSBG.Int := SBGInt;
-
-{ for SO := 0 to High(TextOpt) do begin
- if SelectOptInt = SO then begin
- TextOpt[SO].ColR := STColR;
- TextOpt[SO].ColG := STColG;
- TextOpt[SO].ColB := STColB;
- TextOpt[SO].Int := STInt;
- end else begin
- TextOpt[SO].ColR := STDColR;
- TextOpt[SO].ColG := STDColG;
- TextOpt[SO].ColB := STDColB;
- TextOpt[SO].Int := STDInt;
- end;
- end;}
-
- end else begin
- Texture.ColR := DColR;
- Texture.ColG := DColG;
- Texture.ColB := DColB;
- Texture.Int := DInt;
-
- Text.ColR := TDColR;
- Text.ColG := TDColG;
- Text.ColB := TDColB;
- Text.Int := TDInt;
-
- TextureSBG.ColR := SBGDColR;
- TextureSBG.ColG := SBGDColG;
- TextureSBG.ColB := SBGDColB;
- TextureSBG.Int := SBGDInt;
-
-{ for SO := 0 to High(TextOpt) do begin
- TextOpt[SO].ColR := STDColR;
- TextOpt[SO].ColG := STDColG;
- TextOpt[SO].ColB := STDColB;
- TextOpt[SO].Int := STDInt;
- end;}
- end;
-end;
-
-procedure TSelect.SetSelectOpt(Value: integer);
-var
- SO: integer;
-begin
- SelectOptInt := Value;
- PData^ := Value;
-// SetSelect(true); // reset all colors
-
- for SO := 0 to High(TextOpt) do begin
- if SelectOptInt = SO then begin
- TextOpt[SO].ColR := STColR;
- TextOpt[SO].ColG := STColG;
- TextOpt[SO].ColB := STColB;
- TextOpt[SO].Int := STInt;
- end else begin
- TextOpt[SO].ColR := STDColR;
- TextOpt[SO].ColG := STDColG;
- TextOpt[SO].ColB := STDColB;
- TextOpt[SO].Int := STDInt;
- end;
- end;
-end;
-
-procedure TSelect.Draw(ButtonAlpha: real);
-var
- SO: integer;
-begin
- DrawTexture(Texture);
- DrawTexture(TextureSBG);
-
- Text.Draw;
-
- for SO := 0 to High(TextOpt) do begin
- TextOpt[SO].Draw;
- end;
-end;
-
-end.
+unit UMenuSelect;
+
+interface
+
+{$I switches.inc}
+
+uses TextGL, UTexture, gl, UMenuText;
+
+type
+ PSelect = ^TSelect;
+ TSelect = class
+ private
+ SelectBool: boolean;
+ public
+ // objects
+ Text: TText; // Main Text
+ TextOpt: array of TText; // Options Text
+ Texture: TTexture; // Select Texture
+ TextureSBG: TTexture; // Background Selections Texture
+ TextureS: array of TTexture; // Selections Texture
+ SelectOptInt: integer;
+ PData: ^integer;
+
+ // for selection and deselection
+ // main static
+ ColR: real;
+ ColG: real;
+ ColB: real;
+ Int: real;
+ DColR: real;
+ DColG: real;
+ DColB: real;
+ DInt: real;
+
+ // main text
+ TColR: real;
+ TColG: real;
+ TColB: real;
+ TInt: real;
+ TDColR: real;
+ TDColG: real;
+ TDColB: real;
+ TDInt: real;
+
+ // selection background static
+ SBGColR: real;
+ SBGColG: real;
+ SBGColB: real;
+ SBGInt: real;
+ SBGDColR: real;
+ SBGDColG: real;
+ SBGDColB: real;
+ SBGDInt: real;
+
+ // selection statics
+ SColR: real;
+ SColG: real;
+ SColB: real;
+ SInt: real;
+ SDColR: real;
+ SDColG: real;
+ SDColB: real;
+ SDInt: real;
+
+ // selection text
+ STColR: real;
+ STColG: real;
+ STColB: real;
+ STInt: real;
+ STDColR: real;
+ STDColG: real;
+ STDColB: real;
+ STDInt: real;
+
+ // position and size
+ property X: real read Texture.x write Texture.x;
+ property Y: real read Texture.y write Texture.y;
+ property W: real read Texture.w write Texture.w;
+ property H: real read Texture.h write Texture.h;
+// property X2: real read Texture2.x write Texture2.x;
+// property Y2: real read Texture2.y write Texture2.y;
+// property W2: real read Texture2.w write Texture2.w;
+// property H2: real read Texture2.h write Texture2.h;
+
+ // procedures
+ procedure SetSelect(Value: boolean);
+ property Selected: Boolean read SelectBool write SetSelect;
+ procedure SetSelectOpt(Value: integer);
+ property SelectedOption: integer read SelectOptInt write SetSelectOpt;
+ procedure Draw(ButtonAlpha: real);
+ constructor Create;
+ end;
+
+implementation
+uses UDrawTexture;
+
+// ------------ Select
+constructor TSelect.Create;
+begin
+ inherited Create;
+ Text := TText.Create;
+end;
+
+procedure TSelect.SetSelect(Value: boolean);
+{var
+ SO: integer;}
+begin // default 1, 0.4
+ SelectBool := Value;
+ if Value then begin
+ Texture.ColR := ColR;
+ Texture.ColG := ColG;
+ Texture.ColB := ColB;
+ Texture.Int := Int;
+
+ Text.ColR := TColR;
+ Text.ColG := TColG;
+ Text.ColB := TColB;
+ Text.Int := TInt;
+
+ TextureSBG.ColR := SBGColR;
+ TextureSBG.ColG := SBGColG;
+ TextureSBG.ColB := SBGColB;
+ TextureSBG.Int := SBGInt;
+
+{ for SO := 0 to High(TextOpt) do begin
+ if SelectOptInt = SO then begin
+ TextOpt[SO].ColR := STColR;
+ TextOpt[SO].ColG := STColG;
+ TextOpt[SO].ColB := STColB;
+ TextOpt[SO].Int := STInt;
+ end else begin
+ TextOpt[SO].ColR := STDColR;
+ TextOpt[SO].ColG := STDColG;
+ TextOpt[SO].ColB := STDColB;
+ TextOpt[SO].Int := STDInt;
+ end;
+ end;}
+
+ end else begin
+ Texture.ColR := DColR;
+ Texture.ColG := DColG;
+ Texture.ColB := DColB;
+ Texture.Int := DInt;
+
+ Text.ColR := TDColR;
+ Text.ColG := TDColG;
+ Text.ColB := TDColB;
+ Text.Int := TDInt;
+
+ TextureSBG.ColR := SBGDColR;
+ TextureSBG.ColG := SBGDColG;
+ TextureSBG.ColB := SBGDColB;
+ TextureSBG.Int := SBGDInt;
+
+{ for SO := 0 to High(TextOpt) do begin
+ TextOpt[SO].ColR := STDColR;
+ TextOpt[SO].ColG := STDColG;
+ TextOpt[SO].ColB := STDColB;
+ TextOpt[SO].Int := STDInt;
+ end;}
+ end;
+end;
+
+procedure TSelect.SetSelectOpt(Value: integer);
+var
+ SO: integer;
+begin
+ SelectOptInt := Value;
+ PData^ := Value;
+// SetSelect(true); // reset all colors
+
+ for SO := 0 to High(TextOpt) do begin
+ if SelectOptInt = SO then begin
+ TextOpt[SO].ColR := STColR;
+ TextOpt[SO].ColG := STColG;
+ TextOpt[SO].ColB := STColB;
+ TextOpt[SO].Int := STInt;
+ end else begin
+ TextOpt[SO].ColR := STDColR;
+ TextOpt[SO].ColG := STDColG;
+ TextOpt[SO].ColB := STDColB;
+ TextOpt[SO].Int := STDInt;
+ end;
+ end;
+end;
+
+procedure TSelect.Draw(ButtonAlpha: real);
+var
+ SO: integer;
+begin
+ DrawTexture(Texture);
+ DrawTexture(TextureSBG);
+
+ Text.Draw;
+
+ for SO := 0 to High(TextOpt) do begin
+ TextOpt[SO].Draw;
+ end;
+end;
+
+end.
diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas
index 320f3851..ac8fa2dc 100644
--- a/Game/Code/Menu/UMenuStatic.pas
+++ b/Game/Code/Menu/UMenuStatic.pas
@@ -1,85 +1,85 @@
-unit UMenuStatic;
-
-interface
-
-{$I switches.inc}
-
-uses UTexture, gl;
-
-type
- TStatic = class
- public
- Texture: TTexture; // Button Screen position and size
- Visible: boolean;
-
- //Reflection Mod
- Reflection: boolean;
- Reflectionspacing: Real;
-
- procedure Draw;
- constructor Create(Textura: TTexture); overload;
- end;
-
-implementation
-uses UDrawTexture;
-
-procedure TStatic.Draw;
-begin
- if Visible then
- begin
- DrawTexture(Texture);
-
- //Reflection Mod
- if (Reflection) then // Draw Reflections
- begin
- with Texture do
- begin
- //Bind Tex and GL Attributes
- glEnable(GL_TEXTURE_2D);
- glEnable(GL_BLEND);
-
- glDepthRange(0, 10);
- glDepthFunc(GL_LEQUAL);
- glEnable(GL_DEPTH_TEST);
-
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBindTexture(GL_TEXTURE_2D, TexNum);
-
- //Draw
- glBegin(GL_QUADS);//Top Left
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
- glTexCoord2f(TexX1*TexW, TexY2*TexH);
- glVertex3f(x, y+h*scaleH+ Reflectionspacing, z);
-
- //Bottom Left
- glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
- glTexCoord2f(TexX1*TexW, 0.5*TexH+TexY1);
- glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z);
-
-
- //Bottom Right
- glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
- glTexCoord2f(TexX2*TexW, 0.5*TexH+TexY1);
- glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z);
-
- //Top Right
- glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
- glTexCoord2f(TexX2*TexW, TexY2*TexH);
- glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z);
- glEnd;
-
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- end;
- end;
- end;
-end;
-
-constructor TStatic.Create(Textura: TTexture);
-begin
- inherited Create;
- Texture := Textura;
-end;
-
-end.
+unit UMenuStatic;
+
+interface
+
+{$I switches.inc}
+
+uses UTexture, gl;
+
+type
+ TStatic = class
+ public
+ Texture: TTexture; // Button Screen position and size
+ Visible: boolean;
+
+ //Reflection Mod
+ Reflection: boolean;
+ Reflectionspacing: Real;
+
+ procedure Draw;
+ constructor Create(Textura: TTexture); overload;
+ end;
+
+implementation
+uses UDrawTexture;
+
+procedure TStatic.Draw;
+begin
+ if Visible then
+ begin
+ DrawTexture(Texture);
+
+ //Reflection Mod
+ if (Reflection) then // Draw Reflections
+ begin
+ with Texture do
+ begin
+ //Bind Tex and GL Attributes
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+
+ glDepthRange(0, 10);
+ glDepthFunc(GL_LEQUAL);
+ glEnable(GL_DEPTH_TEST);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBindTexture(GL_TEXTURE_2D, TexNum);
+
+ //Draw
+ glBegin(GL_QUADS);//Top Left
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
+ glTexCoord2f(TexX1*TexW, TexY2*TexH);
+ glVertex3f(x, y+h*scaleH+ Reflectionspacing, z);
+
+ //Bottom Left
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
+ glTexCoord2f(TexX1*TexW, 0.5*TexH+TexY1);
+ glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z);
+
+
+ //Bottom Right
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, 0);
+ glTexCoord2f(TexX2*TexW, 0.5*TexH+TexY1);
+ glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z);
+
+ //Top Right
+ glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3);
+ glTexCoord2f(TexX2*TexW, TexY2*TexH);
+ glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z);
+ glEnd;
+
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+ end;
+ end;
+ end;
+end;
+
+constructor TStatic.Create(Textura: TTexture);
+begin
+ inherited Create;
+ Texture := Textura;
+end;
+
+end.