diff --git a/src/client/kotlin/xyz/thewhitedog9487/client/Miscellaneous.kt b/src/client/kotlin/xyz/thewhitedog9487/client/Miscellaneous.kt index ac42f84..83cd491 100644 --- a/src/client/kotlin/xyz/thewhitedog9487/client/Miscellaneous.kt +++ b/src/client/kotlin/xyz/thewhitedog9487/client/Miscellaneous.kt @@ -34,7 +34,8 @@ data class ModInfo(val ModContainerInstance: ModContainer?) { val ID: String = ModContainerInstance?.metadata?.id ?: Component.translatable("special_provider_UNKNOWN").string val MetaData: ModMetadata? = ModContainerInstance?.metadata val DisplayName: String = MetaData?.name ?: Component.translatable("special_provider_UNKNOWN").string - val HumanFriendlyName: Component = Component.translatableWithFallback("modmenu.nameTranslation." + (MetaData?.id ?: "unknown"), DisplayName) } + val HumanFriendlyName: Component = Component.translatableWithFallback("modmenu.nameTranslation." + (MetaData?.id ?: "unknown"), DisplayName) + val FilePath: String = ModContainerInstance?.origin?.paths?.joinToString("\n") { it.pathString } ?: Component.translatable("special_string_UNKNOWN").string } fun Button.SetNewTooltip(Key: KeyMapping) { if (SettingsInstance.ModEnabled == false) return @@ -62,4 +63,9 @@ fun Button.SetNewTooltip(Key: KeyMapping) { .append(Component.translatable("tooltip.key_id", Component.literal(Key.name))) } + // 第四行:文件路径 + if (SettingsInstance.ShowFilePath) { + NewTooltip.append(Component.literal("\n")) + .append(Component.translatable("tooltip.mod_file_path", Mod.FilePath)) } + setTooltip(Tooltip.create(NewTooltip)) } \ No newline at end of file diff --git a/src/client/kotlin/xyz/thewhitedog9487/client/ModMenuEntryPoint.kt b/src/client/kotlin/xyz/thewhitedog9487/client/ModMenuEntryPoint.kt index 7fa0835..8f3b400 100644 --- a/src/client/kotlin/xyz/thewhitedog9487/client/ModMenuEntryPoint.kt +++ b/src/client/kotlin/xyz/thewhitedog9487/client/ModMenuEntryPoint.kt @@ -51,6 +51,13 @@ class ModMenuEntryPoint: ModMenuApi { .binding( false, { SettingsInstance.SearchInStackTrace }, { SettingsInstance.SearchInStackTrace = it } ) .controller(BooleanControllerBuilder::create ) .build() } + .option { + Option.createBuilder() + .name(Component.translatable("option.ShowFilePath")) + .description { OptionDescription.of(Component.translatable("option.ShowFilePath.description") ) } + .binding( false, { SettingsInstance.ShowFilePath }, { SettingsInstance.ShowFilePath = it } ) + .controller(BooleanControllerBuilder::create ) + .build() } .build() } .build() .generateScreen(ParentScreen) } } \ No newline at end of file diff --git a/src/main/resources/assets/whoprovidethiskeybind/lang/en_us.json b/src/main/resources/assets/whoprovidethiskeybind/lang/en_us.json index 16c6695..d94cd5b 100644 --- a/src/main/resources/assets/whoprovidethiskeybind/lang/en_us.json +++ b/src/main/resources/assets/whoprovidethiskeybind/lang/en_us.json @@ -13,6 +13,8 @@ "option.ShowKeybindID.description": "Display the keybind's own ID in the tooltip", "option.ShowDebugInfo": "Show Debug Info", "option.ShowDebugInfo.description": "This information is used to troubleshoot issues related to this mod; it generally does not need to be enabled", + "option.ShowFilePath": "Show File Path", + "option.ShowFilePath.description": "Display the mod file path in the information", "option.SearchInStackTrace": "Enable aggressive search via stack trace lookup", "option.SearchInStackTrace.description": "Injects into the KeyMapping class constructor and queries the current thread's call stack each time a keybind is registered for aggressive matching\nWarning: In some cases, this may produce more false positives; enable as needed", "tooltip.provided_by": "Provided by: %s", diff --git a/src/main/resources/assets/whoprovidethiskeybind/lang/zh_cn.json b/src/main/resources/assets/whoprovidethiskeybind/lang/zh_cn.json index ffa3977..254a722 100644 --- a/src/main/resources/assets/whoprovidethiskeybind/lang/zh_cn.json +++ b/src/main/resources/assets/whoprovidethiskeybind/lang/zh_cn.json @@ -13,6 +13,8 @@ "option.ShowKeybindID.description": "在提示信息中显示该按键本身的ID", "option.ShowDebugInfo": "是否显示调试信息", "option.ShowDebugInfo.description": "这些信息用于出现和本Mod相关的问题时进行排查,一般情况下不需要开启", + "option.ShowFilePath": "是否显示文件路径", + "option.ShowFilePath.description": "在信息中显示Mod的文件路径", "option.SearchInStackTrace": "是否要通过查询堆栈信息来进行强力搜索", "option.SearchInStackTrace.description": "注入KeyMapping类的构造函数,在每次注册按键绑定时查询线程的调用栈信息来进行强力匹配\n警告:部分情况下可能产生更多误报,请按需选择", "tooltip.provided_by": "提供者:%s",