Terminal: home with three entries (Bank, Poinbase, Web3) plus report; entry icons
Bank shows real credits, rent and deposits/withdrawals; Poinbase is the compliant exchange; Web3 is the wallet and decentralised trading. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ce95ec923d
commit
9441d4d1bd
8 files changed
+211
-23
No files matched your search
@@ -6,13 +6,16 @@ using Decentralized.Domain;
|
||||
|
||||
namespace Decentralized
|
||||
{
|
||||
/// <summary>交易终端窗口:钱包、交易、报告三页。每次操作后按当前页重建窗口。</summary>
|
||||
/// <summary>
|
||||
/// 交易终端窗口:首页三个入口(银行、Poinbase、Web3)加报告。银行是真实的信用点(存取、房租);
|
||||
/// Poinbase 是合规交易所;Web3 是去中心化交易和链上钱包。每次操作后按当前页重建窗口。
|
||||
/// </summary>
|
||||
public static class TerminalWindow
|
||||
{
|
||||
public const string Id = "pd_terminal";
|
||||
private enum Page { Wallet, Trade, Report }
|
||||
private enum Page { Home, Bank, Poinbase, Web3, Report }
|
||||
|
||||
private static Page _page = Page.Wallet;
|
||||
private static Page _page = Page.Home;
|
||||
private static string _amount = "";
|
||||
private static string _message;
|
||||
|
||||
@@ -21,7 +24,7 @@ namespace Decentralized
|
||||
if (Session.Data == null) return;
|
||||
var b = CustomUIManager.Window(Id, L.T("term.title"));
|
||||
if (b == null) return;
|
||||
b.SetSize(620, 560).SetDraggable(true).SetCloseOnEscape(true).UseMachineryStyle();
|
||||
b.SetSize(640, 580).SetDraggable(true).SetCloseOnEscape(true).UseMachineryStyle();
|
||||
b.BeginRow();
|
||||
foreach (Page p in Enum.GetValues(typeof(Page)))
|
||||
{
|
||||
@@ -31,11 +34,13 @@ namespace Decentralized
|
||||
}
|
||||
b.End();
|
||||
b.AddSeparator();
|
||||
b.BeginScroll(440);
|
||||
b.BeginScroll(450);
|
||||
switch (_page)
|
||||
{
|
||||
case Page.Wallet: WalletPage(b); break;
|
||||
case Page.Trade: TradePage(b); break;
|
||||
case Page.Home: HomePage(b); break;
|
||||
case Page.Bank: BankPage(b); break;
|
||||
case Page.Poinbase: ExchangePage(b, Venue.Exchange); break;
|
||||
case Page.Web3: Web3Page(b); break;
|
||||
default: ReportPage(b); break;
|
||||
}
|
||||
b.End();
|
||||
@@ -43,32 +48,67 @@ namespace Decentralized
|
||||
b.Show();
|
||||
}
|
||||
|
||||
private static void WalletPage(CustomUIBuilder b)
|
||||
private static void Go(Page p) { _page = p; _message = null; Open(); }
|
||||
|
||||
private static void Entry(CustomUIBuilder b, string icon, string name, string line1, string line2, Page target)
|
||||
{
|
||||
var w = Session.Data.Hot;
|
||||
if (w.Balances.Count == 0) b.AddLabel(L.T("wallet.empty"));
|
||||
foreach (var kv in w.Balances.OrderBy(k => k.Key))
|
||||
b.AddLabel(L.T("wallet.line", kv.Key, Fmt.Num(kv.Value), Fmt.Credits(kv.Value * Session.Price(kv.Key))));
|
||||
b.AddSeparator();
|
||||
b.AddLabel(L.T("wallet.total", Fmt.Credits(w.Value(Session.Price))));
|
||||
if (w.Taint > 0.5) b.AddLabel(L.T("wallet.taint", Fmt.Credits(w.Taint)));
|
||||
b.BeginPanel(190f, 250f, TextAnchor.UpperCenter, 10f, 6f);
|
||||
b.AddImage(ModInfo.Id + ":" + icon, 96f, 96f);
|
||||
b.AddHeader(name);
|
||||
b.AddLabel(line1);
|
||||
b.AddLabel(line2);
|
||||
b.AddFlexibleSpace();
|
||||
b.AddButton(L.T("home.enter"), () => Go(target));
|
||||
b.End();
|
||||
}
|
||||
|
||||
private static void TradePage(CustomUIBuilder b)
|
||||
private static void HomePage(CustomUIBuilder b)
|
||||
{
|
||||
var d = Session.Data;
|
||||
double chain = d.Hot.Value(Session.Price);
|
||||
b.AddLabel(L.T("home.summary", PlayerStore.Instance.playerCash, Fmt.Credits(chain)));
|
||||
b.AddSpace(6f);
|
||||
b.BeginRow(8f, TextAnchor.UpperCenter);
|
||||
Entry(b, "ui_bank", L.T("entry.bank"), L.T("entry.bank.l1"), L.T("entry.bank.l2", PlayerStore.Instance.playerCash), Page.Bank);
|
||||
Entry(b, "ui_poinbase", L.T("entry.poinbase"), L.T("entry.poinbase.l1"), L.T("entry.poinbase.l2", Fmt.Num(d.Market.Price)), Page.Poinbase);
|
||||
Entry(b, "ui_web3", L.T("entry.web3"), L.T("entry.web3.l1"), L.T("entry.web3.l2", Fmt.Credits(chain)), Page.Web3);
|
||||
b.End();
|
||||
b.AddSpace(8f);
|
||||
b.AddSeparator();
|
||||
var r = d.LastNight;
|
||||
b.AddLabel(r == null ? L.T("report.none") : L.T("home.lastnight", r.Day, Fmt.Num(r.Mined), r.PoweredRigs, r.Rigs));
|
||||
}
|
||||
|
||||
private static void AmountRow(CustomUIBuilder b)
|
||||
{
|
||||
b.AddLabel(L.T("trade.hint"));
|
||||
b.BeginRow();
|
||||
b.AddLabel(L.T("trade.amount"));
|
||||
b.BeginPanel(240f, -1f, TextAnchor.MiddleCenter, 0f, 0f); // 给输入框一个固定宽度,容得下大额数字
|
||||
b.AddInput("0", _amount, s => _amount = s, "amount", s => _amount = s);
|
||||
b.End();
|
||||
b.End();
|
||||
}
|
||||
|
||||
/// <summary>银行:真实的信用点。现金、房租,以及信用点与 Poinbase 账户(CRC)之间的存取。</summary>
|
||||
private static void BankPage(CustomUIBuilder b)
|
||||
{
|
||||
var ps = PlayerStore.Instance;
|
||||
b.AddHeader(L.T("entry.bank"));
|
||||
b.AddLabel(L.T("bank.cash", ps.playerCash));
|
||||
b.AddLabel(L.T("bank.rent", Session.Rent(), ps.GetRentDayCounter()));
|
||||
b.AddLabel(L.T("bank.crc", Fmt.Num(Session.Data.Hot.Get(Assets.CRC))));
|
||||
b.AddSeparator();
|
||||
b.AddLabel(L.T("bank.hint"));
|
||||
AmountRow(b);
|
||||
b.BeginRow();
|
||||
b.AddButton(L.T("trade.deposit"), Deposit);
|
||||
b.AddButton(L.T("trade.withdraw"), Withdraw);
|
||||
b.End();
|
||||
b.AddSeparator();
|
||||
foreach (var pool in Session.Data.Market.Pools)
|
||||
}
|
||||
|
||||
private static void TradeRows(CustomUIBuilder b, Venue venue)
|
||||
{
|
||||
foreach (var pool in Session.Data.Market.Pools.Where(x => x.Venue == venue))
|
||||
{
|
||||
var p = pool;
|
||||
b.AddLabel(L.T("trade.pair", p.Base, p.Quote, L.T("venue." + p.Venue)) + " " + L.T("trade.price", Fmt.Num(p.Price)));
|
||||
@@ -79,6 +119,35 @@ namespace Decentralized
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Poinbase:合规交易所。账户余额与交易对;信用点的存取在银行。</summary>
|
||||
private static void ExchangePage(CustomUIBuilder b, Venue venue)
|
||||
{
|
||||
var w = Session.Data.Hot;
|
||||
b.AddHeader(L.T("entry.poinbase"));
|
||||
b.AddLabel(L.T("poin.account", Fmt.Num(w.Get(Assets.CRC)), Fmt.Num(w.Get(Assets.PSC))));
|
||||
b.AddLabel(L.T("trade.hint"));
|
||||
AmountRow(b);
|
||||
b.AddSeparator();
|
||||
TradeRows(b, venue);
|
||||
}
|
||||
|
||||
/// <summary>Web3:链上钱包与去中心化交易。</summary>
|
||||
private static void Web3Page(CustomUIBuilder b)
|
||||
{
|
||||
var w = Session.Data.Hot;
|
||||
b.AddHeader(L.T("entry.web3"));
|
||||
if (w.Balances.Count == 0) b.AddLabel(L.T("wallet.empty"));
|
||||
foreach (var kv in w.Balances.OrderBy(k => k.Key))
|
||||
b.AddLabel(L.T("wallet.line", kv.Key, Fmt.Num(kv.Value), Fmt.Credits(kv.Value * Session.Price(kv.Key))));
|
||||
b.AddLabel(L.T("wallet.total", Fmt.Credits(w.Value(Session.Price))));
|
||||
if (w.Taint > 0.5) b.AddLabel(L.T("wallet.taint", Fmt.Credits(w.Taint)));
|
||||
b.AddSeparator();
|
||||
b.AddLabel(L.T("trade.hint"));
|
||||
AmountRow(b);
|
||||
b.AddSeparator();
|
||||
TradeRows(b, Venue.Dex);
|
||||
}
|
||||
|
||||
private static void ReportPage(CustomUIBuilder b)
|
||||
{
|
||||
var r = Session.Data.LastNight;
|
||||
|
||||
Reference in new issue
Block a user