Skip to content

Commit 5b40571

Browse files
Add toggling
1 parent c9adad3 commit 5b40571

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

sources/main/java/net/lax1dude/eaglercraft/v1_8/voice/GuiVoiceOverlay.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
2+
* Copyright (c) 2022-2024 lax1dude, ayunami2000, Stoppedwumm. All Rights Reserved.
33
*
44
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
55
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -22,7 +22,6 @@
2222
import java.util.List;
2323
import java.util.Set;
2424

25-
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
2625
import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
2726
import net.lax1dude.eaglercraft.v1_8.Keyboard;
2827
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
@@ -38,8 +37,6 @@ public class GuiVoiceOverlay extends Gui {
3837
public int width;
3938
public int height;
4039

41-
private long pttTimer = 0l;
42-
4340
public GuiVoiceOverlay(Minecraft mc) {
4441
this.mc = mc;
4542
}
@@ -83,26 +80,15 @@ public void drawOverlay() {
8380

8481
mc.getTextureManager().bindTexture(voiceGuiIcons);
8582

86-
if((mc.currentScreen == null || !mc.currentScreen.blockPTTKey()) && Keyboard.isKeyDown(mc.gameSettings.voicePTTKey)) {
87-
long millis = EagRuntime.steadyTimeMillis();
88-
if(pttTimer == 0l) {
89-
pttTimer = millis;
90-
}
83+
if(VoiceClientController.isTalking()) {
84+
// Draw the "ON" icon (red microphone)
9185
GlStateManager.color(0.2f, 0.2f, 0.2f, 1.0f);
9286
drawTexturedModalRect(0, 0, 0, 64, 32, 32);
9387
GlStateManager.translate(-1.5f, -1.5f, 0.0f);
94-
if(millis - pttTimer < 1050l) {
95-
if((millis - pttTimer) % 300l < 150l) {
96-
GlStateManager.color(0.9f, 0.2f, 0.2f, 1.0f);
97-
}else {
98-
GlStateManager.color(0.9f, 0.7f, 0.7f, 1.0f);
99-
}
100-
}else {
101-
GlStateManager.color(0.9f, 0.3f, 0.3f, 1.0f);
102-
}
88+
GlStateManager.color(0.9f, 0.3f, 0.3f, 1.0f);
10389
drawTexturedModalRect(0, 0, 0, 64, 32, 32);
104-
}else {
105-
pttTimer = 0l;
90+
} else {
91+
// Draw the "OFF" icon (white microphone)
10692
GlStateManager.color(0.2f, 0.2f, 0.2f, 1.0f);
10793
drawTexturedModalRect(0, 0, 0, 32, 32, 32);
10894
GlStateManager.translate(-1.5f, -1.5f, 0.0f);
@@ -170,7 +156,6 @@ public void drawOverlay() {
170156

171157
for(int i = 0, l = listenerList.size(); i < l && i < 5; ++i) {
172158
boolean speaking = speakers.contains(listenerList.get(i));
173-
float speakf = speaking ? 1.0f : 0.75f;
174159

175160
drawString(mc.fontRendererObj, listenerListStr.get(i), ww - left, hh - 13 - i * 11, speaking ? 0xEEEEEE : 0xBBBBBB);
176161

@@ -179,6 +164,7 @@ public void drawOverlay() {
179164
GlStateManager.pushMatrix();
180165
GlStateManager.translate(ww - left - 14, hh - 14 - i * 11, 0.0f);
181166

167+
float speakf = speaking ? 1.0f : 0.75f;
182168
GlStateManager.scale(0.75f, 0.75f, 0.75f);
183169
GlStateManager.color(speakf * 0.2f, speakf * 0.2f, speakf * 0.2f, 1.0f);
184170
drawTexturedModalRect(0, 0, 64, speaking ? 176 : 208, 16, 16);

sources/main/java/net/lax1dude/eaglercraft/v1_8/voice/VoiceClientController.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1010
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1111
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
12-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
12+
* ARISING IN ANY WAY OUT of THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1313
* POSSIBILITY OF SUCH DAMAGE.
1414
*
1515
*/
@@ -140,8 +140,6 @@ public static void handleVoiceSignalPacketTypeDescription(EaglercraftUUID user,
140140
voiceClient.handleVoiceSignalPacketTypeDescription(user, desc);
141141
}
142142
}
143-
144-
// ++-===== MODIFICATION START =====-++
145143

146144
private static boolean voiceToggled = false;
147145
private static boolean pttKeyWasDown = false;
@@ -175,8 +173,6 @@ public static void tickVoiceClient() {
175173
}
176174
}
177175

178-
// ++-====== MODIFICATION END ======-++
179-
180176
public static void setVoiceChannel(EnumVoiceChannelType channel) {
181177
if (voiceClient != null) {
182178
voiceClient.setVoiceChannel(channel);
@@ -207,6 +203,10 @@ public static void activateVoice(boolean talk) {
207203
talkStatus = talk;
208204
}
209205
}
206+
207+
public static boolean isTalking() {
208+
return talkStatus;
209+
}
210210

211211
private static int proximity = 16;
212212

0 commit comments

Comments
 (0)