2020-12-13 07:48:15 -05:00
# Usage
## Basic Parsing
2022-07-21 10:23:31 -04:00
If you want to create your own internal CST parsing framework, you can use the `CST` or `CaretSeparatedText` class directly.
2020-12-13 07:48:15 -05:00
```text
1 ^The quick brown fox jumps over the lazy dog.^
```
```csharp
2022-07-21 10:23:31 -04:00
#r "nuget:CSTNet,1.0.400-beta1" // If using notebooks
using CSTNet;
2020-12-13 07:48:15 -05:00
var file = File.ReadAllText("example.cst");
2022-07-21 10:23:31 -04:00
var example = CST.Parse(file, 1);
2020-12-13 07:48:15 -05:00
2022-07-21 10:23:31 -04:00
// "The quick brown fox jumps over the lazy dog."
2020-12-13 07:48:15 -05:00
Console.WriteLine(example);
```
2022-07-21 10:23:31 -04:00
## In Production
2020-12-13 07:48:15 -05:00
2022-10-10 02:54:46 -04:00
The Sims Online, and by extension FreeSO, are the only known example of CST files ever being used in production. CST.NET's APIs is based on FreeSO's and is meant to function both as drop-in replacement and general purpose API.
2020-12-13 07:48:15 -05:00
```csharp
2022-07-21 10:23:31 -04:00
#r "nuget:CSTNet,1.0.300"
using CSTNet;
2020-12-13 07:48:15 -05:00
var english = new UIText(); // UIText assumes English
var swedish = new UIText("swedish");
2021-11-19 13:52:26 -05:00
var engExample = english.GetText(152, 1); // english.dir/_154_miscstrings.cst
var sweExample = swedish.GetText(152, 1); // swedish.dir/_154_miscstrings.cst
2020-12-13 07:48:15 -05:00
Console.WriteLine(engExample);
Console.WriteLine(sweExample);
```
2022-07-21 10:23:31 -04:00
In The Sims Online, it was required translation were prefixed with numbers enclosed in underscores, known as the ID. The IDs were used to locate the right file without having to remember it's name. Meanwhile, each translation was split into their respective ``uitext/<languae>.dir` ` directories:
- ``uitext/english.dir/_154_miscstrings.cst` `
- ``uitext/swedish.dir/_154_miscstrings.cst` `
2022-10-10 02:54:46 -04:00
Note that the ``UIText`` class uses the above mentioned ``CST.Parse()` ` method internally. Any changes made to the CST class.
2020-12-13 07:48:15 -05:00
### Changing base directories
If you want to change the base directory, you can. Though, this is still a work in progress and not recommended.
```csharp
2022-07-21 10:23:31 -04:00
#r "nuget:CSTNet,1.0.300"
using CSTNet;
2020-12-13 07:48:15 -05:00
var example = new UIText()
{
BasePath = new[] { "gamedata", "uitext" },
};
```