Class TextFile
Connects to and reads text from the TEXT.RSC file.
Also provides helpers for other classes using the text resource format.
Assembly: Assembly-CSharp.dll
Syntax
Constructors
|
Improve this Doc
View Source
TextFile()
Declaration
|
Improve this Doc
View Source
TextFile(String, String, FileUsage, Boolean)
Declaration
public TextFile(string arena2Path, string fileName, FileUsage usage = FileUsage.UseMemory, bool readOnly = true)
Parameters
Fields
|
Improve this Doc
View Source
Filename
Declaration
public const string Filename = "TEXT.RSC"
Field Value
Properties
|
Improve this Doc
View Source
IsLoaded
True if a text resource file is loaded.
Declaration
public bool IsLoaded { get; }
Property Value
|
Improve this Doc
View Source
NewLineToken
Declaration
public static TextFile.Token NewLineToken { get; }
Property Value
|
Improve this Doc
View Source
RecordCount
Gets number of text record elements in currently open file.
Declaration
public int RecordCount { get; }
Property Value
|
Improve this Doc
View Source
TabToken
Declaration
public static TextFile.Token TabToken { get; }
Property Value
Methods
|
Improve this Doc
View Source
AppendTokens(TextFile.Token[], TextFile.Token[], Boolean)
Appends new tokens to an existing token array and optionally injects newline between current tokens and appended tokens.
Declaration
public static TextFile.Token[] AppendTokens(TextFile.Token[] current, TextFile.Token[] extra, bool newLine = true)
Parameters
Type |
Name |
Description |
TextFile.Token[] |
current |
Current tokens.
|
TextFile.Token[] |
extra |
New tokens to append.
|
Boolean |
newLine |
True to inject newline between current and extra tokens.
|
Returns
|
Improve this Doc
View Source
CreateFormatToken(TextFile.Formatting)
Declaration
public static TextFile.Token CreateFormatToken(TextFile.Formatting format)
Parameters
Returns
|
Improve this Doc
View Source
CreateTextToken(String)
Declaration
public static TextFile.Token CreateTextToken(string text)
Parameters
Type |
Name |
Description |
String |
text |
|
Returns
|
Improve this Doc
View Source
DumpToCSV(String)
Dumps entire text database to CSV.
Declaration
public void DumpToCSV(string path)
Parameters
Type |
Name |
Description |
String |
path |
Full path to output file.
|
|
Improve this Doc
View Source
GetBytesById(Int32)
Gets raw bytes by id with all special bytes intact, such as terminating 0xfe.
Declaration
public byte[] GetBytesById(int id)
Parameters
Type |
Name |
Description |
Int32 |
id |
|
Returns
|
Improve this Doc
View Source
GetBytesByIndex(Int32)
Gets raw bytes by index with all special bytes intact, such as terminating 0xfe.
Declaration
public byte[] GetBytesByIndex(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
|
Improve this Doc
View Source
GetTextRecordByIndex(Int32)
Gets TextRecord data by index.
Special formatting characters are parsed into [0x00] format.
Declaration
public TextFile.TextRecord GetTextRecordByIndex(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
|
Improve this Doc
View Source
GetTokenLines(TextFile.Token[])
Simple method to split tokens into text array, one entry per text token.
Other formatting tokens are ignored.
This is best used for multi-line popup HUD text.
Declaration
public static string[] GetTokenLines(TextFile.Token[] tokens)
Parameters
Returns
Type |
Description |
String[] |
String array.
|
|
Improve this Doc
View Source
IdToIndex(Int32)
Converts id to index. Invalid id returns -1.
Declaration
public int IdToIndex(int id)
Parameters
Type |
Name |
Description |
Int32 |
id |
|
Returns
|
Improve this Doc
View Source
IndexToId(Int32)
Converts index to id. Invalid index returns -1.
Declaration
public int IndexToId(int index)
Parameters
Type |
Name |
Description |
Int32 |
index |
|
Returns
|
Improve this Doc
View Source
Load(Byte[], String)
Loads a text resource file from raw bytes.
Binary data must still match expected format.
Declaration
public void Load(byte[] data, string filename)
Parameters
Type |
Name |
Description |
Byte[] |
data |
Binary data of RSC file.
|
String |
filename |
Custom filename. Does not have to match standard TEXT.RSC filename.
|
|
Improve this Doc
View Source
Load(String, String, FileUsage, Boolean)
Load a text resource file.
Declaration
public void Load(string arena2Path, string filename, FileUsage usage = FileUsage.UseMemory, bool readOnly = true)
Parameters
|
Improve this Doc
View Source
ReadTokens(ref Byte[], Int32, TextFile.Formatting)
Tokenizes Daggerfall text resource data.
Declaration
public static TextFile.Token[] ReadTokens(ref byte[] buffer, int position, TextFile.Formatting endToken)
Parameters
Type |
Name |
Description |
Byte[] |
buffer |
Source buffer containing raw text resource data (e.g. from TEXT.RSC or a book file).
|
Int32 |
position |
Position in buffer to start tokenizing (e.g. start of record or start of page).
|
TextFile.Formatting |
endToken |
Formatting byte that terminates token stream (e.g. Formatting.EndOfRecord or Formatting.EndOfPage).
|
Returns
Type |
Description |
TextFile.Token[] |
Array of text and formatting tokens.
|