aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu
diff options
context:
space:
mode:
authormogguh <mogguh@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-05-26 23:01:19 +0000
committermogguh <mogguh@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-05-26 23:01:19 +0000
commit69d651dd5933520713ac0ecb4875f0e6702ba002 (patch)
tree5c0dc67caa574ea27d482aba5ed1de22495d35e4 /src/menu
parent0067683559bcdbc1f1937ad445cd297d23bac69b (diff)
downloadusdx-69d651dd5933520713ac0ecb4875f0e6702ba002.tar.gz
usdx-69d651dd5933520713ac0ecb4875f0e6702ba002.tar.xz
usdx-69d651dd5933520713ac0ecb4875f0e6702ba002.zip
Statics defined in theme don't necessarily need a width or height set, if omitted the the values from the texture itself will be used
SelectSlides may now have arrows and only one item set, default is off - view UScreenOptionsGame.pas as example on how to set this git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1783 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'src/menu')
-rw-r--r--src/menu/UMenu.pas32
-rw-r--r--src/menu/UMenuSelectSlide.pas50
2 files changed, 71 insertions, 11 deletions
diff --git a/src/menu/UMenu.pas b/src/menu/UMenu.pas
index f86746ed..ceb4ac77 100644
--- a/src/menu/UMenu.pas
+++ b/src/menu/UMenu.pas
@@ -652,12 +652,22 @@ begin
begin
Static[StatNum] := TStatic.Create(Texture.GetTexture(Name, Typ, Color)); // new skin
end;
-
+
// configures static
Static[StatNum].Texture.X := X;
Static[StatNum].Texture.Y := Y;
- Static[StatNum].Texture.W := W;
- Static[StatNum].Texture.H := H;
+
+ //Set height and width via sprite size if omitted
+ if(H = 0) then
+ Static[StatNum].Texture.H := Static[StatNum].Texture.H
+ else
+ Static[StatNum].Texture.H := H;
+
+ if(W = 0) then
+ Static[StatNum].Texture.W := Static[StatNum].Texture.W
+ else
+ Static[StatNum].Texture.W := W;
+
Static[StatNum].Texture.Z := Z;
if (Typ <> TEXTURE_TYPE_COLORIZED) then
begin
@@ -1212,6 +1222,9 @@ begin
SelectsS[High(SelectsS)].Texture.Z := ThemeSelectS.Z;
SelectsS[High(SelectsS)].TextureSBG.Z := ThemeSelectS.Z;
+ SelectsS[High(SelectsS)].showArrows := ThemeSelectS.showArrows;
+ SelectsS[High(SelectsS)].oneItemOnly := ThemeSelectS.oneItemOnly;
+
//Generate Lines
SelectsS[High(SelectsS)].GenLines;
@@ -1255,9 +1268,20 @@ begin
else
SelectsS[S].TextureSBG := Texture.GetTexture(SBGName, SBGTyp);
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowL := Tex_SelectS_ArrowL;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.X := X + W + SkipX;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.Y := Y;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.W := Tex_SelectS_ArrowL.W;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowL.H := Tex_SelectS_ArrowL.H;
+
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowR := Tex_SelectS_ArrowR;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.X := X + W + SkipX + SBGW - Tex_SelectS_ArrowR.W;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.Y := Y;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.W := Tex_SelectS_ArrowR.W;
+ SelectsS[High(SelectsS)].Tex_SelectS_ArrowR.H := Tex_SelectS_ArrowR.H;
+
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;
diff --git a/src/menu/UMenuSelectSlide.pas b/src/menu/UMenuSelectSlide.pas
index a7133492..81870ab8 100644
--- a/src/menu/UMenuSelectSlide.pas
+++ b/src/menu/UMenuSelectSlide.pas
@@ -54,8 +54,8 @@ type
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)
+ Tex_SelectS_ArrowL: TTexture; // Texture for left arrow
+ Tex_SelectS_ArrowR: TTexture; // Texture for right arrow
SelectOptInt: integer;
PData: ^integer;
@@ -63,6 +63,12 @@ type
//For automatically Setting LineCount
Lines: byte;
+ //Arrows on/off
+ showArrows: Boolean; //default is false
+
+ //whether to show one item or all that fit into the select
+ oneItemOnly:Boolean; //default is false
+
//Visibility
Visible: boolean;
@@ -147,7 +153,7 @@ begin
TextOpt[0] := TText.Create;
//Set Standard Width for Selections Background
- SBGW := 450;
+// SBGW := 400;
Visible := true;
{SetLength(TextOpt, 3);
@@ -250,6 +256,8 @@ begin
begin //First Option Selected
Value := 0;
+ Tex_SelectS_ArrowL.alpha := 0;
+
for SO := low (TextOpt) to high(TextOpt) do
begin
TextOpt[SO].Text := TextOptT[SO];
@@ -261,6 +269,8 @@ begin
begin //Last Option Selected
Value := high(TextOptT);
+ Tex_SelectS_ArrowR.alpha := 0;
+
for SO := high(TextOpt) downto low (TextOpt) do
begin
TextOpt[SO].Text := TextOptT[high(TextOptT)-(Lines-SO-1)];
@@ -269,6 +279,9 @@ begin
end
else
begin
+ Tex_SelectS_ArrowL.alpha := 1;
+ Tex_SelectS_ArrowR.alpha := 1;
+
HalfL := Ceil((Lines-1)/2);
HalfR := Lines-1-HalfL;
@@ -322,6 +335,11 @@ begin
DrawTexture(Texture);
DrawTexture(TextureSBG);
+ if(showArrows) then begin
+ DrawTexture(Tex_SelectS_ArrowL);
+ DrawTexture(Tex_SelectS_ArrowR);
+ end;
+
Text.Draw;
for SO := low(TextOpt) to high(TextOpt) do
@@ -329,6 +347,8 @@ begin
end;
end;
+
+
procedure TSelectSlide.GenLines;
var
maxlength: real;
@@ -344,12 +364,22 @@ begin
maxlength := glTextWidth(TextOptT[I]);
end;
- Lines := floor((TextureSBG.W-40) / (maxlength+7));
- if (Lines > Length(TextOptT)) then
- Lines := Length(TextOptT);
- if (Lines <= 0) then
+ if(oneItemOnly = false) then
+ begin
+ //show all items
+ Lines := floor((TextureSBG.W-40) / (maxlength+7));
+ if (Lines > Length(TextOptT)) then
+ Lines := Length(TextOptT);
+
+ if (Lines <= 0) then
+ Lines := 1;
+ end
+ else
+ begin
+ //show one item only
Lines := 1;
+ end;
//Free old Space used by Texts
for I := low(TextOpt) to high(TextOpt) do
@@ -382,6 +412,12 @@ begin
//Better Look with 2 Options
if (Lines=2) AND (Length(TextOptT)= 2) then
TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(TextOptT[1])) * I;
+
+ if (Lines=1) then
+ begin
+ TextOpt[I].Align := 1; //center text
+ TextOpt[I].X := TextureSBG.X + (TextureSBG.W / 2);
+ end;
end;
end;