From 1a7a2818b8e2ee010f188b3c7520e2b192aee18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=80=E9=94=8B=E9=95=9D=E9=93=B8?= <523084467@qq.com> Date: Wed, 29 Nov 2023 23:21:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B8=AE=E5=8A=A9=E5=8C=85?= =?UTF-8?q?=E8=AF=86=E5=88=AB=E6=97=8B=E8=BD=AC=E5=90=8E=E5=A4=8D=E6=9D=82?= =?UTF-8?q?=E6=96=B9=E5=9D=97=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Widgets/GVHelperInventorySlotWidget.xml | 6 +-- Gigavolt.Helper/ComponentGVHelper.cs | 15 ++++++-- Gigavolt.Helper/StaticGVHelper.cs | 37 +++++++++++++++++-- Gigavolt/Assets/Lang/zh-CN.json | 2 +- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/Gigavolt.Helper/Assets/Widgets/GVHelperInventorySlotWidget.xml b/Gigavolt.Helper/Assets/Widgets/GVHelperInventorySlotWidget.xml index 73841a46..95b1fe5e 100644 --- a/Gigavolt.Helper/Assets/Widgets/GVHelperInventorySlotWidget.xml +++ b/Gigavolt.Helper/Assets/Widgets/GVHelperInventorySlotWidget.xml @@ -1,5 +1,5 @@ - - - + + + diff --git a/Gigavolt.Helper/ComponentGVHelper.cs b/Gigavolt.Helper/ComponentGVHelper.cs index f2e2be31..23fd4b50 100644 --- a/Gigavolt.Helper/ComponentGVHelper.cs +++ b/Gigavolt.Helper/ComponentGVHelper.cs @@ -8,7 +8,10 @@ public class ComponentGVHelper : Component, IUpdateable { public ComponentPlayer m_componentPlayer; public ComponentGui m_componentGui; public ComponentBlockHighlight m_componentBlockHighlight; + public GVHelperInventorySlotWidget m_GVHelperInventorySlotWidget; + public StackPanelWidget m_shortInventoryPanel; + public bool m_slotAdded; public UpdateOrder UpdateOrder => UpdateOrder.Default; @@ -18,8 +21,14 @@ public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToE m_componentGui = Entity.FindComponent(true); m_componentBlockHighlight = Entity.FindComponent(true); m_GVHelperInventorySlotWidget = new GVHelperInventorySlotWidget(m_componentBlockHighlight); + m_shortInventoryPanel = new StackPanelWidget { Direction = LayoutDirection.Horizontal }; + m_componentGui.ShortInventoryWidget.AddChildren(m_shortInventoryPanel); + GridPanelWidget temp = m_componentGui.ShortInventoryWidget.Children.Find("InventoryGrid"); + m_componentGui.ShortInventoryWidget.RemoveChildren(temp); + m_shortInventoryPanel.AddChildren(temp); + temp.ChangeParent(m_shortInventoryPanel); if (GVStaticStorage.GVHelperSlotActive) { - m_componentGui.ShortInventoryWidget.AddChildren(m_GVHelperInventorySlotWidget); + m_shortInventoryPanel.AddChildren(m_GVHelperInventorySlotWidget); m_slotAdded = true; } } @@ -27,13 +36,13 @@ public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToE public void Update(float dt) { if (GVStaticStorage.GVHelperSlotActive) { if (!m_slotAdded) { - m_componentGui.ShortInventoryWidget.AddChildren(m_GVHelperInventorySlotWidget); + m_shortInventoryPanel.AddChildren(m_GVHelperInventorySlotWidget); m_slotAdded = true; } } else { if (m_slotAdded) { - m_componentGui.ShortInventoryWidget.RemoveChildren(m_GVHelperInventorySlotWidget); + m_shortInventoryPanel.RemoveChildren(m_GVHelperInventorySlotWidget); m_slotAdded = false; } } diff --git a/Gigavolt.Helper/StaticGVHelper.cs b/Gigavolt.Helper/StaticGVHelper.cs index 44505e88..17cf9420 100644 --- a/Gigavolt.Helper/StaticGVHelper.cs +++ b/Gigavolt.Helper/StaticGVHelper.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; namespace Game { @@ -21,18 +22,46 @@ public static class StaticGVHelper { { GVJavascriptMicrocontrollerBlock.Index, new[] { "js单片机-javascript-microcontroller", "GVJavascriptMicrocontrollerBlock" } } }; + public static readonly Dictionary> BlockIndex2DataHandler = new() { + { GVWireBlock.Index, blockData => GVWireBlock.SetColor(0, GVWireBlock.GetColor(blockData)) }, + { GVLedBlock.Index, blockData => GVLedBlock.SetColor(0, GVLedBlock.GetColor(blockData)) }, + { GVFourLedBlock.Index, blockData => GVFourLedBlock.SetColor(0, GVFourLedBlock.GetColor(blockData)) }, + { GVSevenSegmentDisplayBlock.Index, blockData => GVSevenSegmentDisplayBlock.SetColor(0, GVSevenSegmentDisplayBlock.GetColor(blockData)) }, + { GVAnalogToDigitalConverterBlock.Index, blockData => GVAnalogToDigitalConverterBlock.SetType(0, GVAnalogToDigitalConverterBlock.GetType(blockData)) }, + { GVDigitalToAnalogConverterBlock.Index, blockData => GVDigitalToAnalogConverterBlock.SetType(0, GVDigitalToAnalogConverterBlock.GetType(blockData)) }, + { GVPistonBlock.Index, blockData => GVPistonBlock.SetMode(0, GVPistonBlock.GetMode(blockData)) }, + { GV8x4LedBlock.Index, blockData => GV8x4LedBlock.SetType(0, GV8x4LedBlock.GetType(blockData)) }, + { GVDoorBlock.Index, blockData => GVDoorBlock.SetModel(0, GVDoorBlock.GetModel(blockData)) }, + { GVTrapdoorBlock.Index, blockData => GVTrapdoorBlock.SetModel(0, GVTrapdoorBlock.GetModel(blockData)) }, + { GVFenceGateBlock.Index, blockData => GVFenceGateBlock.SetModel(GVFenceGateBlock.SetColor(0, GVFenceGateBlock.GetColor(blockData)), GVFenceGateBlock.GetModel(blockData)) }, + { GVDisplayLedBlock.Index, blockData => GVDisplayLedBlock.SetComplex(GVDisplayLedBlock.SetType(0, GVDisplayLedBlock.GetType(blockData)), GVDisplayLedBlock.GetComplex(blockData)) }, + { GVMoreTwoInTwoOutBlock.Index, blockData => GVMoreTwoInTwoOutBlock.SetType(0, GVMoreTwoInTwoOutBlock.GetType(blockData)) }, + { GVMoreOneInOneOutBlock.Index, blockData => GVMoreOneInOneOutBlock.SetType(0, GVMoreOneInOneOutBlock.GetType(blockData)) }, + { GVInventoryFetcherBlock.Index, blockData => GVInventoryFetcherBlock.SetType(0, GVInventoryFetcherBlock.GetType(blockData)) }, + { GVEWireThroughBlock.Index, blockData => GVEWireThroughBlock.SetType(0, GVEWireThroughBlock.GetType(blockData)) }, + { GVPressurePlateBlock.Index, blockData => GVPressurePlateBlock.SetMaterial(0, GVPressurePlateBlock.GetMaterial(blockData)) }, + { GVPressurePlateCBlock.Index, blockData => GVPressurePlateCBlock.SetMaterial(0, GVPressurePlateCBlock.GetMaterial(blockData)) }, + { GVLightbulbBlock.Index, blockData => GVLightbulbBlock.SetColor(0, GVLightbulbBlock.GetColor(blockData)) }, + { GVWoodenPostedSignCBlock.Index, blockData => GVPostedSignCBlock.SetColor(0, GVPostedSignCBlock.GetColor(blockData)) }, + { GVIronPostedSignCBlock.Index, blockData => GVPostedSignCBlock.SetColor(0, GVPostedSignCBlock.GetColor(blockData)) } + }; + public static void GotoBlockDescriptionScreen(int blockValue) { int blockContent = Terrain.ExtractContents(blockValue); if (BlockIndex2HelperInfo.TryGetValue(blockContent, out string[] value)) { GotoGVHelpScreen(value[0], value[1]); } else { - int id = blockContent; + int newBlockValue = blockContent; + int blockData = Terrain.ExtractData(blockValue); Block block = BlocksManager.Blocks[blockContent]; if (block.GetCreativeValues().Contains(blockValue)) { - id = blockValue; + newBlockValue = blockValue; + } + else if (BlockIndex2DataHandler.TryGetValue(blockContent, out Func blockIndex2DataHandler)) { + newBlockValue = Terrain.MakeBlockValue(blockContent, 0, blockIndex2DataHandler(blockData)); } - ScreensManager.SwitchScreen("RecipaediaDescription", id, new List { id }); + ScreensManager.SwitchScreen("RecipaediaDescription", newBlockValue, new List { newBlockValue }); } } diff --git a/Gigavolt/Assets/Lang/zh-CN.json b/Gigavolt/Assets/Lang/zh-CN.json index 7c07bb8c..5570f9e9 100644 --- a/Gigavolt/Assets/Lang/zh-CN.json +++ b/Gigavolt/Assets/Lang/zh-CN.json @@ -359,7 +359,7 @@ "DisplayName": "GV活板门", "Description": "活板门可用来搭建建筑物的垂直入口。单击可以打开和关闭它们。连接到铜线时,活板门将根据电压强度打开或部分打开,0V关门,0x2D V打开45度,0x5A V及以上完全打开。连上电路后时,铁质活板门无法手动操作。它们可以正常放置,也可以上下放置,具体取决于它们是安装在方块的顶部还是底部。颠倒的活板门将阻止掉落的障碍物。" }, - "IronFenceGateBlock:0": { + "GVFenceGateBlock:0": { "DisplayName": "GV栅栏门", "Description": "栅栏门用于通往围栏区域。单击它们可以打开和关闭它们。当连接到铜线上时,栅栏门将根据电压强度打开或部分打开,0V关门,0x2D V打开45度,0x5A V及以上完全打开。动物不能跳过栅栏门。可以染色。" },