From b73bb7080b12266fba7ebfaf4282ca12b9c89577 Mon Sep 17 00:00:00 2001 From: tobigun Date: Thu, 23 Jul 2009 19:21:06 +0000 Subject: further string -> UTF8String or IPath conversions git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1887 b956fd51-792f-4845-bead-9b4dfca2ff2c --- unicode/src/base/UEditorLyrics.pas | 4 ++-- unicode/src/base/UFont.pas | 2 +- unicode/src/base/ULanguage.pas | 7 +++++-- unicode/src/base/ULog.pas | 20 +++++++++--------- unicode/src/base/ULyrics.pas | 4 ++-- unicode/src/base/UMusic.pas | 2 +- unicode/src/base/UNote.pas | 2 +- unicode/src/base/UParty.pas | 4 ++-- unicode/src/base/UPlatformWindows.pas | 38 ----------------------------------- unicode/src/base/USongs.pas | 2 +- 10 files changed, 24 insertions(+), 61 deletions(-) (limited to 'unicode/src/base') diff --git a/unicode/src/base/UEditorLyrics.pas b/unicode/src/base/UEditorLyrics.pas index ef9d8dd6..0eacd1f9 100644 --- a/unicode/src/base/UEditorLyrics.pas +++ b/unicode/src/base/UEditorLyrics.pas @@ -74,7 +74,7 @@ type procedure SetSize(Value: real); procedure SetSelected(Value: integer); procedure SetFontStyle(Value: integer); - procedure AddWord(Text: string); + procedure AddWord(Text: UTF8String); procedure Refresh; public ColR: real; @@ -179,7 +179,7 @@ begin FontStyleI := Value; end; -procedure TEditorLyrics.AddWord(Text: string); +procedure TEditorLyrics.AddWord(Text: UTF8String); var WordNum: integer; begin diff --git a/unicode/src/base/UFont.pas b/unicode/src/base/UFont.pas index 473e8f95..8baab629 100644 --- a/unicode/src/base/UFont.pas +++ b/unicode/src/base/UFont.pas @@ -128,7 +128,7 @@ type {** * Splits lines in Text seperated by newline (char-code #13). - * @param Text UTF-8 encoded string + * @param Text UCS-4 encoded string * @param Lines splitted UCS4String lines *} procedure SplitLines(const Text: UCS4String; var Lines: TUCS4StringArray); diff --git a/unicode/src/base/ULanguage.pas b/unicode/src/base/ULanguage.pas index 88b6647f..3dd5a9e0 100644 --- a/unicode/src/base/ULanguage.pas +++ b/unicode/src/base/ULanguage.pas @@ -33,6 +33,9 @@ interface {$I switches.inc} +uses + UUnicodeUtils; + type TLanguageEntry = record ID: AnsiString; //**< identifier (ASCII) @@ -60,7 +63,7 @@ type public constructor Create; - function Translate(const Text: UTF8String): UTF8String; + function Translate(const Text: RawByteString): UTF8String; procedure ChangeLanguage(const Language: AnsiString); procedure AddConst(const ID: AnsiString; const Text: UTF8String); procedure ChangeConst(const ID: AnsiString; const Text: UTF8String); @@ -208,7 +211,7 @@ end; * 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; +function TLanguage.Translate(const Text: RawByteString): UTF8String; var E: integer; // entry ID: AnsiString; diff --git a/unicode/src/base/ULog.pas b/unicode/src/base/ULog.pas index 08a64e2b..e4ff4862 100644 --- a/unicode/src/base/ULog.pas +++ b/unicode/src/base/ULog.pas @@ -116,7 +116,7 @@ type // voice procedure LogVoice(SoundNr: integer); // buffer - procedure LogBuffer(const buf : Pointer; const bufLength : Integer; const filename : string); + procedure LogBuffer(const buf : Pointer; const bufLength : Integer; const filename : IPath); end; procedure DebugWriteln(const aString: String); @@ -420,21 +420,19 @@ begin FS.Free; end; -procedure TLog.LogBuffer(const buf: Pointer; const bufLength: Integer; const filename: string); +procedure TLog.LogBuffer(const buf: Pointer; const bufLength: Integer; const filename: IPath); var - f : TFileStream; + f : TBinaryFileStream; begin - f := nil; - try - f := TFileStream.Create( filename, fmCreate); - f.Write( buf^, bufLength); - f.Free; - except - on e : Exception do begin - Log.LogError('TLog.LogBuffer: Failed to log buffer into file "' + filename + '". ErrMsg: ' + e.Message); + f := TBinaryFileStream.Create( filename, fmCreate); + try + f.Write( buf^, bufLength); + finally f.Free; end; + except on e : Exception do + Log.LogError('TLog.LogBuffer: Failed to log buffer into file "' + filename.ToNative + '". ErrMsg: ' + e.Message); end; end; diff --git a/unicode/src/base/ULyrics.pas b/unicode/src/base/ULyrics.pas index 82982981..3f62db9c 100644 --- a/unicode/src/base/ULyrics.pas +++ b/unicode/src/base/ULyrics.pas @@ -52,14 +52,14 @@ type Width: real; // width Start: cardinal; // start of the word in quarters (beats) Length: cardinal; // length of the word in quarters - Text: string; // text + Text: UTF8String; // text Freestyle: boolean; // is freestyle? end; TLyricWordArray = array of TLyricWord; TLyricLine = class public - Text: string; // text + Text: UTF8String; // text Width: real; // width Height: real; // height Words: TLyricWordArray; // words in this line diff --git a/unicode/src/base/UMusic.pas b/unicode/src/base/UMusic.pas index 51759b6f..24eb0f45 100644 --- a/unicode/src/base/UMusic.pas +++ b/unicode/src/base/UMusic.pas @@ -457,7 +457,7 @@ const SOUNDID_CLICK = 5; LAST_SOUNDID = SOUNDID_CLICK; - BaseSoundFilenames: array[0..LAST_SOUNDID] of string = ( + BaseSoundFilenames: array[0..LAST_SOUNDID] of IPath = ( '%SOUNDPATH%/Common start.mp3', // Start '%SOUNDPATH%/Common back.mp3', // Back '%SOUNDPATH%/menu swoosh.mp3', // Swoosh diff --git a/unicode/src/base/UNote.pas b/unicode/src/base/UNote.pas index b457bda3..8e5b709a 100644 --- a/unicode/src/base/UNote.pas +++ b/unicode/src/base/UNote.pas @@ -61,7 +61,7 @@ type PPLayer = ^TPlayer; TPlayer = record - Name: string; + Name: UTF8String; // Index in Teaminfo record TeamID: byte; diff --git a/unicode/src/base/UParty.pas b/unicode/src/base/UParty.pas index b02d13be..3cfcb6cb 100644 --- a/unicode/src/base/UParty.pas +++ b/unicode/src/base/UParty.pas @@ -71,7 +71,7 @@ type procedure StartRound; procedure EndRound; function GetTeamOrder: TeamOrderArray; - function GetWinnerString(Round: byte): string; + function GetWinnerString(Round: byte): UTF8String; end; var @@ -347,7 +347,7 @@ end; //---------- //GetWinnerString - Get string with WinnerTeam Name, when there is more than one Winner than Connect with and or , //---------- -function TPartySession.GetWinnerString(Round: byte): string; +function TPartySession.GetWinnerString(Round: byte): UTF8String; var Winners: array of UTF8String; I: integer; diff --git a/unicode/src/base/UPlatformWindows.pas b/unicode/src/base/UPlatformWindows.pas index 2d0bd212..a0372dad 100644 --- a/unicode/src/base/UPlatformWindows.pas +++ b/unicode/src/base/UPlatformWindows.pas @@ -61,44 +61,6 @@ uses Windows, UConfig; -(* -function FindMatchingFileW(var F: TSearchRecW): Integer; forward; -function DirectoryExistsW(const Directory: widestring): Boolean; forward; - -function FindMatchingFileW(var F: TSearchRecW): Integer; -var - LocalFileTime: TFileTime; -begin - with F do - begin - while FindData.dwFileAttributes and ExcludeAttr <> 0 do -{$IFDEF Delphi} - if not FindNextFileW(FindHandle, FindData) then -{$ELSE} - if not FindNextFileW(FindHandle, @FindData) then -{$ENDIF} - begin - Result := GetLastError; - Exit; - end; - FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime); - FileTimeToDosDateTime(LocalFileTime, LongRec(Time).Hi, LongRec(Time).Lo); - Size := FindData.nFileSizeLow; - Attr := FindData.dwFileAttributes; - Name := FindData.cFileName; - end; - Result := 0; -end; - -function DirectoryExistsW(const Directory: widestring): Boolean; -var - Code: Integer; -begin - Code := GetFileAttributesW(PWideChar(Directory)); - Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); -end; -*) - //------------------------------ //Start more than One Time Prevention //------------------------------ diff --git a/unicode/src/base/USongs.pas b/unicode/src/base/USongs.pas index 55ddc5e9..c650c04d 100644 --- a/unicode/src/base/USongs.pas +++ b/unicode/src/base/USongs.pas @@ -76,7 +76,7 @@ type end; TScore = record - Name: widestring; + Name: UTF8String; Score: integer; Length: string; end; -- cgit v1.2.3