Skip to content

Commit a03f8d4

Browse files
committed
truncate module headers with tooltips to keep sliders unobstructed
reposition the font selector closer to its label and align with other controls extend numeric setting handling to BlockValue entries alongside floats and ints Fix range dragging and update module scroll height
1 parent 093e8a8 commit a03f8d4

File tree

9 files changed

+210
-68
lines changed

9 files changed

+210
-68
lines changed

src/main/java/net/ccbluex/liquidbounce/ui/client/clickgui/style/styles/nlclickgui/NeverloseGui.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
/*
2+
* FDPClient Hacked Client
3+
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
4+
* https://github.com/SkidderMC/FDPClient/
5+
*/
16
package net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.nlclickgui
27

38
import com.mojang.realmsclient.gui.ChatFormatting
4-
import net.ccbluex.liquidbounce.FDPClient
9+
import net.ccbluex.liquidbounce.FDPClient.CLIENT_NAME
10+
import net.ccbluex.liquidbounce.FDPClient.fileManager
511
import net.ccbluex.liquidbounce.features.module.Category
612
import net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.fdpdropdown.utils.render.StencilUtil
713
import net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.nlclickgui.Config.Configs
@@ -39,7 +45,7 @@ class NeverloseGui : GuiScreen() {
3945
private var settings = false
4046
private var search = false
4147
private var searchText = ""
42-
private val defaultAvatar = ResourceLocation(FDPClient.CLIENT_NAME.lowercase(Locale.getDefault()) + "/64.png")
48+
private val defaultAvatar = ResourceLocation(CLIENT_NAME.lowercase(Locale.getDefault()) + "/64.png")
4349
private var avatarTexture: ResourceLocation = defaultAvatar
4450
private var avatarLoaded = false
4551
private var nlSetting: NlSetting = NlSetting()
@@ -118,7 +124,7 @@ class NeverloseGui : GuiScreen() {
118124
Fonts.Nl_18.drawString(mc.session.username, (x + 29).toFloat(), (avatarY + 1).toFloat(), if (light) Color(51, 51, 51).rgb else -1)
119125
Fonts.Nl_16.drawString(ChatFormatting.GRAY.toString() + "Till: " + ChatFormatting.RESET + SimpleDateFormat("dd:MM").format(Date()) + " " + SimpleDateFormat("HH:mm").format(Date()), (x + 29).toFloat(), (avatarY + 13).toFloat(), neverlosecolor.rgb)
120126
if (!light) {
121-
NLOutline("FDPCLIENT", Fonts.NLBold_28, (x + 7).toFloat(), (y + 12).toFloat(), -1, neverlosecolor.rgb, 0.7f)
127+
NLOutline("FDP", Fonts.NLBold_28, (x + 7).toFloat(), (y + 12).toFloat(), -1, neverlosecolor.rgb, 0.7f)
122128
} else {
123129
Fonts.NLBold_28.drawString("FDP", (x + 8).toFloat(), (y + 12).toFloat(), Color(51, 51, 51).rgb, false)
124130
}
@@ -178,7 +184,7 @@ class NeverloseGui : GuiScreen() {
178184
if (configManager.activeConfig() != null) {
179185
configManager.saveConfig(configManager.activeConfig()!!.name)
180186
} else {
181-
FDPClient.fileManager.saveAllConfigs()
187+
fileManager.saveAllConfigs()
182188
configManager.refresh()
183189
}
184190
}
@@ -251,7 +257,7 @@ class NeverloseGui : GuiScreen() {
251257
companion object {
252258
lateinit var INSTANCE: NeverloseGui
253259
var neverlosecolor = Color(28, 133, 192)
254-
@JvmStatic
260+
255261
fun getInstance(): NeverloseGui = INSTANCE
256262

257263
@JvmStatic

src/main/java/net/ccbluex/liquidbounce/ui/client/clickgui/style/styles/nlclickgui/NlModule.kt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* FDPClient Hacked Client
3+
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
4+
* https://github.com/SkidderMC/FDPClient/
5+
*/
16
package net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.nlclickgui
27

38
import net.ccbluex.liquidbounce.config.*
@@ -57,7 +62,7 @@ class NlModule(var NlSub: NlSub, var module: Module, var lef: Boolean) {
5762
if (setting is BoolValue) {
5863
this.downwards.add(BoolSetting(setting, this))
5964
}
60-
if (setting is FloatValue || setting is IntValue) {
65+
if (setting is FloatValue || setting is IntValue || setting is BlockValue) {
6166
this.downwards.add(Numbersetting(setting, this))
6267
}
6368
if (setting is FloatRangeValue || setting is IntRangeValue) {
@@ -113,6 +118,7 @@ class NlModule(var NlSub: NlSub, var module: Module, var lef: Boolean) {
113118

114119
fun draw(mx: Int, my: Int) {
115120
posy = calcY()
121+
height = calcHeight()
116122

117123
drawRound(
118124
(x + 95 + posx).toFloat(),
@@ -125,8 +131,8 @@ class NlModule(var NlSub: NlSub, var module: Module, var lef: Boolean) {
125131

126132
Fonts.Nl.Nl_18.Nl_18.drawString(
127133
module.name,
128-
x + 100 + posx,
129-
y + posy + 55 + scrollY,
134+
(x + 100 + posx).toFloat(),
135+
(y + posy + 55 + scrollY).toFloat(),
130136
if (getInstance().light) Color(95, 95, 95).rgb else -1
131137
)
132138

@@ -237,4 +243,4 @@ class NlModule(var NlSub: NlSub, var module: Module, var lef: Boolean) {
237243
module.toggle()
238244
}
239245
}
240-
}
246+
}

src/main/java/net/ccbluex/liquidbounce/ui/client/clickgui/style/styles/nlclickgui/NlSetting.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* FDPClient Hacked Client
3+
* A free open source mixin-based injection hacked client for Minecraft using Minecraft Forge.
4+
* https://github.com/SkidderMC/FDPClient/
5+
*/
16
package net.ccbluex.liquidbounce.ui.client.clickgui.style.styles.nlclickgui
27

38
import com.mojang.realmsclient.gui.ChatFormatting
@@ -10,7 +15,6 @@ import java.awt.Color
1015
import java.time.Instant
1116
import java.time.ZoneId
1217
import java.time.format.DateTimeFormatter
13-
import java.util.*
1418

1519
class NlSetting {
1620
var x = 50

src/main/java/net/ccbluex/liquidbounce/ui/client/clickgui/style/styles/nlclickgui/NlSub.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import org.lwjgl.input.Mouse
1616
import org.lwjgl.opengl.GL11
1717
import java.awt.Color
1818
import java.util.*
19+
import java.util.Locale.getDefault
1920
import java.util.function.Consumer
2021
import java.util.stream.Collectors
2122
import kotlin.math.max
@@ -32,7 +33,7 @@ class NlSub(parentCategory: Category?, var subCategory: SubCategory, var y2: Int
3233

3334
var alphaani: Animation = EaseInOutQuad(150, 1.0, Direction.BACKWARDS)
3435

35-
private var maxScroll = Float.Companion.MAX_VALUE
36+
private var maxScroll = Float.MAX_VALUE
3637
private val minScroll = 0f
3738
private var rawScroll = 0f
3839

@@ -74,13 +75,13 @@ class NlSub(parentCategory: Category?, var subCategory: SubCategory, var y2: Int
7475
this.icon,
7576
x + 10,
7677
y + y2 + 14,
77-
NeverloseGui.Companion.neverlosecolor.getRGB()
78+
NeverloseGui.neverlosecolor.rgb
7879
)
7980

8081
Fonts.Nl.Nl_18.Nl_18.drawString(
8182
subCategory.toString(), x + 10 + Fonts.NlIcon.nlfont_20.nlfont_20.stringWidth(
8283
this.icon
83-
) + 8, y + y2 + 13, if (getInstance().light) Color(18, 18, 19).getRGB() else -1
84+
) + 8, y + y2 + 13, if (getInstance().light) Color(18, 18, 19).rgb else -1
8485
)
8586

8687
if (this.isSelected && subCategory != SubCategory.CONFIGS) {
@@ -92,7 +93,7 @@ class NlSub(parentCategory: Category?, var subCategory: SubCategory, var y2: Int
9293
onScroll(40)
9394

9495
if (!visibleModules.isEmpty()) {
95-
val lastModule = visibleModules.get(visibleModules.size - 1)
96+
val lastModule = visibleModules[visibleModules.size - 1]
9697
maxScroll = max(0, lastModule.y + 50 + lastModule.posy + lastModule.height).toFloat()
9798
} else {
9899
maxScroll = 0f
@@ -166,9 +167,9 @@ class NlSub(parentCategory: Category?, var subCategory: SubCategory, var y2: Int
166167
if (!getInstance().isSearching) {
167168
return nlModules
168169
}
169-
val query: String = getInstance().searchTextContent.toLowerCase()
170+
val query: String = getInstance().searchTextContent.lowercase(getDefault())
170171
return nlModules.stream()
171-
.filter { module: NlModule? -> module!!.module.name.lowercase(Locale.getDefault()).contains(query) }
172+
.filter { module: NlModule? -> module!!.module.name.lowercase(getDefault()).contains(query) }
172173
.collect(Collectors.toList())
173174
}
174175

src/main/java/net/ccbluex/liquidbounce/ui/client/clickgui/style/styles/nlclickgui/settings/ColorSetting.kt

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@ class ColorSetting(setting: ColorValue, moduleRender: NlModule) : Downward<Color
2727
val colory = (y + getScrollY()).toInt()
2828

2929
val titleColor = if (gui.light) Color(95, 95, 95).rgb else -1
30+
val (label, labelTruncated) = abbreviate(setting.name)
31+
val labelX = (mainx + 100 + x).toFloat()
32+
val labelY = (mainy + colory + 57).toFloat()
3033

31-
Fonts.Nl.Nl_16.Nl_16.drawString(setting.name, (mainx + 100 + x), (mainy + colory + 57).toFloat(), titleColor)
34+
Fonts.Nl.Nl_16.Nl_16.drawString(label, labelX, labelY, titleColor)
35+
36+
if (labelTruncated && RenderUtil.isHovering(labelX, labelY - 3f, Fonts.Nl.Nl_16.Nl_16.stringWidth(label).toFloat(), 12f, mouseX, mouseY)) {
37+
drawTooltip(setting.name, mouseX, mouseY)
38+
}
3239

3340
val currentColor = setting.selectedColor()
34-
val previewX = (mainx + 170 + x)
41+
val hexText = "#%08X".format(currentColor.rgb)
42+
val hexX = labelX + Fonts.Nl.Nl_16.Nl_16.stringWidth(label) + 6f
43+
val previewX = computePreviewX(label, hexText, mainx)
3544
val previewY = (mainy + colory + 52).toFloat()
3645

3746
RoundedUtil.drawRound(previewX, previewY, 18f, 12f, 2f, currentColor)
@@ -42,7 +51,7 @@ class ColorSetting(setting: ColorValue, moduleRender: NlModule) : Downward<Color
4251
RoundedUtil.drawRound(rainbowPreviewX, previewY, 18f, 12f, 2f, if (setting.rainbow) rainbowColor else Color(50, 50, 50, 90))
4352
RenderUtil.drawBorderedRect(rainbowPreviewX, previewY, rainbowPreviewX + 18, previewY + 12, 1f, Color(0, 0, 0, 60).rgb, Color(0, 0, 0, 80).rgb)
4453

45-
Fonts.Nl_15.drawString("#%08X".format(currentColor.rgb), previewX + 46, previewY + 3, titleColor)
54+
Fonts.Nl_15.drawString(hexText, hexX, previewY + 3, titleColor)
4655

4756
if (setting.showPicker && dragging != null) {
4857
updateFromMouse(mouseX, mouseY, dragging!!)
@@ -57,7 +66,11 @@ class ColorSetting(setting: ColorValue, moduleRender: NlModule) : Downward<Color
5766

5867
override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) {
5968
val gui = NeverloseGui.getInstance()
60-
val previewX = (gui.x + 170 + x)
69+
val (label, _) = abbreviate(setting.name)
70+
val labelX = (gui.x + 100 + x).toFloat()
71+
val currentColor = setting.selectedColor()
72+
val hexText = "#%08X".format(currentColor.rgb)
73+
val previewX = computePreviewX(label, hexText, gui.x)
6174
val previewY = (gui.y + (y + getScrollY()).toInt() + 52).toFloat()
6275

6376
val inColorPreview = RenderUtil.isHovering(previewX, previewY, 18f, 12f, mouseX, mouseY)
@@ -155,7 +168,9 @@ class ColorSetting(setting: ColorValue, moduleRender: NlModule) : Downward<Color
155168

156169
private fun updateFromMouse(mouseX: Int, mouseY: Int, slider: ColorValue.SliderType) {
157170
val gui = NeverloseGui.getInstance()
158-
val baseX = (gui.x + 170 + x)
171+
val (label, _) = abbreviate(setting.name)
172+
val hexText = "#%08X".format(setting.selectedColor().rgb)
173+
val baseX = computePreviewX(label, hexText, gui.x)
159174
val baseY = (gui.y + (y + getScrollY()).toInt() + 72).toFloat()
160175
val padding = 4f
161176
val squareSize = 70f
@@ -195,6 +210,30 @@ class ColorSetting(setting: ColorValue, moduleRender: NlModule) : Downward<Color
195210
return if (gui.light) Color(95, 95, 95).rgb else -1
196211
}
197212

213+
private fun computePreviewX(label: String, hexText: String, mainx: Int): Float {
214+
val labelX = (mainx + 100 + x).toFloat()
215+
val hexX = labelX + Fonts.Nl.Nl_16.Nl_16.stringWidth(label) + 6f
216+
return hexX + Fonts.Nl_15.stringWidth(hexText) + 8f
217+
}
218+
219+
private fun abbreviate(value: String): Pair<String, Boolean> {
220+
return if (value.length > 10) {
221+
value.substring(0, 10) + "..." to true
222+
} else {
223+
value to false
224+
}
225+
}
226+
227+
private fun drawTooltip(text: String, mouseX: Int, mouseY: Int) {
228+
val width = Fonts.Nl_15.stringWidth(text) + 6
229+
val height = Fonts.Nl_15.height + 4
230+
val renderX = (mouseX + 6).toFloat()
231+
val renderY = (mouseY - height - 2).toFloat()
232+
233+
RenderUtil.drawRoundedRect(renderX, renderY, width.toFloat(), height.toFloat(), 2f, Color(0, 5, 19).rgb, 1f, Color(13, 24, 35).rgb)
234+
Fonts.Nl_15.drawString(text, renderX + 3f, renderY + 2f, Color.WHITE.rgb)
235+
}
236+
198237
override fun drawGradientRect(left: Int, top: Int, right: Int, bottom: Int, startColor: Int, endColor: Int) {
199238
val f = (startColor shr 24 and 255).toFloat() / 255.0f
200239
val f1 = (startColor shr 16 and 255).toFloat() / 255.0f

src/main/java/net/ccbluex/liquidbounce/ui/client/clickgui/style/styles/nlclickgui/settings/FontSetting.kt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,25 @@ class FontSetting(setting: FontValue, moduleRender: NlModule) : Downward<FontVal
2323
val mainy = gui.y
2424
val fontY = (y + getScrollY()).toInt()
2525

26+
val (label, labelTruncated) = abbreviate(setting.name)
27+
val labelX = (mainx + 100 + x).toFloat()
28+
val labelY = (mainy + fontY + 57).toFloat()
29+
2630
Fonts.Nl.Nl_16.Nl_16.drawString(
27-
setting.name,
28-
(mainx + 100 + x).toFloat(),
29-
(mainy + fontY + 57).toFloat(),
31+
label,
32+
labelX,
33+
labelY,
3034
if (gui.light) Color(95, 95, 95).rgb else -1
3135
)
3236

37+
if (labelTruncated && RenderUtil.isHovering(labelX, labelY - 3f, Fonts.Nl.Nl_16.Nl_16.stringWidth(label).toFloat(), 12f, mouseX, mouseY)) {
38+
drawTooltip(setting.name, mouseX, mouseY)
39+
}
40+
3341
val (display, truncated) = abbreviate(setting.displayName)
3442
val rectWidth = calculateRectWidth(display)
3543

36-
val rectX = mainx + 170 + x
44+
val rectX = mainx + 140 + x
3745
val rectY = mainy + fontY + 54
3846

3947
RenderUtil.drawRoundedRect(
@@ -64,7 +72,7 @@ class FontSetting(setting: FontValue, moduleRender: NlModule) : Downward<FontVal
6472

6573
override fun mouseClicked(mouseX: Int, mouseY: Int, mouseButton: Int) {
6674
val gui = NeverloseGui.getInstance()
67-
val rectX = gui.x + 170 + x
75+
val rectX = gui.x + 140 + x
6876
val rectY = gui.y + (y + getScrollY()).toInt() + 54
6977
val display = abbreviate(setting.displayName).first
7078

@@ -84,7 +92,7 @@ class FontSetting(setting: FontValue, moduleRender: NlModule) : Downward<FontVal
8492

8593
private fun abbreviate(value: String): Pair<String, Boolean> {
8694
return if (value.length > 10) {
87-
value.take(10) + "..." to true
95+
value.substring(0, 10) + "..." to true
8896
} else {
8997
value to false
9098
}

0 commit comments

Comments
 (0)