Skip to content

Window resize handle indication and scroll fix #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/main/kotlin/com/lambda/client/gui/AbstractLambdaGui.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class AbstractLambdaGui<S : SettingWindow<*>, E : Any> : GuiScreen() {

// Mouse
private var lastEventButton = -1
private var lastClickPos = Vec2f(0.0f, 0.0f)
private var lastClickPos = Vec2f.ZERO

// Searching
protected var typedString = ""
Expand Down Expand Up @@ -198,6 +198,7 @@ abstract class AbstractLambdaGui<S : SettingWindow<*>, E : Any> : GuiScreen() {
}
}

hoveredWindow?.onMouseInput(mousePos)
super.handleMouseInput()
updateSettingWindow()
}
Expand Down Expand Up @@ -284,8 +285,6 @@ abstract class AbstractLambdaGui<S : SettingWindow<*>, E : Any> : GuiScreen() {
drawTypedString()

GlStateUtils.depth(false)

hoveredWindow?.onMouseInput(getRealMousePos())
}

private fun drawBackground(vertexHelper: VertexHelper, partialTicks: Float) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ object LambdaClickGui : AbstractLambdaGui<ModuleSettingWindow, AbstractModule>()
var posX = 0.0f

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

posX += 90.0f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class PluginWindow(
cname: String,
cPosX: Float,
cPosY: Float,
) : ListWindow(cname, cPosX, cPosY, 120.0f, 200.0f, SettingGroup.CLICK_GUI) {
) : ListWindow(cname, cPosX, cPosY, 120.0f, 200.0f, SettingGroup.CLICK_GUI, drawHandle = true) {
override val minHeight: Float
get() = 100.0f
}
28 changes: 22 additions & 6 deletions src/main/kotlin/com/lambda/client/gui/rgui/windows/ListWindow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import com.lambda.client.gui.AbstractLambdaGui
import com.lambda.client.gui.rgui.Component
import com.lambda.client.gui.rgui.InteractiveComponent
import com.lambda.client.module.modules.client.ClickGUI
import com.lambda.client.module.modules.client.CustomFont
import com.lambda.client.module.modules.client.GuiColors
import com.lambda.client.util.TickTimer
import com.lambda.client.util.color.ColorHolder
import com.lambda.client.util.graphics.GlStateUtils
import com.lambda.client.util.graphics.VertexHelper
import com.lambda.client.util.graphics.font.FontRenderAdapter
import com.lambda.client.util.math.Vec2f
import org.lwjgl.input.Mouse
import org.lwjgl.opengl.GL11.*
Expand All @@ -21,7 +25,8 @@ open class ListWindow(
width: Float,
height: Float,
saveToConfig: SettingGroup,
vararg childrenIn: Component
vararg childrenIn: Component,
val drawHandle: Boolean = false
) : TitledWindow(name, posX, posY, width, height, saveToConfig) {
val children = ArrayList<Component>()

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

if (drawHandle) {
val handleText = "....."
val scale = 0.75f
val posX = renderWidth / 2 - FontRenderAdapter.getStringWidth(handleText, scale) / 2
val posY = renderHeight - 5 - FontRenderAdapter.getFontHeight(scale) / 2
val color = with(GuiColors.text) {
ColorHolder(r, g, b, (a * 0.6f).toInt())
}
FontRenderAdapter.drawString(handleText, posX, posY, CustomFont.shadow, color, scale)
}

synchronized(this) {
renderChildren {
it.onRender(vertexHelper, absolutePos.plus(it.renderPosX, it.renderPosY - renderScrollProgress))
Expand All @@ -171,14 +187,15 @@ open class ListWindow(
((renderPosX + ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(),
mc.displayHeight - ((renderPosY + renderHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt(),
((renderWidth - ClickGUI.horizontalMargin) * ClickGUI.getScaleFactor()).toInt(),
((renderHeight - draggableHeight - ClickGUI.resizeBar)* ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0)
((renderHeight - draggableHeight - ClickGUI.resizeBar) * ClickGUI.getScaleFactor()).toInt().coerceAtLeast(0)
)
glEnable(GL_SCISSOR_TEST)
glTranslatef(0.0f, -renderScrollProgress, 0.0f)

children.filter { it.visible
&& it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight
&& it.renderPosY - renderScrollProgress < renderHeight
children.filter {
it.visible
&& it.renderPosY + it.renderHeight - renderScrollProgress > draggableHeight
&& it.renderPosY - renderScrollProgress < renderHeight
}.forEach {
glPushMatrix()
glTranslatef(it.renderPosX, it.renderPosY, 0.0f)
Expand Down Expand Up @@ -211,7 +228,6 @@ open class ListWindow(
|| relativeMousePos.x < ClickGUI.horizontalMargin
|| relativeMousePos.x > renderWidth - ClickGUI.horizontalMargin
) null

else children.firstOrNull { it.visible && relativeMousePos.y in it.posY..it.posY + it.height }
}

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