/
AdvancedTabWidget.java
186 lines (171 loc) · 8.96 KB
/
AdvancedTabWidget.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package su.plo.voice.client.gui.tabs;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import su.plo.voice.client.VoiceClient;
import su.plo.voice.client.config.ClientConfig;
import su.plo.voice.client.gui.VoiceSettingsScreen;
import su.plo.voice.client.gui.widgets.ConfigIntegerSlider;
import su.plo.voice.client.gui.widgets.MicrophoneThresholdWidget;
import su.plo.voice.client.gui.widgets.ToggleButton;
import su.plo.voice.client.gui.widgets.VoiceVolumeSlider;
import su.plo.voice.client.socket.SocketClientUDPQueue;
import su.plo.voice.client.sound.openal.CustomSoundEngine;
import su.plo.voice.client.utils.TextUtils;
import su.plo.voice.rnnoise.Denoiser;
public class AdvancedTabWidget extends TabWidget {
public AdvancedTabWidget(Minecraft client, VoiceSettingsScreen parent) {
super(client, parent);
ClientConfig config = VoiceClient.getClientConfig();
ToggleButton rnNoise = new ToggleButton(0, 0, 97, 20, config.rnNoise,
toggled -> {
VoiceClient.recorder.toggleRnNoise();
});
rnNoise.active = Denoiser.platformSupported();
this.addEntry(new CategoryEntry(new TranslatableComponent("gui.plasmo_voice.advanced.noise_reduction")));
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.rnnoise"),
rnNoise,
config.rnNoise,
TextUtils.multiLine("gui.plasmo_voice.advanced.rnnoise.tooltip", 6),
(button, element) -> {
VoiceClient.recorder.toggleRnNoise();
((ToggleButton) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.microphone_testing"),
new MicrophoneThresholdWidget(0, 0, 97, false, parent),
null,
null)
);
// this.addEntry(new OptionEntry(
// new TranslatableComponent("jopus mode"),
// new DropDownWidget(parent, 0, 0, 97, 20,
// new TextComponent(config.jopusMode.get()),
// ImmutableList.of(new TextComponent("voip"), new TextComponent("audio"), new TextComponent("low-delay")),
// false,
// i -> {
// VoiceClient.recorder.updateJopusMode();
// config.jopusMode.set(ImmutableList.of("voip", "audio", "low-delay").get(i));
// }),
// config.jopusMode,
// (button, element) -> {
// VoiceClient.recorder.updateJopusMode();
// element.setMessage(new TextComponent(config.jopusMode.get()));
// })
// );
this.addEntry(new CategoryEntry(new TranslatableComponent("gui.plasmo_voice.advanced.compressor")));
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.compressor"),
new ToggleButton(0, 0, 97, 20, config.compressor,
toggled -> {}),
VoiceClient.getClientConfig().compressor,
TextUtils.multiLine("gui.plasmo_voice.advanced.compressor.tooltip", 4),
(button, element) -> {
((ToggleButton) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.compressor.threshold"),
new ConfigIntegerSlider(0, 0, 97, new TextComponent("dB"), config.compressorThreshold, null),
VoiceClient.getClientConfig().compressorThreshold,
TextUtils.multiLine("gui.plasmo_voice.advanced.compressor.threshold.tooltip", 4),
(button, element) -> {
((ConfigIntegerSlider) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.limiter.threshold"),
new ConfigIntegerSlider(0, 0, 97, new TextComponent("dB"), config.limiterThreshold, null),
VoiceClient.getClientConfig().limiterThreshold,
TextUtils.multiLine("gui.plasmo_voice.advanced.limiter.threshold.tooltip", 3),
(button, element) -> {
((ConfigIntegerSlider) element).updateValue();
})
);
ConfigIntegerSlider directionalSourcesAngle = new ConfigIntegerSlider(0, 0, 97, config.directionalSourcesAngle);
ToggleButton directionalSources = new ToggleButton(0, 0, 97, 20, config.directionalSources,
toggled -> directionalSourcesAngle.active = toggled);
directionalSourcesAngle.active = config.directionalSources.get();
this.addEntry(new CategoryEntry(new TranslatableComponent("gui.plasmo_voice.advanced.engine")));
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.hrtf"),
new ToggleButton(0, 0, 97, 20, config.hrtf,
toggled -> VoiceClient.getSoundEngine().restart()),
config.hrtf,
TextUtils.multiLine("gui.plasmo_voice.advanced.hrtf.tooltip", 7),
(button, element) -> {
VoiceClient.getSoundEngine().restart();
((ToggleButton) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.directional_sources"),
directionalSources,
config.directionalSources,
TextUtils.multiLine("gui.plasmo_voice.advanced.directional_sources.tooltip", 5),
(button, element) -> {
// kill all queues to prevent possible problems
SocketClientUDPQueue.closeAll();
directionalSourcesAngle.active = config.directionalSources.get();
((ToggleButton) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.directional_sources_angle"),
directionalSourcesAngle,
config.directionalSourcesAngle,
TextUtils.multiLine("gui.plasmo_voice.advanced.directional_sources_angle.tooltip", 4),
(button, element) -> {
// kill all queues to prevent possible problems
SocketClientUDPQueue.closeAll();
((ConfigIntegerSlider) element).updateValue();
})
);
this.addEntry(new CategoryEntry(new TranslatableComponent("gui.plasmo_voice.advanced.visual_ui")));
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.visual_ui.distance"),
new ToggleButton(0, 0, 97, 20, config.visualizeDistance,
toggled -> {}),
config.visualizeDistance,
(button, element) -> {
((ToggleButton) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.visual_ui.priority"),
new ToggleButton(0, 0, 97, 20, config.showPriorityVolume,
toggled -> {
parent.updateGeneralTab();
}),
config.showPriorityVolume,
TextUtils.multiLine("gui.plasmo_voice.advanced.visual_ui.priority.tooltip", 2),
(button, element) -> {
((ToggleButton) element).updateValue();
parent.updateGeneralTab();
})
);
if (CustomSoundEngine.soundPhysicsReverb != null) {
this.addEntry(new CategoryEntry(new TextComponent("Sound Physics")));
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.sp.mic_reverb"),
new ToggleButton(0, 0, 97, 20, config.micReverb,
toggled -> {}),
config.micReverb,
TextUtils.multiLine("gui.plasmo_voice.advanced.sp.mic_reverb.tooltip", 1),
(button, element) -> {
((ToggleButton) element).updateValue();
})
);
this.addEntry(new OptionEntry(
new TranslatableComponent("gui.plasmo_voice.advanced.sp.mic_reverb_volume"),
new VoiceVolumeSlider(0, 0, 97, VoiceClient.getClientConfig().micReverbVolume),
VoiceClient.getClientConfig().micReverbVolume,
(button, element) -> {
((VoiceVolumeSlider) element).updateValue();
})
);
}
}
}