diff options
author | syeyoung <cyoung06@naver.com> | 2023-01-26 01:27:59 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-01-26 01:27:59 +0900 |
commit | 8f2366c1fd9850c0689306419343265099cfca7a (patch) | |
tree | 85e27135ad97a9201c9ba7ace469cac2217df3b0 /mod | |
parent | 4621a34d61304907b834bc7893cc79488eccb957 (diff) | |
download | Skyblock-Dungeons-Guide-8f2366c1fd9850c0689306419343265099cfca7a.tar.gz Skyblock-Dungeons-Guide-8f2366c1fd9850c0689306419343265099cfca7a.tar.bz2 Skyblock-Dungeons-Guide-8f2366c1fd9850c0689306419343265099cfca7a.zip |
- do not break contract - richtext
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod')
5 files changed, 42 insertions, 31 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java index 35bf616f..5161ee97 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/BindableAttribute.java @@ -46,12 +46,15 @@ public class BindableAttribute<T> { updating = true; T old = this.value; this.value = t; - if (!Objects.equals(t, old)) - for (BiConsumer<T, T> onUpdate : onUpdates) { - onUpdate.accept(old, value); - } - updating = false; - initialized = true; + try { + if (!Objects.equals(t, old)) + for (BiConsumer<T, T> onUpdate : onUpdates) { + onUpdate.accept(old, value); + } + } finally { + updating = false; + initialized = true; + } } public T getValue() { return value; diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java index ffbd27df..902b92c1 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/GuiScreenAdapter.java @@ -59,16 +59,20 @@ public class GuiScreenAdapter extends GuiScreen { super.initGui(); Keyboard.enableRepeatEvents(true); isOpen = true; - view.setRelativeBound(new Rect(0,0,Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); - view.setAbsBounds(new Rect(0,0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); - view.setSize(new Size(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); + try { + view.setRelativeBound(new Rect(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); + view.setAbsBounds(new Rect(0, 0, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); + view.setSize(new Size(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight)); view.getLayouter().layout(view, new ConstraintBox( Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, Minecraft.getMinecraft().displayHeight )); - view.setMounted(true); + view.setMounted(true); + }catch (Exception e) { + e.printStackTrace(); + } } @Override @@ -76,33 +80,36 @@ public class GuiScreenAdapter extends GuiScreen { int i = Mouse.getEventX(); int j = this.mc.displayHeight - Mouse.getEventY(); - if (view.isRelayoutRequested()) { + try { + if (view.isRelayoutRequested()) { - view.setRelayoutRequested(false); + view.setRelayoutRequested(false); view.getLayouter().layout(view, new ConstraintBox( Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight, Minecraft.getMinecraft().displayHeight )); - } + } - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - GlStateManager.pushMatrix(); - GlStateManager.disableDepth(); - GlStateManager.enableBlend(); - GlStateManager.enableAlpha(); - GlStateManager.alphaFunc(GL_GREATER, 0); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); - GlStateManager.color(1, 1, 1, 1); - GlStateManager.scale(1.0 / scaledResolution.getScaleFactor(), 1.0 / scaledResolution.getScaleFactor(), 1.0d); - view.getRenderer().doRender(i, j, i, j, partialTicks, new RenderingContext(), view); - GlStateManager.alphaFunc(GL_GREATER, 0.1f); - GlStateManager.popMatrix(); - GlStateManager.enableDepth(); - GlStateManager.disableTexture2D(); - GL11.glDisable(GL11.GL_SCISSOR_TEST); + ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + GlStateManager.pushMatrix(); + GlStateManager.disableDepth(); + GlStateManager.enableBlend(); + GlStateManager.enableAlpha(); + GlStateManager.alphaFunc(GL_GREATER, 0); + GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GlStateManager.color(1, 1, 1, 1); + GlStateManager.scale(1.0 / scaledResolution.getScaleFactor(), 1.0 / scaledResolution.getScaleFactor(), 1.0d); + view.getRenderer().doRender(i, j, i, j, partialTicks, new RenderingContext(), view); + GlStateManager.alphaFunc(GL_GREATER, 0.1f); + GlStateManager.popMatrix(); + GlStateManager.enableDepth(); + GL11.glDisable(GL11.GL_SCISSOR_TEST); + } catch (Exception e) { + e.printStackTrace(); + } } @Override diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java index 23442d06..4ec68bab 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Text.java @@ -50,7 +50,7 @@ public class Text extends AnnotatedExportOnlyWidget { public final BindableAttribute<String> text = new BindableAttribute<>(String.class, ""); private final ParentDelegatingTextStyle textStyle = ParentDelegatingTextStyle.ofDefault(); - private final RichText richText = new RichText(new TextSpan(textStyle, ""), BreakWord.WORD, true,RichText.TextAlign.LEFT); + private final RichText richText = new RichText(new TextSpan(textStyle, ""), BreakWord.WORD, false,RichText.TextAlign.LEFT); @Override public List<Widget> build(DomElement buildContext) { return Collections.singletonList(richText); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java index 3dc58c7e..ae09501d 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/RichText.java @@ -120,7 +120,9 @@ public class RichText extends Widget implements Layouter, Renderer { richLines = lines; - return new Size(takeAllSpace ? constraintBox.getMaxWidth() : maxWidth, sumHeight); + return new Size(takeAllSpace ? constraintBox.getMaxWidth() : + Layouter.clamp(maxWidth, constraintBox.getMinWidth(), constraintBox.getMaxWidth()), + Layouter.clamp(sumHeight, constraintBox.getMinHeight(), constraintBox.getMaxHeight())); } @Override diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java index a9fb429e..dcfa033f 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/overlay/OverlayManager.java @@ -156,7 +156,6 @@ public class OverlayManager { GlStateManager.alphaFunc(GL_GREATER, 0.1f); GlStateManager.popMatrix(); GlStateManager.enableDepth(); - GlStateManager.enableTexture2D(); GL11.glDisable(GL11.GL_SCISSOR_TEST); } |