diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 90a902a..4651e26 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,29 @@ # 更新日志 | Changelog +## [1.3.0] + +本次更新内容: + +### 新增 + +- **Extraplanetary Launchpads(需要Harmony)** - 可以在其他星球搭建发射台建造火箭的Mod,Mod 很不错,但是我选择【SimpleConstruction!】添加了内置硬编码文本的翻译 +- **OrbitPOInts(需要Harmony)** - 一个能在地图界面可视化星球的引力范围、大气高度等信息的Mod +- **Planetside Exploration Technologies(需要Harmony)** - 硬编码内容的翻译,现在翻译应该完整了。 +- **Resource Overview(需要Harmony)** - 轻量型资源显示器。 +- **Near Future Electrical** - 补充新增的部件翻译 +- **Community Resource Pack** - 为每个资源定义添加了 abbreviation 字段,适配 KSPCF 的改动 https://github.com/KSPModdingLibs/KSPCommunityFixes/pull/235,同时将`联氨(肼)`改为单字翻译`肼`、 `鉛者` 改为单字翻译 `铅` 。这是 1.2 的更新内容,忘记写了,这里补上。 + +### 修正 + +- **James Webb For Kerbal** - 将原来的翻译“詹姆斯·**韦伯**”修改为“詹姆斯·**韦布**”,遵循全国科学技术名词审定委员会发布的译名 +- **Squad** - 将原版中文翻译的 `在<<1>>表面建造一辆探测车` 更正为`在<<1>>表面完成探测车的组装` (英原文 `Finish construction of a Rover on the surface of <<1>>`) +- **Benjee10 sharedAssets** - 修复了一处导致**C-100 异体同构对接装置**的动作按钮仍是英文的错误 +- **Far Future Technologies** - 补充新增的部件翻译 + +### 其他 + +- 代码整体进行重构,输出日志现在包含每个 Mod 的翻译 Patch 的执行时间,更加直观的知道是翻译哪个Mod拖慢了速度 + ## [1.2.0] 本次更新内容: diff --git a/GameData/0000Tinygrox_CNPatches/ASET/PROP/PROP.cfg b/GameData/0000Tinygrox_CNPatches/ASET/PROP/PROP.cfg index bb2c3db..43cd2da 100644 --- a/GameData/0000Tinygrox_CNPatches/ASET/PROP/PROP.cfg +++ b/GameData/0000Tinygrox_CNPatches/ASET/PROP/PROP.cfg @@ -545,7 +545,7 @@ { %fontName = Microsoft YaHei // Arial %fontSize = 4.2 - @labelText = [b]引擎烧毁[/b] // [b]ENGINE$$$FLAME OUT[/b] + @labelText = [b]引擎熄火[/b] // [b]ENGINE$$$FLAME OUT[/b] } } @PROP[DigitalIndicator_DELTAVTOTAL]:AFTER[ASET] diff --git a/GameData/0000Tinygrox_CNPatches/Benjee10 sharedAssets/ZH_Benjee10sharedAssets.cfg b/GameData/0000Tinygrox_CNPatches/Benjee10 sharedAssets/ZH_Benjee10sharedAssets.cfg index 9106ce7..73edb42 100644 --- a/GameData/0000Tinygrox_CNPatches/Benjee10 sharedAssets/ZH_Benjee10sharedAssets.cfg +++ b/GameData/0000Tinygrox_CNPatches/Benjee10 sharedAssets/ZH_Benjee10sharedAssets.cfg @@ -4,7 +4,7 @@ @title = C-100 异体同构对接装置 // C-100 Androgynous Docking Mechanism @description = 这个中等尺寸的对接装置能让人们日益贴近。 // This intermediate-sized docking mechanism is great for bringing people together. - @MODULE[ModuleB9PartSwitch]:HAS[#animationName[APAS_deploy]] + @MODULE[ModuleAnimateGeneric]:HAS[#animationName[APAS_deploy]] { @actionGUIName = 开关柔性对接环 // Toggle Soft Capture Ring @startEventGUIName = 展开柔性对接环 // Extend Soft Capture Ring diff --git a/GameData/0000Tinygrox_CNPatches/ExtraplanetaryLaunchpads/ZH_EL.cfg b/GameData/0000Tinygrox_CNPatches/ExtraplanetaryLaunchpads/ZH_EL.cfg index c83797e..bdc50d2 100644 --- a/GameData/0000Tinygrox_CNPatches/ExtraplanetaryLaunchpads/ZH_EL.cfg +++ b/GameData/0000Tinygrox_CNPatches/ExtraplanetaryLaunchpads/ZH_EL.cfg @@ -263,7 +263,7 @@ Localization #EL_UI_DebugCraftHull = [Debug] Write craft hull points file #EL_UI_KillWarpMessage = 停止加速和信息 #EL_UI_KillWarpOnly = 仅停止加速 - #EL_UI_MessageOnly = 进信息 + #EL_UI_MessageOnly = 仅信息 #EL_UI_PauseGame = 暂停游戏 } } diff --git a/GameData/0000Tinygrox_CNPatches/FarFutureTechnologies/ZH_FTT.cfg b/GameData/0000Tinygrox_CNPatches/FarFutureTechnologies/ZH_FTT.cfg index 078e38a..16df12a 100644 --- a/GameData/0000Tinygrox_CNPatches/FarFutureTechnologies/ZH_FTT.cfg +++ b/GameData/0000Tinygrox_CNPatches/FarFutureTechnologies/ZH_FTT.cfg @@ -2,20 +2,129 @@ Localization { zh-cn { + #LOC_FFT_resource_FissionPulse_title = 裂变脉冲装置 // Fission Pulse Units + #LOC_FFT_resource_FissionPulse_abbrev = NUK + + #LOC_FFT_switcher_fusion-contents_deuterium_summary = 用于聚变作业的液化氘。 // Liquified Deuterium for fusion applications. + #LOC_FFT_switcher_mirror = 方向 // Orientation #LOC_FFT_switcher_mirror_left = 左 // Left #LOC_FFT_switcher_mirror_right = 右 // Right + #LOC_FFT_switcher_radiator_length_size0_detail = 产热 // heat generation + #LOC_FFT_switcher_radiator_length_size1_detail = 93.3% 产热 // 93.3% heat generation + #LOC_FFT_switcher_radiator_length_size2_detail = 86.7% 产热 // 86.7% heat generation + #LOC_FFT_switcher_radiator_length_size3_detail = 80% 产热 // 80% heat generation + #LOC_FFT_switcher_radiator_length_size4_detail = 73.3% 产热 // 73.3% heat generation + #LOC_FFT_switcher_radiator_length_size5_detail = 66.7% 产热 // 66.7% heat generation + #LOC_FFT_switcher_radiator_length_size6_detail = 60% 产热 // 60% heat generation + #LOC_FFT_switcher_radiator_length_size7_detail = 53.3% 产热 // 53.3% heat generation + #LOC_FFT_switcher_radiator_length_size8_detail = 46.7% 产热 // 46.7% heat generation + #LOC_FFT_switcher_radiator_length_size9_detail = 40% 产热 // 40% heat generation + #LOC_FFT_switcher_radiator_length_size10_detail = 33.3% 产热 // 33.3% heat generation + #LOC_FFT_switcher_radiator_length_size11_detail = 26.7% 产热 // 26.7% heat generation + #LOC_FFT_switcher_radiator_length_size12_detail = 20% 产热 // 20% heat generation + #LOC_FFT_switcher_radiator_length_size13_detail = 13.3% 产热 // 13.3% heat generation + #LOC_FFT_switcher_radiator_length_size14_detail = 6.7% 产热 // 6.7% heat generation + #LOC_FFT_switcher_radiator_length_size15_detail = 0% 产热 // 0% heat generation + + #LOC_FFT_switcher_rcs-type = 推进器配置 // Thruster Configuration + #LOC_FFT_switcher_rcs-type_4x = 4路 // 4-Way + #LOC_FFT_switcher_rcs-type_4x_detail = 4 RCS 方向 // 4 RCS directions + #LOC_FFT_switcher_rcs-type_3x = 3路 // 3-Way + #LOC_FFT_switcher_rcs-type_3x_detail = 3个RCS推进器 // Three RCS thrusters + #LOC_FFT_switcher_rcs-type_2x = 2路 // 2-Way + #LOC_FFT_switcher_rcs-type_2x_detail = 2个RCS推进器 // Two RCS thrusters + #LOC_FFT_switcher_rcs-type_1x = 单路 // Single + #LOC_FFT_switcher_rcs-type_1x_detail = 1个RCS推进器 // One RCS thruster + + #LOC_FFT_switcher_rcs-fuel = 推进剂 // Propellant + #LOC_FFT_switcher_rcs-fuel_li = 锂 // Lithium + #LOC_FFT_switcher_rcs-fuel_li_detail = 高推力但低效 // Higher thrust but lower performance fuel + #LOC_FFT_switcher_rcs-fuel_li_summary = 锂推进剂 // Lithium Propellant + #LOC_FFT_switcher_rcs-fuel_h2 = 氢 // Hydrogen + #LOC_FFT_switcher_rcs-fuel_h2_detail = 160%比冲, 80%推力 // 160% Isp, 80% thrust + #LOC_FFT_switcher_rcs-fuel_h2_summary = 氢推进剂 // Hydrogen Propellant + + // #LOC_FFT_fft-fusion-magnetic-tokamak-turbojet-1_title = CFJ-20 + // #LOC_FFT_fft-fusion-magnetic-tokamak-turbojet-1_description = Placeholder for thermal fusion turbojet + // #LOC_FFT_fft-fusion-magnetic-tokamak-turbojet-1_tags = fusion thermal plas nuclear rocket tokamak farfuture + + #LOC_FFT_fft-fission-orion-5-1_title = X-12 '汉密尔顿'核脉冲引擎 // X-12 'Hamilton' Nuclear Pulse Engine + #LOC_FFT_fft-fission-orion-5-1_description = 在锡罐下面燃放爆竹可以将其向上推进,这与在复杂的减震装置下面引爆低当量核弹可以将其向上推进的原理是一样的。它能提供巨大的推力,但不要在你在意的东西附近使用,比如坎巴拉航天中心的设施。 // A firecracker set off under a tin can propels it upward, much in the same way as a low yield nuclear weapon set off under a complicated shock absorbing mechanism propels it upward. Provides great thrust, but don't use near things you care about, like KSC facilities. + // #LOC_FFT_fft-fission-orion-5-1_tags = farfuture fission pulse orion boom boomboom hamilton + + #LOC_FFT_fft-fueltank-targets-5-2_title = PW x8核粒子存储容器 // PW x8 Nuclear Pellet Storage Container + #LOC_FFT_fft-fueltank-targets-5-2_description = 提供集成进料系统和输送机,以储存更多经过精心加工的微小核装料,并将其输送到核脉冲发动机系统。 // Provides integrated feed system and conveyors to store even more tiny, well-machined charges of nuclear fuel for delivery to nuclear pulse engine system. + // #LOC_FFT_fft-fueltank-targets-5-2_tags = fueltank micro fission fusion mag mini micro orion pulse nuke nucl farfuture + + #LOC_FFT_fft-fueltank-pulseunits-5-1_title = OP 6x2 核脉冲单元箱 // OP 6x2 Nuclear Pulse Unit Tank + #LOC_FFT_fft-fueltank-pulseunits-5-1_description = 存储用于脉冲推进的标准核爆炸物,包括传送带和气体喷射系统。 // Stores standardized nuclear explosives for use in pulsed propusion applications, including conveyors and a gas-jet injection system. + // #LOC_FFT_fft-fueltank-pulseunits-5-1_tags = fueltank fission orion boom pulse nuke nucl farfuture + #LOC_FFT_fft-fueltank-pulseunits-5-2_title = OP 6x4 核脉冲单元箱 // OP 6x4 Nuclear Pulse Unit Tank + #LOC_FFT_fft-fueltank-pulseunits-5-2_description = 一箱中型标准化核脉冲装药(核弹),用于核脉冲推进。 // A medium sized box of standardized nuclear pulse charges (nuclear bombs) for use in pulsed propusion applications. + // #LOC_FFT_fft-fueltank-pulseunits-5-2_tags = fueltank fission orion boom pulse nuke nucl farfuture + #LOC_FFT_fft-fueltank-pulseunits-5-3_title = OP 6x8 核脉冲单元箱 // OP 6x8 Nuclear Pulse Unit Tank + #LOC_FFT_fft-fueltank-pulseunits-5-3_description = 一种用于核脉冲推进的非常大的核弹箱。 // A very large box of nuclear bombs for use in pulsed propusion applications. + // #LOC_FFT_fft-fueltank-pulseunits-5-3_tags = fueltank fission orion boom pulse nuke nucl farfuture + + #LOC_FFT_fft-fueltank-antimatter-tank-5-2_title = A-CY1-5B 反物质储存容器 // A-CY1-5B Antimatter Storage Container + #LOC_FFT_fft-fueltank-antimatter-tank-5-2_description = 先进的中等长度大容量反物质储存容器,使用了大量的冷冻反氢和磁铁。\n 需要持续供电,否则内容物泄露会造成灾难性后果! // Advanced medium length, large size antimatter storage using a shielded mass of frozen antihydrogen and lots of magnets. \n Requires a constant stream of electricity or else it will leak with catastrophic effects! + // #LOC_FFT_fft-fueltank-antimatter-tank-5-2_tags = fueltank antimatter anti propellant tank farfuture + #LOC_FFT_fft-fueltank-antimatter-tank-5-3_title = A-CY1-5C 反物质存储容器 // A-CY1-5C Antimatter Storage Container + #LOC_FFT_fft-fueltank-antimatter-tank-5-3_description = 先进的超大型反物质储存容器,使用了大量的冷冻反氢和磁铁。\n 需要持续供电,否则内容物泄露会造成灾难性后果! // Advanced pretty large antimatter storage using a shielded mass of frozen antihydrogen and lots of magnets. \n Requires a constant stream of electricity or else it will leak with catastrophic effects! + // #LOC_FFT_fft-fueltank-antimatter-tank-5-3_tags = fueltank antimatter anti propellant tank farfuture + #LOC_FFT_fft-fueltank-antimatter-tank-5-4_title = A-CY1-5D Antimatter Storage Container + #LOC_FFT_fft-fueltank-antimatter-tank-5-4_description = 先进的巨大型反物质存储容器,使用了大量的冷冻反氢和磁铁。 \n 需要持续供电,否则内容物泄露会造成灾难性后果!// Advanced really quite enormous large antimatter storage using a shielded mass of frozen antihydrogen and lots of magnets. \n Requires a constant stream of electricity or else it will leak with catastrophic effects! + // #LOC_FFT_fft-fueltank-antimatter-tank-5-4_tags = fueltank antimatter anti propellant tank farfuture + + // Utility + // ===================== + // RCS + // ----------------- + + #LOC_FFT_fft-rcs-arcjet-large-1_title = ARC-L 电热推进型RCS // ARC-L Electrothermal RCS + #LOC_FFT_fft-rcs-arcjet-large-1_description = 使用氢或锂作为推进剂的大功率电驱RCS。与化学反应驱动的RCS相比,有更高的比冲,但电力消耗巨大。 // High power electrical RCS block using Lithium or Hydrogen for propellant. Uses an exorbitant amount of power to compete with chemical RCS at much higher impulses. + // #LOC_FFT_fft-rcs-arcjet-large-1_tags = farfuture arc electro thermal ion plasma rcs control jet block + + #LOC_FFT_fft-rcs-arcjet-1_title = ARC-μ 电热推进型RCS // ARC-μ Electrothermal RCS + #LOC_FFT_fft-rcs-arcjet-1_description = 使用氢或锂作为推进剂的大功率电驱RCS。与化学反应驱动的RCS相比,有更高的比冲,但电力消耗很高。 // High power electrical RCS block using Lithium or Hydrogen for propellant. Uses a large amount of power to compete with chemical RCS at much higher impulses. + // #LOC_FFT_fft-rcs-arcjet-1_tags = farfuture arc electro thermal ion plasma rcs control jet block + #LOC_FFT_fft-fueltank-fission-5-1_title = NTS-501 裂变燃料箱 // NTS-501 Fissonables Tank #LOC_FFT_fft-fueltank-fission-5-1_description = 要使用那些最大型核推进引擎,你需要这些大罐罐。NTS系列的大型燃料箱只能用于贮存精心配比的水和核盐水。 // For the largest nuclear propulsion applications, you need those big containers. The large versions of the NTS-series tanks can only hold carefully mixed water and nuclear salts. - #LOC_FFT_fft-fueltank-fission-5-1_tags = fueltank propellant water nuke juice uranium farfuture spicy nsw + // #LOC_FFT_fft-fueltank-fission-5-1_tags = fueltank propellant water nuke juice uranium farfuture spicy nsw #LOC_FFT_fft-fueltank-fission-5-2_title = NTS-502 裂变燃料箱 // NTS-502 Fissonables Tank #LOC_FFT_fft-fueltank-fission-5-2_description = 要使用那些最大型核推进引擎,你需要这些大罐罐。NTS系列的大型燃料箱只能用于贮存精心配比的水和核盐水。 // For the largest nuclear propulsion applications, you need those big containers. The large versions of the NTS-series tanks can only hold carefully mixed water and nuclear salts. - #LOC_FFT_fft-fueltank-fission-5-2_tags = fueltank propellant water nuke juice uranium farfuture spicy nsw + // #LOC_FFT_fft-fueltank-fission-5-2_tags = fueltank propellant water nuke juice uranium farfuture spicy nsw #LOC_FFT_fft-scoop-regolith-2_title = PK-DUST-S表尘处理系统 // PK-DUST-S Regolith Processing System #LOC_FFT_fft-scoop-regolith-2_description = 小一点的、多功能型可部署碎石和萃取系统,旨在收集天体表面沉积物中的微量微量气体,特别是氦-3。安装前部的处理臂可以将碎石压成粉尘,然后加热获得里面的气体物体。 // A smaller, dozer-style regolith crushing and smelting system, designed to harvest minute quantities of trace gases contained in surface deposits - specifically the elusive Helium-3. The front-mounted processor crushes rock into a fine, manageable dust, which is then heated to release trapped gasses. - #LOC_FFT_fft-scoop-regolith-2_tags = isru scoop process resource fusion harvest extract farfuture regolith dust moon + // #LOC_FFT_fft-scoop-regolith-2_tags = isru scoop process resource fusion harvest extract farfuture regolith dust moon + + // SETTINGS + #LOC_FFT_Settings_MainSection_Title = 远未来科技 // Far Future Technologies + #LOC_FFT_Settings_Antimatter_Section_Title = 反物质 // Antimatter + #LOC_FFT_Settings_AntimatterCostsScience_Title = 反物质消耗科技点 // Antimatter Costs Science + #LOC_FFT_Settings_AntimatterCostsScience_Tooltip = 从VAB发射装载有反物质的航天器需要消耗科技点数 // Launching ships with Antimatter from the VAB costs Science Points + #LOC_FFT_Settings_AntimatterScienceCost_Title = 科技点花费 // Science Cost + #LOC_FFT_Settings_AntimatterScienceCost_Tooltip = 每单位反物质消耗的科技点数 // The cost of one unit of Antimatter in Science Points + + #LOC_FFT_Settings_AntimatterContainment_Section_Title = 反物质收容 // Antimatter Containment + + #LOC_FFT_Settings_AntimatterContainmentEnabled_Title = 反物质需要收容 // Antimatter Needs Containment + #LOC_FFT_Settings_AntimatteContainmentEnabled_Tooltip = 如果启用,在航天器上的反物质存储容器会消耗电力否则会引发爆炸 // If enabled, antimatter tanks on a ship need power or else they will explode + #LOC_FFT_Settings_AntimatterDetonationRate_Title = 爆炸速率 // Detonation Rate + #LOC_FFT_Settings_AntimatterDetonationRate_Tooltip = 调整反物质未收容时的爆炸速率 // Scales the detonation rate of uncontained antimatter. + #LOC_FFT_Settings_AntimatterVolatility_Title = 不稳定性 // Volatility + #LOC_FFT_Settings_AntimatterVolatility_Tooltip = 调整单位反物质泄露时造成的爆炸伤害。 // Scales the amount of damage a leaking antimatter tank does per unit leaked. + + #LOC_FFT_Settings_EngineDamage_Section_Title = 引擎损害 // Engine Damage + + #LOC_FFT_Settings_EngineDamageFacilities_Title = 引擎对设施造成破坏 // Engines Damage Facilities + #LOC_FFT_Settings_EngineDamageFacilities_Tooltip = 高能引擎对航天中心设施造成破坏 // High power engines damage KSC facilities + #LOC_FFT_Settings_EngineDamageFacilityScale_Title = 设施破坏伤害 // Facility Damange Scale + #LOC_FFT_Settings_EngineDamageFacilityScale_Tooltip = 调整引擎对设施造成破坏的数值 // Scales the amount of damage engines do to facilities } } diff --git a/GameData/0000Tinygrox_CNPatches/JameWebb/ZH_JamesWebb.cfg b/GameData/0000Tinygrox_CNPatches/JameWebb/ZH_JamesWebb.cfg index 92f3535..547c1ed 100644 --- a/GameData/0000Tinygrox_CNPatches/JameWebb/ZH_JamesWebb.cfg +++ b/GameData/0000Tinygrox_CNPatches/JameWebb/ZH_JamesWebb.cfg @@ -1,7 +1,7 @@ @PART[JWST-BaseStructure]:NEEDS[JamesWebb] { - @title = 詹姆斯·韦伯 基础结构 - @description = 坎巴拉版的詹姆斯·韦伯空间望远镜!包含了18块玻(镀金)镜面、后部遮阳板、用来辅助展开遮阳板的传动折叠装置、观星设备、RCS燃料、光学仪器、计算设备、太阳能电池板内衬和连接环下方以及储能器。 + @title = 詹姆斯·韦布 基础结构 + @description = 坎巴拉版的詹姆斯·韦布空间望远镜!包含了18块玻(镀金)镜面、后部遮阳板、用来辅助展开遮阳板的传动折叠装置、观星设备、RCS燃料、光学仪器、计算设备、太阳能电池板内衬和连接环下方以及储能器。 @MODULE[ModuleScienceContainer] { @@ -24,8 +24,8 @@ @PART[JWST-MainAntenna]:NEEDS[JamesWebb] { - @title = 詹姆斯·韦伯 主天线 - @description = 詹姆斯·韦伯主天线由一个KA波段高增益天线和一个S波段中增益天线组成,这两个天线都安装在一个通用的铰接平台上。天线安装在詹姆斯·韦伯的侧面和后部。 + @title = 詹姆斯·韦布 主天线 + @description = 詹姆斯·韦布主天线由一个KA波段高增益天线和一个S波段中增益天线组成,这两个天线都安装在一个通用的铰接平台上。天线安装在詹姆斯·韦布的侧面和后部。 @MODULE[ModuleDeployableAntenna]:HAS[#animationName[Deploy]] { @@ -37,20 +37,20 @@ @PART[JWST-RCSThrusters]:NEEDS[JamesWebb] { - @title = 詹姆斯·韦伯 RCS推进器 - @description = 8个 RCS 推进器为詹姆斯·韦伯提供了扭矩。每个推进器由 2 个的 Y 轴方向的推进器和一个过 Z 轴方向中心的推进器组成。两两成对放置在基础结构底座的每一个角落。 + @title = 詹姆斯·韦布 RCS推进器 + @description = 8个 RCS 推进器为詹姆斯·韦布提供了扭矩。每个推进器由 2 个的 Y 轴方向的推进器和一个过 Z 轴方向中心的推进器组成。两两成对放置在基础结构底座的每一个角落。 } @PART[JWST-RearSolarPanel]:NEEDS[JamesWebb] { - @title = 詹姆斯·韦伯 背部太阳能电池板 - @description = 背部太阳能电池板满足了詹姆斯·韦伯空间望远镜的大部分电力需求。安装在基础结构的后面。 + @title = 詹姆斯·韦布 背部太阳能电池板 + @description = 背部太阳能电池板满足了詹姆斯·韦布空间望远镜的大部分电力需求。安装在基础结构的后面。 } @PART[JWST-SideAntenna]:NEEDS[JamesWebb] { - @title = 詹姆斯·韦伯 侧面天线 - @description = 那些穿黑色西装的坎巴拉人说这是必要的,所以它应该安装在詹姆斯·韦伯主天线的对面。当时没人质疑为什么要这样做。 + @title = 詹姆斯·韦布 侧面天线 + @description = 那些穿黑色西装的坎巴拉人说这是必要的,所以它应该安装在詹姆斯·韦布主天线的对面。当时没人质疑为什么要这样做。 // @MODULE[ModuleDeployableAntenna] // { @@ -62,8 +62,8 @@ @PART[JWST-SidePanels]:NEEDS[JamesWebb] { - @title = 詹姆斯·韦伯 侧面太阳能板 - @description = 四块有助于满足詹姆斯·韦伯的电力需求,可以让其充分发挥作用。这些应该安装在基础结构的 4 个侧面的安装点。 + @title = 詹姆斯·韦布 侧面太阳能板 + @description = 四块有助于满足詹姆斯·韦布的电力需求,可以让其充分发挥作用。这些应该安装在基础结构的 4 个侧面的安装点。 @MODULE[ModuleDeployableSolarPanel] { diff --git a/GameData/0000Tinygrox_CNPatches/NearFutureElectrical/ZH_NearFutureElectrical.cfg b/GameData/0000Tinygrox_CNPatches/NearFutureElectrical/ZH_NearFutureElectrical.cfg new file mode 100644 index 0000000..228c05a --- /dev/null +++ b/GameData/0000Tinygrox_CNPatches/NearFutureElectrical/ZH_NearFutureElectrical.cfg @@ -0,0 +1,105 @@ +Localization +{ + zh-cn + { + #LOC_NFElectrical_reactor_switcher_mount_compact = 紧凑 // Compact + #LOC_NFElectrical_reactor_switcher_compact_summary = 紧凑型 // Compact Mount + #LOC_NFElectrical_reactor_switcher_compact_detail = 紧凑型底座 // A compact, minimum footprint mount. + #LOC_NFElectrical_reactor_switcher_mount_compactexposed = 紧凑(裸露) // Compact (Exposed) + #LOC_NFElectrical_reactor_switcher_compactexposed_summary = 紧凑型裸露在外底座 // Compact Exposed Mount + #LOC_NFElectrical_reactor_switcher_compactexposed_detail = 将所有内部细节暴露在外的紧凑型底座 // A compact, minimum footprint mount that shows off all the internal bits. + #LOC_NFElectrical_reactor_switcher_mount_0625 = 0.625m + #LOC_NFElectrical_reactor_switcher_0625_summary = 0.625米底座 // 0.625m Mount + #LOC_NFElectrical_reactor_switcher_0625_detail = 适用于0.625米大小的环形底座 // A ring mount in the 0.625m size category + #LOC_NFElectrical_reactor_switcher_mount_0625_radiators = 0.625m(散热) // 0.625m (Radiator) + #LOC_NFElectrical_reactor_switcher_0625_radiators_summary = 带散热的0.625m底座 // 0.625m Mount with Radiator + #LOC_NFElectrical_reactor_switcher_0625_radiators_detail = 内置散热装置,电力供应自给自足。适用于0.625m大小的环形底座 // Add an integrated radiator, making this power system self-contained. Includes a ring mount in the 0.625m size category + #LOC_NFElectrical_reactor_switcher_mount_125 = 1.25m + #LOC_NFElectrical_reactor_switcher_125_summary = 1.25米底座 // 1.25m Mount + #LOC_NFElectrical_reactor_switcher_125_detail = 适用于1.25米大小的环形底座 // A ring mount in the 1.25m size category + #LOC_NFElectrical_reactor_switcher_mount_1875 = 1.875m + #LOC_NFElectrical_reactor_switcher_1875_summary = 1.875米底座 // 1.875m Mount + #LOC_NFElectrical_reactor_switcher_1875_detail = 适用于1.875米大小的环形底座 // A ring mount in the 1.875m size category + #LOC_NFElectrical_reactor_switcher_mount_25 = 2.5m + #LOC_NFElectrical_reactor_switcher_25_summary = 2.5米底座 // 2.5m Mount + #LOC_NFElectrical_reactor_switcher_25_detail = 适用于2.5米大小的环形底座 // A ring mount in the 2.5m size category + #LOC_NFElectrical_reactor_switcher_mount_375 = 3.75m + #LOC_NFElectrical_reactor_switcher_375_summary = 3.75米底座 // 3.75m Mount + #LOC_NFElectrical_reactor_switcher_375_detail = 适用于3.75米大小的环形底座 // A ring mount in the 3.75m size category + + #LOC_NFElectrical_nfe-reactor-tiny-1_title = MN-1 '斯纳克'裂变反应堆 // MN-1 'SNAK' Fission Reactor + #LOC_NFElectrical_nfe-reactor-tiny-1_description = 这个小型的入门级微型反应堆能提供源源不断的电力供应,这是那些非极致工艺的RTG所不能及的。但是,发电效率较低,因为使用的原理是简单的热电转换。 // This small entry level micro-reactor provides a good supply of continuous power that is hard to achieve with any but the best RTGs. However, it isn't very efficient as it uses simple thermoelectric energy conversion. + // #LOC_NFElectrical_nfe-reactor-tiny-1_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission snap + + #LOC_NFElectrical_nfe-reactor-tiny-2_title = MN-2 '坎巴拉电力'裂变反应堆 // MN-2 'Kerbopower' Fission Reactor + #LOC_NFElectrical_nfe-reactor-tiny-2_description = 一个更接近现代工艺的微型核反应堆,坎巴拉电力使用一个卫生纸卷大小的反应堆核心(注意:不要用卫生纸卷进行更换)和几个小型斯特林发动机。 // A more modern approach to micro-reactors, the KerboPower delivers a good baseline current for running small ships and bases using a toilet-paper roll sized reactor core (note: do not replace with actual toilet paper) and a few small Stirling pistons. + // #LOC_NFElectrical_nfe-reactor-tiny-2_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission kilopower + + #LOC_NFElectrical_nfe-reactor-0625-1_title = MX-0 '吐司'裂变反应堆 // MX-0 'Toaster' Fission Reactor + #LOC_NFElectrical_nfe-reactor-0625-1_description = 我们现在开始认真对待了!这个反应堆足以供给电力推进所需的电力以及满足大多数空间站地面基地的电力需求。采用了先进的双面斯特林转换器,可同时烤制两块面包。 // Now we're getting serious! This reactor is sufficient for more effective electrical propulsion and most space and ground needs, and uses advanced double-sided Stirling converters for to toast up to two pieces of bread at once. + // #LOC_NFElectrical_nfe-reactor-0625-1_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission fsps + + #LOC_NFElectrical_nfe-reactor-125-1_title = MX-1 '石榴石'裂变反应堆 // MX-1 'Garnet' Fission Reactor + #LOC_NFElectrical_nfe-reactor-125-1_description = MX-1安置了大量的电能转换装置,增大了MX系列的电流,为终端用户提供可观的充足电力。 // The MX-1 steps up the current in the MX series with a lot of power conversion modules, supplying a decent amount of power for end-user use. + // #LOC_NFElectrical_nfe-reactor-125-1_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission + + #LOC_NFElectrical_nfe-reactor-1875-1_title = MX-1B '普罗米修斯'裂变反应堆 // MX-1B 'Prometheus' Fission Reactor + #LOC_NFElectrical_nfe-reactor-1875-1_description = 普罗米修斯:为坎巴拉人带来核种。这句话从宣传手册上摘录。这个强劲的反应堆安装了2个布雷顿发动机,产出的电力足够任你在任何场景下使用。 // Prometheus: bringing nuclear fire to the Kerbals. That's straight out of the marketing brochure. This potent reactor is coupled with two Brayton turbines to deliver utility-scale nuclear power to whatever you want. + // #LOC_NFElectrical_nfe-reactor-1875-1_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission + + #LOC_NFElectrical_nfe-reactor-25-1_title = MX-2C '海伯利安'裂变反应堆 // MX-2C 'Hyperion' Fission Reactor + #LOC_NFElectrical_nfe-reactor-25-1_description = 更大、更好,一般来说也更强。这个反应堆装有4个更大的布雷顿发动机,能为你提供更多的电力供应,记得带上大量的散热装置。 // Bigger, better, generally more powerful, this reactor packs four larger Brayton cycle turbines to give you more useable energy. Don't forget to pack a bunch of radiators. + // #LOC_NFElectrical_nfe-reactor-25-1_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission + + #LOC_NFElectrical_nfe-reactor-25-2_title = MX-2L '亚瑟王之剑'裂变反应堆 // MX-2L 'Excalibur' Fission Reactor 肯定是不会翻译成咖喱棒的呀 + #LOC_NFElectrical_nfe-reactor-25-2_description = 将温度更高的反应堆芯和卡特彼勒1PO磁流体发电机相结合提高了:更高的热利用率和发电量。同时,非常非常安静。 // Coupling a higher-temperature reactor core with Caterpillar 1PO magnetohydrodynamic generators allows a functional increase in efficiency: more power for your thermal watt. Also very, very quiet. + // #LOC_NFElectrical_nfe-reactor-25-2_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission + + #LOC_NFElectrical_nfe-reactor-375-1_title = MX-3L '赫尔墨斯'裂变反应堆 // MX-3L 'Hermes' Fission Reactor + #LOC_NFElectrical_nfe-reactor-375-1_description = 据工程师所言,只要再将核技术提升一个数量级,我们就能够用电推实现30天内到达Duna。 // Scaling up nuclear technology by another order of magnitude, engineers say that this is about were we need to be to get to Duna in 30 days with electric engines. + // #LOC_NFElectrical_nfe-reactor-375-1_tags = active atom charge e/c elect energ generat nuclear nuke power thermo volt watt reactor nearfuture fission hermes + + + // RTG + #LOC_NFElectrical_nfe-rtg-asrg-1_title = PB-SRG高级放射性同位素发电机 // PB-SRG Advanced Radioisotope Generator + #LOC_NFElectrical_nfe-rtg-asrg-1_description = 通过逆向Post-Kebin公司的发电机,离子质子电子交响乐公司的工程师得以完善工艺,对钚-238的消耗更少,同时提高了能力转换效率,每1美元所发的电量现在大大提高。 // Using less Blutonium-238 per unit power and a more efficient energy conversion system based on technology reverse engineered from a Post-Kerbin generator, engineers at Ionic Symphonic have perfected this advanced RTG that delivers a much better electricity rate per dollar. + // #LOC_NFElectrical_nfe-rtg-asrg-1_tags = active atom charge e/c elect energ generat isotope nuclear nuke power radio rtg stiring thermo volt watt nearfutureasrg + + #LOC_NFElectrical_nfe-rtg-gphs-1_title = PB-NUK-II放射性同位素发电机 // PB-NUK-II Radioisotope Generator + #LOC_NFElectrical_nfe-rtg-gphs-1_description = 如果原型机获得成功,那么后续的系列产品也会随之产生。PB-NUK系列的第二个产品其实只是外形更大而已,一般的批评描述为“缺乏创新”、“多余”以及“抢钱”。 // If the original is a susccess, you can bet on a sequel. The second entry in the PB-NUK is really just larger, and has been described by critics as 'derivative', 'unnecessary' and 'a real cash-grab'. + // #LOC_NFElectrical_nfe-rtg-gphs-1_tags = active atom charge e/c elect energ generat isotope nuclear nuke power radio rtg stiring thermo volt watt nearfuture galileo new horizons gphs + + #LOC_NFElectrical_nfe-rtg-mmrtg-1_title = PB-NUK-III放射性同位素发电机 // PB-NUK-III Radioisotope Generator + #LOC_NFElectrical_nfe-rtg-mmrtg-1_description = 开发第三个产品真的有必要吗?但无论如何,产品名称使用了令人印象深刻的罗马数字3命名,通过影院和流媒体的双线联合营销模式,再在财务报表上发挥创意,现在这款产品对外是价钱公道,质量上乘。 // Was a third entry really necessary? Regardless, the V3 uses impressive Roman numerals and a combination theatrical and streaming release of marketing materials to achieve better mass ratios and cost ratios through the sheer power of creative accounting. + // #LOC_NFElectrical_nfe-rtg-mmrtg-1_tags = active atom charge e/c elect energ generat isotope nuclear nuke power radio rtg stiring thermo volt watt nearfuture curiosity opportunity mmrtg + + #LOC_NFElectrical_nfe-rtg-snap27-1_title = PB-ACK放射性同位素发电机 // PB-ACK Radioisotope Generator + #LOC_NFElectrical_nfe-rtg-snap27-1_description = 作为一款入门级产品,离子质子电子交响乐公司的销售团队将这款产品出售给坎巴拉航天中心的行为确实有点出乎意料,但如果你对发电要求不高,并且对抗撞击能力没什么要求,那这款产品可能会适合你。 // Truly an entry-level product, the sales team at Ionic Symphonic have really outdone themselves by selling this one to the KSC team, but if you want a little trickle of power and are okay with taking a fairly significant mass hit, this could be for you. + // #LOC_NFElectrical_nfe-rtg-snap27-1_tags = active atom charge e/c elect energ generat isotope nuclear nuke power radio rtg stiring thermo volt watt nearfuture apollo snap27 + + /// LEGACY PARTS + + + // Reactors + #LOC_NFElectrical_reactor-0625_description = 已弃用 // deprecated + #LOC_NFElectrical_reactor-0625_tags = 已弃用 // deprecated + #LOC_NFElectrical_reactor-125_description = 已弃用 // deprecated + #LOC_NFElectrical_reactor-25_description = 已弃用 // deprecated + #LOC_NFElectrical_reactor-25_tags = 已弃用 // deprecated + #LOC_NFElectrical_reactor-25-2_tags = 已弃用 // deprecated + #LOC_NFElectrical_reactor-375_tags = 已弃用 // deprecated + #LOC_NFElectrical_reactor-375-2_description = 已弃用 // deprecated + #LOC_NFElectrical_reactor-375-2_tags = 已弃用 // deprecated + + + #LOC_NFElectrical_ModuleMultiJettison_Event_Fairing_Name = 整流罩 // Fairing + #LOC_NFElectrical_ModuleMultiJettison_Event_Fairing_Enabled = 启用 // Enabled + #LOC_NFElectrical_ModuleMultiJettison_Event_Fairing_Disabled = 禁用 // Disabled + + #LOC_NFElectrical_ModuleMultiJettison_Event_Jettision = 抛弃 // Jettison + + /// OTHER + + #LOC_NFE_Subcategory_capacitors = 电容器 // Capacitors + } +} diff --git a/GameData/0000Tinygrox_CNPatches/PlanetsideExplorationTechnologies/ZH_PlanetsideExplorationTechnologies.cfg b/GameData/0000Tinygrox_CNPatches/PlanetsideExplorationTechnologies/ZH_PlanetsideExplorationTechnologies.cfg index 4d5a179..ed67eaf 100644 --- a/GameData/0000Tinygrox_CNPatches/PlanetsideExplorationTechnologies/ZH_PlanetsideExplorationTechnologies.cfg +++ b/GameData/0000Tinygrox_CNPatches/PlanetsideExplorationTechnologies/ZH_PlanetsideExplorationTechnologies.cfg @@ -1268,7 +1268,7 @@ // Source/Modules/ModulePETAnimation.cs // Source/Modules/ModulePETTurbine.cs // 非完全翻译,完全翻译需要更改代码,可参考用户 @judicator 于 2021 年 4 月份提交的 PR:https://github.com/benjee10/Benjee10_MMSEV/pull/6 -Localization:NEEDS[Benjee10_MMSEV] +Localization { zh-cn { diff --git a/GameData/0000Tinygrox_CNPatches/RealAntennas/GroundStations.cfg b/GameData/0000Tinygrox_CNPatches/RealAntennas/GroundStations.cfg index ea31948..1502161 100644 --- a/GameData/0000Tinygrox_CNPatches/RealAntennas/GroundStations.cfg +++ b/GameData/0000Tinygrox_CNPatches/RealAntennas/GroundStations.cfg @@ -64,7 +64,7 @@ } -@Kopernicus:NEEDS[RealAntennas,Kopernicus,RealSolarSystem] +@Kopernicus:NEEDS[RealAntennas,Kopernicus,RealSolarSystem]:AFTER[RealAntennas] { @Body[Kerbin] { @@ -86,35 +86,35 @@ } @City2:HAS[#objectName[NIP?16?-?Evpatoria]] { - @objectName = NIP 16 - Evpatoria // NIP 16 - Evpatoria + @objectName = NIP 16 - 叶夫帕托里亚 // NIP 16 - Evpatoria } @City2:HAS[#objectName[NIP?15?-?Ussuriysk]] { - @objectName = NIP 15 - Ussuriysk // NIP 15 - Ussuriysk + @objectName = NIP 15 - 乌苏里斯克 // NIP 15 - Ussuriysk } @City2:HAS[#objectName[NIP?14?-?Shchelkovo]] { - @objectName = NIP 14 - Shchelkovo // NIP 14 - Shchelkovo + @objectName = NIP 14 - 希奇尔科沃 // NIP 14 - Shchelkovo } @City2:HAS[#objectName[ASF?-?Alaska?Satellite?Facility]] { - @objectName = ASF - Alaska Satellite Facility + @objectName = ASF - 阿拉斯加卫星设施 // ASF - Alaska Satellite Facility } @City2:HAS[#objectName[KSAT?-?Singapore]] { - @objectName = KSAT - Singapore + @objectName = KSAT - 新加坡 // KSAT - Singapore } @City2:HAS[#objectName[SSC?-?Santiago]] { - @objectName = SSC - Santiago + @objectName = SSC - 圣地亚哥 // SSC - Santiago } @City2:HAS[#objectName[SSC?-?Dongara]] { - @objectName = SSC - Dongara + @objectName = SSC - 当加拉 // SSC - Dongara } @City2:HAS[#objectName[SSC?-?South?Point]] { - @objectName = SSC - South Point + @objectName = SSC - 南点 // SSC - South Point } } } diff --git a/GameData/0000Tinygrox_CNPatches/Squad/ZH_Squad.cfg b/GameData/0000Tinygrox_CNPatches/Squad/ZH_Squad.cfg index 3838622..e5ab123 100644 --- a/GameData/0000Tinygrox_CNPatches/Squad/ZH_Squad.cfg +++ b/GameData/0000Tinygrox_CNPatches/Squad/ZH_Squad.cfg @@ -1,9 +1,16 @@ +// 注释的 “-” 左侧为英文原文, 右侧跟原版译文 Localization { zh-cn { + // 明显错译 —— 影响玩家游玩 #autoLOC_283371 = 让<<1>>过载昏迷 // Have <<1>> pass out from gee forces - 让<<1>>摆脱重力 #autoLOC_8003261 = 轴动作组 // Axis Groups - 动作绑定 + #autoLOC_6002550 = 在<<1>>表面完成探测车的组装 // Finish construction of a Rover on the surface of <<1>> - 在<<1>>表面建造一辆探测车 + + #autoLOC_6002674 = 转向调整:<<1[自动/手动]>> // 转向调整:<<1[Auto/Override]>> - Steering Adjust: <<1[Auto/Override]>> + #autoLOC_8002337 = <<1>>已产生<<2>>科技点。\n撞击能量对传感器读数的影响:<<3>>%\n距离衰减:<<4>>%\n部件产出率:<<5>>%\n已将<<6>>科技点回传到<<7>>。// <<1>> generated <<2>> science.\nSensor Readings affected by Impact Energy: <<3>>%\nDistance Attenuation: <<4>>%\nSetup: <<5>>%\n<<6>> Science Points transmitted back to <<7>> + #autoLOC_8002338 = <<1>>已产生<<2>>科技点。\n撞击能量对传感器读数的影响:<<3>>%\n距离衰减:<<4>>%\n部件产出率:<<5>>%\n已存储<<6>>科技点。目前没有连接,无法传输。// <<1>> generated <<2>> science.\nSensor Readings affected by Impact Energy: <<3>>%\nDistance Attenuation: <<4>>%\nSetup: <<5>>%\n<<6>> Science Points stored. No connection for transmission. // ------ 教程 ------ #autoLOC_312954 = 我们将在这个分级安装多个液体燃料箱,以达到上面级引擎所需的数量。我们还需要一个燃料箱承担RCS的重量。\n\n因此,先装一个微型火箭推进剂燃料箱(就是叫>>FL-T100燃料箱的那个),然后再在下面装一个中等大小的(>>FL-T400燃料箱)。 // We'll be adding multiple Liquid Fuel tanks in this stage to get the right amount for the upper stage engine [...] - 我们将在这个分级安装多个液体燃料箱,以达到上层分级引擎所需的数量 [...] @@ -86,12 +93,12 @@ Localization // ------ 旗帜的选项 ------ #autoLOC_6006060 = 纵向 // Portrait - 头像 - #autoLOC_6006061 = 横向 // Landscape - 风景 + #autoLOC_6006061 = 横向 // Landscape - 风景 #autoLOC_6011148 = 使用<<2>>发现<<1>>颗彗星。 // Detect <<1>> comets with a <<2>>. - 探测到<<1>>颗有着<<2>>的彗星。 - // 缺失词条 #autoLOC_6006021 = 载具将会低于地面。\n // Vessel would be below the surface.\n + } } diff --git a/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll b/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll index da3e6bb..cc8e65b 100644 Binary files a/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll and b/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/KSP_Chinese_Patches.dll differ diff --git a/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/OrbitPOInts.cfg b/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/OrbitPOInts.cfg new file mode 100644 index 0000000..329372a --- /dev/null +++ b/GameData/0000Tinygrox_CNPatches/_HarmonyCNPatches/OrbitPOInts.cfg @@ -0,0 +1,39 @@ +Localization +{ + zh-cn + { + #OrbitPOInts_Enabled = 启用 // Enabled + #OrbitPOInts_ForceRefresh = 强制刷新 // Force Refresh + #OrbitPOInts_FocusedBodyOnly = 仅对焦天体 // Focused Body Only + #OrbitPOInts_DrawSpheres = 球体显示 // Draw Spheres + #OrbitPOInts_AlignSpheres = 球体对齐 // Align Spheres + #OrbitPOInts_DrawCircles = 圈形显示 // Draw Circles + #OrbitPOInts_ShowPOIMaxTerrainAltitudeOnAtmoBodies = 在有大气天体上显示POI的最高地形高度 // Show POI Max Terrain Altitude On Atmospheric Bodies + #OrbitPOInts_RestPOIforBodies = 重置 <<1>> 的显示 // Reset POIs for <<1>> to defaults + #OrbitPOInts_ShowOptions = 显示设置 // Show Options + #OrbitPOInts_None = 无 // None + + #OrbitPOInts_HillSphere = 希尔球 // HillSphere + #OrbitPOInts_SphereOfInfluence = 引力范围 // SphereOfInfluence + #OrbitPOInts_Atmosphere = 大气层 // Atmosphere + #OrbitPOInts_MinimumOrbit = 最低轨道 // MinimumOrbit + #OrbitPOInts_MaxTerrainAltitude = 最高地形高度 // MaxTerrainAltitude + #OrbitPOInts_Custom = 自定义 // Custom + + #OrbitPOInts_Misc = 杂项 // Misc + #OrbitPOInts_EnableDebugLevelLogging = 记录调试信息日志 // Enable Debug Level Logging + #OrbitPOInts_UseSkin = 使用皮肤 // Use Skin + #OrbitPOInts_OpaqueBackground = 使用不透明背景 // Use Opaque Background Override + #OrbitPOInts_UseTopRightCloseButton = 关闭按钮在右上角 // Use Top Right Close Button + #OrbitPOInts_LClickToggleRClickSetting = 左键开关/右键设置 // Use LeftClick to toggle / RightClick for settings + #OrbitPOInts_DangerZoneTips = -- 谨慎使用 --(不会弹出确认且无法撤销) // -- Danger Zone -- (no confirmation and no undo) + #OrbitPOInts_ResetPOI = 重置所有标准POI设置 // Reset All Standard POIs to defaults + #OrbitPOInts_RemoveAllPOI = 移除所有自定义POI // Remove All Custom POIs + #OrbitPOInts_ColorPicker_Red = 红(R) // Red + #OrbitPOInts_ColorPicker_Green = 绿(G) // Green + #OrbitPOInts_ColorPicker_Blue = 蓝(B) // Blue + #OrbitPOInts_ColorPicker_Cancel = 取消 // Cancel + #OrbitPOInts_ColorPicker_Default = 默认 // Default + #OrbitPOInts_ColorPicker_Save = 保存 // Save + } +} diff --git a/README.md b/README.md index 920289c..030dd68 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ A collection of Module Manager patches for translating KSP Mods (Part mods mostl - **Benjee10 Suits\*** - 部件翻译和 2 个航天服的名称翻译 - **Benjee10 sharedAssets** - 部件翻译 - **ht Robotics** - 部件翻译 -- **Planetside Exploration Technologies\*** - 部件翻译 + 设置菜单翻译,看说明文件 +- **Planetside Exploration Technologies** - 部件翻译 + 设置菜单翻译,~~看说明文件~~ 硬编码文本已翻译(需要 Harmony) - **HabTech2** - 部件翻译 - **Moldavite Machines** - 本地化简中补充 - **Extraplanetary Launchpads\**** - 简中补充 @@ -110,6 +110,10 @@ A collection of Module Manager patches for translating KSP Mods (Part mods mostl - **HullcamVDS Continued** - 对新的摄像机部件进行翻译,以及 DLL 硬编码的 guiName 的翻译(需要Harmony) - **Through The Eyes of a Kerbal** - 并未翻译,而是一个修复Patch,修复了一个因为这个 Mod 而导致的报错 - **RasterPropMonitor Core(需要Harmony)** - 部分联动摄像机 Mod 的 guiName 相关的翻译 +- **Extraplanetary Launchpads(需要Harmony)** - 可以在其他星球搭建发射台建造火箭的Mod,Mod 很不错,但是我选择【SimpleConstruction!】。添加了内置硬编码文本的翻译 +- **OrbitPOInts(需要Harmony)** - 一个能在地图界面可视化星球的引力范围、大气高度等信息的Mod +- **Resource Overview(需要Harmony)** - 轻量型资源显示器。 +- **Near Future Electrical** - 补充新增的部件翻译 ## 许可协议 | License diff --git a/Source/KSP_Chinese_Patches/AvionicsSystemsPatches.cs b/Source/KSP_Chinese_Patches/AvionicsSystemsPatches.cs index 4a65ce1..a97de0f 100644 --- a/Source/KSP_Chinese_Patches/AvionicsSystemsPatches.cs +++ b/Source/KSP_Chinese_Patches/AvionicsSystemsPatches.cs @@ -1,15 +1,21 @@ using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; +using UnityEngine; namespace KSP_Chinese_Patches { - public class AvionicsSystemsPatches + public class AvionicsSystemsPatches : AbstractPatchBase { + public override string PatchName => "Avionics Systems"; + + public override string PatchDLLName => "AvionicsSystems"; + public static IEnumerable MASFlightComputerProxy_BodyBiome_Patch(IEnumerable codeInstructions, ILGenerator generator) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -54,5 +60,30 @@ public static IEnumerable MASVesselComputer_UpdateTarget_Patch( ; return matcher.InstructionEnumeration(); } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("AvionicsSystems.MASFlightComputerProxy"), "BodyBiome", new[] { typeof(object), typeof(double), typeof(double) }), + new HarmonyMethod(typeof(AvionicsSystemsPatches), nameof(AvionicsSystemsPatches.MASFlightComputerProxy_BodyBiome_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("AvionicsSystems.MASFlightComputerProxy"), "BodyName", new[] { typeof(object) }), + new HarmonyMethod(typeof(AvionicsSystemsPatches), nameof(AvionicsSystemsPatches.MASFlightComputerProxy_BodyName_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("AvionicsSystems.MASVesselComputer"), "UpdateTarget"), + new HarmonyMethod(typeof(AvionicsSystemsPatches), nameof(AvionicsSystemsPatches.MASVesselComputer_UpdateTarget_Patch)), + PatchType.Transpiler + ) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs b/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs index 95df234..5951ffe 100644 --- a/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs +++ b/Source/KSP_Chinese_Patches/B9PartSwithPatches.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -8,8 +9,12 @@ namespace KSP_Chinese_Patches { - public class B9PartSwithPatches + public class B9PartSwithPatches : AbstractPatchBase { + public override string PatchName => "B9 Part Switch"; + + public override string PatchDLLName => "B9PartSwitch"; + public static IEnumerable ModuleB9PartInfo_SetupGUI_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -110,5 +115,16 @@ public static IEnumerable ModuleB9PartInfo_SetupGUI_Patch(IEnum ); return matcher.InstructionEnumeration(); } + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("B9PartSwitch.ModuleB9PartInfo"), "SetupGUI"), + new HarmonyMethod(typeof(B9PartSwithPatches), nameof(B9PartSwithPatches.ModuleB9PartInfo_SetupGUI_Patch)), + PatchType.Transpiler + ) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/BetterBurnTimePatches.cs b/Source/KSP_Chinese_Patches/BetterBurnTimePatches.cs index 1b27c13..634680c 100644 --- a/Source/KSP_Chinese_Patches/BetterBurnTimePatches.cs +++ b/Source/KSP_Chinese_Patches/BetterBurnTimePatches.cs @@ -1,5 +1,6 @@ -using HarmonyLib; +using HarmonyLib; using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -9,7 +10,7 @@ namespace KSP_Chinese_Patches { - public class BetterBurnTimePatches + public class BetterBurnTimePatches : AbstractPatchBase { private static readonly string[] NEW_TIPS = new string[] { "正在计算更好的启动加速时间...", "正在预测撞击时间...", "正在预测接近时间...", "正在添加倒计时指示器..." }; private static readonly string GeosyncLabel = "同步轨道";// "gsync"; @@ -19,6 +20,11 @@ public class BetterBurnTimePatches private static readonly string FormatHoursMinutesSeconds = "{0}时{1}分{2}秒"; // "{0}h{1}m{2}s"; private static readonly string FormatHoursMinutes = "{0}时{1}分"; // "{0}h{1}m"; private static readonly string FormatHours = "{0}时"; // "{0}h"; + + public override string PatchName => "BetterBurnTime"; + + public override string PatchDLLName => "BetterBurnTime"; + public static IEnumerable AtmosphereTracker_CalculateEntryTime_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -103,7 +109,7 @@ public static IEnumerable ModuleEngineBurnTime_OnStart_Patch(IE new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), new CodeInstruction(OpCodes.Ldstr, "burnTimeDisplay"), new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), - new CodeInstruction(OpCodes.Ldstr, "启动加速时间"), + new CodeInstruction(OpCodes.Ldstr, "燃烧时间"), new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))) ); return matcher.InstructionEnumeration(); @@ -172,5 +178,77 @@ public static IEnumerable TimeFormatter_Patch(IEnumerable + { + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.AtmosphereTracker"), "CalculateEntryTime", new[] { typeof(Vessel), typeof(string).MakeByRefType() }), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.AtmosphereTracker_CalculateEntryTime_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.AtmosphereTracker"), "CalculateExitTime", new[] { typeof(Vessel), typeof(string).MakeByRefType() }), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.AtmosphereTracker_CalculateExitTime_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.AtmosphereTracker"), "Recalculate"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.AtmosphereTracker_Recalculate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.BetterBurnTime"), "LateUpdate"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.BetterBurnTime_LateUpdate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ClosestApproachTracker"), "LateUpdate"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ClosestApproachTracker_LateUpdate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ImpactTracker"), "Recalculate"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ImpactTracker_Recalculate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ImpactTracker"), "CalculateTimeToImpact"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ImpactTracker_CalculateTimeToImpact_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ModuleEngineBurnTime"), "OnStart"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ModuleEngineBurnTime_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ModuleEngineBurnTime"), "GetModuleTitle"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ModuleEngineBurnTime_GetModuleTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ModuleEngineBurnTime"), "GetPrimaryField"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ModuleEngineBurnTime_GetPrimaryField_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.SplashScreen"), "InsertTips", new[] { typeof(LoadingScreen.LoadingScreenState) }), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.SplashScreen_InsertTips_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.GeosyncTracker"), "LateUpdate"), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.GeosyncTracker_LateUpdate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.TimeFormatter"), "format", new[] { typeof(int) }), + new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.TimeFormatter_Patch)), + PatchType.Transpiler + ) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/CNPatchInit.cs b/Source/KSP_Chinese_Patches/CNPatchInit.cs index 55ab849..30bc882 100644 --- a/Source/KSP_Chinese_Patches/CNPatchInit.cs +++ b/Source/KSP_Chinese_Patches/CNPatchInit.cs @@ -1,6 +1,8 @@ using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; @@ -24,571 +26,33 @@ public void Start() StaticMethods.sb.AppendLine($"[KSPCNPatches] DLLName: {a.Key} | Version: ({a.Value.Major}.{a.Value.Minor}.{a.Value.Build}.{a.Value.Revision})"); } Debug.Log(StaticMethods.sb); + Harmony.DEBUG = true; #endif if (!StaticMethods.IsAssemblyLoaded("0Harmony")) { - Debug.Log("[KSPCNPatches] 未发现安装有 Harmony2! DLL相关的汉化失效!"); + UnityEngine.Debug.Log("[KSPCNPatches] 未发现安装有 Harmony2! DLL相关的汉化失效!"); return; } - + Stopwatch Clock = Stopwatch.StartNew(); Harmony har = new Harmony("tinygrox.ChinesePatches"); - if (StaticMethods.IsAssemblyLoaded("WhereCanIGo")) - { - Debug.Log("[KSPCNPatches] 已找到 [Where Can I Go]! 应用翻译..."); - har.Patch( - //original: AccessTools.TypeByName("WhereCanIGo.WhereCanIGoEditor").GetMethod("GenerateDialog", BindingFlags.NonPublic), - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoEditor"), "GenerateDialog"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoEditor"), "GetDeltaVString"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoFlight"), "GenerateDialog"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoFlight"), "GetDeltaVString"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.Utilities"), "SituationValid"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.Utilities"), "VesselStatus"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.Utilities"), "GetTextColor"), - transpiler: new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch))); - } - if (StaticMethods.IsAssemblyLoaded("SmartStage")) - { - Debug.Log("[KSPCNPatches] 已找到 [Smart Stage]! 应用翻译..."); - har.Patch - ( - original: AccessTools.Constructor( - AccessTools.TypeByName("SmartStage.AscentPlot"), - new[] { - typeof(List<>).MakeGenericType(AccessTools.TypeByName("SmartStage.Sample")), - typeof(List<>).MakeGenericType(AccessTools.TypeByName("SmartStage.StageDescription")), - typeof(int), - typeof(int) - }), - transpiler: new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.AscentPlotLocPatch)) - ); - - var SmartStageType = AccessTools.TypeByName("SmartStage.MainWindow"); - - har.Patch( - original: AccessTools.Method(SmartStageType, "OnGUI"), - transpiler: new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_OnGUILocPatch)) - ); - - har.Patch( - original: AccessTools.Method(SmartStageType, "drawStagesWindow", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_drawStagesWindowLocPatch)) - ); - har.Patch( - original: AccessTools.Method(SmartStageType, "drawWindow", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_drawWindowLocPatch)) - ); - har.Patch( - original: AccessTools.Method(SmartStageType, "m__0", new[] { typeof(CelestialBody) }), - transpiler: new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_PlanetDisplayNamePatch)) - ); - } - if (StaticMethods.IsAssemblyLoaded("RealAntennas", new Version(2, 6, 0))) - { - Debug.Log("[KSPCNPatches] 已找到 [RealAntennas]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "OnAwake"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.OnAwakePatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]OnAwake 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "RecalculateFields"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RecalculateFieldsLocPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]RecalculateFields 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "PermanentShutdownEvent"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PermanentShutdownEventLocPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]PermanentShutdownEvent 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "ApplyTLColoring"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.ApplyTLColoringLocPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]ApplyTLColoring 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "GetInfo"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.GetInfoLocPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]GetInfo 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "OnGUI"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_OnGUILocPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]OnGUI 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "GUIDisplay", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_GUIDisplayLocPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]GUIDisplay 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI+<>c"), "b__44_0", new[] { typeof(CelestialBody) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_GetDisplayNamePatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]b__44_0 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "RenderPanel"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_RenderPanelPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]RenderPanel 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "FireOnce"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_FireOncePatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]FireOnce 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.RACommNetScenario+d__35"), "MoveNext"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_NotifyDisabledPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]NotifyDisabled 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.RealAntennasUI"), "WindowGUI", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RealAntennasUI_WindowGUIPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]WindowGUI 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.TechLevelInfo"), "ToString"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.TechLevelInfo_ToStringPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]TechLevelInfo 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.MapUI.NetUIConfigurationWindow"), "WindowGUI", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.NetUIConfigurationWindow_WindowGUIPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]NetUIConfigurationWindow_WindowGUI 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.MapUI.SignalToolTipController"), "UpdateList"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.UpdateList_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]UpdateList 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Network.ConnectionDebugger"), "OnGUI"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.ConnectionDebugger_OnGUI_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]ConnectionDebugger_OnGUI 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Network.ConnectionDebugger"), "GUIDisplay", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.ConnectionDebugger_GUIDisplay_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]ConnectionDebugger_GUIDisplay 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.AntennaTargetGUI"), "OnGUI"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.AntennaTargetGUI_OnGUI_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]AntennaTargetGUI_OnGUI 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.AntennaTargetGUI"), "GUIDisplay", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.AntennaTargetGUI_GUIDisplay_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]AntennaTargetGUI_GUIDisplay 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.RemoteAntennaControlUI"), "OnGUI"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RemoteAntennaControlUI_OnGUI_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]RemoteAntennaControlUI_OnGUI 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.RemoteAntennaControlUI"), "GUIDisplay", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RemoteAntennaControlUI_GUIDisplay_Patch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]RemoteAntennaControlUI_GUIDisplay 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("RealAntennas.Antenna.Encoder"), "ToString"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.Encoder_ToStringPatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]Encoder_ToString 已应用!"); - - har.Patch( - original: AccessTools.PropertyGetter(AccessTools.TypeByName("RealAntennas.RAParameters"), "Title"), - transpiler: new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RA_SettingTitlePatch))); - Debug.Log("\t[KSPCNPatches] [RealAntennas]RealAntennas.RAParameters get_Title 已应用!"); - - } - if (StaticMethods.IsAssemblyLoaded("BetterBurnTime")) - { - Debug.Log("[KSPCNPatches] 已找到 [BetterBurnTime]! 应用翻译..."); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.AtmosphereTracker"), "CalculateEntryTime", new[] { typeof(Vessel), typeof(string).MakeByRefType() }), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.AtmosphereTracker_CalculateEntryTime_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]AtmosphereTracker_CalculateEntryTime 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.AtmosphereTracker"), "CalculateExitTime", new[] { typeof(Vessel), typeof(string).MakeByRefType() }), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.AtmosphereTracker_CalculateExitTime_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]AtmosphereTracker_CalculateExitTime 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.AtmosphereTracker"), "Recalculate"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.AtmosphereTracker_Recalculate_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]AtmosphereTracker_Recalculate 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.BetterBurnTime"), "LateUpdate"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.BetterBurnTime_LateUpdate_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]BetterBurnTime_LateUpdate 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ClosestApproachTracker"), "LateUpdate"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ClosestApproachTracker_LateUpdate_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]ClosestApproachTracker_LateUpdate 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ImpactTracker"), "Recalculate"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ImpactTracker_Recalculate_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]ImpactTracker_Recalculate 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ImpactTracker"), "CalculateTimeToImpact"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ImpactTracker_CalculateTimeToImpact_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]ImpactTracker_CalculateTimeToImpact 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ModuleEngineBurnTime"), "OnStart"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ModuleEngineBurnTime_OnStart_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]ModuleEngineBurnTime_OnStart 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ModuleEngineBurnTime"), "GetModuleTitle"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ModuleEngineBurnTime_GetModuleTitle_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]ModuleEngineBurnTime_GetModuleTitle 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.ModuleEngineBurnTime"), "GetPrimaryField"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.ModuleEngineBurnTime_GetPrimaryField_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]ModuleEngineBurnTime_GetPrimaryField 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.SplashScreen"), "InsertTips", new[] { typeof(LoadingScreen.LoadingScreenState) }), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.SplashScreen_InsertTips_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]SplashScreen_InsertTips_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.GeosyncTracker"), "LateUpdate"), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.GeosyncTracker_LateUpdate_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]GeosyncTracker_LateUpdate 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("BetterBurnTime.TimeFormatter"), "format", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(BetterBurnTimePatches), nameof(BetterBurnTimePatches.TimeFormatter_Patch))); - Debug.Log("\t[KSPCNPatches] [BetterBurnTime]TimeFormatter_format 已应用!"); - } - if (StaticMethods.IsAssemblyLoaded("B9PartSwitch")) - { - Debug.Log("[KSPCNPatches] 已找到 [B9PartSwitch]! 应用翻译..."); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("B9PartSwitch.ModuleB9PartInfo"), "SetupGUI"), - transpiler: new HarmonyMethod(typeof(B9PartSwithPatches), nameof(B9PartSwithPatches.ModuleB9PartInfo_SetupGUI_Patch))); - Debug.Log("\t[KSPCNPatches] [B9PartSwitch]ModuleB9PartInfo_SetupGUI 已应用!"); - } - if (StaticMethods.IsAssemblyLoaded("PhysicsRangeExtender")) - { - Debug.Log("[KSPCNPatches] 已找到 [PhysicsRangeExtender]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DisableMod", new[] { typeof(float) }), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DisableMod_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]DisableMod已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawCamFixMultiplier", new[] { typeof(float) }), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawCamFixMultiplier_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]DrawCamFixMultiplier已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawGlobalVesselRange", new[] { typeof(float) }), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawGlobalVesselRange_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]DrawGlobalVesselRange已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawSaveButton", new[] { typeof(float) }), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawSaveButton_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]DrawSaveButton已应用!"); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawTitle"), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawTitle_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]DrawTitle已应用!"); + var PatchTypes = Assembly.GetExecutingAssembly().GetTypes().Where(t => typeof(AbstractPatchBase).IsAssignableFrom(t) && !t.IsAbstract); + List Patches = new List(); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.PhysicsRangeExtender"), "UpdateNearClipPlane"), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.PhysicsRangeExtender_UpdateNearClipPlane_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]UpdateNearClipPlane 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.PhysicsRangeExtender"), "UnloadLandedVessels"), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.PhysicsRangeExtender_UnloadLandedVessels_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]UnloadLandedVessels 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.TerrainExtender"), "ShowMessageTerrainStatus"), - transpiler: new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.TerrainExtender_ShowMessageTerrainStatus_Patch))); - Debug.Log("\t[KSPCNPatches] [PhysicsRangeExtender]ShowMessageTerrainStatus 已应用!"); - } - if (StaticMethods.IsAssemblyLoaded("[x]_Science!")) + foreach (Type patchType in PatchTypes) { - Debug.Log("[KSPCNPatches] 已找到 [[x] Science!]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.Body"), "FigureOutType"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.Body_FigureOutType_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]Body_FigureOutType_Patch 已应用!"); - - har.Patch( - original: AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.HelpWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.HelpWindow_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]HelpWindow_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.HelpWindow"), "DrawWindowContents", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.HelpWindow_DrawWindowContents_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]HelpWindow_DrawWindowContents_Patch 已应用!"); - - har.Patch( - original: AccessTools.PropertyGetter(AccessTools.TypeByName("ScienceChecklist.ScienceInstance"), "Description"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceInstance_Description_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ScienceInstance_Description_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ScienceWindow"), "Draw"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceWindow_Draw_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ScienceWindow_Draw_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ScienceWindow"), "DrawControls", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceWindow_DrawControls_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ScienceWindow_DrawControls_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ScienceWindow"), "DrawTitleBarButtons", new[] { typeof(Rect), typeof(bool) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceWindow_DrawTitleBarButtons_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ScienceWindow_DrawTitleBarButtons_Patch 已应用!"); - - har.Patch( - original: AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.SettingsWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.SettingsWindow_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]SettingsWindow_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.SettingsWindow"), "DrawWindowContents", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.SettingsWindow_DrawWindowContents_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]SettingsWindow_DrawWindowContents_Patch 已应用!"); - - har.Patch( - original: AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.ShipStateWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ShipStateWindow_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ShipStateWindow_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ShipStateWindow"), "DrawBody"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ShipStateWindow_DrawBody_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ShipStateWindow_DrawBody_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ShipStateWindow"), "DrawVessel"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ShipStateWindow_DrawVessel_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ShipStateWindow_DrawVessel_Patch 已应用!"); - - har.Patch( - original: AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.Situation"), new[] { AccessTools.TypeByName("ScienceChecklist.Body"), typeof(ExperimentSituations), typeof(string), typeof(string) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.Situation_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ShipStateWindow_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.Situation"), "ToString", new[] { typeof(ExperimentSituations) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.Situation_ToString_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]Situation_ToString_Patch 已应用!"); - - har.Patch( - original: AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]StatusWindow_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "DrawExperiment", new[] { AccessTools.TypeByName("ScienceChecklist.ScienceInstance"), typeof(Rect) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_DrawExperiment_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]StatusWindow_DrawExperiment_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "DrawWindowContents", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_DrawWindowContents_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]StatusWindow_DrawWindowContents_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "MakeSituationToolTip"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_MakeSituationToolTip_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]StatusWindow_MakeSituationToolTip_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "UpdateSituation"), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_UpdateSituation_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]StatusWindow_UpdateSituation_Patch 已应用!"); - - har.Patch( - original: AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.xResourceData"), new[] { typeof(string) }), - transpiler: new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ResourcesName_Patch))); - Debug.Log("\t[KSPCNPatches] [[x] Science!]ResourcesName_Patch 已应用!"); + if (Activator.CreateInstance(patchType) is AbstractPatchBase PatchInstance) + Patches.Add(PatchInstance); } - #region * DPAI 翻译相关 - if (StaticMethods.IsAssemblyLoaded("DockingPortAlignmentIndicator")) + foreach (AbstractPatchBase patch in Patches) { - Debug.Log("[KSPCNPatches] 已找到 [DockingPortAlignmentIndicator]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "loadTextures"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_loadTexturesPatches_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_loadTexturesPatches_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawIndicatorContentsToTexture"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawIndicatorContentsToTexture_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_drawIndicatorContentsToTexture_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.BitmapFont"), "buildGlyphs"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.Bitmap_FontbuildGlyphs_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]Bitmap_FontbuildGlyphs_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.BitmapFont"), "getGlyphFromID", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.Bitmap_getGlyphFromID_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]Bitmap_getGlyphFromID_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "createBlizzyButton"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_createBlizzyButton_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_createBlizzyButton_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "determineTargetPortName"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_determineTargetPortName_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_determineTargetPortName_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawRenderedGaugeTexture", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawRenderedGaugeTexture_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_drawRenderedGaugeTexture_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawRPMText", new[] { typeof(int), typeof(int) }), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawRPMText_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_drawRPMText_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawSettingsWindowContents", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawSettingsWindowContents_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_drawSettingsWindowContents_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "getReferencePortName"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_getReferencePortName_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_getReferencePortName_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "onGaugeDraw"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_onGaugeDraw_Patch))); - Debug.Log("\t[KSPCNPatches] [DockingPortAlignmentIndicator]DPAI_onGaugeDraw_Patch 已应用!"); - } - if (StaticMethods.IsAssemblyLoaded("moduledockingnodenamed")) - { - Debug.Log("[KSPCNPatches] 已找到 [moduledockingnodenamed]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.ModuleDockingNodeNamed"), "OnAwake"), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.ModuleDockingNodeNamed_OnAwake_Patch))); - Debug.Log("\t[KSPCNPatches] [moduledockingnodenamed]ModuleDockingNodeNamed_OnAwake_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.RenameWindow"), "DisplayForNode", new[] { AccessTools.TypeByName("NavyFish.ModuleDockingNodeNamed") }), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.ModuleDockingNodeNamed_DisplayForNode_Patch))); - Debug.Log("\t[KSPCNPatches] [moduledockingnodenamed]ModuleDockingNodeNamed_DisplayForNode_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("NavyFish.RenameWindow"), "onRenameDialogDraw", new[] { typeof(int) }), - transpiler: new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.ModuleDockingNodeNamed_onRenameDialogDraw_Patch))); - Debug.Log("\t[KSPCNPatches] [moduledockingnodenamed]ModuleDockingNodeNamed_onRenameDialogDraw_Patch 已应用!"); - } - #endregion - - if (StaticMethods.IsAssemblyLoaded("HullcamVDSContinued")) - { - Debug.Log("[KSPCNPatches] 已找到 [HullcamVDSContinued]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterBlackAndWhiteFilm"), "OptionControls"), - transpiler: new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterBlackAndWhiteFilm_OptionControls_Patch))); - Debug.Log("\t[KSPCNPatches] [HullcamVDSContinued]CameraFilterBlackAndWhiteFilm_OptionControls_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterColorFilm"), "OptionControls"), - transpiler: new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterColorFilm_OptionControls_Patch))); - Debug.Log("\t[KSPCNPatches] [HullcamVDSContinued]CameraFilterColorFilm_OptionControls_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterColorHiResTV"), "OptionControls"), - transpiler: new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterColorHiResTV_OptionControls_Patch))); - Debug.Log("\t[KSPCNPatches] [HullcamVDSContinued]CameraFilterColorHiResTV_OptionControls_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterColorLoResTV"), "OptionControls"), - transpiler: new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterColorLoResTV_OptionControls_Patch))); - Debug.Log("\t[KSPCNPatches] [HullcamVDSContinued]CameraFilterColorLoResTV_OptionControls_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterNightVision"), "OptionControls"), - transpiler: new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterNightVision_OptionControls_Patch))); - Debug.Log("\t[KSPCNPatches] [HullcamVDSContinued]CameraFilterNightVision_OptionControls_Patch 已应用!"); - } - - if (StaticMethods.IsAssemblyLoaded("RasterPropMonitor")) - { - Debug.Log("[KSPCNPatches] 已找到 [RasterPropMonitor]! 应用翻译..."); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("JSI.JSIExternalCameraSelector"), "OnAwake"), - transpiler: new HarmonyMethod(typeof(RasterPropMonitorPatches), nameof(RasterPropMonitorPatches.JSIExternalCameraSelector_OnAwake_Patch))); - Debug.Log("\t[KSPCNPatches] [RasterPropMonitor]JSIExternalCameraSelector_OnAwake_Patch 已应用!"); + patch.ApplyPatches(har); } - if (StaticMethods.IsAssemblyLoaded("ThroughTheEyes", new Version(2, 0, 4))) - { - Debug.Log("[KSPCNPatches] 已找到 [ThroughTheEyes]! 执行修复 Patch..."); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("FirstPerson.EVABoundFix"), "Hook"), - transpiler: new HarmonyMethod(typeof(ThroughTheEyesPatches), nameof(ThroughTheEyesPatches.EVABoundFix_Hook_Patch))); - Debug.Log("\t[KSPCNPatches] [RasterPropMonitor]EVABoundFix_Hook_Patch 已应用!"); - } - if (StaticMethods.IsAssemblyLoaded("AvionicsSystems")) - { - Debug.Log("[KSPCNPatches] 已找到 [AvionicsSystems]! 应用翻译..."); - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("AvionicsSystems.MASFlightComputerProxy"), "BodyBiome", new[] { typeof(object), typeof(double), typeof(double) }), - transpiler: new HarmonyMethod(typeof(AvionicsSystemsPatches), nameof(AvionicsSystemsPatches.MASFlightComputerProxy_BodyBiome_Patch))); - Debug.Log("\t[KSPCNPatches] [AvionicsSystems]MASFlightComputerProxy_BodyBiome_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("AvionicsSystems.MASFlightComputerProxy"), "BodyName", new[] { typeof(object) }), - transpiler: new HarmonyMethod(typeof(AvionicsSystemsPatches), nameof(AvionicsSystemsPatches.MASFlightComputerProxy_BodyName_Patch))); - Debug.Log("\t[KSPCNPatches] [AvionicsSystems]MASFlightComputerProxy_BodyName_Patch 已应用!"); - - har.Patch( - original: AccessTools.Method(AccessTools.TypeByName("AvionicsSystems.MASVesselComputer"), "UpdateTarget"), - transpiler: new HarmonyMethod(typeof(AvionicsSystemsPatches), nameof(AvionicsSystemsPatches.MASVesselComputer_UpdateTarget_Patch))); - Debug.Log("\t[KSPCNPatches] [AvionicsSystems]MASVesselComputer_UpdateTarget_Patch 已应用!"); - } + Clock.Stop(); + UnityEngine.Debug.Log($"[KSPCNPatches] Patch 全部运行完毕!共翻译了 {StaticMethods.PatchedModCount} 个 Mod,跳过了 {Patches.Count - StaticMethods.PatchedModCount} 个 Mod。总耗时:{Clock.Elapsed.TotalSeconds:F2}秒"); Destroy(this); } } diff --git a/Source/KSP_Chinese_Patches/DPAIPatches.cs b/Source/KSP_Chinese_Patches/DPAIPatches.cs index b327d1f..80bd124 100644 --- a/Source/KSP_Chinese_Patches/DPAIPatches.cs +++ b/Source/KSP_Chinese_Patches/DPAIPatches.cs @@ -1,6 +1,7 @@ -using HarmonyLib; +using HarmonyLib; using KSP.IO; using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -11,9 +12,14 @@ namespace KSP_Chinese_Patches { - public class DPAIPatches + public class DPAIPatches : AbstractPatchBase { public static int GlyphMaxLength = 65535; + + public override string PatchName => "Docking Port Alignment Indicator"; + + public override string PatchDLLName => "DockingPortAlignmentIndicator"; + public static IEnumerable DPAI_loadTexturesPatches_Patch(IEnumerable codeInstructions) { //CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -214,5 +220,107 @@ public static IEnumerable ModuleDockingNodeNamed_onRenameDialog return matcher.InstructionEnumeration(); } + public override bool IsModLoaded + { + get + { + if (!StaticMethods.IsAssemblyLoaded(PatchDLLName) || !StaticMethods.IsAssemblyLoaded("moduledockingnodenamed")) + { + Debug.Log($"[KSPCNPatches] 未检测到Mod [{PatchName}] 或 [moduledockingnodenamed] 已跳过"); + return false; + } + return true; + } + } + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "loadTextures"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_loadTexturesPatches_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawIndicatorContentsToTexture"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawIndicatorContentsToTexture_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.BitmapFont"), "buildGlyphs"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.Bitmap_FontbuildGlyphs_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.BitmapFont"), "getGlyphFromID", new[] { typeof(int) }), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.Bitmap_getGlyphFromID_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "createBlizzyButton"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_createBlizzyButton_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "determineTargetPortName"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_determineTargetPortName_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawRenderedGaugeTexture", new[] { typeof(int) }), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawRenderedGaugeTexture_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawRPMText", new[] { typeof(int), typeof(int) }), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawRPMText_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "drawSettingsWindowContents", new[] { typeof(int) }), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_drawSettingsWindowContents_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "getReferencePortName"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_getReferencePortName_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.DockingPortAlignmentIndicator"), "onGaugeDraw"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.DPAI_onGaugeDraw_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.ModuleDockingNodeNamed"), "OnAwake"), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.ModuleDockingNodeNamed_OnAwake_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.RenameWindow"), "DisplayForNode", new[] { AccessTools.TypeByName("NavyFish.ModuleDockingNodeNamed") }), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.ModuleDockingNodeNamed_DisplayForNode_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("NavyFish.RenameWindow"), "onRenameDialogDraw", new[] { typeof(int) }), + new HarmonyMethod(typeof(DPAIPatches), nameof(DPAIPatches.ModuleDockingNodeNamed_onRenameDialogDraw_Patch)), + PatchType.Transpiler + ), + }; + } } } diff --git a/Source/KSP_Chinese_Patches/ELPatches.cs b/Source/KSP_Chinese_Patches/ELPatches.cs new file mode 100644 index 0000000..8ef46c6 --- /dev/null +++ b/Source/KSP_Chinese_Patches/ELPatches.cs @@ -0,0 +1,761 @@ +using HarmonyLib; +using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace KSP_Chinese_Patches +{ + public class ELPatches : AbstractPatchBase + { + public override string PatchName => "Extraplanetary Launchpads"; + public override string PatchDLLName => "Launchpad"; + public static IEnumerable ELResourceLine_Resource_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchEndForward( + new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(AccessTools.TypeByName("ExtraplanetaryLaunchpads.IResourceLine"), "ResourceName")) + ) + .Advance(1) + .InsertAndAdvance( + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(ELPatches), nameof(ELPatches.getResourceName), new[] { typeof(string) })) + ) + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ELControlReference_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("MakeReference", Localizer.Format("#autoLOC_6001360"))) // Control From Here + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("ToggleReference", "切换基准")) // Toggle Reference + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELConverter_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("furnaceTemp", "熔炉温度")) // Furnace Temp + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELConverter_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, " at 50% efficiency")) + .SetOperandAndAdvance("处于50%效率工作") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\n\nMass flow: {0:0.00} {1}/{2}")) + .SetOperandAndAdvance("\n\n质流量: {0:0.00} {1}/{2}") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\n\nHeat flow: {0:0.00} {1}/{2}")) + .SetOperandAndAdvance("\n\n热流量: {0:0.00} {1}/{2}") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\n\nInputs:")) + .SetOperandAndAdvance("\n\n输入:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\nOutputs:")) + .SetOperandAndAdvance("\n输出:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "broken configuration")) + .SetOperandAndAdvance("出错的配置") + ; + return matcher.InstructionEnumeration(); + } + + public static void GetModuleDisplayNamePostfixPatch(ref string __result) + { + __result = "EL转换装置"; + } + + public static IEnumerable ELConverter_PostProcess_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "% eff.")) + .SetOperandAndAdvance("% 效率") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Operating")) + .SetOperandAndAdvance("运转中") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELDisposablePad_OnAwake_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("PadName", "发射台名称")) // Pad name + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("HideUI", "隐藏界面")) // Hide UI + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ShowUI", "显示界面")) // Show UI + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ShowRenameUI", "重命名")) // Rename + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELConstructionSkill_GetDescription_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "She")) + .SetOperandAndAdvance("她") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "He")) + .SetOperandAndAdvance("他") + .MatchStartForward(new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELConstructionSkill"), "skills"))) + .SetOperandAndAdvance(AccessTools.Field(typeof(ELPatches), nameof(ELPatches.cnskills))) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELExtendingLaunchClamp_OnAwake_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("ReleaseClamp", "松开爪钩")) // Release Clamp + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("Release", "松开爪钩")) // Release Clamp + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELExtractor_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\n\nInputs:")) + .SetOperandAndAdvance("\n\n输入:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\nOutputs:")) + .SetOperandAndAdvance("\n输出:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "\nRequirements:")) + .SetOperandAndAdvance("\n需要:") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELExtractor_PostProcess_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "stalled")) + .SetOperandAndAdvance("关机") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELExtractor_PrepareRecipe_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "no ground contact")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_259789")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "insufficient abundance")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_259819")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Inactive")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_259826")) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELLaunchpad_OnAwake_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("PadName", "发射台名称")) // Pad name + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("HideUI", "隐藏界面")) // Hide UI + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ShowUI", "显示界面")) // Show UI + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ShowRenameUI", "重命名")) // Rename + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELLaunchpad_GetModuleTitle_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "EL Launchpad")) + .SetOperandAndAdvance("EL 发射台") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELLaunchpad_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Launchpad")) + .SetOperandAndAdvance("发射台") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELRecycler_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("status", "状态")) // State + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("Activate", "启动回收装置")) // Activate Recycler + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("Deactivate", "关闭回收装置")) // Deactivate Recycler + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELRecycler_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Recycler:\n")) + .SetOperandAndAdvance("回收装置:\n") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "rate: {0:G2}t/s")) + .SetOperandAndAdvance("速率: {0:G2}t/s") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELRecycler_GetPrimaryField_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Recycling Rate: {0:G2}t/s")) + .SetOperandAndAdvance("回收速率: {0:G2}t/s") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELRecycler_Activate_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Active")) + .SetOperandAndAdvance("激活") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELRecycler_Deactivate_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Inactive")) + .SetOperandAndAdvance("关闭") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveySkill_GetDescription_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "She")) + .SetOperandAndAdvance("她") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "He")) + .SetOperandAndAdvance("他") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "{0} can use survey sites out to {1}m.")) + .SetOperandAndAdvance("{0}可以使用靠近{1}m内的测量站.") + ; + return matcher.InstructionEnumeration(); + } + + // 资源采用displayName + public static IEnumerable EL_Utils_PrintResource_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward( + new CodeMatch(OpCodes.Ldarg_0), + new CodeMatch(OpCodes.Ldarg_1), + new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(ResourceRatio), nameof(ResourceRatio.ResourceName))) + ) + .Advance(1) + .SetOpcodeAndAdvance(OpCodes.Ldloc_0) + .SetAndAdvance(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(PartResourceDefinition), nameof(PartResourceDefinition.displayName))) + + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "day")) + .SetOperandAndAdvance("天") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "hr")) + .SetOperandAndAdvance("时") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "m")) + .SetOperandAndAdvance("分") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "s")) + .SetOperandAndAdvance("秒") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable EL_Utils_TimeSpanString_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward( + new CodeMatch(OpCodes.Ldsfld, AccessTools.Field(AccessTools.TypeByName("ExtraplanetaryLaunchpads.EL_Utils"), "time_formats")) + ) + .SetOperandAndAdvance(AccessTools.Field(typeof(ELPatches), nameof(ELPatches.time_formats))) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveyStation_OnAwake_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("StationName", "发射台名称")) // Pad Name + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("range", "范围")) // Range + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("HideUI", "隐藏界面")) // Hide UI + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ShowUI", "显示界面")) // Show UI + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ShowRenameUI", "重命名")) // Rename + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveyStation_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Survey Station")) + .SetOperandAndAdvance("测量站") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveyStation_GetModuleTitle_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "EL Survey Station")) + .SetOperandAndAdvance("EL 测量站") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveyStake_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("RenameVessel", "重命名桩")) // Rename Stake + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveyStake_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Survey Stake")) + .SetOperandAndAdvance("测量桩") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELSurveyStake_GetModuleTitle_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "EL Survey Stake")) + .SetOperandAndAdvance("EL 测量桩") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELTarget_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("SetAsTarget", Localizer.Format("#autoLOC_6001448"))) // Set as Target + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("UnsetTarget", Localizer.Format("#autoLOC_6001449"))) // Unset Target + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELTarget_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Targetable")) + .SetOperandAndAdvance("可设置为目标") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ELTarget_GetModuleTitle_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "EL Target")) + .SetOperandAndAdvance("EL 目标") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ELWorkshop_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("_Productivity", "生产率")) // Productivity + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("VesselProductivity", "载具生产率")) // Vessel Productivity + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ELWorkshop_GetInfo_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Workshop: productivity factor {0:G2}")) + .SetOperandAndAdvance("工作车间: 生产率系数 {0:G2}") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ELWorkshop_GetInfoGetPrimaryField_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Productivity Factor: {0:G2}")) + .SetOperandAndAdvance("生产率系数 {0:G2}") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ELWorkshop_GetModuleTitle_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "EL Workshop")) + .SetOperandAndAdvance("EL 工作车间") + ; + return matcher.InstructionEnumeration(); + } + // FSM - 有限状态机 + public static IEnumerable RecyclerFSM_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Off")) + .SetOperandAndAdvance("关闭") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Idle")) + .SetOperandAndAdvance("闲置") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Captured Idle")) + .SetOperandAndAdvance("闲置就绪") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Processing Part")) + .SetOperandAndAdvance("处理部件") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Transferring Resources")) + .SetOperandAndAdvance("输送资源") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Enabled")) + .SetOperandAndAdvance("启用") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Disabled")) + .SetOperandAndAdvance("禁用") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Enter Field")) + .SetOperandAndAdvance("进场") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Part Selected")) + .SetOperandAndAdvance("部件已选取") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Resources Collected")) + .SetOperandAndAdvance("资源已收集") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Resources Transferred")) + .SetOperandAndAdvance("资源已输送") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Parts Exhausted")) + .SetOperandAndAdvance("部件已耗尽") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable RecyclerFSM_get_CurrentState_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "FSM not started")) + .SetOperandAndAdvance("FSM未启动") + ; + return matcher.InstructionEnumeration(); + } + + static string[] time_formats = new[] { "{0:F0}年{1:000}天{2:00}时{3:00}分{4:00}秒", "{1:F0}天{2:00}时{3:00}分{4:00}秒", "{2:F0}时{3:00}分{4:00}秒", "{3:F0}分{4:00}秒", "{4:F0}秒" }; + + static string[] cnskills = new[] { + "可以在完备的工作车间中工作。", // " can work in a fully equipped workshop." + "可以在任何工作车间中工作。", // " can work in any workshop." + "可以为完备的工作车间增加产出。", // " is always productive in a fully equipped workshop." + "可以为任何工作车间增加产出", // " is always productive in any workshop." + // 纳闷了这还是英文吗,给我写哪去了 + "可以使任何工作车间的工作人员增加技能", // " enables skilled workers in any workshop." + "可以使非技术工作人员在完备的工作车间增加技能", // " enables unskilled workers in a fully equipped workshop." + }; + static string getResourceName(string resourceName) + { + PartResourceDefinition res = PartResourceLibrary.Instance.GetDefinition(resourceName); + if (res != null) + { + return res.displayName; + } + return resourceName; + } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELResourceLine"), "Resource", new[] { AccessTools.TypeByName("ExtraplanetaryLaunchpads.IResourceLine") }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELResourceLine_Resource_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELControlReference"), "OnStart"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELControlReference_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELConverter"), "OnStart"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELConverter_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELConverter"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELConverter_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELConverter"), "GetModuleDisplayName"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.GetModuleDisplayNamePostfixPatch)), + PatchType.Postfix + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELConverter"), "PostProcess", new[] { typeof(ConverterResults), typeof(double) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELConverter_PostProcess_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELDisposablePad"), "OnAwake"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELDisposablePad_OnAwake_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELConstructionSkill"), "GetDescription"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELConstructionSkill_GetDescription_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELExtendingLaunchClamp"), "OnAwake"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELExtendingLaunchClamp_OnAwake_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELExtractor"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELExtractor_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELExtractor"), "PostProcess", new[] { typeof(ConverterResults), typeof(double) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELExtractor_PostProcess_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELExtractor"), "PrepareRecipe", new[] { typeof(double) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELExtractor_PrepareRecipe_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELLaunchpad"), "OnAwake"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELLaunchpad_OnAwake_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELLaunchpad"), "GetModuleTitle"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELLaunchpad_GetModuleTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELLaunchpad"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELLaunchpad_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELRecycler"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELRecycler_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELRecycler"), "GetPrimaryField"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELRecycler_GetPrimaryField_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELRecycler"), "OnStart", new[] { typeof(PartModule.StartState) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELRecycler_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELRecycler"), "Activate"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELRecycler_Activate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELRecycler"), "Deactivate"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELRecycler_Deactivate_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveySkill"), "GetDescription"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveySkill_GetDescription_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.EL_Utils"), "PrintResource", new[] { typeof(StringBuilder), typeof(ResourceRatio), typeof(string) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.EL_Utils_PrintResource_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.EL_Utils"), "TimeSpanString", new[] { typeof(double) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.EL_Utils_TimeSpanString_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveyStake"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveyStake_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveyStake"), "GetModuleTitle"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveyStake_GetModuleTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveyStake"), "OnStart", new[] { typeof(PartModule.StartState) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveyStake_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveyStation"), "OnAwake"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveyStation_OnAwake_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveyStation"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveyStation_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELSurveyStation"), "GetModuleTitle"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELSurveyStation_GetModuleTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELTarget"), "OnStart", new[] { typeof(PartModule.StartState) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELTarget_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELTarget"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELTarget_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELTarget"), "GetModuleTitle"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELTarget_GetModuleTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELWorkshop"), "OnStart", new[] { typeof(PartModule.StartState) }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELWorkshop_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELWorkshop"), "GetInfo"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELWorkshop_GetInfo_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELWorkshop"), "GetPrimaryField"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELWorkshop_GetInfoGetPrimaryField_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELWorkshop"), "GetModuleTitle"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.ELWorkshop_GetModuleTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("RecyclerFSM"), new[]{ AccessTools.TypeByName("ExtraplanetaryLaunchpads.ELRecycler") }), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.RecyclerFSM_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.PropertyGetter(AccessTools.TypeByName("RecyclerFSM"), "CurrentState"), + new HarmonyMethod(typeof(ELPatches), nameof(ELPatches.RecyclerFSM_get_CurrentState_Patch)), + PatchType.Transpiler + ), + }; + } + } +} diff --git a/Source/KSP_Chinese_Patches/HullcamVDSContinuedPatches.cs b/Source/KSP_Chinese_Patches/HullcamVDSContinuedPatches.cs index dceb4c9..f560376 100644 --- a/Source/KSP_Chinese_Patches/HullcamVDSContinuedPatches.cs +++ b/Source/KSP_Chinese_Patches/HullcamVDSContinuedPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -8,8 +9,12 @@ namespace KSP_Chinese_Patches { - public class HullcamVDSContinuedPatches + public class HullcamVDSContinuedPatches : AbstractPatchBase { + public override string PatchName => "HullcamVDS Continued"; + + public override string PatchDLLName => "HullcamVDSContinued"; + public static IEnumerable CameraFilterBlackAndWhiteFilm_OptionControls_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -105,5 +110,42 @@ public static IEnumerable CameraFilterNightVision_OptionControl ; return matcher.InstructionEnumeration(); } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterBlackAndWhiteFilm"), "OptionControls"), + new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterBlackAndWhiteFilm_OptionControls_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterColorFilm"), "OptionControls"), + new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterColorFilm_OptionControls_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterColorHiResTV"), "OptionControls"), + new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterColorHiResTV_OptionControls_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterColorLoResTV"), "OptionControls"), + new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterColorLoResTV_OptionControls_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("HullcamVDS.CameraFilterNightVision"), "OptionControls"), + new HarmonyMethod(typeof(HullcamVDSContinuedPatches), nameof(HullcamVDSContinuedPatches.CameraFilterNightVision_OptionControls_Patch)), + PatchType.Transpiler + ), + }; + } } } diff --git a/Source/KSP_Chinese_Patches/OrbitPOIntsPatches.cs b/Source/KSP_Chinese_Patches/OrbitPOIntsPatches.cs new file mode 100644 index 0000000..cfd122d --- /dev/null +++ b/Source/KSP_Chinese_Patches/OrbitPOIntsPatches.cs @@ -0,0 +1,171 @@ +using HarmonyLib; +using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; + +namespace KSP_Chinese_Patches +{ + public class OrbitPOIntsPatches : AbstractPatchBase + { + public override string PatchName => "OrbitPOInts"; + + public override string PatchDLLName => "OrbitPOInts"; + + public static IEnumerable ToolbarUI_DrawUI_Patch(IEnumerable codeInstructions) + { + // 原文太傻逼,只能先做个接口以防改来改去 + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Enabled")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_Enabled")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Force Refresh")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ForceRefresh")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Focused Body Only")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_FocusedBodyOnly")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Draw Spheres")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_DrawSpheres")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Align Spheres")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_AlignSpheres")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Draw Circles")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_DrawCircles")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show POI Max Terrain Altitude On Atmospheric Bodies")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ShowPOIMaxTerrainAltitudeOnAtmoBodies")) + #region ControlWrapperInteractionLogger.WrapButton("Reset POIs for " + this._selectedBodyName + " to defaults", null, null); + // ControlWrapperInteractionLogger.WrapButton(Localizer.Fomat("#OrbitPOInts_RestPOIforBodies", this._selectedBodyName), null, null) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Reset POIs for ")) + .SetOperandAndAdvance("#OrbitPOInts_RestPOIforBodies") + .InsertAndAdvance( + new CodeInstruction(OpCodes.Ldc_I4_1), + new CodeInstruction(OpCodes.Newarr, typeof(string)), + new CodeInstruction(OpCodes.Dup), + new CodeInstruction(OpCodes.Ldc_I4_0) + ) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, " to defaults")) + .RemoveInstructions(2) + .InsertAndAdvance( + new CodeInstruction(OpCodes.Stelem_Ref), + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Localizer), nameof(Localizer.Format), new[] { typeof(string), typeof(string[]) }))) + #endregion + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show Options")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ShowOptions")) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable OptionsPopup_DrawUI_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Misc")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_Misc")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Enable Debug Level Logging")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_EnableDebugLevelLogging")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use Skin")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_UseSkin")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use Opaque Background Override")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_OpaqueBackground")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use Top Right Close Button")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_UseTopRightCloseButton")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use LeftClick to toggle / RightClick for settings")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_LClickToggleRClickSetting")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "-- Danger Zone -- (no confirmation and no undo)")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_DangerZoneTips")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Reset All Standard POIs to defaults")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ResetPOI")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Remove All Custom POIs")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_RemoveAllPOI")) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ToolbarUI_FixState_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(CelestialBody), nameof(CelestialBody.name)))) + .SetOperandAndAdvance(AccessTools.PropertyGetter(typeof(CelestialBody), nameof(CelestialBody.displayName))) + .InsertAndAdvance( + new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(LingoonaGrammarExtensions), nameof(LingoonaGrammarExtensions.LocalizeRemoveGender), new[] { typeof(string) })) + ) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable SimpleColorPicker_DrawUI_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Red")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ColorPicker_Red")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Green")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ColorPicker_Green")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Blue")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ColorPicker_Blue")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Cancel")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ColorPicker_Cancel")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Default")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ColorPicker_Default")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Save")) + .SetOperandAndAdvance(Localizer.Format("#OrbitPOInts_ColorPicker_Save")) + ; + return matcher.InstructionEnumeration(); + } + + public static void POILabelPosfix(ref string __result) + { + if (string.IsNullOrEmpty(__result)) + return; + if (Localizer.TryGetStringByTag($"#OrbitPOInts_{__result}", out string _v)) + { + __result = _v; + } + //__result = __result == Localizer.Format($"#OrbitPOInts_{__result}") ? __result : Localizer.Format($"#OrbitPOInts_{__result}"); + } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("OrbitPOInts.UI.ToolbarUI"), "DrawUI", new[] { typeof(int) }), + new HarmonyMethod(typeof(OrbitPOIntsPatches), nameof(OrbitPOIntsPatches.ToolbarUI_DrawUI_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("OrbitPOInts.UI.ToolbarUI"), "FixState"), + new HarmonyMethod(typeof(OrbitPOIntsPatches), nameof(OrbitPOIntsPatches.ToolbarUI_FixState_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("OrbitPOInts.Data.POI.POI"), "_resolveLabel"), + new HarmonyMethod(typeof(OrbitPOIntsPatches), nameof(OrbitPOIntsPatches.POILabelPosfix)), + PatchType.Postfix + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("OrbitPOInts.UI.OptionsPopup"), "DrawUI", new[] { typeof(int) }), + new HarmonyMethod(typeof(OrbitPOIntsPatches), nameof(OrbitPOIntsPatches.OptionsPopup_DrawUI_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("OrbitPOInts.UI.SimpleColorPicker"), "DrawUI", new[] { typeof(int) }), + new HarmonyMethod(typeof(OrbitPOIntsPatches), nameof(OrbitPOIntsPatches.SimpleColorPicker_DrawUI_Patch)), + PatchType.Transpiler + ) + }; + } + } +} diff --git a/Source/KSP_Chinese_Patches/PatchesInfo/AbstractPatchBase.cs b/Source/KSP_Chinese_Patches/PatchesInfo/AbstractPatchBase.cs new file mode 100644 index 0000000..50d7890 --- /dev/null +++ b/Source/KSP_Chinese_Patches/PatchesInfo/AbstractPatchBase.cs @@ -0,0 +1,87 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace KSP_Chinese_Patches.PatchesInfo +{ + public abstract class AbstractPatchBase + { + public abstract string PatchName { get; } + public abstract string PatchDLLName { get; } + public virtual HashSet Patches { get; set; } + public virtual void PatchApply(Harmony harmony, HarPatchInfo patchInfo) + { + switch (patchInfo.PatchType) + { + case PatchType.Prefix: + harmony.Patch( + original: patchInfo.TargetMethod, + prefix: patchInfo.PatchMethod + ); + break; + case PatchType.Postfix: + harmony.Patch( + original: patchInfo.TargetMethod, + postfix: patchInfo.PatchMethod + ); + break; + case PatchType.Transpiler: + harmony.Patch( + original: patchInfo.TargetMethod, + transpiler: patchInfo.PatchMethod + ); + break; + default: + return; + } + } + public abstract void LoadAllPatchInfo(); + + public virtual bool IsModLoaded + { + get + { + if (!StaticMethods.IsAssemblyLoaded(PatchDLLName)) + { + UnityEngine.Debug.Log($"[KSPCNPatches] 未检测到 [{PatchName}] 已跳过\n"); + return false; + } + return true; + } + } + + public virtual void ApplyPatches(Harmony harmony) + { + if (!IsModLoaded) return; + + Stopwatch watch = Stopwatch.StartNew(); + StaticMethods.PatchedModCount++; + StringBuilder sb = new StringBuilder(); + sb.AppendLine($"\n[KSPCNPatches] 已找到 [{PatchName}]! 应用翻译..."); + LoadAllPatchInfo(); + + foreach (HarPatchInfo patch in Patches) + { + try + { + PatchApply(harmony, patch); + sb.AppendLine($"[{PatchName}] '{patch.PatchMethod.method.Name}' 已应用"); + } + catch (Exception ex) + { + sb.AppendLine($"[{PatchName}] 应用 '{patch.PatchMethod.method.Name}' 时发生错误,错误信息:\n{ex.ToString()}"); + continue; + } + } + + watch.Stop(); + sb.AppendLine($"执行总计{watch.Elapsed.TotalSeconds:F2}秒"); + UnityEngine.Debug.Log(sb.ToStringAndRelease()); + } + } +} diff --git a/Source/KSP_Chinese_Patches/PatchesInfo/HarPatchInfo.cs b/Source/KSP_Chinese_Patches/PatchesInfo/HarPatchInfo.cs new file mode 100644 index 0000000..a64336f --- /dev/null +++ b/Source/KSP_Chinese_Patches/PatchesInfo/HarPatchInfo.cs @@ -0,0 +1,49 @@ +using HarmonyLib; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; + +namespace KSP_Chinese_Patches +{ + public enum PatchType + { + Prefix, + Postfix, + Transpiler + } + public class HarPatchInfo + { + public MethodBase TargetMethod { get; } + public HarmonyMethod PatchMethod { get; } + + public PatchType PatchType { get; } + public HarPatchInfo(MethodBase methodBase, HarmonyMethod patchMethod, PatchType patchType) + { + TargetMethod = methodBase; + PatchMethod = patchMethod; + PatchType = patchType; + } + + public override bool Equals(object obj) + { + return Equals(obj as HarPatchInfo); + } + + public bool Equals(HarPatchInfo other) + { + return other != null && TargetMethod == other.TargetMethod && PatchMethod == other.PatchMethod && PatchType == other.PatchType; + } + + public override int GetHashCode() + { + int hash = 17; + hash = (hash * 23) + TargetMethod.GetHashCode(); + hash = (hash * 23) + PatchMethod.GetHashCode(); + hash = (hash * 23) + PatchType.GetHashCode(); + return hash; + } + } +} diff --git a/Source/KSP_Chinese_Patches/PhysicsRangeExtenderPatches.cs b/Source/KSP_Chinese_Patches/PhysicsRangeExtenderPatches.cs index 1272727..dd35ce4 100644 --- a/Source/KSP_Chinese_Patches/PhysicsRangeExtenderPatches.cs +++ b/Source/KSP_Chinese_Patches/PhysicsRangeExtenderPatches.cs @@ -1,4 +1,5 @@ -using HarmonyLib; +using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -8,8 +9,12 @@ namespace KSP_Chinese_Patches { - public class PhysicsRangeExtenderPatches + public class PhysicsRangeExtenderPatches : AbstractPatchBase { + public override string PatchName => "Physics Range Extender"; + + public override string PatchDLLName => "PhysicsRangeExtender"; + public static IEnumerable Gui_DisableMod_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -95,5 +100,60 @@ public static IEnumerable TerrainExtender_ShowMessageTerrainSta ; return matcher.InstructionEnumeration(); } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DisableMod", new[] { typeof(float) }), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DisableMod_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawCamFixMultiplier", new[] { typeof(float) }), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawCamFixMultiplier_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawGlobalVesselRange", new[] { typeof(float) }), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawGlobalVesselRange_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawSaveButton", new[] { typeof(float) }), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawSaveButton_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.Gui"), "DrawTitle"), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.Gui_DrawTitle_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.PhysicsRangeExtender"), "UpdateNearClipPlane"), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.PhysicsRangeExtender_UpdateNearClipPlane_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.PhysicsRangeExtender"), "UnloadLandedVessels"), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.PhysicsRangeExtender_UnloadLandedVessels_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PhysicsRangeExtender.TerrainExtender"), "ShowMessageTerrainStatus"), + new HarmonyMethod(typeof(PhysicsRangeExtenderPatches), nameof(PhysicsRangeExtenderPatches.TerrainExtender_ShowMessageTerrainStatus_Patch)), + PatchType.Transpiler + ), + }; + } } } diff --git a/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs b/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs new file mode 100644 index 0000000..87a9606 --- /dev/null +++ b/Source/KSP_Chinese_Patches/PlanetsideExplorationTechnologiesPatches.cs @@ -0,0 +1,205 @@ +using HarmonyLib; +using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace KSP_Chinese_Patches +{ + public class PlanetsideExplorationTechnologiesPatches : AbstractPatchBase + { + public override string PatchName => "Planetside Exploration Technologies"; + + public override string PatchDLLName => "PlanetsideExplorationTechnologies"; + + public static IEnumerable ModulePETAnimation_OnStart_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("statusDisplay", "状态")) + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ExtendEvent", "展开")) + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("RetractEvent", "收回")) + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("RepairEvent", "维修")) + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("ToggleAction", "展开/收回")) + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("RetractAction", "收回")) + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("ExtendAction", "展开")) + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ModulePETAnimation_UpdateFSM_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Extended")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234828")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Extending...")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234841")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Retracted")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234861")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Retracting...")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234856")) + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Broken!")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234868")) + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ModulePETAnimation_Repair_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Turbine repaired with {0} repair kits")) + .SetOperandAndAdvance("维修部件需要{0}个维修工具") + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ModulePETAnimation_OnCollisionEnter_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Turbine was destroyed")) + .SetOperandAndAdvance("风电部件已损毁") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ModulePETAnimation_Destroy_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Broken!")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234868")) + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ModulePETAnimation_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Retracted")) + .SetOperandAndAdvance(Localizer.Format("#autoLOC_234861")) + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ModulePETTurbine_OnAwake_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("isActive", "开关风轮")) // Toggle Turbine + .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("isActive", "风力发电")) // Wind Turbine + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("isActive", "关", "开")) + + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("flowRateDisplay", "产出电力")) // EC Output + .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("flowRateDisplay", "风力发电")) // Wind Turbine + + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("turbineEfficiencyDisplay", "发电效率")) // Efficiency + .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("turbineEfficiencyDisplay", "风力发电")) // Wind Turbine + + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("windSpeedDisplay", "当前风速")) // Current Wind Speed + .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("windSpeedDisplay", "风力发电")) // Wind Turbine + + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("windDirectionDisplay", "当前风向")) // Current Wind Direction + .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("windDirectionDisplay", "风力发电")) // Wind Turbine + + .InsertAndAdvance(StaticMethods.Field_GuiName_Instructions("toggleLines", "显示风向")) // Show Wind Direction + .InsertAndAdvance(StaticMethods.Field_groupDisplayName_Instructions("toggleLines", "风力发电")) // Wind Turbine + .InsertAndAdvance(StaticMethods.Field_UIToggle_Instructions("toggleLines", "关", "开")) + + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ToggleEVATurbine", "开关风轮")) // Toggle Turbine + + .InsertAndAdvance(StaticMethods.Event_GuiName_Instructions("ForceWindUpdate", "调试: 强制刷新")) // Debug: Force Update + + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("ToggleTurbine", "开关风轮")) // Toggle Turbine + + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("EnableTurbine", "启动风轮")) // Enable Turbine + + .InsertAndAdvance(StaticMethods.Action_GuiName_Instructions("DisableTurbine", "关闭风轮")) // Disable Turbine + ; + return matcher.InstructionEnumeration(); + } + + public static IEnumerable ModulePETTurbine_UpdateTurbine_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Too little wind to generate power!")) + .SetOperandAndAdvance("当前风速不足以发电!") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Generating Power...")) + .SetOperandAndAdvance("正在发电...") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Turbine destroyed by excessive wind speed")) + .SetOperandAndAdvance("风轮因风速过大而损坏") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Idling - Not generating power")) + .SetOperandAndAdvance("闲置 - 未在发电") + ; + return matcher.InstructionEnumeration(); + } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETAnimation")), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETAnimation_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETAnimation"), "OnStart", new[] { typeof(PartModule.StartState) }), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETAnimation_OnStart_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETAnimation"), "UpdateFSM"), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETAnimation_UpdateFSM_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETAnimation"), "Repair"), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETAnimation_Repair_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETAnimation"), "OnCollisionEnter", new[] { typeof(Collision) }), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETAnimation_OnCollisionEnter_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETAnimation"), "Destroy"), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETAnimation_Destroy_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETTurbine"), "OnAwake"), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETTurbine_OnAwake_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("PlanetsideExplorationTechnologies.Modules.ModulePETTurbine"), "UpdateTurbine"), + new HarmonyMethod(typeof(PlanetsideExplorationTechnologiesPatches), nameof(PlanetsideExplorationTechnologiesPatches.ModulePETTurbine_UpdateTurbine_Patch)), + PatchType.Transpiler + ) + }; + } + } +} diff --git a/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs b/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs index cc54150..d966f3b 100644 --- a/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs +++ b/Source/KSP_Chinese_Patches/RasterPropMonitorPatches.cs @@ -1,5 +1,6 @@ using HarmonyLib; using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -9,8 +10,12 @@ namespace KSP_Chinese_Patches { - public class RasterPropMonitorPatches + public class RasterPropMonitorPatches : AbstractPatchBase { + public override string PatchName => "RasterPropMonitor Core"; + + public override string PatchDLLName => "RasterPropMonitor"; + public static IEnumerable JSIExternalCameraSelector_OnAwake_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -51,5 +56,18 @@ public static IEnumerable JSIExternalCameraSelector_OnAwake_Pat ; return matcher.InstructionEnumeration(); } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("JSI.JSIExternalCameraSelector"), "OnAwake"), + new HarmonyMethod(typeof(RasterPropMonitorPatches), nameof(RasterPropMonitorPatches.JSIExternalCameraSelector_OnAwake_Patch)), + PatchType.Transpiler + ) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/RealAntennasPatches.cs b/Source/KSP_Chinese_Patches/RealAntennasPatches.cs index e385be0..1362047 100644 --- a/Source/KSP_Chinese_Patches/RealAntennasPatches.cs +++ b/Source/KSP_Chinese_Patches/RealAntennasPatches.cs @@ -1,5 +1,6 @@ -using HarmonyLib; +using HarmonyLib; using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.CodeDom; using System.Collections.Generic; @@ -12,9 +13,14 @@ namespace KSP_Chinese_Patches { - public class RealAntennasPatches + public class RealAntennasPatches : AbstractPatchBase { static Type ty = AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"); + + public override string PatchName => "Real Antennas"; + + public override string PatchDLLName => "RealAntennas"; + public static IEnumerable NetUIConfigurationWindow_WindowGUIPatch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -45,16 +51,15 @@ public static IEnumerable OnAwakePatch(IEnumerable), "get_Item", new[] { typeof(string) })), new CodeInstruction(OpCodes.Ldstr, "天线"), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Localizer), nameof(Localizer.Format), new[] { typeof(string) })), + //new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(Localizer), nameof(Localizer.Format), new[] { typeof(string) })), new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), // (base.Fields["_enabled"].uiControlEditor as UI_Toggle).disabledText = "禁用"; - // (base.Fields["_enabled"].uiControlEditor as UI_Toggle).enabledText = "启用"; new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), new CodeInstruction(OpCodes.Ldstr, "_enabled"), @@ -63,6 +68,7 @@ public static IEnumerable OnAwakePatch(IEnumerable禁用"), new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), + // (base.Fields["_enabled"].uiControlEditor as UI_Toggle).enabledText = "启用"; new CodeInstruction(OpCodes.Ldarg_0), new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), new CodeInstruction(OpCodes.Ldstr, "_enabled"), @@ -548,5 +554,162 @@ public static IEnumerable RA_SettingTitlePatch(IEnumerable + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "OnAwake"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.OnAwakePatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "RecalculateFields"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RecalculateFieldsLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "PermanentShutdownEvent"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PermanentShutdownEventLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "ApplyTLColoring"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.ApplyTLColoringLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.ModuleRealAntenna"), "GetInfo"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.GetInfoLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "OnGUI"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_OnGUILocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "GUIDisplay", new[] { typeof(int) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_GUIDisplayLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI+<>c"), "b__44_0", new[] { typeof(CelestialBody) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_GetDisplayNamePatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "RenderPanel"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_RenderPanelPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.PlannerGUI"), "FireOnce"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_FireOncePatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.RACommNetScenario+d__35"), "MoveNext"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.PlannerGUI_NotifyDisabledPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.RealAntennasUI"), "WindowGUI", new[] { typeof(int) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RealAntennasUI_WindowGUIPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.TechLevelInfo"), "ToString"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.TechLevelInfo_ToStringPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.MapUI.NetUIConfigurationWindow"), "WindowGUI", new[] { typeof(int) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.NetUIConfigurationWindow_WindowGUIPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.MapUI.SignalToolTipController"), "UpdateList"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.UpdateList_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Network.ConnectionDebugger"), "OnGUI"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.ConnectionDebugger_OnGUI_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Network.ConnectionDebugger"), "GUIDisplay", new[] { typeof(int) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.ConnectionDebugger_GUIDisplay_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.AntennaTargetGUI"), "OnGUI"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.AntennaTargetGUI_OnGUI_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.AntennaTargetGUI"), "GUIDisplay", new[] { typeof(int) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.AntennaTargetGUI_GUIDisplay_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.RemoteAntennaControlUI"), "OnGUI"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RemoteAntennaControlUI_OnGUI_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Targeting.RemoteAntennaControlUI"), "GUIDisplay", new[] { typeof(int) }), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RemoteAntennaControlUI_GUIDisplay_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("RealAntennas.Antenna.Encoder"), "ToString"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.Encoder_ToStringPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.PropertyGetter(AccessTools.TypeByName("RealAntennas.RAParameters"), "Title"), + new HarmonyMethod(typeof(RealAntennasPatches), nameof(RealAntennasPatches.RA_SettingTitlePatch)), + PatchType.Transpiler + ), + }; + } } } diff --git a/Source/KSP_Chinese_Patches/ResearchBodiesPatches.cs b/Source/KSP_Chinese_Patches/ResearchBodiesPatches.cs new file mode 100644 index 0000000..682cbc2 --- /dev/null +++ b/Source/KSP_Chinese_Patches/ResearchBodiesPatches.cs @@ -0,0 +1,44 @@ +using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; + +namespace KSP_Chinese_Patches +{ + public class ResearchBodiesPatches : AbstractPatchBase + { + public override string PatchName => "ResearchBodies"; + + public override string PatchDLLName => "ResearchBodies"; + + public static IEnumerable ResearchBodies_FoundBody_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Added ")) + .SetOperandAndAdvance("发现天体!已添加 ") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, " science points !")) + .SetOperandAndAdvance(" 科学点数!") + ; + return matcher.InstructionEnumeration(); + } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ResearchBodies.ResearchBodiesController"), "FoundBody", new[] { typeof(int), typeof(CelestialBody), typeof(bool).MakeByRefType(), typeof(CelestialBody).MakeByRefType() }), + new HarmonyMethod(typeof(ResearchBodiesPatches), nameof(ResearchBodiesPatches.ResearchBodies_FoundBody_Patch)), + PatchType.Transpiler + ) + }; + } + } +} diff --git a/Source/KSP_Chinese_Patches/ResourceOverviewPatches.cs b/Source/KSP_Chinese_Patches/ResourceOverviewPatches.cs new file mode 100644 index 0000000..2a5c1ff --- /dev/null +++ b/Source/KSP_Chinese_Patches/ResourceOverviewPatches.cs @@ -0,0 +1,116 @@ +using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Emit; +using System.Text; +using System.Threading.Tasks; + +namespace KSP_Chinese_Patches +{ + public class ResourceOverviewPatches : AbstractPatchBase + { + public override string PatchName => "Resource Overview"; + + public override string PatchDLLName => "ResourceOverview"; + + public static IEnumerable ResourceOverview_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "No command pod")) + .SetOperandAndAdvance("无指令舱") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Has command seat")) + .SetOperandAndAdvance("指令座椅") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "ProbeCore")) + .SetOperandAndAdvance("探测器核心") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Resource Overview")) + .SetOperandAndAdvance("资源总览") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable ResourceOverview_drawGui_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Vessel Type:")) + .SetOperandAndAdvance("载具类型:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Total Mass:")) + .SetOperandAndAdvance("总质量:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Dry Mass:")) + .SetOperandAndAdvance("干质量:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Crew Capacity:")) + .SetOperandAndAdvance("乘员容量:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Part Count:")) + .SetOperandAndAdvance("部件数量:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "TWR:")) + .SetOperandAndAdvance("推重比:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "No resources to display!")) + .SetOperandAndAdvance("载具没有可显示的资源!") + ; + return matcher.InstructionEnumeration(); + } + public static IEnumerable SettingWindow_drawGui_Patch(IEnumerable codeInstructions) + { + CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); + + matcher + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show Total Mass")) + .SetOperandAndAdvance("显示总质量") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show Dry Mass")) + .SetOperandAndAdvance("显示干质量") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show Crew Capacity")) + .SetOperandAndAdvance("显示乘员容量") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show Part Count")) + .SetOperandAndAdvance("显示部件数量") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show TWR")) + .SetOperandAndAdvance("显示推重比") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use Stock Skin")) + .SetOperandAndAdvance("使用原版皮肤") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use Bold Font")) + .SetOperandAndAdvance("字体加粗") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use Compact Spacing")) + .SetOperandAndAdvance("缩小字间距") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Font Size:")) + .SetOperandAndAdvance("字体大小:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Label/Data Space:")) + .SetOperandAndAdvance("标签/数据间空格:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Window Transparency:")) + .SetOperandAndAdvance("窗口透明度:") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Save")) + .SetOperandAndAdvance("保存") + .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Close")) + .SetOperandAndAdvance("关闭") + ; + return matcher.InstructionEnumeration(); + } + + public override void LoadAllPatchInfo() + { + Patches = new HashSet + { + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ResourceOverview.ResourceOverview")), + new HarmonyMethod(typeof(ResourceOverviewPatches), nameof(ResourceOverviewPatches.ResourceOverview_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ResourceOverview.ResourceOverview"), "drawGui", new[] { typeof(int) }), + new HarmonyMethod(typeof(ResourceOverviewPatches), nameof(ResourceOverviewPatches.ResourceOverview_drawGui_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ResourceOverview.SettingsWindow"), "drawGui", new[] { typeof(int) }), + new HarmonyMethod(typeof(ResourceOverviewPatches), nameof(ResourceOverviewPatches.SettingWindow_drawGui_Patch)), + PatchType.Transpiler + ) + }; + } + } +} diff --git a/Source/KSP_Chinese_Patches/SmartStagePatches.cs b/Source/KSP_Chinese_Patches/SmartStagePatches.cs index 39401b2..0539f8a 100644 --- a/Source/KSP_Chinese_Patches/SmartStagePatches.cs +++ b/Source/KSP_Chinese_Patches/SmartStagePatches.cs @@ -1,5 +1,6 @@ -using HarmonyLib; +using HarmonyLib; using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -10,8 +11,12 @@ namespace KSP_Chinese_Patches { - public class SmartStagePatches + public class SmartStagePatches : AbstractPatchBase { + public override string PatchName => "SmartStage"; + + public override string PatchDLLName => "SmartStage"; + public static IEnumerable AscentPlotLocPatch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -57,5 +62,45 @@ public static IEnumerable MainWindow_drawWindowLocPatch(IEnumer matcher.MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Show icon in flight")).SetOperandAndAdvance(Localizer.Format("#CNPatches_SmartStage_ShowIconInFlight")); return matcher.InstructionEnumeration(); } + + public override void LoadAllPatchInfo() + { + Type SmartStageType = AccessTools.TypeByName("SmartStage.MainWindow"); + Patches = new HashSet + { + new HarPatchInfo( + AccessTools.Constructor( + AccessTools.TypeByName("SmartStage.AscentPlot"), + new[] { + typeof(List<>).MakeGenericType(AccessTools.TypeByName("SmartStage.Sample")), + typeof(List<>).MakeGenericType(AccessTools.TypeByName("SmartStage.StageDescription")), + typeof(int), + typeof(int) + }), + new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.AscentPlotLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(SmartStageType, "OnGUI"), + new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_OnGUILocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(SmartStageType, "drawStagesWindow", new[] { typeof(int) }), + new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_drawStagesWindowLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(SmartStageType, "drawWindow", new[] { typeof(int) }), + new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_drawWindowLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo( + AccessTools.Method(SmartStageType, "m__0", new[] { typeof(CelestialBody) }), + new HarmonyMethod(typeof(SmartStagePatches), nameof(SmartStagePatches.MainWindow_PlanetDisplayNamePatch)), + PatchType.Transpiler + ) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/StaticMethods.cs b/Source/KSP_Chinese_Patches/StaticMethods.cs index e7335dd..f31fdcd 100644 --- a/Source/KSP_Chinese_Patches/StaticMethods.cs +++ b/Source/KSP_Chinese_Patches/StaticMethods.cs @@ -1,7 +1,9 @@ -using KSP.IO; +using HarmonyLib; +using KSP.IO; using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; using UnityEngine; @@ -10,6 +12,7 @@ namespace KSP_Chinese_Patches { public static class StaticMethods { + public static int PatchedModCount = 0; public static Dictionary AssemblyVersionMap => AssemblyLoader.loadedAssemblies.ToDictionary(a => a.dllName.ToLowerInvariant(), a => new Version(a.versionMajor, a.versionMinor, a.versionRevision)); public static StringBuilder sb = new StringBuilder(); @@ -48,5 +51,97 @@ public static bool IsAssemblyLoaded(string assemblyName, Version _version) return AssemblyVersionMap.TryGetValue(assemblyName.ToLowerInvariant(), out Version v) && v.Equals(_version); } + + public static CodeInstruction[] Field_GuiName_Instructions(string targetField, string guiName) + { + return new CodeInstruction[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), + new CodeInstruction(OpCodes.Ldstr, targetField), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Ldstr, guiName), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseField), nameof(BaseField.guiName))), + }; + } + public static CodeInstruction[] Field_groupDisplayName_Instructions(string targetField, string guiName) + { + return new CodeInstruction[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), + new CodeInstruction(OpCodes.Ldstr, targetField), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(BaseField), nameof(BaseField.group))), + new CodeInstruction(OpCodes.Ldstr, guiName), + new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(BasePAWGroup), nameof(BasePAWGroup.displayName))), + }; + } + + public static CodeInstruction[] Field_UIToggle_Instructions(string targetField, string disabledText, string enabledText) + { + return new CodeInstruction[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), + new CodeInstruction(OpCodes.Ldstr, targetField), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), + new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), + new CodeInstruction(OpCodes.Ldstr, disabledText), + new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), + + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), + new CodeInstruction(OpCodes.Ldstr, targetField), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlEditor))), + new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), + new CodeInstruction(OpCodes.Ldstr, enabledText), + new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), + + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), + new CodeInstruction(OpCodes.Ldstr, targetField), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlFlight))), + new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), + new CodeInstruction(OpCodes.Ldstr, disabledText), + new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.disabledText))), + + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Fields))), + new CodeInstruction(OpCodes.Ldstr, targetField), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseFieldList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(BaseField), nameof(BaseField.uiControlFlight))), + new CodeInstruction(OpCodes.Isinst, typeof(UI_Toggle)), + new CodeInstruction(OpCodes.Ldstr, enabledText), + new CodeInstruction(OpCodes.Stfld, AccessTools.Field(typeof(UI_Toggle), nameof(UI_Toggle.enabledText))), + }; + } + public static CodeInstruction[] Event_GuiName_Instructions(string targetEvent, string guiName) + { + return new CodeInstruction[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Events))), + new CodeInstruction(OpCodes.Ldstr, targetEvent), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseEventList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Ldstr, guiName), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseEvent), nameof(BaseEvent.guiName))) + }; + } + public static CodeInstruction[] Action_GuiName_Instructions(string targetAction, string guiName) + { + return new CodeInstruction[] + { + new CodeInstruction(OpCodes.Ldarg_0), + new CodeInstruction(OpCodes.Call, AccessTools.PropertyGetter(typeof(PartModule), nameof(PartModule.Actions))), + new CodeInstruction(OpCodes.Ldstr, targetAction), + new CodeInstruction(OpCodes.Callvirt, AccessTools.Method(typeof(BaseActionList), "get_Item", new[] { typeof(string) })), + new CodeInstruction(OpCodes.Ldstr, guiName), + new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertySetter(typeof(BaseAction), nameof(BaseEvent.guiName))) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/ThroughTheEyesPatches.cs b/Source/KSP_Chinese_Patches/ThroughTheEyesPatches.cs index 1c643ad..bb1bfbd 100644 --- a/Source/KSP_Chinese_Patches/ThroughTheEyesPatches.cs +++ b/Source/KSP_Chinese_Patches/ThroughTheEyesPatches.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -8,8 +9,12 @@ namespace KSP_Chinese_Patches { - public class ThroughTheEyesPatches + public class ThroughTheEyesPatches : AbstractPatchBase { + public override string PatchName => "Through The Eyes of a Kerbal"; + + public override string PatchDLLName => "ThroughTheEyes"; + public static IEnumerable EVABoundFix_Hook_Patch(IEnumerable codeInstructions, ILGenerator generator) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -35,5 +40,28 @@ public static IEnumerable EVABoundFix_Hook_Patch(IEnumerable + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("FirstPerson.EVABoundFix"), "Hook"), + new HarmonyMethod(typeof(ThroughTheEyesPatches), nameof(ThroughTheEyesPatches.EVABoundFix_Hook_Patch)), + PatchType.Transpiler + ) + }; + } } } diff --git a/Source/KSP_Chinese_Patches/WhereCanIGoPatches.cs b/Source/KSP_Chinese_Patches/WhereCanIGoPatches.cs index 33ce5eb..3813e4e 100644 --- a/Source/KSP_Chinese_Patches/WhereCanIGoPatches.cs +++ b/Source/KSP_Chinese_Patches/WhereCanIGoPatches.cs @@ -1,5 +1,6 @@ -using HarmonyLib; +using HarmonyLib; using KSP.Localization; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; @@ -10,7 +11,7 @@ namespace KSP_Chinese_Patches { - public class WhereCanIGoPatches + public class WhereCanIGoPatches : AbstractPatchBase { static Dictionary loc = new Dictionary() { @@ -31,6 +32,11 @@ public class WhereCanIGoPatches ["NO"] = Localizer.Format("#CNPatches_WCIG_No"), ["MARGINAL"] = Localizer.Format("#CNPatches_WCIG_Marginal"), }; + + public override string PatchName => "Where Can I Go"; + + public override string PatchDLLName => "WhereCanIGo"; + public static IEnumerable GenerateDialogLocPatch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -58,5 +64,54 @@ public static IEnumerable GenerateDialogLocPatch(IEnumerable() + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoEditor"), "GenerateDialog"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoEditor"), "GetDeltaVString"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoFlight"), "GenerateDialog"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.WhereCanIGoFlight"), "GetDeltaVString"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.Utilities"), "SituationValid"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.Utilities"), "VesselStatus"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("WhereCanIGo.Utilities"), "GetTextColor"), + new HarmonyMethod(typeof(WhereCanIGoPatches), nameof(WhereCanIGoPatches.GenerateDialogLocPatch)), + PatchType.Transpiler + ), + }; + } } } diff --git a/Source/KSP_Chinese_Patches/xSciencePatches.cs b/Source/KSP_Chinese_Patches/xSciencePatches.cs index bbf5d15..f14fb08 100644 --- a/Source/KSP_Chinese_Patches/xSciencePatches.cs +++ b/Source/KSP_Chinese_Patches/xSciencePatches.cs @@ -1,15 +1,21 @@ -using HarmonyLib; +using HarmonyLib; +using KSP_Chinese_Patches.PatchesInfo; using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; using System.Threading.Tasks; +using UnityEngine; namespace KSP_Chinese_Patches { - public class xSciencePatches + public class xSciencePatches : AbstractPatchBase { + public override string PatchName => "[x] Science! Continued"; + + public override string PatchDLLName => "[x]_Science!"; + public static IEnumerable Body_FigureOutType_Patch(IEnumerable codeInstructions) { CodeMatcher matcher = new CodeMatcher(codeInstructions).Start(); @@ -67,7 +73,7 @@ public static IEnumerable HelpWindow_DrawWindowContents_Patch(I .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Use | to mean OR eg \"mun|minmus space\"")) .SetOperandAndAdvance("输入 | 意为 [或] 比如 \"mun|minmus 太空\"") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Hover the mouse over the \"123/456 completed\" text. A pop-up will show more infromation.")) - .SetOperandAndAdvance("鼠标移到已完成 \"123/456 \" 文本上. 能显示更多信息") + .SetOperandAndAdvance("鼠标移到 完成度 \"123/456 \" 文本上. 能显示更多信息") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "Press the X button to clear your text filter.")) .SetOperandAndAdvance("点击 X 按钮能够清空筛选条件。") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "The settings are")) @@ -109,9 +115,9 @@ public static IEnumerable HelpWindow_DrawWindowContents_Patch(I .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "* Need more science? Go to Minmus. It’s a little harder to get to but your fuel will last longer. A single mission can collect thousands of science points before you have to come back.")) .SetOperandAndAdvance("* 还需要更多的科学点数?去 Minmus 吧。它有点难去,但你的燃料能用的时间会更长。单次任务就能收集数千个科学点数。") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "* Generally moons are easier - it is more efficient to collect science from the surface of Ike or Gilly than from Duna or Eve. That said - beware Tylo, it's big and you can't aerobrake.")) - .SetOperandAndAdvance("* 一般来说,天然卫星会更容易 - 从 Ike 或 Gilly 的表面收集科学点数要比从 Duna 或 Eve 收集更容易。但话又说回来,去 Tylo 要小心,它很大,还不能大气制动.") + .SetOperandAndAdvance("* 一般来说,天然卫星会更容易 - 从 Ike 或 Gilly 的表面收集科学点数要比从 Duna 或 Eve 收集更容易。但话又说回来,去 Tylo要小心,它很大,还不能利用大气制动.") .MatchStartForward(new CodeMatch(OpCodes.Ldstr, "* Most of Kerbin’s biomes include both splashed and landed situations. Landed at Kerbin’s water? First build an aircraft carrier.")) - .SetOperandAndAdvance("* Kerbin的大部分生态群落包含了溅落和着陆的情况。要着陆在 Kerbin 的水上?首先建造一个能停飞行器的载具吧,比如航空母舰。") + .SetOperandAndAdvance("* Kerbin的大部分生态群落包含了溅落和着陆的情况。要着陆在 Kerbin的水上?首先建造一个能停飞行器的载具吧,比如航空母舰。") ; return matcher.InstructionEnumeration(); } @@ -460,5 +466,132 @@ public static IEnumerable ResourcesName_Patch(IEnumerable + { + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.Body"), "FigureOutType"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.Body_FigureOutType_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.HelpWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.HelpWindow_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.HelpWindow"), "DrawWindowContents", new[] { typeof(int) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.HelpWindow_DrawWindowContents_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.PropertyGetter(AccessTools.TypeByName("ScienceChecklist.ScienceInstance"), "Description"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceInstance_Description_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ScienceWindow"), "Draw"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceWindow_Draw_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ScienceWindow"), "DrawControls", new[] { typeof(int) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceWindow_DrawControls_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ScienceWindow"), "DrawTitleBarButtons", new[] { typeof(Rect), typeof(bool) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ScienceWindow_DrawTitleBarButtons_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.SettingsWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.SettingsWindow_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.SettingsWindow"), "DrawWindowContents", new[] { typeof(int) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.SettingsWindow_DrawWindowContents_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.ShipStateWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ShipStateWindow_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ShipStateWindow"), "DrawBody"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ShipStateWindow_DrawBody_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.ShipStateWindow"), "DrawVessel"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ShipStateWindow_DrawVessel_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.Situation"), new[] { AccessTools.TypeByName("ScienceChecklist.Body"), typeof(ExperimentSituations), typeof(string), typeof(string) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.Situation_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.Situation"), "ToString", new[] { typeof(ExperimentSituations) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.Situation_ToString_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), new[] { AccessTools.TypeByName("ScienceChecklist.ScienceChecklistAddon") }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "DrawExperiment", new[] { AccessTools.TypeByName("ScienceChecklist.ScienceInstance"), typeof(Rect) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_DrawExperiment_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "DrawWindowContents", new[] { typeof(int) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_DrawWindowContents_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "MakeSituationToolTip"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_MakeSituationToolTip_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Method(AccessTools.TypeByName("ScienceChecklist.StatusWindow"), "UpdateSituation"), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.StatusWindow_UpdateSituation_Patch)), + PatchType.Transpiler + ), + new HarPatchInfo + ( + AccessTools.Constructor(AccessTools.TypeByName("ScienceChecklist.xResourceData"), new[] { typeof(string) }), + new HarmonyMethod(typeof(xSciencePatches), nameof(xSciencePatches.ResourcesName_Patch)), + PatchType.Transpiler + ) + }; + } } }