Repository navigation
ANNA
Add entries to ANNA's menu from your mod. ANNA is the in-car assistant from the separate FH2 ANNA mod: press d-pad down while driving to open her menu on the HUD.
Your entries need FH2 ANNA installed (version 4 of its interface or newer). Without it,
ANNA.IsAvailableis false and adding entries does nothing. Your mod still runs fine.
Thread: any for IsOpen. Add your entries in OnInit. The code an entry runs when it's chosen runs on the game thread, so it can use the other FH2 classes straight away.
Add a list called "My Tools" to ANNA's top list, with an entry that sets the time to noon. Add a headlights switch to her Car > Lights list that stays open, and only shows while you're in a car.
protected override void OnInit()
{
var tools = ANNA.Menu.AddList("My Tools");
tools.Add("Noon", () => World.TimeOfDay = TimeSpan.FromHours(12));
var lights = ANNA.CarLights.Add("Headlights", () =>
{
if (Player.Car is { } car) car.HeadlightsOn = !car.HeadlightsOn;
}, staysOpen: true);
lights.Visible = () => Player.Car is not null;
}Protected Overrides Sub OnInit()
Dim tools = ANNA.Menu.AddList("My Tools")
tools.Add("Noon", Sub() World.TimeOfDay = TimeSpan.FromHours(12))
Dim lights = ANNA.CarLights.Add("Headlights", Sub()
Dim car = Player.Car
If car IsNot Nothing Then car.HeadlightsOn = Not car.HeadlightsOn
End Sub, staysOpen:=True)
lights.Visible = Function() Player.Car IsNot Nothing
End Sub| Member | What it does |
|---|---|
IsAvailable (property, bool) |
True when FH2 ANNA is installed and has given its menu to other mods. |
IsOpen (property, bool) |
True while ANNA's menu is open on the HUD. Any thread. |
Menu (field, MenuList) |
ANNA's top list. |
Car (field, MenuList) |
ANNA's Car list (Lights, Doors, Roof...). |
CarLights (field, MenuList) |
ANNA's Car > Lights list. |
CarDoors (field, MenuList) |
ANNA's Car > Doors list. |
Route (field, MenuList) |
ANNA's Set Route To Nearest list. |
List(string key) (method, returns MenuList) |
Any list in ANNA's menu, by its key: another mod's, a native mod's (see its author's docs), or one of hers. Your entries show once that list exists. If its mod isn't installed, they never show. |
Items(string name) (method, returns MenuList) |
A list in ANNA's menu by what it's called: one of hers ("Car", "Car > Lights", "Car > Doors", "Set Route To Nearest") or one a .NET mod added ("CarSpawner"). Use "A > B" for a list inside a list. A key works too. |
The keys of ANNA's own lists (all const string).
| Member | What it does |
|---|---|
Car |
"car", the Car list. |
CarLights |
"car.lights", the Car > Lights list. |
CarDoors |
"car.doors", the Car > Doors list. |
Route |
"route", the Set Route To Nearest list. |
A list in ANNA's menu: the top list, one of hers, or one of yours.
| Member | What it does |
|---|---|
Key (property, string?) |
The list's key. Null for the top list, or for a list looked up by name that isn't there yet. |
Add(string label, Action onChoose, bool staysOpen = false, string? parent = null, string? key = null) (method, returns MenuItem) |
Adds an entry that runs onChoose (on the game thread) when it's chosen. With staysOpen, ANNA stays open afterwards, for things you flip back and forth. parent puts the entry in another list (by key) instead of this one. key sets the entry's key yourself. |
AddList(string label, string? key = null) (method, returns MenuList) |
Adds a list of your own under this one. It shows once something is in it. Its key is "<your mod>.<label>". |
One entry in ANNA's menu. You can change its label, or when it shows, at any time.
| Member | What it does |
|---|---|
Key (property, string) |
The entry's key. |
Parent (property, string?) |
The key of the list it's in. Null for the top list, or for a list looked up by name that isn't there yet. |
Label (property, string, get/set) |
What the entry says. A change shows the next time its list opens. |
Visible (property, Func<bool>?, get/set) |
Asked each time its list opens. Returning false hides the entry. |
Enabled (property, Func<bool>?, get/set) |
Asked each time its list opens. Returning false greys the entry out. |
- FH2 ANNA is looked up once every mod has started. So early on (for example in
OnInit)IsAvailablemay still be false. That's fine: entries you add are kept and handed to ANNA once she's found. - Keys are made for you from your mod's assembly name and the label, in lower case, with anything other than letters and digits turned into
_. For example, a list "My Tools" in a mod whose assembly is MyMod gets the key"mymod.my_tools". UseMenuList.Keyto see a key. - Your entries are always under your mod's name, so two mods' entries can't clash.
- With
Items(name), the list doesn't have to exist yet. Your entries wait for it until every mod has started. If no list ever has that name, the entries don't show andplatform.logsays so. - If an entry's code (or its
VisibleorEnabledfunction) throws, the error is written toplatform.log. A failingVisibleorEnabledcounts as true. - When your mod is reloaded, its entries do nothing until the new copy adds them again. Adding an entry with the same key again keeps its place in the menu and uses the new code.
VisibleandEnabledare cleared, so set them again. -
ANNAtalks to the FH2 ANNA mod, not to the game's code, so it doesn't switch off on an unsupported game build. It only depends on FH2 ANNA being installed.
Playing
Getting started
Writing mods
The FH2 classes
- Game
- Player
- Vehicle
- World
- Garage, CarCatalog, Profile
- UI and Hud
- Camera
- Audio
- ANNA
- Skills
- DebugOverlay
- Controller
- GameInput
- GameWindow
- Menus and UiElement
- SettingsTile
- ButtonIcons and Picture
- MapView, PhotoCamera, GarageCamera
More