终端页签重组:挖矿提到一级,混币器和商店并入灰网,浏览器进钱包页,连接钱包挪到顶栏
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dada962fe6
commit
264252881c
10 files changed
+147
-106
No files matched your search
@@ -29,7 +29,7 @@ namespace Decentralized
|
||||
private static float F => Mathf.Clamp(1f + Ext * 0.00065f, 1f, 1.3f);
|
||||
public static float ChartScale => LeftW >= 634f ? 3f : 2f;
|
||||
private static float[] Sc(float[] b) { float k = LeftW / 420f; return b.Select(x => x * k).ToArray(); }
|
||||
private enum Page { Home, Bank, Poinbase, Web3, Wallets }
|
||||
private enum Page { Home, Bank, Poinbase, Web3, Mining, Gray, Wallets }
|
||||
|
||||
private static Page _page = Page.Home;
|
||||
private sealed class EditPrice { public GameItem Item; public BmSale Sale; public string Id; public long Ref; }
|
||||
@@ -55,23 +55,25 @@ namespace Decentralized
|
||||
b.BeginPanel(ScreenW, ScreenH, TextAnchor.UpperLeft, 12f, 4f);
|
||||
var screen = b.CurrentContainer;
|
||||
var paper = b.Last.image;
|
||||
b.BeginRow(4f, TextAnchor.MiddleLeft);
|
||||
foreach (Page p in Enum.GetValues(typeof(Page)))
|
||||
if (_page == Page.Gray && !GrayAvailable) _page = Page.Web3;
|
||||
TabRows(b, Enum.GetValues(typeof(Page)).Cast<Page>().Where(p => p != Page.Gray || GrayAvailable).Select(p =>
|
||||
{
|
||||
var page = p;
|
||||
string name = L.T("tab." + p.ToString().ToLowerInvariant());
|
||||
PledgerSkin.Pick(b, name, page == _page, () => { _page = page; _message = null; _edit = null; Open(); }, _picked);
|
||||
}
|
||||
b.End();
|
||||
return new TabDef { Name = L.T("tab." + p.ToString().ToLowerInvariant()), On = page == _page, Click = () => { _page = page; _message = null; _edit = null; Open(); } };
|
||||
}).ToList(), true);
|
||||
ConnectPicker(b);
|
||||
b.AddSeparator();
|
||||
b.BeginScroll(ScreenH - 52f);
|
||||
_clear.Add(b.Last.image);
|
||||
switch (_page)
|
||||
if ((_page == Page.Web3 || _page == Page.Gray) && WalletWindow.Pending != null && !WalletWindow.Pending.Contract) PayPage(b);
|
||||
else switch (_page)
|
||||
{
|
||||
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;
|
||||
case Page.Mining: ReportPage(b); break;
|
||||
case Page.Gray: GrayPage(b); break;
|
||||
case Page.Wallets: WalletsPage(b); break;
|
||||
default: break;
|
||||
}
|
||||
@@ -1146,9 +1148,14 @@ namespace Decentralized
|
||||
|
||||
/// <summary>Poinbase 提到当前钱包:托管账户直接转,不用签名。污点按比例随币走。</summary>
|
||||
/// <summary>钱包页:全部硬件钱包,连接(设为当前)、打开实体钱包。</summary>
|
||||
private enum WalletTab { List, Explorer }
|
||||
private static WalletTab _walletTab = WalletTab.List;
|
||||
|
||||
private static void WalletsPage(CustomUIBuilder b)
|
||||
{
|
||||
var d = Session.Data;
|
||||
TabRows(b, Enum.GetValues(typeof(WalletTab)).Cast<WalletTab>().Select(t => { var tab = t; return new TabDef { Name = L.T("wallets.sub." + t.ToString().ToLowerInvariant()), On = tab == _walletTab, Click = () => { _walletTab = tab; _message = null; _edit = null; Open(); } }; }).ToList(), false);
|
||||
if (_walletTab == WalletTab.Explorer) { ExplorerPage(b); return; }
|
||||
b.AddLabel(L.T("wallets.count", d.Wallets.Count, Tuning.WalletMax), "wallets_count_dim");
|
||||
if (d.Wallets.Count == 0) { b.AddLabel(L.T("wallets.none"), "wallets_none_dim"); return; }
|
||||
bool wide = L.Wide && Ext < 100f;
|
||||
@@ -1265,54 +1272,66 @@ namespace Decentralized
|
||||
var w = Session.Data.AddWallet(poisoned);
|
||||
Log.Info($"添加硬件钱包 {w.Address}{(poisoned ? "(被投毒)" : "")}");
|
||||
Session.Save();
|
||||
_page = Page.Wallets;
|
||||
_page = Page.Wallets; _walletTab = WalletTab.List;
|
||||
_message = L.T("wallets.added", WalletWindow.NameOf(w), w.Address);
|
||||
Open();
|
||||
}
|
||||
|
||||
private sealed class TabDef { public string Name; public bool On; public Action Click; }
|
||||
private static float TabPx(string txt) => txt.Sum(c => c > 0x2E80 ? 18f : 9f) + 28f;
|
||||
|
||||
/// <summary>
|
||||
/// 一排页签:按字数估宽,超出一行就折到下一行。connect 为真时把连接钱包的控件放在最后一行右端,放不下就单独一行。
|
||||
/// </summary>
|
||||
private static void TabRows(CustomUIBuilder b, List<TabDef> tabs, bool connect)
|
||||
{
|
||||
float avail = ScreenW - 40f, used = 0f;
|
||||
bool open = false;
|
||||
foreach (var t in tabs)
|
||||
{
|
||||
float wpx = TabPx(t.Name);
|
||||
if (open && used + wpx > avail) { b.End(); open = false; used = 0f; }
|
||||
if (!open) { b.BeginRow(4f, TextAnchor.MiddleLeft); open = true; }
|
||||
used += wpx + 4f;
|
||||
PledgerSkin.Pick(b, t.Name, t.On, t.Click, _picked);
|
||||
}
|
||||
if (!connect) { if (open) b.End(); return; }
|
||||
float widget = 120f + (Session.Data.Connected ? TabPx(L.T("web3.conn", WalletWindow.NameOf(Session.Data.Hot), ChainAddress.Short(Session.Data.Hot.Address))) : TabPx(L.T("web3.connect")));
|
||||
if (open && used + widget > avail) { b.End(); open = false; }
|
||||
if (!open) b.BeginRow(4f, TextAnchor.MiddleLeft);
|
||||
b.AddFlexibleSpace();
|
||||
ConnectWidget(b);
|
||||
b.End();
|
||||
}
|
||||
|
||||
private static bool GrayAvailable => Unlock.MixerUnlocked || Unlock.BlackUnlocked;
|
||||
private enum GrayTab { Mixer, Black }
|
||||
private static GrayTab _grayTab = GrayTab.Mixer;
|
||||
|
||||
/// <summary>灰网:混币器和商店,各自在人脉网络里解锁,解锁了哪个就有哪个。</summary>
|
||||
private static void GrayPage(CustomUIBuilder b)
|
||||
{
|
||||
if (_grayTab == GrayTab.Mixer && !Unlock.MixerUnlocked) _grayTab = GrayTab.Black;
|
||||
if (_grayTab == GrayTab.Black && !Unlock.BlackUnlocked) _grayTab = GrayTab.Mixer;
|
||||
if (Unlock.MixerUnlocked && Unlock.BlackUnlocked)
|
||||
TabRows(b, Enum.GetValues(typeof(GrayTab)).Cast<GrayTab>().Select(t => { var tab = t; return new TabDef { Name = L.T("gray.sub." + t.ToString().ToLowerInvariant()), On = tab == _grayTab, Click = () => { _grayTab = tab; _message = null; _edit = null; Open(); } }; }).ToList(), false);
|
||||
if (!Session.Data.Connected) b.AddLabel(L.T("web3.err.noconn"), "term_note");
|
||||
if (_grayTab == GrayTab.Mixer) MixerPage(b); else BlackPage(b);
|
||||
}
|
||||
|
||||
/// <summary>Web3:链上钱包与去中心化交易。</summary>
|
||||
private static void Web3Page(CustomUIBuilder b)
|
||||
{
|
||||
var w = Session.Data.Hot;
|
||||
if (WalletWindow.Pending != null && !WalletWindow.Pending.Contract) { PayPage(b); return; }
|
||||
{
|
||||
if (_web3Tab == Web3Tab.Mixer && !Unlock.MixerUnlocked) _web3Tab = Web3Tab.Trade;
|
||||
if (_web3Tab == Web3Tab.Black && !Unlock.BlackUnlocked) _web3Tab = Web3Tab.Trade;
|
||||
if (_web3Tab == Web3Tab.Predict && !PredictGame.Available(StoreStation.GetDayCounter())) _web3Tab = Web3Tab.Trade;
|
||||
var tabs = Enum.GetValues(typeof(Web3Tab)).Cast<Web3Tab>()
|
||||
.Where(t => !((t == Web3Tab.Mixer && !Unlock.MixerUnlocked) || (t == Web3Tab.Black && !Unlock.BlackUnlocked) || (t == Web3Tab.Predict && !PredictGame.Available(StoreStation.GetDayCounter()))))
|
||||
.ToList();
|
||||
// 页签按字数估宽,超出一行就折到下一行;连接钱包的控件放在最后一行右端,放不下就单独一行
|
||||
float avail = ScreenW - 40f, used = 0f;
|
||||
Func<string, float> px = txt => txt.Sum(c => c > 0x2E80 ? 18f : 9f) + 28f;
|
||||
bool open = false;
|
||||
foreach (var t in tabs)
|
||||
{
|
||||
string name = L.T("web3.sub." + t.ToString().ToLowerInvariant());
|
||||
float wpx = px(name);
|
||||
if (open && used + wpx > avail) { b.End(); open = false; used = 0f; }
|
||||
if (!open) { b.BeginRow(4f); open = true; }
|
||||
used += wpx + 4f;
|
||||
var tab = t;
|
||||
PledgerSkin.Pick(b, name, tab == _web3Tab, () => { _web3Tab = tab; _message = null; _edit = null; Open(); }, _picked);
|
||||
}
|
||||
float widget = 120f + (Session.Data.Connected ? px(L.T("web3.conn", WalletWindow.NameOf(Session.Data.Hot), ChainAddress.Short(Session.Data.Hot.Address))) : px(L.T("web3.connect")));
|
||||
if (open && used + widget > avail) { b.End(); open = false; }
|
||||
if (!open) b.BeginRow(4f);
|
||||
b.AddFlexibleSpace();
|
||||
ConnectWidget(b);
|
||||
b.End();
|
||||
ConnectPicker(b);
|
||||
if (!Session.Data.Connected && _web3Tab != Web3Tab.Explorer) b.AddLabel(L.T("web3.err.noconn"), "term_note");
|
||||
if (_web3Tab == Web3Tab.Stake) { StakePage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Predict) { PredictPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Ponzi) { YieldPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Airdrop) { AirdropPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Mining) { ReportPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Mixer) { MixerPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Black) { BlackPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Explorer) { ExplorerPage(b); return; }
|
||||
}
|
||||
if (_web3Tab == Web3Tab.Predict && !PredictGame.Available(StoreStation.GetDayCounter())) _web3Tab = Web3Tab.Trade;
|
||||
TabRows(b, Enum.GetValues(typeof(Web3Tab)).Cast<Web3Tab>()
|
||||
.Where(t => t != Web3Tab.Predict || PredictGame.Available(StoreStation.GetDayCounter()))
|
||||
.Select(t => { var tab = t; return new TabDef { Name = L.T("web3.sub." + t.ToString().ToLowerInvariant()), On = tab == _web3Tab, Click = () => { _web3Tab = tab; _message = null; _edit = null; Open(); } }; }).ToList(), false);
|
||||
if (!Session.Data.Connected) b.AddLabel(L.T("web3.err.noconn"), "term_note");
|
||||
if (_web3Tab == Web3Tab.Stake) { StakePage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Predict) { PredictPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Ponzi) { YieldPage(b); return; }
|
||||
if (_web3Tab == Web3Tab.Airdrop) { AirdropPage(b); return; }
|
||||
Columns(b, l =>
|
||||
{
|
||||
l.AddHeader(L.T("web3.wallet.h") + (Session.Data.Connected ? " " + WalletWindow.NameOf(w) : ""));
|
||||
@@ -1778,7 +1797,7 @@ namespace Decentralized
|
||||
{
|
||||
if (win?.root == null) return;
|
||||
var old = win.root.transform.Find("pd_cart_fab");
|
||||
bool show = _page == Page.Web3 && _web3Tab == Web3Tab.Black && !_checkout && WalletWindow.Pending == null && Unlock.BlackUnlocked;
|
||||
bool show = _page == Page.Gray && _grayTab == GrayTab.Black && !_checkout && WalletWindow.Pending == null && Unlock.BlackUnlocked;
|
||||
if (!show) { if (old != null) UnityEngine.Object.Destroy(old.gameObject); return; }
|
||||
if (old != null) UnityEngine.Object.DestroyImmediate(old.gameObject);
|
||||
var go = new GameObject("pd_cart_fab", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image), typeof(Button), typeof(LayoutElement));
|
||||
@@ -2243,7 +2262,7 @@ namespace Decentralized
|
||||
Open();
|
||||
}
|
||||
|
||||
private enum Web3Tab { Trade, Stake, Airdrop, Predict, Ponzi, Mining, Mixer, Black, Explorer }
|
||||
private enum Web3Tab { Trade, Stake, Airdrop, Predict, Ponzi }
|
||||
private static Web3Tab _web3Tab = Web3Tab.Trade;
|
||||
private static string _mixAsset = Assets.PSC;
|
||||
private static int _mixRounds = 2;
|
||||
|
||||
Reference in new issue
Block a user