Skip to content

Commit 099b0ec

Browse files
Window resize handle indication and scroll fix (#441)
* set rubberbanding speed default value to be equal to lambda 3.2.1 * added dots to the module window resize handles * restored scroll responsiveness * Remove the line that broke scrolling Co-authored-by: Constructor <fractalminds@protonmail.com>
1 parent f4f99ec commit 099b0ec

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
lines changed

Diff for: src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract class AbstractLambdaGui<S : SettingWindow<*>, E : Any> : GuiScreen() {
4545

4646
// Mouse
4747
private var lastEventButton = -1
48-
private var lastClickPos = Vec2f(0.0f, 0.0f)
48+
private var lastClickPos = Vec2f.ZERO
4949

5050
// Searching
5151
protected var typedString = ""
@@ -198,6 +198,7 @@ abstract class AbstractLambdaGui<S : SettingWindow<*>, E : Any> : GuiScreen() {
198198
}
199199
}
200200

201+
hoveredWindow?.onMouseInput(mousePos)
201202
super.handleMouseInput()
202203
updateSettingWindow()
203204
}
@@ -284,8 +285,6 @@ abstract class AbstractLambdaGui<S : SettingWindow<*>, E : Any> : GuiScreen() {
284285
drawTypedString()
285286

286287
GlStateUtils.depth(false)
287-
288-
hoveredWindow?.onMouseInput(getRealMousePos())
289288
}
290289

291290
private fun drawBackground(vertexHelper: VertexHelper, partialTicks: Float) {

Diff for: src/main/kotlin/com/lambda/client/gui/clickgui/LambdaClickGui.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object LambdaClickGui : AbstractLambdaGui<ModuleSettingWindow, AbstractModule>()
4141
var posX = 0.0f
4242

4343
Category.values().forEach { category ->
44-
val window = ListWindow(category.displayName, posX, 0.0f, 90.0f, 300.0f, Component.SettingGroup.CLICK_GUI)
44+
val window = ListWindow(category.displayName, posX, 0.0f, 90.0f, 300.0f, Component.SettingGroup.CLICK_GUI, drawHandle = true)
4545
windows.add(window)
4646

4747
posX += 90.0f

Diff for: src/main/kotlin/com/lambda/client/gui/clickgui/component/PluginWindow.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class PluginWindow(
66
cname: String,
77
cPosX: Float,
88
cPosY: Float,
9-
) : ListWindow(cname, cPosX, cPosY, 120.0f, 200.0f, SettingGroup.CLICK_GUI) {
9+
) : ListWindow(cname, cPosX, cPosY, 120.0f, 200.0f, SettingGroup.CLICK_GUI, drawHandle = true) {
1010
override val minHeight: Float
1111
get() = 100.0f
1212
}

Diff for: src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt

+22-6
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ import com.lambda.client.gui.AbstractLambdaGui
55
import com.lambda.client.gui.rgui.Component
66
import com.lambda.client.gui.rgui.InteractiveComponent
77
import com.lambda.client.module.modules.client.ClickGUI
8+
import com.lambda.client.module.modules.client.CustomFont
9+
import com.lambda.client.module.modules.client.GuiColors
810
import com.lambda.client.util.TickTimer
11+
import com.lambda.client.util.color.ColorHolder
912
import com.lambda.client.util.graphics.GlStateUtils
1013
import com.lambda.client.util.graphics.VertexHelper
14+
import com.lambda.client.util.graphics.font.FontRenderAdapter
1115
import com.lambda.client.util.math.Vec2f
1216
import org.lwjgl.input.Mouse
1317
import org.lwjgl.opengl.GL11.*
@@ -21,7 +25,8 @@ open class ListWindow(
2125
width: Float,
2226
height: Float,
2327
saveToConfig: SettingGroup,
24-
vararg childrenIn: Component
28+
vararg childrenIn: Component,
29+
val drawHandle: Boolean = false
2530
) : TitledWindow(name, posX, posY, width, height, saveToConfig) {
2631
val children = ArrayList<Component>()
2732

@@ -147,6 +152,17 @@ open class ListWindow(
147152
override fun onRender(vertexHelper: VertexHelper, absolutePos: Vec2f) {
148153
super.onRender(vertexHelper, absolutePos)
149154

155+
if (drawHandle) {
156+
val handleText = "....."
157+
val scale = 0.75f
158+
val posX = renderWidth / 2 - FontRenderAdapter.getStringWidth(handleText, scale) / 2
159+
val posY = renderHeight - 5 - FontRenderAdapter.getFontHeight(scale) / 2
160+
val color = with(GuiColors.text) {
161+
ColorHolder(r, g, b, (a * 0.6f).toInt())
162+
}
163+
FontRenderAdapter.drawString(handleText, posX, posY, CustomFont.shadow, color, scale)
164+
}
165+
150166
synchronized(this) {
151167
renderChildren {
152168
it.onRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress))
@@ -171,14 +187,15 @@ open class ListWindow(
171187
((renderPosX + ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(),
172188
mc.displayHeight - ((renderPosY + renderHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt(),
173189
((renderWidth - ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(),
174-
((renderHeight - draggableHeight - ClickGUI.resizeBar)* ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0)
190+
((renderHeight - draggableHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0)
175191
)
176192
glEnable(GL_SCISSOR_TEST)
177193
glTranslatef(0.0f, -renderScrollProgress, 0.0f)
178194

179-
children.filter { it.visible
180-
&& it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight
181-
&& it.renderPosY - renderScrollProgress < renderHeight
195+
children.filter {
196+
it.visible
197+
&& it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight
198+
&& it.renderPosY - renderScrollProgress < renderHeight
182199
}.forEach {
183200
glPushMatrix()
184201
glTranslatef(it.renderPosX, it.renderPosY, 0.0f)
@@ -211,7 +228,6 @@ open class ListWindow(
211228
|| relativeMousePos.x < ClickGUI.horizontalMargin
212229
|| relativeMousePos.x > renderWidth - ClickGUI.horizontalMargin
213230
) null
214-
215231
else children.firstOrNull { it.visible && relativeMousePos.y in it.posY..it.posY + it.height }
216232
}
217233

Diff for: src/main/kotlin/com/lambda/client/module/modules/client/ClickGUI.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object ClickGUI : Module(
3232
val fadeInTime by setting("Fade In Time", 0.25f, 0.0f..1.0f, 0.05f, unit = "s")
3333
val fadeOutTime by setting("Fade Out Time", 0.1f, 0.0f..1.0f, 0.05f, unit = "s")
3434
val scrollRubberband by setting("Scroll Rubberband", false)
35-
val scrollRubberbandSpeed by setting("Scroll Rubberband Speed", 0.5f, 0.01f..1.0f, 0.05f, { scrollRubberband })
35+
val scrollRubberbandSpeed by setting("Scroll Rubberband Speed", 0.25f, 0.01f..1.0f, 0.05f, { scrollRubberband })
3636
val showModifiedInBold by setting("Show Modified In Bold", false, description = "Display modified settings in a bold font")
3737
private val resetComponents = setting("Reset Positions", false)
3838
private val resetScale = setting("Reset Scale", false)

0 commit comments

Comments
 (0)