К содержимому

SusShopScreenContent

SusShopScreenContent

Панель магазина — балансы, category tabs (SetCategories), список items (SetItems), Buy по selection + CanPurchase.

Пакет

SusGame · Экраны (коммерческий)

Открыть в песочнице

SusGame · Screens

Свойства

ИмяТипПо умолчанию
TitleProp<string>"Shop"
SoftBalanceProp<int>0
HardBalanceProp<int>0
CanPurchaseProp<bool>true
BuyLabelProp<string>"Buy"

Слоты

Слотов нет.

События

ИмяПолеPayload
CategoryChangedOnCategoryChangedstring
ItemSelectedOnItemSelectedstring
BuyClickedOnBuyClicked

Хуки стиля

Контракт USS-классов — внешний вид переопределяется без правки C#. Состояния переключаются этими классами:

  • breakpoint-md
  • breakpoint-sm
  • sus-flow-panel--w320
  • sus-flow-panel--w360
  • sus-flow-panel--w380
  • sus-icon
  • sus-scroll
  • sus-shop-screen
  • sus-shop-screen__bal
  • sus-shop-screen__balances
  • sus-shop-screen__icon
  • sus-shop-screen__item
  • sus-shop-screen__item--owned
  • sus-shop-screen__item--selected
  • sus-shop-screen__items
  • sus-shop-screen__meta
  • sus-shop-screen__name
  • sus-shop-screen__panel
  • sus-shop-screen__price
  • sus-shop-screen__tabs
  • sus-shop-screen__tabs-scroll
  • sus-shop-screen__title
  • sus-shop-screen__top
  • sus-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 реальный.