aboutsummaryrefslogtreecommitdiffstats
path: root/Game
diff options
context:
space:
mode:
authork-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-23 08:26:07 +0000
committerk-m_schindler <k-m_schindler@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-05-23 08:26:07 +0000
commit6bf9add301711bf6a5fdf5bf1fd5a20c6a722924 (patch)
treeae4cd272d14e1c0b11fc176dec85d071c4d9fbe7 /Game
parentf18a8e85ad8fe1727bfb9732b39428e83a599929 (diff)
downloadusdx-6bf9add301711bf6a5fdf5bf1fd5a20c6a722924.tar.gz
usdx-6bf9add301711bf6a5fdf5bf1fd5a20c6a722924.tar.xz
usdx-6bf9add301711bf6a5fdf5bf1fd5a20c6a722924.zip
eol-style unified and propset, indentation, PosEx for Darwin commented
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1128 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game')
-rw-r--r--Game/Code/Menu/UMenuText.pas98
1 files changed, 47 insertions, 51 deletions
diff --git a/Game/Code/Menu/UMenuText.pas b/Game/Code/Menu/UMenuText.pas
index 69acd4eb..2955263a 100644
--- a/Game/Code/Menu/UMenuText.pas
+++ b/Game/Code/Menu/UMenuText.pas
@@ -10,7 +10,8 @@ interface
uses TextGL,
UTexture,
- gl,
+ gl,
+ math,
SysUtils,
SDL;
@@ -18,17 +19,17 @@ type
TText = class
private
SelectBool: boolean;
- TextString: String;
- TextTiles: Array of String;
+ TextString: string;
+ TextTiles: array of string;
STicks: Cardinal;
- SelectBlink: Boolean;
+ 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
+ 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; //text wider than W is broken
// H: real;
Size: real;
ColR: real;
@@ -41,21 +42,21 @@ type
Align: integer; // 0 = left, 1 = center, 2 = right
//Reflection
- Reflection: boolean;
- ReflectionSpacing: Real;
+ Reflection: boolean;
+ ReflectionSpacing: real;
- procedure SetSelect(Value: Boolean);
- property Selected: Boolean read SelectBool write SetSelect;
+ procedure SetSelect(Value: boolean);
+ property Selected: boolean read SelectBool write SetSelect;
- procedure SetText(Value: String);
- property Text: String read TextString write SetText;
+ 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; ParReflection: Boolean; ParReflectionSpacing: Real); overload;
+ constructor Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string; ParReflection: boolean; ParReflectionSpacing: real); overload;
end;
implementation
@@ -64,10 +65,11 @@ uses UGraphic,
StrUtils;
{$IFDEF DARWIN}
-function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer;
+{ Why is this needed? Is PosEx from StrUtils different?
+function PosEx(const SubStr, S: string; Offset: Cardinal = 1): integer;
var
- I,X: Integer;
- Len, LenSubStr: Integer;
+ I, X: integer;
+ Len, LenSubStr: integer;
begin
if Offset = 1 then
Result := Pos(SubStr, S)
@@ -94,9 +96,10 @@ begin
Result := 0;
end;
end;
+}
{$ENDIF}
-procedure TText.SetSelect(Value: Boolean);
+procedure TText.SetSelect(Value: boolean);
begin
SelectBool := Value;
@@ -105,23 +108,16 @@ begin
STicks := SDL_GetTicks() div 550;
end;
-procedure TText.SetText(Value: String);
+procedure TText.SetText(Value: string);
var
- NextPos: Cardinal; //NextPos of a Space etc.
- LastPos: Cardinal; //LastPos "
+ 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
+ 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;
+ function GetNextPos: boolean;
var
T1, T2, T3: Cardinal;
begin
@@ -146,7 +142,7 @@ var
T3 := Length(Value);
//Get Nearest Pos
- NextPos := Smallest(T1, T3{Smallest(T2, T3)});
+ NextPos := min(T1, T3{min(T2, T3)});
if (LastPos = Length(Value)) then
NextPos := 0;
@@ -154,6 +150,7 @@ var
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
@@ -169,6 +166,7 @@ var
FirstWord := 0;
end;
end;
+
begin
//Set TExtstring
TextString := Value;
@@ -178,7 +176,7 @@ begin
STicks := SDL_GetTicks() div 550;
//Exit if there is no Need to Create Tiles
- If (W <= 0) and (Pos('\n', Value) = 0) then
+ if (W <= 0) and (Pos('\n', Value) = 0) then
begin
SetLength (TextTiles, 1);
TextTiles[0] := Value;
@@ -196,16 +194,15 @@ begin
LastBreak := 1;
FirstWord := 1;
-
if (W > 0) then
begin
- //Set Font Propertys
+ //Set Font Properties
SetFontStyle(Style);
SetFontSize(Size);
end;
//go Through Text
- While (GetNextPos) do
+ while (GetNextPos) do
begin
//Break in Text
if isBreak then
@@ -217,7 +214,7 @@ 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
+ //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
@@ -253,10 +250,10 @@ begin
AddBreak(LastBreak, Length(Value)+1);
end;
-Procedure TText.DeleteLastL;
+procedure TText.DeleteLastL;
var
- S: String;
- L: Integer;
+ S: string;
+ L: integer;
begin
S := TextString;
L := Length(S);
@@ -268,9 +265,9 @@ end;
procedure TText.Draw;
var
- X2, Y2: real;
+ X2, Y2: real;
Text2: string;
- I: Integer;
+ I: integer;
begin
if Visible then
begin
@@ -281,12 +278,12 @@ begin
glColor4f(ColR*Int, ColG*Int, ColB*Int, Alpha);
//Reflection
- if Reflection = true then
- SetFontReflection(true,ReflectionSpacing)
- else
+ if Reflection = true then
+ SetFontReflection(true, ReflectionSpacing)
+ else
SetFontReflection(false,0);
- //If Selected Set Blink...
+ //if selected set blink...
if SelectBool then
begin
I := SDL_GetTicks() div 550;
@@ -297,7 +294,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
@@ -316,12 +313,12 @@ begin
end
else
begin}
- //Now Use allways:
- //Draw Text as Many Strings
+ //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
+ if (not (SelectBool and SelectBlink)) or (I <> high(TextTiles)) then
Text2 := TextTiles[I]
else
Text2 := TextTiles[I] + '|';
@@ -359,7 +356,7 @@ begin
Create(X, Y, 0, 0, 10, 0, 0, 0, 0, Tekst, false, 0);
end;
-constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string; ParReflection: Boolean; ParReflectionSpacing: Real);
+constructor TText.Create(ParX, ParY, ParW: real; ParStyle: integer; ParSize, ParColR, ParColG, ParColB: real; ParAlign: integer; ParTekst: string; ParReflection: boolean; ParReflectionSpacing: real);
begin
inherited Create;
Alpha := 1;
@@ -380,5 +377,4 @@ begin
ReflectionSpacing:= ParReflectionSpacing;
end;
-
end.