aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Classes/TextGL.pas70
-rw-r--r--Game/Code/Classes/UThemes.pas12
-rw-r--r--Game/Code/Menu/UMenu.pas10
-rw-r--r--Game/Code/Menu/UMenuText.pas18
4 files changed, 94 insertions, 16 deletions
diff --git a/Game/Code/Classes/TextGL.pas b/Game/Code/Classes/TextGL.pas
index 5b114669..e00388a4 100644
--- a/Game/Code/Classes/TextGL.pas
+++ b/Game/Code/Classes/TextGL.pas
@@ -33,7 +33,7 @@ procedure SetFontSize(Size: real);
procedure SetFontStyle(Style: integer); // sets active font style (normal, bold, etc)
procedure SetFontItalic(Enable: boolean); // sets italic type letter (works for all fonts)
procedure SetFontAspectW(Aspect: real);
-
+procedure SetFontReflection(Enable:boolean;Spacing: real); // Enables/Disables text reflection
// Start of SDL_ttf
function NextPowerOfTwo(Value: Integer): Integer;
//Checks if the ttf exists, if yes then a SDL_ttf is returned
@@ -63,6 +63,8 @@ type
Done: real;
Outline: real;
Italic: boolean;
+ Reflection: boolean;
+ ReflectionSpacing: real;
end;
@@ -74,6 +76,9 @@ var
PColG: real;
PColB: real;
+ // Colours for the reflection
+ TempColor: Array[0..3] of GLfloat;
+ PTempColor: PGLfloat;
implementation
uses
@@ -208,24 +213,27 @@ procedure glPrintLetter(Letter: char);
var
TexX, TexY: real;
TexR, TexB: real;
+ TestHeight: real;
FWidth: real;
PL, PT: real;
PR, PB: real;
XItal: real; // X shift for italic type letter
+ ReflectionSpacing:real; // Distance of the reflection
begin
with Fonts[ActFont].Tex do
begin
FWidth := Fonts[ActFont].Width[Ord(Letter)];
W := FWidth * (H/30) * Fonts[ActFont].AspectW;
- // H := 30;
// set texture positions
TexX := (ord(Letter) mod 16) * 1/16 + 1/32 - FWidth/1024 - Fonts[ActFont].Outline/1024;
- TexY := (ord(Letter) div 16) * 1/16 + 2/1024; // 2/1024
+ TexY := (ord(Letter) div 16) * 1/16 + 2/1024;
TexR := (ord(Letter) mod 16) * 1/16 + 1/32 + FWidth/1024 + Fonts[ActFont].Outline/1024;
TexB := (1 + ord(Letter) div 16) * 1/16 - 2/1024;
+ TestHeight := TexB - TexY;
+
// set vector positions
PL := X - Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW /2;
PT := Y;
@@ -252,10 +260,47 @@ begin
glEnd;
end;
- X := X + W;
- glDisable(GL_BLEND);
- glDisable(GL_TEXTURE_2D);
- end; // with
+ // <mog> Reflection
+ // Yes it would make sense to put this in an extra procedure,
+ // but this works, doesn't take much lines, and is almost lightweight
+ if Fonts[ActFont].Reflection = true then
+ begin
+ ReflectionSpacing := Fonts[ActFont].ReflectionSpacing + H/2;
+
+ glDepthRange(0, 10);
+ glDepthFunc(GL_LEQUAL);
+ glEnable(GL_DEPTH_TEST);
+
+ glBegin(GL_QUADS);
+ try
+ glColor4f(TempColor[0], TempColor[1], TempColor[2], 0);
+ glTexCoord2f(TexX, TexY + TestHeight/2);
+ glVertex3f(PL, PB + ReflectionSpacing - H/2, z);
+
+ glColor4f(TempColor[0], TempColor[1], TempColor[2], Alpha-0.3);
+ glTexCoord2f(TexX, TexB );
+ glVertex3f(PL + XItal, PT + ReflectionSpacing, z);
+
+ glTexCoord2f(TexR, TexB );
+ glVertex3f(PR + XItal, PT + ReflectionSpacing, z);
+
+ glColor4f(TempColor[0], TempColor[1], TempColor[2], 0);
+ glTexCoord2f(TexR, TexY + TestHeight/2);
+ glVertex3f(PR, PB + ReflectionSpacing - H/2, z);
+ finally
+ glEnd;
+ end;
+ glDisable(GL_DEPTH_TEST);
+ end; // reflection
+
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+
+ X := X + W;
+ end; // with
+
+ //write the colour back
+ glColor4fv(PTempColor);
end;
procedure glPrintLetterCut(letter: char; Start, Finish: real);
@@ -334,6 +379,11 @@ begin
end; // while
*)
+//Save the actual color and alpha (for reflection)
+ PTempColor:= @TempColor;
+//I've read that glGetFloat is quite slow, but it seems that there is no alternative
+ glGetFloatv(GL_CURRENT_COLOR, PTempColor);
+
// This code is better, because doing a Copy of for every
// letter in a string is a waste of CPU & Memory resources.
// Copy operations are quite memory intensive, and this simple
@@ -536,6 +586,12 @@ begin
Fonts[ActFont].AspectW := Aspect;
end;
+procedure SetFontReflection(Enable:boolean;Spacing: real);
+begin
+ Fonts[ActFont].Reflection := Enable;
+ Fonts[ActFont].ReflectionSpacing := Spacing;
+end;
+
end.
diff --git a/Game/Code/Classes/UThemes.pas b/Game/Code/Classes/UThemes.pas
index dc9e2935..366e478e 100644
--- a/Game/Code/Classes/UThemes.pas
+++ b/Game/Code/Classes/UThemes.pas
@@ -46,7 +46,7 @@ type
TexY1: real;
TexX2: real;
TexY2: real;
- //Reflection Mod
+ //Reflection
Reflection: boolean;
Reflectionspacing: Real;
end;
@@ -64,6 +64,9 @@ type
Size: integer;
Align: integer;
Text: string;
+ //Reflection
+ Reflection: boolean;
+ ReflectionSpacing: Real;
end;
AThemeText = array of TThemeText;
@@ -1463,6 +1466,10 @@ begin
ThemeText.Text := Language.Translate(ThemeIni.ReadString(Name, 'Text', ''));
ThemeText.Color := ThemeIni.ReadString(Name, 'Color', '');
+ //Reflection
+ ThemeText.Reflection := (ThemeIni.ReadInteger(Name, 'Reflection', 0)) = 1;
+ ThemeText.Reflectionspacing := ThemeIni.ReadFloat(Name, 'ReflectionSpacing', 15);
+
C := ColorExists(ThemeText.Color);
if C >= 0 then begin
ThemeText.ColR := Color[C].RGB.R;
@@ -2125,6 +2132,9 @@ begin
ThemeIni.WriteString(Name, 'Text', ThemeText.Text);
ThemeIni.WriteString(Name, 'Color', ThemeText.Color);
+
+ ThemeIni.WriteBool(Name, 'Reflection', ThemeText.Reflection);
+ ThemeIni.WriteFloat(Name, 'ReflectionSpacing', ThemeText.ReflectionSpacing);
end;
procedure TTheme.ThemeSaveTexts(ThemeText: AThemeText; Name: string);
diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas
index 126fefa1..0eebeaf6 100644
--- a/Game/Code/Menu/UMenu.pas
+++ b/Game/Code/Menu/UMenu.pas
@@ -75,7 +75,7 @@ type
function AddText(ThemeText: TThemeText): integer; overload;
function AddText(X, Y: real; const Text_: string): integer; overload;
function AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; const Text: string): integer; overload;
- function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: string): integer; overload;
+ function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: string; Reflection_: Boolean; ReflectionSpacing_: Real): integer; overload;
// button
Procedure SetButtonLength(Length: Cardinal); //Function that Set Length of Button Array in one Step instead of register new Memory for every Button
@@ -539,7 +539,7 @@ end;
function TMenu.AddText(ThemeText: TThemeText): integer;
begin
Result := AddText(ThemeText.X, ThemeText.Y, ThemeText.W, ThemeText.Font, ThemeText.Size,
- ThemeText.ColR, ThemeText.ColG, ThemeText.ColB, ThemeText.Align, ThemeText.Text);
+ ThemeText.ColR, ThemeText.ColG, ThemeText.ColB, ThemeText.Align, ThemeText.Text, ThemeText.Reflection, ThemeText.ReflectionSpacing);
end;
function TMenu.AddText(X, Y: real; const Text_: string): integer;
@@ -555,17 +555,17 @@ end;
function TMenu.AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; const Text: string): integer;
begin
- Result := AddText(X, Y, 0, Style, Size, ColR, ColG, ColB, 0, Text);
+ Result := AddText(X, Y, 0, Style, Size, ColR, ColG, ColB, 0, Text, false, 0);
end;
-function TMenu.AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: string): integer;
+function TMenu.AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; const Text_: string; Reflection_: Boolean; ReflectionSpacing_: Real): integer;
var
TextNum: integer;
begin
// adds text
TextNum := Length(Text);
SetLength(Text, TextNum + 1);
- Text[TextNum] := TText.Create(X, Y, W, Style, Size, ColR, ColG, ColB, Align, Text_);
+ Text[TextNum] := TText.Create(X, Y, W, Style, Size, ColR, ColG, ColB, Align, Text_, Reflection_, ReflectionSpacing_);
Result := TextNum;
end;
diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas
index 4b376a90..3ed0095e 100644
--- a/Game/Code/Menu/UMenuText.pas
+++ b/Game/Code/Menu/UMenuText.pas
@@ -40,6 +40,10 @@ type
Visible: boolean;
Align: integer; // 0 = left, 1 = center, 2 = right
+ //Reflection
+ Reflection: boolean;
+ ReflectionSpacing: Real;
+
procedure SetSelect(Value: Boolean);
property Selected: Boolean read SelectBool write SetSelect;
@@ -51,7 +55,7 @@ type
procedure Draw;
constructor Create; overload;
constructor Create(X, Y: real; Tekst: string); overload;
- constructor Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); overload;
+ constructor Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string; ParReflection: Boolean; ParReflectionSpacing: Real) overload;
end;
implementation
@@ -276,6 +280,12 @@ begin
glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha);
+ //Reflection
+ if Reflection = true then
+ SetFontReflection(true,ReflectionSpacing)
+ else
+ SetFontReflection(false,0);
+
//If Selected Set Blink...
if SelectBool then
begin
@@ -346,10 +356,10 @@ end;
constructor TText.Create(X, Y: real; Tekst: string);
begin
- Create(X, Y, 0, 0, 10, 0, 0, 0, 0, Tekst);
+ Create(X, Y, 0, 0, 10, 0, 0, 0, 0, Tekst, false, 0);
end;
-constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string);
+constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string; ParReflection: Boolean; ParReflectionSpacing: Real);
begin
inherited Create;
Alpha := 1;
@@ -366,6 +376,8 @@ begin
Align := ParAlign;
SelectBool := false;
Visible := true;
+ Reflection:= ParReflection;
+ ReflectionSpacing:= ParReflectionSpacing;
end;