|
|
@@ -3,17 +3,15 @@ using EFT;
|
|
|
using EFT.UI;
|
|
|
using EFT.UI.Matchmaker;
|
|
|
using HarmonyLib;
|
|
|
-using OneShot.Core;
|
|
|
|
|
|
namespace OneShot.Patches
|
|
|
{
|
|
|
/// <summary>
|
|
|
- /// 主菜单“开始游戏”按钮状态补丁:限制生效时置灰并显示本地化悬停提示,未生效时不干预、交由游戏原生逻辑决定。
|
|
|
- /// 仅通过原生 <see cref="DefaultUIButton.Interactable"/> 置灰(原生 alpha 0.3 且禁用点击),不自行改色、改布局或新建 UI。
|
|
|
- /// Patches the main menu "play" button: greys it out with a localized tooltip while the restriction is
|
|
|
- /// active, and leaves it untouched otherwise so native game logic decides. Greying only relies on the native
|
|
|
- /// <see cref="DefaultUIButton.Interactable"/> (native alpha 0.3 and click disabled); no recoloring,
|
|
|
- /// re-layout or new UI elements are introduced.
|
|
|
+ /// 主菜单“开始游戏”按钮状态补丁:限制生效时置灰,未生效时不干预、交由游戏原生逻辑决定。
|
|
|
+ /// 仅通过原生 <see cref="DefaultUIButton.Interactable"/> 置灰(原生 alpha 0.3 且禁用点击),不显示提示、不自行改色、改布局或新建 UI。
|
|
|
+ /// Patches the main menu "play" button: greys it out while the restriction is active, and leaves it untouched
|
|
|
+ /// otherwise so native game logic decides. Greying only relies on the native <see cref="DefaultUIButton.Interactable"/>
|
|
|
+ /// (native alpha 0.3 and click disabled); no tooltip, recoloring, re-layout or new UI elements are introduced.
|
|
|
/// </summary>
|
|
|
[HarmonyPatch(typeof(MenuScreen))]
|
|
|
internal static class PlayButtonStatePatch
|
|
|
@@ -47,8 +45,8 @@ namespace OneShot.Patches
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 计算并施加“开始游戏”按钮状态:仅限制生效时置灰并挂提示,否则直接返回、不触碰按钮。幂等:重复调用不会叠加副作用。
|
|
|
- /// Computes and applies the play button state: only greys it out with a tooltip when blocked, otherwise returns without
|
|
|
+ /// 计算并施加“开始游戏”按钮状态:仅限制生效时置灰,否则直接返回、不触碰按钮。幂等:重复调用不会叠加副作用。
|
|
|
+ /// Computes and applies the play button state: only greys it out when blocked, otherwise returns without
|
|
|
/// touching the button. Idempotent: repeated calls accumulate no side effects.
|
|
|
/// </summary>
|
|
|
private static void ApplyState(MenuScreen menuScreen)
|
|
|
@@ -60,8 +58,8 @@ namespace OneShot.Patches
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- bool enabled = PluginConfig.Enabled != null && PluginConfig.Enabled.Value;
|
|
|
- bool blocked = OneShotPlugin.Gate != null && OneShotPlugin.Gate.ShouldBlockStart(enabled);
|
|
|
+ bool blocked = PluginConfig.Enabled != null && PluginConfig.Enabled.Value
|
|
|
+ && OneShotPlugin.Gate != null && OneShotPlugin.Gate.ShouldBlockStart(true);
|
|
|
|
|
|
if (!blocked)
|
|
|
{
|
|
|
@@ -72,21 +70,9 @@ namespace OneShot.Patches
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 先登记禁用态悬停提示,再置灰;Interactable 的 setter 会据当前状态刷新提示。
|
|
|
- // Register the disabled tooltip first, then grey out; the Interactable setter refreshes the tooltip for the new state.
|
|
|
- menuScreen._playButton.SetDisabledTooltip(GetBlockedTooltip);
|
|
|
+ // 仅置灰,不挂提示;Interactable 的 setter 会据当前状态刷新按钮外观。
|
|
|
+ // Grey out only, no tooltip; the Interactable setter refreshes the button appearance for the new state.
|
|
|
menuScreen._playButton.Interactable = false;
|
|
|
}
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 读取游戏当前语言并返回“已被限制”的本地化提示;语言管理器缺失时回退英文。
|
|
|
- /// Reads the current game culture and returns the localized "blocked" message; falls back to English when the localization manager is missing.
|
|
|
- /// </summary>
|
|
|
- private static string GetBlockedTooltip()
|
|
|
- {
|
|
|
- LocalizationManager manager = LocalizationManager.Instance;
|
|
|
- string culture = manager == null ? null : manager.Culture;
|
|
|
- return OneShotText.Get(LocaleSelector.Resolve(culture));
|
|
|
- }
|
|
|
}
|
|
|
}
|