ui: skin black market buy, sell, orders and pay pages

This commit is contained in:
ZHU MINCHAO committed 2026-11-04 10:10:34 +08:00
1 parent 96be937daa
commit 66a8f6e903
1 file changed
+42 -33
+42 -33
View File
@@ -1166,17 +1166,17 @@ namespace Decentralized
int rep = StoreReputation.GetBMReputation(); int rep = StoreReputation.GetBMReputation();
int day = StoreStation.GetDayCounter(); int day = StoreStation.GetDayCounter();
var d = Session.Data; var d = Session.Data;
if (Night.ActiveEvents().Contains(MarketEvent.Crackdown)) { b.AddLabel(L.T("black.offline")); return; } if (Night.ActiveEvents().Contains(MarketEvent.Crackdown)) { b.AddLabel(L.T("black.offline"), "black_offline_note"); return; }
if (!BlackMarket.Open(rep)) { b.AddLabel(L.T("black.closed", Tuning.BmOpenRep, rep)); return; } if (!BlackMarket.Open(rep)) { b.AddLabel(L.T("black.closed", Tuning.BmOpenRep, rep), "black_closed_note"); return; }
b.BeginRow(); b.BeginRow(4f);
foreach (BlackTab t in Enum.GetValues(typeof(BlackTab))) foreach (BlackTab t in Enum.GetValues(typeof(BlackTab)))
{ {
var tab = t; var tab = t;
string name = L.T("black.sub." + t.ToString().ToLowerInvariant()); string name = L.T("black.sub." + t.ToString().ToLowerInvariant());
b.AddButton(tab == _blackTab ? $"[{name}]" : name, () => { _blackTab = tab; _message = null; _edit = null; Open(); }); PledgerSkin.Pick(b, name, tab == _blackTab, () => { _blackTab = tab; _message = null; _edit = null; Open(); }, _picked);
} }
b.End(); b.End();
if (d.Black.Closed(day)) { b.AddLabel(L.T("black.rugged", d.Black.ClosedUntil - day + 1)); return; } if (d.Black.Closed(day)) { b.AddLabel(L.T("black.rugged", d.Black.ClosedUntil - day + 1), "black_rugged_note"); return; }
if (_edit != null) { EditPage(b); return; } if (_edit != null) { EditPage(b); return; }
if (_blackTab == BlackTab.Orders) { OrdersPage(b, day); return; } if (_blackTab == BlackTab.Orders) { OrdersPage(b, day); return; }
if (_blackTab == BlackTab.Sell) { SellPage(b, day); return; } if (_blackTab == BlackTab.Sell) { SellPage(b, day); return; }
@@ -1191,36 +1191,36 @@ namespace Decentralized
if (_merchant >= sellers.Count) _merchant = -1; if (_merchant >= sellers.Count) _merchant = -1;
bool platform = _merchant < 0; bool platform = _merchant < 0;
b.AddLabel(L.T("black.rep", rep, BlackMarket.MaxLevel(rep)) + " " + L.T("mixer.balance", _payAsset, Fmt.Num(w.Avail(_payAsset))) + (w.Taint > 0.5 ? " " + L.T("wallet.taint", Fmt.Credits(w.Taint)) : "")); b.AddLabel(L.T("black.rep", rep, BlackMarket.MaxLevel(rep)) + " " + L.T("mixer.balance", _payAsset, Fmt.Num(w.Avail(_payAsset))) + (w.Taint > 0.5 ? " " + L.T("wallet.taint", Fmt.Credits(w.Taint)) : ""));
b.BeginRow(); b.BeginRow(4f);
foreach (var a in new[] { Assets.PSC, Assets.CRT, Assets.CRA, Assets.Ponero }) foreach (var a in new[] { Assets.PSC, Assets.CRT, Assets.CRA, Assets.Ponero })
{ {
var asset = a; var asset = a;
b.AddButton(asset == _payAsset ? $"[{asset}]" : asset, () => { _payAsset = asset; Open(); }); PledgerSkin.Pick(b, asset, asset == _payAsset, () => { _payAsset = asset; Open(); }, _picked);
} }
if (!platform) if (!platform)
foreach (PayMode m in Enum.GetValues(typeof(PayMode))) foreach (PayMode m in Enum.GetValues(typeof(PayMode)))
{ {
var mode = m; var mode = m;
string n = L.T("black.mode." + m); string n = L.T("black.mode." + m);
b.AddButton(mode == _mode ? $"[{n}]" : n, () => { _mode = mode; Open(); }); PledgerSkin.Pick(b, n, mode == _mode, () => { _mode = mode; Open(); }, _picked);
} }
b.End(); b.End();
b.BeginRow(); b.BeginRow(4f);
foreach (var m in Qtys) foreach (var m in Qtys)
{ {
int q = m; int q = m;
b.AddButton(q == _qty ? $"[×{q}]" : "×" + q, () => { _qty = q; Open(); }); PledgerSkin.Pick(b, "×" + q, q == _qty, () => { _qty = q; Open(); }, _picked);
} }
b.End(); b.End();
var all = new System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<int, string>> { new System.Collections.Generic.KeyValuePair<int, string>(-1, "[" + L.T("merchant.Platform") + "] " + d.Address("platform")) }; var all = new System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<int, string>> { new System.Collections.Generic.KeyValuePair<int, string>(-1, L.T("merchant.Platform") + " " + d.Address("platform")) };
for (int k = 0; k < sellers.Count; k++) all.Add(new System.Collections.Generic.KeyValuePair<int, string>(k, MerchantLabel(sellers[k]))); for (int k = 0; k < sellers.Count; k++) all.Add(new System.Collections.Generic.KeyValuePair<int, string>(k, MerchantLabel(sellers[k])));
for (int i = 0; i < all.Count; i += 3) for (int i = 0; i < all.Count; i += 3)
{ {
b.BeginRow(); b.BeginRow(4f);
for (int k = i; k < Math.Min(all.Count, i + 3); k++) for (int k = i; k < Math.Min(all.Count, i + 3); k++)
{ {
int idx = all[k].Key; string n = all[k].Value; int idx = all[k].Key; string n = all[k].Value;
b.AddButton(idx == _merchant ? "> " + n : n, () => { _merchant = idx; Open(); }); PledgerSkin.Pick(b, n, idx == _merchant, () => { _merchant = idx; Open(); }, _picked);
} }
b.End(); b.End();
} }
@@ -1229,15 +1229,15 @@ namespace Decentralized
else MerchantShelf(b, d); else MerchantShelf(b, d);
b.AddSeparator(); b.AddSeparator();
b.AddHeader(L.T("black.forum.h")); b.AddHeader(L.T("black.forum.h"));
if (d.Black.Forum.Count == 0) b.AddLabel(L.T("black.forum.quiet")); if (d.Black.Forum.Count == 0) b.AddLabel(L.T("black.forum.quiet"), "forum_quiet_dim");
foreach (var f in d.Black.Forum) foreach (var f in d.Black.Forum)
b.AddLabel(f.StartsWith("phish:") ? L.T("black.forum.phish", f.Substring(6)) : f.StartsWith("scam:") ? L.T("black.forum.scam", BlackDelivery.DisplayName(f.Substring(5))) : f.StartsWith("busted:") ? L.T("black.forum.busted", f.Substring(7)) : L.T("black.forum." + f)); b.AddLabel(f.StartsWith("phish:") ? L.T("black.forum.phish", f.Substring(6)) : f.StartsWith("scam:") ? L.T("black.forum.scam", BlackDelivery.DisplayName(f.Substring(5))) : f.StartsWith("busted:") ? L.T("black.forum.busted", f.Substring(7)) : L.T("black.forum." + f), "forum_dim");
} }
private static void PlatformShelf(CustomUIBuilder b, SaveData d) private static void PlatformShelf(CustomUIBuilder b, SaveData d)
{ {
b.AddLabel(L.T("black.platform.line", d.Address("platform"))); b.AddLabel(L.T("black.platform.line", d.Address("platform")), "platform_line_dim");
if (d.Black.Offers.Count == 0) { b.AddLabel(L.T("black.empty")); return; } if (d.Black.Offers.Count == 0) { b.AddLabel(L.T("black.empty"), "platform_empty_dim"); return; }
Shelf(b, d.Black.Offers.Cast<BmGood>().ToList(), (c, g) => Shelf(b, d.Black.Offers.Cast<BmGood>().ToList(), (c, g) =>
{ {
var offer = (BmOffer)g; var offer = (BmOffer)g;
@@ -1256,12 +1256,12 @@ namespace Decentralized
private static void SellPage(CustomUIBuilder b, int day) private static void SellPage(CustomUIBuilder b, int day)
{ {
var d = Session.Data; var d = Session.Data;
b.BeginRow(); b.BeginRow(4f);
foreach (var m in SellMults) foreach (var m in SellMults)
{ {
double mult = m; double mult = m;
string n = m.ToString("0.0", CultureInfo.InvariantCulture); string n = m.ToString("0.0", CultureInfo.InvariantCulture);
b.AddButton(Math.Abs(mult - _sellMult) < 1e-9 ? $"[×{n}]" : "×" + n, () => { _sellMult = mult; Open(); }); PledgerSkin.Pick(b, "×" + n, Math.Abs(mult - _sellMult) < 1e-9, () => { _sellMult = mult; Open(); }, _picked);
} }
b.End(); b.End();
b.AddLabel(L.T("mixer.balance", _payAsset, Fmt.Num(d.Hot.Avail(_payAsset))) + " " + L.T("black.sell.rating", d.Black.Rating) + " " + L.T("black.sell.slots", d.Black.ActiveListings, Tuning.BmMaxListings)); b.AddLabel(L.T("mixer.balance", _payAsset, Fmt.Num(d.Hot.Avail(_payAsset))) + " " + L.T("black.sell.rating", d.Black.Rating) + " " + L.T("black.sell.slots", d.Black.ActiveListings, Tuning.BmMaxListings));
@@ -1272,7 +1272,7 @@ namespace Decentralized
}); });
b.AddSeparator(); b.AddSeparator();
var items = BlackDelivery.Sellable(); var items = BlackDelivery.Sellable();
if (items.Count == 0) { b.AddLabel(L.T("black.sell.none")); return; } if (items.Count == 0) { b.AddLabel(L.T("black.sell.none"), "sell_none_dim"); return; }
Shelf(b, items.Select(it => Shelf(b, items.Select(it =>
{ {
string id = BlackDelivery.SellId(it); string id = BlackDelivery.SellId(it);
@@ -1326,7 +1326,7 @@ namespace Decentralized
Open(); Open();
} }
private static string MerchantLabel(BmSeller s) => "[" + L.T("merchant." + s.Type) + "] " + s.Name; private static string MerchantLabel(BmSeller s) => L.T("merchant." + s.Type) + " " + s.Name;
private static int _merchant = -1; private static int _merchant = -1;
private static int _qty = 1; private static int _qty = 1;
@@ -1339,7 +1339,7 @@ namespace Decentralized
var seller = sellers[_merchant]; var seller = sellers[_merchant];
b.AddLabel(L.T("black.seller", MerchantLabel(seller), seller.Trades, seller.Rating) + " " + L.T("black.days", seller.Days)); b.AddLabel(L.T("black.seller", MerchantLabel(seller), seller.Trades, seller.Rating) + " " + L.T("black.days", seller.Days));
var goods = d.Black.Catalog.Where(l => l.Seller == _merchant).Cast<BmGood>().ToList(); var goods = d.Black.Catalog.Where(l => l.Seller == _merchant).Cast<BmGood>().ToList();
if (goods.Count == 0) { b.AddLabel(L.T("black.empty")); return; } if (goods.Count == 0) { b.AddLabel(L.T("black.empty"), "shelf_empty_dim"); return; }
Shelf(b, goods, (c, g) => Shelf(b, goods, (c, g) =>
{ {
var listing = (BmListing)g; var listing = (BmListing)g;
@@ -1370,6 +1370,11 @@ namespace Decentralized
{ {
var g = goods[k]; var g = goods[k];
b.BeginPanel(CardW, CardH, TextAnchor.UpperCenter, 6f, 3f); b.BeginPanel(CardW, CardH, TextAnchor.UpperCenter, 6f, 3f);
if (b.Last != null && b.Last.image != null)
{
b.Last.image.sprite = MachineryStyle.White;
b.Last.image.color = PledgerSkin.RowNormal;
}
card(b, g); card(b, g);
b.End(); b.End();
} }
@@ -1383,8 +1388,8 @@ namespace Decentralized
if (sprite != null) c.AddImage(sprite, 64f, 64f); else c.AddSpace(64f); if (sprite != null) c.AddImage(sprite, 64f, 64f); else c.AddSpace(64f);
c.AddLabel("<b>" + ItemName(g.Item) + "</b>"); c.AddLabel("<b>" + ItemName(g.Item) + "</b>");
bool asic = g.Kind == GoodKind.Gpu && g.Model != null && Hardware.Specs.TryGetValue(g.Model, out var gs) && gs.Asic; bool asic = g.Kind == GoodKind.Gpu && g.Model != null && Hardware.Specs.TryGetValue(g.Model, out var gs) && gs.Asic;
c.AddLabel(asic ? (g.Health >= 100 ? L.T("black.kind.asicnew") : L.T("black.kind.asic", (int)Math.Round(g.Health))) : g.Kind == GoodKind.Gpu ? (g.Health >= 100 ? L.T("black.kind.gpunew") : L.T("black.kind.gpu", (int)Math.Round(g.Health))) : L.T("black.kind." + g.Kind + (g.Kind == GoodKind.Contraband ? "." + g.Level : ""))); c.AddLabel(asic ? (g.Health >= 100 ? L.T("black.kind.asicnew") : L.T("black.kind.asic", (int)Math.Round(g.Health))) : g.Kind == GoodKind.Gpu ? (g.Health >= 100 ? L.T("black.kind.gpunew") : L.T("black.kind.gpu", (int)Math.Round(g.Health))) : L.T("black.kind." + g.Kind + (g.Kind == GoodKind.Contraband ? "." + g.Level : "")), "good_kind_dim");
if (!string.IsNullOrEmpty(line2)) c.AddLabel(line2); if (!string.IsNullOrEmpty(line2)) c.AddLabel(line2, "good_line2_dim");
} }
private static string ItemName(string id) => BlackDelivery.ItemName(id); private static string ItemName(string id) => BlackDelivery.ItemName(id);
@@ -1407,11 +1412,11 @@ namespace Decentralized
b.AddHeader(L.T("black.pay.confirm")); b.AddHeader(L.T("black.pay.confirm"));
b.AddLabel(p.Summary); b.AddLabel(p.Summary);
b.BeginRow(8f, TextAnchor.MiddleLeft); b.BeginRow(8f, TextAnchor.MiddleLeft);
b.AddLabel(L.T("black.pay.to", p.Address)); b.AddLabel(L.T("black.pay.to", p.Address), "pay_to_dim");
b.AddButton(L.T("hw.copy"), () => { Clipboard.Copy(p.Address); _message = L.T("hw.copied.addr", p.Address); Open(); }); b.AddButton(L.T("hw.copy"), () => { Clipboard.Copy(p.Address); _message = L.T("hw.copied.addr", p.Address); Open(); });
b.End(); b.End();
b.AddLabel(L.T("black.pay.amount", WalletWindow.Amt(p.Amount), p.Asset, Fmt.Credits(p.Amount * Session.Price(p.Asset)))); b.AddLabel(L.T("black.pay.amount", WalletWindow.Amt(p.Amount), p.Asset, Fmt.Credits(p.Amount * Session.Price(p.Asset))));
b.BeginRow(); b.BeginRow(6f);
b.AddButton(L.T("black.pay.wallet"), () => WalletWindow.OpenForBill(p)); b.AddButton(L.T("black.pay.wallet"), () => WalletWindow.OpenForBill(p));
b.AddButton(L.T("black.pay.cancel"), () => { WalletWindow.Pending = null; _message = null; Open(); }); b.AddButton(L.T("black.pay.cancel"), () => { WalletWindow.Pending = null; _message = null; Open(); });
b.End(); b.End();
@@ -1461,20 +1466,24 @@ namespace Decentralized
{ {
var e = _edit; var e = _edit;
b.AddHeader(ItemName(e.Id)); b.AddHeader(ItemName(e.Id));
b.AddLabel(L.T("black.edit.ref", e.Ref)); b.AddLabel(L.T("black.edit.ref", e.Ref), "edit_ref_dim");
b.BeginPanel(RightW, -1f, TextAnchor.MiddleCenter, 0f, 0f); b.BeginPanel(RightW, -1f, TextAnchor.MiddleCenter, 0f, 0f);
if (b.Last != null && b.Last.image != null) _clear.Add(b.Last.image);
b.AddInput(L.T("black.edit.input"), _editPrice, s => _editPrice = s, "price", s => _editPrice = s); b.AddInput(L.T("black.edit.input"), _editPrice, s => _editPrice = s, "price", s => _editPrice = s);
b.End(); b.End();
b.BeginRow(); b.BeginRow(4f);
foreach (var m in SellMults) foreach (var m in SellMults)
{ {
double mult = m; double mult = m;
b.AddButton("×" + m.ToString("0.0", CultureInfo.InvariantCulture), () => { _editPrice = BlackMarket.ListPriceOf(e.Ref, mult).ToString(CultureInfo.InvariantCulture); Open(); }); string label = "×" + m.ToString("0.0", CultureInfo.InvariantCulture);
int targetPrice = BlackMarket.ListPriceOf(e.Ref, mult);
bool sel = int.TryParse((_editPrice ?? "").Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int curP) && curP == targetPrice;
PledgerSkin.Pick(b, label, sel, () => { _editPrice = targetPrice.ToString(CultureInfo.InvariantCulture); Open(); }, _picked);
} }
b.End(); b.End();
if (int.TryParse((_editPrice ?? "").Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int p) && p > 0) if (int.TryParse((_editPrice ?? "").Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int p) && p > 0)
b.AddLabel(L.T("black.edit.price", p, (p / (double)e.Ref).ToString("0.00", CultureInfo.InvariantCulture))); b.AddLabel(L.T("black.edit.price", p, (p / (double)e.Ref).ToString("0.00", CultureInfo.InvariantCulture)));
b.BeginRow(); b.BeginRow(6f);
b.AddButton(L.T("black.edit.ok"), () => b.AddButton(L.T("black.edit.ok"), () =>
{ {
if (!int.TryParse((_editPrice ?? "").Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int price) || price < MinPrice(e.Ref) || price > MaxPrice(e.Ref)) if (!int.TryParse((_editPrice ?? "").Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out int price) || price < MinPrice(e.Ref) || price > MaxPrice(e.Ref))
@@ -1514,12 +1523,12 @@ namespace Decentralized
{ {
var d = Session.Data; var d = Session.Data;
b.AddHeader(L.T("black.orders.in")); b.AddHeader(L.T("black.orders.in"));
if (d.Black.Orders.Count == 0) b.AddLabel(L.T("black.mine.none")); if (d.Black.Orders.Count == 0) b.AddLabel(L.T("black.mine.none"), "orders_in_none_dim");
foreach (var o in d.Black.Orders.OrderByDescending(x => x.PlacedDay)) foreach (var o in d.Black.Orders.OrderByDescending(x => x.PlacedDay))
b.AddLabel(L.T("black.mine.line", ItemName(o.Item) + (o.Count > 1 ? " ×" + o.Count : ""), BlackDelivery.DisplayName(o.Seller), L.T("black.mode." + o.Mode), L.T("black.state." + o.State + (o.Why != null && o.State != OrderState.Done ? "." + o.Why : "")), o.DueDay)); b.AddLabel(L.T("black.mine.line", ItemName(o.Item) + (o.Count > 1 ? " ×" + o.Count : ""), BlackDelivery.DisplayName(o.Seller), L.T("black.mode." + o.Mode), L.T("black.state." + o.State + (o.Why != null && o.State != OrderState.Done ? "." + o.Why : "")), o.DueDay));
b.AddSeparator(); b.AddSeparator();
b.AddHeader(L.T("black.orders.out")); b.AddHeader(L.T("black.orders.out"));
if (d.Black.Sales.Count == 0) b.AddLabel(L.T("black.mine.none")); if (d.Black.Sales.Count == 0) b.AddLabel(L.T("black.mine.none"), "orders_out_none_dim");
foreach (var sl in d.Black.Sales.Where(x => x.State != SaleState.Delisted || x.Why == "fake").OrderByDescending(x => x.ListedDay)) foreach (var sl in d.Black.Sales.Where(x => x.State != SaleState.Delisted || x.Why == "fake").OrderByDescending(x => x.ListedDay))
{ {
var sale = sl; var sale = sl;
@@ -1527,7 +1536,7 @@ namespace Decentralized
b.AddLabel(L.T("black.mine.sale", ItemName(sale.Item), sale.Ref, sale.ListPrice, sale.Mult.ToString("0.00", CultureInfo.InvariantCulture), st)); b.AddLabel(L.T("black.mine.sale", ItemName(sale.Item), sale.Ref, sale.ListPrice, sale.Mult.ToString("0.00", CultureInfo.InvariantCulture), st));
if (sale.State == SaleState.Listed) if (sale.State == SaleState.Listed)
{ {
b.BeginRow(); b.BeginRow(6f);
b.AddButton(L.T("black.sell.reprice"), () => BeginEdit(new EditPrice { Sale = sale, Id = sale.Item, Ref = sale.Ref }, sale.ListPrice)); b.AddButton(L.T("black.sell.reprice"), () => BeginEdit(new EditPrice { Sale = sale, Id = sale.Item, Ref = sale.Ref }, sale.ListPrice));
b.AddButton(L.T("black.sell.delist"), () => Delist(sale)); b.AddButton(L.T("black.sell.delist"), () => Delist(sale));
b.End(); b.End();