File tree Expand file tree Collapse file tree 3 files changed +15
-4
lines changed
src/main/kotlin/xyz/bluspring/unitytranslate Expand file tree Collapse file tree 3 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import net.minecraft.client.resources.language.I18n
88import net.minecraft.network.chat.Component
99import net.minecraft.network.chat.FormattedText
1010import xyz.bluspring.unitytranslate.UnityTranslate
11+ import xyz.bluspring.unitytranslate.config.UnityTranslateConfig
1112
1213class OpenBrowserScreen (val address : String ) : Screen(Component .empty()) {
1314 override fun init () {
@@ -16,14 +17,23 @@ class OpenBrowserScreen(val address: String) : Screen(Component.empty()) {
1617 addRenderableWidget(
1718 Button .builder(Component .translatable(" unitytranslate.do_not_show_again" )) {
1819 Util .getPlatform().openUri(address)
19- UnityTranslate .config.client.openBrowserWithoutPrompt = true
20+ UnityTranslate .config.client.openBrowserWithoutPrompt = UnityTranslateConfig . TriState . TRUE
2021 UnityTranslate .saveConfig()
2122 this .onClose()
2223 }
2324 .pos(this .width / 2 - (Button .DEFAULT_WIDTH / 2 ), this .height - 20 - Button .DEFAULT_HEIGHT - 5 - Button .DEFAULT_HEIGHT - 15 )
2425 .build()
2526 )
2627
28+ addRenderableWidget(
29+ Button .builder(Component .translatable(" gui.copy_link_to_clipboard" )) {
30+ this .minecraft!! .keyboardHandler.clipboard = address
31+ this .onClose()
32+ }
33+ .pos(this .width / 2 - (Button .DEFAULT_WIDTH / 2 ), this .height - 20 - Button .DEFAULT_HEIGHT - 5 - Button .DEFAULT_HEIGHT - 5 - Button .DEFAULT_HEIGHT - 15 )
34+ .build()
35+ )
36+
2737 addRenderableWidget(
2838 Button .builder(Component .translatable(" unitytranslate.open_browser.open_in_browser" )) {
2939 Util .getPlatform().openUri(address)
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import xyz.bluspring.unitytranslate.client.gui.OpenBrowserScreen
1919import xyz.bluspring.unitytranslate.client.gui.RequestDownloadScreen
2020import xyz.bluspring.unitytranslate.client.transcribers.SpeechTranscriber
2121import xyz.bluspring.unitytranslate.client.transcribers.TranscriberType
22+ import xyz.bluspring.unitytranslate.config.UnityTranslateConfig
2223import java.net.InetSocketAddress
2324
2425class BrowserSpeechTranscriber (language : Language ) : SpeechTranscriber(language) {
@@ -49,9 +50,9 @@ class BrowserSpeechTranscriber(language: Language) : SpeechTranscriber(language)
4950 val mc = Minecraft .getInstance()
5051
5152 if (socket.totalConnections <= 0 && UnityTranslate .config.client.enabled) {
52- if (UnityTranslate .config.client.openBrowserWithoutPrompt) {
53+ if (UnityTranslate .config.client.openBrowserWithoutPrompt == UnityTranslateConfig . TriState . TRUE ) {
5354 Util .getPlatform().openUri(" http://127.0.0.1:$serverPort " )
54- } else {
55+ } else if ( UnityTranslate .config.client.openBrowserWithoutPrompt == UnityTranslateConfig . TriState . DEFAULT ) {
5556 Minecraft .getInstance().execute {
5657 if (mc.screen is RequestDownloadScreen ) {
5758 (mc.screen as RequestDownloadScreen ).parent = OpenBrowserScreen (" http://127.0.0.1:$serverPort " )
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ data class UnityTranslateConfig(
1313 @Serializable
1414 data class ClientConfig (
1515 var enabled : Boolean = true ,
16- var openBrowserWithoutPrompt : Boolean = false ,
16+ var openBrowserWithoutPrompt : TriState = TriState . DEFAULT ,
1717 var muteTranscriptWhenVoiceChatMuted : Boolean = true ,
1818
1919 @get:IntRange(from = 10, to = 300, increment = 10)
You can’t perform that action at this time.
0 commit comments