Skip to content

Commit c0f952a

Browse files
committed
fix crashes and radii issue
1 parent 58a5fea commit c0f952a

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ kotlinx-coroutines = "1.10.2"
77
kotlinx-atomicfu = "0.29.0"
88
fabric-language-kotlin = "1.13.5+kotlin.2.2.10"
99
google-ksp = "2.2.10-2.0.2"
10-
polyui = "2.0.5"
10+
polyui = "2.0.6"
1111
annotations = "24.1.0"
1212
hypixel-modapi = "1.0.1"
1313
hypixel-data = "0.2.0" # Dep of hypixel-modapi

modules/config-impl/src/main/java/org/polyfrost/oneconfig/api/config/v1/ConfigManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.polyfrost.oneconfig.api.config.v1.collect.PropertyCollector;
3838
import org.polyfrost.oneconfig.api.config.v1.collect.impl.OneConfigCollector;
3939
import org.polyfrost.oneconfig.api.config.v1.serialize.ObjectSerializer;
40+
import org.polyfrost.oneconfig.api.config.v1.serialize.adapter.impl.FontAdapter;
4041
import org.polyfrost.oneconfig.api.config.v1.serialize.adapter.impl.PolyColorAdapter;
4142
import org.polyfrost.oneconfig.api.config.v1.serialize.adapter.impl.Vec4Adapter;
4243
import org.polyfrost.oneconfig.api.config.v1.serialize.impl.FileSerializer;
@@ -64,6 +65,7 @@ public final class ConfigManager {
6465

6566
static {
6667
ObjectSerializer.INSTANCE.registerTypeAdapter(new PolyColorAdapter());
68+
ObjectSerializer.INSTANCE.registerTypeAdapter(new FontAdapter());
6769
ObjectSerializer.INSTANCE.registerTypeAdapter(new Vec4Adapter());
6870
registerCollector(new OneConfigCollector());
6971
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.polyfrost.oneconfig.api.config.v1.serialize.adapter.impl;
2+
3+
import org.polyfrost.oneconfig.api.config.v1.serialize.adapter.Adapter;
4+
import org.polyfrost.polyui.data.Font;
5+
6+
public class FontAdapter extends Adapter <Font, String> {
7+
@Override
8+
public Font deserialize(String in) {
9+
return Font.of(in);
10+
}
11+
12+
@Override
13+
public String serialize(Font in) {
14+
return in.getResourcePath();
15+
}
16+
17+
@Override
18+
public Class<Font> getTargetClass() {
19+
return Font.class;
20+
}
21+
22+
@Override
23+
public Class<String> getOutputClass() {
24+
return String.class;
25+
}
26+
}

modules/config-impl/src/main/kotlin/org/polyfrost/oneconfig/api/config/v1/Visualizer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fun interface Visualizer {
230230
placeholder = placeholder,
231231
image = "assets/oneconfig/ico/text.svg".image(),
232232
size = Vec2(200f, 32f),
233-
value = state,
233+
value = state.value.toFloat().toString(dps = 2),
234234
post = unit
235235
)
236236
s.getTextFromBoxedTextInput().numeric(min, max, state)

modules/config-impl/src/main/kotlin/org/polyfrost/oneconfig/api/config/v1/internal/ConfigVisualizer.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ open class ConfigVisualizer {
269269
var contentHeight = -1f
270270
// asm: signature as it prevents re-wrapping of function
271271
val openInsn: Drawable.(Any?) -> Unit = {
272-
open.value = !open.value
273272
val arrow = if (enabled != null) this[1][1] else this[1]
274273
val anim = Animations.Default.create(0.6.seconds)
275274
Rotate(arrow, if (!open.value) PI else 0.0, false, anim).add()
@@ -292,13 +291,13 @@ open class ConfigVisualizer {
292291
size = 21f,
293292
state = open
294293
).onChange(open) {
295-
enabled?.setAs(it)
294+
enabled?.set(it)
296295
if (open.value != it) (parent.parent as Drawable).openInsn(null)
297296
},
298297
Image("polyui/chevron-down.svg").also { it.rotation = PI }
299298
)
300299
// lmao
301-
open.value = !open.value
300+
//open.value = !open.value
302301
@Suppress("UNCHECKED_CAST") // reason: #already-type-checked
303302
enabled = e as Property<Boolean>
304303
} else {

modules/ui/src/main/kotlin/org/polyfrost/oneconfig/api/ui/v1/internal/GLRendererImpl.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re
100100

101101
// Current batch state
102102
private var count = 0
103-
private var curTex = 0
104103
private var transformDepth = 0
105104
private var scissorDepth = 0
106105
private var transform = IDENTITY.copyOf()
@@ -145,9 +144,9 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re
145144
float py = step(0.0, p.y);
146145
147146
// Select radius per quadrant
148-
float rLeft = mix(r.w, r.x, py); // bottom-left / top-left
149-
float rRight = mix(r.z, r.y, py); // bottom-right / top-right
150-
float radius = mix(rLeft, rRight, px);
147+
float rLeft = mix(r.x, r.w, py); // top-left / bottom-left
148+
float rRight = mix(r.y, r.z, py); // top-right / bottom-right
149+
float radius = mix(rLeft, rRight, px); // left vs right
151150
152151
vec2 q = abs(p) - (b - radius);
153152
return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
@@ -467,7 +466,7 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re
467466
}
468467

469468
glActiveTexture(GL_TEXTURE0)
470-
glBindTexture(GL_TEXTURE_2D, curTex)
469+
glBindTexture(GL_TEXTURE_2D, atlas)
471470

472471
// Quad attrib
473472
glBindBuffer(GL_ARRAY_BUFFER, quadVbo)
@@ -596,8 +595,6 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re
596595
colorMask: Int, topLeftRadius: Float, topRightRadius: Float, bottomLeftRadius: Float, bottomRightRadius: Float
597596
) {
598597
if (count >= MAX_BATCH) flush()
599-
if (count > 0 && curTex != atlas) flush()
600-
curTex = atlas
601598

602599
buffer.put(x).put(y).put(width).put(height)
603600
buffer.put(topLeftRadius).put(topRightRadius).put(bottomRightRadius).put(bottomLeftRadius)
@@ -616,8 +613,6 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re
616613
val s = transformScale()
617614
val fAtlasForRendering = if (s == 1f) fAtlas else getFontAtlas(font, fontSize * s)
618615
if (count >= MAX_BATCH) flush()
619-
if (count > 0 && curTex != atlas) flush()
620-
curTex = atlas
621616

622617
var penX = x
623618
val scaleFactor = fontSize / fAtlas.renderedSize
@@ -918,8 +913,8 @@ class GLRendererImpl(private val nsvg: NanoSvgApi, private val stb: StbApi) : Re
918913
if (quadVbo != 0) glDeleteBuffers(quadVbo)
919914
if (instancedVbo != 0) glDeleteBuffers(instancedVbo)
920915
if (atlas != 0) glDeleteTextures(atlas)
916+
if (vao != 0) org.lwjgl.opengl.GL30C.glDeleteVertexArrays(vao)
921917
fonts.clear()
922-
buffer.clear()
923918
}
924919

925920
override fun delete(font: Font?) {}

0 commit comments

Comments
 (0)