From 5ed6620bad808381fce94f2cd67ee911b4d45bff Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 21 Mar 2007 19:19:04 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.dcu | Bin 0 -> 7030 bytes Game/Code/Menu/UDisplay.pas | 289 +++++++++ Game/Code/Menu/UDrawTexture.dcu | Bin 0 -> 3640 bytes Game/Code/Menu/UDrawTexture.pas | 101 ++++ Game/Code/Menu/UMenu.dcu | Bin 0 -> 31672 bytes Game/Code/Menu/UMenu.pas | 1136 +++++++++++++++++++++++++++++++++++ Game/Code/Menu/UMenuButton.dcu | Bin 0 -> 5472 bytes Game/Code/Menu/UMenuButton.pas | 238 ++++++++ Game/Code/Menu/UMenuInteract.dcu | Bin 0 -> 404 bytes Game/Code/Menu/UMenuInteract.pas | 14 + Game/Code/Menu/UMenuSelect.dcu | Bin 0 -> 3922 bytes Game/Code/Menu/UMenuSelect.pas | 198 ++++++ Game/Code/Menu/UMenuSelectSlide.dcu | Bin 0 -> 6108 bytes Game/Code/Menu/UMenuSelectSlide.pas | 335 +++++++++++ Game/Code/Menu/UMenuStatic.dcu | Bin 0 -> 1594 bytes Game/Code/Menu/UMenuStatic.pas | 32 + Game/Code/Menu/UMenuText.dcu | Bin 0 -> 3155 bytes Game/Code/Menu/UMenuText.pas | 96 +++ 18 files changed, 2439 insertions(+) create mode 100644 Game/Code/Menu/UDisplay.dcu create mode 100644 Game/Code/Menu/UDisplay.pas create mode 100644 Game/Code/Menu/UDrawTexture.dcu create mode 100644 Game/Code/Menu/UDrawTexture.pas create mode 100644 Game/Code/Menu/UMenu.dcu create mode 100644 Game/Code/Menu/UMenu.pas create mode 100644 Game/Code/Menu/UMenuButton.dcu create mode 100644 Game/Code/Menu/UMenuButton.pas create mode 100644 Game/Code/Menu/UMenuInteract.dcu create mode 100644 Game/Code/Menu/UMenuInteract.pas create mode 100644 Game/Code/Menu/UMenuSelect.dcu create mode 100644 Game/Code/Menu/UMenuSelect.pas create mode 100644 Game/Code/Menu/UMenuSelectSlide.dcu create mode 100644 Game/Code/Menu/UMenuSelectSlide.pas create mode 100644 Game/Code/Menu/UMenuStatic.dcu create mode 100644 Game/Code/Menu/UMenuStatic.pas create mode 100644 Game/Code/Menu/UMenuText.dcu create mode 100644 Game/Code/Menu/UMenuText.pas (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.dcu b/Game/Code/Menu/UDisplay.dcu new file mode 100644 index 00000000..f4f89245 Binary files /dev/null and b/Game/Code/Menu/UDisplay.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UDrawTexture.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenu.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenuButton.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenuInteract.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenuSelect.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenuSelectSlide.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenuStatic.dcu 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 Binary files /dev/null and b/Game/Code/Menu/UMenuText.dcu 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. -- cgit v1.2.3 From 3f7e97009ad3a96dce1a51e98dc2b99aa8a78ef3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 21 Mar 2007 19:35:46 +0000 Subject: =?UTF-8?q?Datei=20/=20Ordner=20gel=C3=B6scht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@5 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.dcu | Bin 7030 -> 0 bytes Game/Code/Menu/UDrawTexture.dcu | Bin 3640 -> 0 bytes Game/Code/Menu/UMenu.dcu | Bin 31672 -> 0 bytes Game/Code/Menu/UMenuButton.dcu | Bin 5472 -> 0 bytes Game/Code/Menu/UMenuInteract.dcu | Bin 404 -> 0 bytes Game/Code/Menu/UMenuSelect.dcu | Bin 3922 -> 0 bytes Game/Code/Menu/UMenuSelectSlide.dcu | Bin 6108 -> 0 bytes Game/Code/Menu/UMenuStatic.dcu | Bin 1594 -> 0 bytes Game/Code/Menu/UMenuText.dcu | Bin 3155 -> 0 bytes 9 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Game/Code/Menu/UDisplay.dcu delete mode 100644 Game/Code/Menu/UDrawTexture.dcu delete mode 100644 Game/Code/Menu/UMenu.dcu delete mode 100644 Game/Code/Menu/UMenuButton.dcu delete mode 100644 Game/Code/Menu/UMenuInteract.dcu delete mode 100644 Game/Code/Menu/UMenuSelect.dcu delete mode 100644 Game/Code/Menu/UMenuSelectSlide.dcu delete mode 100644 Game/Code/Menu/UMenuStatic.dcu delete mode 100644 Game/Code/Menu/UMenuText.dcu (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.dcu b/Game/Code/Menu/UDisplay.dcu deleted file mode 100644 index f4f89245..00000000 Binary files a/Game/Code/Menu/UDisplay.dcu and /dev/null differ diff --git a/Game/Code/Menu/UDrawTexture.dcu b/Game/Code/Menu/UDrawTexture.dcu deleted file mode 100644 index 9e6402a9..00000000 Binary files a/Game/Code/Menu/UDrawTexture.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenu.dcu b/Game/Code/Menu/UMenu.dcu deleted file mode 100644 index 126834d8..00000000 Binary files a/Game/Code/Menu/UMenu.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenuButton.dcu b/Game/Code/Menu/UMenuButton.dcu deleted file mode 100644 index b97d1670..00000000 Binary files a/Game/Code/Menu/UMenuButton.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenuInteract.dcu b/Game/Code/Menu/UMenuInteract.dcu deleted file mode 100644 index 785be771..00000000 Binary files a/Game/Code/Menu/UMenuInteract.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenuSelect.dcu b/Game/Code/Menu/UMenuSelect.dcu deleted file mode 100644 index 9d483c33..00000000 Binary files a/Game/Code/Menu/UMenuSelect.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenuSelectSlide.dcu b/Game/Code/Menu/UMenuSelectSlide.dcu deleted file mode 100644 index 1475c1ac..00000000 Binary files a/Game/Code/Menu/UMenuSelectSlide.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenuStatic.dcu b/Game/Code/Menu/UMenuStatic.dcu deleted file mode 100644 index 901fa2c7..00000000 Binary files a/Game/Code/Menu/UMenuStatic.dcu and /dev/null differ diff --git a/Game/Code/Menu/UMenuText.dcu b/Game/Code/Menu/UMenuText.dcu deleted file mode 100644 index 7cfe0316..00000000 Binary files a/Game/Code/Menu/UMenuText.dcu and /dev/null differ -- cgit v1.2.3 From e0e16a3b1d28cf51fecf669d42465cf2a65728f3 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 29 Mar 2007 16:54:52 +0000 Subject: Added SBGW to TSelectSlide: Defining the Width of the Selections BG Added W to TText + Pagebreaks. If Width is given the Text breaks at the given width. Breaks are not generated perfect yet, needs some tuning. Changed all affected Screens to fit the new TText Component git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@49 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 20 ++--- Game/Code/Menu/UMenuSelectSlide.pas | 7 +- Game/Code/Menu/UMenuText.pas | 141 +++++++++++++++++++++++++++++++----- 3 files changed, 140 insertions(+), 28 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 7c256b5c..bf823b16 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -56,7 +56,7 @@ type 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; + function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): integer; overload; // button function AddButton(ThemeButton: TThemeButton): integer; overload; @@ -82,7 +82,7 @@ type // 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, + function AddSelectSlide(X, Y, W, H, SkipX, SBGW, 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; @@ -320,7 +320,7 @@ end; function TMenu.AddText(ThemeText: TThemeText): integer; begin - Result := AddText(ThemeText.X, ThemeText.Y, ThemeText.Font, ThemeText.Size, + Result := AddText(ThemeText.X, ThemeText.Y, ThemeText.W, ThemeText.Font, ThemeText.Size, ThemeText.ColR, ThemeText.ColG, ThemeText.ColB, ThemeText.Align, ThemeText.Text); end; @@ -337,17 +337,17 @@ 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); + Result := AddText(X, Y, 0, 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; +function TMenu.AddText(X, Y, W: 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); + Text[TextNum] := TText.Create(X, Y, W, Style, Size, ColR, ColG, ColB, Align, Tekst); Result := TextNum; end; @@ -846,7 +846,7 @@ function TMenu.AddSelectSlide(ThemeSelectS: TThemeSelectSlide; var Data: integer var SO: integer; begin - Result := AddSelectSlide(ThemeSelectS.X, ThemeSelectS.Y, ThemeSelectS.W, ThemeSelectS.H, ThemeSelectS.SkipX, + Result := AddSelectSlide(ThemeSelectS.X, ThemeSelectS.Y, ThemeSelectS.W, ThemeSelectS.H, ThemeSelectS.SkipX, ThemeSelectS.SBGW, ThemeSelectS.ColR, ThemeSelectS.ColG, ThemeSelectS.ColB, ThemeSelectS.Int, ThemeSelectS.DColR, ThemeSelectS.DColG, ThemeSelectS.DColB, ThemeSelectS.DInt, ThemeSelectS.TColR, ThemeSelectS.TColG, ThemeSelectS.TColB, ThemeSelectS.TInt, @@ -867,7 +867,7 @@ begin 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, +function TMenu.AddSelectSlide(X, Y, W, H, SkipX, SBGW, 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; @@ -886,6 +886,7 @@ begin SelectsS[S].Y := Y; SelectsS[S].W := W; SelectsS[S].H := H; + SelectsS[S].ColR := ColR; SelectsS[S].ColG := ColG; SelectsS[S].ColB := ColB; @@ -898,7 +899,8 @@ begin 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.W := 450; + SelectsS[S].SBGW := SBGW; SelectsS[S].TextureSBG.H := H; SelectsS[S].SBGColR := SBGColR; SelectsS[S].SBGColG := SBGColG; diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index 7850cdf6..9885acc0 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -81,6 +81,8 @@ type // property W2: real read Texture2.w write Texture2.w; // property H2: real read Texture2.h write Texture2.h; + property SBGW: real read TextureSBG.w write TextureSBG.w; + // procedures procedure SetSelect(Value: boolean); property Selected: Boolean read SelectBool write SetSelect; @@ -104,6 +106,9 @@ begin SetLength(TextOpt, 1); TextOpt[0] := TText.Create; + //Set Standard Width for Selections Background + SBGW := 450; + Visible := True; {SetLength(TextOpt, 3); TextOpt[0] := TText.Create; @@ -326,7 +331,7 @@ begin TextOpt[I].Y := TextureSBG.Y + 20; //Better Look with 2 Options - if (Lines=2) then + if (Lines=2) AND (Length(TextOptT)= 2) then TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I; end; //TextOpt[I] := TextOpt[0]; diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 5c435a18..4a5356d8 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -7,13 +7,14 @@ type TText = class private SelectBool: boolean; + TextString: String; + TextTiles: Array of String; public X: real; Y: real; -// W: real; // if text is wider than W then it is streched (not yet implemented) + W: real; // if text is wider than W then it is breaked // H: real; Size: real; - Text: string; ColR: real; ColG: real; ColB: real; @@ -25,43 +26,146 @@ type procedure SetSelect(Value: Boolean); property Selected: Boolean read SelectBool write SetSelect; + procedure SetText(Value: String); + property Text: String read TextString write SetText; + + procedure DeleteLastL; //Procedure to Delete Last Letter + 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; + constructor Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); overload; end; implementation -uses UGraphic; +uses UGraphic, StrUtils; procedure TText.SetSelect(Value: Boolean); begin SelectBool := Value; end; +procedure TText.SetText(Value: String); +var + I: Integer; + L: Integer; + LastPos: Integer; + LastBreak: Integer; +begin + TextString := Value; + + if (W > 0) then + begin + //Set Font Propertys + SetFontStyle(Style); + SetFontSize(Size); + + //Create New TextTiles Array + SetLength (TextTiles, 0); + L := 0; + + LastPos := 1; + LastBreak := 0; + I := Pos (' ', Value); + While (I <> 0) do + begin + if (glTextWidth(PChar(Copy (Value,LastBreak + 1,I))) > W) AND (LastPos <> 1) then + begin + //new Break + SetLength (TextTiles, L+1); + TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); + + Inc(L); + LastBreak := LastPos; + end; + + LastPos := I; + I := PosEx (' ', Value, I+1); + end; + + //Last Break + if (glTextWidth(PChar(Copy (Value,LastBreak + 1,Length(Value) - LastBreak))) > W) AND (LastPos <> 1) then + begin + //new Break + SetLength (TextTiles, L+1); + TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); + + Inc(L); + LastBreak := LastPos; + end; + + //last Part + SetLength (TextTiles, L+1); + TextTiles[L] := Copy (Value, LastBreak + 1, Length(Value) - LastBreak); + + end; +end; + +Procedure TText.DeleteLastL; +var + S: String; + L: Integer; +begin + S := TextString; + L := Length(S); + if (L > 0) then + SetLength(S, L-1); + + SetText(S); +end; + procedure TText.Draw; var - X2: real; + X2, Y2: real; Text2: string; + I: Integer; begin if Visible then begin SetFontStyle(Style); SetFontSize(Size); + SetFontItalic(False); glColor3f(ColR*Int, ColG*Int, ColB*Int); - if not SelectBool then - Text2 := Text + if (W <= 0) then //No Width set Draw as one Long String + begin + 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 else - Text2 := Text + '|'; + begin //Draw Text as Many Strings + Y2 := Y; + for I := 0 to high(TextTiles) do + begin + if (not SelectBool) OR (I <> high(TextTiles)) then + Text2 := TextTiles[I] + else + Text2 := TextTiles[I] + '|'; - case Align of - 0: X2 := X; - 1: X2 := X - glTextWidth(pchar(Text2))/2; - 2: X2 := X - glTextWidth(pchar(Text2)); - end; + 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 + SetFontPos(X2, Y2); + glPrint(PChar(Text2)); + + Y2 := Y2 + Size * 1.7; + end; + SetFontStyle(0); // reset to default + + end; end; end; @@ -72,14 +176,15 @@ end; constructor TText.Create(X, Y: real; Tekst: string); begin - Create(X, Y, 0, 10, 0, 0, 0, 0, Tekst); + Create(X, Y, 0, 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); +constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); begin inherited Create; X := ParX; Y := ParY; + W := ParW; Style := ParStyle; Size := ParSize; Text := ParTekst; -- cgit v1.2.3 From eb7df4c30c7e119ad56eb3ba8506ff3e3afce4a4 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 30 Mar 2007 19:18:27 +0000 Subject: Added Cursor Blink to TText git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@56 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 4a5356d8..4b8ea391 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -9,6 +9,9 @@ type SelectBool: boolean; TextString: String; TextTiles: Array of String; + + STicks: Cardinal; + SelectBlink: Boolean; public X: real; Y: real; @@ -38,11 +41,15 @@ type end; implementation -uses UGraphic, StrUtils; +uses UGraphic, StrUtils, Windows; procedure TText.SetSelect(Value: Boolean); begin SelectBool := Value; + + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; end; procedure TText.SetText(Value: String); @@ -99,6 +106,10 @@ begin TextTiles[L] := Copy (Value, LastBreak + 1, Length(Value) - LastBreak); end; + + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; end; Procedure TText.DeleteLastL; @@ -125,9 +136,21 @@ begin SetFontSize(Size); SetFontItalic(False); glColor3f(ColR*Int, ColG*Int, ColB*Int); + + //If Selected Set Blink... + if SelectBool then + begin + I := Gettickcount div 550; + if I <> STicks then + begin //Change Visability + STicks := I; + SelectBlink := Not SelectBlink; + end; + end; + if (W <= 0) then //No Width set Draw as one Long String begin - if not SelectBool then + if not (SelectBool AND SelectBlink) then Text2 := Text else Text2 := Text + '|'; @@ -147,7 +170,7 @@ begin Y2 := Y; for I := 0 to high(TextTiles) do begin - if (not SelectBool) OR (I <> high(TextTiles)) then + if (not (SelectBool AND SelectBlink)) OR (I <> high(TextTiles)) then Text2 := TextTiles[I] else Text2 := TextTiles[I] + '|'; -- cgit v1.2.3 From 5c46c303e25f84e49e36918bafc8d7eca09a507b Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 5 Apr 2007 13:43:20 +0000 Subject: Fixed: Button.Z Attribut not loaded from Theme Fixed: AddButton procedure don't set Result git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@58 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 54 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index bf823b16..45a25cb7 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -369,6 +369,8 @@ begin ThemeButton.DColR, ThemeButton.DColG, ThemeButton.DColB, ThemeButton.DInt, Skin.GetTextureFileName(ThemeButton.Tex), 'JPG', ThemeButton.Typ, ThemeButton.Reflection); + Button[Result].Z := ThemeButton.Z; + BTLen := Length(ThemeButton.Text); for BT := 0 to BTLen-1 do begin @@ -390,44 +392,42 @@ begin 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)); + Result := Length(Button); + SetLength(Button, Result + 1); +// Button[Result] := 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 + Button[Result] := 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} +// Button[Result] := 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; + Button[Result].Texture.X := X; + Button[Result].Texture.Y := Y; + Button[Result].Texture.W := W; + Button[Result].Texture.H := H; + Button[Result].SelectColR := ColR; + Button[Result].SelectColG := ColG; + Button[Result].SelectColB := ColB; + Button[Result].SelectInt := Int; + Button[Result].DeselectColR := DColR; + Button[Result].DeselectColG := DColG; + Button[Result].DeselectColB := DColB; + Button[Result].DeselectInt := DInt; + Button[Result].Texture.TexX1 := 0; + Button[Result].Texture.TexY1 := 0; + Button[Result].Texture.TexX2 := 1; + Button[Result].Texture.TexY2 := 1; + Button[Result].SetSelect(false); + + Button[Result].Reflection := Reflection; // adds interaction - AddInteraction(iButton, ButNum); + AddInteraction(iButton, Result); Interaction := 0; end; -- cgit v1.2.3 From e6917faa19aebfa6d089b24c65e4c7fe4bd6b503 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 13 Apr 2007 11:25:13 +0000 Subject: Added Reflection to ThemeStatic Added Attribut ReflectionSpacing git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@83 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 24 +++++++++++++-------- Game/Code/Menu/UMenuButton.pas | 9 ++++---- Game/Code/Menu/UMenuStatic.pas | 47 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 13 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 45a25cb7..7908d980 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -13,7 +13,6 @@ type protected Interactions: array of TInteract; SelInteraction: integer; - Static: array of TStatic; Button: array of TButton; Selects: array of TSelect; SelectsS: array of TSelectSlide; @@ -22,6 +21,7 @@ type BackH: integer; public Text: array of TText; + Static: array of TStatic; mX: integer; // mouse X mY: integer; // mouse Y @@ -50,7 +50,7 @@ type 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; + function AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; Name, Format, Typ: string; Color: integer; Reflection: Boolean; ReflectionSpacing: Real): integer; overload; // text function AddText(ThemeText: TThemeText): integer; overload; @@ -62,7 +62,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): 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; procedure ClearButtons; procedure AddButtonText(AddX, AddY: real; AddText: string); overload; procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; AddText: string); overload; @@ -232,7 +232,7 @@ begin 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); + 'JPG', ThemeStatic.Typ, $FFFFFF, ThemeStatic.Reflection, ThemeStatic.Reflectionspacing); //'Font Black'); end; @@ -284,11 +284,11 @@ 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); + Result := AddStatic(X, Y, W, H, Z, ColR, ColG, ColB, 0, 0, 1, 1, Name, Format, Typ, Color, False, 0); // 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; +function TMenu.AddStatic(X, Y, W, H, Z: real; ColR, ColG, ColB: real; TexX1, TexY1, TexX2, TexY2: real; Name, Format, Typ: string; Color: integer; Reflection: Boolean; ReflectionSpacing: Real): integer; var StatNum: integer; begin @@ -315,6 +315,11 @@ Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format) Static[StatNum].Texture.TexY2 := TexY2; Static[StatNum].Texture.Alpha := 1; Static[StatNum].Visible := true; + + //ReflectionMod + Static[StatNum].Reflection := Reflection; + Static[StatNum].ReflectionSpacing := ReflectionSpacing; + Result := StatNum; end; @@ -367,7 +372,7 @@ 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); + Skin.GetTextureFileName(ThemeButton.Tex), 'JPG', ThemeButton.Typ, ThemeButton.Reflection, ThemeButton.Reflectionspacing); Button[Result].Z := ThemeButton.Z; @@ -388,10 +393,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); + Result := AddButton(X, Y, W, H, 1, 1, 1, 1, 1, 1, 1, 0.5, Name, 'JPG', 'Plain', Reflection, 15); end; -function TMenu.AddButton(X, Y, W, H, ColR, ColG, ColB, Int, DColR, DColG, DColB, DInt: real; Name, Format, Typ: String; Reflection: Boolean): integer; +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; begin // adds button Result := Length(Button); @@ -425,6 +430,7 @@ begin Button[Result].SetSelect(false); Button[Result].Reflection := Reflection; + Button[Result].Reflectionspacing := ReflectionSpacing; // adds interaction AddInteraction(iButton, Result); diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index e42a5488..f4f8e1a8 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -19,6 +19,7 @@ type Visible: boolean; //Reflection Mod Reflection: boolean; + Reflectionspacing: Real; Selectable: boolean; @@ -190,23 +191,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+ 15, z); + glVertex3f(x, y+h*scaleH+ Reflectionspacing, 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); + glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, 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); + glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Top Right glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); glTexCoord2f(TexX2*TexW, TexY2*TexH); - glVertex3f(x+w*scaleW, y+h*scaleH + 15, z); + glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z); glEnd; end; end; diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas index 4b10e54c..c19e6abc 100644 --- a/Game/Code/Menu/UMenuStatic.pas +++ b/Game/Code/Menu/UMenuStatic.pas @@ -8,6 +8,11 @@ type public Texture: TTexture; // Button Screen position and size Visible: boolean; + + //Reflection Mod + Reflection: boolean; + Reflectionspacing: Real; + procedure Draw; constructor Create(Textura: TTexture); overload; end; @@ -21,6 +26,48 @@ var begin if Visible then DrawTexture(Texture); + + //Reflection Mod + if (Reflection) then // Draw Reflections + begin + with Texture do + begin + //Bind Tex and GL Attributes + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); + //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+ Reflectionspacing, 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); + + + //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); + + //Top Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX2*TexW, TexY2*TexH); + glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z); + glEnd; + end; + end; + end; constructor TStatic.Create(Textura: TTexture); -- cgit v1.2.3 From b8722c611ffaabde301f3134c1c8d76e64e3b02f Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 13 Apr 2007 12:10:49 +0000 Subject: Fixed Bug in Reflection Code that Causes wrong Depth Test when drawing Text git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@84 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuButton.pas | 8 ++++++-- Game/Code/Menu/UMenuStatic.pas | 15 ++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index f4f8e1a8..3a871c5f 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -179,12 +179,12 @@ 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 @@ -209,6 +209,10 @@ begin glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z); glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); end; end; diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas index c19e6abc..2a5e1e93 100644 --- a/Game/Code/Menu/UMenuStatic.pas +++ b/Game/Code/Menu/UMenuStatic.pas @@ -25,6 +25,7 @@ var Pet: integer; begin if Visible then + begin DrawTexture(Texture); //Reflection Mod @@ -35,12 +36,12 @@ 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 @@ -51,13 +52,13 @@ begin //Bottom Left glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX1*TexW, {TexY1*TexH*}0.5); + glTexCoord2f(TexX1*TexW, 0.5); glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Bottom Right glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX2*TexW, {TexY1*TexH*}0.5); + glTexCoord2f(TexX2*TexW, 0.5); glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Top Right @@ -65,9 +66,13 @@ begin glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x+w*scaleW, y+h*scaleH + Reflectionspacing, z); glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); end; end; - + end; end; constructor TStatic.Create(Textura: TTexture); -- cgit v1.2.3 From b1e40ba133782a3d36ec78d4cf9c0245b88448d1 Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 13 Apr 2007 22:17:48 +0000 Subject: implemented fading between screens (needs to be tested), minor tweaking of perfect-line effect position, added myself to credits ;) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@86 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 209 ++++++++++++++++++-------------------------- 1 file changed, 86 insertions(+), 123 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 6d0443cc..d7439dc9 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,7 +2,7 @@ unit UDisplay; interface -uses Windows, SDL, UMenu, OpenGL12, SysUtils; +uses Windows, SDL, UMenu, OpenGL12, SysUtils, dialogs; type TDisplay = class @@ -12,13 +12,19 @@ type h_DC: HDC; h_RC: HGLRC; -// FadeType: integer; - FadeTex: glUInt; - LastFade: real; - Fade: real; + Fade: Real; + // fade-mod + myfade: integer; + pTexData : Pointer; + pTex : glUInt; + // end + function Draw: Boolean; procedure PrintScreen; constructor Create; + // fade mod + destructor Destroy; + // end procedure ScreenShot; end; @@ -34,23 +40,42 @@ uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture; constructor TDisplay.Create; begin inherited Create; -// FadeType := 0; - Fade := 0; + // fade mod + myfade:=0; + // generate texture for fading between screens + GetMem(pTexData, 1024*1024*4); + glGenTextures(1, pTex); + glBindTexture(GL_TEXTURE_2D, pTex); + + glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + FreeMem(pTexData); + // end +end; + +// fade mod +destructor TDisplay.Destroy; +begin + glDeleteTextures(1,@pTex); + inherited Destroy; end; +// end function TDisplay.Draw: Boolean; var S: integer; - Col: real; - Surface: PSDL_Surface; + // fade mod + myfade2:integer; + // end begin Result := True; - Col := 1; +{ Col := 1; if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then - Col := 0; + Col := 0;} - glClearColor(Col, Col, Col , 1); + glClearColor(0, 0, 0 , 0); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); for S := 1 to Screens do begin @@ -62,125 +87,63 @@ begin ScreenX := 0; - if S = 2 then TimeSkip := 0; // it's easier than rewriting code + if S = 2 then TimeSkip := 0 else; // 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 +// ActualScreen.SetAnimationProgress(1); + if not assigned (NextScreen) then begin + Result := ActualScreen.Draw; + // fade mod + myfade:=0; + // end + end 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 + // fade mod + //Create Fading texture if we're just starting + if myfade = 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 + glBindTexture(GL_TEXTURE_2D, pTex); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1024, 1024, 0); + NextScreen.onShow; 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; +// LastFade := Fade; // whatever +// Fade := Fade -0.999; // start fading out + myfade:=myfade+1; + +// ActualScreen.ShowFinish := false; // no purpose? + +// ActualScreen.SetAnimationProgress(Fade-1); // nop? + + NextScreen.Draw; // draw next screen + + // and draw old screen over it... slowly fading out + myfade2:=myfade*myfade; + glBindTexture(GL_TEXTURE_2D, pTex); + glColor4f(1, 1, 1, (1000-myfade2)/1000); // strange calculation - alpha gets negative... but looks good this way + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + glTexCoord2f(0,0);glVertex2f(0-myfade2, 600+myfade2); + glTexCoord2f(0,ScreenH/1024);glVertex2f(0-myfade2, 0-myfade2); + glTexCoord2f(ScreenW/1024,ScreenH/1024);glVertex2f(800+myfade2, 0-myfade2); + glTexCoord2f(ScreenW/1024,0);glVertex2f(800+myfade2, 600+myfade2); + glEnd; + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; + + if myfade > 50 then begin // fade out complete... + myfade:=0; + ActualScreen.onHide; // nop... whatever + ActualScreen.ShowFinish:=False; + ActualScreen:=NextScreen; NextScreen := nil; - ActualScreen.onShowFinish; - ActualScreen.ShowFinish := true; - end; + ActualScreen.onShowFinish; // one more nop... + ActualScreen.ShowFinish := true; // who wrote this crap? + // end of fade mod end; // if end; // for // SwapBuffers(h_DC); -- cgit v1.2.3 From b627232ec93e4cb32790ddf30e3d27e7a2775cbb Mon Sep 17 00:00:00 2001 From: b1indy Date: Sat, 14 Apr 2007 14:30:37 +0000 Subject: added some error checking to screen-fade-effect, restored proper order of credits git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@88 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 114 ++++++++++++++++++++++++++++---------------- 1 file changed, 73 insertions(+), 41 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index d7439dc9..876fb6b6 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -14,7 +14,9 @@ type Fade: Real; // fade-mod - myfade: integer; + doFade: Boolean; + myFade: integer; + lastTime: Cardinal; pTexData : Pointer; pTex : glUInt; // end @@ -42,22 +44,36 @@ begin inherited Create; // fade mod myfade:=0; + doFade:=True; // generate texture for fading between screens GetMem(pTexData, 1024*1024*4); - glGenTextures(1, pTex); - glBindTexture(GL_TEXTURE_2D, pTex); - - glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - FreeMem(pTexData); + if pTexData <> NIL then + begin + glGenTextures(1, pTex); + if glGetError <> GL_NO_ERROR then doFade := False; + glBindTexture(GL_TEXTURE_2D, pTex); + if glGetError <> GL_NO_ERROR then doFade := False; + glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); + if glGetError <> GL_NO_ERROR then doFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if glGetError <> GL_NO_ERROR then doFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + if glGetError <> GL_NO_ERROR then doFade := False; + FreeMem(pTexData); + end + else + begin + doFade:=False; + end; + if not doFade then showmessage('Fehler beim Initialisieren der Fading-Textur... Fading deaktiviert'); // end end; // fade mod destructor TDisplay.Destroy; begin - glDeleteTextures(1,@pTex); + if doFade then + glDeleteTextures(1,@pTex); inherited Destroy; end; // end @@ -66,7 +82,8 @@ function TDisplay.Draw: Boolean; var S: integer; // fade mod - myfade2:integer; + myFade2:integer; + currentTime: Cardinal; // end begin Result := True; @@ -97,53 +114,68 @@ begin myfade:=0; // end end - else begin - // fade mod - //Create Fading texture if we're just starting - if myfade = 0 then + else + begin + if doFade then begin - ActualScreen.Draw; - glBindTexture(GL_TEXTURE_2D, pTex); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1024, 1024, 0); - NextScreen.onShow; - end; - + // fade mod + //Create Fading texture if we're just starting + if myfade = 0 then + begin + ActualScreen.Draw; + glBindTexture(GL_TEXTURE_2D, pTex); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1024, 1024, 0); + if glGetError <> GL_NO_ERROR then + begin + doFade := False; + showmessage('Fehler beim Kopieren der Fade-Textur... Fading deaktiviert'); + end; + NextScreen.onShow; + lastTime:=GetTickCount; + myfade:=myfade+1; + end; + currentTime:=GetTickCount; + if currentTime > lastTime+30 then + begin + myfade:=myfade+4; + lastTime:=currentTime; + end; // LastFade := Fade; // whatever // Fade := Fade -0.999; // start fading out - myfade:=myfade+1; + // ActualScreen.ShowFinish := false; // no purpose? // ActualScreen.SetAnimationProgress(Fade-1); // nop? - NextScreen.Draw; // draw next screen + NextScreen.Draw; // draw next screen // and draw old screen over it... slowly fading out - myfade2:=myfade*myfade; - glBindTexture(GL_TEXTURE_2D, pTex); - glColor4f(1, 1, 1, (1000-myfade2)/1000); // strange calculation - alpha gets negative... but looks good this way - glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glBegin(GL_QUADS); - glTexCoord2f(0,0);glVertex2f(0-myfade2, 600+myfade2); - glTexCoord2f(0,ScreenH/1024);glVertex2f(0-myfade2, 0-myfade2); - glTexCoord2f(ScreenW/1024,ScreenH/1024);glVertex2f(800+myfade2, 0-myfade2); - glTexCoord2f(ScreenW/1024,0);glVertex2f(800+myfade2, 600+myfade2); - glEnd; - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - end; - - if myfade > 50 then begin // fade out complete... - myfade:=0; + myfade2:=myfade*myfade; + glBindTexture(GL_TEXTURE_2D, pTex); + glColor4f(1, 1, 1, (1000-myfade2)/1000); // strange calculation - alpha gets negative... but looks good this way + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + glTexCoord2f(0,0);glVertex2f(0-myfade2, 600+myfade2); + glTexCoord2f(0,ScreenH/1024);glVertex2f(0-myfade2, 0-myfade2); + glTexCoord2f(ScreenW/1024,ScreenH/1024);glVertex2f(800+myfade2, 0-myfade2); + glTexCoord2f(ScreenW/1024,0);glVertex2f(800+myfade2, 600+myfade2); + glEnd; + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end; + if (myfade > 40) or (not doFade) then begin // fade out complete... + myFade:=0; ActualScreen.onHide; // nop... whatever ActualScreen.ShowFinish:=False; ActualScreen:=NextScreen; NextScreen := nil; ActualScreen.onShowFinish; // one more nop... ActualScreen.ShowFinish := true; // who wrote this crap? - // end of fade mod + // end of fade mod + end; end; // if end; // for // SwapBuffers(h_DC); -- cgit v1.2.3 From 23c69ff32e06a2570641e352ad17f2816ae748f2 Mon Sep 17 00:00:00 2001 From: b1indy Date: Sun, 15 Apr 2007 13:45:17 +0000 Subject: re-inserted some code to set clear-color to white per default or to black via commandline switch (affects whole classic theme and singscreen in deluxe theme) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@95 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 876fb6b6..b6489c70 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -46,14 +46,14 @@ begin myfade:=0; doFade:=True; // generate texture for fading between screens - GetMem(pTexData, 1024*1024*4); + GetMem(pTexData, 1024*1024*3); if pTexData <> NIL then begin glGenTextures(1, pTex); if glGetError <> GL_NO_ERROR then doFade := False; glBindTexture(GL_TEXTURE_2D, pTex); if glGetError <> GL_NO_ERROR then doFade := False; - glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); + glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); if glGetError <> GL_NO_ERROR then doFade := False; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if glGetError <> GL_NO_ERROR then doFade := False; @@ -81,6 +81,7 @@ end; function TDisplay.Draw: Boolean; var S: integer; + Col: Real; // fade mod myFade2:integer; currentTime: Cardinal; @@ -88,11 +89,11 @@ var begin Result := True; -{ Col := 1; + Col := 1; if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then - Col := 0;} + Col := 0; - glClearColor(0, 0, 0 , 0); + glClearColor(Col, Col, Col , 0); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); for S := 1 to Screens do begin @@ -124,7 +125,7 @@ begin begin ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1024, 1024, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1024, 1024, 0); if glGetError <> GL_NO_ERROR then begin doFade := False; -- cgit v1.2.3 From e8f259a1a37ce5cf10a79dc53e184d6af4e7b7d6 Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 17 Apr 2007 00:48:03 +0000 Subject: Changed aadvanced options to switch on/off sing-effects and screen-fading Changed Languages (english, german) and Theme (deluxe) to reflect these changes implemented checks for config values to make these things work as expected git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@101 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index b6489c70..3f6e70da 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -15,6 +15,7 @@ type Fade: Real; // fade-mod doFade: Boolean; + canFade: Boolean; myFade: integer; lastTime: Cardinal; pTexData : Pointer; @@ -37,42 +38,51 @@ var implementation -uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture; +uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture, UIni; constructor TDisplay.Create; begin inherited Create; // fade mod myfade:=0; - doFade:=True; + + if Ini.ScreenFade=1 then + doFade:=True + else + doFade:=False; + + canFade:=True; // generate texture for fading between screens GetMem(pTexData, 1024*1024*3); if pTexData <> NIL then begin glGenTextures(1, pTex); - if glGetError <> GL_NO_ERROR then doFade := False; + if glGetError <> GL_NO_ERROR then canFade := False; glBindTexture(GL_TEXTURE_2D, pTex); - if glGetError <> GL_NO_ERROR then doFade := False; + if glGetError <> GL_NO_ERROR then canFade := False; glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); - if glGetError <> GL_NO_ERROR then doFade := False; + if glGetError <> GL_NO_ERROR then canFade := False; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if glGetError <> GL_NO_ERROR then doFade := False; + if glGetError <> GL_NO_ERROR then canFade := False; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - if glGetError <> GL_NO_ERROR then doFade := False; + if glGetError <> GL_NO_ERROR then canFade := False; FreeMem(pTexData); end else begin - doFade:=False; + canFade:=False; end; - if not doFade then showmessage('Fehler beim Initialisieren der Fading-Textur... Fading deaktiviert'); + if not canFade then begin + showmessage('Fehler beim Initialisieren der Fading-Textur... Fading deaktiviert'); + doFade:=False; + end // end end; // fade mod destructor TDisplay.Destroy; begin - if doFade then + if canFade then glDeleteTextures(1,@pTex); inherited Destroy; end; @@ -113,11 +123,15 @@ begin Result := ActualScreen.Draw; // fade mod myfade:=0; + if (Ini.ScreenFade=1) and canFade then + doFade:=True + else if Ini.ScreenFade=0 then + doFade:=False; // end end else begin - if doFade then + if doFade and canFade then begin // fade mod //Create Fading texture if we're just starting @@ -128,7 +142,7 @@ begin glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1024, 1024, 0); if glGetError <> GL_NO_ERROR then begin - doFade := False; + canFade := False; showmessage('Fehler beim Kopieren der Fade-Textur... Fading deaktiviert'); end; NextScreen.onShow; @@ -167,7 +181,7 @@ begin glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); end; - if (myfade > 40) or (not doFade) then begin // fade out complete... + if (myfade > 40) or (not doFade) or (not canFade) then begin // fade out complete... myFade:=0; ActualScreen.onHide; // nop... whatever ActualScreen.ShowFinish:=False; -- cgit v1.2.3 From 6b6edf009b8708de5a3918cad39708b07f1886d9 Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 17 Apr 2007 23:48:00 +0000 Subject: fixed a bug that caused song selection screen to be drawn incorrectly and singscreen crash when screen fading was disabled git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@111 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 3f6e70da..fc18025f 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,7 +2,7 @@ unit UDisplay; interface -uses Windows, SDL, UMenu, OpenGL12, SysUtils, dialogs; +uses Windows, SDL, UMenu, OpenGL12, SysUtils, dialogs, Math; type TDisplay = class @@ -43,6 +43,7 @@ uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture, UIni; constructor TDisplay.Create; begin inherited Create; + // fade mod myfade:=0; @@ -163,6 +164,8 @@ begin // ActualScreen.SetAnimationProgress(Fade-1); // nop? + glClearColor(Col, Col, Col , 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); NextScreen.Draw; // draw next screen // and draw old screen over it... slowly fading out @@ -180,7 +183,10 @@ begin glEnd; glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); - end; + end + else NextScreen.OnShow; + + if (myfade > 40) or (not doFade) or (not canFade) then begin // fade out complete... myFade:=0; ActualScreen.onHide; // nop... whatever -- cgit v1.2.3 From e7650e739e84b47ce6384767e39115adb5d3211a Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 19 Apr 2007 15:30:51 +0000 Subject: Fixed a Bug in PageBreak generation for Text Added support for /n Tag in Texts git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@117 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 4b8ea391..55f84bf8 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -61,6 +61,7 @@ var begin TextString := Value; + //Create Page Breaks if width is given if (W > 0) then begin //Set Font Propertys @@ -76,7 +77,7 @@ begin I := Pos (' ', Value); While (I <> 0) do begin - if (glTextWidth(PChar(Copy (Value,LastBreak + 1,I))) > W) AND (LastPos <> 1) then + if (glTextWidth(PChar(Copy (Value,LastBreak + 1,I - LastBreak))) > W) AND (LastPos <> 1) then begin //new Break SetLength (TextTiles, L+1); @@ -105,6 +106,39 @@ begin SetLength (TextTiles, L+1); TextTiles[L] := Copy (Value, LastBreak + 1, Length(Value) - LastBreak); + end + else + begin + SetLength (TextTiles, 1); + TextTiles[0] := Value; + end; + + I := 0; + // /n Hack + While (I <= High(TextTiles)) do + begin + LastPos := Pos ('/n', TextTiles[I]); + if (LastPos = 0) then //No /n Tags -> Search in next Tile + Inc(I) + else //Found /n Tag -> Create a Break + begin + //Add a new Tile and move all Tiles behind actual Tile to the right + L := Length(TextTiles); + SetLength(TextTiles, L+1); + For L := L-1 downto I + 1 do + begin + TextTiles[L+1] := TextTiles[L]; + end; + + //Write Text to new Tile + TextTiles[I+1] := Trim(Copy(TextTiles[I], LastPos + 2, Length(TextTiles[I]) - LastPos - 1)); + //Delete Text that now is in new Tile from cur. Tile + Delete(TextTiles[I], LastPos, Length(TextTiles[I]) - LastPos + 1); + TextTiles[I] := Trim (TextTiles[I]); + + //Goto next Tile because cur. Tile can not have another /n Tag + Inc(I) + end; end; //Set Cursor Visible @@ -148,7 +182,7 @@ begin end; end; - if (W <= 0) then //No Width set Draw as one Long String + if (False) then //No Width set Draw as one Long String begin if not (SelectBool AND SelectBlink) then Text2 := Text -- cgit v1.2.3 From 6cdcfb402ce738dfc77b008fcb98fd1cda691eb5 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 19 Apr 2007 18:53:22 +0000 Subject: Added Statistic Screens to C0de and to Theme Moved some Translated Strings from UScreenPartyOptions to UTheme to use it with the Statistic Screens, too. Fixed use of /n Tag istead of the correct \n git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@118 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 55f84bf8..65034f1d 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -114,13 +114,13 @@ begin end; I := 0; - // /n Hack + // \n Hack While (I <= High(TextTiles)) do begin - LastPos := Pos ('/n', TextTiles[I]); + LastPos := Pos ('\n', TextTiles[I]); if (LastPos = 0) then //No /n Tags -> Search in next Tile Inc(I) - else //Found /n Tag -> Create a Break + else //Found \n Tag -> Create a Break begin //Add a new Tile and move all Tiles behind actual Tile to the right L := Length(TextTiles); -- cgit v1.2.3 From 34988301a511ca8552a954c231fafde007cb94a1 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 20 Apr 2007 15:29:48 +0000 Subject: Some Memory tweaking (13 MB Less Ram using at 800 Songs) Some Loading Time tweaking (From 8 Secs to 6 Secs on my Computer) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@123 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 7908d980..1c4418c1 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -11,6 +11,8 @@ type PMenu = ^TMenu; TMenu = class protected + ButtonPos: Integer; + Interactions: array of TInteract; SelInteraction: integer; Button: array of TButton; @@ -59,6 +61,7 @@ type function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): 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 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; @@ -150,6 +153,9 @@ begin SetLength(Button, 0); BackImg.TexNum := -1; + + //Set ButtonPos to Autoset Length + ButtonPos := -1; end; constructor TMenu.Create(Back: String); @@ -165,6 +171,9 @@ begin BackH := 1; end else BackImg.TexNum := -1; + + //Set ButtonPos to Autoset Length + ButtonPos := -1; end; constructor TMenu.Create(Back: string; W, H: integer); @@ -356,6 +365,19 @@ begin Result := TextNum; end; +//Function that Set Length of Button Array in one Step instead of register new Memory for every Button +Procedure TMenu.SetButtonLength(Length: Cardinal); +begin + if (ButtonPos = -1) AND (Length > 0) then + begin + //Set Length of Button + SetLength(Button, Length); + + //Set ButtonPos to start with 0 + ButtonPos := 0; + end; +end; + // Method to add a button in our TMenu. It returns the assigned ButtonNumber function TMenu.AddButton(ThemeButton: TThemeButton): integer; @@ -399,8 +421,17 @@ 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; begin // adds button - Result := Length(Button); - SetLength(Button, Result + 1); + //SetLength is used to reduce Memory usement + if (ButtonPos <> -1) then + begin + Result := ButtonPos; + Inc(ButtonPos) + end + else //Old Method -> Reserve new Memory for every Button + begin + Result := Length(Button); + SetLength(Button, Result + 1); + end; // Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ)); // check here for cache -- cgit v1.2.3 From e4c8e7918cde3b197a1c26e496bd9c345b7a0fa3 Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 24 Apr 2007 11:38:52 +0000 Subject: ScreenFading now works in dual screen mode (it should not work with resolutions higher than 1024x768 because of limited texture size, someone with a big screen should check this) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@129 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 51 ++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index fc18025f..ad383782 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,7 +2,7 @@ unit UDisplay; interface -uses Windows, SDL, UMenu, OpenGL12, SysUtils, dialogs, Math; +uses Windows, SDL, UMenu, OpenGL12, SysUtils, dialogs; type TDisplay = class @@ -19,7 +19,7 @@ type myFade: integer; lastTime: Cardinal; pTexData : Pointer; - pTex : glUInt; + pTex : array[1..2] of glUInt; // end function Draw: Boolean; @@ -41,6 +41,7 @@ implementation uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture, UIni; constructor TDisplay.Create; +var i: integer; begin inherited Create; @@ -56,10 +57,11 @@ begin // generate texture for fading between screens GetMem(pTexData, 1024*1024*3); if pTexData <> NIL then + for i:= 1 to 2 do begin - glGenTextures(1, pTex); + glGenTextures(1, pTex[i]); if glGetError <> GL_NO_ERROR then canFade := False; - glBindTexture(GL_TEXTURE_2D, pTex); + glBindTexture(GL_TEXTURE_2D, pTex[i]); if glGetError <> GL_NO_ERROR then canFade := False; glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); if glGetError <> GL_NO_ERROR then canFade := False; @@ -67,12 +69,12 @@ begin if glGetError <> GL_NO_ERROR then canFade := False; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); if glGetError <> GL_NO_ERROR then canFade := False; - FreeMem(pTexData); end else begin canFade:=False; end; + FreeMem(pTexData); if not canFade then begin showmessage('Fehler beim Initialisieren der Fading-Textur... Fading deaktiviert'); doFade:=False; @@ -94,7 +96,7 @@ var S: integer; Col: Real; // fade mod - myFade2:integer; + myFade2: Real; currentTime: Cardinal; // end begin @@ -116,7 +118,6 @@ begin ScreenX := 0; - if S = 2 then TimeSkip := 0 else; // it's easier than rewriting code glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); // ActualScreen.SetAnimationProgress(1); @@ -139,8 +140,8 @@ begin if myfade = 0 then begin ActualScreen.Draw; - glBindTexture(GL_TEXTURE_2D, pTex); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 1024, 1024, 0); + glBindTexture(GL_TEXTURE_2D, pTex[S]); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (S-1)*ScreenW div Screens, 0, 1024, 1024, 0); if glGetError <> GL_NO_ERROR then begin canFade := False; @@ -148,14 +149,18 @@ begin end; NextScreen.onShow; lastTime:=GetTickCount; - myfade:=myfade+1; - end; + if (S=2) or (Screens = 1) then + myfade:=myfade+1; + end; // end texture creation in first fading step + + //do some time-based fading currentTime:=GetTickCount; - if currentTime > lastTime+30 then + if (currentTime > lastTime+30) and (S=1) then begin myfade:=myfade+4; lastTime:=currentTime; end; + // LastFade := Fade; // whatever // Fade := Fade -0.999; // start fading out @@ -164,22 +169,20 @@ begin // ActualScreen.SetAnimationProgress(Fade-1); // nop? - glClearColor(Col, Col, Col , 0); - glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); NextScreen.Draw; // draw next screen // and draw old screen over it... slowly fading out - myfade2:=myfade*myfade; - glBindTexture(GL_TEXTURE_2D, pTex); - glColor4f(1, 1, 1, (1000-myfade2)/1000); // strange calculation - alpha gets negative... but looks good this way + myfade2:=(myfade*myfade)/10000; + glBindTexture(GL_TEXTURE_2D, pTex[S]); + glColor4f(1, 1, 1, (1000-myfade*myfade)/1000); // strange calculation - alpha gets negative... but looks good this way glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glBegin(GL_QUADS); - glTexCoord2f(0,0);glVertex2f(0-myfade2, 600+myfade2); - glTexCoord2f(0,ScreenH/1024);glVertex2f(0-myfade2, 0-myfade2); - glTexCoord2f(ScreenW/1024,ScreenH/1024);glVertex2f(800+myfade2, 0-myfade2); - glTexCoord2f(ScreenW/1024,0);glVertex2f(800+myfade2, 600+myfade2); + glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600); + glTexCoord2f(0+myfade2,ScreenH/1024-myfade2);glVertex2f(0, 0); + glTexCoord2f((ScreenW div Screens)/1024-myfade2,ScreenH/1024-myfade2);glVertex2f(800, 0); + glTexCoord2f((ScreenW div Screens)/1024-myfade2,0+myfade2);glVertex2f(800, 600); glEnd; glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); @@ -189,12 +192,12 @@ begin if (myfade > 40) or (not doFade) or (not canFade) then begin // fade out complete... myFade:=0; - ActualScreen.onHide; // nop... whatever + ActualScreen.onHide; ActualScreen.ShowFinish:=False; ActualScreen:=NextScreen; NextScreen := nil; - ActualScreen.onShowFinish; // one more nop... - ActualScreen.ShowFinish := true; // who wrote this crap? + ActualScreen.onShowFinish; + ActualScreen.ShowFinish := true; // end of fade mod end; end; // if -- cgit v1.2.3 From 8c3c4d3107df8a6fa9cddbc7360cd7fa36b39c95 Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 24 Apr 2007 11:48:19 +0000 Subject: re-inserted a line that is essential for proper timing in dual screen mode git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@130 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index ad383782..6144f3bd 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -117,7 +117,7 @@ begin // if (Screens = 2) and (S = 2) then ScreenX := 1; ScreenX := 0; - + if S = 2 then TimeSkip := 0 else; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); // ActualScreen.SetAnimationProgress(1); -- cgit v1.2.3 From 569213582ca4147e6df5309f65d8a442da394a25 Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 24 Apr 2007 13:02:06 +0000 Subject: changed size of texture for screen fading effect to fixed size of 512x512, need comments git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@132 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 6144f3bd..ddbc0d1f 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -55,7 +55,7 @@ begin canFade:=True; // generate texture for fading between screens - GetMem(pTexData, 1024*1024*3); + GetMem(pTexData, 512*512*3); if pTexData <> NIL then for i:= 1 to 2 do begin @@ -63,7 +63,7 @@ begin if glGetError <> GL_NO_ERROR then canFade := False; glBindTexture(GL_TEXTURE_2D, pTex[i]); if glGetError <> GL_NO_ERROR then canFade := False; - glTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); + glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); if glGetError <> GL_NO_ERROR then canFade := False; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if glGetError <> GL_NO_ERROR then canFade := False; @@ -117,7 +117,7 @@ begin // if (Screens = 2) and (S = 2) then ScreenX := 1; ScreenX := 0; - if S = 2 then TimeSkip := 0 else; + if S = 2 then TimeSkip := 0 else; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); // ActualScreen.SetAnimationProgress(1); @@ -139,9 +139,11 @@ begin //Create Fading texture if we're just starting if myfade = 0 then begin + glViewPort((S-1) * 512, 0, 512, 512); ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (S-1)*ScreenW div Screens, 0, 1024, 1024, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (S-1)*512, 0, 512, 512, 0); + glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); if glGetError <> GL_NO_ERROR then begin canFade := False; @@ -180,9 +182,9 @@ begin glEnable(GL_BLEND); glBegin(GL_QUADS); glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600); - glTexCoord2f(0+myfade2,ScreenH/1024-myfade2);glVertex2f(0, 0); - glTexCoord2f((ScreenW div Screens)/1024-myfade2,ScreenH/1024-myfade2);glVertex2f(800, 0); - glTexCoord2f((ScreenW div Screens)/1024-myfade2,0+myfade2);glVertex2f(800, 600); + glTexCoord2f(0+myfade2,1-myfade2);glVertex2f(0, 0); + glTexCoord2f(1-myfade2,1-myfade2);glVertex2f(800, 0); + glTexCoord2f(1-myfade2,0+myfade2);glVertex2f(800, 600); glEnd; glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); -- cgit v1.2.3 From 6c530e99b8a5314bb1e988a00680ba4332ac4abc Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 24 Apr 2007 13:23:53 +0000 Subject: UTexture.pas: texture-wrap-mode changed to GL_CLAMP_TO_EDGE - solves some problems where edges of textures were drawn incorrectly UDisplay.pas: simplified generation of fade texture (a little) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@134 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index ddbc0d1f..9d13d2a6 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -139,10 +139,10 @@ begin //Create Fading texture if we're just starting if myfade = 0 then begin - glViewPort((S-1) * 512, 0, 512, 512); + glViewPort(0, 0, 512, 512); ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (S-1)*512, 0, 512, 512, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); if glGetError <> GL_NO_ERROR then begin -- cgit v1.2.3 From 019b5bf1730eab1c5b69a0cf1f805b3aa8566b6b Mon Sep 17 00:00:00 2001 From: b1indy Date: Tue, 24 Apr 2007 19:57:28 +0000 Subject: just to test something git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@137 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 9d13d2a6..19266414 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -143,12 +143,12 @@ begin ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); - glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); if glGetError <> GL_NO_ERROR then begin canFade := False; showmessage('Fehler beim Kopieren der Fade-Textur... Fading deaktiviert'); end; + glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); NextScreen.onShow; lastTime:=GetTickCount; if (S=2) or (Screens = 1) then -- cgit v1.2.3 From b2518890d0dd62eeb96ee8b4b5f2d86e61ca75e7 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 26 Apr 2007 19:42:55 +0000 Subject: 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 --- Game/Code/Menu/UMenu.pas | 26 ++-- Game/Code/Menu/UMenuButton.pas | 266 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 270 insertions(+), 22 deletions(-) (limited to 'Game/Code/Menu') 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); -- cgit v1.2.3 From 3d1f2a49bbffd8568916a41a131213198f408bef Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 27 Apr 2007 20:02:41 +0000 Subject: PageBreak Code Rewritten Now there is more structur in Code Also some Bugs are fixed that appears when \n Tags and Textwidth is used in one Text. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@145 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 283 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 233 insertions(+), 50 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 65034f1d..adf58840 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -15,6 +15,8 @@ type public X: real; Y: real; + MoveX: real; //Some Modifier for X - Position that don't Affect the Real Y + MoveY: real; //Some Modifier for Y - Position that don't Affect the Real Y W: real; // if text is wider than W then it is breaked // H: real; Size: real; @@ -54,66 +56,139 @@ end; procedure TText.SetText(Value: String); var - I: Integer; - L: Integer; - LastPos: Integer; - LastBreak: Integer; + NextPos: Cardinal; //NextPos of a Space etc. + LastPos: Cardinal; //LastPos " + LastBreak: Cardinal; //Last Break + isBreak: Boolean; //True if the Break is not Caused because the Text is out of the area + FirstWord: Word; //Is First Word after Break? + Len: Word; //Length of the Tiles Array + Function Smallest(const A, B: Cardinal):Cardinal; + begin + if (A < B) then + Result := A + else + Result := B; + end; + + Function GetNextPos: Boolean; + var + T1, T2, T3: Cardinal; + begin + LastPos := NextPos; + + //Next Space (If Width is given) + if (W > 0) then + T1 := PosEx(' ', Value, LastPos + 1) + else T1 := Length(Value); + + {//Next - + T2 := PosEx('-', Value, LastPos + 1);} + + //Next Break + T3 := PosEx('\n', Value, LastPos + 1); + + if T1 = 0 then + T1 := Length(Value); + {if T2 = 0 then + T2 := Length(Value); } + if T3 = 0 then + T3 := Length(Value); + + //Get Nearest Pos + NextPos := Smallest(T1, T3{Smallest(T2, T3)}); + + if (LastPos = Length(Value)) then + NextPos := 0; + + isBreak := (NextPos = T3) AND (NextPos <> Length(Value)); + Result := (NextPos <> 0); + end; + procedure AddBreak(const From, bTo: Cardinal); + begin + if (isBreak) OR (bTo - From > 1) then + begin + Inc(Len); + SetLength (TextTiles, Len); + TextTiles[Len-1] := Trim(Copy(Value, From, bTo - From)); + + if isBreak then + LastBreak := bTo + 2 + else + LastBreak := bTo + 1; + FirstWord := 0; + end; + end; begin + //Set TExtstring TextString := Value; - //Create Page Breaks if width is given + //Create Tiles + //Reset Text Array + SetLength (TextTiles, 0); + Len := 0; + + //Reset Counter Vars + LastPos := 1; + NextPos := 1; + LastBreak := 1; + FirstWord := 1; + if (W > 0) then begin //Set Font Propertys SetFontStyle(Style); SetFontSize(Size); + end; - //Create New TextTiles Array - SetLength (TextTiles, 0); - L := 0; - LastPos := 1; - LastBreak := 0; - I := Pos (' ', Value); - While (I <> 0) do - begin - if (glTextWidth(PChar(Copy (Value,LastBreak + 1,I - LastBreak))) > W) AND (LastPos <> 1) then + //go Through Text + While (GetNextPos) do + begin + //Break in Text + if isBreak then begin - //new Break - SetLength (TextTiles, L+1); - TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); - - Inc(L); - LastBreak := LastPos; - end; - - LastPos := I; - I := PosEx (' ', Value, I+1); - end; + //Look for Break before the Break + if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) AND (NextPos-LastPos > 1) then + begin + //Not the First word after Break, so we don't have to break within a word + if (FirstWord > 1) then + begin + //Add Break before actual Position, because there the Text fits the Area + AddBreak(LastBreak, LastPos); + end + else //First Word after Break Break within the Word + begin + //ToDo + //AddBreak(LastBreak, LastBreak + 155); + end; + end; - //Last Break - if (glTextWidth(PChar(Copy (Value,LastBreak + 1,Length(Value) - LastBreak))) > W) AND (LastPos <> 1) then + //Add Break from Text + AddBreak(LastBreak, NextPos); + end + //Text comes out of the Text Area -> CreateBreak + else if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) then begin - //new Break - SetLength (TextTiles, L+1); - TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); - - Inc(L); - LastBreak := LastPos; + //Not the First word after Break, so we don't have to break within a word + if (FirstWord > 1) then + begin + //Add Break before actual Position, because there the Text fits the Area + AddBreak(LastBreak, LastPos); + end + else //First Word after Break -> Break within the Word + begin + //ToDo + //AddBreak(LastBreak, LastBreak + 155); + end; end; - - //last Part - SetLength (TextTiles, L+1); - TextTiles[L] := Copy (Value, LastBreak + 1, Length(Value) - LastBreak); - - end - else - begin - SetLength (TextTiles, 1); - TextTiles[0] := Value; + //end; + Inc(FirstWord) end; + //Add Ending + AddBreak(LastBreak, Length(Value)+1); + - I := 0; + {I := 0; // \n Hack While (I <= High(TextTiles)) do begin @@ -135,12 +210,120 @@ begin //Delete Text that now is in new Tile from cur. Tile Delete(TextTiles[I], LastPos, Length(TextTiles[I]) - LastPos + 1); TextTiles[I] := Trim (TextTiles[I]); - + //Goto next Tile because cur. Tile can not have another /n Tag - Inc(I) + Inc(I) end; end; + //Create Page Breaks if width is given and the Text overlapps the width + if (W > 0) then + begin + //Set Font Propertys + SetFontStyle(Style); + SetFontSize(Size); + + {//Create New TextTiles Array + SetLength (TextTiles, 0);}{ + I := 0; + + //Go Through all Tiles + While (I <= High(TextTiles)) do + begin + LastPos := 0; + CurPos := Pos (' ', TextTiles[I]); + + //Go through all Spaces + While (CurPos <> 0) do + begin + //Text is too long for given Width and not the First Word(That means that the Given Word don't Fit the given Width + if (glTextWidth(PChar(Copy (TextTiles[I],1,CurPos-1))) > W) AND (LastPos <> 1) then + begin + //Add a new Tile and move all Tiles behind actual Tile to the right + L := Length(TextTiles); + SetLength(TextTiles, L+1); + For L := L-1 downto I + 1 do + begin + TextTiles[L+1] := TextTiles[L]; + end; + + //Write Text to new Tile + TextTiles[I+1] := Trim(Copy(TextTiles[I], LastPos + 1, Length(TextTiles[I]) - LastPos)); + //Delete Text that now is in new Tile from cur. Tile + Delete(TextTiles[I], LastPos, Length(TextTiles[I]) - LastPos + 1); + TextTiles[I] := Trim (TextTiles[I]); + + //Goto next Tile because cur. Tile can not have another Space + Inc(I) + end; + //Set LastPos and Cur Pos + LastPos := CurPos; + CurPos := PosEx (' ', TextTiles[I], LastPos+1); + end; + + //Look for PageBreak in Last Part of the Tile + CurPos := Length(TextTiles[I]); + if (glTextWidth(PChar(Copy (TextTiles[I],1,CurPos))) > W) AND (LastPos <> 1) then + begin + //Add a new Tile and move all Tiles behind actual Tile to the right + L := Length(TextTiles); + SetLength(TextTiles, L+1); + For L := L-1 downto I + 1 do + begin + TextTiles[L+1] := TextTiles[L]; + end; + + //Write Text to new Tile + TextTiles[I+1] := Trim(Copy(TextTiles[I], LastPos + 1, CurPos - LastPos)); + //Delete Text from cur. Tile that now is in new Tile + Delete(TextTiles[I], LastPos, CurPos - LastPos + 1); + TextTiles[I] := Trim (TextTiles[I]); + //Goto next Tile because cur. Tile can not have another Space + Inc(I) + end; + + //Inc I if Current Tile has no more Spaces + Inc(I) + end; + + I := high(TextTiles); + + {LastPos := 1; + LastBreak := 0; + I := Pos (' ', Value); + While (I <> 0) do + begin + if (glTextWidth(PChar(Copy (Value,LastBreak + 1,I - LastBreak))) > W) AND (LastPos <> 1) then + begin + //new Break + SetLength (TextTiles, L+1); + TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); + + Inc(L); + LastBreak := LastPos; + end; + + LastPos := I; + I := PosEx (' ', Value, I+1); + end; + + //Last Break + if (glTextWidth(PChar(Copy (Value,LastBreak + 1,Length(Value) - LastBreak))) > W) AND (LastPos <> 1) then + begin + //new Break + SetLength (TextTiles, L+1); + TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); + + Inc(L); + LastBreak := LastPos; + end; + + //last Part + SetLength (TextTiles, L+1); + TextTiles[L] := Copy (Value, LastBreak + 1, Length(Value) - LastBreak); + + end; } + //Set Cursor Visible SelectBlink := True; STicks := GettickCount div 550; @@ -201,7 +384,7 @@ begin end else begin //Draw Text as Many Strings - Y2 := Y; + Y2 := Y + MoveY; for I := 0 to high(TextTiles) do begin if (not (SelectBool AND SelectBlink)) OR (I <> high(TextTiles)) then @@ -210,9 +393,9 @@ begin Text2 := TextTiles[I] + '|'; case Align of - 0: X2 := X; - 1: X2 := X - glTextWidth(pchar(Text2))/2; - 2: X2 := X - glTextWidth(pchar(Text2)); + 0: X2 := X + MoveX; + 1: X2 := X + MoveX - glTextWidth(pchar(Text2))/2; + 2: X2 := X + MoveX - glTextWidth(pchar(Text2)); end; SetFontPos(X2, Y2); -- cgit v1.2.3 From 5c8ba0055244ca316dc9957fec02d6f151df0d2e Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 27 Apr 2007 20:04:56 +0000 Subject: Some Code Cleanup in UMenuText git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@146 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 145 ++----------------------------------------- 1 file changed, 5 insertions(+), 140 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index adf58840..0ebaede2 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -187,143 +187,6 @@ begin //Add Ending AddBreak(LastBreak, Length(Value)+1); - - {I := 0; - // \n Hack - While (I <= High(TextTiles)) do - begin - LastPos := Pos ('\n', TextTiles[I]); - if (LastPos = 0) then //No /n Tags -> Search in next Tile - Inc(I) - else //Found \n Tag -> Create a Break - begin - //Add a new Tile and move all Tiles behind actual Tile to the right - L := Length(TextTiles); - SetLength(TextTiles, L+1); - For L := L-1 downto I + 1 do - begin - TextTiles[L+1] := TextTiles[L]; - end; - - //Write Text to new Tile - TextTiles[I+1] := Trim(Copy(TextTiles[I], LastPos + 2, Length(TextTiles[I]) - LastPos - 1)); - //Delete Text that now is in new Tile from cur. Tile - Delete(TextTiles[I], LastPos, Length(TextTiles[I]) - LastPos + 1); - TextTiles[I] := Trim (TextTiles[I]); - - //Goto next Tile because cur. Tile can not have another /n Tag - Inc(I) - end; - end; - - //Create Page Breaks if width is given and the Text overlapps the width - if (W > 0) then - begin - //Set Font Propertys - SetFontStyle(Style); - SetFontSize(Size); - - {//Create New TextTiles Array - SetLength (TextTiles, 0);}{ - I := 0; - - //Go Through all Tiles - While (I <= High(TextTiles)) do - begin - LastPos := 0; - CurPos := Pos (' ', TextTiles[I]); - - //Go through all Spaces - While (CurPos <> 0) do - begin - //Text is too long for given Width and not the First Word(That means that the Given Word don't Fit the given Width - if (glTextWidth(PChar(Copy (TextTiles[I],1,CurPos-1))) > W) AND (LastPos <> 1) then - begin - //Add a new Tile and move all Tiles behind actual Tile to the right - L := Length(TextTiles); - SetLength(TextTiles, L+1); - For L := L-1 downto I + 1 do - begin - TextTiles[L+1] := TextTiles[L]; - end; - - //Write Text to new Tile - TextTiles[I+1] := Trim(Copy(TextTiles[I], LastPos + 1, Length(TextTiles[I]) - LastPos)); - //Delete Text that now is in new Tile from cur. Tile - Delete(TextTiles[I], LastPos, Length(TextTiles[I]) - LastPos + 1); - TextTiles[I] := Trim (TextTiles[I]); - - //Goto next Tile because cur. Tile can not have another Space - Inc(I) - end; - //Set LastPos and Cur Pos - LastPos := CurPos; - CurPos := PosEx (' ', TextTiles[I], LastPos+1); - end; - - //Look for PageBreak in Last Part of the Tile - CurPos := Length(TextTiles[I]); - if (glTextWidth(PChar(Copy (TextTiles[I],1,CurPos))) > W) AND (LastPos <> 1) then - begin - //Add a new Tile and move all Tiles behind actual Tile to the right - L := Length(TextTiles); - SetLength(TextTiles, L+1); - For L := L-1 downto I + 1 do - begin - TextTiles[L+1] := TextTiles[L]; - end; - - //Write Text to new Tile - TextTiles[I+1] := Trim(Copy(TextTiles[I], LastPos + 1, CurPos - LastPos)); - //Delete Text from cur. Tile that now is in new Tile - Delete(TextTiles[I], LastPos, CurPos - LastPos + 1); - TextTiles[I] := Trim (TextTiles[I]); - //Goto next Tile because cur. Tile can not have another Space - Inc(I) - end; - - //Inc I if Current Tile has no more Spaces - Inc(I) - end; - - I := high(TextTiles); - - {LastPos := 1; - LastBreak := 0; - I := Pos (' ', Value); - While (I <> 0) do - begin - if (glTextWidth(PChar(Copy (Value,LastBreak + 1,I - LastBreak))) > W) AND (LastPos <> 1) then - begin - //new Break - SetLength (TextTiles, L+1); - TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); - - Inc(L); - LastBreak := LastPos; - end; - - LastPos := I; - I := PosEx (' ', Value, I+1); - end; - - //Last Break - if (glTextWidth(PChar(Copy (Value,LastBreak + 1,Length(Value) - LastBreak))) > W) AND (LastPos <> 1) then - begin - //new Break - SetLength (TextTiles, L+1); - TextTiles[L] := Copy (Value, LastBreak + 1, LastPos - LastBreak); - - Inc(L); - LastBreak := LastPos; - end; - - //last Part - SetLength (TextTiles, L+1); - TextTiles[L] := Copy (Value, LastBreak + 1, Length(Value) - LastBreak); - - end; } - //Set Cursor Visible SelectBlink := True; STicks := GettickCount div 550; @@ -365,7 +228,7 @@ begin end; end; - if (False) then //No Width set Draw as one Long String + {if (False) then //No Width set Draw as one Long String begin if not (SelectBool AND SelectBlink) then Text2 := Text @@ -383,7 +246,9 @@ begin SetFontStyle(0); // reset to default end else - begin //Draw Text as Many Strings + begin} + //Now Use allways: + //Draw Text as Many Strings Y2 := Y + MoveY; for I := 0 to high(TextTiles) do begin @@ -405,7 +270,7 @@ begin end; SetFontStyle(0); // reset to default - end; + //end; end; end; -- cgit v1.2.3 From 23e4d293dc19ce496da33b3929c9b71952148e86 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 28 Apr 2007 15:25:11 +0000 Subject: Fixed a Bug in UMenuText that causes that Text with only one Char is not displayed git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@148 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 0ebaede2..abf3784c 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -105,7 +105,7 @@ var end; procedure AddBreak(const From, bTo: Cardinal); begin - if (isBreak) OR (bTo - From > 1) then + if (isBreak) OR (bTo - From >= 1) then begin Inc(Len); SetLength (TextTiles, Len); @@ -122,6 +122,18 @@ begin //Set TExtstring TextString := Value; + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; + + //Exit if there is no Need to Create Tiles + If (W <= 0) and (Pos('\n', Value) = 0) then + begin + SetLength (TextTiles, 1); + TextTiles[0] := Value; + Exit; + end; + //Create Tiles //Reset Text Array SetLength (TextTiles, 0); @@ -133,6 +145,7 @@ begin LastBreak := 1; FirstWord := 1; + if (W > 0) then begin //Set Font Propertys @@ -140,7 +153,6 @@ begin SetFontSize(Size); end; - //go Through Text While (GetNextPos) do begin @@ -186,10 +198,6 @@ begin end; //Add Ending AddBreak(LastBreak, Length(Value)+1); - - //Set Cursor Visible - SelectBlink := True; - STicks := GettickCount div 550; end; Procedure TText.DeleteLastL; -- cgit v1.2.3 From bda4fa8e57ca63a1d591433f120b4226d6a5d327 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 29 Apr 2007 17:50:29 +0000 Subject: Added 2 new Buttons to ScreenMain: Multi and Stats Updated Language Fiels to Fit with new Buttons Some CodeClean Up in Menu Class and in Screens Some minor Bug fixes I forgot about Added ability to group Buttons within a Screen New Theme Object: ButtonCollection: Same Attributes as a Button Plus FirstChild: Defining the First Button in the Group. For Example: SingSolo is 1, SingMulti Button is 2, in ScreenMain Added Attribute to Theme Button: Parent: Number of the assigned Group, 0 for no Group Used new Abilitys in MainScreen git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@149 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 348 ++++++++++++++++++++++++++----- Game/Code/Menu/UMenuButton.pas | 17 +- Game/Code/Menu/UMenuButtonCollection.pas | 59 ++++++ Game/Code/Menu/UMenuInteract.pas | 2 +- Game/Code/Menu/UMenuText.pas | 2 + 5 files changed, 368 insertions(+), 60 deletions(-) create mode 100644 Game/Code/Menu/UMenuButtonCollection.pas (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 28ba17e7..fc217dba 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -3,7 +3,7 @@ unit UMenu; interface uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, - UMenuInteract, UThemes; + UMenuInteract, UThemes, UMenuButtonCollection; type { Int16 = SmallInt;} @@ -18,12 +18,13 @@ type Button: array of TButton; Selects: array of TSelect; SelectsS: array of TSelectSlide; + ButtonCollection: Array of TButtonCollection; BackImg: TTexture; BackW: integer; BackH: integer; public Text: array of TText; - Static: array of TStatic; + Static: array of TStatic; mX: integer; // mouse X mY: integer; // mouse Y @@ -33,14 +34,20 @@ type 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 + //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; + //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic + procedure LoadFromTheme(const ThemeBasic: TThemeBasic); + + procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); + procedure AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); + // background procedure AddBackground(Name: string); @@ -70,6 +77,7 @@ type 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; + procedure AddButtonText(CustomButton: TButton; 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; @@ -113,7 +121,8 @@ type procedure SetAnimationProgress(Progress: real); virtual; - + function IsSelectable(Int: Cardinal): Boolean; + procedure InteractNext; virtual; procedure InteractCustom(CustomSwitch: integer); virtual; procedure InteractPrev; virtual; @@ -132,13 +141,14 @@ const iSelect = 1; iText = 2; iSelectS = 3; + iBCollectionChild = 5; // fBlack = 0; // fade type // fWhite = 1; implementation -uses UMain, UDrawTexture, UGraphic, UDisplay, UCovers, USkins; +uses UMain, UDrawTexture, UGraphic, UDisplay, UCovers, USkins, Dialogs; destructor TMenu.Destroy; begin @@ -157,7 +167,7 @@ begin //Set ButtonPos to Autoset Length ButtonPos := -1; end; - +{ constructor TMenu.Create(Back: String); begin inherited Create; @@ -183,7 +193,7 @@ begin BackImg.H := BackImg.H / H; BackW := W; BackH := H; -end; +end; } procedure TMenu.AddInteraction(Typ, Num: integer); var @@ -204,25 +214,67 @@ begin // set inactive OldNum := Interactions[Interaction].Num; OldTyp := Interactions[Interaction].Typ; + + NewNum := Interactions[Num].Num; + NewTyp := Interactions[Num].Typ; + case OldTyp of iButton: Button[OldNum].Selected := False; iSelect: Selects[OldNum].Selected := False; iText: Text[OldNum].Selected := False; iSelectS: SelectsS[OldNum].Selected := False; + //Button Collection Mod + iBCollectionChild: + begin + Button[OldNum].Selected := False; + + //Deselect Collection if Next Button is Not from Collection + if (NewTyp <> iButton) Or (Button[NewNum].Parent <> Button[OldNum].Parent) then + ButtonCollection[Button[OldNum].Parent-1].Selected := False; + end; 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; + + //Button Collection Mod + iBCollectionChild: + begin + Button[NewNum].Selected := True; + ButtonCollection[Button[NewNum].Parent-1].Selected := True; + end; end; end; +//---------------------- +//LoadFromTheme - Load BG, Texts, Statics and +//Button Collections from ThemeBasic +//---------------------- +procedure TMenu.LoadFromTheme(const ThemeBasic: TThemeBasic); +var + I: Integer; +begin + //Add Button Collections (Set Button CollectionsLength) + //Button Collections are Created when the first ChildButton is Created + PrepareButtonCollections(ThemeBasic.ButtonCollection); + + + //Add Background + AddBackground(ThemeBasic.Background.Tex); + + //Add Statics and Texts + for I := 0 to High(ThemeBasic.Static) do + AddStatic(ThemeBasic.Static[I]); + + for I := 0 to High(ThemeBasic.Text) do + AddText(ThemeBasic.Text[I]); +end; + procedure TMenu.AddBackground(Name: string); begin if Name <> '' then begin @@ -235,6 +287,84 @@ begin end; end; +//---------------------- +//PrepareButtonCollections: +//Add Button Collections (Set Button CollectionsLength) +//---------------------- +procedure TMenu.PrepareButtonCollections(const Collections: AThemeButtonCollection); +var + I: Integer; +begin + SetLength(ButtonCollection, Length(Collections)); + For I := 0 to High(ButtonCollection) do + AddButtonCollection(Collections[I], I); +end; + +//---------------------- +//AddButtonCollection: +//Create a Button Collection; +//---------------------- +procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); +var + BT, BTLen: Integer; +begin + if (Num > High(ButtonCollection)) then + exit; + + ButtonCollection[Num] := TButtonCollection.Create(Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.Tex), ThemeCollection.Style.Typ, true)); // use cache texture + + //Set Parent menu + ButtonCollection[Num].ScreenButton := @Self.Button; + + //Set Attributes + ButtonCollection[Num].FirstChild := ThemeCollection.FirstChild; + ButtonCollection[Num].CountChilds := ThemeCollection.ChildCount; + ButtonCollection[Num].Parent := Num + 1; + + //Set Style + ButtonCollection[Num].X := ThemeCollection.Style.X; + ButtonCollection[Num].Y := ThemeCollection.Style.Y; + ButtonCollection[Num].W := ThemeCollection.Style.W; + ButtonCollection[Num].H := ThemeCollection.Style.H; + ButtonCollection[Num].SelectColR := ThemeCollection.Style.ColR; + ButtonCollection[Num].SelectColG := ThemeCollection.Style.ColG; + ButtonCollection[Num].SelectColB := ThemeCollection.Style.ColB; + ButtonCollection[Num].SelectInt := ThemeCollection.Style.Int; + ButtonCollection[Num].DeselectColR := ThemeCollection.Style.DColR; + ButtonCollection[Num].DeselectColG := ThemeCollection.Style.DColG; + ButtonCollection[Num].DeselectColB := ThemeCollection.Style.DColB; + ButtonCollection[Num].DeselectInt := ThemeCollection.Style.DInt; + ButtonCollection[Num].Texture.TexX1 := 0; + ButtonCollection[Num].Texture.TexY1 := 0; + ButtonCollection[Num].Texture.TexX2 := 1; + ButtonCollection[Num].Texture.TexY2 := 1; + ButtonCollection[Num].SetSelect(false); + + ButtonCollection[Num].Reflection := ThemeCollection.Style.Reflection; + ButtonCollection[Num].Reflectionspacing := ThemeCollection.Style.ReflectionSpacing; + ButtonCollection[Num].DeSelectReflectionspacing := ThemeCollection.Style.DeSelectReflectionSpacing; + + ButtonCollection[Num].Z := ThemeCollection.Style.Z; + + //Some Things from ButtonFading + ButtonCollection[Num].SelectH := ThemeCollection.Style.SelectH; + ButtonCollection[Num].SelectW := ThemeCollection.Style.SelectW; + + ButtonCollection[Num].Fade := ThemeCollection.Style.Fade; + ButtonCollection[Num].FadeText := ThemeCollection.Style.FadeText; + ButtonCollection[Num].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex), ThemeCollection.Style.Typ, true); + ButtonCollection[Num].FadeTexPos := ThemeCollection.Style.FadeTexPos; + + + BTLen := Length(ThemeCollection.Style.Text); + for BT := 0 to BTLen-1 do begin + AddButtonText(ButtonCollection[Num], ThemeCollection.Style.Text[BT].X, ThemeCollection.Style.Text[BT].Y, + ThemeCollection.Style.Text[BT].ColR, ThemeCollection.Style.Text[BT].ColG, ThemeCollection.Style.Text[BT].ColB, + ThemeCollection.Style.Text[BT].Font, ThemeCollection.Style.Text[BT].Size, ThemeCollection.Style.Text[BT].Align, + ThemeCollection.Style.Text[BT].Text); + end; +end; + function TMenu.AddStatic(ThemeStatic: TThemeStatic): integer; begin Result := AddStatic(ThemeStatic.X, ThemeStatic.Y, ThemeStatic.W, ThemeStatic.H, ThemeStatic.Z, @@ -415,6 +545,20 @@ begin ThemeButton.Text[BT].Font, ThemeButton.Text[BT].Size, ThemeButton.Text[BT].Align, ThemeButton.Text[BT].Text); end; + + //BAutton Collection Mod + if (ThemeButton.Parent <> 0) then + begin + //If Collection Exists then Change Interaction to Child Button + if (@ButtonCollection[ThemeButton.Parent-1] <> nil) then + begin + Interactions[High(Interactions)].Typ := iBCollectionChild; + Button[Result].Visible := False; + Button[Result].Parent := ThemeButton.Parent; + if (ButtonCollection[ThemeButton.Parent-1].Fade) then + Button[Result].Texture.Alpha := 0; + end; + end; end; function TMenu.AddButton(X, Y, W, H: real; Name: String): integer; @@ -473,6 +617,10 @@ begin Button[Result].Reflectionspacing := ReflectionSpacing; Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing; + //Button Collection Mod + Button[Result].Parent := 0; + + // adds interaction AddInteraction(iButton, Result); Interaction := 0; @@ -527,6 +675,10 @@ begin for J := 0 to Length(Text) - 1 do Text[J].Draw; + // Draw all ButtonCollections + For J := 0 to High(ButtonCollection) do + ButtonCollection[J].Draw; + // Second, we draw all of our buttons for J := 0 to Length(Button) - 1 do Button[J].Draw; @@ -595,60 +747,68 @@ begin SetLength(WidgetsRect, MinNumber); end;} +function TMenu.IsSelectable(Int: Cardinal): Boolean; +begin + Result := True; + Case Interactions[Int].Typ of + //Button + iButton: Result := Button[Interactions[Int].Num].Visible and Button[Interactions[Int].Num].Selectable; + //Select + iSelect: Result := True; + //Select Slide + iSelectS: Result := SelectsS[Interactions[Int].Num].Visible; + + //ButtonCollection Child + iBCollectionChild: + Result := (ButtonCollection[Button[Interactions[Int].Num].Parent - 1].FirstChild - 1 = Int) AND ((Interactions[Interaction].Typ <> iBCollectionChild) OR (Button[Interactions[Interaction].Num].Parent <> Button[Interactions[Int].Num].Parent)); + end; +end; + procedure TMenu.InteractNext; var - Num: integer; - Typ: integer; - Again: boolean; + Int: Integer; begin - Again := true; + Int := Interaction; // 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 + repeat + Int := (Int + 1) Mod Length(Interactions); + + //If no Interaction is Selectable Simply Select Next + if (Int = Interaction) then + begin + Int := (Int + 1) Mod Length(Interactions); + Break; + end; + Until IsSelectable(Int); + + //Set Interaction + Interaction := Int; end; procedure TMenu.InteractPrev; var - Num: integer; - Typ: integer; - Again: boolean; + Int: Integer; begin - Again := true; + Int := Interaction; // 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 - + repeat + Int := Int - 1; + if Int = -1 then Int := High(Interactions); + + //If no Interaction is Selectable Simply Select Next + if (Int = Interaction) then + begin + Int := SelInteraction - 1; + if Int = -1 then Int := High(Interactions); + Break; + end; + Until IsSelectable(Int); + + //Set Interaction + Interaction := Int end; @@ -658,7 +818,9 @@ var Typ: integer; Again: boolean; begin - if num<0 then begin + //Code Commented atm, because it needs to be Rewritten + //it doesn't work with Button Collections + {then begin CustomSwitch:= CustomSwitch*(-1); Again := true; // change interaction as long as it's needed @@ -698,7 +860,7 @@ begin end; end; // case end; // while - end + end } end; @@ -746,6 +908,24 @@ begin end; end; +procedure TMenu.AddButtonText(CustomButton: TButton; AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); +var + Il: integer; +begin + with CustomButton 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; @@ -1114,6 +1294,28 @@ begin if Value <= High(SelectsS[Num].TextOptT) then SelectsS[Num].SelectedOption := Value; end; + //Button Collection Mod + iBCollectionChild: + begin + + //Select Next Button in Collection + For Num := 1 to High(Button) do + begin + Value := (Interaction + Num) Mod Length(Button); + if Value = 0 then + begin + InteractNext; + Break; + end; + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + //interact Next if there is Nothing to Change + else InteractNext; end; end; @@ -1141,7 +1343,45 @@ begin if Value >= 0 then SelectsS[Num].SelectedOption := Value; end; - end + //Button Collection Mod + iBCollectionChild: + begin + //Select Prev Button in Collection + For Num := High(Button) downto 1 do + begin + Value := (Interaction + Num) Mod Length(Button); + if Value = High(Button) then + begin + InteractPrev; + Break; + end; + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + //interact Prev if there is Nothing to Change + else + begin + InteractPrev; + //If ButtonCollection with more than 1 Entry then Select Last Entry + if (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then + begin + //Select Last Child + For Num := High(Button) downto 1 do + begin + Value := (Interaction + Num) Mod Length(Button); + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + end; + end; end; procedure TMenu.AddBox(X, Y, W, H: real); diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index 34d45083..fde808e2 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -4,8 +4,9 @@ interface uses TextGL, UTexture, OpenGL12, UMenuText; type + CButton = class of TButton; TButton = class - private + protected SelectBool: Boolean; FadeProgress: Real; @@ -14,9 +15,10 @@ type DeSelectW: Real; DeSelectH: Real; PosX: Real; - PosY: Real; - + PosY: Real; + constructor Create(); overload; + public Text: Array of TText; Texture: TTexture; // Button Screen position and size @@ -40,6 +42,9 @@ type Selectable: boolean; + //No of the Parent Collection, 0 if in no Collection + Parent: Byte; + SelectColR: real; SelectColG: real; SelectColB: real; @@ -60,7 +65,7 @@ type procedure SetW(Value: real); procedure SetH(Value: real); - procedure SetSelect(Value: Boolean); + procedure SetSelect(Value: Boolean); virtual; property X: real read PosX write SetX; property Y: real read PosY write SetY; property Z: real read Texture.z write Texture.z; @@ -68,7 +73,7 @@ type property H: real read DeSelectH write SetH; property Selected: Boolean read SelectBool write SetSelect; - procedure Draw; + procedure Draw; virtual; constructor Create(Textura: TTexture); overload; destructor Destroy; override; @@ -250,6 +255,8 @@ begin PosX := 0; PosY := 0; + + Parent := 0; end; // ***** Public methods ****** // diff --git a/Game/Code/Menu/UMenuButtonCollection.pas b/Game/Code/Menu/UMenuButtonCollection.pas new file mode 100644 index 00000000..66ac70fc --- /dev/null +++ b/Game/Code/Menu/UMenuButtonCollection.pas @@ -0,0 +1,59 @@ +unit UMenuButtonCollection; + +interface +uses UMenuButton; + +type + //---------------- + //TButtonCollection + //No Extra Attributes or Functions ATM + //---------------- + AButton = Array of TButton; + PAButton = ^AButton; + TButtonCollection = class(TButton) + //num of the First Button, that can be Selected + FirstChild: Byte; + CountChilds: Byte; + + ScreenButton: PAButton; + + procedure SetSelect(Value : Boolean); override; + procedure Draw; override; + end; + +implementation + +procedure TButtonCollection.SetSelect(Value : Boolean); +var I: Integer; +begin + inherited; + + //Set Visible for Every Button that is a Child of this ButtonCollection + if (Not Fade) then + For I := 0 to High(ScreenButton^) do + if (ScreenButton^[I].Parent = Parent) then + ScreenButton^[I].Visible := Value; +end; + +procedure TButtonCollection.Draw; +var I: Integer; +begin + inherited; + //If fading is activated, Fade Child Buttons + if (Fade) then + begin + For I := 0 to High(ScreenButton^) do + if (ScreenButton^[I].Parent = Parent) then + begin + if (FadeProgress < 0.5) then + ScreenButton^[I].Visible := SelectBool + else + ScreenButton^[I].Texture.Alpha := (FadeProgress-0.666)*3; + //ScreenButton^[I].Text[0]. + end; + end; +end; + + + +end. diff --git a/Game/Code/Menu/UMenuInteract.pas b/Game/Code/Menu/UMenuInteract.pas index 3f2960b8..43249e3e 100644 --- a/Game/Code/Menu/UMenuInteract.pas +++ b/Game/Code/Menu/UMenuInteract.pas @@ -4,7 +4,7 @@ interface type TInteract = record // for moving thru menu - Typ: integer; // 0 - button, 1 - select + Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child Num: integer; // number of this item in proper list like buttons, selects end; diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index abf3784c..4cb48cad 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -162,6 +162,7 @@ begin //Look for Break before the Break if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) AND (NextPos-LastPos > 1) then begin + isBreak := False; //Not the First word after Break, so we don't have to break within a word if (FirstWord > 1) then begin @@ -175,6 +176,7 @@ begin end; end; + isBreak := True; //Add Break from Text AddBreak(LastBreak, NextPos); end -- cgit v1.2.3 From cc06446d0a651113083478fda94dfaa9a25d1d7e Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 29 Apr 2007 18:29:42 +0000 Subject: Commented some Debuging Outputs in ULog Fixed a Bug in ButtonCollection that causes a Crash when UpButton is Pressed at the Last Button Added ShortCut E in MainMenu for Editor git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@150 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index fc217dba..c30b5c5c 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -1367,7 +1367,7 @@ begin begin InteractPrev; //If ButtonCollection with more than 1 Entry then Select Last Entry - if (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then + if (Button[Interactions[Interaction].Num].Parent <> 0) AND (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then begin //Select Last Child For Num := High(Button) downto 1 do -- cgit v1.2.3 From 5737662e749229ef0631e3731858a5bf013c78eb Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 30 Apr 2007 12:30:35 +0000 Subject: Added ability to make buttons invisible(and also unselectable) in Theme. Visible = 0 Useful for f.e. the Exit Button from MainScreen Fixed a bug in PartyNewRoundScreen that causes a crash when an Arrow Button is pressed git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@152 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index c30b5c5c..4ad8270a 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -528,6 +528,9 @@ begin Button[Result].Z := ThemeButton.Z; + //Button Visibility + Button[Result].Visible := ThemeButton.Visible; + //Some Things from ButtonFading Button[Result].SelectH := ThemeButton.SelectH; Button[Result].SelectW := ThemeButton.SelectW; @@ -574,7 +577,7 @@ end; 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 + //SetLength is used once to reduce Memory usement if (ButtonPos <> -1) then begin Result := ButtonPos; -- cgit v1.2.3 From 5bf0ebf274fef28811ab952338bd261bd1dd0fa8 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 00:19:52 +0000 Subject: added "popups" to ask for confirmation when leaving party mode or game or to display messages (like minor errors) still ugly, needs some theme work git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@157 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 40 +++++++++++++++++++++++++++++++++------- Game/Code/Menu/UMenu.pas | 19 +++++++++++++++---- 2 files changed, 48 insertions(+), 11 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 19266414..428cc6c7 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,12 +2,15 @@ unit UDisplay; interface -uses Windows, SDL, UMenu, OpenGL12, SysUtils, dialogs; +uses Windows, SDL, UMenu, OpenGL12, SysUtils; type TDisplay = class ActualScreen: PMenu; NextScreen: PMenu; + //popup hack + NextScreenWithCheck: Pmenu; + CheckOK: Boolean; h_DC: HDC; h_RC: HGLRC; @@ -45,6 +48,11 @@ var i: integer; begin inherited Create; + //popup hack + CheckOK:=False; + NextScreen:=NIL; + NextScreenWithCheck:=NIL; + // fade mod myfade:=0; @@ -75,10 +83,6 @@ begin canFade:=False; end; FreeMem(pTexData); - if not canFade then begin - showmessage('Fehler beim Initialisieren der Fading-Textur... Fading deaktiviert'); - doFade:=False; - end // end end; @@ -120,9 +124,26 @@ begin if S = 2 then TimeSkip := 0 else; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); + //popup hack + // check was successful... move on + if CheckOK then + if assigned (NextScreenWithCheck)then + begin + NextScreen:=NextScreenWithCheck; + NextScreenWithCheck := NIL; + CheckOk:=False; + end + else + Result:=False; + //end popup hack + // ActualScreen.SetAnimationProgress(1); if not assigned (NextScreen) then begin - Result := ActualScreen.Draw; + ActualScreen.Draw; + //popup mod + if ScreenPopupError <> NIL then if ScreenPopupError.Visible then ScreenPopupError.Draw else + if ScreenPopupCheck <> NIL then if ScreenPopupCheck.Visible then ScreenPopupCheck.Draw; + //popup end // fade mod myfade:=0; if (Ini.ScreenFade=1) and canFade then @@ -133,6 +154,11 @@ begin end else begin + // check if we had an initialization error (canfade=false, dofade=true) + if doFade and not canFade then begin + doFade:=False; //disable fading + ScreenPopupError.ShowPopup(['Error initializing','fade texture','','fading','disabled']); //show error message + end; if doFade and canFade then begin // fade mod @@ -146,7 +172,7 @@ begin if glGetError <> GL_NO_ERROR then begin canFade := False; - showmessage('Fehler beim Kopieren der Fade-Textur... Fading deaktiviert'); + ScreenPopupError.ShowPopup(['Error copying','fade texture','','fading','disabled']); //show error message end; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); NextScreen.onShow; diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 4ad8270a..c9d3c726 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -12,7 +12,7 @@ type TMenu = class protected ButtonPos: Integer; - + Interactions: array of TInteract; SelInteraction: integer; Button: array of TButton; @@ -29,7 +29,7 @@ type mY: integer; // mouse Y Fade: integer; // fade type - ShowFinish: boolean; // true if there is no fade + ShowFinish: boolean; // true if there is no fade destructor Destroy; override; @@ -47,7 +47,7 @@ type procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); procedure AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); - + // background procedure AddBackground(Name: string); @@ -68,7 +68,7 @@ type function AddText(X, Y, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): 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 + Procedure SetButtonLength(Length: Cardinal); //Function that Set Length of Button Array in one Step instead of register new Memory for every 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; @@ -107,6 +107,8 @@ type // function AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16; // procedure ClearWidgets(MinNumber : Int16); procedure FadeTo(Screen: PMenu); + //popup hack + procedure CheckFadeTo(Screen: PMenu; msg: String); function DrawBG: boolean; virtual; function DrawFG: boolean; virtual; @@ -873,6 +875,15 @@ begin Display.NextScreen := Screen; end; +//popup hack +procedure TMenu.CheckFadeTo(Screen: PMenu; msg: String); +begin + Display.Fade := 0; + Display.NextScreenWithCheck := Screen; + Display.CheckOK:=False; + ScreenPopupCheck.ShowPopup(msg); +end; + procedure TMenu.AddButtonText(AddX, AddY: real; AddText: string); begin AddButtonText(AddX, AddY, 1, 1, 1, AddText); -- cgit v1.2.3 From c7db744c1dcbafb38f25a5cb005219faf16134b8 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 15:34:36 +0000 Subject: minor changes to PopUp code and to related parts of themes git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@160 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 428cc6c7..e6c0c4f0 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -157,7 +157,7 @@ begin // check if we had an initialization error (canfade=false, dofade=true) if doFade and not canFade then begin doFade:=False; //disable fading - ScreenPopupError.ShowPopup(['Error initializing','fade texture','','fading','disabled']); //show error message + ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message end; if doFade and canFade then begin @@ -169,10 +169,10 @@ begin ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); - if glGetError <> GL_NO_ERROR then + if glGetError = GL_NO_ERROR then begin canFade := False; - ScreenPopupError.ShowPopup(['Error copying','fade texture','','fading','disabled']); //show error message + ScreenPopupError.ShowPopup('Error copying\nfade texture\nfading\ndisabled'); //show error message end; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); NextScreen.onShow; -- cgit v1.2.3 From 0ef472e08a64e5f9b8c33d6b0206a559a56c71ba Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 16:14:05 +0000 Subject: screen fades to black at game end, when fading is enabled git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@161 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index e6c0c4f0..ae7f901d 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -8,6 +8,9 @@ type TDisplay = class ActualScreen: PMenu; NextScreen: PMenu; + + //fade-to-black-hack + BlackScreen: Boolean; //popup hack NextScreenWithCheck: Pmenu; CheckOK: Boolean; @@ -36,8 +39,6 @@ type var Display: TDisplay; -// ActualScreen: PMenu; -// NextScreen: PMenu; implementation @@ -52,6 +53,7 @@ begin CheckOK:=False; NextScreen:=NIL; NextScreenWithCheck:=NIL; + BlackScreen:=False; // fade mod myfade:=0; @@ -134,11 +136,11 @@ begin CheckOk:=False; end else - Result:=False; + BlackScreen:=True; // end of game - fade to black before exit //end popup hack // ActualScreen.SetAnimationProgress(1); - if not assigned (NextScreen) then begin + if (not assigned (NextScreen)) and (not BlackScreen) then begin ActualScreen.Draw; //popup mod if ScreenPopupError <> NIL then if ScreenPopupError.Visible then ScreenPopupError.Draw else @@ -169,13 +171,15 @@ begin ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); - if glGetError = GL_NO_ERROR then + if glGetError <> GL_NO_ERROR then begin canFade := False; ScreenPopupError.ShowPopup('Error copying\nfade texture\nfading\ndisabled'); //show error message end; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); - NextScreen.onShow; + // blackscreen-hack + if not BlackScreen then + NextScreen.onShow; lastTime:=GetTickCount; if (S=2) or (Screens = 1) then myfade:=myfade+1; @@ -197,7 +201,13 @@ begin // ActualScreen.SetAnimationProgress(Fade-1); // nop? - NextScreen.Draw; // draw next screen + // blackscreen-hack + if not BlackScreen then + NextScreen.Draw // draw next screen + else begin + glClearColor(0, 0, 0 , 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + end; // and draw old screen over it... slowly fading out myfade2:=(myfade*myfade)/10000; @@ -215,7 +225,11 @@ begin glDisable(GL_BLEND); glDisable(GL_TEXTURE_2D); end - else NextScreen.OnShow; + else + // blackscreen hack + if not BlackScreen then + NextScreen.OnShow; + if (myfade > 40) or (not doFade) or (not canFade) then begin // fade out complete... @@ -224,8 +238,13 @@ begin ActualScreen.ShowFinish:=False; ActualScreen:=NextScreen; NextScreen := nil; - ActualScreen.onShowFinish; - ActualScreen.ShowFinish := true; + if not blackscreen then + begin + ActualScreen.onShowFinish; + ActualScreen.ShowFinish := true; + end + else + Result:=False; // end of fade mod end; end; // if -- cgit v1.2.3 From f38292d6da93cf20c075e4ed74c377819af88091 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 20:05:07 +0000 Subject: more explanatory error message in case copying the fade texture fails git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@162 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index ae7f901d..d1d3038d 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -104,6 +104,8 @@ var // fade mod myFade2: Real; currentTime: Cardinal; + glError: glEnum; + glErrorStr: String; // end begin Result := True; @@ -171,10 +173,20 @@ begin ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); - if glGetError <> GL_NO_ERROR then + glError:=glGetError; + if glError <> GL_NO_ERROR then begin canFade := False; - ScreenPopupError.ShowPopup('Error copying\nfade texture\nfading\ndisabled'); //show error message + case glError of + GL_INVALID_ENUM: glErrorStr:='INVALID_ENUM'; + GL_INVALID_VALUE: glErrorStr:='INVALID_VALUE'; + GL_INVALID_OPERATION: glErrorStr:='INVALID_OPERATION'; + GL_STACK_OVERFLOW: glErrorStr:='STACK_OVERFLOW'; + GL_STACK_UNDERFLOW: glErrorStr:='STACK_UNDERFLOW'; + GL_OUT_OF_MEMORY: glErrorStr:='OUT_OF_MEMORY'; + else glErrorStr:='unknown error'; + end; + ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message end; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); // blackscreen-hack -- cgit v1.2.3 From 4c6e44e0c1fced2b2d2edf8640fe0652b94f2811 Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 3 May 2007 23:42:02 +0000 Subject: reflections of buttoncollection nur fade out more realisticly (need your opinion on that) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@167 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuButton.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index fde808e2..87ebbb89 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -434,7 +434,7 @@ begin //Draw glBegin(GL_QUADS);//Top Left - glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glColor4f(ColR * Int, ColG * Int, ColB * Int, (Alpha-0.3)*FadeProgress*FadeProgress*FadeProgress); glTexCoord2f(TexX1*TexW, TexY2*TexH); glVertex3f(x, y+h*scaleH+ Spacing, z); @@ -450,7 +450,7 @@ begin glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); //Top Right - glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glColor4f(ColR * Int, ColG * Int, ColB * Int, (Alpha-0.3)*FadeProgress*FadeProgress*FadeProgress); glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); glEnd; -- cgit v1.2.3 From 188929aca69791bc755db6562582acfcf10df2e5 Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 4 May 2007 16:21:40 +0000 Subject: well... changed Button Reflections back to old behavior git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@173 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuButton.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index 87ebbb89..fde808e2 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -434,7 +434,7 @@ begin //Draw glBegin(GL_QUADS);//Top Left - glColor4f(ColR * Int, ColG * Int, ColB * Int, (Alpha-0.3)*FadeProgress*FadeProgress*FadeProgress); + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); glTexCoord2f(TexX1*TexW, TexY2*TexH); glVertex3f(x, y+h*scaleH+ Spacing, z); @@ -450,7 +450,7 @@ begin glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); //Top Right - glColor4f(ColR * Int, ColG * Int, ColB * Int, (Alpha-0.3)*FadeProgress*FadeProgress*FadeProgress); + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); glTexCoord2f(TexX2*TexW, TexY2*TexH); glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); glEnd; -- cgit v1.2.3 From 9b29c5321e423fbe6ba29f32bdcf8f2c83828e92 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 16 May 2007 18:18:37 +0000 Subject: Fixed text position of SelectSlide when High is not 70 Added ability to change Z and Textsize from SelectSlide Use new abilitys to finish SongMenu Screen in Deluxe Theme git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@196 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 7 ++++++- Game/Code/Menu/UMenuSelectSlide.pas | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index c9d3c726..d7c919ee 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -1102,6 +1102,11 @@ begin for SO := 0 to High(Values) do AddSelectSlideOption(Values[SO]); + SelectsS[High(SelectsS)].Text.Size := ThemeSelectS.TextSize; + + SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z; + SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z; + //Generate Lines SelectsS[High(SelectsS)].GenLines; @@ -1153,7 +1158,7 @@ begin SelectsS[S].SBGDInt := SBGDInt; SelectsS[S].Text.X := X + 20; - SelectsS[S].Text.Y := Y + 20; + SelectsS[S].Text.Y := Y + (SelectsS[S].TextureSBG.H / 2) - 15; SelectsS[S].Text.Text := Caption; SelectsS[S].Text.Size := 10; SelectsS[S].Text.Visible := true; diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index 9885acc0..0149ea2b 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -315,7 +315,7 @@ begin //TextOpt[I] := TextOpt[0]; TextOpt[I] := TText.Create; - TextOpt[I].Size := 10; + TextOpt[I].Size := Text.Size; //TextOpt[I].Align := 1; TextOpt[I].Align := 0; TextOpt[I].Visible := True; @@ -328,7 +328,7 @@ begin //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; + TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; //Better Look with 2 Options if (Lines=2) AND (Length(TextOptT)= 2) then -- cgit v1.2.3 From 4a731514163a14bd3a9222d99707880b56772663 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Wed, 16 May 2007 19:19:35 +0000 Subject: all SongFile Loading and Saving procedures moved to UFiles. Added Some Tolerance in Song File Loading and Song Header Loading. Fix: Programm doesn't Crash anymore when a coruppted Song is loaded for Singing or Editing. Now Jump back to SongScreen and show an Error Message. Also Party Mode is not Interupted, a new Song will be selected automatically. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@197 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index d1d3038d..abaedfa8 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -42,7 +42,7 @@ var implementation -uses UGraphic, UTime, Graphics, Jpeg, UPliki, UTexture, UIni; +uses UGraphic, UTime, Graphics, Jpeg, UFiles, UTexture, UIni; constructor TDisplay.Create; var i: integer; @@ -137,8 +137,8 @@ begin NextScreenWithCheck := NIL; CheckOk:=False; end - else - BlackScreen:=True; // end of game - fade to black before exit + else + BlackScreen:=True; // end of game - fade to black before exit //end popup hack // ActualScreen.SetAnimationProgress(1); -- cgit v1.2.3 From 4f7f9544e5dbf992599865243aee4c6e2a5b5f8e Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 18 May 2007 10:55:28 +0000 Subject: Added ability to take a Screenshot with the Print Key from every Screen in the Game git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@219 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index abaedfa8..f95a73e3 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -300,7 +300,6 @@ begin Jpeg.Assign(Bitmap); Bitmap.Free; Jpeg.CompressionQuality := 95;//90; - ForceDirectories(ScreenshotsPath); Jpeg.SaveToFile(FileName); Jpeg.Free; end; @@ -317,7 +316,7 @@ begin for Num := 1 to 9999 do begin FileName := IntToStr(Num); while Length(FileName) < 4 do FileName := '0' + FileName; - FileName := {ScreenshotsPath + }'screenshot' + FileName + '.BMP'; + FileName := ScreenshotsPath + FileName + '.BMP'; if not FileExists(FileName) then break end; @@ -331,8 +330,8 @@ begin //Schreiben der Bitmap-Informationen FileInfo.biSize := SizeOf(BITMAPINFOHEADER); - FileInfo.biWidth := ScreenH; - FileInfo.biHeight := ScreenW; + FileInfo.biWidth := ScreenW; + FileInfo.biHeight := ScreenH; FileInfo.biPlanes := 1; FileInfo.biBitCount := 32; FileInfo.biSizeImage := FileInfo.biWidth*FileInfo.biHeight*(FileInfo.biBitCount div 8); -- cgit v1.2.3 From 7ee656d31524f4820b362a31fc6bc1fe0988c0dc Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 28 May 2007 18:58:08 +0000 Subject: Changed Text Spacing for a better look SelectLoadingAnimation in ScreenAdvanced hidden, because it is useless atm Changed Theme to fit the new Textspacing Fixed some Language entrys git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@232 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 4cb48cad..5b035f51 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -276,7 +276,10 @@ begin SetFontPos(X2, Y2); glPrint(PChar(Text2)); - Y2 := Y2 + Size * 1.7; + {if Size >= 10 then + Y2 := Y2 + Size * 2.8 + else} + Y2 := Y2 + Size * 2.15; end; SetFontStyle(0); // reset to default -- cgit v1.2.3 From 0bb302b56187c6435ae78bee7901765dbf72e89d Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Mon, 28 May 2007 19:58:06 +0000 Subject: New spacing for Font type 1 git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@236 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuText.pas | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 5b035f51..69ece02f 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -279,6 +279,9 @@ begin {if Size >= 10 then Y2 := Y2 + Size * 2.8 else} + if (Style = 1) then + Y2 := Y2 + Size * 2.8 + else Y2 := Y2 + Size * 2.15; end; SetFontStyle(0); // reset to default -- cgit v1.2.3 From dc72a49b4c680fe6698b831a203a9b00e476d562 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Fri, 1 Jun 2007 17:23:59 +0000 Subject: Fixed a Memory Bug in UMenuSelectSlide that causes memory that is not in use anymore is not freeed when the Attributes of a SelectSlide are Updated git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@240 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuSelectSlide.pas | 43 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index 0149ea2b..f18b45cd 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -308,33 +308,34 @@ begin if (Lines <= 0) then Lines := 1; + //Free old Space used by Texts + For I := low(TextOpt) to high(TextOpt) do + TextOpt[I].Free; + setLength (TextOpt, Lines); for I := low(TextOpt) to high(TextOpt) do begin + TextOpt[I] := TText.Create; + TextOpt[I].Size := Text.Size; + //TextOpt[I].Align := 1; + TextOpt[I].Align := 0; + TextOpt[I].Visible := True; - //TextOpt[I] := TextOpt[0]; - TextOpt[I] := TText.Create; - TextOpt[I].Size := Text.Size; - //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 + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; - - //Better Look with 2 Options - if (Lines=2) AND (Length(TextOptT)= 2) then - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I; + 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 + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; + + //Better Look with 2 Options + if (Lines=2) AND (Length(TextOptT)= 2) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I; end; - //TextOpt[I] := TextOpt[0]; end; end. -- cgit v1.2.3 From 141878175d76d013be3ec8fb9fd0a58dc9b0d3eb Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 9 Jun 2007 10:10:25 +0000 Subject: Added Preview Volume and Fading to Sound Options Changed Themes to Fit these changes Updated Language Files Some fixes in SelectSlide git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@251 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuSelectSlide.pas | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index f18b45cd..c1ccad6d 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -291,8 +291,8 @@ var maxlength: Real; I: Integer; begin - SetFontStyle(TextOpt[0].Style); - SetFontSize(TextOpt[0].Size); + SetFontStyle(0{Text.Style}); + SetFontSize(Text.Size); maxlength := 0; for I := low(TextOptT) to high (TextOptT) do @@ -329,7 +329,11 @@ begin //Generate Positions //TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * (I + 0.5); - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I; + if (I <> High(TextOpt)) OR (High(TextOpt) = 0) OR (Length(TextOptT) = Lines) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I + else + TextOpt[I].X := TextureSBG.X + TextureSBG.W - maxlength; + TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; //Better Look with 2 Options -- cgit v1.2.3 From 5f45fd926da919d8057dfcca4101dc305bd230df Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Thu, 14 Jun 2007 13:08:54 +0000 Subject: Added Text Fading to ButtonCollection git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@262 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 4 ++++ Game/Code/Menu/UMenuButtonCollection.pas | 15 ++++++++++++--- Game/Code/Menu/UMenuText.pas | 4 +++- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index d7c919ee..309e199a 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -559,6 +559,10 @@ begin begin Interactions[High(Interactions)].Typ := iBCollectionChild; Button[Result].Visible := False; + + for BT := 0 to BTLen-1 do + Button[Result].Text[BT].Alpha := 0; + Button[Result].Parent := ThemeButton.Parent; if (ButtonCollection[ThemeButton.Parent-1].Fade) then Button[Result].Texture.Alpha := 0; diff --git a/Game/Code/Menu/UMenuButtonCollection.pas b/Game/Code/Menu/UMenuButtonCollection.pas index 66ac70fc..5c9045a7 100644 --- a/Game/Code/Menu/UMenuButtonCollection.pas +++ b/Game/Code/Menu/UMenuButtonCollection.pas @@ -36,7 +36,7 @@ begin end; procedure TButtonCollection.Draw; -var I: Integer; +var I, J: Integer; begin inherited; //If fading is activated, Fade Child Buttons @@ -46,10 +46,19 @@ begin if (ScreenButton^[I].Parent = Parent) then begin if (FadeProgress < 0.5) then - ScreenButton^[I].Visible := SelectBool + begin + ScreenButton^[I].Visible := SelectBool; + + For J := 0 to High(ScreenButton^[I].Text) do + ScreenButton^[I].Text[J].Visible := SelectBool; + end else + begin ScreenButton^[I].Texture.Alpha := (FadeProgress-0.666)*3; - //ScreenButton^[I].Text[0]. + + For J := 0 to High(ScreenButton^[I].Text) do + ScreenButton^[I].Text[J].Alpha := (FadeProgress-0.666)*3; + end; end; end; end; diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 69ece02f..4713962e 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -23,6 +23,7 @@ type ColR: real; ColG: real; ColB: real; + Alpha: real; Int: real; Style: integer; Visible: boolean; @@ -225,7 +226,7 @@ begin SetFontStyle(Style); SetFontSize(Size); SetFontItalic(False); - glColor3f(ColR*Int, ColG*Int, ColB*Int); + glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); //If Selected Set Blink... if SelectBool then @@ -303,6 +304,7 @@ end; constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); begin inherited Create; + Alpha := 1; X := ParX; Y := ParY; W := ParW; -- cgit v1.2.3 From dd3cc6f8e84f03f626a88741474412d36e4d18ac Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 8 Jul 2007 12:00:15 +0000 Subject: Improved Error Logging and Benchmark: Write US Version, date and time to files. Added better Commandline Parameter Interpreter: More than one parameter can be used at the same time Many new, useful farameters: e.g. No error logging, Resolution change, FullScreen, DualScreen Mode, other Config File, other Score File and SongPath git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@274 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index f95a73e3..223a7615 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -111,8 +111,8 @@ begin Result := True; Col := 1; - if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then - Col := 0; + {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then + Col := 0; } glClearColor(Col, Col, Col , 0); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); -- cgit v1.2.3 From 002bda99cfc259407bd924619302671bc5cd193a Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 8 Jul 2007 12:08:51 +0000 Subject: Fixed a bug in UDisplay that causes the game to crash on exit in Dualscreen Mode. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@275 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 223a7615..92693a41 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -244,7 +244,7 @@ begin - if (myfade > 40) or (not doFade) or (not canFade) then begin // fade out complete... + if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then begin // fade out complete... myFade:=0; ActualScreen.onHide; ActualScreen.ShowFinish:=False; @@ -256,7 +256,10 @@ begin ActualScreen.ShowFinish := true; end else + begin Result:=False; + Break; + end; // end of fade mod end; end; // if -- cgit v1.2.3 From 7bfc5ef4301caf4d3841c7741af5c8409fe0b175 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sun, 8 Jul 2007 13:20:16 +0000 Subject: Add Debug OSD with FPS and RSpeed Will be extended in further Releases with some error messages git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@278 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 73 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 92693a41..70e678fb 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -28,6 +28,14 @@ type pTex : array[1..2] of glUInt; // end + //FPS Counter + FPSCounter: Cardinal; + LastFPS: Cardinal; + NextFPSSwap:Cardinal; + + //For Debug OSD + OSD_LastError: String; + function Draw: Boolean; procedure PrintScreen; constructor Create; @@ -35,6 +43,8 @@ type destructor Destroy; // end procedure ScreenShot; + + procedure DrawDebugInformation; end; var @@ -42,7 +52,7 @@ var implementation -uses UGraphic, UTime, Graphics, Jpeg, UFiles, UTexture, UIni; +uses UGraphic, UTime, Graphics, Jpeg, UFiles, UTexture, UIni, TextGL, UCommandLine; constructor TDisplay.Create; var i: integer; @@ -86,6 +96,9 @@ begin end; FreeMem(pTexData); // end + + //Set LastError for OSD to No Error + OSD_LastError := 'No Errors'; end; // fade mod @@ -243,7 +256,6 @@ begin NextScreen.OnShow; - if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then begin // fade out complete... myFade:=0; ActualScreen.onHide; @@ -263,6 +275,11 @@ begin // end of fade mod end; end; // if + + //Draw OSD only on first Screen if Debug Mode is enabled + if ((Ini.Debug = 1) OR (Params.Debug)) AND (S=1) then + DrawDebugInformation; + end; // for // SwapBuffers(h_DC); end; @@ -365,5 +382,57 @@ begin end; end; +//------------ +// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen +//------------ +procedure TDisplay.DrawDebugInformation; +var Ticks: Cardinal; +begin + //Some White Background for information + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glColor4f(1, 1, 1, 0.5); + glBegin(GL_QUADS); + glVertex2f(690, 44); + glVertex2f(690, 0); + glVertex2f(800, 0); + glVertex2f(800, 44); + glEnd; + glDisable(GL_BLEND); + + //Set Font Specs + SetFontStyle(0); + SetFontSize(7); + SetFontItalic(False); + glColor4f(0, 0, 0, 1); + + //Calculate FPS + Ticks := GetTickCount; + if (Ticks >= NextFPSSwap) then + begin + LastFPS := FPSCounter * 4; + FPSCounter := 0; + NextFPSSwap := Ticks + 250; + end; + + Inc(FPSCounter); + + //Draw Text + + //FPS + SetFontPos(695, 0); + glPrint (PChar('FPS: ' + InttoStr(LastFPS))); + + //RSpeed + SetFontPos(695, 13); + glPrint (PChar('RSpeed: ' + InttoStr(Round(1000 * TimeMid)))); + + //LastError + SetFontPos(695, 26); + glColor4f(1, 0, 0, 1); + glPrint (PChar(OSD_LastError)); + + glColor4f(1, 1, 1, 1); +end; end. -- cgit v1.2.3 From b9f7f03201214e97feebb101e3e2c0fd257353fc Mon Sep 17 00:00:00 2001 From: b1indy Date: Sun, 22 Jul 2007 14:07:29 +0000 Subject: fixed a minor bug in the reflection code that caused some reflections to be incorrectly drawn git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@316 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuStatic.pas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas index 2a5e1e93..41d5046f 100644 --- a/Game/Code/Menu/UMenuStatic.pas +++ b/Game/Code/Menu/UMenuStatic.pas @@ -52,13 +52,13 @@ begin //Bottom Left glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX1*TexW, 0.5); + glTexCoord2f(TexX1*TexW, 0.5*TexH); glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Bottom Right glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX2*TexW, 0.5); + glTexCoord2f(TexX2*TexW, 0.5*TexH); glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Top Right @@ -68,7 +68,7 @@ begin glEnd; glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); end; end; -- cgit v1.2.3 From 210eeef171f0842a52e1a27008b4a7be41c50ee8 Mon Sep 17 00:00:00 2001 From: b1indy Date: Sun, 22 Jul 2007 14:40:26 +0000 Subject: again some fixes in reflection code for buttons and statics git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@318 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuButton.pas | 6 +++--- Game/Code/Menu/UMenuStatic.pas | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index fde808e2..919a18c9 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -418,7 +418,7 @@ begin Spacing := Reflectionspacing else Spacing := DeSelectReflectionspacing; - + with Texture do begin //Bind Tex and GL Attributes @@ -440,13 +440,13 @@ begin //Bottom Left glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX1*TexW, {TexY1*TexH*}0.5); + glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); //Bottom Right glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX2*TexW, {TexY1*TexH*}0.5); + glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); //Top Right diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas index 41d5046f..5f19fbf3 100644 --- a/Game/Code/Menu/UMenuStatic.pas +++ b/Game/Code/Menu/UMenuStatic.pas @@ -52,13 +52,13 @@ begin //Bottom Left glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX1*TexW, 0.5*TexH); + glTexCoord2f(TexX1*TexW, 0.5*TexH+TexY1); glVertex3f(x, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Bottom Right glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX2*TexW, 0.5*TexH); + glTexCoord2f(TexX2*TexW, 0.5*TexH+TexY1); glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Reflectionspacing, z); //Top Right -- cgit v1.2.3 From 69c42b2bde3146a61d4b1e8e1cbedfd7163b1c60 Mon Sep 17 00:00:00 2001 From: b1indy Date: Sun, 2 Sep 2007 21:06:08 +0000 Subject: finished stuff for colorized transparent textures with statics (credits to mog, who started it) still to do: same thing with buttons and maybe everything else ;) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@363 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 309e199a..24af3e1d 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -3,7 +3,7 @@ unit UMenu; interface uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, - UMenuInteract, UThemes, UMenuButtonCollection; + UMenuInteract, UThemes, UMenuButtonCollection, Math; type { Int16 = SmallInt;} @@ -432,13 +432,26 @@ 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; Reflection: Boolean; ReflectionSpacing: Real): integer; var StatNum: integer; + TempR, TempG, TempB: Cardinal; + TempCol: Cardinal; 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 + +// colorize hack +if Typ='Colorized' then +begin + TempR:=floor(255*ColR); + TempG:=floor(255*ColG); + TempB:=floor(255*ColB); + // give encoded color to loadtexture + Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR shl 8) or TempG) shl 8)or TempB))); +end +else + 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 @@ -447,9 +460,11 @@ Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format) 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; + if Typ <> 'Colorized' then begin + Static[StatNum].Texture.ColR := ColR; + Static[StatNum].Texture.ColG := ColG; + Static[StatNum].Texture.ColB := ColB; + end; Static[StatNum].Texture.TexX1 := TexX1; Static[StatNum].Texture.TexY1 := TexY1; Static[StatNum].Texture.TexX2 := TexX2; -- cgit v1.2.3 From d5ebad3a661194459da1b134978ed353e46c9b72 Mon Sep 17 00:00:00 2001 From: b1indy Date: Sun, 2 Sep 2007 23:45:33 +0000 Subject: now buttons can also have transparent colorized textures POC-Pic: http://imageshock.eu/img/colorizedbuttons-ao81.jpg git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@365 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 83 +++++++++++++++++++++++++++++++-------- Game/Code/Menu/UMenuButton.pas | 88 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 149 insertions(+), 22 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 24af3e1d..0fb1614f 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -309,10 +309,28 @@ end; procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); var BT, BTLen: Integer; + TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; + begin if (Num > High(ButtonCollection)) then exit; +// colorize hack +if ThemeCollection.Style.Typ='Colorized' then +begin + TempR:=floor(255*ThemeCollection.Style.ColR); + TempG:=floor(255*ThemeCollection.Style.ColG); + TempB:=floor(255*ThemeCollection.Style.ColB); + TempR2:=floor(255*ThemeCollection.Style.DColR); + TempG2:=floor(255*ThemeCollection.Style.DColG); + TempB2:=floor(255*ThemeCollection.Style.DColB); + // give encoded color to loadtexture + ButtonCollection[Num] := TButtonCollection.Create(Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.Tex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)), + Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.Tex)), 'JPG', 'Colorized', ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); + +// Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); // use cache texture +end +else ButtonCollection[Num] := TButtonCollection.Create(Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.Tex), ThemeCollection.Style.Typ, true)); // use cache texture //Set Parent menu @@ -328,13 +346,15 @@ begin ButtonCollection[Num].Y := ThemeCollection.Style.Y; ButtonCollection[Num].W := ThemeCollection.Style.W; ButtonCollection[Num].H := ThemeCollection.Style.H; - ButtonCollection[Num].SelectColR := ThemeCollection.Style.ColR; - ButtonCollection[Num].SelectColG := ThemeCollection.Style.ColG; - ButtonCollection[Num].SelectColB := ThemeCollection.Style.ColB; + if ThemeCollection.Style.Typ <> 'Colorized' then begin + ButtonCollection[Num].SelectColR := ThemeCollection.Style.ColR; + ButtonCollection[Num].SelectColG := ThemeCollection.Style.ColG; + ButtonCollection[Num].SelectColB := ThemeCollection.Style.ColB; + ButtonCollection[Num].DeselectColR := ThemeCollection.Style.DColR; + ButtonCollection[Num].DeselectColG := ThemeCollection.Style.DColG; + ButtonCollection[Num].DeselectColB := ThemeCollection.Style.DColB; + end; ButtonCollection[Num].SelectInt := ThemeCollection.Style.Int; - ButtonCollection[Num].DeselectColR := ThemeCollection.Style.DColR; - ButtonCollection[Num].DeselectColG := ThemeCollection.Style.DColG; - ButtonCollection[Num].DeselectColB := ThemeCollection.Style.DColB; ButtonCollection[Num].DeselectInt := ThemeCollection.Style.DInt; ButtonCollection[Num].Texture.TexX1 := 0; ButtonCollection[Num].Texture.TexY1 := 0; @@ -354,13 +374,16 @@ begin ButtonCollection[Num].Fade := ThemeCollection.Style.Fade; ButtonCollection[Num].FadeText := ThemeCollection.Style.FadeText; - ButtonCollection[Num].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex), ThemeCollection.Style.Typ, true); + if ThemeCollection.Style.Typ='Colorized' then + ButtonCollection[Num].FadeTex := Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)) + else + ButtonCollection[Num].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex), ThemeCollection.Style.Typ, true); ButtonCollection[Num].FadeTexPos := ThemeCollection.Style.FadeTexPos; BTLen := Length(ThemeCollection.Style.Text); for BT := 0 to BTLen-1 do begin - AddButtonText(ButtonCollection[Num], ThemeCollection.Style.Text[BT].X, ThemeCollection.Style.Text[BT].Y, + AddButtonText(ButtonCollection[Num], ThemeCollection.Style.Text[BT].X, ThemeCollection.Style.Text[BT].Y, ThemeCollection.Style.Text[BT].ColR, ThemeCollection.Style.Text[BT].ColG, ThemeCollection.Style.Text[BT].ColB, ThemeCollection.Style.Text[BT].Font, ThemeCollection.Style.Text[BT].Size, ThemeCollection.Style.Text[BT].Align, ThemeCollection.Style.Text[BT].Text); @@ -532,6 +555,7 @@ var BT: integer; BTLen: integer; temp: integer; + TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; begin { Result := AddButton(ThemeButton.X, ThemeButton.Y, ThemeButton.W, ThemeButton.H, ThemeButton.ColR, ThemeButton.ColG, ThemeButton.ColB, ThemeButton.Int, @@ -554,7 +578,14 @@ begin Button[Result].Fade := ThemeButton.Fade; Button[Result].FadeText := ThemeButton.FadeText; - Button[Result].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeButton.FadeTex), ThemeButton.Typ, true); + if ThemeButton.Typ='Colorized' then begin + TempR:=floor(255*ThemeButton.ColR); + TempG:=floor(255*ThemeButton.ColG); + TempB:=floor(255*ThemeButton.ColB); + Button[Result].FadeTex := Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeButton.FadeTex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)); + end + else + Button[Result].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeButton.FadeTex), ThemeButton.Typ, true); Button[Result].FadeTexPos := ThemeButton.FadeTexPos; @@ -596,6 +627,7 @@ begin end; 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; +var TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; begin // adds button //SetLength is used once to reduce Memory usement @@ -604,7 +636,7 @@ begin Result := ButtonPos; Inc(ButtonPos) end - else //Old Method -> Reserve new Memory for every Button + else //Old Method -> Reserve new Memory for every Button begin Result := Length(Button); SetLength(Button, Result + 1); @@ -614,6 +646,23 @@ begin // check here for cache // Texture.GetTexture(Name, Typ, false); // preloads textures and creates cahce mipmap when needed // if Covers.CoverExists(Name) then +// colorize hack +if Typ='Colorized' then +begin + TempR:=floor(255*ColR); + TempG:=floor(255*ColG); + TempB:=floor(255*ColB); + TempR2:=floor(255*DColR); + TempG2:=floor(255*DColG); + TempB2:=floor(255*DColB); + // give encoded color to loadtexture + Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR shl 8) or TempG) shl 8)or TempB)), + Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); + +// Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); // use cache texture +end +else + Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, true)); // use cache texture // else // Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, false)); // don't use cache texture} @@ -623,13 +672,15 @@ begin Button[Result].Y := Y; Button[Result].W := W; Button[Result].H := H; - Button[Result].SelectColR := ColR; - Button[Result].SelectColG := ColG; - Button[Result].SelectColB := ColB; + if Typ <> 'Colorized' then begin + Button[Result].SelectColR := ColR; + Button[Result].SelectColG := ColG; + Button[Result].SelectColB := ColB; + Button[Result].DeselectColR := DColR; + Button[Result].DeselectColG := DColG; + Button[Result].DeselectColB := DColB; + end; Button[Result].SelectInt := Int; - Button[Result].DeselectColR := DColR; - Button[Result].DeselectColG := DColG; - Button[Result].DeselectColB := DColB; Button[Result].DeselectInt := DInt; Button[Result].Texture.TexX1 := 0; Button[Result].Texture.TexY1 := 0; diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index 919a18c9..51c746fe 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -11,18 +11,21 @@ type FadeProgress: Real; FadeLastTick: Cardinal; - + DeSelectW: Real; DeSelectH: Real; PosX: Real; PosY: Real; constructor Create(); overload; - + public Text: Array of TText; Texture: TTexture; // Button Screen position and size Texture2: TTexture; // second texture only used for fading full resolution covers + //colorized hack + Colorized: Boolean; + DeSelectTexture: TTexture; // texture for colorized hack FadeTex: TTexture; //Texture for beautiful fading FadeTexPos: byte; //Pos of the FadeTexture (0: Top, 1: Left, 2: Bottom, 3: Right) @@ -76,6 +79,7 @@ type procedure Draw; virtual; constructor Create(Textura: TTexture); overload; + constructor Create(Textura, DSTexture: TTexture); overload; destructor Destroy; override; end; @@ -110,7 +114,7 @@ begin for T := 0 to High(Text) do Text[T].Y := Text[T].Y + dY;} - + PosY := Value; if (FadeTex.TexNum = -1) then Texture.y := Value; @@ -149,7 +153,7 @@ begin end; procedure TButton.SetSelect(Value : Boolean); -var +var T: integer; begin SelectBool := Value; @@ -217,6 +221,9 @@ begin //Reflection Mod Reflection := true; + //colorized hack + Colorized:=False; + // Default // SelectInt := 1; // DeselectInt := 0.5; @@ -297,11 +304,15 @@ begin begin Texture.W := DeSelectW + (SelectW - DeSelectW) * FadeProgress; Texture.H := DeSelectH + (SelectH - DeSelectH) * FadeProgress; + DeselectTexture.W := Texture.W; + DeselectTexture.H := Texture.H; end else //method with Fade Texture begin Texture.W := DeSelectW; Texture.H := DeSelectH; + DeselectTexture.W := Texture.W; + DeselectTexture.H := Texture.H; FadeTex.ColR := Texture.ColR; FadeTex.ColG := Texture.ColG; @@ -322,6 +333,8 @@ begin //Standard Texture Texture.X := PosX; Texture.Y := PosY + (SelectH - DeSelectH) * FadeProgress; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; //Fade Tex FadeTex.X := PosX; FadeTex.Y := PosY; @@ -336,6 +349,8 @@ begin //Standard Texture Texture.X := PosX + (SelectW - DeSelectW) * FadeProgress; Texture.Y := PosY; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; //Fade Tex FadeTex.X := PosX; FadeTex.Y := PosY; @@ -350,6 +365,8 @@ begin //Standard Texture Texture.X := PosX; Texture.Y := PosY; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; //Fade Tex FadeTex.X := PosX; FadeTex.Y := PosY + (SelectH - DeSelectH) * FadeProgress;; @@ -364,6 +381,8 @@ begin //Standard Texture Texture.X := PosX; Texture.Y := PosY; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; //Fade Tex FadeTex.X := PosX + (SelectW - DeSelectW) * FadeProgress; FadeTex.Y := PosY; @@ -382,7 +401,10 @@ begin Text[T].MoveY := (SelectH - DeSelectH); end; - DrawTexture(Texture); + if SelectBool or not Colorized then + DrawTexture(Texture) + else + DrawTexture(DeselectTexture); //Draw FadeTex if (FadeTex.TexNum <> -1) then @@ -419,6 +441,7 @@ begin else Spacing := DeSelectReflectionspacing; + if SelectBool or not Colorized then with Texture do begin //Bind Tex and GL Attributes @@ -456,7 +479,47 @@ begin glEnd; glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + end else + with DeselectTexture do + begin + //Bind Tex and GL Attributes + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + + //Draw + glBegin(GL_QUADS);//Top Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX1*TexW, TexY2*TexH); + glVertex3f(x, y+h*scaleH+ Spacing, z); + + //Bottom Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); + glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); + + + //Bottom Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); + glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); + + //Top Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX2*TexW, TexY2*TexH); + glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); + glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); glDisable(GL_BLEND); end; end; @@ -478,11 +541,24 @@ constructor TButton.Create(Textura: TTexture); begin Create(); Texture := Textura; + DeselectTexture:=Textura; Texture.ColR := 0; Texture.ColG := 0.5; Texture.ColB := 0; Texture.Int := 1; + Colorized:=False; end; +constructor TButton.Create(Textura, DSTexture: TTexture); +begin + Create(); + Texture := Textura; + DeselectTexture := DSTexture; + Texture.ColR := 1; + Texture.ColG := 1; + Texture.ColB := 1; + Texture.Int := 1; + Colorized:=True; +end; end. -- cgit v1.2.3 From f043468a9c9f13099efe30e86d1b0befca8fc6c2 Mon Sep 17 00:00:00 2001 From: b1indy Date: Mon, 3 Sep 2007 00:11:25 +0000 Subject: some small improvement with fading buttons git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@366 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenuButton.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index 51c746fe..cb343cf8 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -401,7 +401,7 @@ begin Text[T].MoveY := (SelectH - DeSelectH); end; - if SelectBool or not Colorized then + if SelectBool or (FadeProgress > 0) or not Colorized then DrawTexture(Texture) else DrawTexture(DeselectTexture); -- cgit v1.2.3 From 247cbdca4eb8af228fa1753f1185e85077b5befa Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 7 Sep 2007 21:09:02 +0000 Subject: UScreenSing.pas, UScreenSingModi.pas: removed Uffmpeg and USmpeg, added UVideo UGraphic.pas: prepared for possible loading animation UGraphicClasses.pas, ULCD.pas, ULight.pas, UMain.pas, USkins.pas, UDisplay.pas, UMenuButton.pas, UMenuSelect.pas, UMenuSelectSlide.pas, UMenuStatic.pas, UScreenCredits.pas, UScreenEditSub.pas, UScreenOpen.pas, UScreenPopup.pas: some fixes to get rid of some compiler infos/warnings git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@374 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 2 +- Game/Code/Menu/UMenuButton.pas | 9 +++++---- Game/Code/Menu/UMenuSelect.pas | 4 ++-- Game/Code/Menu/UMenuSelectSlide.pas | 6 +++--- Game/Code/Menu/UMenuStatic.pas | 2 -- 5 files changed, 11 insertions(+), 12 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 70e678fb..82b4acc7 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -40,7 +40,7 @@ type procedure PrintScreen; constructor Create; // fade mod - destructor Destroy; + destructor Destroy; override; // end procedure ScreenShot; diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index cb343cf8..f3b00830 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -87,9 +87,9 @@ implementation uses UDrawTexture, SysUtils, windows; procedure TButton.SetX(Value: real); -var +{var dx: real; - T: integer; // text + T: integer; // text} begin {dY := Value - Texture.y; @@ -105,9 +105,9 @@ begin end; procedure TButton.SetY(Value: real); -var +{var dY: real; - T: integer; // text + T: integer; // text} begin {dY := Value - PosY; @@ -276,6 +276,7 @@ var begin if Visible then begin //Fade Mod + T:=0; if Fade then begin if (FadeProgress < 1) and (FadeProgress > 0) then diff --git a/Game/Code/Menu/UMenuSelect.pas b/Game/Code/Menu/UMenuSelect.pas index f7bb871f..72141a27 100644 --- a/Game/Code/Menu/UMenuSelect.pas +++ b/Game/Code/Menu/UMenuSelect.pas @@ -99,8 +99,8 @@ begin end; procedure TSelect.SetSelect(Value: boolean); -var - SO: integer; +{var + SO: integer;} begin // default 1, 0.4 SelectBool := Value; if Value then begin diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index c1ccad6d..3659c00d 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -117,9 +117,9 @@ begin end; procedure TSelectSlide.SetSelect(Value: boolean); -var +{var SO: integer; - I: integer; + I: integer;} begin SelectBool := Value; if Value then begin @@ -187,7 +187,7 @@ procedure DoSelection(Sel: Cardinal); TextOpt[I].ColB := STDColB; TextOpt[I].Int := STDInt; end; - if (Sel <= high(TextOpt)) then + if (integer(Sel) <= high(TextOpt)) then begin TextOpt[Sel].ColR := STColR; TextOpt[Sel].ColG := STColG; diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas index 5f19fbf3..cfa4a596 100644 --- a/Game/Code/Menu/UMenuStatic.pas +++ b/Game/Code/Menu/UMenuStatic.pas @@ -21,8 +21,6 @@ implementation uses UDrawTexture; procedure TStatic.Draw; -var - Pet: integer; begin if Visible then begin -- cgit v1.2.3 From af73174a22a52fd9e2a6320737fb5b1ef87628ce Mon Sep 17 00:00:00 2001 From: b1indy Date: Fri, 7 Sep 2007 21:37:23 +0000 Subject: removed "error" messages (are more like warnings and did only confuse users) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@375 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 82b4acc7..0bded712 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -174,7 +174,7 @@ begin // check if we had an initialization error (canfade=false, dofade=true) if doFade and not canFade then begin doFade:=False; //disable fading - ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message +// ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message end; if doFade and canFade then begin @@ -199,7 +199,7 @@ begin GL_OUT_OF_MEMORY: glErrorStr:='OUT_OF_MEMORY'; else glErrorStr:='unknown error'; end; - ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message +// ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message end; glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); // blackscreen-hack -- cgit v1.2.3 From 16e0d37948cc1137d0c79f48f9b5e12e5bf77686 Mon Sep 17 00:00:00 2001 From: b1indy Date: Sat, 8 Sep 2007 15:33:52 +0000 Subject: did some cleanup and minor modifications UDisplay.pas: tried to make the screenfade-effect transparent (doesn't work for now) UMenu.pas: removed some unnecessary code from DrawBG UGraphic.pas: fixed display of loading screen (after it broke with the modifications in UMenu.pas) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@379 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 8 ++++---- Game/Code/Menu/UMenu.pas | 16 ++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 0bded712..fcba4382 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -75,7 +75,7 @@ begin canFade:=True; // generate texture for fading between screens - GetMem(pTexData, 512*512*3); + GetMem(pTexData, 512*512*4); if pTexData <> NIL then for i:= 1 to 2 do begin @@ -83,7 +83,7 @@ begin if glGetError <> GL_NO_ERROR then canFade := False; glBindTexture(GL_TEXTURE_2D, pTex[i]); if glGetError <> GL_NO_ERROR then canFade := False; - glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, pTexData); + glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); if glGetError <> GL_NO_ERROR then canFade := False; glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if glGetError <> GL_NO_ERROR then canFade := False; @@ -185,7 +185,7 @@ begin glViewPort(0, 0, 512, 512); ActualScreen.Draw; glBindTexture(GL_TEXTURE_2D, pTex[S]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, 512, 512, 0); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0); glError:=glGetError; if glError <> GL_NO_ERROR then begin @@ -229,7 +229,7 @@ begin // blackscreen-hack if not BlackScreen then NextScreen.Draw // draw next screen - else begin + else if ScreenAct=1 then begin glClearColor(0, 0, 0 , 0); glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); end; diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 0fb1614f..b0622d4b 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -712,14 +712,6 @@ 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; @@ -728,13 +720,17 @@ begin BackImg.TexX2 := 1; BackImg.TexY2 := 1; if (BackImg.TexNum <> -1) then begin - // draw texture with overlapping + // does anyone know what these loops were for? +{ // 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; // for PetX} + BackImg.X:=BackW; + BackImg.Y:=BackW; + DrawTexture(BackImg); end; // if end; -- cgit v1.2.3 From 6e7b96ca3a7d47b0441bed904a9b8bb25c3223de Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 12 Sep 2007 12:43:38 +0000 Subject: * added missed dependency PNGImage. * moved FUNCTION InitializePaths(), from uFiles to uMain as this is a more sane location for it. * updated files that used UFiles to point to UMain, and removed uFiles where its not needed. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@385 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index fcba4382..2af1dfa0 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -52,7 +52,16 @@ var implementation -uses UGraphic, UTime, Graphics, Jpeg, UFiles, UTexture, UIni, TextGL, UCommandLine; +uses Graphics, + Jpeg, + TextGL, + // UFiles, + UMain, + UTexture, + UIni, + UGraphic, + UTime, + UCommandLine; constructor TDisplay.Create; var i: integer; -- cgit v1.2.3 From 433a1b7339e2bf96f3b0bb4c98b8c799c6540027 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 18 Sep 2007 13:19:20 +0000 Subject: changes in order to compile in lazarus... minor tidy ups and removal of big old comment blocks.. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@394 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 7 +++++-- Game/Code/Menu/UMenu.pas | 4 ++++ Game/Code/Menu/UMenuSelectSlide.pas | 10 +++++++++- Game/Code/Menu/UMenuText.pas | 5 +++++ 4 files changed, 23 insertions(+), 3 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 2af1dfa0..6ad01406 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -52,8 +52,11 @@ var implementation -uses Graphics, - Jpeg, +uses + {$IFNDEF FPC} + Graphics, + JPEG, + {$ENDIF} TextGL, // UFiles, UMain, diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index b0622d4b..3c50967d 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -2,6 +2,10 @@ unit UMenu; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, UMenuInteract, UThemes, UMenuButtonCollection, Math; diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index 3659c00d..bb9b5809 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -1,7 +1,15 @@ unit UMenuSelectSlide; interface -uses TextGL, UTexture, OpenGL12, UMenuText; + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses TextGL, + UTexture, + OpenGL12, + UMenuText; type PSelectSlide = ^TSelectSlide; diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 4713962e..cba237b8 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -1,6 +1,11 @@ unit UMenuText; interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + uses TextGL, UTexture, OpenGL12, SysUtils; type -- cgit v1.2.3 From 62c82114318ed04ce42617fa9ce2e179834dbda4 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 19 Sep 2007 11:44:10 +0000 Subject: added UCommon ( in classes ) for lazarus... common functions needed for lazarus ( and others ) can be put in here. also this now compiles on lazarus.. ( dosnt link yet... but I dont get any critical compiler errors ) tested to compile in my delphi, and basic functionality is fine. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@395 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 20 +++++++++++++++----- Game/Code/Menu/UMenu.pas | 7 ++++++- 2 files changed, 21 insertions(+), 6 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 6ad01406..160e8a73 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,7 +2,15 @@ unit UDisplay; interface -uses Windows, SDL, UMenu, OpenGL12, SysUtils; +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses Windows, + SDL, + UMenu, + OpenGL12, + SysUtils; type TDisplay = class @@ -53,10 +61,12 @@ var implementation uses - {$IFNDEF FPC} - Graphics, + {$IFDEF FPC} + lazjpeg, + {$ELSE} JPEG, {$ENDIF} + graphics, TextGL, // UFiles, UMain, @@ -320,8 +330,8 @@ begin end; glReadPixels(0, 0, ScreenW, ScreenH, GL_RGBA, GL_UNSIGNED_BYTE, @PrintScreenData[0]); - Bitmap := TBitmap.Create; - Bitmap.Width := ScreenW; + Bitmap := TBitmap.Create; + Bitmap.Width := ScreenW; Bitmap.Height := ScreenH; for Y := 0 to ScreenH-1 do diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 3c50967d..1e6c1e87 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -154,7 +154,12 @@ const implementation -uses UMain, UDrawTexture, UGraphic, UDisplay, UCovers, USkins, Dialogs; +uses UMain, + UDrawTexture, + UGraphic, + UDisplay, + UCovers, + USkins; destructor TMenu.Destroy; begin -- cgit v1.2.3 From 84beb7412eaca48cbf5c9915b83e5f8c79c9a0e7 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 19 Sep 2007 13:13:37 +0000 Subject: fixes to get working in lazarus.. compiling, linking, starting to run.. just fixing stuff :) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@397 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 160e8a73..ed65d62d 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -62,7 +62,7 @@ implementation uses {$IFDEF FPC} - lazjpeg, + ulazjpeg, {$ELSE} JPEG, {$ENDIF} -- cgit v1.2.3 From db82b7e30a1b58b56fdb4bfc6089b47200ca1da1 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Sep 2007 06:36:58 +0000 Subject: Ultrastar-DX now compiles in linux (using lazarus) Bass etc is commented out.. but it compiles, and im working through the runtime errors. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@408 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 929 ++++++++++++++++---------------- Game/Code/Menu/UMenuButton.pas | 1137 ++++++++++++++++++++-------------------- Game/Code/Menu/UMenuText.pas | 668 +++++++++++------------ 3 files changed, 1380 insertions(+), 1354 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index ed65d62d..6181fab1 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -1,460 +1,469 @@ -unit UDisplay; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -uses Windows, - SDL, - UMenu, - OpenGL12, - SysUtils; - -type - TDisplay = class - ActualScreen: PMenu; - NextScreen: PMenu; - - //fade-to-black-hack - BlackScreen: Boolean; - //popup hack - NextScreenWithCheck: Pmenu; - CheckOK: Boolean; - - h_DC: HDC; - h_RC: HGLRC; - - Fade: Real; - // fade-mod - doFade: Boolean; - canFade: Boolean; - myFade: integer; - lastTime: Cardinal; - pTexData : Pointer; - pTex : array[1..2] of glUInt; - // end - - //FPS Counter - FPSCounter: Cardinal; - LastFPS: Cardinal; - NextFPSSwap:Cardinal; - - //For Debug OSD - OSD_LastError: String; - - function Draw: Boolean; - procedure PrintScreen; - constructor Create; - // fade mod - destructor Destroy; override; - // end - procedure ScreenShot; - - procedure DrawDebugInformation; - end; - -var - Display: TDisplay; - -implementation - -uses - {$IFDEF FPC} - ulazjpeg, - {$ELSE} - JPEG, - {$ENDIF} - graphics, - TextGL, - // UFiles, - UMain, - UTexture, - UIni, - UGraphic, - UTime, - UCommandLine; - -constructor TDisplay.Create; -var i: integer; -begin - inherited Create; - - //popup hack - CheckOK:=False; - NextScreen:=NIL; - NextScreenWithCheck:=NIL; - BlackScreen:=False; - - // fade mod - myfade:=0; - - if Ini.ScreenFade=1 then - doFade:=True - else - doFade:=False; - - canFade:=True; - // generate texture for fading between screens - GetMem(pTexData, 512*512*4); - if pTexData <> NIL then - for i:= 1 to 2 do - begin - glGenTextures(1, pTex[i]); - if glGetError <> GL_NO_ERROR then canFade := False; - glBindTexture(GL_TEXTURE_2D, pTex[i]); - if glGetError <> GL_NO_ERROR then canFade := False; - glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); - if glGetError <> GL_NO_ERROR then canFade := False; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if glGetError <> GL_NO_ERROR then canFade := False; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - if glGetError <> GL_NO_ERROR then canFade := False; - end - else - begin - canFade:=False; - end; - FreeMem(pTexData); - // end - - //Set LastError for OSD to No Error - OSD_LastError := 'No Errors'; -end; - -// fade mod -destructor TDisplay.Destroy; -begin - if canFade then - glDeleteTextures(1,@pTex); - inherited Destroy; -end; -// end - -function TDisplay.Draw: Boolean; -var - S: integer; - Col: Real; - // fade mod - myFade2: Real; - currentTime: Cardinal; - glError: glEnum; - glErrorStr: String; - // end -begin - Result := True; - - Col := 1; - {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then - Col := 0; } - - glClearColor(Col, Col, Col , 0); - glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); - - for S := 1 to Screens do begin - ScreenAct := S; - -// if Screens = 1 then ScreenX := 0; -// if (Screens = 2) and (S = 1) then ScreenX := -1; -// if (Screens = 2) and (S = 2) then ScreenX := 1; - ScreenX := 0; - - if S = 2 then TimeSkip := 0 else; - glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); - - //popup hack - // check was successful... move on - if CheckOK then - if assigned (NextScreenWithCheck)then - begin - NextScreen:=NextScreenWithCheck; - NextScreenWithCheck := NIL; - CheckOk:=False; - end - else - BlackScreen:=True; // end of game - fade to black before exit - //end popup hack - -// ActualScreen.SetAnimationProgress(1); - if (not assigned (NextScreen)) and (not BlackScreen) then begin - ActualScreen.Draw; - //popup mod - if ScreenPopupError <> NIL then if ScreenPopupError.Visible then ScreenPopupError.Draw else - if ScreenPopupCheck <> NIL then if ScreenPopupCheck.Visible then ScreenPopupCheck.Draw; - //popup end - // fade mod - myfade:=0; - if (Ini.ScreenFade=1) and canFade then - doFade:=True - else if Ini.ScreenFade=0 then - doFade:=False; - // end - end - else - begin - // check if we had an initialization error (canfade=false, dofade=true) - if doFade and not canFade then begin - doFade:=False; //disable fading -// ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message - end; - if doFade and canFade then - begin - // fade mod - //Create Fading texture if we're just starting - if myfade = 0 then - begin - glViewPort(0, 0, 512, 512); - ActualScreen.Draw; - glBindTexture(GL_TEXTURE_2D, pTex[S]); - glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0); - glError:=glGetError; - if glError <> GL_NO_ERROR then - begin - canFade := False; - case glError of - GL_INVALID_ENUM: glErrorStr:='INVALID_ENUM'; - GL_INVALID_VALUE: glErrorStr:='INVALID_VALUE'; - GL_INVALID_OPERATION: glErrorStr:='INVALID_OPERATION'; - GL_STACK_OVERFLOW: glErrorStr:='STACK_OVERFLOW'; - GL_STACK_UNDERFLOW: glErrorStr:='STACK_UNDERFLOW'; - GL_OUT_OF_MEMORY: glErrorStr:='OUT_OF_MEMORY'; - else glErrorStr:='unknown error'; - end; -// ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message - end; - glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); - // blackscreen-hack - if not BlackScreen then - NextScreen.onShow; - lastTime:=GetTickCount; - if (S=2) or (Screens = 1) then - myfade:=myfade+1; - end; // end texture creation in first fading step - - //do some time-based fading - currentTime:=GetTickCount; - if (currentTime > lastTime+30) and (S=1) then - begin - myfade:=myfade+4; - lastTime:=currentTime; - end; - -// LastFade := Fade; // whatever -// Fade := Fade -0.999; // start fading out - - -// ActualScreen.ShowFinish := false; // no purpose? - -// ActualScreen.SetAnimationProgress(Fade-1); // nop? - - // blackscreen-hack - if not BlackScreen then - NextScreen.Draw // draw next screen - else if ScreenAct=1 then begin - glClearColor(0, 0, 0 , 0); - glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); - end; - - // and draw old screen over it... slowly fading out - myfade2:=(myfade*myfade)/10000; - glBindTexture(GL_TEXTURE_2D, pTex[S]); - glColor4f(1, 1, 1, (1000-myfade*myfade)/1000); // strange calculation - alpha gets negative... but looks good this way - glEnable(GL_TEXTURE_2D); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - glBegin(GL_QUADS); - glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600); - glTexCoord2f(0+myfade2,1-myfade2);glVertex2f(0, 0); - glTexCoord2f(1-myfade2,1-myfade2);glVertex2f(800, 0); - glTexCoord2f(1-myfade2,0+myfade2);glVertex2f(800, 600); - glEnd; - glDisable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - end - else - // blackscreen hack - if not BlackScreen then - NextScreen.OnShow; - - - if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then begin // fade out complete... - myFade:=0; - ActualScreen.onHide; - ActualScreen.ShowFinish:=False; - ActualScreen:=NextScreen; - NextScreen := nil; - if not blackscreen then - begin - ActualScreen.onShowFinish; - ActualScreen.ShowFinish := true; - end - else - begin - Result:=False; - Break; - end; - // end of fade mod - end; - end; // if - - //Draw OSD only on first Screen if Debug Mode is enabled - if ((Ini.Debug = 1) OR (Params.Debug)) AND (S=1) then - DrawDebugInformation; - - end; // for -// 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; - 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 + 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 := ScreenW; - FileInfo.biHeight := ScreenH; - 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; - -//------------ -// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen -//------------ -procedure TDisplay.DrawDebugInformation; -var Ticks: Cardinal; -begin - //Some White Background for information - glEnable(GL_BLEND); - glDisable(GL_TEXTURE_2D); - glColor4f(1, 1, 1, 0.5); - glBegin(GL_QUADS); - glVertex2f(690, 44); - glVertex2f(690, 0); - glVertex2f(800, 0); - glVertex2f(800, 44); - glEnd; - glDisable(GL_BLEND); - - //Set Font Specs - SetFontStyle(0); - SetFontSize(7); - SetFontItalic(False); - glColor4f(0, 0, 0, 1); - - //Calculate FPS - Ticks := GetTickCount; - if (Ticks >= NextFPSSwap) then - begin - LastFPS := FPSCounter * 4; - FPSCounter := 0; - NextFPSSwap := Ticks + 250; - end; - - Inc(FPSCounter); - - //Draw Text - - //FPS - SetFontPos(695, 0); - glPrint (PChar('FPS: ' + InttoStr(LastFPS))); - - //RSpeed - SetFontPos(695, 13); - glPrint (PChar('RSpeed: ' + InttoStr(Round(1000 * TimeMid)))); - - //LastError - SetFontPos(695, 26); - glColor4f(1, 0, 0, 1); - glPrint (PChar(OSD_LastError)); - - glColor4f(1, 1, 1, 1); -end; - -end. +unit UDisplay; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses {$IFDEF win32} + windows, + {$ELSE} + LCLType, + {$ENDIF} + ucommon, + SDL, + UMenu, + OpenGL12, + SysUtils; + +type + TDisplay = class + ActualScreen: PMenu; + NextScreen: PMenu; + + //fade-to-black-hack + BlackScreen: Boolean; + //popup hack + NextScreenWithCheck: Pmenu; + CheckOK: Boolean; + + h_DC: HDC; + h_RC: HGLRC; + + Fade: Real; + // fade-mod + doFade: Boolean; + canFade: Boolean; + myFade: integer; + lastTime: Cardinal; + pTexData : Pointer; + pTex : array[1..2] of glUInt; + // end + + //FPS Counter + FPSCounter: Cardinal; + LastFPS: Cardinal; + NextFPSSwap:Cardinal; + + //For Debug OSD + OSD_LastError: String; + + function Draw: Boolean; + procedure PrintScreen; + constructor Create; + // fade mod + destructor Destroy; override; + // end + procedure ScreenShot; + + procedure DrawDebugInformation; + end; + +var + Display: TDisplay; + +implementation + +uses + {$IFDEF FPC} + ulazjpeg, + {$ELSE} + JPEG, + {$ENDIF} + {$IFNDEF win32} + lclintf, + {$ENDIF} + graphics, + TextGL, + // UFiles, + UMain, + UTexture, + UIni, + UGraphic, + UTime, + UCommandLine; + +constructor TDisplay.Create; +var i: integer; +begin + inherited Create; + + //popup hack + CheckOK:=False; + NextScreen:=NIL; + NextScreenWithCheck:=NIL; + BlackScreen:=False; + + // fade mod + myfade:=0; + + if Ini.ScreenFade=1 then + doFade:=True + else + doFade:=False; + + canFade:=True; + // generate texture for fading between screens + GetMem(pTexData, 512*512*4); + if pTexData <> NIL then + for i:= 1 to 2 do + begin + glGenTextures(1, pTex[i]); + if glGetError <> GL_NO_ERROR then canFade := False; + glBindTexture(GL_TEXTURE_2D, pTex[i]); + if glGetError <> GL_NO_ERROR then canFade := False; + glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); + if glGetError <> GL_NO_ERROR then canFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + if glGetError <> GL_NO_ERROR then canFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + if glGetError <> GL_NO_ERROR then canFade := False; + end + else + begin + canFade:=False; + end; + FreeMem(pTexData); + // end + + //Set LastError for OSD to No Error + OSD_LastError := 'No Errors'; +end; + +// fade mod +destructor TDisplay.Destroy; +begin + if canFade then + glDeleteTextures(1,@pTex); + inherited Destroy; +end; +// end + +function TDisplay.Draw: Boolean; +var + S: integer; + Col: Real; + // fade mod + myFade2: Real; + currentTime: Cardinal; + glError: glEnum; + glErrorStr: String; + // end +begin + Result := True; + + Col := 1; + {if (ParamStr(1) = '-black') or (ParamStr(1) = '-fsblack') then + Col := 0; } + + glClearColor(Col, Col, Col , 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + + for S := 1 to Screens do begin + ScreenAct := S; + +// if Screens = 1 then ScreenX := 0; +// if (Screens = 2) and (S = 1) then ScreenX := -1; +// if (Screens = 2) and (S = 2) then ScreenX := 1; + ScreenX := 0; + + if S = 2 then TimeSkip := 0 else; + glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); + + //popup hack + // check was successful... move on + if CheckOK then + if assigned (NextScreenWithCheck)then + begin + NextScreen:=NextScreenWithCheck; + NextScreenWithCheck := NIL; + CheckOk:=False; + end + else + BlackScreen:=True; // end of game - fade to black before exit + //end popup hack + +// ActualScreen.SetAnimationProgress(1); + if (not assigned (NextScreen)) and (not BlackScreen) then begin + ActualScreen.Draw; + //popup mod + if ScreenPopupError <> NIL then if ScreenPopupError.Visible then ScreenPopupError.Draw else + if ScreenPopupCheck <> NIL then if ScreenPopupCheck.Visible then ScreenPopupCheck.Draw; + //popup end + // fade mod + myfade:=0; + if (Ini.ScreenFade=1) and canFade then + doFade:=True + else if Ini.ScreenFade=0 then + doFade:=False; + // end + end + else + begin + // check if we had an initialization error (canfade=false, dofade=true) + if doFade and not canFade then begin + doFade:=False; //disable fading +// ScreenPopupError.ShowPopup('Error initializing\nfade texture\n\nfading\ndisabled'); //show error message + end; + if doFade and canFade then + begin + // fade mod + //Create Fading texture if we're just starting + if myfade = 0 then + begin + glViewPort(0, 0, 512, 512); + ActualScreen.Draw; + glBindTexture(GL_TEXTURE_2D, pTex[S]); + glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0); + glError:=glGetError; + if glError <> GL_NO_ERROR then + begin + canFade := False; + case glError of + GL_INVALID_ENUM: glErrorStr:='INVALID_ENUM'; + GL_INVALID_VALUE: glErrorStr:='INVALID_VALUE'; + GL_INVALID_OPERATION: glErrorStr:='INVALID_OPERATION'; + GL_STACK_OVERFLOW: glErrorStr:='STACK_OVERFLOW'; + GL_STACK_UNDERFLOW: glErrorStr:='STACK_UNDERFLOW'; + GL_OUT_OF_MEMORY: glErrorStr:='OUT_OF_MEMORY'; + else glErrorStr:='unknown error'; + end; +// ScreenPopupError.ShowPopup('Error copying\nfade texture\n('+glErrorStr+')\nfading\ndisabled'); //show error message + end; + glViewPort((S-1) * ScreenW div Screens, 0, ScreenW div Screens, ScreenH); + // blackscreen-hack + if not BlackScreen then + NextScreen.onShow; + + lastTime:=GetTickCount; + if (S=2) or (Screens = 1) then + myfade:=myfade+1; + end; // end texture creation in first fading step + + //do some time-based fading + currentTime:=GetTickCount; + if (currentTime > lastTime+30) and (S=1) then + begin + myfade:=myfade+4; + lastTime:=currentTime; + end; + +// LastFade := Fade; // whatever +// Fade := Fade -0.999; // start fading out + + +// ActualScreen.ShowFinish := false; // no purpose? + +// ActualScreen.SetAnimationProgress(Fade-1); // nop? + + // blackscreen-hack + if not BlackScreen then + NextScreen.Draw // draw next screen + else if ScreenAct=1 then begin + glClearColor(0, 0, 0 , 0); + glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); + end; + + // and draw old screen over it... slowly fading out + myfade2:=(myfade*myfade)/10000; + glBindTexture(GL_TEXTURE_2D, pTex[S]); + glColor4f(1, 1, 1, (1000-myfade*myfade)/1000); // strange calculation - alpha gets negative... but looks good this way + glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + glBegin(GL_QUADS); + glTexCoord2f(0+myfade2,0+myfade2);glVertex2f(0, 600); + glTexCoord2f(0+myfade2,1-myfade2);glVertex2f(0, 0); + glTexCoord2f(1-myfade2,1-myfade2);glVertex2f(800, 0); + glTexCoord2f(1-myfade2,0+myfade2);glVertex2f(800, 600); + glEnd; + glDisable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + end + else + // blackscreen hack + if not BlackScreen then + NextScreen.OnShow; + + + if ((myfade > 40) or (not doFade) or (not canFade)) And (S = 1) then begin // fade out complete... + myFade:=0; + ActualScreen.onHide; + ActualScreen.ShowFinish:=False; + ActualScreen:=NextScreen; + NextScreen := nil; + if not blackscreen then + begin + ActualScreen.onShowFinish; + ActualScreen.ShowFinish := true; + end + else + begin + Result:=False; + Break; + end; + // end of fade mod + end; + end; // if + + //Draw OSD only on first Screen if Debug Mode is enabled + if ((Ini.Debug = 1) OR (Params.Debug)) AND (S=1) then + DrawDebugInformation; + + end; // for +// 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; + 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 + 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 := ScreenW; + FileInfo.biHeight := ScreenH; + 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; + +//------------ +// DrawDebugInformation - Procedure draw FPS and some other Informations on Screen +//------------ +procedure TDisplay.DrawDebugInformation; +var Ticks: Cardinal; +begin + //Some White Background for information + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glColor4f(1, 1, 1, 0.5); + glBegin(GL_QUADS); + glVertex2f(690, 44); + glVertex2f(690, 0); + glVertex2f(800, 0); + glVertex2f(800, 44); + glEnd; + glDisable(GL_BLEND); + + //Set Font Specs + SetFontStyle(0); + SetFontSize(7); + SetFontItalic(False); + glColor4f(0, 0, 0, 1); + + //Calculate FPS + Ticks := GetTickCount; + if (Ticks >= NextFPSSwap) then + begin + LastFPS := FPSCounter * 4; + FPSCounter := 0; + NextFPSSwap := Ticks + 250; + end; + + Inc(FPSCounter); + + //Draw Text + + //FPS + SetFontPos(695, 0); + glPrint (PChar('FPS: ' + InttoStr(LastFPS))); + + //RSpeed + SetFontPos(695, 13); + glPrint (PChar('RSpeed: ' + InttoStr(Round(1000 * TimeMid)))); + + //LastError + SetFontPos(695, 26); + glColor4f(1, 0, 0, 1); + glPrint (PChar(OSD_LastError)); + + glColor4f(1, 1, 1, 1); +end; + +end. diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index f3b00830..af4f69ee 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -1,565 +1,572 @@ -unit UMenuButton; - -interface -uses TextGL, UTexture, OpenGL12, UMenuText; - -type - CButton = class of TButton; - TButton = class - protected - SelectBool: Boolean; - - FadeProgress: Real; - FadeLastTick: Cardinal; - - DeSelectW: Real; - DeSelectH: Real; - PosX: Real; - PosY: Real; - - constructor Create(); overload; - - public - Text: Array of TText; - Texture: TTexture; // Button Screen position and size - Texture2: TTexture; // second texture only used for fading full resolution covers - //colorized hack - Colorized: Boolean; - DeSelectTexture: TTexture; // texture for colorized hack - - FadeTex: TTexture; //Texture for beautiful fading - FadeTexPos: byte; //Pos of the FadeTexture (0: Top, 1: Left, 2: Bottom, 3: Right) -// Texture2Blend: real; // blending factor for second texture (0=invisible, 1=visible) - // now uses alpha - - DeselectType: integer; // not used yet - Visible: boolean; - //Reflection Mod - Reflection: boolean; - Reflectionspacing: Real; - DeSelectReflectionspacing: Real; - - //Fade Mod - Fade: Boolean; - FadeText: Boolean; - - Selectable: boolean; - - //No of the Parent Collection, 0 if in no Collection - Parent: Byte; - - SelectColR: real; - SelectColG: real; - SelectColB: real; - SelectInt: real; - SelectTInt: real; - //Fade Mod - SelectW: real; - SelectH: real; - - DeselectColR: real; - DeselectColG: real; - DeselectColB: real; - DeselectInt: real; - DeselectTInt: real; - - procedure SetY(Value: real); - procedure SetX(Value: real); - procedure SetW(Value: real); - procedure SetH(Value: real); - - procedure SetSelect(Value: Boolean); virtual; - property X: real read PosX write SetX; - property Y: real read PosY write SetY; - property Z: real read Texture.z write Texture.z; - property W: real read DeSelectW write SetW; - property H: real read DeSelectH write SetH; - property Selected: Boolean read SelectBool write SetSelect; - - procedure Draw; virtual; - - constructor Create(Textura: TTexture); overload; - constructor Create(Textura, DSTexture: TTexture); overload; - destructor Destroy; override; - end; - -implementation -uses 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 - PosY; - - - for T := 0 to High(Text) do - 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 - T: integer; -begin - SelectBool := Value; - if (Value) then begin - Texture.ColR := SelectColR; - Texture.ColG := SelectColG; - Texture.ColB := SelectColB; - Texture.Int := SelectInt; - - Texture2.ColR := SelectColR; - Texture2.ColG := SelectColG; - Texture2.ColB := SelectColB; - Texture2.Int := SelectInt; - - for T := 0 to High(Text) do - Text[T].Int := SelectTInt; - - //Fade Mod - if Fade then - begin - if (FadeProgress <= 0) then - FadeProgress := 0.125; - end - else - begin - Texture.W := SelectW; - Texture.H := SelectH; - end; - end else begin - Texture.ColR := DeselectColR; - Texture.ColG := DeselectColG; - Texture.ColB := DeselectColB; - Texture.Int := DeselectInt; - - Texture2.ColR := DeselectColR; - Texture2.ColG := DeselectColG; - Texture2.ColB := DeselectColB; - Texture2.Int := DeselectInt; - - for T := 0 to High(Text) do - Text[T].Int := DeselectTInt; - - //Fade Mod - if Fade then - begin - if (FadeProgress >= 1) then - FadeProgress := 0.875; - end - else - begin - Texture.W := DeSelectW; - Texture.H := DeSelectH; - end; - end; -end; - -constructor TButton.Create(); -begin - inherited Create; - // We initialize all to 0, nil or false - Visible := true; - SelectBool := false; - DeselectType := 0; - Selectable := true; - //Reflection Mod - Reflection := true; - - //colorized hack - Colorized:=False; - - // Default -// SelectInt := 1; -// DeselectInt := 0.5; - -{ SelectColR := 0.5; - SelectColG := 0.75; - SelectColB := 0; - SelectInt := 1; - SelectTInt := 1; - - DeselectColR := 1; - DeselectColG := 1; - DeselectColB := 1; - DeselectInt := 0.5; - DeselectTInt := 1;} - - SelectColR := 1; - SelectColG := 1; - SelectColB := 1; - SelectInt := 1; - SelectTInt := 1; - - DeselectColR := 1; - DeselectColG := 1; - DeselectColB := 1; - DeselectInt := 0.5; - DeselectTInt := 1; - - FadeTex.TexNum := -1; - - FadeProgress := 0; - Fade := False; - FadeText := False; - SelectW := DeSelectW; - SelectH := DeSelectH; - - PosX := 0; - PosY := 0; - - Parent := 0; -end; - -// ***** Public methods ****** // - -procedure TButton.Draw; -var - T: integer; - Tick: Cardinal; - Spacing: Real; -begin - if Visible then begin - //Fade Mod - T:=0; - if Fade then - begin - if (FadeProgress < 1) and (FadeProgress > 0) then - begin - Tick := 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; - DeselectTexture.W := Texture.W; - DeselectTexture.H := Texture.H; - end - else //method with Fade Texture - begin - Texture.W := DeSelectW; - Texture.H := DeSelectH; - DeselectTexture.W := Texture.W; - DeselectTexture.H := Texture.H; - - FadeTex.ColR := Texture.ColR; - FadeTex.ColG := Texture.ColG; - FadeTex.ColB := Texture.ColB; - FadeTex.Int := Texture.Int; - - FadeTex.Z := Texture.Z; - - FadeTex.Alpha := Texture.Alpha; - FadeTex.TexX1 := 0; - FadeTex.TexX2 := 1; - FadeTex.TexY1 := 0; - FadeTex.TexY2 := 1; - - Case FadeTexPos of - 0: //FadeTex on Top - begin - //Standard Texture - Texture.X := PosX; - Texture.Y := PosY + (SelectH - DeSelectH) * FadeProgress; - DeselectTexture.X := Texture.X; - DeselectTexture.Y := Texture.Y; - //Fade Tex - FadeTex.X := PosX; - FadeTex.Y := PosY; - FadeTex.W := Texture.W; - FadeTex.H := (SelectH - DeSelectH) * FadeProgress; - FadeTex.ScaleW := Texture.ScaleW; - //Some Hack that Fixes a little Space between both Textures - FadeTex.TexY2 := 0.9; - end; - 1: //FadeTex on Left - begin - //Standard Texture - Texture.X := PosX + (SelectW - DeSelectW) * FadeProgress; - Texture.Y := PosY; - DeselectTexture.X := Texture.X; - DeselectTexture.Y := Texture.Y; - //Fade Tex - FadeTex.X := PosX; - FadeTex.Y := PosY; - FadeTex.H := Texture.H; - FadeTex.W := (SelectW - DeSelectW) * FadeProgress; - FadeTex.ScaleH := Texture.ScaleH; - //Some Hack that Fixes a little Space between both Textures - FadeTex.TexX2 := 0.9; - end; - 2: //FadeTex on Bottom - begin - //Standard Texture - Texture.X := PosX; - Texture.Y := PosY; - DeselectTexture.X := Texture.X; - DeselectTexture.Y := Texture.Y; - //Fade Tex - FadeTex.X := PosX; - FadeTex.Y := PosY + (SelectH - DeSelectH) * FadeProgress;; - FadeTex.W := Texture.W; - FadeTex.H := (SelectH - DeSelectH) * FadeProgress; - FadeTex.ScaleW := Texture.ScaleW; - //Some Hack that Fixes a little Space between both Textures - FadeTex.TexY1 := 0.1; - end; - 3: //FadeTex on Right - begin - //Standard Texture - Texture.X := PosX; - Texture.Y := PosY; - DeselectTexture.X := Texture.X; - DeselectTexture.Y := Texture.Y; - //Fade Tex - FadeTex.X := PosX + (SelectW - DeSelectW) * FadeProgress; - FadeTex.Y := PosY; - FadeTex.H := Texture.H; - FadeTex.W := (SelectW - DeSelectW) * FadeProgress; - FadeTex.ScaleH := Texture.ScaleH; - //Some Hack that Fixes a little Space between both Textures - FadeTex.TexX1 := 0.1; - end; - end; - end; - end - else if (FadeText) then - begin - Text[T].MoveX := (SelectW - DeSelectW); - Text[T].MoveY := (SelectH - DeSelectH); - end; - - if SelectBool or (FadeProgress > 0) or not Colorized then - DrawTexture(Texture) - else - DrawTexture(DeselectTexture); - - //Draw FadeTex - if (FadeTex.TexNum <> -1) then - DrawTexture(FadeTex); - - if Texture2.Alpha > 0 then begin - Texture2.ScaleW := Texture.ScaleW; - Texture2.ScaleH := Texture.ScaleH; - - Texture2.X := Texture.X; - Texture2.Y := Texture.Y; - Texture2.W := Texture.W; - Texture2.H := Texture.H; - - Texture2.ColR := Texture.ColR; - Texture2.ColG := Texture.ColG; - Texture2.ColB := Texture.ColB; - Texture2.Int := Texture.Int; - - Texture2.Z := Texture.Z; - - DrawTexture(Texture2); - end; - - //Reflection Mod - if (Reflection) then // Draw Reflections - begin - if (FadeProgress <> 0) AND (FadeProgress <> 1) then - begin - Spacing := DeSelectReflectionspacing - (DeSelectReflectionspacing - Reflectionspacing) * FadeProgress; - end - else if SelectBool then - Spacing := Reflectionspacing - else - Spacing := DeSelectReflectionspacing; - - if SelectBool or not Colorized then - with Texture do - begin - //Bind Tex and GL Attributes - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - glDepthRange(0, 10); - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, TexNum); - - //Draw - glBegin(GL_QUADS);//Top Left - glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); - glTexCoord2f(TexX1*TexW, TexY2*TexH); - glVertex3f(x, y+h*scaleH+ Spacing, z); - - //Bottom Left - glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); - glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); - - - //Bottom Right - glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); - glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); - - //Top Right - glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); - glTexCoord2f(TexX2*TexW, TexY2*TexH); - glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); - glEnd; - - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - end else - with DeselectTexture do - begin - //Bind Tex and GL Attributes - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - - glDepthRange(0, 10); - glDepthFunc(GL_LEQUAL); - glEnable(GL_DEPTH_TEST); - - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBindTexture(GL_TEXTURE_2D, TexNum); - - //Draw - glBegin(GL_QUADS);//Top Left - glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); - glTexCoord2f(TexX1*TexW, TexY2*TexH); - glVertex3f(x, y+h*scaleH+ Spacing, z); - - //Bottom Left - glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); - glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); - - - //Bottom Right - glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); - glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); - glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); - - //Top Right - glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); - glTexCoord2f(TexX2*TexW, TexY2*TexH); - glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); - glEnd; - - glDisable(GL_TEXTURE_2D); - glDisable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - end; - end; - - for T := 0 to High(Text) do begin - Text[T].Draw; - end; - end; -end; - -// ***** ****** // - -destructor TButton.Destroy; -begin - inherited; -end; - -constructor TButton.Create(Textura: TTexture); -begin - Create(); - Texture := Textura; - DeselectTexture:=Textura; - Texture.ColR := 0; - Texture.ColG := 0.5; - Texture.ColB := 0; - Texture.Int := 1; - Colorized:=False; -end; - -constructor TButton.Create(Textura, DSTexture: TTexture); -begin - Create(); - Texture := Textura; - DeselectTexture := DSTexture; - Texture.ColR := 1; - Texture.ColG := 1; - Texture.ColB := 1; - Texture.Int := 1; - Colorized:=True; -end; - -end. +unit UMenuButton; + +interface +uses TextGL, UTexture, OpenGL12, UMenuText; + +type + CButton = class of TButton; + TButton = class + protected + SelectBool: Boolean; + + FadeProgress: Real; + FadeLastTick: Cardinal; + + DeSelectW: Real; + DeSelectH: Real; + PosX: Real; + PosY: Real; + + constructor Create(); overload; + + public + Text: Array of TText; + Texture: TTexture; // Button Screen position and size + Texture2: TTexture; // second texture only used for fading full resolution covers + //colorized hack + Colorized: Boolean; + DeSelectTexture: TTexture; // texture for colorized hack + + FadeTex: TTexture; //Texture for beautiful fading + FadeTexPos: byte; //Pos of the FadeTexture (0: Top, 1: Left, 2: Bottom, 3: Right) +// Texture2Blend: real; // blending factor for second texture (0=invisible, 1=visible) + // now uses alpha + + DeselectType: integer; // not used yet + Visible: boolean; + //Reflection Mod + Reflection: boolean; + Reflectionspacing: Real; + DeSelectReflectionspacing: Real; + + //Fade Mod + Fade: Boolean; + FadeText: Boolean; + + Selectable: boolean; + + //No of the Parent Collection, 0 if in no Collection + Parent: Byte; + + SelectColR: real; + SelectColG: real; + SelectColB: real; + SelectInt: real; + SelectTInt: real; + //Fade Mod + SelectW: real; + SelectH: real; + + DeselectColR: real; + DeselectColG: real; + DeselectColB: real; + DeselectInt: real; + DeselectTInt: real; + + procedure SetY(Value: real); + procedure SetX(Value: real); + procedure SetW(Value: real); + procedure SetH(Value: real); + + procedure SetSelect(Value: Boolean); virtual; + property X: real read PosX write SetX; + property Y: real read PosY write SetY; + property Z: real read Texture.z write Texture.z; + property W: real read DeSelectW write SetW; + property H: real read DeSelectH write SetH; + property Selected: Boolean read SelectBool write SetSelect; + + procedure Draw; virtual; + + constructor Create(Textura: TTexture); overload; + constructor Create(Textura, DSTexture: TTexture); overload; + destructor Destroy; override; + end; + +implementation + +uses SysUtils, + {$IFDEF win32} + windows, + {$ELSE} + lclintf, + {$ENDIF} + UDrawTexture; + +procedure TButton.SetX(Value: real); +{var + dx: real; + T: integer; // text} +begin + {dY := Value - Texture.y; + + Texture.X := Value; + + for T := 0 to High(Text) do + Text[T].X := Text[T].X + dY;} + + PosX := Value; + if (FadeTex.TexNum = -1) then + Texture.X := Value; + +end; + +procedure TButton.SetY(Value: real); +{var + dY: real; + T: integer; // text} +begin + {dY := Value - PosY; + + + for T := 0 to High(Text) do + Text[T].Y := Text[T].Y + dY;} + + PosY := Value; + if (FadeTex.TexNum = -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 + T: integer; +begin + SelectBool := Value; + if (Value) then begin + Texture.ColR := SelectColR; + Texture.ColG := SelectColG; + Texture.ColB := SelectColB; + Texture.Int := SelectInt; + + Texture2.ColR := SelectColR; + Texture2.ColG := SelectColG; + Texture2.ColB := SelectColB; + Texture2.Int := SelectInt; + + for T := 0 to High(Text) do + Text[T].Int := SelectTInt; + + //Fade Mod + if Fade then + begin + if (FadeProgress <= 0) then + FadeProgress := 0.125; + end + else + begin + Texture.W := SelectW; + Texture.H := SelectH; + end; + end else begin + Texture.ColR := DeselectColR; + Texture.ColG := DeselectColG; + Texture.ColB := DeselectColB; + Texture.Int := DeselectInt; + + Texture2.ColR := DeselectColR; + Texture2.ColG := DeselectColG; + Texture2.ColB := DeselectColB; + Texture2.Int := DeselectInt; + + for T := 0 to High(Text) do + Text[T].Int := DeselectTInt; + + //Fade Mod + if Fade then + begin + if (FadeProgress >= 1) then + FadeProgress := 0.875; + end + else + begin + Texture.W := DeSelectW; + Texture.H := DeSelectH; + end; + end; +end; + +constructor TButton.Create(); +begin + inherited Create; + // We initialize all to 0, nil or false + Visible := true; + SelectBool := false; + DeselectType := 0; + Selectable := true; + //Reflection Mod + Reflection := true; + + //colorized hack + Colorized:=False; + + // Default +// SelectInt := 1; +// DeselectInt := 0.5; + +{ SelectColR := 0.5; + SelectColG := 0.75; + SelectColB := 0; + SelectInt := 1; + SelectTInt := 1; + + DeselectColR := 1; + DeselectColG := 1; + DeselectColB := 1; + DeselectInt := 0.5; + DeselectTInt := 1;} + + SelectColR := 1; + SelectColG := 1; + SelectColB := 1; + SelectInt := 1; + SelectTInt := 1; + + DeselectColR := 1; + DeselectColG := 1; + DeselectColB := 1; + DeselectInt := 0.5; + DeselectTInt := 1; + + FadeTex.TexNum := -1; + + FadeProgress := 0; + Fade := False; + FadeText := False; + SelectW := DeSelectW; + SelectH := DeSelectH; + + PosX := 0; + PosY := 0; + + Parent := 0; +end; + +// ***** Public methods ****** // + +procedure TButton.Draw; +var + T: integer; + Tick: Cardinal; + Spacing: Real; +begin + if Visible then begin + //Fade Mod + T:=0; + if Fade then + begin + if (FadeProgress < 1) and (FadeProgress > 0) then + begin + Tick := 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; + DeselectTexture.W := Texture.W; + DeselectTexture.H := Texture.H; + end + else //method with Fade Texture + begin + Texture.W := DeSelectW; + Texture.H := DeSelectH; + DeselectTexture.W := Texture.W; + DeselectTexture.H := Texture.H; + + FadeTex.ColR := Texture.ColR; + FadeTex.ColG := Texture.ColG; + FadeTex.ColB := Texture.ColB; + FadeTex.Int := Texture.Int; + + FadeTex.Z := Texture.Z; + + FadeTex.Alpha := Texture.Alpha; + FadeTex.TexX1 := 0; + FadeTex.TexX2 := 1; + FadeTex.TexY1 := 0; + FadeTex.TexY2 := 1; + + Case FadeTexPos of + 0: //FadeTex on Top + begin + //Standard Texture + Texture.X := PosX; + Texture.Y := PosY + (SelectH - DeSelectH) * FadeProgress; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; + //Fade Tex + FadeTex.X := PosX; + FadeTex.Y := PosY; + FadeTex.W := Texture.W; + FadeTex.H := (SelectH - DeSelectH) * FadeProgress; + FadeTex.ScaleW := Texture.ScaleW; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexY2 := 0.9; + end; + 1: //FadeTex on Left + begin + //Standard Texture + Texture.X := PosX + (SelectW - DeSelectW) * FadeProgress; + Texture.Y := PosY; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; + //Fade Tex + FadeTex.X := PosX; + FadeTex.Y := PosY; + FadeTex.H := Texture.H; + FadeTex.W := (SelectW - DeSelectW) * FadeProgress; + FadeTex.ScaleH := Texture.ScaleH; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexX2 := 0.9; + end; + 2: //FadeTex on Bottom + begin + //Standard Texture + Texture.X := PosX; + Texture.Y := PosY; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; + //Fade Tex + FadeTex.X := PosX; + FadeTex.Y := PosY + (SelectH - DeSelectH) * FadeProgress;; + FadeTex.W := Texture.W; + FadeTex.H := (SelectH - DeSelectH) * FadeProgress; + FadeTex.ScaleW := Texture.ScaleW; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexY1 := 0.1; + end; + 3: //FadeTex on Right + begin + //Standard Texture + Texture.X := PosX; + Texture.Y := PosY; + DeselectTexture.X := Texture.X; + DeselectTexture.Y := Texture.Y; + //Fade Tex + FadeTex.X := PosX + (SelectW - DeSelectW) * FadeProgress; + FadeTex.Y := PosY; + FadeTex.H := Texture.H; + FadeTex.W := (SelectW - DeSelectW) * FadeProgress; + FadeTex.ScaleH := Texture.ScaleH; + //Some Hack that Fixes a little Space between both Textures + FadeTex.TexX1 := 0.1; + end; + end; + end; + end + else if (FadeText) then + begin + Text[T].MoveX := (SelectW - DeSelectW); + Text[T].MoveY := (SelectH - DeSelectH); + end; + + if SelectBool or (FadeProgress > 0) or not Colorized then + DrawTexture(Texture) + else + DrawTexture(DeselectTexture); + + //Draw FadeTex + if (FadeTex.TexNum <> -1) then + DrawTexture(FadeTex); + + if Texture2.Alpha > 0 then begin + Texture2.ScaleW := Texture.ScaleW; + Texture2.ScaleH := Texture.ScaleH; + + Texture2.X := Texture.X; + Texture2.Y := Texture.Y; + Texture2.W := Texture.W; + Texture2.H := Texture.H; + + Texture2.ColR := Texture.ColR; + Texture2.ColG := Texture.ColG; + Texture2.ColB := Texture.ColB; + Texture2.Int := Texture.Int; + + Texture2.Z := Texture.Z; + + DrawTexture(Texture2); + end; + + //Reflection Mod + if (Reflection) then // Draw Reflections + begin + if (FadeProgress <> 0) AND (FadeProgress <> 1) then + begin + Spacing := DeSelectReflectionspacing - (DeSelectReflectionspacing - Reflectionspacing) * FadeProgress; + end + else if SelectBool then + Spacing := Reflectionspacing + else + Spacing := DeSelectReflectionspacing; + + if SelectBool or not Colorized then + with Texture do + begin + //Bind Tex and GL Attributes + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + + //Draw + glBegin(GL_QUADS);//Top Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX1*TexW, TexY2*TexH); + glVertex3f(x, y+h*scaleH+ Spacing, z); + + //Bottom Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); + glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); + + + //Bottom Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); + glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); + + //Top Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX2*TexW, TexY2*TexH); + glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); + glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + end else + with DeselectTexture do + begin + //Bind Tex and GL Attributes + glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + + glDepthRange(0, 10); + glDepthFunc(GL_LEQUAL); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBindTexture(GL_TEXTURE_2D, TexNum); + + //Draw + glBegin(GL_QUADS);//Top Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX1*TexW, TexY2*TexH); + glVertex3f(x, y+h*scaleH+ Spacing, z); + + //Bottom Left + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX1*TexW, TexY1+TexH*0.5); + glVertex3f(x, y+h*scaleH + h*scaleH/2 + Spacing, z); + + + //Bottom Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, 0); + glTexCoord2f(TexX2*TexW, TexY1+TexH*0.5); + glVertex3f(x+w*scaleW, y+h*scaleH + h*scaleH/2 + Spacing, z); + + //Top Right + glColor4f(ColR * Int, ColG * Int, ColB * Int, Alpha-0.3); + glTexCoord2f(TexX2*TexW, TexY2*TexH); + glVertex3f(x+w*scaleW, y+h*scaleH + Spacing, z); + glEnd; + + glDisable(GL_TEXTURE_2D); + glDisable(GL_DEPTH_TEST); + glDisable(GL_BLEND); + end; + end; + + for T := 0 to High(Text) do begin + Text[T].Draw; + end; + end; +end; + +// ***** ****** // + +destructor TButton.Destroy; +begin + inherited; +end; + +constructor TButton.Create(Textura: TTexture); +begin + Create(); + Texture := Textura; + DeselectTexture:=Textura; + Texture.ColR := 0; + Texture.ColG := 0.5; + Texture.ColB := 0; + Texture.Int := 1; + Colorized:=False; +end; + +constructor TButton.Create(Textura, DSTexture: TTexture); +begin + Create(); + Texture := Textura; + DeselectTexture := DSTexture; + Texture.ColR := 1; + Texture.ColG := 1; + Texture.ColB := 1; + Texture.Int := 1; + Colorized:=True; +end; + +end. diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index cba237b8..d1c8b7b1 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -1,329 +1,339 @@ -unit UMenuText; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -uses TextGL, UTexture, OpenGL12, SysUtils; - -type - TText = class - private - SelectBool: boolean; - TextString: String; - TextTiles: Array of String; - - STicks: Cardinal; - SelectBlink: Boolean; - public - X: real; - Y: real; - MoveX: real; //Some Modifier for X - Position that don't Affect the Real Y - MoveY: real; //Some Modifier for Y - Position that don't Affect the Real Y - W: real; // if text is wider than W then it is breaked -// H: real; - Size: real; - ColR: real; - ColG: real; - ColB: real; - Alpha: 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 SetText(Value: String); - property Text: String read TextString write SetText; - - procedure DeleteLastL; //Procedure to Delete Last Letter - - 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; - end; - -implementation -uses UGraphic, StrUtils, Windows; - -procedure TText.SetSelect(Value: Boolean); -begin - SelectBool := Value; - - //Set Cursor Visible - SelectBlink := True; - STicks := GettickCount div 550; -end; - -procedure TText.SetText(Value: String); -var - NextPos: Cardinal; //NextPos of a Space etc. - LastPos: Cardinal; //LastPos " - LastBreak: Cardinal; //Last Break - isBreak: Boolean; //True if the Break is not Caused because the Text is out of the area - FirstWord: Word; //Is First Word after Break? - Len: Word; //Length of the Tiles Array - Function Smallest(const A, B: Cardinal):Cardinal; - begin - if (A < B) then - Result := A - else - Result := B; - end; - - Function GetNextPos: Boolean; - var - T1, T2, T3: Cardinal; - begin - LastPos := NextPos; - - //Next Space (If Width is given) - if (W > 0) then - T1 := PosEx(' ', Value, LastPos + 1) - else T1 := Length(Value); - - {//Next - - T2 := PosEx('-', Value, LastPos + 1);} - - //Next Break - T3 := PosEx('\n', Value, LastPos + 1); - - if T1 = 0 then - T1 := Length(Value); - {if T2 = 0 then - T2 := Length(Value); } - if T3 = 0 then - T3 := Length(Value); - - //Get Nearest Pos - NextPos := Smallest(T1, T3{Smallest(T2, T3)}); - - if (LastPos = Length(Value)) then - NextPos := 0; - - isBreak := (NextPos = T3) AND (NextPos <> Length(Value)); - Result := (NextPos <> 0); - end; - procedure AddBreak(const From, bTo: Cardinal); - begin - if (isBreak) OR (bTo - From >= 1) then - begin - Inc(Len); - SetLength (TextTiles, Len); - TextTiles[Len-1] := Trim(Copy(Value, From, bTo - From)); - - if isBreak then - LastBreak := bTo + 2 - else - LastBreak := bTo + 1; - FirstWord := 0; - end; - end; -begin - //Set TExtstring - TextString := Value; - - //Set Cursor Visible - SelectBlink := True; - STicks := GettickCount div 550; - - //Exit if there is no Need to Create Tiles - If (W <= 0) and (Pos('\n', Value) = 0) then - begin - SetLength (TextTiles, 1); - TextTiles[0] := Value; - Exit; - end; - - //Create Tiles - //Reset Text Array - SetLength (TextTiles, 0); - Len := 0; - - //Reset Counter Vars - LastPos := 1; - NextPos := 1; - LastBreak := 1; - FirstWord := 1; - - - if (W > 0) then - begin - //Set Font Propertys - SetFontStyle(Style); - SetFontSize(Size); - end; - - //go Through Text - While (GetNextPos) do - begin - //Break in Text - if isBreak then - begin - //Look for Break before the Break - if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) AND (NextPos-LastPos > 1) then - begin - isBreak := False; - //Not the First word after Break, so we don't have to break within a word - if (FirstWord > 1) then - begin - //Add Break before actual Position, because there the Text fits the Area - AddBreak(LastBreak, LastPos); - end - else //First Word after Break Break within the Word - begin - //ToDo - //AddBreak(LastBreak, LastBreak + 155); - end; - end; - - isBreak := True; - //Add Break from Text - AddBreak(LastBreak, NextPos); - end - //Text comes out of the Text Area -> CreateBreak - else if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) then - begin - //Not the First word after Break, so we don't have to break within a word - if (FirstWord > 1) then - begin - //Add Break before actual Position, because there the Text fits the Area - AddBreak(LastBreak, LastPos); - end - else //First Word after Break -> Break within the Word - begin - //ToDo - //AddBreak(LastBreak, LastBreak + 155); - end; - end; - //end; - Inc(FirstWord) - end; - //Add Ending - AddBreak(LastBreak, Length(Value)+1); -end; - -Procedure TText.DeleteLastL; -var - S: String; - L: Integer; -begin - S := TextString; - L := Length(S); - if (L > 0) then - SetLength(S, L-1); - - SetText(S); -end; - -procedure TText.Draw; -var - X2, Y2: real; - Text2: string; - I: Integer; -begin - if Visible then begin - SetFontStyle(Style); - SetFontSize(Size); - SetFontItalic(False); - glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); - - //If Selected Set Blink... - if SelectBool then - begin - I := Gettickcount div 550; - if I <> STicks then - begin //Change Visability - STicks := I; - SelectBlink := Not SelectBlink; - end; - end; - - {if (False) then //No Width set Draw as one Long String - begin - if not (SelectBool AND SelectBlink) 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 - else - begin} - //Now Use allways: - //Draw Text as Many Strings - Y2 := Y + MoveY; - for I := 0 to high(TextTiles) do - begin - if (not (SelectBool AND SelectBlink)) OR (I <> high(TextTiles)) then - Text2 := TextTiles[I] - else - Text2 := TextTiles[I] + '|'; - - case Align of - 0: X2 := X + MoveX; - 1: X2 := X + MoveX - glTextWidth(pchar(Text2))/2; - 2: X2 := X + MoveX - glTextWidth(pchar(Text2)); - end; - - SetFontPos(X2, Y2); - glPrint(PChar(Text2)); - - {if Size >= 10 then - Y2 := Y2 + Size * 2.8 - else} - if (Style = 1) then - Y2 := Y2 + Size * 2.8 - else - Y2 := Y2 + Size * 2.15; - end; - SetFontStyle(0); // reset to default - - //end; - end; -end; - -constructor TText.Create; -begin - Create(0, 0, ''); -end; - -constructor TText.Create(X, Y: real; Tekst: string); -begin - Create(X, Y, 0, 0, 10, 0, 0, 0, 0, Tekst); -end; - -constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); -begin - inherited Create; - Alpha := 1; - X := ParX; - Y := ParY; - W := ParW; - Style := ParStyle; - Size := ParSize; - Text := ParTekst; - ColR := ParColR; - ColG := ParColG; - ColB := ParColB; - Int := 1; - Align := ParAlign; - SelectBool := false; - Visible := true; -end; - - -end. +unit UMenuText; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses TextGL, + UTexture, + OpenGL12, + SysUtils; + +type + TText = class + private + SelectBool: boolean; + TextString: String; + TextTiles: Array of String; + + STicks: Cardinal; + SelectBlink: Boolean; + public + X: real; + Y: real; + MoveX: real; //Some Modifier for X - Position that don't Affect the Real Y + MoveY: real; //Some Modifier for Y - Position that don't Affect the Real Y + W: real; // if text is wider than W then it is breaked +// H: real; + Size: real; + ColR: real; + ColG: real; + ColB: real; + Alpha: 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 SetText(Value: String); + property Text: String read TextString write SetText; + + procedure DeleteLastL; //Procedure to Delete Last Letter + + 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; + end; + +implementation + +uses UGraphic, + {$IFDEF win32} + windows, + {$ELSE} + lclintf, + {$ENDIF} + StrUtils; + +procedure TText.SetSelect(Value: Boolean); +begin + SelectBool := Value; + + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; +end; + +procedure TText.SetText(Value: String); +var + NextPos: Cardinal; //NextPos of a Space etc. + LastPos: Cardinal; //LastPos " + LastBreak: Cardinal; //Last Break + isBreak: Boolean; //True if the Break is not Caused because the Text is out of the area + FirstWord: Word; //Is First Word after Break? + Len: Word; //Length of the Tiles Array + Function Smallest(const A, B: Cardinal):Cardinal; + begin + if (A < B) then + Result := A + else + Result := B; + end; + + Function GetNextPos: Boolean; + var + T1, T2, T3: Cardinal; + begin + LastPos := NextPos; + + //Next Space (If Width is given) + if (W > 0) then + T1 := PosEx(' ', Value, LastPos + 1) + else T1 := Length(Value); + + {//Next - + T2 := PosEx('-', Value, LastPos + 1);} + + //Next Break + T3 := PosEx('\n', Value, LastPos + 1); + + if T1 = 0 then + T1 := Length(Value); + {if T2 = 0 then + T2 := Length(Value); } + if T3 = 0 then + T3 := Length(Value); + + //Get Nearest Pos + NextPos := Smallest(T1, T3{Smallest(T2, T3)}); + + if (LastPos = Length(Value)) then + NextPos := 0; + + isBreak := (NextPos = T3) AND (NextPos <> Length(Value)); + Result := (NextPos <> 0); + end; + procedure AddBreak(const From, bTo: Cardinal); + begin + if (isBreak) OR (bTo - From >= 1) then + begin + Inc(Len); + SetLength (TextTiles, Len); + TextTiles[Len-1] := Trim(Copy(Value, From, bTo - From)); + + if isBreak then + LastBreak := bTo + 2 + else + LastBreak := bTo + 1; + FirstWord := 0; + end; + end; +begin + //Set TExtstring + TextString := Value; + + //Set Cursor Visible + SelectBlink := True; + STicks := GettickCount div 550; + + //Exit if there is no Need to Create Tiles + If (W <= 0) and (Pos('\n', Value) = 0) then + begin + SetLength (TextTiles, 1); + TextTiles[0] := Value; + Exit; + end; + + //Create Tiles + //Reset Text Array + SetLength (TextTiles, 0); + Len := 0; + + //Reset Counter Vars + LastPos := 1; + NextPos := 1; + LastBreak := 1; + FirstWord := 1; + + + if (W > 0) then + begin + //Set Font Propertys + SetFontStyle(Style); + SetFontSize(Size); + end; + + //go Through Text + While (GetNextPos) do + begin + //Break in Text + if isBreak then + begin + //Look for Break before the Break + if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) AND (NextPos-LastPos > 1) then + begin + isBreak := False; + //Not the First word after Break, so we don't have to break within a word + if (FirstWord > 1) then + begin + //Add Break before actual Position, because there the Text fits the Area + AddBreak(LastBreak, LastPos); + end + else //First Word after Break Break within the Word + begin + //ToDo + //AddBreak(LastBreak, LastBreak + 155); + end; + end; + + isBreak := True; + //Add Break from Text + AddBreak(LastBreak, NextPos); + end + //Text comes out of the Text Area -> CreateBreak + else if (glTextWidth(PChar(Copy(Value, LastBreak, NextPos - LastBreak + 1))) > W) then + begin + //Not the First word after Break, so we don't have to break within a word + if (FirstWord > 1) then + begin + //Add Break before actual Position, because there the Text fits the Area + AddBreak(LastBreak, LastPos); + end + else //First Word after Break -> Break within the Word + begin + //ToDo + //AddBreak(LastBreak, LastBreak + 155); + end; + end; + //end; + Inc(FirstWord) + end; + //Add Ending + AddBreak(LastBreak, Length(Value)+1); +end; + +Procedure TText.DeleteLastL; +var + S: String; + L: Integer; +begin + S := TextString; + L := Length(S); + if (L > 0) then + SetLength(S, L-1); + + SetText(S); +end; + +procedure TText.Draw; +var + X2, Y2: real; + Text2: string; + I: Integer; +begin + if Visible then begin + SetFontStyle(Style); + SetFontSize(Size); + SetFontItalic(False); + glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); + + //If Selected Set Blink... + if SelectBool then + begin + I := Gettickcount div 550; + if I <> STicks then + begin //Change Visability + STicks := I; + SelectBlink := Not SelectBlink; + end; + end; + + {if (False) then //No Width set Draw as one Long String + begin + if not (SelectBool AND SelectBlink) 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 + else + begin} + //Now Use allways: + //Draw Text as Many Strings + Y2 := Y + MoveY; + for I := 0 to high(TextTiles) do + begin + if (not (SelectBool AND SelectBlink)) OR (I <> high(TextTiles)) then + Text2 := TextTiles[I] + else + Text2 := TextTiles[I] + '|'; + + case Align of + 0: X2 := X + MoveX; + 1: X2 := X + MoveX - glTextWidth(pchar(Text2))/2; + 2: X2 := X + MoveX - glTextWidth(pchar(Text2)); + end; + + SetFontPos(X2, Y2); + glPrint(PChar(Text2)); + + {if Size >= 10 then + Y2 := Y2 + Size * 2.8 + else} + if (Style = 1) then + Y2 := Y2 + Size * 2.8 + else + Y2 := Y2 + Size * 2.15; + end; + SetFontStyle(0); // reset to default + + //end; + end; +end; + +constructor TText.Create; +begin + Create(0, 0, ''); +end; + +constructor TText.Create(X, Y: real; Tekst: string); +begin + Create(X, Y, 0, 0, 10, 0, 0, 0, 0, Tekst); +end; + +constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string); +begin + inherited Create; + Alpha := 1; + X := ParX; + Y := ParY; + W := ParW; + Style := ParStyle; + Size := ParSize; + Text := ParTekst; + ColR := ParColR; + ColG := ParColG; + ColB := ParColB; + Int := 1; + Align := ParAlign; + SelectBool := false; + Visible := true; +end; + + +end. -- cgit v1.2.3 From fd5f18250e6da98c47f23f49b7c4663c9a8bf7d3 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Sep 2007 12:37:24 +0000 Subject: Adding new Resource compiler for lazarus projects.. (other one did not name resources correctly) this resource compiler could be expanded by someone to Parse Ultrastar.rc and compile the lrs file, rather than having it hardcoded in USDXResCompiler other changes, include ability to read the Resource String properly in code generated by lazarus. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@422 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 1e6c1e87..ccce325e 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -288,7 +288,8 @@ end; procedure TMenu.AddBackground(Name: string); begin - if Name <> '' then 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; -- cgit v1.2.3 From cf1102dac69a569279ae05dd95426d9e1c544ffc Mon Sep 17 00:00:00 2001 From: jaybinks Date: Sat, 22 Sep 2007 08:15:59 +0000 Subject: minor bug fixes to have lazarus build load resources into SDL_Image correctly... ( lazarus Resources are weak compared to delphi :( ) also Laz build will now run, and main loop works properly. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@429 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index ccce325e..16bc4ab2 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -287,15 +287,23 @@ begin end; procedure TMenu.AddBackground(Name: string); +var + lFileName : 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; + lFileName := Skin.GetTextureFileName(Name); + + if lFileName <> '' then + begin + BackImg := Texture.GetTexture( lFileName , 'Plain'); + + BackImg.W := 800; + BackImg.H := 600; + BackW := 1; + BackH := 1; + end; end; end; -- cgit v1.2.3 From 739ad9a6dee57375f05dcd20dc59ba2d619f11fa Mon Sep 17 00:00:00 2001 From: jaybinks Date: Mon, 24 Sep 2007 13:31:43 +0000 Subject: fixed song loading in Lazarus.. cant assume variables are initialized as 0 :) in UFile "Done: byte;" was no initialized on lazarus compiler. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@431 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 1 + Game/Code/Menu/UMenuText.pas | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 16bc4ab2..291dc201 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -764,6 +764,7 @@ begin for J := 0 to Length(Text) - 1 do Text[J].Draw; + // Draw all ButtonCollections For J := 0 to High(ButtonCollection) do ButtonCollection[J].Draw; diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index d1c8b7b1..19adef03 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -237,10 +237,12 @@ var Text2: string; I: Integer; begin - if Visible then begin + if Visible then + begin SetFontStyle(Style); SetFontSize(Size); SetFontItalic(False); + glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha); //If Selected Set Blink... -- cgit v1.2.3 From 4ae028b8f6e105f2628303a4f8bacbb6f7bcb93a Mon Sep 17 00:00:00 2001 From: b1indy Date: Thu, 27 Sep 2007 23:01:40 +0000 Subject: TextGL.pas: changed text blendmode... most texts should be readable UDisplay.pas: disabled Screenshot code, something's broken (it's called without me even getting close to the print button), maybe we can fix this and rewrite everything to use SDL_Image (any thoughts on this?) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@442 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 1 + 1 file changed, 1 insertion(+) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 6181fab1..077342d3 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -363,6 +363,7 @@ procedure TDisplay.ScreenShot; FileName: String; Num: Integer; begin + Exit; // something broken in here... quick fix... disabled it //bilddatei Suchen for Num := 1 to 9999 do begin FileName := IntToStr(Num); -- cgit v1.2.3 From b29759fbfdd8a013e3d0a85b578934ebec028c41 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Tue, 2 Oct 2007 04:39:22 +0000 Subject: Fixed linux compilation. Linux is now running in the main loop fine. * no audio playback or input yet... * Timing hack inplace.. that must be replace * bunch of textures not working.. however the play screen is looking similar to windows builds. I hope this dosnt break windows builds to much. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@460 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 90 +- Game/Code/Menu/UMenu.pas | 3073 ++++++++++++++++++++++--------------------- 2 files changed, 1593 insertions(+), 1570 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index 077342d3..c83d3c37 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -19,45 +19,41 @@ uses {$IFDEF win32} type TDisplay = class - ActualScreen: PMenu; - NextScreen: PMenu; + ActualScreen : PMenu; + NextScreen : PMenu; //fade-to-black-hack BlackScreen: Boolean; + //popup hack NextScreenWithCheck: Pmenu; - CheckOK: Boolean; + CheckOK : Boolean; - h_DC: HDC; - h_RC: HGLRC; + h_DC : HDC; + h_RC : HGLRC; - Fade: Real; - // fade-mod - doFade: Boolean; - canFade: Boolean; - myFade: integer; - lastTime: Cardinal; + Fade : Real; + doFade : Boolean; + canFade : Boolean; + myFade : integer; + lastTime : Cardinal; pTexData : Pointer; - pTex : array[1..2] of glUInt; - // end + pTex : array[1..2] of glUInt; - //FPS Counter - FPSCounter: Cardinal; - LastFPS: Cardinal; - NextFPSSwap:Cardinal; + FPSCounter : Cardinal; + LastFPS : Cardinal; + NextFPSSwap : Cardinal; - //For Debug OSD - OSD_LastError: String; + OSD_LastError : String; + public + constructor Create; + destructor Destroy; override; - function Draw: Boolean; procedure PrintScreen; - constructor Create; - // fade mod - destructor Destroy; override; - // end procedure ScreenShot; - procedure DrawDebugInformation; + + function Draw: Boolean; end; var @@ -76,7 +72,7 @@ uses {$ENDIF} graphics, TextGL, - // UFiles, +// ULog, UMain, UTexture, UIni, @@ -85,15 +81,17 @@ uses UCommandLine; constructor TDisplay.Create; -var i: integer; +var + i: integer; + begin inherited Create; //popup hack - CheckOK:=False; - NextScreen:=NIL; - NextScreenWithCheck:=NIL; - BlackScreen:=False; + CheckOK := False; + NextScreen := NIL; + NextScreenWithCheck := NIL; + BlackScreen := False; // fade mod myfade:=0; @@ -106,24 +104,37 @@ begin canFade:=True; // generate texture for fading between screens GetMem(pTexData, 512*512*4); + if pTexData <> NIL then for i:= 1 to 2 do begin - glGenTextures(1, pTex[i]); - if glGetError <> GL_NO_ERROR then canFade := False; + + glGenTextures(1, @pTex[i] ); + + if glGetError <> GL_NO_ERROR then + canFade := False; + glBindTexture(GL_TEXTURE_2D, pTex[i]); - if glGetError <> GL_NO_ERROR then canFade := False; + if glGetError <> GL_NO_ERROR then + canFade := False; + glTexImage2D(GL_TEXTURE_2D, 0, 4, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, pTexData); - if glGetError <> GL_NO_ERROR then canFade := False; + if glGetError <> GL_NO_ERROR then + canFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if glGetError <> GL_NO_ERROR then canFade := False; + if glGetError <> GL_NO_ERROR then + canFade := False; + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - if glGetError <> GL_NO_ERROR then canFade := False; + if glGetError <> GL_NO_ERROR then + canFade := False; end else begin canFade:=False; end; + FreeMem(pTexData); // end @@ -131,25 +142,22 @@ begin OSD_LastError := 'No Errors'; end; -// fade mod destructor TDisplay.Destroy; begin if canFade then glDeleteTextures(1,@pTex); + inherited Destroy; end; -// end function TDisplay.Draw: Boolean; var S: integer; Col: Real; - // fade mod myFade2: Real; currentTime: Cardinal; glError: glEnum; glErrorStr: String; - // end begin Result := True; diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 291dc201..2efae5e4 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -1,1529 +1,1544 @@ -unit UMenu; - -interface - -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} - -uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, - UMenuInteract, UThemes, UMenuButtonCollection, Math; - -type -{ Int16 = SmallInt;} - - PMenu = ^TMenu; - TMenu = class - protected - ButtonPos: Integer; - - Interactions: array of TInteract; - SelInteraction: integer; - Button: array of TButton; - Selects: array of TSelect; - SelectsS: array of TSelectSlide; - ButtonCollection: Array of TButtonCollection; - BackImg: TTexture; - BackW: integer; - BackH: integer; - public - Text: array of TText; - Static: array of TStatic; - 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; - - //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic - procedure LoadFromTheme(const ThemeBasic: TThemeBasic); - - procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); - procedure AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); - - // 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; Reflection: Boolean; ReflectionSpacing: Real): 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, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): 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 - 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, 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; - procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); overload; - procedure AddButtonText(CustomButton: TButton; 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, SBGW, 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); - //popup hack - procedure CheckFadeTo(Screen: PMenu; msg: String); - - 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; - - function IsSelectable(Int: Cardinal): Boolean; - - 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; - iBCollectionChild = 5; - -// 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; - - //Set ButtonPos to Autoset Length - ButtonPos := -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; - - //Set ButtonPos to Autoset Length - ButtonPos := -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; - - NewNum := Interactions[Num].Num; - NewTyp := Interactions[Num].Typ; - - case OldTyp of - iButton: Button[OldNum].Selected := False; - iSelect: Selects[OldNum].Selected := False; - iText: Text[OldNum].Selected := False; - iSelectS: SelectsS[OldNum].Selected := False; - //Button Collection Mod - iBCollectionChild: - begin - Button[OldNum].Selected := False; - - //Deselect Collection if Next Button is Not from Collection - if (NewTyp <> iButton) Or (Button[NewNum].Parent <> Button[OldNum].Parent) then - ButtonCollection[Button[OldNum].Parent-1].Selected := False; - end; - end; - - // set active - SelInteraction := Num; - case NewTyp of - iButton: Button[NewNum].Selected := True; - iSelect: Selects[NewNum].Selected := True; - iText: Text[NewNum].Selected := True; - iSelectS: SelectsS[NewNum].Selected := True; - - //Button Collection Mod - iBCollectionChild: - begin - Button[NewNum].Selected := True; - ButtonCollection[Button[NewNum].Parent-1].Selected := True; - end; - end; -end; - -//---------------------- -//LoadFromTheme - Load BG, Texts, Statics and -//Button Collections from ThemeBasic -//---------------------- -procedure TMenu.LoadFromTheme(const ThemeBasic: TThemeBasic); -var - I: Integer; -begin - //Add Button Collections (Set Button CollectionsLength) - //Button Collections are Created when the first ChildButton is Created - PrepareButtonCollections(ThemeBasic.ButtonCollection); - - - //Add Background - AddBackground(ThemeBasic.Background.Tex); - - //Add Statics and Texts - for I := 0 to High(ThemeBasic.Static) do - AddStatic(ThemeBasic.Static[I]); - - for I := 0 to High(ThemeBasic.Text) do - AddText(ThemeBasic.Text[I]); -end; - -procedure TMenu.AddBackground(Name: string); -var - lFileName : string; -begin - if Name <> '' then - begin -// BackImg := Texture.LoadTexture(false, PChar(Skin.SkinPath + FileName), 'JPG', 'Plain', 0); // new theme system - lFileName := Skin.GetTextureFileName(Name); - - if lFileName <> '' then - begin - BackImg := Texture.GetTexture( lFileName , 'Plain'); - - BackImg.W := 800; - BackImg.H := 600; - BackW := 1; - BackH := 1; - end; - end; -end; - -//---------------------- -//PrepareButtonCollections: -//Add Button Collections (Set Button CollectionsLength) -//---------------------- -procedure TMenu.PrepareButtonCollections(const Collections: AThemeButtonCollection); -var - I: Integer; -begin - SetLength(ButtonCollection, Length(Collections)); - For I := 0 to High(ButtonCollection) do - AddButtonCollection(Collections[I], I); -end; - -//---------------------- -//AddButtonCollection: -//Create a Button Collection; -//---------------------- -procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); -var - BT, BTLen: Integer; - TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; - -begin - if (Num > High(ButtonCollection)) then - exit; - -// colorize hack -if ThemeCollection.Style.Typ='Colorized' then -begin - TempR:=floor(255*ThemeCollection.Style.ColR); - TempG:=floor(255*ThemeCollection.Style.ColG); - TempB:=floor(255*ThemeCollection.Style.ColB); - TempR2:=floor(255*ThemeCollection.Style.DColR); - TempG2:=floor(255*ThemeCollection.Style.DColG); - TempB2:=floor(255*ThemeCollection.Style.DColB); - // give encoded color to loadtexture - ButtonCollection[Num] := TButtonCollection.Create(Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.Tex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)), - Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.Tex)), 'JPG', 'Colorized', ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); - -// Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); // use cache texture -end -else - ButtonCollection[Num] := TButtonCollection.Create(Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.Tex), ThemeCollection.Style.Typ, true)); // use cache texture - - //Set Parent menu - ButtonCollection[Num].ScreenButton := @Self.Button; - - //Set Attributes - ButtonCollection[Num].FirstChild := ThemeCollection.FirstChild; - ButtonCollection[Num].CountChilds := ThemeCollection.ChildCount; - ButtonCollection[Num].Parent := Num + 1; - - //Set Style - ButtonCollection[Num].X := ThemeCollection.Style.X; - ButtonCollection[Num].Y := ThemeCollection.Style.Y; - ButtonCollection[Num].W := ThemeCollection.Style.W; - ButtonCollection[Num].H := ThemeCollection.Style.H; - if ThemeCollection.Style.Typ <> 'Colorized' then begin - ButtonCollection[Num].SelectColR := ThemeCollection.Style.ColR; - ButtonCollection[Num].SelectColG := ThemeCollection.Style.ColG; - ButtonCollection[Num].SelectColB := ThemeCollection.Style.ColB; - ButtonCollection[Num].DeselectColR := ThemeCollection.Style.DColR; - ButtonCollection[Num].DeselectColG := ThemeCollection.Style.DColG; - ButtonCollection[Num].DeselectColB := ThemeCollection.Style.DColB; - end; - ButtonCollection[Num].SelectInt := ThemeCollection.Style.Int; - ButtonCollection[Num].DeselectInt := ThemeCollection.Style.DInt; - ButtonCollection[Num].Texture.TexX1 := 0; - ButtonCollection[Num].Texture.TexY1 := 0; - ButtonCollection[Num].Texture.TexX2 := 1; - ButtonCollection[Num].Texture.TexY2 := 1; - ButtonCollection[Num].SetSelect(false); - - ButtonCollection[Num].Reflection := ThemeCollection.Style.Reflection; - ButtonCollection[Num].Reflectionspacing := ThemeCollection.Style.ReflectionSpacing; - ButtonCollection[Num].DeSelectReflectionspacing := ThemeCollection.Style.DeSelectReflectionSpacing; - - ButtonCollection[Num].Z := ThemeCollection.Style.Z; - - //Some Things from ButtonFading - ButtonCollection[Num].SelectH := ThemeCollection.Style.SelectH; - ButtonCollection[Num].SelectW := ThemeCollection.Style.SelectW; - - ButtonCollection[Num].Fade := ThemeCollection.Style.Fade; - ButtonCollection[Num].FadeText := ThemeCollection.Style.FadeText; - if ThemeCollection.Style.Typ='Colorized' then - ButtonCollection[Num].FadeTex := Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)) - else - ButtonCollection[Num].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex), ThemeCollection.Style.Typ, true); - ButtonCollection[Num].FadeTexPos := ThemeCollection.Style.FadeTexPos; - - - BTLen := Length(ThemeCollection.Style.Text); - for BT := 0 to BTLen-1 do begin - AddButtonText(ButtonCollection[Num], ThemeCollection.Style.Text[BT].X, ThemeCollection.Style.Text[BT].Y, - ThemeCollection.Style.Text[BT].ColR, ThemeCollection.Style.Text[BT].ColG, ThemeCollection.Style.Text[BT].ColB, - ThemeCollection.Style.Text[BT].Font, ThemeCollection.Style.Text[BT].Size, ThemeCollection.Style.Text[BT].Align, - ThemeCollection.Style.Text[BT].Text); - 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, ThemeStatic.Reflection, ThemeStatic.Reflectionspacing); - //'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, False, 0); -// -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; Reflection: Boolean; ReflectionSpacing: Real): integer; -var - StatNum: integer; - TempR, TempG, TempB: Cardinal; - TempCol: Cardinal; -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 - -// colorize hack -if Typ='Colorized' then -begin - TempR:=floor(255*ColR); - TempG:=floor(255*ColG); - TempB:=floor(255*ColB); - // give encoded color to loadtexture - Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR shl 8) or TempG) shl 8)or TempB))); -end -else - 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; - if Typ <> 'Colorized' then begin - Static[StatNum].Texture.ColR := ColR; - Static[StatNum].Texture.ColG := ColG; - Static[StatNum].Texture.ColB := ColB; - end; - 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; - - //ReflectionMod - Static[StatNum].Reflection := Reflection; - Static[StatNum].ReflectionSpacing := ReflectionSpacing; - - Result := StatNum; -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); -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, 0, Style, Size, ColR, ColG, ColB, 0, Tekst); -end; - -function TMenu.AddText(X, Y, W: 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, W, Style, Size, ColR, ColG, ColB, Align, Tekst); - Result := TextNum; -end; - -//Function that Set Length of Button Array in one Step instead of register new Memory for every Button -Procedure TMenu.SetButtonLength(Length: Cardinal); -begin - if (ButtonPos = -1) AND (Length > 0) then - begin - //Set Length of Button - SetLength(Button, Length); - - //Set ButtonPos to start with 0 - ButtonPos := 0; - end; -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; - TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; -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, ThemeButton.Reflectionspacing, ThemeButton.DeSelectReflectionspacing); - - Button[Result].Z := ThemeButton.Z; - - //Button Visibility - Button[Result].Visible := ThemeButton.Visible; - - //Some Things from ButtonFading - Button[Result].SelectH := ThemeButton.SelectH; - Button[Result].SelectW := ThemeButton.SelectW; - - Button[Result].Fade := ThemeButton.Fade; - Button[Result].FadeText := ThemeButton.FadeText; - if ThemeButton.Typ='Colorized' then begin - TempR:=floor(255*ThemeButton.ColR); - TempG:=floor(255*ThemeButton.ColG); - TempB:=floor(255*ThemeButton.ColB); - Button[Result].FadeTex := Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeButton.FadeTex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)); - end - else - 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 - 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; - - //BAutton Collection Mod - if (ThemeButton.Parent <> 0) then - begin - //If Collection Exists then Change Interaction to Child Button - if (@ButtonCollection[ThemeButton.Parent-1] <> nil) then - begin - Interactions[High(Interactions)].Typ := iBCollectionChild; - Button[Result].Visible := False; - - for BT := 0 to BTLen-1 do - Button[Result].Text[BT].Alpha := 0; - - Button[Result].Parent := ThemeButton.Parent; - if (ButtonCollection[ThemeButton.Parent-1].Fade) then - Button[Result].Texture.Alpha := 0; - end; - 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, 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, DeSelectReflectionSpacing: Real): integer; -var TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; -begin - // adds button - //SetLength is used once to reduce Memory usement - if (ButtonPos <> -1) then - begin - Result := ButtonPos; - Inc(ButtonPos) - end - else //Old Method -> Reserve new Memory for every Button - begin - Result := Length(Button); - SetLength(Button, Result + 1); - end; -// Button[Result] := 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 -// colorize hack -if Typ='Colorized' then -begin - TempR:=floor(255*ColR); - TempG:=floor(255*ColG); - TempB:=floor(255*ColB); - TempR2:=floor(255*DColR); - TempG2:=floor(255*DColG); - TempB2:=floor(255*DColB); - // give encoded color to loadtexture - Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR shl 8) or TempG) shl 8)or TempB)), - Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); - -// Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); // use cache texture -end -else - - Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, true)); // use cache texture -// else -// Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, false)); // don't use cache texture} - - // configures button - Button[Result].X := X; - Button[Result].Y := Y; - Button[Result].W := W; - Button[Result].H := H; - if Typ <> 'Colorized' then begin - Button[Result].SelectColR := ColR; - Button[Result].SelectColG := ColG; - Button[Result].SelectColB := ColB; - Button[Result].DeselectColR := DColR; - Button[Result].DeselectColG := DColG; - Button[Result].DeselectColB := DColB; - end; - Button[Result].SelectInt := Int; - Button[Result].DeselectInt := DInt; - Button[Result].Texture.TexX1 := 0; - Button[Result].Texture.TexY1 := 0; - Button[Result].Texture.TexX2 := 1; - Button[Result].Texture.TexY2 := 1; - Button[Result].SetSelect(false); - - Button[Result].Reflection := Reflection; - Button[Result].Reflectionspacing := ReflectionSpacing; - Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing; - - //Button Collection Mod - Button[Result].Parent := 0; - - - // adds interaction - AddInteraction(iButton, Result); - 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 - 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 - // does anyone know what these loops were for? -{ // 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} - BackImg.X:=BackW; - BackImg.Y:=BackW; - DrawTexture(BackImg); - 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; - - - // Draw all ButtonCollections - For J := 0 to High(ButtonCollection) do - ButtonCollection[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;} - -function TMenu.IsSelectable(Int: Cardinal): Boolean; -begin - Result := True; - Case Interactions[Int].Typ of - //Button - iButton: Result := Button[Interactions[Int].Num].Visible and Button[Interactions[Int].Num].Selectable; - //Select - iSelect: Result := True; - //Select Slide - iSelectS: Result := SelectsS[Interactions[Int].Num].Visible; - - //ButtonCollection Child - iBCollectionChild: - Result := (ButtonCollection[Button[Interactions[Int].Num].Parent - 1].FirstChild - 1 = Int) AND ((Interactions[Interaction].Typ <> iBCollectionChild) OR (Button[Interactions[Interaction].Num].Parent <> Button[Interactions[Int].Num].Parent)); - end; -end; - -procedure TMenu.InteractNext; -var - Int: Integer; -begin - Int := Interaction; - - // change interaction as long as it's needed - repeat - Int := (Int + 1) Mod Length(Interactions); - - //If no Interaction is Selectable Simply Select Next - if (Int = Interaction) then - begin - Int := (Int + 1) Mod Length(Interactions); - Break; - end; - Until IsSelectable(Int); - - //Set Interaction - Interaction := Int; -end; - - -procedure TMenu.InteractPrev; -var - Int: Integer; -begin - Int := Interaction; - - // change interaction as long as it's needed - repeat - Int := Int - 1; - if Int = -1 then Int := High(Interactions); - - //If no Interaction is Selectable Simply Select Next - if (Int = Interaction) then - begin - Int := SelInteraction - 1; - if Int = -1 then Int := High(Interactions); - Break; - end; - Until IsSelectable(Int); - - //Set Interaction - Interaction := Int -end; - - -procedure TMenu.InteractCustom(CustomSwitch: integer); -var - Num: integer; - Typ: integer; - Again: boolean; -begin - //Code Commented atm, because it needs to be Rewritten - //it doesn't work with Button Collections - {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; - -//popup hack -procedure TMenu.CheckFadeTo(Screen: PMenu; msg: String); -begin - Display.Fade := 0; - Display.NextScreenWithCheck := Screen; - Display.CheckOK:=False; - ScreenPopupCheck.ShowPopup(msg); -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; - -procedure TMenu.AddButtonText(CustomButton: TButton; AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); -var - Il: integer; -begin - with CustomButton 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.SBGW, - 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]); - - SelectsS[High(SelectsS)].Text.Size := ThemeSelectS.TextSize; - - SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z; - SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z; - - //Generate Lines - SelectsS[High(SelectsS)].GenLines; - - SelectsS[High(SelectsS)].SelectedOption := SelectsS[High(SelectsS)].SelectOptInt; // refresh -end; - -function TMenu.AddSelectSlide(X, Y, W, H, SkipX, SBGW, 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].SBGW := SBGW; - 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 + (SelectsS[S].TextureSBG.H / 2) - 15; - 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; - //Button Collection Mod - iBCollectionChild: - begin - - //Select Next Button in Collection - For Num := 1 to High(Button) do - begin - Value := (Interaction + Num) Mod Length(Button); - if Value = 0 then - begin - InteractNext; - Break; - end; - if (Button[Value].Parent = Button[Interaction].Parent) then - begin - Interaction := Value; - Break; - end; - end; - end; - //interact Next if there is Nothing to Change - else InteractNext; - 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; - //Button Collection Mod - iBCollectionChild: - begin - //Select Prev Button in Collection - For Num := High(Button) downto 1 do - begin - Value := (Interaction + Num) Mod Length(Button); - if Value = High(Button) then - begin - InteractPrev; - Break; - end; - if (Button[Value].Parent = Button[Interaction].Parent) then - begin - Interaction := Value; - Break; - end; - end; - end; - //interact Prev if there is Nothing to Change - else - begin - InteractPrev; - //If ButtonCollection with more than 1 Entry then Select Last Entry - if (Button[Interactions[Interaction].Num].Parent <> 0) AND (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then - begin - //Select Last Child - For Num := High(Button) downto 1 do - begin - Value := (Interaction + Num) Mod Length(Button); - if (Button[Value].Parent = Button[Interaction].Parent) then - begin - Interaction := Value; - Break; - end; - end; - end; - 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. - +unit UMenu; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, + UMenuInteract, UThemes, UMenuButtonCollection, Math; + +type +{ Int16 = SmallInt;} + + PMenu = ^TMenu; + TMenu = class + protected + ButtonPos: Integer; + + Interactions: array of TInteract; + SelInteraction: integer; + Button: array of TButton; + Selects: array of TSelect; + SelectsS: array of TSelectSlide; + ButtonCollection: Array of TButtonCollection; + BackImg: TTexture; + BackW: integer; + BackH: integer; + public + Text: array of TText; + Static: array of TStatic; + 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; + + //Procedure Load BG, Texts, Statics and Button Collections from ThemeBasic + procedure LoadFromTheme(const ThemeBasic: TThemeBasic); + + procedure PrepareButtonCollections(const Collections: AThemeButtonCollection); + procedure AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); + + // 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; Reflection: Boolean; ReflectionSpacing: Real): 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, W: real; Style: integer; Size, ColR, ColG, ColB: real; Align: integer; Tekst: string): 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 + 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, 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; + procedure AddButtonText(AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); overload; + procedure AddButtonText(CustomButton: TButton; 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, SBGW, 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); + //popup hack + procedure CheckFadeTo(Screen: PMenu; msg: String); + + 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; + + function IsSelectable(Int: Cardinal): Boolean; + + 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; + iBCollectionChild = 5; + +// fBlack = 0; // fade type +// fWhite = 1; + +implementation + +uses UCommon, + 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; + + //Set ButtonPos to Autoset Length + ButtonPos := -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; + + //Set ButtonPos to Autoset Length + ButtonPos := -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; + + NewNum := Interactions[Num].Num; + NewTyp := Interactions[Num].Typ; + + case OldTyp of + iButton: Button[OldNum].Selected := False; + iSelect: Selects[OldNum].Selected := False; + iText: Text[OldNum].Selected := False; + iSelectS: SelectsS[OldNum].Selected := False; + //Button Collection Mod + iBCollectionChild: + begin + Button[OldNum].Selected := False; + + //Deselect Collection if Next Button is Not from Collection + if (NewTyp <> iButton) Or (Button[NewNum].Parent <> Button[OldNum].Parent) then + ButtonCollection[Button[OldNum].Parent-1].Selected := False; + end; + end; + + // set active + SelInteraction := Num; + case NewTyp of + iButton: Button[NewNum].Selected := True; + iSelect: Selects[NewNum].Selected := True; + iText: Text[NewNum].Selected := True; + iSelectS: SelectsS[NewNum].Selected := True; + + //Button Collection Mod + iBCollectionChild: + begin + Button[NewNum].Selected := True; + ButtonCollection[Button[NewNum].Parent-1].Selected := True; + end; + end; +end; + +//---------------------- +//LoadFromTheme - Load BG, Texts, Statics and +//Button Collections from ThemeBasic +//---------------------- +procedure TMenu.LoadFromTheme(const ThemeBasic: TThemeBasic); +var + I: Integer; +begin + //Add Button Collections (Set Button CollectionsLength) + //Button Collections are Created when the first ChildButton is Created + PrepareButtonCollections(ThemeBasic.ButtonCollection); + + {$ifdef fpc} + writeln(' TMenu.LoadFromThem : '+ThemeBasic.Background.Tex ); + {$endif} + + //Add Background + AddBackground(ThemeBasic.Background.Tex); + + //Add Statics and Texts + for I := 0 to High(ThemeBasic.Static) do + AddStatic(ThemeBasic.Static[I]); + + for I := 0 to High(ThemeBasic.Text) do + AddText(ThemeBasic.Text[I]); +end; + +procedure TMenu.AddBackground(Name: string); +var + lFileName : string; +begin + if Name <> '' then + begin +// BackImg := Texture.LoadTexture(false, PChar(Skin.SkinPath + FileName), 'JPG', 'Plain', 0); // new theme system + lFileName := Skin.GetTextureFileName(Name); + lFileName := AdaptFilePaths( lFileName ); + + {$ifdef fpc} + writeln(' TMenu.AddBackground : '+Name+ ' - '+ lFileName ); + {$endif} + +// if lFileName <> '' then + if fileexists( lFileName ) then + begin + BackImg := Texture.GetTexture( lFileName , 'Plain'); + + {$ifdef fpc} + writeln(' TMenu.AddBackground : '+ lFileName +' - LOADED'); + {$endif} + + + BackImg.W := 800; + BackImg.H := 600; + BackW := 1; + BackH := 1; + end; + end; +end; + +//---------------------- +//PrepareButtonCollections: +//Add Button Collections (Set Button CollectionsLength) +//---------------------- +procedure TMenu.PrepareButtonCollections(const Collections: AThemeButtonCollection); +var + I: Integer; +begin + SetLength(ButtonCollection, Length(Collections)); + For I := 0 to High(ButtonCollection) do + AddButtonCollection(Collections[I], I); +end; + +//---------------------- +//AddButtonCollection: +//Create a Button Collection; +//---------------------- +procedure TMenu.AddButtonCollection(const ThemeCollection: TThemeButtonCollection; Const Num: Byte); +var + BT, BTLen: Integer; + TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; + +begin + if (Num > High(ButtonCollection)) then + exit; + +// colorize hack +if ThemeCollection.Style.Typ='Colorized' then +begin + TempR:=floor(255*ThemeCollection.Style.ColR); + TempG:=floor(255*ThemeCollection.Style.ColG); + TempB:=floor(255*ThemeCollection.Style.ColB); + TempR2:=floor(255*ThemeCollection.Style.DColR); + TempG2:=floor(255*ThemeCollection.Style.DColG); + TempB2:=floor(255*ThemeCollection.Style.DColB); + // give encoded color to loadtexture + ButtonCollection[Num] := TButtonCollection.Create(Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.Tex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)), + Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.Tex)), 'JPG', 'Colorized', ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); + +// Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); // use cache texture +end +else + ButtonCollection[Num] := TButtonCollection.Create(Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.Tex), ThemeCollection.Style.Typ, true)); // use cache texture + + //Set Parent menu + ButtonCollection[Num].ScreenButton := @Self.Button; + + //Set Attributes + ButtonCollection[Num].FirstChild := ThemeCollection.FirstChild; + ButtonCollection[Num].CountChilds := ThemeCollection.ChildCount; + ButtonCollection[Num].Parent := Num + 1; + + //Set Style + ButtonCollection[Num].X := ThemeCollection.Style.X; + ButtonCollection[Num].Y := ThemeCollection.Style.Y; + ButtonCollection[Num].W := ThemeCollection.Style.W; + ButtonCollection[Num].H := ThemeCollection.Style.H; + if ThemeCollection.Style.Typ <> 'Colorized' then begin + ButtonCollection[Num].SelectColR := ThemeCollection.Style.ColR; + ButtonCollection[Num].SelectColG := ThemeCollection.Style.ColG; + ButtonCollection[Num].SelectColB := ThemeCollection.Style.ColB; + ButtonCollection[Num].DeselectColR := ThemeCollection.Style.DColR; + ButtonCollection[Num].DeselectColG := ThemeCollection.Style.DColG; + ButtonCollection[Num].DeselectColB := ThemeCollection.Style.DColB; + end; + ButtonCollection[Num].SelectInt := ThemeCollection.Style.Int; + ButtonCollection[Num].DeselectInt := ThemeCollection.Style.DInt; + ButtonCollection[Num].Texture.TexX1 := 0; + ButtonCollection[Num].Texture.TexY1 := 0; + ButtonCollection[Num].Texture.TexX2 := 1; + ButtonCollection[Num].Texture.TexY2 := 1; + ButtonCollection[Num].SetSelect(false); + + ButtonCollection[Num].Reflection := ThemeCollection.Style.Reflection; + ButtonCollection[Num].Reflectionspacing := ThemeCollection.Style.ReflectionSpacing; + ButtonCollection[Num].DeSelectReflectionspacing := ThemeCollection.Style.DeSelectReflectionSpacing; + + ButtonCollection[Num].Z := ThemeCollection.Style.Z; + + //Some Things from ButtonFading + ButtonCollection[Num].SelectH := ThemeCollection.Style.SelectH; + ButtonCollection[Num].SelectW := ThemeCollection.Style.SelectW; + + ButtonCollection[Num].Fade := ThemeCollection.Style.Fade; + ButtonCollection[Num].FadeText := ThemeCollection.Style.FadeText; + if ThemeCollection.Style.Typ='Colorized' then + ButtonCollection[Num].FadeTex := Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)) + else + ButtonCollection[Num].FadeTex := Texture.GetTexture(Skin.GetTextureFileName(ThemeCollection.Style.FadeTex), ThemeCollection.Style.Typ, true); + ButtonCollection[Num].FadeTexPos := ThemeCollection.Style.FadeTexPos; + + + BTLen := Length(ThemeCollection.Style.Text); + for BT := 0 to BTLen-1 do begin + AddButtonText(ButtonCollection[Num], ThemeCollection.Style.Text[BT].X, ThemeCollection.Style.Text[BT].Y, + ThemeCollection.Style.Text[BT].ColR, ThemeCollection.Style.Text[BT].ColG, ThemeCollection.Style.Text[BT].ColB, + ThemeCollection.Style.Text[BT].Font, ThemeCollection.Style.Text[BT].Size, ThemeCollection.Style.Text[BT].Align, + ThemeCollection.Style.Text[BT].Text); + 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, ThemeStatic.Reflection, ThemeStatic.Reflectionspacing); + //'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, False, 0); +// +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; Reflection: Boolean; ReflectionSpacing: Real): integer; +var + StatNum: integer; + TempR, TempG, TempB: Cardinal; + TempCol: Cardinal; +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 + +// colorize hack +if Typ='Colorized' then +begin + TempR:=floor(255*ColR); + TempG:=floor(255*ColG); + TempB:=floor(255*ColB); + // give encoded color to loadtexture + Static[StatNum] := TStatic.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR shl 8) or TempG) shl 8)or TempB))); +end +else + 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; + if Typ <> 'Colorized' then begin + Static[StatNum].Texture.ColR := ColR; + Static[StatNum].Texture.ColG := ColG; + Static[StatNum].Texture.ColB := ColB; + end; + 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; + + //ReflectionMod + Static[StatNum].Reflection := Reflection; + Static[StatNum].ReflectionSpacing := ReflectionSpacing; + + Result := StatNum; +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); +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, 0, Style, Size, ColR, ColG, ColB, 0, Tekst); +end; + +function TMenu.AddText(X, Y, W: 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, W, Style, Size, ColR, ColG, ColB, Align, Tekst); + Result := TextNum; +end; + +//Function that Set Length of Button Array in one Step instead of register new Memory for every Button +Procedure TMenu.SetButtonLength(Length: Cardinal); +begin + if (ButtonPos = -1) AND (Length > 0) then + begin + //Set Length of Button + SetLength(Button, Length); + + //Set ButtonPos to start with 0 + ButtonPos := 0; + end; +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; + TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; +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, ThemeButton.Reflectionspacing, ThemeButton.DeSelectReflectionspacing); + + Button[Result].Z := ThemeButton.Z; + + //Button Visibility + Button[Result].Visible := ThemeButton.Visible; + + //Some Things from ButtonFading + Button[Result].SelectH := ThemeButton.SelectH; + Button[Result].SelectW := ThemeButton.SelectW; + + Button[Result].Fade := ThemeButton.Fade; + Button[Result].FadeText := ThemeButton.FadeText; + if ThemeButton.Typ='Colorized' then begin + TempR:=floor(255*ThemeButton.ColR); + TempG:=floor(255*ThemeButton.ColG); + TempB:=floor(255*ThemeButton.ColB); + Button[Result].FadeTex := Texture.LoadTexture(PChar(Skin.GetTextureFileName(ThemeButton.FadeTex)), 'JPG', 'Colorized', ((((TempR shl 8) or TempG) shl 8)or TempB)); + end + else + 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 + 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; + + //BAutton Collection Mod + if (ThemeButton.Parent <> 0) then + begin + //If Collection Exists then Change Interaction to Child Button + if (@ButtonCollection[ThemeButton.Parent-1] <> nil) then + begin + Interactions[High(Interactions)].Typ := iBCollectionChild; + Button[Result].Visible := False; + + for BT := 0 to BTLen-1 do + Button[Result].Text[BT].Alpha := 0; + + Button[Result].Parent := ThemeButton.Parent; + if (ButtonCollection[ThemeButton.Parent-1].Fade) then + Button[Result].Texture.Alpha := 0; + end; + 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, 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, DeSelectReflectionSpacing: Real): integer; +var TempR, TempG, TempB, TempR2, TempG2, TempB2: Cardinal; +begin + // adds button + //SetLength is used once to reduce Memory usement + if (ButtonPos <> -1) then + begin + Result := ButtonPos; + Inc(ButtonPos) + end + else //Old Method -> Reserve new Memory for every Button + begin + Result := Length(Button); + SetLength(Button, Result + 1); + end; +// Button[Result] := 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 +// colorize hack +if Typ='Colorized' then +begin + TempR:=floor(255*ColR); + TempG:=floor(255*ColG); + TempB:=floor(255*ColB); + TempR2:=floor(255*DColR); + TempG2:=floor(255*DColG); + TempB2:=floor(255*DColB); + // give encoded color to loadtexture + Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR shl 8) or TempG) shl 8)or TempB)), + Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); + +// Button[Result] := TButton.Create(Texture.LoadTexture(PChar(Name), PChar(Format), PChar(Typ), ((((TempR2 shl 8) or TempG2) shl 8)or TempB2))); // use cache texture +end +else + + Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, true)); // use cache texture +// else +// Button[Result] := TButton.Create(Texture.GetTexture(Name, Typ, false)); // don't use cache texture} + + // configures button + Button[Result].X := X; + Button[Result].Y := Y; + Button[Result].W := W; + Button[Result].H := H; + if Typ <> 'Colorized' then begin + Button[Result].SelectColR := ColR; + Button[Result].SelectColG := ColG; + Button[Result].SelectColB := ColB; + Button[Result].DeselectColR := DColR; + Button[Result].DeselectColG := DColG; + Button[Result].DeselectColB := DColB; + end; + Button[Result].SelectInt := Int; + Button[Result].DeselectInt := DInt; + Button[Result].Texture.TexX1 := 0; + Button[Result].Texture.TexY1 := 0; + Button[Result].Texture.TexX2 := 1; + Button[Result].Texture.TexY2 := 1; + Button[Result].SetSelect(false); + + Button[Result].Reflection := Reflection; + Button[Result].Reflectionspacing := ReflectionSpacing; + Button[Result].DeSelectReflectionspacing := DeSelectReflectionSpacing; + + //Button Collection Mod + Button[Result].Parent := 0; + + + // adds interaction + AddInteraction(iButton, Result); + 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 + 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 + // does anyone know what these loops were for? +{ // 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} + BackImg.X:=BackW; + BackImg.Y:=BackW; + DrawTexture(BackImg); + 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; + + + // Draw all ButtonCollections + For J := 0 to High(ButtonCollection) do + ButtonCollection[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;} + +function TMenu.IsSelectable(Int: Cardinal): Boolean; +begin + Result := True; + Case Interactions[Int].Typ of + //Button + iButton: Result := Button[Interactions[Int].Num].Visible and Button[Interactions[Int].Num].Selectable; + //Select + iSelect: Result := True; + //Select Slide + iSelectS: Result := SelectsS[Interactions[Int].Num].Visible; + + //ButtonCollection Child + iBCollectionChild: + Result := (ButtonCollection[Button[Interactions[Int].Num].Parent - 1].FirstChild - 1 = Int) AND ((Interactions[Interaction].Typ <> iBCollectionChild) OR (Button[Interactions[Interaction].Num].Parent <> Button[Interactions[Int].Num].Parent)); + end; +end; + +procedure TMenu.InteractNext; +var + Int: Integer; +begin + Int := Interaction; + + // change interaction as long as it's needed + repeat + Int := (Int + 1) Mod Length(Interactions); + + //If no Interaction is Selectable Simply Select Next + if (Int = Interaction) then + begin + Int := (Int + 1) Mod Length(Interactions); + Break; + end; + Until IsSelectable(Int); + + //Set Interaction + Interaction := Int; +end; + + +procedure TMenu.InteractPrev; +var + Int: Integer; +begin + Int := Interaction; + + // change interaction as long as it's needed + repeat + Int := Int - 1; + if Int = -1 then Int := High(Interactions); + + //If no Interaction is Selectable Simply Select Next + if (Int = Interaction) then + begin + Int := SelInteraction - 1; + if Int = -1 then Int := High(Interactions); + Break; + end; + Until IsSelectable(Int); + + //Set Interaction + Interaction := Int +end; + + +procedure TMenu.InteractCustom(CustomSwitch: integer); +var + Num: integer; + Typ: integer; + Again: boolean; +begin + //Code Commented atm, because it needs to be Rewritten + //it doesn't work with Button Collections + {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; + +//popup hack +procedure TMenu.CheckFadeTo(Screen: PMenu; msg: String); +begin + Display.Fade := 0; + Display.NextScreenWithCheck := Screen; + Display.CheckOK:=False; + ScreenPopupCheck.ShowPopup(msg); +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; + +procedure TMenu.AddButtonText(CustomButton: TButton; AddX, AddY: real; ColR, ColG, ColB: real; Font: integer; Size: integer; Align: integer; AddText: string); +var + Il: integer; +begin + with CustomButton 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.SBGW, + 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]); + + SelectsS[High(SelectsS)].Text.Size := ThemeSelectS.TextSize; + + SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z; + SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z; + + //Generate Lines + SelectsS[High(SelectsS)].GenLines; + + SelectsS[High(SelectsS)].SelectedOption := SelectsS[High(SelectsS)].SelectOptInt; // refresh +end; + +function TMenu.AddSelectSlide(X, Y, W, H, SkipX, SBGW, 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].SBGW := SBGW; + 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 + (SelectsS[S].TextureSBG.H / 2) - 15; + 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; + //Button Collection Mod + iBCollectionChild: + begin + + //Select Next Button in Collection + For Num := 1 to High(Button) do + begin + Value := (Interaction + Num) Mod Length(Button); + if Value = 0 then + begin + InteractNext; + Break; + end; + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + //interact Next if there is Nothing to Change + else InteractNext; + 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; + //Button Collection Mod + iBCollectionChild: + begin + //Select Prev Button in Collection + For Num := High(Button) downto 1 do + begin + Value := (Interaction + Num) Mod Length(Button); + if Value = High(Button) then + begin + InteractPrev; + Break; + end; + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + //interact Prev if there is Nothing to Change + else + begin + InteractPrev; + //If ButtonCollection with more than 1 Entry then Select Last Entry + if (Button[Interactions[Interaction].Num].Parent <> 0) AND (ButtonCollection[Button[Interactions[Interaction].Num].Parent-1].CountChilds > 1) then + begin + //Select Last Child + For Num := High(Button) downto 1 do + begin + Value := (Interaction + Num) Mod Length(Button); + if (Button[Value].Parent = Button[Interaction].Parent) then + begin + Interaction := Value; + Break; + end; + end; + end; + 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. + -- cgit v1.2.3 From 2b83fa1741b6b2d4c7548cd165f2158f9fdb351f Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Sat, 27 Oct 2007 09:02:09 +0000 Subject: Fixed "White Line" Bug -> I think so ;) (Bg was not at the right position) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@534 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 2efae5e4..75d6a957 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -761,8 +761,12 @@ begin BackImg.Y := (PetY-1)/BackH * 600; //480 DrawTexture(BackImg); end; // for PetX} - BackImg.X:=BackW; - BackImg.Y:=BackW; + {BackImg.X:=BackW; + BackImg.Y:=BackW; } + BackImg.X := 0; + BackImg.Y := 0; + BackImg.W := 800; + BackImg.H := 600; DrawTexture(BackImg); end; // if end; -- cgit v1.2.3 From 391d30716d48dc709f6444b19c008e82311623b9 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 1 Nov 2007 19:34:40 +0000 Subject: Mac OS X version compiles and links. I hope I didn't break too many files on windows/linux. Added switches.inc to all files. Changed many IFDEFs. For Windows-only code please use MSWINDOWS instead of WIN32 now. WIN32 is also used by the Mac port. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@546 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 6 ++---- Game/Code/Menu/UDrawTexture.pas | 3 +++ Game/Code/Menu/UMenu.pas | 4 +--- Game/Code/Menu/UMenuButton.pas | 3 +++ Game/Code/Menu/UMenuButtonCollection.pas | 3 +++ Game/Code/Menu/UMenuInteract.pas | 2 ++ Game/Code/Menu/UMenuSelect.pas | 3 +++ Game/Code/Menu/UMenuSelectSlide.pas | 4 +--- Game/Code/Menu/UMenuStatic.pas | 3 +++ Game/Code/Menu/UMenuText.pas | 37 +++++++++++++++++++++++++++++--- 10 files changed, 55 insertions(+), 13 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index c83d3c37..b3529d0a 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,9 +2,7 @@ unit UDisplay; interface -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} +{$I switches.inc} uses {$IFDEF win32} windows, @@ -62,7 +60,7 @@ var implementation uses - {$IFDEF FPC} + {$IFDEF LAZARUS} ulazjpeg, {$ELSE} JPEG, diff --git a/Game/Code/Menu/UDrawTexture.pas b/Game/Code/Menu/UDrawTexture.pas index 5a543f33..de20bd4b 100644 --- a/Game/Code/Menu/UDrawTexture.pas +++ b/Game/Code/Menu/UDrawTexture.pas @@ -1,6 +1,9 @@ unit UDrawTexture; interface + +{$I switches.inc} + uses UTexture; procedure DrawLine(X1, Y1, X2, Y2, ColR, ColG, ColB: real); diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 75d6a957..08ba1e4d 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -2,9 +2,7 @@ unit UMenu; interface -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} +{$I switches.inc} uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, UMenuInteract, UThemes, UMenuButtonCollection, Math; diff --git a/Game/Code/Menu/UMenuButton.pas b/Game/Code/Menu/UMenuButton.pas index af4f69ee..93b987b7 100644 --- a/Game/Code/Menu/UMenuButton.pas +++ b/Game/Code/Menu/UMenuButton.pas @@ -1,6 +1,9 @@ unit UMenuButton; interface + +{$I switches.inc} + uses TextGL, UTexture, OpenGL12, UMenuText; type diff --git a/Game/Code/Menu/UMenuButtonCollection.pas b/Game/Code/Menu/UMenuButtonCollection.pas index 5c9045a7..981452b1 100644 --- a/Game/Code/Menu/UMenuButtonCollection.pas +++ b/Game/Code/Menu/UMenuButtonCollection.pas @@ -1,6 +1,9 @@ unit UMenuButtonCollection; interface + +{$I switches.inc} + uses UMenuButton; type diff --git a/Game/Code/Menu/UMenuInteract.pas b/Game/Code/Menu/UMenuInteract.pas index 43249e3e..78f9bd89 100644 --- a/Game/Code/Menu/UMenuInteract.pas +++ b/Game/Code/Menu/UMenuInteract.pas @@ -2,6 +2,8 @@ unit UMenuInteract; interface +{$I switches.inc} + type TInteract = record // for moving thru menu Typ: integer; // 0 - button, 1 - select, 2 - Text, 3 - Select SLide, 5 - ButtonCollection Child diff --git a/Game/Code/Menu/UMenuSelect.pas b/Game/Code/Menu/UMenuSelect.pas index 72141a27..b0ee2b78 100644 --- a/Game/Code/Menu/UMenuSelect.pas +++ b/Game/Code/Menu/UMenuSelect.pas @@ -1,6 +1,9 @@ unit UMenuSelect; interface + +{$I switches.inc} + uses TextGL, UTexture, OpenGL12, UMenuText; type diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index bb9b5809..e4c5f959 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -2,9 +2,7 @@ unit UMenuSelectSlide; interface -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} +{$I switches.inc} uses TextGL, UTexture, diff --git a/Game/Code/Menu/UMenuStatic.pas b/Game/Code/Menu/UMenuStatic.pas index cfa4a596..a2c709ad 100644 --- a/Game/Code/Menu/UMenuStatic.pas +++ b/Game/Code/Menu/UMenuStatic.pas @@ -1,6 +1,9 @@ unit UMenuStatic; interface + +{$I switches.inc} + uses UTexture, OpenGL12; type diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 19adef03..350c28de 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -2,9 +2,7 @@ unit UMenuText; interface -{$IFDEF FPC} - {$MODE Delphi} -{$ENDIF} +{$I switches.inc} uses TextGL, UTexture, @@ -61,6 +59,39 @@ uses UGraphic, {$ENDIF} StrUtils; +{$IFDEF DARWIN} +function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer; +var + I,X: Integer; + Len, LenSubStr: Integer; +begin + if Offset = 1 then + Result := Pos(SubStr, S) + else + begin + I := Offset; + LenSubStr := Length(SubStr); + Len := Length(S) - LenSubStr + 1; + while I <= Len do + begin + if S[I] = SubStr[1] then + begin + X := 1; + while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do + Inc(X); + if (X = LenSubStr) then + begin + Result := I; + exit; + end; + end; + Inc(I); + end; + Result := 0; + end; +end; +{$ENDIF} + procedure TText.SetSelect(Value: Boolean); begin SelectBool := Value; -- cgit v1.2.3 From 99955c78f63d1cb0d8bec666bc33953590a74c8a Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 1 Nov 2007 23:22:01 +0000 Subject: fixed failed builds build:USDX-LAZLIN-75 build:USDX-LAZLIN-76 for some reason we can not use {$MODE Delphi} in an included file. ( Probably because of the way the compier scopes this switch to each pas file ) ive had to revert this part of eddies changes. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@548 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UDisplay.pas | 4 + Game/Code/Menu/UMenu.pas | 4 + Game/Code/Menu/UMenuSelectSlide.pas | 706 ++++++++++++++++++------------------ Game/Code/Menu/UMenuText.pas | 4 + 4 files changed, 367 insertions(+), 351 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UDisplay.pas b/Game/Code/Menu/UDisplay.pas index b3529d0a..c8a0aaf2 100644 --- a/Game/Code/Menu/UDisplay.pas +++ b/Game/Code/Menu/UDisplay.pas @@ -2,6 +2,10 @@ unit UDisplay; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + {$I switches.inc} uses {$IFDEF win32} diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 08ba1e4d..84cbe8a3 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -2,6 +2,10 @@ unit UMenu; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + {$I switches.inc} uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, diff --git a/Game/Code/Menu/UMenuSelectSlide.pas b/Game/Code/Menu/UMenuSelectSlide.pas index e4c5f959..d52474e6 100644 --- a/Game/Code/Menu/UMenuSelectSlide.pas +++ b/Game/Code/Menu/UMenuSelectSlide.pas @@ -1,351 +1,355 @@ -unit UMenuSelectSlide; - -interface - -{$I switches.inc} - -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; - - property SBGW: real read TextureSBG.w write TextureSBG.w; - - // 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; - - //Set Standard Width for Selections Background - SBGW := 450; - - 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 (integer(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(0{Text.Style}); - SetFontSize(Text.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; - - //Free old Space used by Texts - For I := low(TextOpt) to high(TextOpt) do - TextOpt[I].Free; - - setLength (TextOpt, Lines); - - for I := low(TextOpt) to high(TextOpt) do - begin - TextOpt[I] := TText.Create; - TextOpt[I].Size := Text.Size; - //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); - if (I <> High(TextOpt)) OR (High(TextOpt) = 0) OR (Length(TextOptT) = Lines) then - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I - else - TextOpt[I].X := TextureSBG.X + TextureSBG.W - maxlength; - - TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; - - //Better Look with 2 Options - if (Lines=2) AND (Length(TextOptT)= 2) then - TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I; - end; -end; - -end. +unit UMenuSelectSlide; + +interface + +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + +{$I switches.inc} + +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; + + property SBGW: real read TextureSBG.w write TextureSBG.w; + + // 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; + + //Set Standard Width for Selections Background + SBGW := 450; + + 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 (integer(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(0{Text.Style}); + SetFontSize(Text.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; + + //Free old Space used by Texts + For I := low(TextOpt) to high(TextOpt) do + TextOpt[I].Free; + + setLength (TextOpt, Lines); + + for I := low(TextOpt) to high(TextOpt) do + begin + TextOpt[I] := TText.Create; + TextOpt[I].Size := Text.Size; + //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); + if (I <> High(TextOpt)) OR (High(TextOpt) = 0) OR (Length(TextOptT) = Lines) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W / Lines) * I + else + TextOpt[I].X := TextureSBG.X + TextureSBG.W - maxlength; + + TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H / 2) - 1.5 * Text.Size{20}; + + //Better Look with 2 Options + if (Lines=2) AND (Length(TextOptT)= 2) then + TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(PChar(TextOptT[1]))) * I; + end; +end; + +end. diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas index 350c28de..f180a41b 100644 --- a/Game/Code/Menu/UMenuText.pas +++ b/Game/Code/Menu/UMenuText.pas @@ -2,6 +2,10 @@ unit UMenuText; interface +{$IFDEF FPC} + {$MODE Delphi} +{$ENDIF} + {$I switches.inc} uses TextGL, -- cgit v1.2.3 From ffd5802b61992b3b6a5f891036c1717fa4de7d6b Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 22 Nov 2007 23:46:45 +0000 Subject: Fixed texture drawing on Mac OS X (looks like BackImg.Z was not initialized). Now BackImg.Z is set to 0. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@629 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 1 + 1 file changed, 1 insertion(+) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 84cbe8a3..99f10c08 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -767,6 +767,7 @@ begin BackImg.Y:=BackW; } BackImg.X := 0; BackImg.Y := 0; + BackImg.Z := 0; // todo: eddie: to the opengl experts: please check this! On the mac z is not initialized??? BackImg.W := 800; BackImg.H := 600; DrawTexture(BackImg); -- cgit v1.2.3 From a00122fe60de966751b637477ac8e0a4fdcfbf4b Mon Sep 17 00:00:00 2001 From: jaybinks Date: Thu, 20 Dec 2007 23:59:59 +0000 Subject: removed a bunch of debugging from usdx startup. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@738 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index 99f10c08..e6bb6b45 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -277,10 +277,6 @@ begin //Button Collections are Created when the first ChildButton is Created PrepareButtonCollections(ThemeBasic.ButtonCollection); - {$ifdef fpc} - writeln(' TMenu.LoadFromThem : '+ThemeBasic.Background.Tex ); - {$endif} - //Add Background AddBackground(ThemeBasic.Background.Tex); @@ -298,24 +294,13 @@ var begin if Name <> '' then begin -// BackImg := Texture.LoadTexture(false, PChar(Skin.SkinPath + FileName), 'JPG', 'Plain', 0); // new theme system lFileName := Skin.GetTextureFileName(Name); lFileName := AdaptFilePaths( lFileName ); - {$ifdef fpc} - writeln(' TMenu.AddBackground : '+Name+ ' - '+ lFileName ); - {$endif} - -// if lFileName <> '' then if fileexists( lFileName ) then begin BackImg := Texture.GetTexture( lFileName , 'Plain'); - {$ifdef fpc} - writeln(' TMenu.AddBackground : '+ lFileName +' - LOADED'); - {$endif} - - BackImg.W := 800; BackImg.H := 600; BackW := 1; -- cgit v1.2.3 From 78c0c01f78b649bdc8e74c7c14d07590070a8765 Mon Sep 17 00:00:00 2001 From: jaybinks Date: Wed, 13 Feb 2008 12:04:57 +0000 Subject: small modification to the FadeTo function... it can now take a TAudioPlaybackStream as an optional 2nd paramater. so you can do a screen fade & play the swoosh sound, in 1 function call. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@848 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Menu/UMenu.pas | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Game/Code/Menu') diff --git a/Game/Code/Menu/UMenu.pas b/Game/Code/Menu/UMenu.pas index e6bb6b45..339402a2 100644 --- a/Game/Code/Menu/UMenu.pas +++ b/Game/Code/Menu/UMenu.pas @@ -9,7 +9,7 @@ interface {$I switches.inc} uses OpenGL12, SysUtils, UTexture, UMenuStatic, UMenuText, UMenuButton, UMenuSelect, UMenuSelectSlide, - UMenuInteract, UThemes, UMenuButtonCollection, Math; + UMenuInteract, UThemes, UMenuButtonCollection, Math, UMusic; type { Int16 = SmallInt;} @@ -112,7 +112,8 @@ type // function AddWidget(X, Y : UInt16; WidgetSrc : PSDL_Surface): Int16; // procedure ClearWidgets(MinNumber : Int16); - procedure FadeTo(Screen: PMenu); + procedure FadeTo(Screen: PMenu); overload; + procedure FadeTo(Screen: PMenu; aSound: TAudioPlaybackStream); overload; //popup hack procedure CheckFadeTo(Screen: PMenu; msg: String); @@ -967,6 +968,13 @@ begin Display.NextScreen := Screen; end; +procedure TMenu.FadeTo(Screen: PMenu; aSound: TAudioPlaybackStream); +begin + FadeTo( Screen ); + AudioPlayback.PlaySound( aSound ); +end; + + //popup hack procedure TMenu.CheckFadeTo(Screen: PMenu; msg: String); begin -- cgit v1.2.3