diff options
author | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-04-13 14:11:07 +0000 |
---|---|---|
committer | whiteshark0 <whiteshark0@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2010-04-13 14:11:07 +0000 |
commit | d119e6f390a66f5ec10fa55b2ab01a005d526715 (patch) | |
tree | e98d3f0b86a1d61b727a7a7a13e987c4dfe6e1e5 | |
parent | f2d449a58392a6d65dfb981054014353b84ca2f6 (diff) | |
download | usdx-d119e6f390a66f5ec10fa55b2ab01a005d526715.tar.gz usdx-d119e6f390a66f5ec10fa55b2ab01a005d526715.tar.xz usdx-d119e6f390a66f5ec10fa55b2ab01a005d526715.zip |
some code cleanup
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@2232 b956fd51-792f-4845-bead-9b4dfca2ff2c
-rw-r--r-- | src/menu/UMenuSelectSlide.pas | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/menu/UMenuSelectSlide.pas b/src/menu/UMenuSelectSlide.pas index 86458005..7fa9aca7 100644 --- a/src/menu/UMenuSelectSlide.pas +++ b/src/menu/UMenuSelectSlide.pas @@ -405,6 +405,9 @@ procedure TSelectSlide.GenLines; var maxlength: real; I: integer; +const + MinItemSpacing = 5; + MinSideSpacing = 24; begin SetFontStyle(0{Text.Style}); SetFontSize(Text.Size); @@ -420,7 +423,7 @@ begin if (oneItemOnly = false) then begin //show all items - Lines := floor((TextureSBG.W-40) / (maxlength+7)); + Lines := floor((TextureSBG.W - MinSideSpacing * 2) / (maxlength + MinItemSpacing)); if (Lines > Length(TextOptT)) then Lines := Length(TextOptT); @@ -437,14 +440,12 @@ begin for I := Low(TextOpt) to High(TextOpt) do TextOpt[I].Free; - setLength (TextOpt, Lines); + 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; @@ -452,23 +453,24 @@ begin 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; - + // generate positions TextOpt[I].Y := TextureSBG.Y + (TextureSBG.H - Text.Size) / 2; - //Better Look with 2 Options - if (Lines = 2) and (Length(TextOptT) = 2) then + // better look with 2 options and a single option + if (Lines = 2) then + begin TextOpt[I].X := TextureSBG.X + 20 + (TextureSBG.W -40 - glTextWidth(TextOptT[1])) * I; - - if (Lines = 1) then + TextOpt[I].Align := 0; + end + else if (Lines = 1) then begin - TextOpt[I].Align := 1; //center text TextOpt[I].X := TextureSBG.X + (TextureSBG.W / 2); + TextOpt[I].Align := 1; //center text + end + else + begin + TextOpt[I].X := TextureSBG.X + TextureSBG.W / 2 + (TextureSBG.W - MinSideSpacing*2) * (I / Lines - 0.5); + TextOpt[I].Align := 0; end; end; end; |