跳转到内容

SusShopScreenContent

SusShopScreenContent

商店面板 — 余额、分类标签页(SetCategories)、物品列表(SetItems)、Buy 由选中项 + CanPurchase 门控。

SusGame · 屏幕(商业)

在 Playground 中打开

SusGame · Screens

属性

名称类型默认值
TitleProp<string>"Shop"
SoftBalanceProp<int>0
HardBalanceProp<int>0
CanPurchaseProp<bool>true
BuyLabelProp<string>"Buy"

插槽

没有插槽。

事件

名称字段载荷
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 / APIRole
Title头部芯片
SoftBalance / HardBalanceSoft / Hard 芯片
CanPurchase选中某个物品时门控 Buy
BuyLabelBuy 按钮文本
SetCategories(tabs, active?)构建 SusTabs items
SetItems(List<ShopItem>)行:Id/Name/Icon/Price/Currency/Owned/DiscountPercent
SelectedItemId最近选中的 id(只读)
OnCategoryChanged / OnItemSelected / OnBuyClicked宿主事件
BackBtn / BuyBtn / EmptyAlert内置宿主

备注

  • 空列表显示「No items in this category.」;在选中非已拥有物品之前 Buy 保持禁用。
  • 已拥有的行获得 --owned 透明度;选中获得 --selected
  • 存在于 SusGame pin 中 — 嵌套的 ShopItem 是真实的。