Skip to content

Commit 455c94d

Browse files
authored
Feature: Menu Bar, improved GUI layout and QuickSearch (#140)
1 parent 0177bf0 commit 455c94d

33 files changed

+1067
-116
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ void injectConstructor(String message, Throwable cause, CallbackInfo ci) {
5454
@WrapMethod(method = "asString(Lnet/minecraft/util/crash/ReportType;Ljava/util/List;)Ljava/lang/String;")
5555
String injectString(ReportType type, List<String> extraInfo, Operation<String> original) {
5656
var list = new ArrayList<>(extraInfo);
57-
58-
list.add("If this issue is related to Lambda, check if other users have experienced this too, or create a new issue at https://github.com/lambda-client/lambda/issues.\n\n");
57+
list.add("If this issue is related to Lambda, check if other users have experienced this too, or create a new issue at " + Lambda.REPO_URL + "/issues.\n\n");
5958

6059
if (MinecraftClient.getInstance() != null) {
6160
list.add("Enabled modules:");
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.mixin.render;
19+
20+
import com.lambda.gui.components.QuickSearch;
21+
import net.minecraft.client.gui.screen.Screen;
22+
import org.lwjgl.glfw.GLFW;
23+
import org.spongepowered.asm.mixin.Mixin;
24+
import org.spongepowered.asm.mixin.injection.At;
25+
import org.spongepowered.asm.mixin.injection.Inject;
26+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
27+
28+
@Mixin(Screen.class)
29+
public class ScreenMixin {
30+
31+
@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
32+
private void onKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
33+
if (keyCode == GLFW.GLFW_KEY_ESCAPE && QuickSearch.INSTANCE.isOpen()) {
34+
QuickSearch.INSTANCE.close();
35+
cir.setReturnValue(true);
36+
}
37+
}
38+
}

src/main/kotlin/com/lambda/Lambda.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ object Lambda : ClientModInitializer {
5151
const val MOD_ID = "lambda"
5252
const val SYMBOL = "λ"
5353
const val APP_ID = "1221289599427416127"
54+
const val REPO_URL = "https://github.com/lambda-client/lambda"
5455
val VERSION: String = FabricLoader.getInstance()
5556
.getModContainer("lambda").orElseThrow()
5657
.metadata.version.friendlyString

src/main/kotlin/com/lambda/config/AbstractSetting.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ abstract class AbstractSetting<T : Any>(
158158
groups.add(path.toList())
159159
}
160160

161-
fun reset() {
162-
if (value == defaultValue) {
161+
fun reset(silent: Boolean = false) {
162+
if (!silent && value == defaultValue) {
163163
ConfigCommand.info(notChangedMessage())
164164
return
165165
}
166-
ConfigCommand.info(resetMessage(value, defaultValue))
166+
if (!silent) ConfigCommand.info(resetMessage(value, defaultValue))
167167
value = defaultValue
168168
}
169169

src/main/kotlin/com/lambda/gui/DearImGui.kt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,26 @@ import com.lambda.module.modules.client.GuiSettings
2626
import com.lambda.util.path
2727
import com.mojang.blaze3d.opengl.GlStateManager
2828
import com.mojang.blaze3d.systems.RenderSystem
29+
import imgui.ImFontConfig
30+
import imgui.ImFontGlyphRangesBuilder
2931
import imgui.ImGui
3032
import imgui.ImGuiIO
3133
import imgui.flag.ImGuiConfigFlags
3234
import imgui.gl3.ImGuiImplGl3
3335
import imgui.glfw.ImGuiImplGlfw
3436
import net.minecraft.client.gl.GlBackend
3537
import net.minecraft.client.texture.GlTexture
36-
import org.lwjgl.opengl.GL11.glViewport
3738
import org.lwjgl.opengl.GL30.GL_FRAMEBUFFER
3839
import kotlin.math.abs
3940

4041
object DearImGui : Loadable {
4142
val implGlfw = ImGuiImplGlfw()
4243
val implGl3 = ImGuiImplGl3()
4344

45+
const val EXTERNAL_LINK = ''
46+
const val BREADCRUMB_SEPARATOR = '»'
47+
const val BASE_FONT_SCALE = 13f
48+
4449
val io: ImGuiIO get() = ImGui.getIO()
4550
const val DEFAULT_FLAGS = ImGuiConfigFlags.NavEnableKeyboard or // Enable Keyboard Controls
4651
ImGuiConfigFlags.NavEnableSetMousePos or // Move the cursor using the keyboard
@@ -52,11 +57,20 @@ object DearImGui : Loadable {
5257
private var targetScale = 0f
5358

5459
private fun updateScale(scale: Float) {
55-
io.fonts.clear()
56-
val baseFontSize = 13f
57-
io.fonts.addFontFromFileTTF("fonts/FiraSans-Regular.ttf".path, baseFontSize * scale)
58-
io.fonts.build()
59-
60+
val glyphRanges = ImFontGlyphRangesBuilder().apply {
61+
addRanges(io.fonts.glyphRangesDefault)
62+
addRanges(io.fonts.glyphRangesGreek)
63+
addChar(EXTERNAL_LINK)
64+
addChar(BREADCRUMB_SEPARATOR)
65+
}.buildRanges()
66+
val fontConfig = ImFontConfig()
67+
val size = BASE_FONT_SCALE * scale
68+
with(io.fonts) {
69+
clear()
70+
addFontFromFileTTF("fonts/FiraSans-Regular.ttf".path, size, fontConfig, glyphRanges)
71+
addFontFromFileTTF("fonts/MinecraftDefault-Regular.ttf".path, size, fontConfig, glyphRanges)
72+
build()
73+
}
6074
implGl3.createFontsTexture()
6175
}
6276

src/main/kotlin/com/lambda/gui/LambdaScreen.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import net.minecraft.client.gui.DrawContext
2222
import net.minecraft.client.gui.screen.Screen
2323
import net.minecraft.text.Text
2424

25-
26-
object LambdaScreen : Screen(Text.of("")) {
25+
object LambdaScreen : Screen(Text.of("Lambda")) {
2726
override fun shouldPause() = false
2827
override fun removed() = ClickGui.disable()
2928
override fun render(context: DrawContext?, mouseX: Int, mouseY: Int, deltaTicks: Float) {}

0 commit comments

Comments
 (0)