aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Menu
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Game/Code/Menu/UDisplay.dcubin0 -> 7030 bytes
-rw-r--r--Game/Code/Menu/UDisplay.pas289
-rw-r--r--Game/Code/Menu/UDrawTexture.dcubin0 -> 3640 bytes
-rw-r--r--Game/Code/Menu/UDrawTexture.pas101
-rw-r--r--Game/Code/Menu/UMenu.dcubin0 -> 31672 bytes
-rw-r--r--Game/Code/Menu/UMenu.pas1136
-rw-r--r--Game/Code/Menu/UMenuButton.dcubin0 -> 5472 bytes
-rw-r--r--Game/Code/Menu/UMenuButton.pas238
-rw-r--r--Game/Code/Menu/UMenuInteract.dcubin0 -> 404 bytes
-rw-r--r--Game/Code/Menu/UMenuInteract.pas14
-rw-r--r--Game/Code/Menu/UMenuSelect.dcubin0 -> 3922 bytes
-rw-r--r--Game/Code/Menu/UMenuSelect.pas198
-rw-r--r--Game/Code/Menu/UMenuSelectSlide.dcubin0 -> 6108 bytes
-rw-r--r--Game/Code/Menu/UMenuSelectSlide.pas335
-rw-r--r--Game/Code/Menu/UMenuStatic.dcubin0 -> 1594 bytes
-rw-r--r--Game/Code/Menu/UMenuStatic.pas32
-rw-r--r--Game/Code/Menu/UMenuText.dcubin0 -> 3155 bytes
-rw-r--r--Game/Code/Menu/UMenuText.pas96
18 files changed, 2439 insertions, 0 deletions
diff --git a/Game/Code/Menu/UDisplay.dcu b/Game/Code/Menu/UDisplay.dcu
new file mode 100644
index 00000000..f4f89245
--- /dev/null
+++ b/Game/Code/Menu/UDisplay.dcu
Binary files differ
diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas
new file mode 100644
index 00000000..6d0443cc
--- /dev/null
+++ b/Game/Code/Menu/UDisplay.pas
@@ -0,0 +1,289 @@
+unit UDisplay;
+
+interface
+
+uses Windows, SDL, UMenu, OpenGL12, SysUtils;
+
+type
+ TDisplay = class
+ ActualScreen: PMenu;
+ NextScreen: PMenu;
+
+ h_DC: HDC;
+ h_RC: HGLRC;
+
+// FadeType: integer;
+ FadeTex: glUInt;
+ LastFade: real;
+ Fade: real;
+ function Draw: Boolean;
+ procedure PrintScreen;
+ constructor Create;
+ procedure ScreenShot;
+ end;
+
+var
+ Display: TDisplay;
+// ActualScreen: PMenu;
+// NextScreen: PMenu;
+
+implementation
+
+uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture;
+
+constructor TDisplay.Create;
+begin
+ inherited Create;
+// FadeType := 0;
+ Fade := 0;
+end;
+
+function TDisplay.Draw: Boolean;
+var
+ S: integer;
+ Col: real;
+ Surface: PSDL_Surface;
+begin
+ Result := True;
+
+ Col := 1;
+ if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then
+ Col := 0;
+
+ glClearColor(Col, Col, Col , 1);
+ 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;
+
+
+ if S = 2 then TimeSkip := 0; // it's easier than rewriting code
+ glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH);
+
+ ActualScreen.SetAnimationProgress(1);
+ if not assigned (NextScreen) then Result := ActualScreen.Draw
+ else begin
+ LastFade := Fade;
+ Fade := Fade + TimeSkip * 6; // * 4
+
+ {//Create Fading texture
+ if Fade = 0 then
+ begin
+ Surface := SDL_GetVideoSurface;
+ glGenTextures(1, FadeTex);
+
+ glBindTexture(GL_TEXTURE_2D, FadeTex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, Surface.pitch div Surface.format.BytesPerPixel);
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, 800, 600, 0, GL_RGBA, GL_UNSIGNED_BYTE, Surface.pixels);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ end;}
+
+ ActualScreen.ShowFinish := false;
+
+ //Fade = 2 (Belnding) Mod
+ if (FadeTex > 0) then
+ begin
+ ActualScreen.SetAnimationProgress(Fade-1);
+ ActualScreen.Draw;
+ glBindTexture(GL_TEXTURE_2D, FadeTex);
+ glColor4f(Col, Col, Col, 1-Fade); // 0
+ glEnable(GL_BLEND);
+ glBegin(GL_QUADS);
+ glVertex2f(0, 0);
+ glVertex2f(0, 600);
+ glVertex2f(800, 600);
+ glVertex2f(800, 0);
+ glEnd;
+ glDisable(GL_BLEND);
+ end
+ else
+ begin
+ case ActualScreen.Fade of
+ 0: begin
+ if Fade < 1 then begin
+ ActualScreen.SetAnimationProgress(1-Fade);
+ ActualScreen.Draw;
+ glColor4f(Col, Col, Col, Fade); // 0
+ end else begin
+ ActualScreen.SetAnimationProgress(Fade-1);
+ ActualScreen.Draw;
+ glColor4f(Col, Col, Col, 1-Fade); // 0
+ end;
+ glEnable(GL_BLEND);
+ glBegin(GL_QUADS);
+ glVertex2f(0, 0);
+ glVertex2f(0, 600);
+ glVertex2f(800, 600);
+ glVertex2f(800, 0);
+ glEnd;
+ glDisable(GL_BLEND);
+ end;
+ 2: begin
+ if Fade < 1 then begin
+ ActualScreen.SetAnimationProgress(1-Fade);
+ ActualScreen.Draw;
+ //glColor4f(Col, Col, Col, Fade); // 0
+ glColor4f(1, 1, 1, 1); // 0
+ //Fade := 1
+ end;
+ glEnable(GL_BLEND);
+ glBegin(GL_QUADS);
+ glVertex2f(0, 0);
+ glVertex2f(0, 600);
+ glVertex2f(800, 600);
+ glVertex2f(800, 0);
+ glEnd;
+ glDisable(GL_BLEND);
+ end;
+ end; // case
+ end;
+
+ if (LastFade < 1 ) and (Fade >= 1) then begin
+ if (ActualScreen.Fade = 2) then
+ begin
+ ScreenShot;
+ //Create Fading Texture
+ Surface := SDL_GetVideoSurface;
+ glGenTextures(1, FadeTex);
+
+ glBindTexture(GL_TEXTURE_2D, FadeTex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, Surface.pitch div Surface.format.BytesPerPixel);
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, 800, 600, 0, GL_RGBA, GL_UNSIGNED_BYTE, Surface.pixels);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ end;
+
+ // pokazuje 2 ekran, ale nie kasuje informacji o NextScreen
+ ActualScreen.onHide;
+ ActualScreen := NextScreen;
+ ActualScreen.onShow;
+ end;
+
+ if Fade >= 2 then begin
+ if (FadeTex > 0) then //Delete Fade Tex
+ begin
+ glDeleteTextures(1, @FadeTex);
+ FadeTex := 0;
+ end;
+
+ // koniec fade'a
+ ActualScreen := NextScreen;
+ NextScreen := nil;
+ ActualScreen.onShowFinish;
+ ActualScreen.ShowFinish := true;
+ end;
+ end; // if
+ end; // for
+// SwapBuffers(h_DC);
+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.PrintScreen;
+var
+ Bitmap: TBitmap;
+ Jpeg: TJpegImage;
+ X, Y: integer;
+ Num: integer;
+ FileName: string;
+begin
+ for Num := 1 to 9999 do begin
+ FileName := IntToStr(Num);
+ while Length(FileName) < 4 do FileName := '0' + FileName;
+ FileName := ScreenshotsPath + 'screenshot' + FileName + '.jpg';
+ if not FileExists(FileName) then break
+ end;
+
+ glReadPixels(0, 0, ScreenW, ScreenH, GL_RGBA, GL_UNSIGNED_BYTE, @PrintScreenData[0]);
+ Bitmap := TBitmap.Create;
+ Bitmap.Width := ScreenW;
+ Bitmap.Height := ScreenH;
+
+ for Y := 0 to ScreenH-1 do
+ for X := 0 to ScreenW-1 do
+ Bitmap.Canvas.Pixels[X, Y] := PrintScreenData[(ScreenH-1-Y) * ScreenW + X] and $00FFFFFF;
+
+ Jpeg := TJpegImage.Create;
+ Jpeg.Assign(Bitmap);
+ Bitmap.Free;
+ Jpeg.CompressionQuality := 95;//90;
+ ForceDirectories(ScreenshotsPath);
+ Jpeg.SaveToFile(FileName);
+ Jpeg.Free;
+end;
+
+procedure TDisplay.ScreenShot;
+ var F : file;
+ FileInfo: BITMAPINFOHEADER;
+ FileHeader : BITMAPFILEHEADER;
+ pPicData:Pointer;
+ FileName: String;
+ Num: Integer;
+begin
+ //bilddatei Suchen
+ for Num := 1 to 9999 do begin
+ FileName := IntToStr(Num);
+ while Length(FileName) < 4 do FileName := '0' + FileName;
+ FileName := {ScreenshotsPath + }'screenshot' + FileName + '.BMP';
+ if not FileExists(FileName) then break
+ end;
+
+ //Speicher für die Speicherung der Header-Informationen vorbereiten
+ ZeroMemory(@FileHeader, SizeOf(BITMAPFILEHEADER));
+ ZeroMemory(@FileInfo, SizeOf(BITMAPINFOHEADER));
+
+ //Initialisieren der Daten des Headers
+ FileHeader.bfType := 19778; //$4D42 = 'BM'
+ FileHeader.bfOffBits := SizeOf(BITMAPINFOHEADER)+SizeOf(BITMAPFILEHEADER);
+
+ //Schreiben der Bitmap-Informationen
+ FileInfo.biSize := SizeOf(BITMAPINFOHEADER);
+ FileInfo.biWidth := ScreenH;
+ FileInfo.biHeight := ScreenW;
+ FileInfo.biPlanes := 1;
+ FileInfo.biBitCount := 32;
+ FileInfo.biSizeImage := FileInfo.biWidth*FileInfo.biHeight*(FileInfo.biBitCount div 8);
+
+ //Größenangabe auch in den Header übernehmen
+ FileHeader.bfSize := FileHeader.bfOffBits + FileInfo.biSizeImage;
+
+ //Speicher für die Bilddaten reservieren
+ GetMem(pPicData, FileInfo.biSizeImage);
+ try
+ //Bilddaten von OpenGL anfordern (siehe oben)
+ glReadPixels(0, 0, ScreenW, ScreenH, GL_BGRA, GL_UNSIGNED_BYTE, pPicData);
+
+ //Und den ganzen Müll in die Datei schieben ;-)
+ //Moderne Leute nehmen dafür auch Streams ...
+ AssignFile(f, Filename);
+ Rewrite( f,1 );
+ try
+ BlockWrite(F, FileHeader, SizeOf(BITMAPFILEHEADER));
+ BlockWrite(F, FileInfo, SizeOf(BITMAPINFOHEADER));
+ BlockWrite(F, pPicData^, FileInfo.biSizeImage );
+ finally
+ CloseFile(f);
+ end;
+ finally
+ //Und den angeforderten Speicher wieder freigeben ...
+ FreeMem(pPicData, FileInfo.biSizeImage);
+ end;
+end;
+
+
+end.
diff --git a/Game/Code/Menu/UDrawTexture.dcu b/Game/Code/Menu/UDrawTexture.dcu
new file mode 100644
index 00000000..9e6402a9
--- /dev/null
+++ b/Game/Code/Menu/UDrawTexture.dcu
Binary files differ
diff --git a/Game/Code/Menu/UDrawTexture.pas b/Game/Code/Menu/UDrawTexture.pas
new file mode 100644
index 00000000..5a543f33
--- /dev/null
+++ b/Game/Code/Menu/UDrawTexture.pas
@@ -0,0 +1,101 @@
+unit UDrawTexture;
+
+interface
+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 OpenGL12;
+
+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/UMenu.dcu b/Game/Code/Menu/UMenu.dcu
new file mode 100644
index 00000000..126834d8
--- /dev/null
+++ b/Game/Code/Menu/UMenu.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas
new file mode 100644
index 00000000..7c256b5c
--- /dev/null
+++ b/Game/Code/Menu/UMenu.pas
@@ -0,0 +1,1136 @@
+unit UMenu;
+
+interface
+
+uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide,
+ UMenuInteract, UThemes;
+
+type
+{ Int16 = SmallInt;}
+
+ PMenu = ^TMenu;
+ TMenu = class
+ protected
+ Interactions: array of TInteract;
+ SelInteraction: integer;
+ Static: array of TStatic;
+ Button: array of TButton;
+ Selects: array of TSelect;
+ SelectsS: array of TSelectSlide;
+ BackImg: TTexture;
+ BackW: integer;
+ BackH: integer;
+ public
+ Text: array of TText;
+ mX: integer; // mouse X
+ mY: integer; // mouse Y
+
+ Fade: integer; // fade type
+ ShowFinish: boolean; // true if there is no fade
+
+
+ destructor Destroy; override;
+ constructor Create; overload; virtual;
+ constructor Create(Back: string); overload; virtual; // Back is a JPG resource name for background
+ constructor Create(Back: string; W, H: integer); overload; virtual; // W and H are the number of overlaps
+
+ // interaction
+ procedure AddInteraction(Typ, Num: integer);
+ procedure SetInteraction(Num: integer);
+ property Interaction: integer read SelInteraction write SetInteraction;
+
+ // background
+ procedure AddBackground(Name: string);
+
+ // static
+ function AddStatic(ThemeStatic: TThemeStatic): integer; overload;
+ function AddStatic(X, Y, W, H: real; Name: string): integer; overload;
+ function AddStatic(X, Y, W, H: real; Name, Format, Typ: string): integer; overload;
+ function AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer; overload;
+ function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer; overload;
+ function AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer; overload;
+ function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer; overload;
+ function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; Name, Format, Typ: string; Color: integer): integer; overload;
+
+ // text
+ function AddText(ThemeText: TThemeText): integer; overload;
+ function AddText(X, Y: real; Tekst: string): integer; overload;
+ function AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; Tekst: string): integer; overload;
+ function AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): integer; overload;
+
+ // button
+ 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): integer; overload;
+ procedure ClearButtons;
+ procedure AddButtonText(AddX, AddY: real; AddText: string); overload;
+ procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; AddText: string); overload;
+ procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); overload;
+
+ // select
+ function AddSelect(ThemeSelect: TThemeSelect; var Data: integer; Values: array of string): integer; overload;
+ function AddSelect(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt,
+ TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt,
+ SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt,
+ STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real;
+ Name, Typ: String; SBGName, SBGTyp: String;
+ Caption: string; var Data: integer): integer; overload;
+ procedure AddSelectOption(AddX, AddY: real; AddText: string); overload;
+ procedure AddSelectOption(SelectNo: Cardinal; AddX, AddY: real; AddText: string); overload;
+ procedure UpdateSelectOptions(ThemeSelect: TThemeSelect; SelectNum: integer; Values: array of string; var Data: integer);
+
+ // select slide
+ function AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer; Values: array of string): integer; overload;
+ function AddSelectSlide(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt,
+ TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt,
+ SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt,
+ STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real;
+ Name, Typ: String; SBGName, SBGTyp: String;
+ Caption: string; var Data: integer): integer; overload;
+ procedure AddSelectSlideOption(AddText: string); overload;
+ procedure AddSelectSlideOption(SelectNo: Cardinal; AddText: string); overload;
+ procedure UpdateSelectSlideOptions(ThemeSelectSlide: TThemeSelectSlide; SelectNum: integer; Values: array of string; var Data: integer);
+
+
+// function AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16;
+// procedure ClearWidgets(MinNumber : Int16);
+ procedure FadeTo(Screen: PMenu);
+
+ function DrawBG: boolean; virtual;
+ function DrawFG: boolean; virtual;
+ function Draw: boolean; virtual;
+ function ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown : Boolean): Boolean; virtual;
+ function ParseMouse(Typ: integer; X: integer; Y: integer): Boolean; virtual; abstract;
+ function InRegion(X1, Y1, X2, Y2, X, Y: real): Boolean;
+ function InStaticRegion(StaticNr: integer; X, Y: integer): Boolean;
+ procedure onShow; virtual;
+ procedure onShowFinish; virtual;
+ procedure onHide; virtual;
+
+ procedure SetAnimationProgress(Progress: real); virtual;
+
+
+ procedure InteractNext; virtual;
+ procedure InteractCustom(CustomSwitch: integer); virtual;
+ procedure InteractPrev; virtual;
+ procedure InteractInc; virtual;
+ procedure InteractDec; virtual;
+
+ procedure AddBox(X, Y, W, H: real);
+ end;
+
+const
+ pmMove = 1;
+ pmClick = 2;
+ pmUnClick = 3;
+
+ iButton = 0; // interaction type
+ iSelect = 1;
+ iText = 2;
+ iSelectS = 3;
+
+// fBlack = 0; // fade type
+// fWhite = 1;
+
+implementation
+
+uses UMain, UDrawTexture, UGraphic, UDisplay, UCovers, USkins;
+
+destructor TMenu.Destroy;
+begin
+ inherited;
+end;
+
+constructor TMenu.Create;
+begin
+ Fade := 0;//fWhite;
+
+ SetLength(Static, 0);
+ SetLength(Button, 0);
+
+ BackImg.TexNum := -1;
+end;
+
+constructor TMenu.Create(Back: String);
+begin
+ inherited Create;
+
+ if Back <> '' then begin
+// BackImg := Texture.LoadTexture(true, PChar(Back), 'JPG', 'Plain', 0);
+ BackImg := Texture.LoadTexture(PChar(Back), 'JPG', 'Plain', 0); // new theme system
+ BackImg.W := 800;//640;
+ BackImg.H := 600;//480;
+ BackW := 1;
+ BackH := 1;
+ end else
+ BackImg.TexNum := -1;
+end;
+
+constructor TMenu.Create(Back: string; W, H: integer);
+begin
+ Create(Back);
+ BackImg.W := BackImg.W / W;
+ BackImg.H := BackImg.H / H;
+ BackW := W;
+ BackH := H;
+end;
+
+procedure TMenu.AddInteraction(Typ, Num: integer);
+var
+ IntNum: integer;
+begin
+ IntNum := Length(Interactions);
+ SetLength(Interactions, IntNum+1);
+ Interactions[IntNum].Typ := Typ;
+ Interactions[IntNum].Num := Num;
+ Interaction := 0;
+end;
+
+procedure TMenu.SetInteraction(Num: integer);
+var
+ OldNum, OldTyp: integer;
+ NewNum, NewTyp: integer;
+begin
+ // set inactive
+ OldNum := Interactions[Interaction].Num;
+ OldTyp := Interactions[Interaction].Typ;
+ case OldTyp of
+ iButton: Button[OldNum].Selected := False;
+ iSelect: Selects[OldNum].Selected := False;
+ iText: Text[OldNum].Selected := False;
+ iSelectS: SelectsS[OldNum].Selected := False;
+ end;
+
+ // set active
+ SelInteraction := Num;
+ NewNum := Interactions[Interaction].Num;
+ NewTyp := Interactions[Interaction].Typ;
+ case NewTyp of
+ iButton: Button[NewNum].Selected := True;
+ iSelect: Selects[NewNum].Selected := True;
+ iText: Text[NewNum].Selected := True;
+ iSelectS: SelectsS[NewNum].Selected := True;
+ end;
+end;
+
+procedure TMenu.AddBackground(Name: string);
+begin
+ if Name <> '' then begin
+// BackImg := Texture.LoadTexture(false, PChar(Skin.SkinPath + FileName), 'JPG', 'Plain', 0); // new theme system
+ BackImg := Texture.GetTexture(Skin.GetTextureFileName(Name), 'Plain');
+ BackImg.W := 800;
+ BackImg.H := 600;
+ BackW := 1;
+ BackH := 1;
+ end;
+end;
+
+function TMenu.AddStatic(ThemeStatic: TThemeStatic): integer;
+begin
+ Result := AddStatic(ThemeStatic.X, ThemeStatic.Y, ThemeStatic.W, ThemeStatic.H, ThemeStatic.Z,
+ ThemeStatic.ColR, ThemeStatic.ColG, ThemeStatic.ColB,
+ ThemeStatic.TexX1, ThemeStatic.TexY1, ThemeStatic.TexX2, ThemeStatic.TexY2,
+ {<0.5.1: Skin.SkinPath + ThemeStatic.Tex, 0.5.1:} Skin.GetTextureFileName(ThemeStatic.Tex),
+ 'JPG', ThemeStatic.Typ, $FFFFFF);
+ //'Font Black');
+end;
+
+function TMenu.AddStatic(X, Y, W, H: real; Name: string): integer;
+begin
+ Result := AddStatic(X, Y, W, H, Name, 'JPG', 'Plain');
+end;
+
+function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer;
+var
+ StatNum: integer;
+begin
+ Result := AddStatic(X, Y, W, H, ColR, ColG, ColB, Name, Format, Typ, $FFFFFF);
+end;
+
+function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string): integer;
+var
+ StatNum: integer;
+begin
+ Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, Name, Format, Typ, $FFFFFF);
+end;
+
+function TMenu.AddStatic(X, Y, W, H: real; Name, Format, Typ: string): integer;
+var
+ StatNum: integer;
+begin
+ // adds static
+ StatNum := Length(Static);
+ SetLength(Static, StatNum + 1);
+// Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), $FF00FF)); // $FFFFFF
+// Static[StatNum] := TStatic.Create(Texture.LoadTexture(Skin.SkinReg, PChar(Name), PChar(Format), PChar(Typ), $FF00FF)); // new skin system
+ Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), $FF00FF)); // new skin
+
+ // configures static
+ Static[StatNum].Texture.X := X;
+ Static[StatNum].Texture.Y := Y;
+ Static[StatNum].Texture.W := W;
+ Static[StatNum].Texture.H := H;
+ Static[StatNum].Visible := true;
+ Result := StatNum;
+end;
+
+function TMenu.AddStatic(X, Y, W, H: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer;
+var
+ StatNum: integer;
+begin
+ Result := AddStatic(X, Y, W, H, 0, ColR, ColG, ColB, Name, Format, Typ, Color);
+end;
+
+function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; Name, Format, Typ: string; Color: integer): integer;
+begin
+ Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, 0, 0, 1, 1, Name, Format, Typ, Color);
+//
+end;
+
+function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; Name, Format, Typ: string; Color: integer): integer;
+var
+ StatNum: integer;
+begin
+ // adds static
+ StatNum := Length(Static);
+ SetLength(Static, StatNum + 1);
+// Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), Color));
+// Static[StatNum] := TStatic.Create(Texture.LoadTexture(Skin.SkinReg, PChar(Name), PChar(Format), PChar(Typ), Color)); // new skin system
+Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), Color)); // new skin
+// Static[StatNum] := TStatic.Create(Texture.GetTexture(Name, Typ));
+
+ // configures static
+ Static[StatNum].Texture.X := X;
+ Static[StatNum].Texture.Y := Y;
+ Static[StatNum].Texture.W := W;
+ Static[StatNum].Texture.H := H;
+ Static[StatNum].Texture.Z := Z;
+ Static[StatNum].Texture.ColR := ColR;
+ Static[StatNum].Texture.ColG := ColG;
+ Static[StatNum].Texture.ColB := ColB;
+ Static[StatNum].Texture.TexX1 := TexX1;
+ Static[StatNum].Texture.TexY1 := TexY1;
+ Static[StatNum].Texture.TexX2 := TexX2;
+ Static[StatNum].Texture.TexY2 := TexY2;
+ Static[StatNum].Texture.Alpha := 1;
+ Static[StatNum].Visible := true;
+ Result := StatNum;
+end;
+
+function TMenu.AddText(ThemeText: TThemeText): integer;
+begin
+ Result := AddText(ThemeText.X, ThemeText.Y, ThemeText.Font, ThemeText.Size,
+ ThemeText.ColR, ThemeText.ColG, ThemeText.ColB, ThemeText.Align, ThemeText.Text);
+end;
+
+function TMenu.AddText(X, Y: real; Tekst: string): integer;
+var
+ TextNum: integer;
+begin
+ // adds text
+ TextNum := Length(Text);
+ SetLength(Text, TextNum + 1);
+ Text[TextNum] := TText.Create(X, Y, Tekst);
+ Result := TextNum;
+end;
+
+function TMenu.AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; Tekst: string): integer;
+begin
+ Result := AddText(X, Y, Style, Size, ColR, ColG, ColB, 0, Tekst);
+end;
+
+function TMenu.AddText(X, Y: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): integer;
+var
+ TextNum: integer;
+begin
+ // adds text
+ TextNum := Length(Text);
+ SetLength(Text, TextNum + 1);
+ Text[TextNum] := TText.Create(X, Y, Style, Size, ColR, ColG, ColB, Align, Tekst);
+ Result := TextNum;
+end;
+
+
+// Method to add a button in our TMenu. It returns the assigned ButtonNumber
+function TMenu.AddButton(ThemeButton: TThemeButton): integer;
+var
+ BT: integer;
+ BTLen: integer;
+ temp: integer;
+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,
+ ThemeButton.Tex, 'JPG', 'Font Black');}
+
+ 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);
+
+
+ BTLen := Length(ThemeButton.Text);
+ for BT := 0 to BTLen-1 do begin
+ AddButtonText(ThemeButton.Text[BT].X, ThemeButton.Text[BT].Y,
+ ThemeButton.Text[BT].ColR, ThemeButton.Text[BT].ColG, ThemeButton.Text[BT].ColB,
+ ThemeButton.Text[BT].Font, ThemeButton.Text[BT].Size, ThemeButton.Text[BT].Align,
+ ThemeButton.Text[BT].Text);
+ end;
+end;
+
+function TMenu.AddButton(X, Y, W, H: real; Name: String): integer;
+begin
+ Result := AddButton(X, Y, W, H, Name, 'JPG', 'Plain', False);
+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);
+end;
+
+function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean): integer;
+var
+ ButNum : integer;
+begin
+ // adds button
+ ButNum := Length(Button);
+ SetLength(Button, ButNum + 1);
+// Button[ButNum] := TButton.Create(Texture.GetTexture(Name, Typ));
+
+ // check here for cache
+// Texture.GetTexture(Name, Typ, false); // preloads textures and creates cahce mipmap when needed
+// if Covers.CoverExists(Name) then
+ Button[ButNum] := TButton.Create(Texture.GetTexture(Name, Typ, true)); // use cache texture
+// else
+// Button[ButNum] := TButton.Create(Texture.GetTexture(Name, Typ, false)); // don't use cache texture}
+
+ // configures button
+ Button[ButNum].Texture.X := X;
+ Button[ButNum].Texture.Y := Y;
+ Button[ButNum].Texture.W := W;
+ Button[ButNum].Texture.H := H;
+ Button[ButNum].SelectColR := ColR;
+ Button[ButNum].SelectColG := ColG;
+ Button[ButNum].SelectColB := ColB;
+ Button[ButNum].SelectInt := Int;
+ Button[ButNum].DeselectColR := DColR;
+ Button[ButNum].DeselectColG := DColG;
+ Button[ButNum].DeselectColB := DColB;
+ Button[ButNum].DeselectInt := DInt;
+ Button[ButNum].Texture.TexX1 := 0;
+ Button[ButNum].Texture.TexY1 := 0;
+ Button[ButNum].Texture.TexX2 := 1;
+ Button[ButNum].Texture.TexY2 := 1;
+ Button[ButNum].SetSelect(false);
+
+ Button[ButNum].Reflection := Reflection;
+
+ // adds interaction
+ AddInteraction(iButton, ButNum);
+ Interaction := 0;
+end;
+
+procedure TMenu.ClearButtons;
+begin
+ Setlength(Button, 0);
+end;
+
+// Method to draw our TMenu and all his child buttons
+function TMenu.DrawBG: boolean;
+var
+ PetX: integer;
+ PetY: integer;
+begin
+// glClearColor(1, 1, 1, 1);
+// glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity;
+ glOrtho(0, RenderW, RenderH, 0, -1, 100);
+ glMatrixMode(GL_MODELVIEW);
+
+ BackImg.ColR := 1;
+ BackImg.ColG := 1;
+ BackImg.ColB := 1;
+ BackImg.TexX1 := 0;
+ BackImg.TexY1 := 0;
+ BackImg.TexX2 := 1;
+ BackImg.TexY2 := 1;
+ if (BackImg.TexNum <> -1) then begin
+ // draw texture with overlapping
+ for PetY := 1 to BackH do
+ for PetX := 1 to BackW do begin
+ BackImg.X := (PetX-1)/BackW * 800; //640
+ BackImg.Y := (PetY-1)/BackH * 600; //480
+ DrawTexture(BackImg);
+ end; // for PetX
+ end; // if
+end;
+
+function TMenu.DrawFG: boolean;
+var
+ J: Integer;
+begin
+ // We don't forget about newly implemented static for nice skin ...
+ for J := 0 to Length(Static) - 1 do
+ Static[J].Draw;
+
+ // ... and slightly implemented menutext unit
+ for J := 0 to Length(Text) - 1 do
+ Text[J].Draw;
+
+ // Second, we draw all of our buttons
+ for J := 0 to Length(Button) - 1 do
+ Button[J].Draw;
+
+ // Third, we draw all of our selects
+ for J := 0 to Length(Selects) - 1 do
+ Selects[J].Draw(1);
+
+ for J := 0 to Length(SelectsS) - 1 do
+ SelectsS[J].Draw;
+
+ // Third, we draw all our widgets
+// for J := 0 to Length(WidgetsSrc) - 1 do
+// SDL_BlitSurface(WidgetsSrc[J], nil, ParentBackBuf, WidgetsRect[J]);
+ Result := True;
+end;
+
+function TMenu.Draw: boolean;
+begin
+ DrawBG;
+ DrawFG;
+ Result := True;
+end;
+
+{function TMenu.GetNextScreen(): PMenu;
+begin
+ Result := NextScreen;
+end;}
+
+{function TMenu.AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16;
+var
+ WidgetNum : Int16;
+
+begin
+ If (Assigned(WidgetSrc)) Then
+ begin
+ WidgetNum := Length(WidgetsSrc);
+
+ SetLength(WidgetsSrc, WidgetNum + 1);
+ SetLength(WidgetsRect, WidgetNum + 1);
+
+ WidgetsSrc[WidgetNum] := WidgetSrc;
+ WidgetsRect[WidgetNum] := new(PSDL_Rect);
+ WidgetsRect[WidgetNum]^.x := X;
+ WidgetsRect[WidgetNum]^.y := Y;
+ WidgetsRect[WidgetNum]^.w := WidgetSrc^.w;
+ WidgetsRect[WidgetNum]^.h := WidgetSrc^.h;
+
+ Result := WidgetNum;
+ end
+ else
+ Result := -1;
+end;}
+
+{procedure TMenu.ClearWidgets(MinNumber : Int16);
+var
+ J : Int16;
+begin
+ For J := MinNumber to (Length(WidgetsSrc) - 1) do
+ begin
+ SDL_FreeSurface(WidgetsSrc[J]);
+ dispose(WidgetsRect[J]);
+ end;
+
+ SetLength(WidgetsSrc, MinNumber);
+ SetLength(WidgetsRect, MinNumber);
+end;}
+
+procedure TMenu.InteractNext;
+var
+ Num: integer;
+ Typ: integer;
+ Again: boolean;
+begin
+ Again := true;
+
+ // change interaction as long as it's needed
+ while (Again = true) do begin
+ Num := (Interaction + 1) Mod Length(Interactions);
+ Interaction := Num;
+ Again := false; // reset, default to accept changing interaction
+
+
+ // checking newly interacted element
+ Num := Interactions[Interaction].Num;
+ Typ := Interactions[Interaction].Typ;
+ case Typ of
+ iButton:
+ begin
+ if Button[Num].Selectable = false then Again := True;
+ end;
+ end; // case
+ end; // while
+end;
+
+
+procedure TMenu.InteractPrev;
+var
+ Num: integer;
+ Typ: integer;
+ Again: boolean;
+begin
+ Again := true;
+
+ // change interaction as long as it's needed
+ while (Again = true) do begin
+ Num := SelInteraction - 1;
+ if Num = -1 then Num := High(Interactions);
+ Interaction := Num;
+ Again := false; // reset, default to accept changing interaction
+
+ // checking newly interacted element
+ Num := Interactions[Interaction].Num;
+ Typ := Interactions[Interaction].Typ;
+ case Typ of
+ iButton:
+ begin
+ if Button[Num].Selectable = false then Again := True;
+ end;
+ end; // case
+ end; // while
+
+end;
+
+
+procedure TMenu.InteractCustom(CustomSwitch: integer);
+var
+ Num: integer;
+ Typ: integer;
+ Again: boolean;
+begin
+ if num<0 then begin
+ CustomSwitch:= CustomSwitch*(-1);
+ Again := true;
+ // change interaction as long as it's needed
+ while (Again = true) do begin
+ Num := SelInteraction - CustomSwitch;
+ if Num = -1 then Num := High(Interactions);
+ Interaction := Num;
+ Again := false; // reset, default to accept changing interaction
+
+ // checking newly interacted element
+ Num := Interactions[Interaction].Num;
+ Typ := Interactions[Interaction].Typ;
+ case Typ of
+ iButton:
+ begin
+ if Button[Num].Selectable = false then Again := True;
+ end;
+ end; // case
+ end; // while
+ end
+ else if num>0 then begin
+ Again := true;
+ // change interaction as long as it's needed
+ while (Again = true) do begin
+ Num := (Interaction + CustomSwitch) Mod Length(Interactions);
+ Interaction := Num;
+ Again := false; // reset, default to accept changing interaction
+
+
+ // checking newly interacted element
+ Num := Interactions[Interaction].Num;
+ Typ := Interactions[Interaction].Typ;
+ case Typ of
+ iButton:
+ begin
+ if Button[Num].Selectable = false then Again := True;
+ end;
+ end; // case
+ end; // while
+ end
+end;
+
+
+procedure TMenu.FadeTo(Screen: PMenu);
+begin
+ Display.Fade := 0;
+ Display.NextScreen := Screen;
+end;
+
+procedure TMenu.AddButtonText(AddX, AddY: real; AddText: string);
+begin
+ AddButtonText(AddX, AddY, 1, 1, 1, AddText);
+end;
+
+procedure TMenu.AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; AddText: string);
+var
+ Il: integer;
+begin
+ with Button[High(Button)] do begin
+ Il := Length(Text);
+ SetLength(Text, Il+1);
+ Text[Il] := TText.Create(X + AddX, Y + AddY, AddText);
+ Text[Il].ColR := ColR;
+ Text[Il].ColG := ColG;
+ Text[Il].ColB := ColB;
+ Text[Il].Int := 1;//0.5;
+ end;
+end;
+
+procedure TMenu.AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string);
+var
+ Il: integer;
+begin
+ with Button[High(Button)] do begin
+ Il := Length(Text);
+ SetLength(Text, Il+1);
+ Text[Il] := TText.Create(X + AddX, Y + AddY, AddText);
+ Text[Il].ColR := ColR;
+ Text[Il].ColG := ColG;
+ Text[Il].ColB := ColB;
+ Text[Il].Int := 1;//0.5;
+ Text[Il].Style := Font;
+ Text[Il].Size := Size;
+ Text[Il].Align := Align;
+ end;
+end;
+
+function TMenu.AddSelect(ThemeSelect: TThemeSelect; var Data: integer; Values: array of string): integer;
+var
+ SO: integer;
+begin
+ Result := AddSelect(ThemeSelect.X, ThemeSelect.Y, ThemeSelect.W, ThemeSelect.H, ThemeSelect.SkipX,
+ ThemeSelect.ColR, ThemeSelect.ColG, ThemeSelect.ColB, ThemeSelect.Int,
+ ThemeSelect.DColR, ThemeSelect.DColG, ThemeSelect.DColB, ThemeSelect.DInt,
+ ThemeSelect.TColR, ThemeSelect.TColG, ThemeSelect.TColB, ThemeSelect.TInt,
+ ThemeSelect.TDColR, ThemeSelect.TDColG, ThemeSelect.TDColB, ThemeSelect.TDInt,
+ ThemeSelect.SBGColR, ThemeSelect.SBGColG, ThemeSelect.SBGColB, ThemeSelect.SBGInt,
+ ThemeSelect.SBGDColR, ThemeSelect.SBGDColG, ThemeSelect.SBGDColB, ThemeSelect.SBGDInt,
+ ThemeSelect.STColR, ThemeSelect.STColG, ThemeSelect.STColB, ThemeSelect.STInt,
+ ThemeSelect.STDColR, ThemeSelect.STDColG, ThemeSelect.STDColB, ThemeSelect.STDInt,
+ Skin.GetTextureFileName(ThemeSelect.Tex), 'Font Black',
+ Skin.GetTextureFileName(ThemeSelect.TexSBG), 'Font Black',
+ ThemeSelect.Text, Data);
+ for SO := 0 to High(Values) do
+ AddSelectOption(ThemeSelect.X + ThemeSelect.W + ThemeSelect.SkipX + SO * 100 + 20, ThemeSelect.Y + 20, Values[SO]);
+end;
+
+function TMenu.AddSelect(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt,
+ TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt,
+ SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt,
+ STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real;
+ Name, Typ: String; SBGName, SBGTyp: String;
+ Caption: string; var Data: integer): integer;
+var
+ S: integer;
+begin
+ S := Length(Selects);
+ SetLength(Selects, S + 1);
+ Selects[S] := TSelect.Create;
+
+ Selects[S].Texture := Texture.GetTexture(Name, Typ);
+ Selects[S].X := X;
+ Selects[S].Y := Y;
+ Selects[S].W := W;
+ Selects[S].H := H;
+ Selects[S].ColR := ColR;
+ Selects[S].ColG := ColG;
+ Selects[S].ColB := ColB;
+ Selects[S].Int := Int;
+ Selects[S].DColR := DColR;
+ Selects[S].DColG := DColG;
+ Selects[S].DColB := DColB;
+ Selects[S].DInt := DInt;
+
+ Selects[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp);
+ Selects[S].TextureSBG.X := X + W + SkipX;
+ Selects[S].TextureSBG.Y := Y;
+ Selects[S].TextureSBG.W := 450;
+ Selects[S].TextureSBG.H := H;
+ Selects[S].SBGColR := SBGColR;
+ Selects[S].SBGColG := SBGColG;
+ Selects[S].SBGColB := SBGColB;
+ Selects[S].SBGInt := SBGInt;
+ Selects[S].SBGDColR := SBGDColR;
+ Selects[S].SBGDColG := SBGDColG;
+ Selects[S].SBGDColB := SBGDColB;
+ Selects[S].SBGDInt := SBGDInt;
+
+ Selects[S].Text.X := X + 20;
+ Selects[S].Text.Y := Y + 20;
+ Selects[S].Text.Text := Caption;
+ Selects[S].Text.Size := 10;
+ Selects[S].Text.Visible := true;
+ Selects[S].TColR := TColR;
+ Selects[S].TColG := TColG;
+ Selects[S].TColB := TColB;
+ Selects[S].TInt := TInt;
+ Selects[S].TDColR := TDColR;
+ Selects[S].TDColG := TDColG;
+ Selects[S].TDColB := TDColB;
+ Selects[S].TDInt := TDInt;
+
+ Selects[S].STColR := STColR;
+ Selects[S].STColG := STColG;
+ Selects[S].STColB := STColB;
+ Selects[S].STInt := STInt;
+ Selects[S].STDColR := STDColR;
+ Selects[S].STDColG := STDColG;
+ Selects[S].STDColB := STDColB;
+ Selects[S].STDInt := STDInt;
+
+ // new
+ Selects[S].Texture.TexX1 := 0;
+ Selects[S].Texture.TexY1 := 0;
+ Selects[S].Texture.TexX2 := 1;
+ Selects[S].Texture.TexY2 := 1;
+ Selects[S].TextureSBG.TexX1 := 0;
+ Selects[S].TextureSBG.TexY1 := 0;
+ Selects[S].TextureSBG.TexX2 := 1;
+ Selects[S].TextureSBG.TexY2 := 1;
+
+ // Sets Data to copy the value of selectops to global value;
+ Selects[S].PData := @Data;
+
+ // Sets default value of selectopt from Data;
+ Selects[S].SelectedOption := Data;
+
+ // Disables default selection
+ Selects[S].SetSelect(false);
+
+ // adds interaction
+ AddInteraction(iSelect, S);
+end;
+
+procedure TMenu.AddSelectOption(AddX, AddY: real; AddText: string);
+begin
+ AddSelectOption (High(Selects), AddX, AddY, AddText);
+end;
+
+procedure TMenu.AddSelectOption(SelectNo: Cardinal; AddX, AddY: real; AddText: string);
+var
+ SO: integer;
+begin
+ SO := Length(Selects[SelectNo].TextOpt);
+ SetLength(Selects[SelectNo].TextOpt, SO + 1);
+
+ Selects[SelectNo].TextOpt[SO] := TText.Create;
+
+ Selects[SelectNo].TextOpt[SO].X := AddX;
+ Selects[SelectNo].TextOpt[SO].Y := AddY;
+ Selects[SelectNo].TextOpt[SO].Text := AddText;
+ Selects[SelectNo].TextOpt[SO].Size := 10;
+ Selects[SelectNo].TextOpt[SO].ColR := Selects[SelectNo].STDColR;
+ Selects[SelectNo].TextOpt[SO].ColG := Selects[SelectNo].STDColG;
+ Selects[SelectNo].TextOpt[SO].ColB := Selects[SelectNo].STDColB;
+ Selects[SelectNo].TextOpt[SO].Int := Selects[SelectNo].STDInt;
+ Selects[SelectNo].TextOpt[SO].Visible := true;
+
+ if SO = Selects[SelectNo].PData^ then Selects[SelectNo].SelectedOption := SO;
+end;
+
+procedure TMenu.UpdateSelectOptions(ThemeSelect: TThemeSelect; SelectNum: integer; Values: array of string; var Data: integer);
+var
+ SO: integer;
+begin
+ SetLength(Selects[SelectNum].TextOpt, 0);
+ for SO := 0 to High(Values) do
+ AddSelectOption(SelectNum, ThemeSelect.X + ThemeSelect.W + ThemeSelect.SkipX + SO * 100 + 20, ThemeSelect.Y + 20, Values[SO]);
+end;
+
+function TMenu.AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer; Values: array of string): integer;
+var
+ SO: integer;
+begin
+ Result := AddSelectSlide(ThemeSelectS.X, ThemeSelectS.Y, ThemeSelectS.W, ThemeSelectS.H, ThemeSelectS.SkipX,
+ ThemeSelectS.ColR, ThemeSelectS.ColG, ThemeSelectS.ColB, ThemeSelectS.Int,
+ ThemeSelectS.DColR, ThemeSelectS.DColG, ThemeSelectS.DColB, ThemeSelectS.DInt,
+ ThemeSelectS.TColR, ThemeSelectS.TColG, ThemeSelectS.TColB, ThemeSelectS.TInt,
+ ThemeSelectS.TDColR, ThemeSelectS.TDColG, ThemeSelectS.TDColB, ThemeSelectS.TDInt,
+ ThemeSelectS.SBGColR, ThemeSelectS.SBGColG, ThemeSelectS.SBGColB, ThemeSelectS.SBGInt,
+ ThemeSelectS.SBGDColR, ThemeSelectS.SBGDColG, ThemeSelectS.SBGDColB, ThemeSelectS.SBGDInt,
+ ThemeSelectS.STColR, ThemeSelectS.STColG, ThemeSelectS.STColB, ThemeSelectS.STInt,
+ ThemeSelectS.STDColR, ThemeSelectS.STDColG, ThemeSelectS.STDColB, ThemeSelectS.STDInt,
+ Skin.GetTextureFileName(ThemeSelectS.Tex), 'Font Black',
+ Skin.GetTextureFileName(ThemeSelectS.TexSBG), 'Font Black',
+ ThemeSelectS.Text, Data);
+ for SO := 0 to High(Values) do
+ AddSelectSlideOption(Values[SO]);
+
+ //Generate Lines
+ SelectsS[High(SelectsS)].GenLines;
+
+ SelectsS[High(SelectsS)].SelectedOption := SelectsS[High(SelectsS)].SelectOptInt; // refresh
+end;
+
+function TMenu.AddSelectSlide(X, Y, W, H, SkipX, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt,
+ TColR, TColG, TColB, TInt, TDColR, TDColG, TDColB, TDInt,
+ SBGColR, SBGColG, SBGColB, SBGInt, SBGDColR, SBGDColG, SBGDColB, SBGDInt,
+ STColR, STColG, STColB, STInt, STDColR, STDColG, STDColB, STDInt: real;
+ Name, Typ: String; SBGName, SBGTyp: String;
+ Caption: string; var Data: integer): integer;
+var
+ S: integer;
+ I: integer;
+begin
+ S := Length(SelectsS);
+ SetLength(SelectsS, S + 1);
+ SelectsS[S] := TSelectSlide.Create;
+
+ SelectsS[S].Texture := Texture.GetTexture(Name, Typ);
+ SelectsS[S].X := X;
+ SelectsS[S].Y := Y;
+ SelectsS[S].W := W;
+ SelectsS[S].H := H;
+ SelectsS[S].ColR := ColR;
+ SelectsS[S].ColG := ColG;
+ SelectsS[S].ColB := ColB;
+ SelectsS[S].Int := Int;
+ SelectsS[S].DColR := DColR;
+ SelectsS[S].DColG := DColG;
+ SelectsS[S].DColB := DColB;
+ SelectsS[S].DInt := DInt;
+
+ SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp);
+ SelectsS[S].TextureSBG.X := X + W + SkipX;
+ SelectsS[S].TextureSBG.Y := Y;
+ SelectsS[S].TextureSBG.W := 450;
+ SelectsS[S].TextureSBG.H := H;
+ SelectsS[S].SBGColR := SBGColR;
+ SelectsS[S].SBGColG := SBGColG;
+ SelectsS[S].SBGColB := SBGColB;
+ SelectsS[S].SBGInt := SBGInt;
+ SelectsS[S].SBGDColR := SBGDColR;
+ SelectsS[S].SBGDColG := SBGDColG;
+ SelectsS[S].SBGDColB := SBGDColB;
+ SelectsS[S].SBGDInt := SBGDInt;
+
+ SelectsS[S].Text.X := X + 20;
+ SelectsS[S].Text.Y := Y + 20;
+ SelectsS[S].Text.Text := Caption;
+ SelectsS[S].Text.Size := 10;
+ SelectsS[S].Text.Visible := true;
+ SelectsS[S].TColR := TColR;
+ SelectsS[S].TColG := TColG;
+ SelectsS[S].TColB := TColB;
+ SelectsS[S].TInt := TInt;
+ SelectsS[S].TDColR := TDColR;
+ SelectsS[S].TDColG := TDColG;
+ SelectsS[S].TDColB := TDColB;
+ SelectsS[S].TDInt := TDInt;
+
+ SelectsS[S].STColR := STColR;
+ SelectsS[S].STColG := STColG;
+ SelectsS[S].STColB := STColB;
+ SelectsS[S].STInt := STInt;
+ SelectsS[S].STDColR := STDColR;
+ SelectsS[S].STDColG := STDColG;
+ SelectsS[S].STDColB := STDColB;
+ SelectsS[S].STDInt := STDInt;
+
+ // new
+ SelectsS[S].Texture.TexX1 := 0;
+ SelectsS[S].Texture.TexY1 := 0;
+ SelectsS[S].Texture.TexX2 := 1;
+ SelectsS[S].Texture.TexY2 := 1;
+ SelectsS[S].TextureSBG.TexX1 := 0;
+ SelectsS[S].TextureSBG.TexY1 := 0;
+ SelectsS[S].TextureSBG.TexX2 := 1;
+ SelectsS[S].TextureSBG.TexY2 := 1;
+
+ // Sets Data to copy the value of selectops to global value;
+ SelectsS[S].PData := @Data;
+ // Configures Select options
+ {//SelectsS[S].TextOpt[0].Text := IntToStr(I+1);
+ SelectsS[S].TextOpt[0].Size := 10;
+ SelectsS[S].TextOpt[0].Align := 1;
+
+ SelectsS[S].TextOpt[0].ColR := SelectsS[S].STDColR;
+ SelectsS[S].TextOpt[0].ColG := SelectsS[S].STDColG;
+ SelectsS[S].TextOpt[0].ColB := SelectsS[S].STDColB;
+ SelectsS[S].TextOpt[0].Int := SelectsS[S].STDInt;
+ SelectsS[S].TextOpt[0].Visible := true; }
+
+ // Sets default value of selectopt from Data;
+ SelectsS[S].SelectedOption := Data;
+
+ // Disables default selection
+ SelectsS[S].SetSelect(false);
+
+ {// Configures 3 select options
+ for I := 0 to 2 do begin
+ SelectsS[S].TextOpt[I].X := SelectsS[S].TextureSBG.X + 20 + (50 + 20) + (150 - 20) * I;
+ SelectsS[S].TextOpt[I].Y := SelectsS[S].TextureSBG.Y + 20;
+ SelectsS[S].TextOpt[I].Text := IntToStr(I+1);
+ SelectsS[S].TextOpt[I].Size := 10;
+ SelectsS[S].TextOpt[I].Align := 1;
+
+
+ SelectsS[S].TextOpt[I].ColR := SelectsS[S].STDColR;
+ SelectsS[S].TextOpt[I].ColG := SelectsS[S].STDColG;
+ SelectsS[S].TextOpt[I].ColB := SelectsS[S].STDColB;
+ SelectsS[S].TextOpt[I].Int := SelectsS[S].STDInt;
+ SelectsS[S].TextOpt[I].Visible := true;
+ end;}
+
+
+ // adds interaction
+ AddInteraction(iSelectS, S);
+ Result := S;
+end;
+
+procedure TMenu.AddSelectSlideOption(AddText: string);
+begin
+ AddSelectSlideOption(High(SelectsS), AddText);
+end;
+
+procedure TMenu.AddSelectSlideOption(SelectNo: Cardinal; AddText: string);
+var
+ SO: integer;
+begin
+ SO := Length(SelectsS[SelectNo].TextOptT);
+
+ SetLength(SelectsS[SelectNo].TextOptT, SO + 1);
+ SelectsS[SelectNo].TextOptT[SO] := AddText;
+
+ //SelectsS[S].SelectedOption := SelectsS[S].SelectOptInt; // refresh
+
+ //if SO = Selects[S].PData^ then Selects[S].SelectedOption := SO;
+end;
+
+procedure TMenu.UpdateSelectSlideOptions(ThemeSelectSlide: TThemeSelectSlide; SelectNum: integer; Values: array of string; var Data: integer);
+var
+ SO: integer;
+begin
+ SetLength(SelectsS[SelectNum].TextOptT, 0);
+ for SO := 0 to High(Values) do
+ AddSelectSlideOption(SelectNum, Values[SO]);
+
+ SelectsS[SelectNum].GenLines;
+
+// SelectsS[SelectNum].SelectedOption := SelectsS[SelectNum].SelectOptInt; // refresh
+// SelectS[SelectNum].SetSelectOpt(Data);
+// SelectS[SelectNum].SelectedOption := 0;//Data;
+
+// Log.LogError(IntToStr(High(SelectsS[SelectNum].TextOptT)));
+// if 0 <= High(SelectsS[SelectNum].TextOptT) then
+
+ SelectsS[SelectNum].PData := @Data;
+ SelectsS[SelectNum].SelectedOption := Data;
+end;
+
+function TMenu.InRegion(X1, Y1, X2, Y2, X, Y: real): Boolean;
+begin
+ Result := false;
+ X1 := X1 * RenderW/640;
+ X2 := X2 * RenderW/640;
+ Y1 := Y1 * RenderH/480;
+ Y2 := Y2 * RenderH/480;
+ if (X >= X1) and (X <= X2) and (Y >= Y1) and (Y <= Y2) then
+ Result := true;
+end;
+
+function TMenu.InStaticRegion(StaticNr: integer; X, Y: integer): Boolean;
+begin
+ Result := InRegion(Static[StaticNr].Texture.X,
+ Static[StaticNr].Texture.Y,
+ Static[StaticNr].Texture.X + Static[StaticNr].Texture.W - 1,
+ Static[StaticNr].Texture.Y + Static[StaticNr].Texture.H - 1,
+ X, Y);
+end;
+
+procedure TMenu.InteractInc;
+var
+ Num: integer;
+ Value: integer;
+begin
+ case Interactions[Interaction].Typ of
+ iSelect: begin
+ Num := Interactions[Interaction].Num;
+ Value := Selects[Num].SelectedOption;
+ Value := (Value + 1) Mod (Length(Selects[Num].TextOpt));
+ Selects[Num].SelectedOption := Value;
+ end;
+ iSelectS: begin
+ Num := Interactions[Interaction].Num;
+ Value := SelectsS[Num].SelectedOption;
+// Value := (Value + 1) Mod (Length(SelectsS[Num].TextOptT));
+
+ // limit
+ Value := Value + 1;
+ if Value <= High(SelectsS[Num].TextOptT) then
+ SelectsS[Num].SelectedOption := Value;
+ end;
+ end;
+end;
+
+procedure TMenu.InteractDec;
+var
+ Num: integer;
+ Value: integer;
+begin
+ case Interactions[Interaction].Typ of
+ iSelect: begin
+ Num := Interactions[Interaction].Num;
+ Value := Selects[Num].SelectedOption;
+ Value := Value - 1;
+ if Value = -1 then
+ Value := High(Selects[Num].TextOpt);
+ Selects[Num].SelectedOption := Value;
+ end;
+ iSelectS: begin
+ Num := Interactions[Interaction].Num;
+ Value := SelectsS[Num].SelectedOption;
+ Value := Value - 1;
+// if Value = -1 then
+// Value := High(SelectsS[Num].TextOptT);
+
+ if Value >= 0 then
+ SelectsS[Num].SelectedOption := Value;
+ end;
+ end
+end;
+
+procedure TMenu.AddBox(X, Y, W, H: real);
+begin
+ AddStatic(X, Y, W, H, 0, 0, 0, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black');
+ AddStatic(X+2, Y+2, W-4, H-4, 1, 1, 1, Skin.GetTextureFileName('Bar'), 'JPG', 'Font Black');
+end;
+
+procedure TMenu.onShow;
+begin
+// nothing
+// beep;
+end;
+
+procedure TMenu.onShowFinish;
+begin
+// nothing
+// beep;
+end;
+
+procedure TMenu.onHide;
+begin
+// nothing
+// beep;
+end;
+
+function TMenu.ParseInput(PressedKey: Cardinal; ScanCode: byte; PressedDown: Boolean): Boolean;
+begin
+// nothing
+// Beep;
+ Result := true;
+end;
+
+procedure TMenu.SetAnimationProgress(Progress: real);
+begin
+// nothing
+//beep;
+end;
+
+end.
+
diff --git a/Game/Code/Menu/UMenuButton.dcu b/Game/Code/Menu/UMenuButton.dcu
new file mode 100644
index 00000000..b97d1670
--- /dev/null
+++ b/Game/Code/Menu/UMenuButton.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas
new file mode 100644
index 00000000..e42a5488
--- /dev/null
+++ b/Game/Code/Menu/UMenuButton.pas
@@ -0,0 +1,238 @@
+unit UMenuButton;
+
+interface
+uses TextGL, UTexture, OpenGL12, UMenuText;
+
+type
+ TButton = class
+ private
+ SelectBool: Boolean;
+ 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
+// 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;
+
+ Selectable: boolean;
+
+ SelectColR: real;
+ SelectColG: real;
+ SelectColB: real;
+ SelectInt: real;
+ SelectTInt: real;
+
+ DeselectColR: real;
+ DeselectColG: real;
+ DeselectColB: real;
+ DeselectInt: real;
+ DeselectTInt: real;
+
+ procedure SetY(Value: real);
+ procedure SetSelect(Value: Boolean);
+ property X: real read Texture.x write Texture.x;
+ property Y: real read Texture.y 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 Selected: Boolean read SelectBool write SetSelect;
+
+ procedure Draw;
+
+ constructor Create(Textura: TTexture); overload;
+ destructor Destroy; override;
+ end;
+
+implementation
+uses UDrawTexture, SysUtils;
+
+procedure TButton.SetY(Value: real);
+var
+ dY: real;
+ T: integer; // text
+begin
+ dY := Value - Texture.y;
+
+ Texture.y := Value;
+
+ for T := 0 to High(Text) do
+ Text[T].Y := Text[T].Y + dY;
+
+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;
+ 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;
+ 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;
+
+ // 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;
+
+
+end;
+
+// ***** Public methods ****** //
+
+procedure TButton.Draw;
+var
+ T: integer;
+begin
+ if Visible then begin
+ DrawTexture(Texture);
+
+ 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
+ with Texture do
+ begin
+ //Bind Tex and GL Attributes
+ 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);
+
+ //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+ 15, 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 + 15, 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 + 15, 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 + 15, z);
+ glEnd;
+ 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;
+ Texture.ColR := 0;
+ Texture.ColG := 0.5;
+ Texture.ColB := 0;
+ Texture.Int := 1;
+end;
+
+
+end.
diff --git a/Game/Code/Menu/UMenuInteract.dcu b/Game/Code/Menu/UMenuInteract.dcu
new file mode 100644
index 00000000..785be771
--- /dev/null
+++ b/Game/Code/Menu/UMenuInteract.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenuInteract.pas b/Game/Code/Menu/UMenuInteract.pas
new file mode 100644
index 00000000..3f2960b8
--- /dev/null
+++ b/Game/Code/Menu/UMenuInteract.pas
@@ -0,0 +1,14 @@
+unit UMenuInteract;
+
+interface
+
+type
+ TInteract = record // for moving thru menu
+ Typ: integer; // 0 - button, 1 - select
+ 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.dcu b/Game/Code/Menu/UMenuSelect.dcu
new file mode 100644
index 00000000..9d483c33
--- /dev/null
+++ b/Game/Code/Menu/UMenuSelect.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenuSelect.pas b/Game/Code/Menu/UMenuSelect.pas
new file mode 100644
index 00000000..f7bb871f
--- /dev/null
+++ b/Game/Code/Menu/UMenuSelect.pas
@@ -0,0 +1,198 @@
+unit UMenuSelect;
+
+interface
+uses TextGL, UTexture, OpenGL12, 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/UMenuSelectSlide.dcu b/Game/Code/Menu/UMenuSelectSlide.dcu
new file mode 100644
index 00000000..1475c1ac
--- /dev/null
+++ b/Game/Code/Menu/UMenuSelectSlide.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas
new file mode 100644
index 00000000..7850cdf6
--- /dev/null
+++ b/Game/Code/Menu/UMenuSelectSlide.pas
@@ -0,0 +1,335 @@
+unit UMenuSelectSlide;
+
+interface
+uses TextGL, UTexture, OpenGL12, UMenuText;
+
+type
+ PSelectSlide = ^TSelectSlide;
+ TSelectSlide = class
+ private
+ SelectBool: boolean;
+ public
+ // objects
+ Text: TText; // Main text describing option
+ TextOpt: array of TText; // 3 texts in the position of possible options
+ TextOptT: array of string; // array of names for possible options
+
+ Texture: TTexture; // Select Texture
+ TextureSBG: TTexture; // Background Selections Texture
+// TextureS: array of TTexture; // Selections Texture (not used)
+
+// TextureArrowL: TTexture; // Texture for left arrow (not used yet)
+// TextureArrowR: TTexture; // Texture for right arrow (not used yet)
+
+ SelectOptInt: integer;
+ PData: ^integer;
+
+ //For automatically Setting LineCount
+ Lines: Byte;
+
+ //Visibility
+ Visible: Boolean;
+
+ // 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 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;
+ constructor Create;
+
+ //Automatically Generate Lines (Texts)
+ procedure genLines;
+ end;
+
+implementation
+uses UDrawTexture, math, ULog, SysUtils;
+
+// ------------ Select
+constructor TSelectSlide.Create;
+begin
+ inherited Create;
+ Text := TText.Create;
+ SetLength(TextOpt, 1);
+ TextOpt[0] := TText.Create;
+
+ Visible := True;
+ {SetLength(TextOpt, 3);
+ TextOpt[0] := TText.Create;
+ TextOpt[1] := TText.Create;
+ TextOpt[2] := TText.Create;}
+end;
+
+procedure TSelectSlide.SetSelect(Value: boolean);
+var
+ SO: integer;
+ I: integer;
+begin
+ 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 I := 0 to High(TextOpt) do begin
+ TextOpt[I].ColR := STColR;
+ TextOpt[I].ColG := STColG;
+ TextOpt[I].ColB := STColB;
+ TextOpt[I].Int := STInt;
+ 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 I := 0 to High(TextOpt) do begin
+ TextOpt[I].ColR := STDColR;
+ TextOpt[I].ColG := STDColG;
+ TextOpt[I].ColB := STDColB;
+ TextOpt[I].Int := STDInt;
+ end;}
+ end;
+end;
+
+procedure TSelectSlide.SetSelectOpt(Value: integer);
+var
+ SO: integer;
+ Sel: integer;
+ HalfL: integer;
+ HalfR: integer;
+
+procedure DoSelection(Sel: Cardinal);
+ var I: Integer;
+ begin
+ for I := low(TextOpt) to high(TextOpt) do
+ begin
+ TextOpt[I].ColR := STDColR;
+ TextOpt[I].ColG := STDColG;
+ TextOpt[I].ColB := STDColB;
+ TextOpt[I].Int := STDInt;
+ end;
+ if (Sel <= high(TextOpt)) then
+ begin
+ TextOpt[Sel].ColR := STColR;
+ TextOpt[Sel].ColG := STColG;
+ TextOpt[Sel].ColB := STColB;
+ TextOpt[Sel].Int := STInt;
+ end;
+ end;
+begin
+ SelectOptInt := Value;
+ PData^ := Value;
+// SetSelect(true); // reset all colors
+
+ if (Length(TextOpt)>0) AND (Length(TextOptT)>0) then
+ begin
+
+ if (Value <= 0) then
+ begin //First Option Selected
+ Value := 0;
+
+ for SO := low (TextOpt) to high(TextOpt) do
+ begin
+ TextOpt[SO].Text := TextOptT[SO];
+ end;
+
+ DoSelection(0);
+ end
+ else if (Value >= high(TextOptT)) then
+ begin //Last Option Selected
+ Value := high(TextOptT);
+
+ for SO := high(TextOpt) downto low (TextOpt) do
+ begin
+ TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)];
+ end;
+ DoSelection(Lines-1);
+ end
+ else
+ begin
+ HalfL := Ceil((Lines-1)/2);
+ HalfR := Lines-1-HalfL;
+
+ if (Value <= HalfL) then
+ begin //Selected Option is near to the left side
+ {HalfL := Value;
+ HalfR := Lines-1-HalfL;}
+ //Change Texts
+ for SO := low (TextOpt) to high(TextOpt) do
+ begin
+ TextOpt[SO].Text := TextOptT[SO];
+ end;
+
+ DoSelection(Value);
+ end
+ else if (Value > High(TextOptT)-HalfR) then
+ begin //Selected is too near to the right border
+ HalfR := high(TextOptT) - Value;
+ HalfL := Lines-1-HalfR;
+ //Change Texts
+ for SO := high(TextOpt) downto low (TextOpt) do
+ begin
+ TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)];
+ end;
+
+ DoSelection (HalfL);
+ end
+ else
+ begin
+ //Change Texts
+ for SO := low (TextOpt) to high(TextOpt) do
+ begin
+ TextOpt[SO].Text := TextOptT[Value - HalfL + SO];
+ end;
+
+ DoSelection(HalfL);
+ end;
+
+ end;
+
+ end;
+
+end;
+
+procedure TSelectSlide.Draw;
+var
+ SO: integer;
+begin
+ if Visible then
+ begin
+ DrawTexture(Texture);
+ DrawTexture(TextureSBG);
+
+ Text.Draw;
+
+ for SO := low(TextOpt) to high(TextOpt) do
+ TextOpt[SO].Draw;
+ end;
+end;
+
+procedure TSelectSlide.GenLines;
+var
+maxlength: Real;
+I: Integer;
+begin
+ SetFontStyle(TextOpt[0].Style);
+ SetFontSize(TextOpt[0].Size);
+ maxlength := 0;
+
+ for I := low(TextOptT) to high (TextOptT) do
+ begin
+ if (glTextWidth(PChar(TextOptT[I])) > maxlength) then
+ maxlength := glTextWidth(PChar(TextOptT[I]));
+ end;
+
+ Lines := floor((TextureSBG.W-40) / (maxlength+7));
+ if (Lines > Length(TextOptT)) then
+ Lines := Length(TextOptT);
+
+ if (Lines <= 0) then
+ Lines := 1;
+
+ setLength (TextOpt, Lines);
+
+ for I := low(TextOpt) to high(TextOpt) do
+ begin
+
+ //TextOpt[I] := TextOpt[0];
+ TextOpt[I] := TText.Create;
+ TextOpt[I].Size := 10;
+ //TextOpt[I].Align := 1;
+ TextOpt[I].Align := 0;
+ TextOpt[I].Visible := True;
+
+ TextOpt[I].ColR := STDColR;
+ TextOpt[I].ColG := STDColG;
+ TextOpt[I].ColB := STDColB;
+ TextOpt[I].Int := STDInt;
+
+ //Generate Positions
+ //TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * (I + 0.5);
+ TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I;
+ TextOpt[I].Y := TextureSBG.Y + 20;
+
+ //Better Look with 2 Options
+ if (Lines=2) then
+ TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I;
+ end;
+ //TextOpt[I] := TextOpt[0];
+end;
+
+end.
diff --git a/Game/Code/Menu/UMenuStatic.dcu b/Game/Code/Menu/UMenuStatic.dcu
new file mode 100644
index 00000000..901fa2c7
--- /dev/null
+++ b/Game/Code/Menu/UMenuStatic.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas
new file mode 100644
index 00000000..4b10e54c
--- /dev/null
+++ b/Game/Code/Menu/UMenuStatic.pas
@@ -0,0 +1,32 @@
+unit UMenuStatic;
+
+interface
+uses UTexture, OpenGL12;
+
+type
+ TStatic = class
+ public
+ Texture: TTexture; // Button Screen position and size
+ Visible: boolean;
+ procedure Draw;
+ constructor Create(Textura: TTexture); overload;
+ end;
+
+implementation
+uses UDrawTexture;
+
+procedure TStatic.Draw;
+var
+ Pet: integer;
+begin
+ if Visible then
+ DrawTexture(Texture);
+end;
+
+constructor TStatic.Create(Textura: TTexture);
+begin
+ inherited Create;
+ Texture := Textura;
+end;
+
+end.
diff --git a/Game/Code/Menu/UMenuText.dcu b/Game/Code/Menu/UMenuText.dcu
new file mode 100644
index 00000000..7cfe0316
--- /dev/null
+++ b/Game/Code/Menu/UMenuText.dcu
Binary files differ
diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas
new file mode 100644
index 00000000..5c435a18
--- /dev/null
+++ b/Game/Code/Menu/UMenuText.pas
@@ -0,0 +1,96 @@
+unit UMenuText;
+
+interface
+uses TextGL, UTexture, OpenGL12, SysUtils;
+
+type
+ TText = class
+ private
+ SelectBool: boolean;
+ public
+ X: real;
+ Y: real;
+// W: real; // if text is wider than W then it is streched (not yet implemented)
+// H: real;
+ Size: real;
+ Text: string;
+ ColR: real;
+ ColG: real;
+ ColB: real;
+ Int: real;
+ Style: integer;
+ Visible: boolean;
+ Align: integer; // 0 = left, 1 = center, 2 = right
+
+ procedure SetSelect(Value: Boolean);
+ property Selected: Boolean read SelectBool write SetSelect;
+
+ procedure Draw;
+ constructor Create; overload;
+ constructor Create(X, Y: real; Tekst: string); overload;
+ constructor Create(ParX, ParY: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); overload;
+ end;
+
+implementation
+uses UGraphic;
+
+procedure TText.SetSelect(Value: Boolean);
+begin
+ SelectBool := Value;
+end;
+
+procedure TText.Draw;
+var
+ X2: real;
+ Text2: string;
+begin
+ if Visible then begin
+ SetFontStyle(Style);
+ SetFontSize(Size);
+ glColor3f(ColR*Int, ColG*Int, ColB*Int);
+ if not SelectBool then
+ Text2 := Text
+ else
+ Text2 := Text + '|';
+
+ case Align of
+ 0: X2 := X;
+ 1: X2 := X - glTextWidth(pchar(Text2))/2;
+ 2: X2 := X - glTextWidth(pchar(Text2));
+ end;
+
+ SetFontPos(X2, Y);
+ glPrint(PChar(Text2));
+ SetFontStyle(0); // reset to default
+ end;
+end;
+
+constructor TText.Create;
+begin
+ Create(0, 0, '');
+end;
+
+constructor TText.Create(X, Y: real; Tekst: string);
+begin
+ Create(X, Y, 0, 10, 0, 0, 0, 0, Tekst);
+end;
+
+constructor TText.Create(ParX, ParY: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string);
+begin
+ inherited Create;
+ X := ParX;
+ Y := ParY;
+ Style := ParStyle;
+ Size := ParSize;
+ Text := ParTekst;
+ ColR := ParColR;
+ ColG := ParColG;
+ ColB := ParColB;
+ Int := 1;
+ Align := ParAlign;
+ SelectBool := false;
+ Visible := true;
+end;
+
+
+end.