Skip to content

Commit 19bf35d

Browse files
committed
Implemented Lambda Set Title
1 parent ef5e7bc commit 19bf35d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

src/main/java/com/lambda/mixin/MinecraftClientMixin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@
2323
import com.lambda.event.events.InventoryEvent;
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.gui.DearImGui;
26+
import com.lambda.gui.components.ClickGuiLayout;
2627
import com.lambda.module.modules.player.Interact;
2728
import com.lambda.module.modules.player.InventoryMove;
2829
import com.lambda.module.modules.player.PacketMine;
30+
import com.lambda.util.WindowUtils;
2931
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
3032
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
3133
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
@@ -196,4 +198,11 @@ float getTargetMillisPerTick(float millis, Operation<Float> original) {
196198
else
197199
return (float) TimerManager.INSTANCE.getLength();
198200
}
201+
202+
@Inject(method = "updateWindowTitle", at = @At("HEAD"), cancellable = true)
203+
void updateWindowTitle(CallbackInfo ci) {
204+
if (!ClickGuiLayout.getSetLambdaWindowTitle()) return;
205+
WindowUtils.setLambdaTitle();
206+
ci.cancel();
207+
}
199208
}

src/main/kotlin/com/lambda/gui/components/ClickGuiLayout.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import com.lambda.sound.SoundManager.play
3737
import com.lambda.util.Describable
3838
import com.lambda.util.KeyCode
3939
import com.lambda.util.NamedEnum
40-
import com.lambda.util.WindowIcons.setLambdaWindowIcon
40+
import com.lambda.util.WindowUtils.setLambdaTitle
41+
import com.lambda.util.WindowUtils.setLambdaWindowIcon
4142
import imgui.ImGui
4243
import imgui.extension.implot.ImPlot
4344
import imgui.flag.ImGuiCol
@@ -90,7 +91,8 @@ object ClickGuiLayout : Loadable, Configurable(GuiConfig) {
9091
mc.window.setIcon(mc.defaultResourcePack, icon)
9192
}
9293
}
93-
val setLambdaWindowTitle by setting("Set Lambda Window Title", true).group(Group.General)
94+
@JvmStatic val setLambdaWindowTitle by setting("Set Lambda Window Title", true).onValueChange { _, _ -> mc.updateWindowTitle() }.group(Group.General)
95+
val lambdaTitleAppendixName by setting("Append Username", true) { setLambdaWindowTitle }.onValueChange { _, _ -> mc.updateWindowTitle() }.group(Group.General)
9496

9597
// Sizing
9698
val windowPaddingX by setting("Window Padding X", 8.0f, 0.0f..20.0f, 0.1f).group(Group.Sizing)

src/main/kotlin/com/lambda/util/WindowIcons.kt renamed to src/main/kotlin/com/lambda/util/WindowUtils.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818
package com.lambda.util
1919

20+
import com.lambda.Lambda.MOD_NAME
21+
import com.lambda.Lambda.SYMBOL
22+
import com.lambda.Lambda.VERSION
2023
import com.lambda.Lambda.mc
24+
import com.lambda.gui.components.ClickGuiLayout.lambdaTitleAppendixName
2125
import net.minecraft.client.util.MacWindowUtil
2226
import org.lwjgl.glfw.GLFW
2327
import org.lwjgl.glfw.GLFWImage
@@ -29,7 +33,19 @@ import java.io.ByteArrayOutputStream
2933
import java.nio.ByteBuffer
3034
import javax.imageio.ImageIO
3135

32-
object WindowIcons {
36+
object WindowUtils {
37+
/**
38+
* Updates the Lambda title for the application window.
39+
*
40+
* Constructs and sets the window title based on the current application symbol, name, version,
41+
* and additional dynamic details (e.g., username if `lambdaTitleAppendixName` is enabled).
42+
*/
43+
@JvmStatic
44+
fun setLambdaTitle() {
45+
val name = if (lambdaTitleAppendixName) " - ${mc.session.username}" else ""
46+
mc.window.setTitle("$SYMBOL $MOD_NAME $VERSION - ${mc.windowTitle}$name")
47+
}
48+
3349
/**
3450
* Sets the window icon for the application using a predefined set of icon sizes.
3551
*

0 commit comments

Comments
 (0)