### StardewUI Quick Start: ModEntry, MenuData, and ScrollingItemGrid.sml Source: https://focustense.github.io/StardewUI The C# files define the mod entry point and menu data for a StardewUI example. ModEntry registers views and creates a menu on F8; MenuData provides a list of edible items. The XML defines the menu layout with a banner, frame, scrollable grid, and repeating images. ```csharp internal sealed class ModEntry : Mod { private IViewEngine viewEngine; public override void Entry(IModHelper helper) { helper.Events.GameLoop.GameLaunched += GameLoop_GameLaunched; helper.Events.Input.ButtonPressed += Input_ButtonPressed; } private void GameLoop_GameLaunched(object? sender, GameLaunchedEventArgs e) { viewEngine = Helper.ModRegistry.GetApi("focustense.StardewUI"); viewEngine.RegisterViews("Mods/TestMod/Views", "assets/views"); viewEngine.EnableHotReloading(); } private void Input_ButtonPressed(object? sender, ButtonPressedEventArgs e) { if (Context.IsPlayerFree && e.Button == SButton.F8) { var context = MenuData.Edibles(); Game1.activeClickableMenu = viewEngine.CreateMenuFromAsset( "Mods/TestMod/Views/ScrollingItemGrid", context); } } } ``` ```csharp public class MenuData { public string HeaderText { get; set; } = ""; public List Items { get; set; } = []; public static MenuData Edibles() { int[] edibleCategories = [ StardewValley.Object.CookingCategory, StardewValley.Object.EggCategory, StardewValley.Object.FishCategory, StardewValley.Object.FruitsCategory, StardewValley.Object.meatCategory, StardewValley.Object.MilkCategory, StardewValley.Object.VegetableCategory, ]; var items = ItemRegistry.ItemTypes .Single(type => type.Identifier == ItemRegistry.type_object) .GetAllIds() .Select(id => ItemRegistry.GetDataOrErrorItem(id)) .Where(data => edibleCategories.Contains(data.Category)) .ToList(); return new() { HeaderText = "All Edibles", Items = items, }; } } ``` ```xml ``` -------------------------------- ### Start(V, V, TimeSpan?) Method Source: https://focustense.github.io/StardewUI/reference/stardewui/animation/animator-2 Method to start an animation with explicit start and end values. ```APIDOC ## Start(V, V, TimeSpan?) Method ### Description Starts a new animation using the specified start/end values and duration. ### Signature ```csharp public void Start(V startValue, V endValue, System.TimeSpan? duration); ``` ### Parameters - **startValue** (V) - Required - The initial value of the animation property. This will take effect immediately, even if it is far away from the current value; i.e. it may cause "jumps". - **endValue** (V) - Required - The final value to be reached once the duration ends. - **duration** (Nullable) - Optional - Duration of the animation; defaults to 1 second if not specified. ``` -------------------------------- ### Minimal Example: ViewModels Source: https://focustense.github.io/StardewUI/framework/included-views View models for the minimal example. OuterViewModel contains an InnerViewModel property, and InnerViewModel has a Text property. ```csharp public class OuterViewModel { public InnerViewModel Inner { get; set; } } public class InnerViewModel { public string Text { get; set; } } ``` -------------------------------- ### StarML basic frame example Source: https://focustense.github.io/StardewUI/framework/starml A basic StarML frame that demonstrates layout, data binding, and event handling. Use it as a starting point for UI screens: the frame sets a fixed size, background, border, and border thickness, while the lane stacks a label, a bound label, a text input bound to FarmerName, an image, and a button that invokes LaunchCoolFeature("now") on click. ```markup