aboutsummaryrefslogtreecommitdiffstats
path: root/unicode/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--unicode/src/base/TextGL.pas9
-rw-r--r--unicode/src/base/UCovers.pas6
-rw-r--r--unicode/src/base/UFiles.pas1
-rw-r--r--unicode/src/base/UFont.pas32
-rw-r--r--unicode/src/base/ULanguage.pas176
-rw-r--r--unicode/src/base/UParty.pas2
-rw-r--r--unicode/src/base/UPlaylist.pas18
7 files changed, 136 insertions, 108 deletions
diff --git a/unicode/src/base/TextGL.pas b/unicode/src/base/TextGL.pas
index 2bc68637..28c3c6b6 100644
--- a/unicode/src/base/TextGL.pas
+++ b/unicode/src/base/TextGL.pas
@@ -55,8 +55,8 @@ var
procedure BuildFont; // build our bitmap font
procedure KillFont; // delete the font
-function glTextWidth(const text: string): real; // returns text width
-procedure glPrint(const text: string); // custom GL "Print" routine
+function glTextWidth(const text: UTF8String): real; // returns text width
+procedure glPrint(const text: UTF8String); // custom GL "Print" routine
procedure ResetFont(); // reset font settings of active font
procedure SetFontPos(X, Y: real); // sets X and Y
procedure SetFontZ(Z: real); // sets Z
@@ -132,7 +132,7 @@ begin
//glDeleteLists(..., 256);
end;
-function glTextWidth(const text: string): real;
+function glTextWidth(const text: UTF8String): real;
var
Bounds: TBoundsDbl;
begin
@@ -141,7 +141,7 @@ begin
end;
// Custom GL "Print" Routine
-procedure glPrint(const Text: string);
+procedure glPrint(const Text: UTF8String);
var
GLFont: PGLFont;
begin
@@ -155,7 +155,6 @@ begin
// set font position
glTranslatef(GLFont.X, GLFont.Y + GLFont.Font.Ascender, GLFont.Z);
// draw string
- //GLFont.Font.Print(RecodeString(Text, encCP1252));
GLFont.Font.Print(Text);
glPopMatrix();
end;
diff --git a/unicode/src/base/UCovers.pas b/unicode/src/base/UCovers.pas
index a1705674..8e7934b2 100644
--- a/unicode/src/base/UCovers.pas
+++ b/unicode/src/base/UCovers.pas
@@ -111,7 +111,7 @@ uses
DateUtils;
const
- COVERDB_FILENAME = 'cover.db';
+ COVERDB_FILENAME: UTF8String = 'cover.db';
COVERDB_VERSION = 01; // 0.1
COVER_TBL = 'Cover';
COVER_THUMBNAIL_TBL = 'CoverThumbnail';
@@ -210,9 +210,9 @@ end;
procedure TCoverDatabase.Open();
var
Version: integer;
- Filename: string;
+ Filename: UTF8String;
begin
- Filename := UTF8Encode(Platform.GetGameUserPath() + COVERDB_FILENAME);
+ Filename := Platform.GetGameUserPath() + COVERDB_FILENAME;
DB := TSQLiteDatabase.Create(Filename);
Version := GetVersion();
diff --git a/unicode/src/base/UFiles.pas b/unicode/src/base/UFiles.pas
index add81f23..463801c7 100644
--- a/unicode/src/base/UFiles.pas
+++ b/unicode/src/base/UFiles.pas
@@ -106,6 +106,7 @@ var
NoteState: String;
begin
+ // FIXME: UNICODE
// Relative := true; // override (idea - use shift+S to save with relative)
AssignFile(SongFile, Name);
Rewrite(SongFile);
diff --git a/unicode/src/base/UFont.pas b/unicode/src/base/UFont.pas
index a72bca21..3d6e9be3 100644
--- a/unicode/src/base/UFont.pas
+++ b/unicode/src/base/UFont.pas
@@ -190,7 +190,7 @@ type
*}
procedure Print(const Text: WideString); overload;
{** UTF-8 version of @link(Print) }
- procedure Print(const Text: string); overload;
+ procedure Print(const Text: UTF8String); overload;
{**
* Calculates the bounding box (width and height) around Text.
@@ -498,7 +498,7 @@ type
procedure ResetIntern();
protected
- fFilename: string; //**< filename of the font-file
+ fFilename: AnsiString; //**< filename of the font-file
fSize: integer; //**< Font base size (in pixels)
fOutset: single; //**< size of outset extrusion (in pixels)
fFace: FT_Face; //**< Holds the height of the font
@@ -528,7 +528,7 @@ type
* @param LoadFlags flags passed to FT_Load_Glyph()
* @raises Exception if the font-file could not be loaded
*}
- constructor Create(const Filename: string;
+ constructor Create(const Filename: AnsiString;
Size: integer; Outset: single = 0.0;
LoadFlags: FT_Int32 = FT_LOAD_DEFAULT);
@@ -558,7 +558,7 @@ type
* The extrusion in pixels is Size*OutsetAmount
* (0.0 -> no extrusion, 0.1 -> 10%).
*}
- constructor Create(const Filename: string;
+ constructor Create(const Filename: AnsiString;
Size: integer; OutsetAmount: single = 0.0;
UseMipmaps: boolean = true);
@@ -576,7 +576,7 @@ type
*}
TFTOutlineFont = class(TFont)
private
- fFilename: string;
+ fFilename: AnsiString;
fSize: integer;
fOutset: single;
fInnerFont, fOutlineFont: TFTFont;
@@ -603,7 +603,7 @@ type
procedure SetReflectionPass(Enable: boolean); override;
public
- constructor Create(const Filename: string;
+ constructor Create(const Filename: AnsiString;
Size: integer; Outset: single;
LoadFlags: FT_Int32 = FT_LOAD_DEFAULT);
destructor Destroy; override;
@@ -637,7 +637,7 @@ type
function CreateMipmap(Level: integer; Scale: single): TFont; override;
public
- constructor Create(const Filename: string;
+ constructor Create(const Filename: AnsiString;
Size: integer; OutsetAmount: single;
UseMipmaps: boolean = true);
@@ -679,7 +679,7 @@ type
* @param InfoFile the name of the info (.dat) file
* @raises Exception if the file is corrupted
*}
- procedure LoadFontInfo(const InfoFile: string);
+ procedure LoadFontInfo(const InfoFile: AnsiString);
protected
procedure Render(const Text: WideString); override;
@@ -699,7 +699,7 @@ type
* (y-axis up) and from the lower edge of the glyphs bounding box)
* @param(Ascender pixels from baseline to top of highest glyph)
*}
- constructor Create(const Filename: string; Outline: integer;
+ constructor Create(const Filename: AnsiString; Outline: integer;
Baseline, Ascender, Descender: integer);
destructor Destroy(); override;
@@ -912,7 +912,7 @@ begin
glPopAttrib();
end;
-procedure TFont.Print(const Text: string);
+procedure TFont.Print(const Text: UTF8String);
var
LineArray: TWideStringArray;
begin
@@ -1368,7 +1368,7 @@ end;
*}
constructor TFTFont.Create(
- const Filename: string;
+ const Filename: AnsiString;
Size: integer; Outset: single;
LoadFlags: FT_Int32);
var
@@ -1606,7 +1606,7 @@ end;
* TFTScalableFont
*}
-constructor TFTScalableFont.Create(const Filename: string;
+constructor TFTScalableFont.Create(const Filename: AnsiString;
Size: integer; OutsetAmount: single;
UseMipmaps: boolean);
var
@@ -1662,7 +1662,7 @@ end;
*}
constructor TFTOutlineFont.Create(
- const Filename: string;
+ const Filename: AnsiString;
Size: integer; Outset: single;
LoadFlags: FT_Int32);
begin
@@ -1852,7 +1852,7 @@ end;
*}
constructor TFTScalableOutlineFont.Create(
- const Filename: string;
+ const Filename: AnsiString;
Size: integer; OutsetAmount: single;
UseMipmaps: boolean);
var
@@ -2482,7 +2482,7 @@ end;
* TBitmapFont
*}
-constructor TBitmapFont.Create(const Filename: string; Outline: integer;
+constructor TBitmapFont.Create(const Filename: AnsiString; Outline: integer;
Baseline, Ascender, Descender: integer);
begin
inherited Create();
@@ -2524,7 +2524,7 @@ begin
fWidths[Count] := Round(fWidths[Count] * WidthMult) + WidthAdd;
end;
-procedure TBitmapFont.LoadFontInfo(const InfoFile: string);
+procedure TBitmapFont.LoadFontInfo(const InfoFile: AnsiString);
var
Stream: TFileStream;
begin
diff --git a/unicode/src/base/ULanguage.pas b/unicode/src/base/ULanguage.pas
index 31840f5f..a89ded2d 100644
--- a/unicode/src/base/ULanguage.pas
+++ b/unicode/src/base/ULanguage.pas
@@ -35,31 +35,36 @@ interface
type
TLanguageEntry = record
- ID: string;
- Text: string;
+ ID: AnsiString; //**< identifier (ASCII)
+ Text: UTF8String; //**< translation (UTF-8)
end;
TLanguageList = record
- Name: string;
- {FileName: string; }
+ Name: AnsiString; //**< language name (ASCII)
end;
+ TLanguageEntryArray = array of TLanguageEntry;
+
TLanguage = class
- public
- Entry: array of TLanguageEntry; //Entrys of Chosen Language
- SEntry: array of TLanguageEntry; //Entrys of Standard Language
- CEntry: array of TLanguageEntry; //Constant Entrys e.g. Version
- Implode_Glue1, Implode_Glue2: String;
- public
+ private
List: array of TLanguageList;
- constructor Create;
+ Entry: TLanguageEntryArray; //**< Entrys of Chosen Language
+ SEntry: TLanguageEntryArray; //**< Entrys of Standard Language
+ CEntry: TLanguageEntryArray; //**< Constant Entrys e.g. Version
+
+ Implode_Glue1, Implode_Glue2: UTF8String;
+
procedure LoadList;
- function Translate(Text: String): String;
- procedure ChangeLanguage(Language: String);
- procedure AddConst(ID, Text: String);
- procedure ChangeConst(ID, Text: String);
- function Implode(Pieces: Array of String): String;
+ function FindID(const ID: AnsiString; const EntryList: TLanguageEntryArray): integer;
+
+ public
+ constructor Create;
+ function Translate(const Text: UTF8String): UTF8String;
+ procedure ChangeLanguage(const Language: AnsiString);
+ procedure AddConst(const ID: AnsiString; const Text: UTF8String);
+ procedure ChangeConst(const ID: AnsiString; const Text: UTF8String);
+ function Implode(const Pieces: array of UTF8String): UTF8String;
end;
var
@@ -69,19 +74,15 @@ implementation
uses
UMain,
- // UFiles,
UIni,
IniFiles,
Classes,
SysUtils,
- {$IFDEF win32}
- windows,
- {$ENDIF}
ULog;
-//----------
-//Create - Construct Class then LoadList + Standard Language + Set Standard Implode Glues
-//----------
+{**
+ * LoadList, set default language, set standard implode glues
+ *}
constructor TLanguage.Create;
var
I, J: Integer;
@@ -107,7 +108,7 @@ begin
ChangeLanguage('English');
SetLength(SEntry, Length(Entry));
- for J := low(Entry) to high(Entry) do
+ for J := 0 to high(Entry) do
SEntry[J] := Entry[J];
SetLength(Entry, 0);
@@ -122,9 +123,9 @@ begin
end;
-//----------
-//LoadList - Parse the Language Dir searching Translations
-//----------
+{**
+ * Parse the Language Dir searching Translations
+ *}
procedure TLanguage.LoadList;
var
SR: TSearchRec; // for parsing directory
@@ -132,7 +133,8 @@ begin
SetLength(List, 0);
SetLength(ILanguage, 0);
- if FindFirst(LanguagesPath + '*.ini', 0, SR) = 0 then begin
+ if FindFirst(LanguagesPath + '*.ini', 0, SR) = 0 then
+ begin
repeat
SetLength(List, Length(List)+1);
SetLength(ILanguage, Length(ILanguage)+1);
@@ -140,16 +142,15 @@ begin
List[High(List)].Name := SR.Name;
ILanguage[High(ILanguage)] := SR.Name;
-
- until FindNext(SR) <> 0;
- SysUtils.FindClose(SR);
+ until (FindNext(SR) <> 0);
+ SysUtils.FindClose(SR);
end; // if FindFirst
end;
-//----------
-//ChangeLanguage - Load the specified LanguageFile
-//----------
-procedure TLanguage.ChangeLanguage(Language: String);
+{**
+ * Load the specified LanguageFile
+ *}
+procedure TLanguage.ChangeLanguage(const Language: AnsiString);
var
IniFile: TIniFile;
E: integer; // entry
@@ -176,57 +177,84 @@ begin
IniFile.Free;
end;
-//----------
-//Translate - Translate the Text
-//----------
-Function TLanguage.Translate(Text: String): String;
+{**
+ * Find the index of ID an array of language entries.
+ * @returns the index on success, -1 otherwise.
+ *}
+function TLanguage.FindID(const ID: AnsiString; const EntryList: TLanguageEntryArray): integer;
var
- E: integer; // entry
+ Index: integer;
begin
+ for Index := 0 to High(EntryList) do
+ begin
+ if ID = EntryList[Index].ID then
+ begin
+ Result := Index;
+ Exit;
+ end;
+ end;
+ Result := -1;
+end;
+
+{**
+ * Translate the Text.
+ * If Text is an ID, text will be translated according to the current language
+ * setting. If Text is not a known ID, it will be returned as is.
+ * @param Text either an ID or an UTF-8 encoded string
+ *}
+function TLanguage.Translate(const Text: UTF8String): UTF8String;
+var
+ E: integer; // entry
+ ID: AnsiString;
+ EntryIndex: integer;
+begin
+ // fallback result in case Text is not a known ID
Result := Text;
- Text := Uppercase(Result);
+
+ // normalize ID case
+ ID := UpperCase(Text);
+
+ // Check if ID exists
//Const Mod
- for E := 0 to high(CEntry) do
- if Text = CEntry[E].ID then
- begin
- Result := CEntry[E].Text;
- exit;
- end;
- //Const Mod End
+ EntryIndex := FindID(ID, CEntry);
+ if (EntryIndex >= 0) then
+ begin
+ Result := CEntry[EntryIndex].Text;
+ Exit;
+ end;
- for E := 0 to high(Entry) do
- if Text = Entry[E].ID then
- begin
- Result := Entry[E].Text;
- exit;
- end;
+ EntryIndex := FindID(ID, Entry);
+ if (EntryIndex >= 0) then
+ begin
+ Result := Entry[EntryIndex].Text;
+ Exit;
+ end;
//Standard Language (If a Language File is Incomplete)
//Then use Standard Language
- for E := low(SEntry) to high(SEntry) do
- if Text = SEntry[E].ID then
- begin
- Result := SEntry[E].Text;
- Break;
- end;
- //Standard Language END
+ EntryIndex := FindID(ID, SEntry);
+ if (EntryIndex >= 0) then
+ begin
+ Result := SEntry[EntryIndex].Text;
+ Exit;
+ end;
end;
-//----------
-//AddConst - Add a Constant ID that will be Translated but not Loaded from the LanguageFile
-//----------
-procedure TLanguage.AddConst (ID, Text: String);
+{**
+ * Add a Constant ID that will be Translated but not Loaded from the LanguageFile
+ *}
+procedure TLanguage.AddConst(const ID: AnsiString; const Text: UTF8String);
begin
SetLength (CEntry, Length(CEntry) + 1);
CEntry[high(CEntry)].ID := ID;
CEntry[high(CEntry)].Text := Text;
end;
-//----------
-//ChangeConst - Change a Constant Value by ID
-//----------
-procedure TLanguage.ChangeConst(ID, Text: String);
+{**
+ * Change a Constant Value by ID
+ *}
+procedure TLanguage.ChangeConst(const ID: AnsiString; const Text: UTF8String);
var
I: Integer;
begin
@@ -240,16 +268,16 @@ begin
end;
end;
-//----------
-//Implode - Connect an Array of Strings with ' and ' or ', ' to one String
-//----------
-function TLanguage.Implode(Pieces: Array of String): String;
+{**
+ * Connect an array of strings with ' and ' or ', ' to one string
+ *}
+function TLanguage.Implode(const Pieces: array of UTF8String): UTF8String;
var
I: Integer;
begin
Result := '';
//Go through Pieces
- for I := low(Pieces) to high(Pieces) do
+ for I := 0 to high(Pieces) do
begin
//Add Value
Result := Result + Pieces[I];
diff --git a/unicode/src/base/UParty.pas b/unicode/src/base/UParty.pas
index cf19e46e..36ab33fb 100644
--- a/unicode/src/base/UParty.pas
+++ b/unicode/src/base/UParty.pas
@@ -606,7 +606,7 @@ end;
//----------
Function TPartySession.GetWinnerString(wParam: TwParam; lParam: TlParam): integer;
var
- Winners: Array of String;
+ Winners: array of UTF8String;
I: Integer;
ResultStr: String;
S: ^String;
diff --git a/unicode/src/base/UPlaylist.pas b/unicode/src/base/UPlaylist.pas
index 11ed84de..09043a1b 100644
--- a/unicode/src/base/UPlaylist.pas
+++ b/unicode/src/base/UPlaylist.pas
@@ -38,15 +38,15 @@ uses
type
TPlaylistItem = record
- Artist: String;
- Title: String;
+ Artist: UTF8String;
+ Title: UTF8String;
SongID: Integer;
end;
APlaylistItem = array of TPlaylistItem;
TPlaylist = record
- Name: String;
+ Name: string;
Filename: String;
Items: APlaylistItem;
end;
@@ -68,18 +68,18 @@ type
constructor Create;
Procedure LoadPlayLists;
- Function LoadPlayList(Index: Cardinal; Filename: String): Boolean;
+ Function LoadPlayList(Index: Cardinal; const Filename: String): Boolean;
Procedure SavePlayList(Index: Cardinal);
Procedure SetPlayList(Index: Cardinal);
- Function AddPlaylist(Name: String): Cardinal;
+ Function AddPlaylist(const Name: string): Cardinal;
Procedure DelPlaylist(const Index: Cardinal);
Procedure AddItem(const SongID: Cardinal; const iPlaylist: Integer = -1);
Procedure DelItem(const iItem: Cardinal; const iPlaylist: Integer = -1);
- Procedure GetNames(var PLNames: array of String);
+ Procedure GetNames(var PLNames: array of string);
Function GetIndexbySongID(const SongID: Cardinal; const iPlaylist: Integer = -1): Integer;
end;
@@ -151,7 +151,7 @@ end;
//----------
//LoadPlayList - Load a Playlist in the Array
//----------
-Function TPlayListManager.LoadPlayList(Index: Cardinal; Filename: String): Boolean;
+Function TPlayListManager.LoadPlayList(Index: Cardinal; const Filename: String): Boolean;
var
F: TextFile;
Line: String;
@@ -159,7 +159,7 @@ Function TPlayListManager.LoadPlayList(Index: Cardinal; Filename: String): Bo
SongID: Integer;
Len: Integer;
- Function FindSong(Artist, Title: String): Integer;
+ Function FindSong(Artist, Title: UTF8String): Integer;
var I: Integer;
begin
Result := -1;
@@ -323,7 +323,7 @@ end;
//----------
//AddPlaylist - Adds a Playlist and Returns the Index
//----------
-Function TPlayListManager.AddPlaylist(Name: String): Cardinal;
+Function TPlayListManager.AddPlaylist(const Name: string): Cardinal;
var
I: Integer;
begin