Skip to content
Mohammad Shoaib Khan edited this page Aug 29, 2024 · 6 revisions

API Reference

Quick reference for the mod's API which can be found in IStardewAccessAPI.cs.

Table of Contents

Screen Reader Related

PrevMenuQueryText Property

Summary:

The query text for the previously spoken (or currently being spoken) by the screen reader in current menu. This is used to prevent speaking same texts repeatedly Resets when the menu is closed or changed.

Type:

String

MenuPrefixText Property

Summary:

The prefix which will get prepended to the next text the screen reader will speak in current menu. Included in query check, alongside PrevMenuQueryText. Resets when the menu is closed or changed.

Type:

String

MenuSuffixText Property

Summary:

The suffix which will get appended to the next text the screen reader will speak in current menu. Included in query check, alongside PrevMenuQueryText. Resets when the menu is closed or changed.

Type:

String

MenuPrefixNoQueryText Property

Summary:

The prefix which will get prepended to the next text the screen reader will speak in current menu. Won't be included in query check. Resets everytime after use.

Type:

String

MenuSuffixNoQueryText Property

Summary:

The suffix which will get appended to the next text the screen reader will speak in current menu. Won't be included in query check. Resets every time after use.

Type:

String

Say()

Summary:

Speaks the text via the loaded screen reader (if any)

Returns:

true if the text was spoken otherwise false.

Parameters:

Name Type Default Value Description
text string - The text to be narrated.
interrupt bool - Whether to skip the currently speaking text or not.

SayWithChecker()

Summary:

Speaks the text via the loaded screen reader (if any). Skips the text narration if the previously narrated text was the same as the one provided.

Returns:

true if the text was spoken otherwise false.

Parameters:

Name Type Default Value Description
text string - The text to be narrated.
interrupt boolean - Whether to skip the currently speaking text or not.
customQuery string null If set, uses this instead of text as query to check whether to speak the text or not.

SayWithMenuChecker()

Summary:

Speaks the text via the loaded screen reader (if any). Skips the text narration if the previously narrated text was the same as the one provided. Use this when narrating hovered component in menus to avoid interference.

Returns:

true if the text was spoken otherwise false.

Parameters:

Name Type Default Value Description
text string - The text to be narrated.
interrupt boolean - Whether to skip the currently speaking text or not.
customQuery string null If set, uses this instead of text as query to check whether to speak the text or not.

SayWithChatChecker()

Summary:

Speaks the text via the loaded screen reader (if any). Skips the text narration if the previously narrated text was the same as the one provided. Use this when narrating chat messages to avoid interference.

Returns:

true if the text was spoken otherwise false.

Parameters:

Name Type Default Value Description
text string - The text to be narrated.
interrupt bool - Whether to skip the currently speaking text or not.

Tile Related

SayWithTileQuery()

Summary:

Speaks the text via the loaded screen reader (if any). Skips the text narration if the previously narrated text was the same as the one provided. Use this when narrating texts based on tile position to avoid interference.

Returns:

true if the text was spoken otherwise false.

Parameters:

Name Type Default Value Description
text string - The text to be narrated.
x int - The X location of tile.
y int - The Y location of tile.
interrupt bool - Whether to skip the currently speaking text or not.

SearchNearbyTiles()

Summary:

Search the area using Breadth First Search algorithm(BFS).

Returns:

A dictionary with all the detected tiles along with the name of the object on it and it's category.

Dictionary<Vector2, (string name, string category)>

Parameters:

Name Type Default Value Description
center Vector2 - The starting point.
limit int - The limiting factor or simply radius of the search area.

SearchLocation()

Summary:

Search the entire location using Breadth First Search algorithm(BFS).

Returns:

A dictionary with all the detected tiles along with the name of the object on it and it's category.

Dictionary<Vector2, (string name, string category)>

GetNameWithCategoryNameAtTile()

Summary:

Check the tile for any object.

Returns:

Name of the object as the first item (name) and category as the second item (category). Returns null if no object found.

(string? name, string? category)

Parameters:

Name Type Default Value Description
tile Vector2 - The tile where we want to check the name and category of object if any.

GetNameAtTile()

Summary:

Check the tile for any object.

Returns:

Name of the object. Returns null if no object found.

Parameters:

Name Type Default Value Description
tile Vector2 - The tile where we want to check the name and category of object if any.

Inventory and Item Related

SpeakHoveredInventorySlot()

Summary:

Speaks the hovered inventory slot from the provided InventoryMenu. In case there is nothing in a slot, then it will speak "Empty Slot". Also plays a sound if the slot is grayed out, like tools in geode menu.

Returns:

true if any inventory slot was hovered or found at the hoverX and hoverY.

Parameters:

Name Type Default Value Description
inventoryMenu InventoryMenu - The object of InventoryMenu whose inventory is to be spoken.
giveExtraDetails boolean null (Optional) Whether to speak extra details about the item in slot or not. Default to null in which case it uses DisableInventoryVerbosity config to get whether to speak extra details or not.
hoverPrice int -1 (Optional) The price of the hovered item, generally used in ShopMenu.
extraItemToShowIndex string null (Optional) The index (probably parentSheetIndex) of the extra item which is generally a requirement for the hovered item in certain menus.
extraItemToShowAmount int -1 (Optional) The amount or quantity of the extra item which is generally a requirement for the hovered item in certain menus.
highlightedItemPrefix string null (Optional) The prefix to add to the spoken hovered item's details if it is highlighted i.e., not grayed out.
highlightedItemSuffix string null (Optional) The suffix to add to the spoken hovered item's details if it is highlighted i.e., not grayed out.
hoverX int null (Optional) The X position on screen to check. Default to null, in which case it uses the mouse's X position.
hoverY int null (Optional) The Y position on screen to check. Default to null, in which case it uses the mouse's Y position.

GetDetailsOfItem()

Summary:

Get the details (name, description, quality, etc.) of an Item.

Returns:

The details of the given item.

Parameters:

Name Type Default Value Description
item Item - The Item's object that we want to get details of.
giveExtraDetails boolean false (Optional) Whether to also return extra details or not. These include: description, health, stamina and other buffs.
price int -1 (Optional) Generally the selling price of the item.
extraItemToShowIndex string null (Optional) The index of the extra item which is generally the required item for the given item.
extraItemToShowAmount int -1 (Optional) The amount or quantity of the extra item.

Menu Helpers

PrimaryInfoKey Property

(Default to C) Mainly used to speak some visual information in a menu like some label(s) which isn't reachable by gamepad naviagtion.

Type:

StardewModdingAPI.Utilities.KeybindList

SpeakHoveredClickableComponentsFromList<T>()

Summary:

Speaks the contents of hovered clickable component from the list. Prioritizes speaking from ClickableComponent.ScreenReaderText and ClickableComponent.ScreenReaderDescription and if these are empty, speaks the ClickableComponent.name and ClickableComponent.label as fallback.

Returns:

true if a hovered component was detected, otherwise false.

Parameters:

Name Type Default Value Description
ccList List<T> (where T is ClickableComponent) - The list of components to speak from.

SpeakClickableComponent()

Summary:

Speaks the contents of the given clickable component. Prioritizes speaking from ClickableComponent.ScreenReaderText and ClickableComponent.ScreenReaderDescription and if these are empty, speaks the ClickableComponent.name and ClickableComponent.label as fallback. Ignores speaking if ClickableComponent.ScreenReaderIgnore was set to true.

Parameters:

Name Type Default Value Description
component ClickableComponent - The component to speak.

SpeakHoveredOptionsElementSlot()

Summary:

Speaks the hovered element from list which are being drawn/rendered in slots. Prioritizes speaking from OptionsElement.ScreenReaderText and OptionsElement.ScreenReaderDescription and if these are empty, speaks the OptionsElement.label as fallback.

Returns:

true if a hovered element was detected, otherwise false.

Parameters:

Name Type Default Value Description
optionSlots List<ClickableComponent> - The slots where the elements will be drawn/rendered.
options List<OptionsElement> - The list of elements.
currentItemIndex int - The index of the element currently being rendered in the first slot.

SpeakHoveredOptionsElementFromList<T>()

Summary:

Speaks the hovered element from options. Prioritizes speaking from OptionsElement.ScreenReaderText and OptionsElement.ScreenReaderDescription and if these are empty, speaks the OptionsElement.label as fallback.

Remarks:

Only use this when elements are being drawn independently from slots or when the element's position is correctly reflected in OptionsElement.bounds.

Returns:

true if a hovered element was detected, otherwise false.

Parameters:

Name Type Default Value Description
options List<T> (where T is OptionsElement) - The list of elements.

SpeakOptionsElement()

Summary:

Parameters:

Name Type Default Value Description
element OptionsElement - The element to speak.

Other

RegisterCustomMenuAsAccessible()### RegisterCustomMenuAsAccessible()

Summary:

Necessary to be called once if you have manually made a custom menu of your mod accessible. This will skip Stardew Access' patch to attempt speaking hovered component i.e., automatic menu accessibility.

Parameters:

Name Type Default Value Description
fullNameOfClass string? - The full name of the menu's class. Example: typeof(MyCustomMenu).FullName

RegisterLanguageHelper()

Summary:

Registers a language helper to be used for a specific locale.

Remarks:

The provided helper class should ideally derive from LanguageHelperBase for optimal compatibility, though this is not strictly required as long as it implements ILanguageHelper.

Parameters:

Name Type Default Value Description
locale string - The locale for which the helper should be used (e.g., "en", "fr", "es-es").
helperType Type - An instance of the language helper class implementing ILanguageHelper.

Legacy

SpeakHoveredInventorySlot()

Summary:

(Legacy! Should not be used from v1.6)

Speaks the hovered inventory slot from the provided InventoryMenu. In case there is nothing in a slot, then it will speak "Empty Slot". Also plays a sound if the slot is grayed out, like tools in geode menu.

Returns:

true if any inventory slot was hovered or found at the hoverX and hoverY.

Parameters:

Name Type Default Value Description
inventoryMenu InventoryMenu - The object of InventoryMenu whose inventory is to be spoken.
giveExtraDetails boolean null (Optional) Whether to speak extra details about the item in slot or not. Default to null in which case it uses DisableInventoryVerbosity config to get whether to speak extra details or not.
hoverPrice int -1 (Optional) The price of the hovered item, generally used in ShopMenu.
extraItemToShowIndex int -1 (Optional) The index (probably parentSheetIndex) of the extra item which is generally a requirement for the hovered item in certain menus.
extraItemToShowAmount int -1 (Optional) The amount or quantity of the extra item which is generally a requirement for the hovered item in certain menus.
highlightedItemPrefix string null (Optional) The prefix to add to the spoken hovered item's details if it is highlighted i.e., not grayed out.
highlightedItemSuffix string null (Optional) The suffix to add to the spoken hovered item's details if it is highlighted i.e., not grayed out.
hoverX int null (Optional) The X position on screen to check. Default to null, in which case it uses the mouse's X position.
hoverY int null (Optional) The Y position on screen to check. Default to null, in which case it uses the mouse's Y position.

GetDetailsOfItem()

Summary:

(Legacy! Should not be used from v1.6)

Get the details (name, description, quality, etc.) of an Item.

Returns:

The details of the given item

Parameters:

Name Type Default Value Description
item Item - The Item's object that we want to get details of.
giveExtraDetails boolean false (Optional)Whether to also return extra details or not. These include: description, health, stamina and other buffs.
price int -1 (Optional) Generally the selling price of the item.
extraItemToShowIndex int -1 (Optional) The index of the extra item which is generally the required item for the given item.
extraItemToShowAmount int -1 (Optional) The amount or quantity of the extra item.