aboutsummaryrefslogtreecommitdiffstats
path: root/Game/Code/Classes
diff options
context:
space:
mode:
Diffstat (limited to 'Game/Code/Classes')
-rw-r--r--Game/Code/Classes/TextGL.pas485
-rw-r--r--Game/Code/Classes/UDraw.pas100
-rw-r--r--Game/Code/Classes/UFiles.pas9
-rw-r--r--Game/Code/Classes/UGraphicClasses.pas27
-rw-r--r--Game/Code/Classes/UIni.pas2
-rw-r--r--Game/Code/Classes/UTexture.pas21
6 files changed, 438 insertions, 206 deletions
diff --git a/Game/Code/Classes/TextGL.pas b/Game/Code/Classes/TextGL.pas
index ee8187ad..7bb9699d 100644
--- a/Game/Code/Classes/TextGL.pas
+++ b/Game/Code/Classes/TextGL.pas
@@ -19,6 +19,18 @@ procedure SetFontItalic(Enable: boolean); // sets italic type letter (works for
procedure SetFontAspectW(Aspect: real);
type
+ TChar = record
+ id: integer;
+ x: integer;
+ y: integer;
+ width: integer;
+ height: integer;
+ xOffset: integer;
+ yOffset: integer;
+ xAdvance: integer;
+ page: integer;
+ end;
+
TTextGL = record
X: real;
Y: real;
@@ -30,15 +42,24 @@ type
end;
TFont = record
- Tex: TTexture;
- Width: array[0..255] of byte;
- AspectW: real;
- Centered: boolean;
+ Tex: array of TTexture;
+ Chars: array of TChar;
+ IDs: array of integer;
+ TexSize: integer;
+ Size: integer;
Done: real;
- Outline: real;
+ AspectW: real;
+ AspectH: real;
+ Bold: boolean;
Italic: boolean;
+ lineH: integer;
+ base: integer;
+ X, Y: real;
+ W, H: real;
end;
+const
+ SCALE = 28;
var
base: GLuint; // Base Display List For The Font Set
@@ -50,79 +71,240 @@ var
implementation
-uses UMain, Windows, SysUtils, UGraphic;
+uses UMain, Windows, SysUtils, UGraphic, UFiles;
procedure BuildFont; // Build Our Bitmap Font
var
- Rejestr: TResourceStream;
- Pet: integer;
-begin
- ActFont := 0;
-
- SetLength(Fonts, 5);
- Fonts[0].Tex := Texture.LoadTexture(true, 'Font', 'PNG', 'Font', 0);
- Fonts[0].Tex.H := 30;
- Fonts[0].AspectW := 0.9;
- Fonts[0].Done := -1;
- Fonts[0].Outline := 0;
-
- Fonts[1].Tex := Texture.LoadTexture(true, 'FontB', 'PNG', 'Font', 0);
- Fonts[1].Tex.H := 30;
- Fonts[1].AspectW := 1;
- Fonts[1].Done := -1;
- Fonts[1].Outline := 0;
-
- Fonts[2].Tex := Texture.LoadTexture(true, 'FontO', 'PNG', 'Font Outline', 0);
- Fonts[2].Tex.H := 30;
- Fonts[2].AspectW := 0.95;
- Fonts[2].Done := -1;
- Fonts[2].Outline := 5;
-
- Fonts[3].Tex := Texture.LoadTexture(true, 'FontO2', 'PNG', 'Font Outline 2', 0);
- Fonts[3].Tex.H := 30;
- Fonts[3].AspectW := 0.95;
- Fonts[3].Done := -1;
- Fonts[3].Outline := 4;
-
-{ Fonts[4].Tex := Texture.LoadTexture('FontO', 'BMP', 'Arrow', 0); // for score screen
- Fonts[4].Tex.H := 30;
- Fonts[4].AspectW := 0.95;
- Fonts[4].Done := -1;
- Fonts[4].Outline := 5;}
-
-
- Rejestr := TResourceStream.Create(HInstance, 'Font', 'FNT');
- Rejestr.Read(Fonts[0].Width, 256);
- Rejestr.Free;
-
- Rejestr := TResourceStream.Create(HInstance, 'FontB', 'FNT');
- Rejestr.Read(Fonts[1].Width, 256);
- Rejestr.Free;
-
- Rejestr := TResourceStream.Create(HInstance, 'FontO', 'FNT');
- Rejestr.Read(Fonts[2].Width, 256);
- Rejestr.Free;
-
- Rejestr := TResourceStream.Create(HInstance, 'FontO2', 'FNT');
- Rejestr.Read(Fonts[3].Width, 256);
- Rejestr.Free;
-
-{ Rejestr := TResourceStream.Create(HInstance, 'FontO', 'FNT');
- Rejestr.Read(Fonts[4].Width, 256);
- Rejestr.Free;}
-
- for Pet := 0 to 255 do
- Fonts[1].Width[Pet] := Fonts[1].Width[Pet] div 2;
+ I: integer;
+ FontFiles: array of string;
+
+ procedure ReadFontFile(num: integer);
+ var
+ Line: string;
+ Fractal: string;
+ FontFile: TextFile;
+ Position: word;
+ id: integer;
+ idstr: string;
+ len: integer;
+ I: integer;
+ Ident: string;
+ maxID: integer;
+
+ begin
+ maxID := 0;
+ AssignFile(FontFile, FontPath + FontFiles[num]);
+ Reset(FontFile);
+
+ ReadLn(FontFile, Line);
+ While (Length(Line) <> 0) do
+ begin
+ Position := Pos(' ', Line);
+ Ident := Trim(Copy(Line, 1, Position - 1));
+ Fractal := Trim(Copy(Line, Position + 1, Length(Line) - Position));
+
+ if (Ident='info') then
+ begin
+ //face
+
+ //size
+ Position := Pos('size=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 5, Length(Fractal) - Position - 4));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].size);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //bold
+
+ //italic
+
+ //charset
+
+ //unicode
+
+ //stretchH
+
+ //smooth
+
+ //aa
+
+ //padding
+
+ //spacing
+
+ //outline
+ end
+
+ else if (Ident='common') then
+ begin
+ //lineHeight
+ Position := Pos('lineHeight=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 11, Length(Fractal) - Position - 10));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].lineH);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //base
+ Position := Pos('base=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 5, Length(Fractal) - Position - 4));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].base);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //scaleW (TexSize)
+ Position := Pos('scaleW=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 7, Length(Fractal) - Position - 6));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].TexSize);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //scaleH
+ end
+
+ else if (Ident='page') then
+ begin
+ len := Length(Fonts[num].Tex);
+ SetLength(Fonts[num].Tex, len+1);
+
+ //id
+ Position := Pos('id=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 3, Length(Fractal) - Position - 2));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), id);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //file
+ Position := Pos('file="', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 6, Length(Fractal) - Position - 5));
+ Position := Pos('"', Fractal);
+ idstr := Trim(Copy(Fractal, 1, Position - 1));
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ if (num<2) then
+ Fonts[num].Tex[len] := Texture.LoadTexture(false, PChar(FontPath + idstr), 'PNG', 'Font', 0)
+ else
+ Fonts[num].Tex[len] := Texture.LoadTexture(false, PChar(FontPath + idstr), 'PNG', 'Font Outline', 0);
+ end
+
+ else if (Ident='chars') then
+ begin
+ end
+
+ else if (Ident='char') then
+ begin
+ len := Length(Fonts[num].Chars);
+ SetLength(Fonts[num].Chars, len+1);
+
+ //id
+ Position := Pos('id=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 3, Length(Fractal) - Position - 2));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].id);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ if (maxID < Fonts[num].Chars[len].id) then
+ maxID := Fonts[num].Chars[len].id;
+
+ //x
+ Position := Pos('x=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 2, Length(Fractal) - Position - 1));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].x);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //y
+ Position := Pos('y=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 2, Length(Fractal) - Position - 1));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].y);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //width
+ Position := Pos('width=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 6, Length(Fractal) - Position - 5));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].width);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //height
+ Position := Pos('height=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 7, Length(Fractal) - Position - 6));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].height);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //xoffset
+ Position := Pos('xoffset=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 8, Length(Fractal) - Position - 7));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].xOffset);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //yoffset
+ Position := Pos('yoffset=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 8, Length(Fractal) - Position - 7));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].yOffset);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //xadvance
+ Position := Pos('xadvance=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 9, Length(Fractal) - Position - 8));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].xAdvance);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //page
+ Position := Pos('page=', Fractal);
+ Fractal := Trim(Copy(Fractal, Position + 5, Length(Fractal) - Position - 4));
+ Position := Pos(' ', Fractal);
+ TryStrtoInt(Trim(Copy(Fractal, 1, Position - 1)), Fonts[num].Chars[len].page);
+ Fractal := Trim(Copy(Fractal, Position + 1, Length(Fractal) - Position));
+
+ //chnl
+ end
+
+ else if (Ident='kernings') then
+ begin
+ end
+
+ else if (Ident='kerning') then
+ begin
+ end;
+
+ if not EOf(FontFile) then
+ ReadLn (FontFile, Line)
+ else
+ break;
+ end;
- for Pet := 0 to 255 do
- Fonts[2].Width[Pet] := Fonts[2].Width[Pet] div 2 + 2;
+ CloseFile(FontFile);
- for Pet := 0 to 255 do
- Fonts[3].Width[Pet] := Fonts[3].Width[Pet] + 1;
+ SetLength(Fonts[num].IDs, maxID+1);
+ for I := 0 to Length(Fonts[num].Chars) - 1 do
+ begin
+ Fonts[num].IDs[Fonts[num].Chars[I].id] := I;
+ end;
+ end;
-{ for Pet := 0 to 255 do
- Fonts[4].Width[Pet] := Fonts[4].Width[Pet] div 2 + 2;}
+begin
+ ActFont := 0;
+ SetLength(FontFiles, 5);
+ FontFiles[0] := 'Normal.fnt';
+ FontFiles[1] := 'Bold.fnt';
+ FontFiles[2] := 'FontO.fnt';
+ FontFiles[3] := 'FontO2.fnt';
+ FontFiles[4] := 'HighResNumbersO.fnt';
+ SetLength(Fonts, 5);
+ for I := 0 to Length(FontFiles) - 1 do
+ begin
+ Fonts[I].Done := -1;
+ Fonts[I].AspectW := 1.0;
+ Fonts[I].AspectH := 1.0;
+ Fonts[I].H := 30;
+ ReadFontFile(I);
+ end;
end;
procedure KillFont; // Delete The Font
@@ -134,13 +316,14 @@ function glTextWidth(text: pchar): real;
var
Letter: char;
begin
-// Log.LogStatus(Text, 'glTextWidth');
Result := 0;
- while (length(text) > 0) do begin
+ while (length(text) > 0) do
+ begin
Letter := Text[0];
text := pchar(Copy(text, 2, Length(text)-1));
- Result := Result + Fonts[ActFont].Width[Ord(Letter)] * Fonts[ActFont].Tex.H / 30 * Fonts[ActFont].AspectW;
- end; // while
+ Result := Result + Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].xAdvance *
+ (Fonts[ActFont].H/30) * Fonts[ActFont].AspectW * SCALE/Fonts[ActFont].lineH;
+ end;
end;
procedure glPrintDone(text: pchar; Done: real; ColR, ColG, ColB, Alpha: real);
@@ -155,104 +338,107 @@ end;
procedure glPrintLetter(Letter: char);
var
- TexX, TexY: real;
- TexR, TexB: real;
- FWidth: real;
- PL, PT: real;
- PR, PB: real;
XItal: real; // X shift for italic type letter
+ gXO, gYO: real;
+ gX, gY: real;
+ gW, gH: real;
+ tW, tH: real;
+ fW, fH: real;
begin
- with Fonts[ActFont].Tex do begin
- FWidth := Fonts[ActFont].Width[Ord(Letter)];
-
- W := FWidth * (H/30) * Fonts[ActFont].AspectW;
-// H := 30;
-
- // set texture positions
- TexX := (ord(Letter) mod 16) * 1/16 + 1/32 - FWidth/1024 - Fonts[ActFont].Outline/1024;
- TexY := (ord(Letter) div 16) * 1/16 + 2/1024; // 2/1024
- TexR := (ord(Letter) mod 16) * 1/16 + 1/32 + FWidth/1024 + Fonts[ActFont].Outline/1024;
- TexB := (1 + ord(Letter) div 16) * 1/16 - 2/1024;
-
- // set vector positions
- PL := X - Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW /2;
- PT := Y;
- PR := PL + W + Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW;
- PB := PT + H;
+ fW := Fonts[ActFont].H/30 * Fonts[ActFont].AspectW * SCALE/Fonts[ActFont].lineH;
+ fH := Fonts[ActFont].H/30 * Fonts[ActFont].AspectH * SCALE/Fonts[ActFont].lineH;
+
+ tW := Fonts[ActFont].TexSize;
+ tH := Fonts[ActFont].TexSize;
+
+ gX := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].x;
+ gY := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].y;
+ gW := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].width;
+ gH := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].height;
+ gXO := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].xOffset * fW;
+ gYO := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].yOffset * fH +
+ Fonts[ActFont].H/30 * 2.5;
+
if Fonts[ActFont].Italic = false then
XItal := 0
else
- XItal := 12;
+ XItal := fH*gH*0.3;
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBindTexture(GL_TEXTURE_2D, TexNum);
+ glBindTexture(GL_TEXTURE_2D, Fonts[ActFont].Tex[Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].page].TexNum);
glBegin(GL_QUADS);
- glTexCoord2f(TexX, TexY); glVertex2f(PL+XItal, PT);
- glTexCoord2f(TexX, TexB); glVertex2f(PL, PB);
- glTexCoord2f(TexR, TexB); glVertex2f(PR, PB);
- glTexCoord2f(TexR, TexY); glVertex2f(PR+XItal, PT);
+ glTexCoord2f(gX/tW, gY/tH);
+ glVertex2f(Fonts[ActFont].X + gXO + XItal, Fonts[ActFont].Y + gYO);
+
+ glTexCoord2f((gX+gW)/tW, gY/tH);
+ glVertex2f(Fonts[ActFont].X + gW*fW + gXO + XItal, Fonts[ActFont].Y + gYO);
+
+ glTexCoord2f((gX+gW)/tW, (gY+gH)/tH);
+ glVertex2f(Fonts[ActFont].X + gW*fW + gXO, Fonts[ActFont].Y + gH*fH + gYO);
+
+ glTexCoord2f(gX/tW, (gY+gH)/tH);
+ glVertex2f(Fonts[ActFont].X + gXO, Fonts[ActFont].Y + gH*fH + gYO);
glEnd;
- X := X + W;
+ Fonts[ActFont].X := Fonts[ActFont].X + Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].xAdvance * fW;
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
- end; // with
end;
procedure glPrintLetterCut(letter: char; Start, Finish: real);
var
- TexX, TexY: real;
- TexR, TexB: real;
- TexTemp: real;
- FWidth: real;
- PL, PT: real;
- PR, PB: real;
- OutTemp: real;
+ gXO, gYO: real;
+ gX, gY: real;
+ gW, gH: real;
+ tW, tH: real;
+ fW, fH: real;
+ TexR: real;
XItal: real;
+
begin
- with Fonts[ActFont].Tex do begin
- FWidth := Fonts[ActFont].Width[Ord(Letter)];
-
- W := FWidth * (H/30) * Fonts[ActFont].AspectW;
-// H := 30;
- OutTemp := Fonts[ActFont].Outline * (H/30) * Fonts[ActFont].AspectW;
-
- // set texture positions
- TexX := (ord(Letter) mod 16) * 1/16 + 1/32 - FWidth/1024 - Fonts[ActFont].Outline/1024;
- TexY := (ord(Letter) div 16) * 1/16 + 2/1024; // 2/1024
- TexR := (ord(Letter) mod 16) * 1/16 + 1/32 + FWidth/1024 + Fonts[ActFont].Outline/1024;
- TexB := (1 + ord(Letter) div 16) * 1/16 - 2/1024;
-
- TexTemp := TexX + Start * (TexR - TexX);
- TexR := TexX + Finish * (TexR - TexX);
- TexX := TexTemp;
-
- // set vector positions
- PL := X - OutTemp / 2 + OutTemp * Start;
- PT := Y;
- PR := PL + (W + OutTemp) * (Finish - Start);
- PB := PT + H;
+ fW := Fonts[ActFont].H/30 * Fonts[ActFont].AspectW * SCALE/Fonts[ActFont].lineH;
+ fH := Fonts[ActFont].H/30 * Fonts[ActFont].AspectH * SCALE/Fonts[ActFont].lineH;
+
+ tW := Fonts[ActFont].TexSize;
+ tH := Fonts[ActFont].TexSize;
+
+ gX := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].x;
+ gY := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].y;
+ gW := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].width;
+ gH := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].height;
+ gXO := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].xOffset * fW;
+ gYO := Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].yOffset * fH +
+ Fonts[ActFont].H/30 * 2.5;
+
+ TexR := gX + Finish * gW;
+ gX := gX + Start * gW;
+
if Fonts[ActFont].Italic = false then
XItal := 0
else
- XItal := 12;
+ XItal := fH*gH*0.3;
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glBindTexture(GL_TEXTURE_2D, TexNum);
+ glBindTexture(GL_TEXTURE_2D, Fonts[ActFont].Tex[Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].page].TexNum);
glBegin(GL_QUADS);
- glTexCoord2f(TexX, TexY); glVertex2f(PL+XItal, PT);
- glTexCoord2f(TexX, TexB); glVertex2f(PL, PB);
- glTexCoord2f(TexR, TexB); glVertex2f(PR, PB);
- glTexCoord2f(TexR, TexY); glVertex2f(PR+XItal, PT); // not tested with XItal
+ glTexCoord2f(gX/tW, gY/tH);
+ glVertex2f(Fonts[ActFont].X + gXO + XItal, Fonts[ActFont].Y + gYO);
+
+ glTexCoord2f(TexR/tW, gY/tH);
+ glVertex2f(Fonts[ActFont].X + gXO + gW*fW*(Finish-Start) + XItal, Fonts[ActFont].Y + gYO);
+
+ glTexCoord2f(TexR/tW, (gY+gH)/tH);
+ glVertex2f(Fonts[ActFont].X + gXO + gW*fW*(Finish-Start), Fonts[ActFont].Y + gH*fH + gYO);
+
+ glTexCoord2f(gX/tW, (gY+gH)/tH);
+ glVertex2f(Fonts[ActFont].X + gXO, Fonts[ActFont].Y + gH*fH + gYO);
glEnd;
- X := X + W * (Finish - Start);
+ Fonts[ActFont].X := Fonts[ActFont].X + gW*fW*(Finish-Start);
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
- end; // with
-
end;
procedure glPrint(text: pchar); // Custom GL "Print" Routine
@@ -279,6 +465,7 @@ var
PTotWidth: real;
PDoingNow: real;
S: string;
+ lastX: real;
begin
if (Text = '') then // If There's No Text
Exit; // Do Nothing
@@ -299,10 +486,14 @@ begin
if (PToDo > 0) and (PDoingNow <= PToDo) then
glPrintLetter(Letter);
- if (PToDo > 0) and (PDoingNow > PToDo) then begin
+ if (PToDo > 0) and (PDoingNow > PToDo) then
+ begin
+ lastX := Fonts[ActFont].X;
glPrintLetterCut(Letter, 0, PToDo / PDoingNow);
glColor4f(PColR, PColG, PColB, Alpha);
glPrintLetterCut(Letter, PToDo / PDoingNow, 1);
+ Fonts[ActFont].X := lastX + Fonts[ActFont].Chars[Fonts[ActFont].IDs[Ord(Letter)]].xAdvance *
+ (Fonts[ActFont].H/30) * Fonts[ActFont].AspectW * SCALE/Fonts[ActFont].lineH;
end;
if (PToDo <= 0) then
@@ -316,13 +507,13 @@ end;
procedure SetFontPos(X, Y: real);
begin
- Fonts[ActFont].Tex.X := X;
- Fonts[ActFont].Tex.Y := Y;
+ Fonts[ActFont].X := X;
+ Fonts[ActFont].Y := Y;
end;
procedure SetFontSize(Size: real);
begin
- Fonts[ActFont].Tex.H := 30 * (Size/10);
+ Fonts[ActFont].H := 30 * (Size/10);
end;
procedure SetFontStyle(Style: integer);
diff --git a/Game/Code/Classes/UDraw.pas b/Game/Code/Classes/UDraw.pas
index 162164d6..9fa0a4f7 100644
--- a/Game/Code/Classes/UDraw.pas
+++ b/Game/Code/Classes/UDraw.pas
@@ -100,7 +100,7 @@ var
begin
if ScreenSing.Tex_Background.TexNum >= 1 then
begin
-
+ exit;
glClearColor (1, 1, 1, 1);
glColor4f (1, 1, 1, 1);
@@ -261,6 +261,7 @@ var
CP: integer;
end_: integer;
st: integer;
+ nW: real;
begin
CP := NrCzesci;
if (Length(Czesci[CP].Czesc[Czesci[CP].Akt].Nuta)=0) then
@@ -277,12 +278,17 @@ begin
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
TempR := (Right-Left) / (end_ - st);
+
with Czesci[NrCzesci].Czesc[Czesci[NrCzesci].Akt] do
begin
for Pet := 0 to HighNut do
begin
with Nuta[Pet] do
begin
+ nW := NotesW;
+ if ( 1 + 2*NotesW >Dlugosc * TempR ) then
+ nW := TempR/2;
+
if not FreeStyle then
begin
if Ini.EffectSing = 0 then
@@ -297,8 +303,8 @@ begin
glColor4f(1, 1, 1, 0.85*Alpha);
// lewa czesc - left part
- Rec.Left := (Start-st) * TempR + Left + 0.5 + 10*ScreenX;
- Rec.Right := Rec.Left + NotesW;
+ Rec.Left := (Start-st) * TempR + Left + 0.5 {+ 10*ScreenX};
+ Rec.Right := Rec.Left + nW;
Rec.Top := Top - (Ton-BaseNote)*Space/2 - NotesH;
Rec.Bottom := Rec.Top + 2 * NotesH;
glBindTexture(GL_TEXTURE_2D, Tex_Left[Color].TexNum);
@@ -315,19 +321,22 @@ begin
// srodkowa czesc - middle part
Rec.Left := Rec.Right;
- Rec.Right := (Start+Dlugosc-st) * TempR + Left - NotesW - 0.5 + 10*ScreenX;
-
- glBindTexture(GL_TEXTURE_2D, Tex_Mid[Color].TexNum);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
- glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
- glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
- glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
- glEnd;
+ Rec.Right := (Start+Dlugosc-st) * TempR + Left - nW - 0.5 {+ 10*ScreenX};
+ if (nW=NotesW) then
+ begin
+ glBindTexture(GL_TEXTURE_2D, Tex_Mid[Color].TexNum);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
+ glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
+ glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
+ glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
+ glEnd;
+ end;
+
// prawa czesc - right part
Rec.Left := Rec.Right;
- Rec.Right := Rec.Right + NotesW;
+ Rec.Right := Rec.Right + nW;
glBindTexture(GL_TEXTURE_2D, Tex_Right[Color].TexNum);
glBegin(GL_QUADS);
@@ -362,6 +371,7 @@ var
NotesH2: real;
end_: integer;
st: integer;
+ nW: real;
begin
if (Length(Czesci[CP].Czesc[Czesci[CP].Akt].Nuta)=0) then
Exit
@@ -381,9 +391,13 @@ begin
begin
with Player[NrGracza].Nuta[N] do
begin
+ nW := NotesW;
+ if ( 1 + 2*NotesW >Dlugosc * TempR ) then
+ nW := TempR/2;
+
// lewa czesc
- Rec.Left := X + (Start-st) * TempR + 0.5 + 10*ScreenX;
- Rec.Right := Rec.Left + NotesW;
+ Rec.Left := X + (Start-st) * TempR + 0.5 {+ 10*ScreenX};
+ Rec.Right := Rec.Left + nW;
// Half size Notes Patch
if Hit then
@@ -408,24 +422,27 @@ begin
// srodkowa czesc
Rec.Left := Rec.Right;
- Rec.Right := X + (Start+Dlugosc-st) * TempR - NotesW - 0.5 + 10*ScreenX;
+ Rec.Right := X + (Start+Dlugosc-st) * TempR - nW - 0.5 { + 10*ScreenX};
// (nowe)
if (Start+Dlugosc-1 = Czas.AktBeatD) then
Rec.Right := Rec.Right - (1-Frac(Czas.MidBeatD)) * TempR;
if Rec.Right <= Rec.Left then Rec.Right := Rec.Left;
- glBindTexture(GL_TEXTURE_2D, Tex_Mid[NrGracza+1].TexNum);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
- glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
- glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
- glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
- glEnd;
+ if (nW=NotesW) then
+ begin
+ glBindTexture(GL_TEXTURE_2D, Tex_Mid[NrGracza+1].TexNum);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
+ glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
+ glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
+ glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
+ glEnd;
+ end;
// prawa czesc
Rec.Left := Rec.Right;
- Rec.Right := Rec.Right + NotesW;
+ Rec.Right := Rec.Right + nW;
glBindTexture(GL_TEXTURE_2D, Tex_Right[NrGracza+1].TexNum);
glBegin(GL_QUADS);
@@ -463,6 +480,7 @@ var
CP: integer;
end_: integer;
st: integer;
+ nW: real;
begin
if (Player[NrGracza].ScoreTotalI >= 0) then
begin
@@ -499,17 +517,21 @@ begin
begin
if not FreeStyle then
begin
+ nW := NotesW;
+ if ( 1 + 2*NotesW >Dlugosc * TempR ) then
+ nW := TempR/2;
+
// begin: 14, 20
// easy: 6, 11
- W := NotesW * 2 + 2;
+ W := nW * 2 + 2;
H := NotesH * 1.5 + 3.5;
-
- X2 := (Start-st) * TempR + Left + 0.5 + 10*ScreenX + 4; // wciecie
+
+ X2 := (Start-st) * TempR + Left + 0.5 {+ 10*ScreenX} + 4; // wciecie
X1 := X2-W;
- X3 := (Start+Dlugosc-st) * TempR + Left - 0.5 + 10*ScreenX - 4; // wciecie
+ X3 := (Start+Dlugosc-st) * TempR + Left - 0.5 {+ 10*ScreenX} - 4; // wciecie
X4 := X3+W;
-
+
// left
Rec.Left := X1;
Rec.Right := X2;
@@ -528,15 +550,17 @@ begin
// srodkowa czesc
Rec.Left := X2;
Rec.Right := X3;
-
- glBindTexture(GL_TEXTURE_2D, Tex_BG_Mid[NrGracza+1].TexNum);
- glBegin(GL_QUADS);
- glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
- glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
- glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
- glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
- glEnd;
-
+ if (nW=NotesW) then
+ begin
+ glBindTexture(GL_TEXTURE_2D, Tex_BG_Mid[NrGracza+1].TexNum);
+ glBegin(GL_QUADS);
+ glTexCoord2f(0, 0); glVertex2f(Rec.Left, Rec.Top);
+ glTexCoord2f(0, 1); glVertex2f(Rec.Left, Rec.Bottom);
+ glTexCoord2f(1, 1); glVertex2f(Rec.Right, Rec.Bottom);
+ glTexCoord2f(1, 0); glVertex2f(Rec.Right, Rec.Top);
+ glEnd;
+ end;
+
// prawa czesc
Rec.Left := X3;
Rec.Right := X4;
diff --git a/Game/Code/Classes/UFiles.pas b/Game/Code/Classes/UFiles.pas
index ebeb1314..93e745e5 100644
--- a/Game/Code/Classes/UFiles.pas
+++ b/Game/Code/Classes/UFiles.pas
@@ -55,6 +55,7 @@ var
PlayListPath: string;
RecordingsPath: string;
SessionLogPath: string;
+ FontPath: string;
SongFile: TextFile; // all procedures in this unit operates on this file
FileLineNo: integer; //Line which is readed at Last, for error reporting
@@ -91,6 +92,7 @@ begin
PlaylistPath := GamePath + 'Playlists\';
RecordingsPath := GamePath + 'Recordings\';
SessionLogPath := GamePath + 'SessionLog\';
+ FontPath := GamePath + 'Fonts\';
Writeable := true;
@@ -125,6 +127,9 @@ begin
If Writeable And (not DirectoryExists(SessionLogPath)) then
Writeable := ForceDirectories(SessionLogPath);
+ If Writeable And (not DirectoryExists(FontPath)) then
+ Writeable := ForceDirectories(FontPath);
+
if not Writeable then
Log.LogError('Error: Dir is Readonly');
@@ -1334,7 +1339,7 @@ begin
begin
for J := I+1 to num_lines - 1 do
begin
- if sentences[I]=sentences[J] then
+ if (sentences[I]<>'') and (sentences[I]=sentences[J]) then
begin
temp_series.start := I;
temp_series.end_ := I;
@@ -1346,7 +1351,7 @@ begin
for K := 1 to max do
begin
- if sentences[I+K]=sentences[J+K] then
+ if (sentences[I+K]<>'') and (sentences[I+K]=sentences[J+K]) then
temp_series.end_ := I+K
else
break;
diff --git a/Game/Code/Classes/UGraphicClasses.pas b/Game/Code/Classes/UGraphicClasses.pas
index d9aeb227..6f192af6 100644
--- a/Game/Code/Classes/UGraphicClasses.pas
+++ b/Game/Code/Classes/UGraphicClasses.pas
@@ -305,27 +305,32 @@ end;
procedure TParticle.Draw(Alph: TAlpha);
var L: Cardinal;
begin
- if ScreenAct = Screen then
+ if (ScreenAct = Screen) then
+ begin
// this draws (multiple) texture(s) of our particle
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, Tex);
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+
for L:=0 to High(Col) do
begin
glColor4f(Col[L].r, Col[L].g, Col[L].b, Alpha*Alph[CP]);
- glBindTexture(GL_TEXTURE_2D, Tex);
- glEnable(GL_TEXTURE_2D);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glEnable(GL_BLEND);
-
- begin
- glBegin(GL_QUADS);
+ glBegin(GL_QUADS);
glTexCoord2f((1/16) * Frame, 0); glVertex2f(X-W*Scale[L]*SizeMod, Y-H*Scale[L]*SizeMod);
glTexCoord2f((1/16) * Frame + (1/16), 0); glVertex2f(X-W*Scale[L]*SizeMod, Y+H*Scale[L]*SizeMod);
glTexCoord2f((1/16) * Frame + (1/16), 1); glVertex2f(X+W*Scale[L]*SizeMod, Y+H*Scale[L]*SizeMod);
glTexCoord2f((1/16) * Frame, 1); glVertex2f(X+W*Scale[L]*SizeMod, Y-H*Scale[L]*SizeMod);
- glEnd;
- end;
+ glEnd;
end;
- glcolor4f(1,1,1,1);
+
+ glDisable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glcolor4f(1,1,1,1);
+ end;
end;
// end of TParticle
diff --git a/Game/Code/Classes/UIni.pas b/Game/Code/Classes/UIni.pas
index 66bfba26..46137de8 100644
--- a/Game/Code/Classes/UIni.pas
+++ b/Game/Code/Classes/UIni.pas
@@ -294,7 +294,7 @@ begin
if Tekst = INewPartyPoints[Pet] then Ini.NewPartyPoints := Pet;
// ShowCredits
- Tekst := IniFile.ReadString('Game', 'ShowCredits', IShowCredits[1]);
+ Tekst := IniFile.ReadString('Game', 'ShowCredits', IShowCredits[0]);
for Pet := 0 to High(IShowCredits) do
if Tekst = IShowCredits[Pet] then Ini.ShowCredits := Pet;
diff --git a/Game/Code/Classes/UTexture.pas b/Game/Code/Classes/UTexture.pas
index d7d3e690..cd39dd2f 100644
--- a/Game/Code/Classes/UTexture.pas
+++ b/Game/Code/Classes/UTexture.pas
@@ -73,6 +73,9 @@ type
procedure UnloadTexture(Name: string; FromCache: boolean);
end;
+const
+ max = 2048;
+
var
Texture: TTextureUnit;
TextureDatabase: TTextureDatabase;
@@ -99,11 +102,11 @@ var
TexFitW: integer;
TexFitH: integer; // new for limit
- TextureD8: array[1..1024*1024] of byte; // 1MB
- TextureD16: array[1..1024*1024, 1..2] of byte; // luminance/alpha tex (2MB)
- TextureD24: array[1..1024*1024, 1..3] of byte; // normal 24-bit tex (3MB)
+ TextureD8: array[1..max*max] of byte; // 1MB
+ TextureD16: array[1..max*max, 1..2] of byte; // luminance/alpha tex (2MB)
+ TextureD24: array[1..max*max, 1..3] of byte; // normal 24-bit tex (3MB)
TextureD242: array[1..512*512, 1..3] of byte; // normal 24-bit tex (0,75MB)
- TextureD32: array[1..1024*1024, 1..4] of byte; // transparent 32-bit tex (4MB)
+ TextureD32: array[1..max*max, 1..4] of byte; // transparent 32-bit tex (4MB)
// total 40MB at 2048*2048
// total 10MB at 1024*1024
@@ -245,7 +248,8 @@ begin
TextureJ.Free;
end
- else if Format = 'PNG' then begin
+ else if Format = 'PNG' then
+ begin
TexturePNG := TPNGObject.Create;
if FromRegistry then TexturePNG.LoadFromStream(Res)
else begin
@@ -281,7 +285,7 @@ begin
if FromRegistry then Res.Free;
- if (TextureB.Width > 1024) or (TextureB.Height > 1024) then begin // will be fixed in 0.5.1 and dynamically extended to 8192x8192 depending on the driver
+ if (TextureB.Width > max) or (TextureB.Height > max) then begin // will be fixed in 0.5.1 and dynamically extended to 8192x8192 depending on the driver
Log.LogError('Image ' + Nazwa + ' is too big (' + IntToStr(TextureB.Width) + 'x' + IntToStr(TextureB.Height) + ')');
Result.TexNum := -1;
end else begin
@@ -452,7 +456,8 @@ begin
end;}
end;
- if Typ = 'Font' then begin
+ if Typ = 'Font' then
+ begin
// a patch from Linnex, that solves the font problem in wine which causes chrashes
//TextureB.PixelFormat := pf24bit;
@@ -469,6 +474,8 @@ begin
PPix := TextureB.ScanLine[Pet];
for Pet2 := 0 to TextureB.Width-1 do begin
Pix := PPix[Pet2 * 3];
+ if Pix>0 then
+ Pix := Pix * 1;
TextureD16[Pet*TextureB.Width + Pet2 + 1, 1] := 255;
TextureD16[Pet*TextureB.Width + Pet2 + 1, 2] := Pix;
end;