From a41b6e786788f13ea764a7b4f9b19becc8e1775c Mon Sep 17 00:00:00 2001 From: Willem Cazander Date: Thu, 3 Feb 2022 01:27:55 +0100 Subject: [PATCH] Removed duplicate code --- .../demo4d/screen/BasePartRenderer.java | 13 ++++--- .../numberxd/base2t/part/BãßBȍőnPartʸᴰ.java | 39 +++---------------- 2 files changed, 13 insertions(+), 39 deletions(-) diff --git a/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java b/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java index 0c2d9ee8..a806da0c 100644 --- a/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java +++ b/core/src/love/distributedrebirth/demo4d/screen/BasePartRenderer.java @@ -11,6 +11,7 @@ import imgui.type.ImInt; import love.distributedrebirth.demo4d.Demo4DMain; import love.distributedrebirth.demo4d.ImGuiRendererMain; import love.distributedrebirth.numberxd.base2t.BasePartFactory; +import love.distributedrebirth.numberxd.base2t.glyph.BaseGlyphSet; import love.distributedrebirth.numberxd.base2t.part.BãßBȍőnPartAlt1ʸᴰ; import love.distributedrebirth.numberxd.base2t.part.BãßBȍőnPartAlt2ʸᴰ; import love.distributedrebirth.numberxd.base2t.part.BãßBȍőnPartAlt3ʸᴰ; @@ -83,17 +84,17 @@ public class BasePartRenderer extends ImGuiRendererMain { ImGui.tableNextColumn(); ImGui.text(part.BȍőnIdentifierTone()); ImGui.tableNextColumn(); - ImGui.text(part.BȍőnGlyphSetNumber16LatinBasic()); + ImGui.text(part.BȍőnGlyphSetNumber16(BaseGlyphSet.LATIN_BASIC)); ImGui.tableNextColumn(); - ImGui.text(part.BȍőnGlyphSetNumber16Greek()); + ImGui.text(part.BȍőnGlyphSetNumber16(BaseGlyphSet.GREEK)); ImGui.tableNextColumn(); - ImGui.text(part.BȍőnGlyphSetNumber16Korean()); + ImGui.text(part.BȍőnGlyphSetNumber16(BaseGlyphSet.KOREAN)); ImGui.tableNextColumn(); - ImGui.text(part.BȍőnGlyphSetNumber36LatinBasic()); + ImGui.text(part.BȍőnGlyphSetNumber36(BaseGlyphSet.LATIN_BASIC)); ImGui.tableNextColumn(); - ImGui.text(part.BȍőnGlyphSetNumber36Greek()); + ImGui.text(part.BȍőnGlyphSetNumber36(BaseGlyphSet.GREEK)); ImGui.tableNextColumn(); - ImGui.text(part.BȍőnGlyphSetNumber36Hebrew()); + ImGui.text(part.BȍőnGlyphSetNumber36(BaseGlyphSet.HEBREW)); ImGui.tableNextColumn(); ImGui.text(part.BȍőnChinaKey()); ImGui.tableNextColumn(); diff --git a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/BãßBȍőnPartʸᴰ.java b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/BãßBȍőnPartʸᴰ.java index 87589b92..45a354ea 100644 --- a/numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/BãßBȍőnPartʸᴰ.java +++ b/numberxd/src/main/love/distributedrebirth/numberxd/base2t/part/BãßBȍőnPartʸᴰ.java @@ -23,52 +23,25 @@ public interface BãßBȍőnPartʸᴰ> extends return GET_BBC().GET_STR(BãßBȍőnPartKeyʸᴰ.CHINA_VALUE); } - default String BȍőnGlyphSetNumber16Greek() { - return BȍőnGlyphSetNumber16(BaseGlyphSet.GREEK); - } - - default String BȍőnGlyphSetNumber16LatinBasic() { - return BȍőnGlyphSetNumber16(BaseGlyphSet.LATIN_BASIC); - } - - default String BȍőnGlyphSetNumber16Korean() { - return BȍőnGlyphSetNumber16(BaseGlyphSet.KOREAN); - } - default String BȍőnGlyphSetNumber16(BaseGlyphSet glyphSet) { + StringBuilder buf = new StringBuilder(); T[] values = BãßInstances(); if (values.length <= 16) { - return glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor(BȍőnRangTelNul()); + buf.append(glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor(BȍőnRangTelNul())); } else if (values.length <= 256) { - StringBuilder buf = new StringBuilder(); buf.append(glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor(BȍőnRangTelNul() >> 4)); buf.append(glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor(BȍőnRangTelNul() & 0x0F)); - return buf.toString(); } else if (values.length <= 0xFFF+1) { - StringBuilder buf = new StringBuilder(); buf.append(glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor((BȍőnRangTelNul() >> 8) & 0x0F)); buf.append(glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor((BȍőnRangTelNul() >> 4) & 0x0F)); buf.append(glyphSet.BȍőnGlyphSetNumber16().BȍőnCharFor(BȍőnRangTelNul() & 0x0F)); - return buf.toString(); } else { throw new IllegalStateException("Can't handle more than 0xFFF values."); } - } - - default String BȍőnGlyphSetNumber36Greek() { - return BȍőnGlyphSetNumber36(BaseGlyphSet.GREEK); - } - - default String BȍőnGlyphSetNumber36LatinBasic() { - return BȍőnGlyphSetNumber36(BaseGlyphSet.LATIN_BASIC); - } - - default String BȍőnGlyphSetNumber36Hebrew() { - return BȍőnGlyphSetNumber36(BaseGlyphSet.HEBREW); - } - - default String BȍőnGlyphSetNumber36Arabic() { - return BȍőnGlyphSetNumber36(BaseGlyphSet.ARABIC); + if (BaseGlyphSet.HEBREW.equals(glyphSet)) { + return buf.reverse().toString(); + } + return buf.toString(); } default String BȍőnGlyphSetNumber36(BaseGlyphSet glyphSet) {