SusShopScreenContent

Панель магазина — балансы, category tabs (SetCategories), список items (SetItems), Buy по selection + CanPurchase.
Пакет
SusGame · Экраны (коммерческий)
Свойства
| Имя | Тип | По умолчанию | |
|---|---|---|---|
Title | Prop<string> | "Shop" | |
SoftBalance | Prop<int> | 0 | |
HardBalance | Prop<int> | 0 | |
CanPurchase | Prop<bool> | true | |
BuyLabel | Prop<string> | "Buy" |
Слоты
Слотов нет.
События
| Имя | Поле | Payload |
|---|---|---|
CategoryChanged | OnCategoryChanged | string |
ItemSelected | OnItemSelected | string |
BuyClicked | OnBuyClicked | — |
Хуки стиля
Контракт USS-классов — внешний вид переопределяется без правки C#. Состояния переключаются этими классами:
breakpoint-mdbreakpoint-smsus-flow-panel--w320sus-flow-panel--w360sus-flow-panel--w380sus-iconsus-scrollsus-shop-screensus-shop-screen__balsus-shop-screen__balancessus-shop-screen__iconsus-shop-screen__itemsus-shop-screen__item--ownedsus-shop-screen__item--selectedsus-shop-screen__itemssus-shop-screen__metasus-shop-screen__namesus-shop-screen__panelsus-shop-screen__pricesus-shop-screen__tabssus-shop-screen__tabs-scrollsus-shop-screen__titlesus-shop-screen__topsus-tabs__tab
Использование
xml
<template>
<sus:SusShopScreenContent
:Title="Title.Value"
:SoftBalance="Soft.Value"
:HardBalance="Hard.Value"
:CanPurchase="CanBuy.Value"
:BuyLabel="Buy.Value"
/>
</template>
<script>
public Prop<string> Title = new("Shop");
public Prop<int> Soft = new(1200);
public Prop<int> Hard = new(40);
public Prop<bool> CanBuy = new(true);
public Prop<string> Buy = new("Buy");
</script>csharp
var shop = new SusShopScreenContent();
shop.Title.Value = "Armory";
shop.SoftBalance.Value = 1200;
shop.HardBalance.Value = 40;
shop.SetCategories(new List<string> { "Weapons", "Cosmetics" }, active: "Weapons");
shop.SetItems(new List<SusShopScreenContent.ShopItem> {
new() { Id = "rifle", Name = "Rifle", Price = 300, Currency = "soft" },
new() { Id = "skin", Name = "Camo", Price = 10, Currency = "hard", DiscountPercent = 20 },
new() { Id = "owned", Name = "Starter kit", Price = 0, Currency = "soft", Owned = true },
});
shop.OnCategoryChanged += cat => { /* reload SetItems */ };
shop.OnItemSelected += id => { /* preview */ };
shop.OnBuyClicked += () => { /* purchase shop.SelectedItemId */ };
shop.BackBtn.OnClick += () => { /* back */ };| Prop / API | Роль |
|---|---|
Title | Чип заголовка |
SoftBalance / HardBalance | Чипы Soft / Hard |
CanPurchase | Открывает Buy, когда item выбран |
BuyLabel | Текст кнопки Buy |
SetCategories(tabs, active?) | Строит элементы SusTabs |
SetItems(List<ShopItem>) | Строки: Id/Name/Icon/Price/Currency/Owned/DiscountPercent |
SelectedItemId | Последний выбранный id (только чтение) |
OnCategoryChanged / OnItemSelected / OnBuyClicked | События хоста |
BackBtn / BuyBtn / EmptyAlert | Построенные хосты |
Заметки
- Пустой список показывает «No items in this category.»; Buy изначально отключён, пока не выбран неприобретённый item.
- Приобретённые строки получают прозрачность
--owned; выбранная строка —--selected. - Присутствует в пине SusGame — вложенный
ShopItemреальный.