diff options
author | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-04-26 19:42:55 +0000 |
---|---|---|
committer | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-04-26 19:42:55 +0000 |
commit | b2518890d0dd62eeb96ee8b4b5f2d86e61ca75e7 (patch) | |
tree | aff3f22b7fc7ef8b8fe69d0714ffaf968e96ccdb /Game/Code | |
parent | 88180a90a43d3a5392b300b95d62249f11fed786 (diff) | |
download | usdx-b2518890d0dd62eeb96ee8b4b5f2d86e61ca75e7.tar.gz usdx-b2518890d0dd62eeb96ee8b4b5f2d86e61ca75e7.tar.xz usdx-b2518890d0dd62eeb96ee8b4b5f2d86e61ca75e7.zip |
Added PS3 like ButtonFade ability
Some new ThemeButton Attributes:
DeSelectReflectionSpacing: ReflectionSpacing when Button is not Selected
Fade: Enable Stepings in Fading
FadeText: Fade Texts with Button
SelectW, SelectH: Width and Height when Button is Selected
FadeTex: Texture used when Button Fades to not stretch the Texture. Not nessecary.
FadeTexPos: Position of FadeTex
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@143 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r-- | Game/Code/Classes/UThemes.pas | 24 | ||||
-rw-r--r-- | Game/Code/Menu/UMenu.pas | 26 | ||||
-rw-r--r-- | Game/Code/Menu/UMenuButton.pas | 266 | ||||
-rw-r--r-- | Game/Code/Screens/UScreenMain.pas | 20 |
4 files changed, 295 insertions, 41 deletions
diff --git a/Game/Code/Classes/UThemes.pas b/Game/Code/Classes/UThemes.pas index 33cf4258..90bab7c1 100644 --- a/Game/Code/Classes/UThemes.pas +++ b/Game/Code/Classes/UThemes.pas @@ -134,6 +134,14 @@ type //Reflection Mod
Reflection: boolean;
Reflectionspacing: Real;
+ //Fade Mod
+ SelectH: integer;
+ SelectW: integer;
+ Fade: boolean;
+ FadeText: boolean;
+ DeSelectReflectionspacing : Real;
+ FadeTex: string;
+ FadeTexPos: integer;
end;
TThemeSelect = record
@@ -1454,6 +1462,22 @@ begin ThemeButton.DColB := Color[C].RGB.B;
end;
+ //Fade Mod
+ ThemeButton.SelectH := ThemeIni.ReadInteger (Name, 'SelectH', ThemeButton.H);
+ ThemeButton.SelectW := ThemeIni.ReadInteger (Name, 'SelectW', ThemeButton.W);
+
+ ThemeButton.DeSelectReflectionspacing := ThemeIni.ReadFloat(Name, 'DeSelectReflectionSpacing', ThemeButton.Reflectionspacing);
+
+ ThemeButton.Fade := (ThemeIni.ReadInteger(Name, 'Fade', 0) = 1);
+ ThemeButton.FadeText := (ThemeIni.ReadInteger(Name, 'FadeText', 0) = 1);
+
+
+ ThemeButton.FadeTex := ThemeIni.ReadString(Name, 'FadeTex', '');
+ ThemeButton.FadeTexPos:= ThemeIni.ReadInteger(Name, 'FadeTexPos', 0);
+ if (ThemeButton.FadeTexPos > 4) Or (ThemeButton.FadeTexPos < 0) then
+ ThemeButton.FadeTexPos := 0;
+
+ //Read ButtonTexts
TLen := ThemeIni.ReadInteger(Name, 'Texts', 0);
SetLength(ThemeButton.Text, TLen);
for T := 1 to TLen do
diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 1c4418c1..28ba17e7 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -65,7 +65,7 @@ type function AddButton(ThemeButton: TThemeButton): integer; overload;
function AddButton(X, Y, W, H: real; Name: String): integer; overload;
function AddButton(X, Y, W, H: real; Name, Format, Typ: String; Reflection: Boolean): integer; overload;
- function AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean; ReflectionSpacing: Real): integer; overload;
+ function AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean; ReflectionSpacing, DeSelectReflectionSpacing: Real): integer; overload;
procedure ClearButtons;
procedure AddButtonText(AddX, AddY: real; AddText: string); overload;
procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; AddText: string); overload;
@@ -394,10 +394,19 @@ begin Result := AddButton(ThemeButton.X, ThemeButton.Y, ThemeButton.W, ThemeButton.H,
ThemeButton.ColR, ThemeButton.ColG, ThemeButton.ColB, ThemeButton.Int,
ThemeButton.DColR, ThemeButton.DColG, ThemeButton.DColB, ThemeButton.DInt,
- Skin.GetTextureFileName(ThemeButton.Tex), 'JPG', ThemeButton.Typ, ThemeButton.Reflection, ThemeButton.Reflectionspacing);
+ Skin.GetTextureFileName(ThemeButton.Tex), 'JPG', ThemeButton.Typ, ThemeButton.Reflection, ThemeButton.Reflectionspacing, ThemeButton.DeSelectReflectionspacing);
Button[Result].Z := ThemeButton.Z;
+ //Some Things from ButtonFading
+ Button[Result].SelectH := ThemeButton.SelectH;
+ Button[Result].SelectW := ThemeButton.SelectW;
+
+ Button[Result].Fade := ThemeButton.Fade;
+ Button[Result].FadeText := ThemeButton.FadeText;
+ Button[Result].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeButton.FadeTex), ThemeButton.Typ, true);
+ Button[Result].FadeTexPos := ThemeButton.FadeTexPos;
+
BTLen := Length(ThemeButton.Text);
for BT := 0 to BTLen-1 do begin
@@ -415,10 +424,10 @@ end; function TMenu.AddButton(X, Y, W, H: real; Name, Format, Typ: String; Reflection: Boolean): integer;
begin
- Result := AddButton(X, Y, W, H, 1, 1, 1, 1, 1, 1, 1, 0.5, Name, 'JPG', 'Plain', Reflection, 15);
+ Result := AddButton(X, Y, W, H, 1, 1, 1, 1, 1, 1, 1, 0.5, Name, 'JPG', 'Plain', Reflection, 15, 15);
end;
-function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean; ReflectionSpacing: Real): integer;
+function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean; ReflectionSpacing, DeSelectReflectionSpacing: Real): integer;
begin
// adds button
//SetLength is used to reduce Memory usement
@@ -442,10 +451,10 @@ begin // Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, false)); // don't use cache texture}
// configures button
- Button[Result].Texture.X := X;
- Button[Result].Texture.Y := Y;
- Button[Result].Texture.W := W;
- Button[Result].Texture.H := H;
+ Button[Result].X := X;
+ Button[Result].Y := Y;
+ Button[Result].W := W;
+ Button[Result].H := H;
Button[Result].SelectColR := ColR;
Button[Result].SelectColG := ColG;
Button[Result].SelectColB := ColB;
@@ -462,6 +471,7 @@ begin Button[Result].Reflection := Reflection;
Button[Result].Reflectionspacing := ReflectionSpacing;
+ Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing;
// adds interaction
AddInteraction(iButton, Result);
diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index 3a871c5f..34d45083 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -7,11 +7,23 @@ type TButton = class
private
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
+
+ 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
@@ -20,7 +32,12 @@ type //Reflection Mod
Reflection: boolean;
Reflectionspacing: Real;
-
+ DeSelectReflectionspacing: Real;
+
+ //Fade Mod
+ Fade: Boolean;
+ FadeText: Boolean;
+
Selectable: boolean;
SelectColR: real;
@@ -28,6 +45,9 @@ type SelectColB: real;
SelectInt: real;
SelectTInt: real;
+ //Fade Mod
+ SelectW: real;
+ SelectH: real;
DeselectColR: real;
DeselectColG: real;
@@ -36,12 +56,16 @@ type DeselectTInt: real;
procedure SetY(Value: real);
+ procedure SetX(Value: real);
+ procedure SetW(Value: real);
+ procedure SetH(Value: real);
+
procedure SetSelect(Value: Boolean);
- property X: real read Texture.x write Texture.x;
- property Y: real read Texture.y write SetY;
+ 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 Texture.w write Texture.w;
- property H: real read Texture.h write Texture.h;
+ property W: real read DeSelectW write SetW;
+ property H: real read DeSelectH write SetH;
property Selected: Boolean read SelectBool write SetSelect;
procedure Draw;
@@ -51,24 +75,76 @@ type end;
implementation
-uses UDrawTexture, SysUtils;
+uses UDrawTexture, SysUtils, windows;
+
+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 = -1) then
+ Texture.X := Value;
+
+end;
procedure TButton.SetY(Value: real);
var
dY: real;
T: integer; // text
begin
- dY := Value - Texture.y;
+ {dY := Value - PosY;
- Texture.y := Value;
for T := 0 to High(Text) do
- Text[T].Y := Text[T].Y + dY;
+ Text[T].Y := Text[T].Y + dY;}
+
+ PosY := Value;
+ if (FadeTex.TexNum = -1) 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
+var
T: integer;
begin
SelectBool := Value;
@@ -85,6 +161,18 @@ begin 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;
@@ -98,6 +186,18 @@ begin 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;
@@ -140,7 +240,16 @@ begin DeselectInt := 0.5;
DeselectTInt := 1;
+ FadeTex.TexNum := -1;
+ FadeProgress := 0;
+ Fade := False;
+ FadeText := False;
+ SelectW := DeSelectW;
+ SelectH := DeSelectH;
+
+ PosX := 0;
+ PosY := 0;
end;
// ***** Public methods ****** //
@@ -148,10 +257,130 @@ end; procedure TButton.Draw;
var
T: integer;
+ Tick: Cardinal;
+ Spacing: Real;
begin
if Visible then begin
+ //Fade Mod
+ if Fade then
+ begin
+ if (FadeProgress < 1) and (FadeProgress > 0) then
+ begin
+ Tick := GetTickCount 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 = -1) then
+ begin
+ Texture.W := DeSelectW + (SelectW - DeSelectW) * FadeProgress;
+ Texture.H := DeSelectH + (SelectH - DeSelectH) * FadeProgress;
+ end
+ else //method with Fade Texture
+ begin
+ Texture.W := DeSelectW;
+ Texture.H := DeSelectH;
+
+ 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;
+ //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;
+ //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;
+ //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;
+ //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;
+
DrawTexture(Texture);
+ //Draw FadeTex
+ if (FadeTex.TexNum <> -1) then
+ DrawTexture(FadeTex);
+
if Texture2.Alpha > 0 then begin
Texture2.ScaleW := Texture.ScaleW;
Texture2.ScaleH := Texture.ScaleH;
@@ -174,6 +403,15 @@ begin //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;
+
with Texture do
begin
//Bind Tex and GL Attributes
@@ -191,23 +429,23 @@ begin 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);
+ 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 + Reflectionspacing, z);
+ 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 + Reflectionspacing, z);
+ 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 + Reflectionspacing, z);
+ glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z);
glEnd;
glDisable(GL_TEXTURE_2D);
diff --git a/Game/Code/Screens/UScreenMain.pas b/Game/Code/Screens/UScreenMain.pas index 28c255d1..4c822640 100644 --- a/Game/Code/Screens/UScreenMain.pas +++ b/Game/Code/Screens/UScreenMain.pas @@ -23,7 +23,7 @@ type implementation
-uses Windows, UGraphic, UMain, UIni, UTexture, USongs, Textgl, opengl, ULanguage, UParty, UDLLManager, UScreenCredits;
+uses Windows, UGraphic, UMain, UIni, UTexture, USongs, Textgl, opengl, ULanguage, UParty, UDLLManager, UScreenCredits, USkins;
function TScreenMain.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean;
@@ -149,24 +149,6 @@ begin TextDescriptionLong := AddText(Theme.Main.TextDescriptionLong);
Interaction := 0;
-
- //Some Testing for Button Fade
-{ Button[0].SelectH := Button[0].H * 3;
- Button[0].Fade := True;
- Button[0].FadeText := True;
- Button[0].DeSelectReflectionspacing := 280;
-
- Button[1].SelectH := Button[0].H * 3;
- Button[1].Fade := True;
-
- Button[2].SelectH := Button[0].H * 3;
- Button[2].Fade := True;
- Button[2].FadeText := True;
-
- Button[3].SelectH := Button[0].H * 3;
- Button[3].Fade := True;
- Button[3].FadeText := True;
-}
end;
procedure TScreenMain.onShow;
|