Magnifier inspection view for graphics cards
Cards are inspectable. While the magnifier inspection tray shows a card, a mod-owned panel under the tray draws the card enlarged with its appearance overlays and a turn-over button. No Harmony patches: a resident component watches the inspection manager. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e643332a41
commit
c05fe41ca9
6 files changed
+169
-17
No files matched your search
+35
-17
@@ -70,6 +70,7 @@ namespace Decentralized
|
||||
{
|
||||
var item = ItemDirectory.CreateEmptyItem(GpuId(spec.Model));
|
||||
item.SetGameItemType("MATERIAL");
|
||||
InspectableHelper.InitInspectableItem(item);
|
||||
item.onLoaded = Refresh;
|
||||
// 右键"切换"翻面;外观差异用叠加图画在同一张底图上
|
||||
item.EnableTag(ToggleAppearanceHelper.TOGGLE_APPEARANCE_TAG);
|
||||
@@ -77,8 +78,7 @@ namespace Decentralized
|
||||
item.canToggleSlotItemFunc = (_, _, _) => true;
|
||||
item.onToggleSlotItemFunc = (toggled, _, _) => Log.Guard("显卡翻面", () =>
|
||||
{
|
||||
if (toggled.IsTag(BackTag)) toggled.ModifyTag(BackTag, t => t.Disable()); else toggled.EnableTag(BackTag);
|
||||
Refresh(toggled);
|
||||
Flip(toggled);
|
||||
});
|
||||
item.getItemSpriteModifierForItemFunc = Overlays;
|
||||
ModHelper.SetSource(item, ModInfo.Id, ModInfo.Name);
|
||||
@@ -152,33 +152,51 @@ namespace Decentralized
|
||||
SyncValue(item);
|
||||
}
|
||||
|
||||
private static Sprite ModSprite(string key)
|
||||
public static bool IsBack(GameItem item) => item.IsTag(BackTag);
|
||||
|
||||
public static void Flip(GameItem item)
|
||||
{
|
||||
var mod = ModLoader.Mods.Find(m => m.Manifest.ID.Equals(ModInfo.Id));
|
||||
return mod != null && mod.Sprites.TryGetValue(key, out var sprite) ? sprite : null;
|
||||
if (IsBack(item)) item.ModifyTag(BackTag, t => t.Disable()); else item.EnableTag(BackTag);
|
||||
Refresh(item);
|
||||
}
|
||||
|
||||
/// <summary>外观叠加图:正面三个维度,背面丝印与贴纸;烧毁的卡不叠。</summary>
|
||||
private static List<ItemSpriteModifier> Overlays(GameItem item)
|
||||
/// <summary>当前面的底图名与叠加图名:正面三个维度,背面丝印与贴纸;烧毁的卡不叠。</summary>
|
||||
public static string LookKeys(GameItem item, List<string> overlays)
|
||||
{
|
||||
var list = new List<ItemSpriteModifier>();
|
||||
SyncValue(item); // 归属变化(买下)后价格随之变回真实价值
|
||||
if (item.IsTag(DeadTag)) return list;
|
||||
var u = ToUnit(item);
|
||||
var keys = new List<string>();
|
||||
if (!item.IsTag(BackTag))
|
||||
bool back = IsBack(item);
|
||||
string brand = u.Label.Brand == Hardware.Probidia ? "gpu_probidia" : "gpu_pmd";
|
||||
if (u.Dead) return back ? "gpu_burnt_b" : "gpu_burnt_f";
|
||||
if (!back)
|
||||
{
|
||||
if (u.Look.Fan > 0) keys.Add("gpu_ov_fan" + u.Look.Fan);
|
||||
if (u.Look.Fingers > 0) keys.Add("gpu_ov_fin" + u.Look.Fingers);
|
||||
if (u.Look.Bracket > 0) keys.Add("gpu_ov_brk" + u.Look.Bracket);
|
||||
if (u.Look.Fan > 0) overlays.Add("gpu_ov_fan" + u.Look.Fan);
|
||||
if (u.Look.Fingers > 0) overlays.Add("gpu_ov_fin" + u.Look.Fingers);
|
||||
if (u.Look.Bracket > 0) overlays.Add("gpu_ov_brk" + u.Look.Bracket);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 丝印:0 标称型号;1 印的是真实芯片型号;2 标称型号但字歪(重印过)
|
||||
string model = u.Look.Print == 1 && u.FakeOf != null ? u.FakeOf : u.Model;
|
||||
keys.Add((u.Look.Print == 2 ? "gpu_ov_txs_" : "gpu_ov_txt_") + model.ToLowerInvariant());
|
||||
if (u.Look.Sticker > 0) keys.Add("gpu_ov_stk" + u.Look.Sticker);
|
||||
overlays.Add((u.Look.Print == 2 ? "gpu_ov_txs_" : "gpu_ov_txt_") + model.ToLowerInvariant());
|
||||
if (u.Look.Sticker > 0) overlays.Add("gpu_ov_stk" + u.Look.Sticker);
|
||||
}
|
||||
return brand + (back ? "_b" : "_f");
|
||||
}
|
||||
|
||||
public static Sprite ModSprite(string key)
|
||||
{
|
||||
var mod = ModLoader.Mods.Find(m => m.Manifest.ID.Equals(ModInfo.Id));
|
||||
return mod != null && mod.Sprites.TryGetValue(key, out var sprite) ? sprite : null;
|
||||
}
|
||||
|
||||
/// <summary>物品栏里的外观叠加图。</summary>
|
||||
private static List<ItemSpriteModifier> Overlays(GameItem item)
|
||||
{
|
||||
var list = new List<ItemSpriteModifier>();
|
||||
SyncValue(item); // 归属变化(买下)后价格随之变回真实价值
|
||||
if (item.IsTag(DeadTag)) return list;
|
||||
var keys = new List<string>();
|
||||
LookKeys(item, keys);
|
||||
int priority = 0;
|
||||
foreach (var k in keys)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user