diff options
author | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-03-29 16:54:52 +0000 |
---|---|---|
committer | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2007-03-29 16:54:52 +0000 |
commit | e0e16a3b1d28cf51fecf669d42465cf2a65728f3 (patch) | |
tree | ad80058b83e11b1bf42210d8e49922b44745ca98 /Game/Code/Menu | |
parent | 8d591b8344e0cb87e1a987961b3790fa26d323a6 (diff) | |
download | usdx-e0e16a3b1d28cf51fecf669d42465cf2a65728f3.tar.gz usdx-e0e16a3b1d28cf51fecf669d42465cf2a65728f3.tar.xz usdx-e0e16a3b1d28cf51fecf669d42465cf2a65728f3.zip |
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
Diffstat (limited to 'Game/Code/Menu')
-rw-r--r-- | Game/Code/Menu/UMenu.pas | 20 | ||||
-rw-r--r-- | Game/Code/Menu/UMenuSelectSlide.pas | 7 | ||||
-rw-r--r-- | Game/Code/Menu/UMenuText.pas | 141 |
3 files changed, 140 insertions, 28 deletions
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;
|