diff --git a/Loader/src/main/java/cn/xiaozhou233/orangex/loader/Loader.java b/Loader/src/main/java/cn/xiaozhou233/orangex/loader/Loader.java index 82bad10..0e4d500 100644 --- a/Loader/src/main/java/cn/xiaozhou233/orangex/loader/Loader.java +++ b/Loader/src/main/java/cn/xiaozhou233/orangex/loader/Loader.java @@ -3,7 +3,6 @@ package cn.xiaozhou233.orangex.loader; import cn.xiaozhou233.juiceagent.api.JuiceAgent; -import javax.swing.*; import java.io.File; public class Loader { @@ -25,55 +24,55 @@ public class Loader { throw new IllegalStateException("Cannot find Minecraft client thread"); } - // Check if LaunchWrapper exists - if (Detector.isLaunchWrapper()){ - System.out.println("LaunchWrapper detected"); - } +// // Check if LaunchWrapper exists +// if (Detector.isLaunchWrapper()){ +// System.out.println("LaunchWrapper detected"); +// } // Get Minecraft ClassLoader minecraftClassLoader = clientThread.getContextClassLoader(); System.out.println("Minecraft ClassLoader: " + minecraftClassLoader); - switch (Detector.detect()) { - case MCP: - break; - case VANILLA: - // No more support - JOptionPane.showMessageDialog( - null, - "Not support Vanilla Client! \n 不支持原版客户端!", - "Vanilla Obfuscation", - JOptionPane.ERROR_MESSAGE - ); - throw new IllegalStateException("Not support Vanilla Client!"); - case LUNAR: - break; - case BADLION: - // No more support - JOptionPane.showMessageDialog( - null, - "Not support Badlion Client! \n 不支持Badlion客户端!", - "Badlion Obfuscation", - JOptionPane.ERROR_MESSAGE - ); - throw new IllegalStateException("Not support Badlion Client!"); - case UNKNOWN: - JOptionPane.showMessageDialog( - null, - "Inject Failed! Cause: Unknown Obfuscation \n 注入失败! 原因: 未知的混淆", - "Unknown Obfuscation", - JOptionPane.ERROR_MESSAGE - ); - throw new IllegalStateException("Unknown Obfuscation"); - default: - JOptionPane.showMessageDialog( - null, - "Inject Failed! Cause: Unknown Obfuscation", - "Unknown Obfuscation", - JOptionPane.ERROR_MESSAGE - ); - throw new IllegalStateException("Unexpected value: " + Detector.detect()); - } +// switch (Detector.detect()) { +// case MCP: +// break; +// case VANILLA: +// // No more support +// JOptionPane.showMessageDialog( +// null, +// "Not support Vanilla Client! \n 不支持原版客户端!", +// "Vanilla Obfuscation", +// JOptionPane.ERROR_MESSAGE +// ); +// throw new IllegalStateException("Not support Vanilla Client!"); +// case LUNAR: +// break; +// case BADLION: +// // No more support +// JOptionPane.showMessageDialog( +// null, +// "Not support Badlion Client! \n 不支持Badlion客户端!", +// "Badlion Obfuscation", +// JOptionPane.ERROR_MESSAGE +// ); +// throw new IllegalStateException("Not support Badlion Client!"); +// case UNKNOWN: +// JOptionPane.showMessageDialog( +// null, +// "Inject Failed! Cause: Unknown Obfuscation \n 注入失败! 原因: 未知的混淆", +// "Unknown Obfuscation", +// JOptionPane.ERROR_MESSAGE +// ); +// throw new IllegalStateException("Unknown Obfuscation"); +// default: +// JOptionPane.showMessageDialog( +// null, +// "Inject Failed! Cause: Unknown Obfuscation", +// "Unknown Obfuscation", +// JOptionPane.ERROR_MESSAGE +// ); +// throw new IllegalStateException("Unexpected value: " + Detector.detect()); +// } // Load OrangeX File injectionFile = new File(userDir + "/.orangex/OrangeX.jar"); @@ -90,4 +89,5 @@ public class Loader { } System.out.println("======== Loader END ========"); } + } \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/OrangeX.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/OrangeX.java index 353505b..a00471f 100644 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/OrangeX.java +++ b/OrangeX/src/main/java/cn/xiaozhou233/orangex/OrangeX.java @@ -1,21 +1,10 @@ package cn.xiaozhou233.orangex; - -import cn.xiaozhou233.orangex.font.FontManager; -import cn.xiaozhou233.orangex.font.StbFontManager; -import cn.xiaozhou233.orangex.manager.ThreadManager; -import cn.xiaozhou233.orangex.mixin.MixinManager; -import cn.xiaozhou233.orangex.module.ModuleManager; import lombok.Getter; import org.greenrobot.eventbus.EventBus; @Getter public class OrangeX { public static final OrangeX INSTANCE = new OrangeX(); - public MixinManager mixinManager = new MixinManager(); - FontManager fontManager = new FontManager(); - StbFontManager stbFontManager = new StbFontManager(); - ModuleManager moduleManager = new ModuleManager(); - ThreadManager threadManager = new ThreadManager(); private final EventBus eventBus = EventBus.builder() .logNoSubscriberMessages(false) .logSubscriberExceptions(false) @@ -27,18 +16,11 @@ public class OrangeX { public void start() { System.out.println("OrangeX starting..."); - stbFontManager.loadFonts(); - mixinManager.start(); - threadManager.init(); - moduleManager.registerModules(); - moduleManager.loadConfig(); - System.out.println("OrangeX started."); } public void stop() { System.out.println("OrangeX stopping..."); - moduleManager.saveConfig(); System.out.println("OrangeX stopped."); } diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/config/ModuleConfig.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/config/ModuleConfig.java deleted file mode 100644 index b5c5104..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/config/ModuleConfig.java +++ /dev/null @@ -1,107 +0,0 @@ -package cn.xiaozhou233.orangex.config; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.OptionSerializer; -import com.google.gson.*; - -import java.io.*; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.util.List; - -public class ModuleConfig { - private final File configFile; - private final Gson gson; - - public ModuleConfig(String path) { - this.configFile = new File(path); - this.gson = new GsonBuilder().setPrettyPrinting().create(); - } - - public void save(List modules) { - JsonObject config = new JsonObject(); - JsonArray modulesArray = new JsonArray(); - for (Module module : modules) { - JsonObject moduleObj = new JsonObject(); - moduleObj.addProperty("name", module.getName()); - moduleObj.addProperty("enabled", module.isEnabled()); - moduleObj.addProperty("key", module.getKey()); - if (!module.getOptions().isEmpty()) { - moduleObj.add("options", OptionSerializer.toJson(module.getOptions())); - } - modulesArray.add(moduleObj); - } - config.add("modules", modulesArray); - writeConfig(config); - } - - public void saveClickGui(JsonObject clickGuiData) { - JsonObject config = loadRaw(); - config.add("clickgui", clickGuiData); - writeConfig(config); - } - - public JsonObject loadClickGui() { - JsonObject config = loadRaw(); - if (config == null || !config.has("clickgui")) { - return new JsonObject(); - } - return config.getAsJsonObject("clickgui"); - } - - private JsonObject loadRaw() { - if (!configFile.exists()) return new JsonObject(); - try (Reader reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.UTF_8)) { - JsonObject config = gson.fromJson(reader, JsonObject.class); - return config != null ? config : new JsonObject(); - } catch (IOException e) { - e.printStackTrace(); - return new JsonObject(); - } - } - - private void writeConfig(JsonObject config) { - configFile.getParentFile().mkdirs(); - try (Writer writer = new OutputStreamWriter(Files.newOutputStream(configFile.toPath()), StandardCharsets.UTF_8)) { - gson.toJson(config, writer); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public void load(List modules) { - if (!configFile.exists()) return; - try (Reader reader = new InputStreamReader(Files.newInputStream(configFile.toPath()), StandardCharsets.UTF_8)) { - JsonObject config = gson.fromJson(reader, JsonObject.class); - if (config == null) return; - JsonArray modulesArray = config.getAsJsonArray("modules"); - if (modulesArray == null) return; - for (JsonElement element : modulesArray) { - JsonObject moduleObj = element.getAsJsonObject(); - String name = moduleObj.get("name").getAsString(); - Module module = findModule(modules, name); - if (module == null) continue; - if (moduleObj.has("enabled") && moduleObj.get("enabled").getAsBoolean()) { - module.setEnabled(true); - } - if (moduleObj.has("key")) { - module.setKey(moduleObj.get("key").getAsInt()); - } - if (moduleObj.has("options")) { - OptionSerializer.fromJson(moduleObj.getAsJsonObject("options"), module.getOptions()); - } - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private Module findModule(List modules, String name) { - for (Module module : modules) { - if (module.getName().equalsIgnoreCase(name)) { - return module; - } - } - return null; - } -} \ No newline at end of file diff --git a/Loader/src/main/java/cn/xiaozhou233/orangex/loader/Detector.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/detector/Detector.java similarity index 97% rename from Loader/src/main/java/cn/xiaozhou233/orangex/loader/Detector.java rename to OrangeX/src/main/java/cn/xiaozhou233/orangex/detector/Detector.java index c1d1f48..b1d7a55 100644 --- a/Loader/src/main/java/cn/xiaozhou233/orangex/loader/Detector.java +++ b/OrangeX/src/main/java/cn/xiaozhou233/orangex/detector/Detector.java @@ -1,4 +1,4 @@ -package cn.xiaozhou233.orangex.loader; +package cn.xiaozhou233.orangex.detector; public class Detector { diff --git a/Loader/src/main/java/cn/xiaozhou233/orangex/loader/DetectorType.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/detector/DetectorType.java similarity index 68% rename from Loader/src/main/java/cn/xiaozhou233/orangex/loader/DetectorType.java rename to OrangeX/src/main/java/cn/xiaozhou233/orangex/detector/DetectorType.java index 490195d..419d053 100644 --- a/Loader/src/main/java/cn/xiaozhou233/orangex/loader/DetectorType.java +++ b/OrangeX/src/main/java/cn/xiaozhou233/orangex/detector/DetectorType.java @@ -1,4 +1,4 @@ -package cn.xiaozhou233.orangex.loader; +package cn.xiaozhou233.orangex.detector; public enum DetectorType { BADLION, diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/Cancellable.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/Cancellable.java deleted file mode 100644 index 7507b9e..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/Cancellable.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.xiaozhou233.orangex.event; - -public class Cancellable extends Event{ - - private boolean cancelled; - - public boolean isCancelled() { - return cancelled; - } - - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - - public void cancel() { - this.cancelled = true; - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/Event.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/Event.java deleted file mode 100644 index 4ba967e..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/Event.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.xiaozhou233.orangex.event; - -public class Event { -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventKey.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventKey.java deleted file mode 100644 index 55811e6..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventKey.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import cn.xiaozhou233.orangex.event.Event; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class EventKey extends Event { - private final int key; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventLoop.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventLoop.java deleted file mode 100644 index 762d698..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventLoop.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -public class EventLoop { -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventMouseButton.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventMouseButton.java deleted file mode 100644 index b226502..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventMouseButton.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class EventMouseButton { - private final int button; - private final boolean pressed; - private final int x; - private final int y; -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventMouseMove.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventMouseMove.java deleted file mode 100644 index e350e60..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventMouseMove.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class EventMouseMove { - private final int x; - private final int y; -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventPacketSend.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventPacketSend.java deleted file mode 100644 index 778214a..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventPacketSend.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import cn.xiaozhou233.orangex.event.Cancellable; -import cn.xiaozhou233.orangex.event.Event; -import lombok.AllArgsConstructor; -import lombok.Getter; -import net.minecraft.network.Packet; - -@Getter -@AllArgsConstructor -public class EventPacketSend extends Cancellable { - private Packet packet; -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventRender2D.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventRender2D.java deleted file mode 100644 index 82a7bbd..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventRender2D.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import cn.xiaozhou233.orangex.event.Event; -import lombok.Getter; - -@Getter -public class EventRender2D extends Event { - private float partialTicks; - - public EventRender2D(float partialTicks) { - this.partialTicks = partialTicks; - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventRender3D.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventRender3D.java deleted file mode 100644 index d236314..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventRender3D.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import cn.xiaozhou233.orangex.event.Event; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class EventRender3D extends Event { - - private float partialTicks; - -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventTick.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventTick.java deleted file mode 100644 index 37f9b6e..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventTick.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -public class EventTick { -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventTimerThread.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventTimerThread.java deleted file mode 100644 index 5f47e30..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventTimerThread.java +++ /dev/null @@ -1,6 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -import cn.xiaozhou233.orangex.event.Event; - -public class EventTimerThread extends Event { -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventWorldLoad.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventWorldLoad.java deleted file mode 100644 index 7867010..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/event/impl/EventWorldLoad.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.xiaozhou233.orangex.event.impl; - -public class EventWorldLoad { -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/CFont.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/CFont.java deleted file mode 100644 index 2e5eb40..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/CFont.java +++ /dev/null @@ -1,253 +0,0 @@ -package cn.xiaozhou233.orangex.font; - - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.AbstractTexture; -import net.minecraft.client.renderer.texture.DynamicTexture; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.awt.geom.Rectangle2D; -import java.awt.image.BufferedImage; - - - -public class CFont -{ - private float imgSize = 1024; - protected CharData[] charData = new CharData[256]; - protected Font font; - protected boolean antiAlias; - protected boolean fractionalMetrics; - protected int fontHeight = -1; - protected int charOffset = 0; - private BufferedImage fontImage; - protected AbstractTexture tex; - - public CFont(Font font, boolean antiAlias, boolean fractionalMetrics) - { - this.font = font; - this.antiAlias = antiAlias; - this.fractionalMetrics = fractionalMetrics; - this.fontImage = generateFontImage(font, antiAlias, fractionalMetrics, this.charData); - } - - protected AbstractTexture getTexture() - { - if (tex == null) - { - tex = setupTexture(fontImage); - fontImage = null; - } - return tex; - } - - public AbstractTexture setupTexture(BufferedImage img) - { - try - { - AbstractTexture texture = new DynamicTexture(img); - GlStateManager.bindTexture(texture.getGlTextureId()); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - return texture; - } - catch (Exception e) - { - e.printStackTrace(); - } - - return null; - } - - protected BufferedImage generateFontImage(Font font, boolean antiAlias, boolean fractionalMetrics, CharData[] chars) - { - int imgSize = (int) this.imgSize; - this.fontHeight = -1; - BufferedImage bufferedImage = null; - - while (true) - { - bufferedImage = new BufferedImage(imgSize, imgSize, BufferedImage.TYPE_INT_ARGB); - Graphics2D g = (Graphics2D) bufferedImage.getGraphics(); - g.setFont(font.deriveFont(font.getSize2D() * 2.0F)); - g.setColor(new Color(255, 255, 255, 0)); - g.fillRect(0, 0, imgSize, imgSize); - g.setColor(Color.WHITE); - g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, fractionalMetrics ? RenderingHints.VALUE_FRACTIONALMETRICS_ON : RenderingHints.VALUE_FRACTIONALMETRICS_OFF); - g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, antiAlias ? RenderingHints.VALUE_TEXT_ANTIALIAS_ON : RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF); - FontMetrics fontMetrics = g.getFontMetrics(); - int charHeight = 0; - int positionX = 0; - int positionY = 1; - boolean overflow = false; - - for (int i = 0; i < chars.length; i++) - { - char ch = (char) i; - CharData charData = new CharData(); - Rectangle2D dimensions = fontMetrics.getStringBounds(String.valueOf(ch), g); - charData.width = (dimensions.getBounds().width + 8); - charData.height = dimensions.getBounds().height; - - if (positionX + charData.width >= imgSize) - { - positionX = 0; - positionY += charHeight; - charHeight = 0; - } - - if (positionY + charData.height >= imgSize) - { - overflow = true; - break; - } - - if (charData.height > charHeight) - { - charHeight = charData.height; - } - - charData.storedX = positionX; - charData.storedY = positionY; - - if (charData.height > this.fontHeight) - { - this.fontHeight = charData.height; - } - - chars[i] = charData; - g.drawString(String.valueOf(ch), positionX + 2, positionY + fontMetrics.getAscent()); - positionX += charData.width; - } - - g.dispose(); - - if (!overflow) - { - this.imgSize = imgSize; - return bufferedImage; - } - - imgSize *= 2; - } - } - - public void drawChar(CharData[] chars, char c, float x, float y) throws ArrayIndexOutOfBoundsException - { - try - { - drawQuad(x, y, chars[c].width, chars[c].height, chars[c].storedX, chars[c].storedY, chars[c].width, chars[c].height); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - protected void drawQuad(float x, float y, float width, float height, float srcX, float srcY, float srcWidth, float srcHeight) - { - float renderSRCX = srcX / imgSize; - float renderSRCY = srcY / imgSize; - float renderSRCWidth = srcWidth / imgSize; - float renderSRCHeight = srcHeight / imgSize; - GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY); - GL11.glVertex2d(x + width, y); - GL11.glTexCoord2f(renderSRCX, renderSRCY); - GL11.glVertex2d(x, y); - GL11.glTexCoord2f(renderSRCX, renderSRCY + renderSRCHeight); - GL11.glVertex2d(x, y + height); - GL11.glTexCoord2f(renderSRCX, renderSRCY + renderSRCHeight); - GL11.glVertex2d(x, y + height); - GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY + renderSRCHeight); - GL11.glVertex2d(x + width, y + height); - GL11.glTexCoord2f(renderSRCX + renderSRCWidth, renderSRCY); - GL11.glVertex2d(x + width, y); - } - - public int getStringHeight(String text) - { - return getHeight(); - } - - public int getHeight() - { - return (int) (((this.fontHeight - 8) / 2) * getFontScale()); - } - - protected double getFontScale() - { - return (Minecraft.getMinecraft().displayWidth / 1920.0D) * 0.5D; - } - - public int getStringWidth(String text) - { - int width = 0; - - for (char c : text.toCharArray()) - { - if ((c < this.charData.length) && (c >= 0)) - { - width += this.charData[c].width - 8 + this.charOffset; - } - } - - return width / 2; - } - - public boolean isAntiAlias() - { - return this.antiAlias; - } - - public void setAntiAlias(boolean antiAlias) - { - if (this.antiAlias != antiAlias) - { - this.antiAlias = antiAlias; - this.fontImage = generateFontImage(this.font, antiAlias, this.fractionalMetrics, this.charData); - this.tex = null; - } - } - - public boolean isFractionalMetrics() - { - return this.fractionalMetrics; - } - - public void setFractionalMetrics(boolean fractionalMetrics) - { - if (this.fractionalMetrics != fractionalMetrics) - { - this.fractionalMetrics = fractionalMetrics; - this.fontImage = generateFontImage(this.font, this.antiAlias, fractionalMetrics, this.charData); - this.tex = null; - } - } - - public Font getFont() - { - return this.font; - } - - public void setFont(Font font) - { - this.font = font; - this.fontImage = generateFontImage(font, this.antiAlias, this.fractionalMetrics, this.charData); - this.tex = null; - } - - protected class CharData - { - public int width; - public int height; - public int storedX; - public int storedY; - - protected CharData() - { - } - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontManager.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontManager.java deleted file mode 100644 index 7c18bef..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontManager.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import java.awt.*; - -public class FontManager { - public FontRenderer MontserratLight18 = new FontRenderer("Montserrat-Light.ttf", 18, Font.PLAIN, true, true); - - public FontRenderer MontserratRegular18 = new FontRenderer("Montserrat-Bold.ttf", 18, Font.PLAIN, true, true); - public FontRenderer MontserratRegular32 = new FontRenderer("Montserrat-Bold.ttf", 32, Font.PLAIN, true, true); - - public FontRenderer MontserratMedium18 = new FontRenderer("Montserrat-Medium.ttf", 18, Font.PLAIN, true, true); - public FontRenderer MontserratMedium32 = new FontRenderer("Montserrat-Medium.ttf", 32, Font.PLAIN, true, true); - - public FontRenderer MontserratBold18 = new FontRenderer("Montserrat-Bold.ttf", 18, Font.PLAIN, true, true); - public FontRenderer MontserratBold32 = new FontRenderer("Montserrat-Bold.ttf", 32, Font.PLAIN, true, true); - - public FontRenderer JelloMedium32 = new FontRenderer("JelloMedium.ttf", 32, Font.PLAIN, true, true); - public FontRenderer JelloRegular16 = new FontRenderer("JelloRegular.ttf", 16, Font.PLAIN, true, true); -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontRenderer.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontRenderer.java deleted file mode 100644 index 50e5d79..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontRenderer.java +++ /dev/null @@ -1,501 +0,0 @@ -package cn.xiaozhou233.orangex.font; - - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.texture.AbstractTexture; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.awt.image.BufferedImage; -import java.util.ArrayList; -import java.util.List; - - -public class FontRenderer extends CFont { - protected CFont.CharData[] boldChars = new CFont.CharData[256]; - protected CFont.CharData[] italicChars = new CFont.CharData[256]; - protected CFont.CharData[] boldItalicChars = new CFont.CharData[256]; - - private final int[] colorCode = new int[32]; - - /* - CREDIT G0dwhitelight. - */ - public FontRenderer(Font font, boolean antiAlias, boolean fractionalMetrics) { - super(font, antiAlias, fractionalMetrics); - setupMinecraftColorcodes(); - setupBoldItalicIDs(); - } - - public FontRenderer(String filePath, int size, int fontType, boolean antiAlias, boolean fractionalMetrics) { - super(FontUtil.getFontFromTTF( - FontRenderer.class.getClassLoader().getResourceAsStream("fonts/" + filePath), size, fontType), - antiAlias, fractionalMetrics); - setupMinecraftColorcodes(); - setupBoldItalicIDs(); - } - - public float drawString(String text, float x, float y, int color) { - return drawString(text, x, y, color, false); - } - - public float drawString(String text, double x, double y, int color) { - return drawString(text, x, y, color, false); - } - - public float drawStringWithShadow(String text, float x, float y, int color) { - float shadowWidth = drawString(text, x + 1D, y + .5D, color, true); - return Math.max(shadowWidth, drawString(text, x, y, color, false)); - } - - public float drawStringWithShadow(String text, double x, double y, int color) { - float shadowWidth = drawString(text, x + 1, y + .5, color, true); - return Math.max(shadowWidth, drawString(text, x, y, color, false)); - } - - public float drawCenteredString(String text, float x, float y, int color) { - return drawString(text, x - getStringWidth(text) / 2, y, color); - } - - public float drawCenteredString(String text, double x, double y, int color) { - return drawString(text, x - getStringWidth(text) / 2, y, color); - } - - public float drawCenteredStringWithShadow(String text, float x, float y, int color) { - float shadowWidth = drawString(text, x - getStringWidth(text) / 2 + 0.45D, y + 0.5D, color, true); - return drawString(text, x - getStringWidth(text) / 2, y, color); - } - - public void drawStringWithOutline(String text, double x, double y, int color) { - drawString(text, x - .5, y, 0x000000); - - drawString(text, x + .5, y, 0x000000); - - drawString(text, x, y - .5, 0x000000); - - drawString(text, x, y + .5, 0x000000); - - drawString(text, x, y, color); - } - - public void drawCenteredStringWithOutline(String text, double x, double y, int color) { - drawCenteredString(text, x - .5, y, 0x000000); - - drawCenteredString(text, x + .5, y, 0x000000); - - drawCenteredString(text, x, y - .5, 0x000000); - - drawCenteredString(text, x, y + .5, 0x000000); - - drawCenteredString(text, x, y, color); - } - - public float drawCenteredStringWithShadow(String text, double x, double y, int color) { - float shadowWidth = drawString(text, x - getStringWidth(text) / 2 + 0.45D, y + 0.5D, color, true); - return drawString(text, x - getStringWidth(text) / 2, y, color); - } - - public float drawString(String text, double x, double y, int color, boolean shadow) { - x -= 1; - - if (text == null) { - return 0.0F; - } - - if (color == 553648127) { - color = 16777215; - } - - if ((color & 0xFC000000) == 0) { - color |= -16777216; - } - - if (shadow) { - color = (color & 0xFCFCFC) >> 2 | color & new Color(20, 20, 20, 200).getRGB(); - } - - CFont.CharData[] currentData = this.charData; - float alpha = (color >> 24 & 0xFF) / 255.0F; - boolean randomCase = false; - boolean bold = false; - boolean italic = false; - boolean strikethrough = false; - boolean underline = false; - boolean render = true; - double scaleFactor = 2.0D / getFontScale(); - x *= scaleFactor; - y = (y - 3.0D) * scaleFactor; - - if (render) { - GL11.glPushMatrix(); - GlStateManager.scale(1.0D / scaleFactor, 1.0D / scaleFactor, 1.0D / scaleFactor); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(770, 771); - GlStateManager.color((color >> 16 & 0xFF) / 255.0F, (color >> 8 & 0xFF) / 255.0F, (color & 0xFF) / 255.0F, alpha); - int size = text.length(); - GlStateManager.enableTexture2D(); - GlStateManager.bindTexture(getTexture().getGlTextureId()); - - GL11.glBindTexture(GL11.GL_TEXTURE_2D, getTexture().getGlTextureId()); - - for (int i = 0; i < size; i++) { - char character = text.charAt(i); - if ((String.valueOf(character).equals("\247")) && (i < size)) { - int colorIndex = 21; - - try { - colorIndex = "0123456789abcdefklmnor".indexOf(text.charAt(i + 1)); - } catch (Exception e) { - e.printStackTrace(); - } - - if (colorIndex < 16) { - bold = false; - italic = false; - randomCase = false; - underline = false; - strikethrough = false; - GlStateManager.bindTexture(getTexture().getGlTextureId()); - // GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D, - // tex.getGlTextureId()); - currentData = this.charData; - - if ((colorIndex < 0) || (colorIndex > 15)) { - colorIndex = 15; - } - - if (shadow) { - colorIndex += 16; - } - - int colorcode = this.colorCode[colorIndex]; - GlStateManager.color((colorcode >> 16 & 0xFF) / 255.0F, (colorcode >> 8 & 0xFF) / 255.0F, (colorcode & 0xFF) / 255.0F, alpha); - } else if (colorIndex == 16) { - randomCase = true; - } else if (colorIndex == 17) { - bold = true; - - if (italic) { - GlStateManager.bindTexture(getTexItalicBold().getGlTextureId()); - // GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D, - // texItalicBold.getGlTextureId()); - currentData = this.boldItalicChars; - } else { - GlStateManager.bindTexture(getTexBold().getGlTextureId()); - // GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D, - // texBold.getGlTextureId()); - currentData = this.boldChars; - } - } else if (colorIndex == 18) { - strikethrough = true; - } else if (colorIndex == 19) { - underline = true; - } else if (colorIndex == 20) { - italic = true; - - if (bold) { - GlStateManager.bindTexture(getTexItalicBold().getGlTextureId()); - // GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D, - // texItalicBold.getGlTextureId()); - currentData = this.boldItalicChars; - } else { - GlStateManager.bindTexture(getTexItalic().getGlTextureId()); - // GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D, - // texItalic.getGlTextureId()); - currentData = this.italicChars; - } - } else if (colorIndex == 21) { - bold = false; - italic = false; - randomCase = false; - underline = false; - strikethrough = false; - GlStateManager.color((color >> 16 & 0xFF) / 255.0F, (color >> 8 & 0xFF) / 255.0F, (color & 0xFF) / 255.0F, alpha); - GlStateManager.bindTexture(getTexture().getGlTextureId()); - // GL11.glfunc_179144_i(GL11.GL_TEXTURE_2D, - // tex.getGlTextureId()); - currentData = this.charData; - } - - i++; - } else if ((character < currentData.length) && (character >= 0)) { - GL11.glBegin(GL11.GL_TRIANGLES); - drawChar(currentData, character, (float) x, (float) y); - GL11.glEnd(); - - if (strikethrough) { - drawLine(x, y + currentData[character].height / 2, x + currentData[character].width - 8.0D, y + currentData[character].height / 2, 1.0F); - } - - if (underline) { - drawLine(x, y + currentData[character].height - 2.0D, x + currentData[character].width - 8.0D, y + currentData[character].height - 2.0D, 1.0F); - } - - x += currentData[character].width - 8 + this.charOffset; - } - } - - GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_DONT_CARE); - GL11.glPopMatrix(); - } - - return (float) (x / scaleFactor); - } - - public int getStringWidth(String text) { - if (text == null) { - return 0; - } - int width = 0; - CFont.CharData[] currentData = this.charData; - boolean bold = false; - boolean italic = false; - int size = text.length(); - - for (int i = 0; i < size; i++) { - char character = text.charAt(i); - - if ((String.valueOf(character).equals("\247")) && (i < size)) { - int colorIndex = "0123456789abcdefklmnor".indexOf(character); - - if (colorIndex < 16) { - bold = false; - italic = false; - } else if (colorIndex == 17) { - bold = true; - - if (italic) { - currentData = this.boldItalicChars; - } else { - currentData = this.boldChars; - } - } else if (colorIndex == 20) { - italic = true; - - if (bold) { - currentData = this.boldItalicChars; - } else { - currentData = this.italicChars; - } - } else if (colorIndex == 21) { - bold = false; - italic = false; - currentData = this.charData; - } - - i++; - } else if ((character < currentData.length) && (character >= 0)) { - width += currentData[character].width - 8 + this.charOffset; - } - } - - return (int) ((width / 2) * getFontScale()); - } - - public int getStringWidthCust(String text) { - if (text == null) { - return 0; - } - - int width = 0; - CFont.CharData[] currentData = this.charData; - boolean bold = false; - boolean italic = false; - int size = text.length(); - - for (int i = 0; i < size; i++) { - char character = text.charAt(i); - - if ((String.valueOf(character).equals("§")) && (i < size)) { - int colorIndex = "0123456789abcdefklmnor".indexOf(character); - - if (colorIndex < 16) { - bold = false; - italic = false; - } else if (colorIndex == 17) { - bold = true; - - if (italic) { - currentData = this.boldItalicChars; - } else { - currentData = this.boldChars; - } - } else if (colorIndex == 20) { - italic = true; - - if (bold) { - currentData = this.boldItalicChars; - } else { - currentData = this.italicChars; - } - } else if (colorIndex == 21) { - bold = false; - italic = false; - currentData = this.charData; - } - - i++; - } else if ((character < currentData.length) && (character >= 0)) { - width += currentData[character].width - 8 + this.charOffset; - } - } - - return (int) (((width - this.charOffset) / 2) * getFontScale()); - } - - public void setFont(Font font) { - super.setFont(font); - setupBoldItalicIDs(); - } - - public void setAntiAlias(boolean antiAlias) { - super.setAntiAlias(antiAlias); - setupBoldItalicIDs(); - } - - public void setFractionalMetrics(boolean fractionalMetrics) { - super.setFractionalMetrics(fractionalMetrics); - setupBoldItalicIDs(); - } - - protected AbstractTexture texBold; - protected AbstractTexture texItalic; - protected AbstractTexture texItalicBold; - private BufferedImage boldImage; - private BufferedImage italicImage; - private BufferedImage boldItalicImage; - - private void setupBoldItalicIDs() { - boldImage = generateFontImage(this.font.deriveFont(1), this.antiAlias, this.fractionalMetrics, this.boldChars); - italicImage = generateFontImage(this.font.deriveFont(2), this.antiAlias, this.fractionalMetrics, this.italicChars); - boldItalicImage = generateFontImage(this.font.deriveFont(3), this.antiAlias, this.fractionalMetrics, this.boldItalicChars); - texBold = null; - texItalic = null; - texItalicBold = null; - } - - private AbstractTexture getTexBold() { - if (texBold == null) { - texBold = setupTexture(boldImage); - boldImage = null; - } - return texBold; - } - - private AbstractTexture getTexItalic() { - if (texItalic == null) { - texItalic = setupTexture(italicImage); - italicImage = null; - } - return texItalic; - } - - private AbstractTexture getTexItalicBold() { - if (texItalicBold == null) { - texItalicBold = setupTexture(boldItalicImage); - boldItalicImage = null; - } - return texItalicBold; - } - - private void drawLine(double x, double y, double x1, double y1, float width) { - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glLineWidth(width); - GL11.glBegin(GL11.GL_LINES); - GL11.glVertex2d(x, y); - GL11.glVertex2d(x1, y1); - GL11.glEnd(); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - public List wrapWords(String text, double width) { - List finalWords = new ArrayList(); - - if (getStringWidth(text) > width) { - String[] words = text.split(" "); - String currentWord = ""; - char lastColorCode = 65535; - - for (String word : words) { - for (int i = 0; i < word.toCharArray().length; i++) { - char c = word.toCharArray()[i]; - - if ((String.valueOf(c).equals("§")) && (i < word.toCharArray().length - 1)) { - lastColorCode = word.toCharArray()[(i + 1)]; - } - } - - if (getStringWidth(currentWord + word + " ") < width) { - currentWord = currentWord + word + " "; - } else { - finalWords.add(currentWord); - currentWord = "" + lastColorCode + word + " "; - } - } - - if (currentWord.length() > 0) if (getStringWidth(currentWord) < width) { - finalWords.add("" + lastColorCode + currentWord + " "); - currentWord = ""; - } else { - for (String s : formatString(currentWord, width)) { - finalWords.add(s); - } - } - } else { - finalWords.add(text); - } - - return finalWords; - } - - public List formatString(String string, double width) { - List finalWords = new ArrayList(); - String currentWord = ""; - char lastColorCode = 65535; - char[] chars = string.toCharArray(); - - for (int i = 0; i < chars.length; i++) { - char c = chars[i]; - - if ((String.valueOf(c).equals("§")) && (i < chars.length - 1))//Why does intelij replace "§" with § - { - lastColorCode = chars[(i + 1)]; - } - - if (getStringWidth(currentWord + c) < width) { - currentWord = currentWord + c; - } else { - finalWords.add(currentWord); - currentWord = "" + lastColorCode + String.valueOf(c); - } - } - - if (currentWord.length() > 0) { - finalWords.add(currentWord); - } - - return finalWords; - } - - private void setupMinecraftColorcodes() { - for (int index = 0; index < 32; index++) { - int noClue = (index >> 3 & 0x1) * 85; - int red = (index >> 2 & 0x1) * 170 + noClue; - int green = (index >> 1 & 0x1) * 170 + noClue; - int blue = (index >> 0 & 0x1) * 170 + noClue; - - if (index == 6) { - red += 85; - } - - if (index >= 16) { - red /= 4; - green /= 4; - blue /= 4; - } - - this.colorCode[index] = ((red & 0xFF) << 16 | (green & 0xFF) << 8 | blue & 0xFF); - } - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontUtil.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontUtil.java deleted file mode 100644 index 18301cc..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/FontUtil.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import java.awt.*; -import java.io.InputStream; - - -public class FontUtil { - - public static Font getFontFromTTF(InputStream inputStream, float fontSize, int fontType) { - Font output = null; - try { - output = Font.createFont(fontType, inputStream); - output = output.deriveFont(fontSize); - } catch (Exception e) { - e.printStackTrace(); - } - return output; - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/GlImageTexture.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/GlImageTexture.java deleted file mode 100644 index 2b72282..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/GlImageTexture.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -public class GlImageTexture { - public int width; - public int height; - public int textureId; - - public GlImageTexture() { - this.textureId = GL11.glGenTextures(); - } - - public GlImageTexture(int textureId) { - this.textureId = textureId; - } - - public void bind() { - GlStateManager.bindTexture(this.textureId); - } - - public void delete() { - GL11.glDeleteTextures(this.textureId); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/LegacyFontShaderProgram.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/LegacyFontShaderProgram.java deleted file mode 100644 index 38a58e7..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/LegacyFontShaderProgram.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import cn.xiaozhou233.orangex.font.shader.ShaderProgram; - -public class LegacyFontShaderProgram extends ShaderProgram { - private static final String VERTEX_SHADER_SOURCE; - private static final String FRAGMENT_SHADER_SOURCE; - - public LegacyFontShaderProgram() { - super(VERTEX_SHADER_SOURCE, FRAGMENT_SHADER_SOURCE); - } - - static { - FRAGMENT_SHADER_SOURCE = "#version 120\nuniform sampler2D texture;\nvoid main() {\n vec2 coords = gl_TexCoord[0].xy;\n float alpha = texture2D(texture, coords).x;\n alpha = max(0.0, alpha + 0.25 * (1.0 - alpha));\n float smoothenAlpha = smoothstep(0.2, 0.8, alpha);\n alpha = mix(alpha, 0.0, 1.0 - smoothenAlpha);\n gl_FragColor = vec4(gl_Color.rgb, alpha * gl_Color.a);\n}"; - VERTEX_SHADER_SOURCE = "#version 120\nvoid main(void) {\n gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;\n gl_FrontColor = gl_Color;\n}"; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/LegacySmoothFontRenderer.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/LegacySmoothFontRenderer.java deleted file mode 100644 index c1d5c9c..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/LegacySmoothFontRenderer.java +++ /dev/null @@ -1,382 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeFontInfo; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackContext; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackRange; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackedChar; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.ResourceLocation; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import java.awt.Color; -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.ByteBuffer; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -public class LegacySmoothFontRenderer extends SmoothFontRenderer { - private float ascent; - private Map glyphs = new HashMap(); - private int textureId; - private float pixelScale; - private float renderScale = 0.6f; - private LegacyFontShaderProgram shader; - - public LegacySmoothFontRenderer(byte[] fontData, int fontSize, String fontName) { - this.fontSize = fontSize; - buildFont(fontData, fontSize, fontName); - } - - public LegacySmoothFontRenderer(String resourcePath, int fontSize) { - this.fontSize = fontSize; - try { - byte[] fontData = readResource(resourcePath); - buildFont(fontData, fontSize, resourcePath); - } catch (Exception e) { - e.printStackTrace(); - } - } - - private byte[] readResource(String path) { - try { - String resourcePath = "fonts/" + path; - InputStream is = LegacySmoothFontRenderer.class.getClassLoader().getResourceAsStream(resourcePath); - if (is == null) { - is = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("fonts/" + path)).getInputStream(); - } - if (is == null) return null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buf = new byte[8192]; - int len; - while ((len = is.read(buf)) != -1) { - baos.write(buf, 0, len); - } - is.close(); - return baos.toByteArray(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - private void buildFont(byte[] fontData, int fontSize, String fontName) { - if (fontData == null) return; - - HashSet charSet = new HashSet(); - for (int i = 32; i <= 126; ++i) { - charSet.add(i); - } - charSet.add(0); - - try { - byte[] chineseData = readResource("chinese.properties.txt"); - if (chineseData != null) { - BufferedReader reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(chineseData), StandardCharsets.UTF_8)); - int ch; - while ((ch = reader.read()) != -1) { - if (ch >= 32) charSet.add(ch); - } - reader.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } - - int[] chars = charSet.stream().mapToInt(Integer::intValue).toArray(); - Arrays.sort(chars); - - int atlasSize = 4096; - StbTrueTypeFontInfo fontInfo = new StbTrueTypeFontInfo(); - if (SmoothFontRasterState.z(fontInfo, fontData, 0) == 0) { - System.err.println("Failed to init font: " + fontName); - return; - } - - int[] ascentArr = new int[1], descentArr = new int[1], lineGap = new int[1]; - SmoothFontRasterState.x(fontInfo, ascentArr, descentArr, lineGap); - this.ascent = ascentArr[0]; - - int[] fw = new int[1], fh = new int[1], fx = new int[1], fy = new int[1]; - SmoothFontRasterState.s(fontInfo, 72, fw, fh, fx, fy); - float glyphHeight = fy[0] - fh[0]; - float fontHeight = ascentArr[0] - descentArr[0]; - float aspect = glyphHeight / fontHeight; - float pixelHeight = (float) this.fontSize * (0.6f / aspect); - - byte[] atlasData = new byte[atlasSize * atlasSize]; - StbTrueTypePackContext packCtx = new StbTrueTypePackContext(); - if (SmoothFontRasterState.C(packCtx, atlasData, atlasSize, atlasSize, 0, 1) == 0) { - System.err.println("Failed to begin packing font"); - return; - } - - int oversampleX = 2, oversampleY = 2; - SmoothFontRasterState.n(packCtx, oversampleX, oversampleY); - - try { - StbTrueTypePackedChar[] packedChars = new StbTrueTypePackedChar[chars.length]; - for (int i = 0; i < packedChars.length; ++i) { - packedChars[i] = new StbTrueTypePackedChar(); - } - StbTrueTypePackRange range = new StbTrueTypePackRange(); - range.E = pixelHeight; - range.R = 0; - range.N = chars; - range.b = chars.length; - range.M = packedChars; - range.i = (byte) oversampleX; - range.y = (byte) oversampleY; - SmoothFontRasterState.c(packCtx, fontData, 0, new StbTrueTypePackRange[]{range}, 1); - SmoothFontRasterState.S(packCtx); - - this.pixelScale = SmoothFontRasterState.V(fontInfo, pixelHeight); - for (int i = 0; i < chars.length; ++i) { - int cp = chars[i]; - StbTrueTypePackedChar pc = packedChars[i]; - float invW = 1.0f / (float) atlasSize; - float invH = 1.0f / (float) atlasSize; - this.glyphs.put(cp, new SmoothFontGlyph( - pc.s, pc.G, pc.t, pc.R, - (float) pc.b * invW, (float) pc.k * invH, - (float) pc.q * invW, (float) pc.p * invH, - pc.A - )); - } - } catch (Exception e) { - e.printStackTrace(); - } - - ByteBuffer buffer = BufferUtils.createByteBuffer(atlasData.length + 128); - buffer.put(atlasData); - buffer.flip(); - - this.textureId = GL11.glGenTextures(); - GlStateManager.bindTexture(this.textureId); - GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); - GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_LUMINANCE, atlasSize, atlasSize, 0, GL11.GL_LUMINANCE, GL11.GL_UNSIGNED_BYTE, buffer); - - shader = new LegacyFontShaderProgram(); - } - - @Override - public void drawVerticalString(String text, double x, double y, Color color) { - char[] chars = text.toCharArray(); - for (int i = 0; i < chars.length; ++i) { - drawStringWithShadow(String.valueOf(chars[i]), x, y, color); - y += getStringHeight(String.valueOf(chars[i])) * 0.9; - } - } - - @Override - public void renderString(String text, double x, double y, int color, boolean fallbackToVanilla) { - if (!fallbackToVanilla) { - if (text == null || text.length() == 0 || textureId == 0) return; - - int r = (color >> 16) & 0xFF; - int g = (color >> 8) & 0xFF; - int b = color & 0xFF; - int a = (color >> 24) & 0xFF; - if (a < 0) a += 256; - if (a == 0) a = 255; - Color baseColor = new Color(r, g, b, a); - - char[] colorCodes = new char[text.length()]; - Arrays.fill(colorCodes, '\u0000'); - StringBuilder sb = new StringBuilder(); - char[] chars = text.toCharArray(); - int codeIdx = 0; - for (int i = 0; i < chars.length; ++i) { - char c = chars[i]; - if (c == '\u00a7') { - if (++i >= chars.length) continue; - colorCodes[codeIdx] = chars[i]; - continue; - } - sb.append(c); - ++codeIdx; - } - text = sb.toString(); - - float f = renderScale; - y += (double)(this.ascent * this.pixelScale * f); - Color currentColor = baseColor; - - int prevTex = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D); - boolean blendEnabled = GL11.glIsEnabled(GL11.GL_BLEND); - boolean texEnabled = GL11.glIsEnabled(GL11.GL_TEXTURE_2D); - boolean lightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING); - boolean alphaEnabled = GL11.glIsEnabled(GL11.GL_ALPHA_TEST); - boolean cullEnabled = GL11.glIsEnabled(GL11.GL_CULL_FACE); - - if (!blendEnabled) GlStateManager.enableBlend(); - if (!texEnabled) GlStateManager.enableTexture2D(); - if (lightingEnabled) GlStateManager.disableLighting(); - if (!alphaEnabled) GlStateManager.enableAlpha(); - if (cullEnabled) GlStateManager.disableCull(); - - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.bindTexture(this.textureId); - - if (shader != null) shader.bind(); - - GL11.glBegin(GL11.GL_QUADS); - for (int i = 0; i < text.length(); ++i) { - char c = text.charAt(i); - SmoothFontGlyph glyph = this.glyphs.get((int) c); - if (glyph == null) glyph = this.glyphs.get(32); - if (glyph == null) continue; - - char cc = colorCodes[i]; - if (cc != '\u0000') { - float[] rgb = new float[3]; - applyColorCode(cc, rgb); - currentColor = new Color(rgb[0], rgb[1], rgb[2]); - if (cc == 'r') currentColor = baseColor; - } - - float x1 = (float) x + glyph.xOffset * f; - float y1 = (float) y + glyph.yOffset * f; - float x2 = (float) x + glyph.xMax * f; - float y2 = (float) y + glyph.yMax * f; - - GL11.glColor4f( - (float) currentColor.getRed() / 255.0f, - (float) currentColor.getGreen() / 255.0f, - (float) currentColor.getBlue() / 255.0f, - (float) baseColor.getAlpha() / 255.0f - ); - GL11.glTexCoord2f(glyph.uMin, glyph.vMin); - GL11.glVertex2f(x1, y1); - GL11.glTexCoord2f(glyph.uMin, glyph.vMax); - GL11.glVertex2f(x1, y2); - GL11.glTexCoord2f(glyph.uMax, glyph.vMax); - GL11.glVertex2f(x2, y2); - GL11.glTexCoord2f(glyph.uMax, glyph.vMin); - GL11.glVertex2f(x2, y1); - - x += glyph.advance * f; - } - GL11.glEnd(); - - if (shader != null) shader.restorePreviousProgram(); - - GlStateManager.bindTexture(prevTex); - if (!alphaEnabled) GlStateManager.disableAlpha(); - if (lightingEnabled) GlStateManager.enableLighting(); - if (!blendEnabled) GlStateManager.disableBlend(); - if (!texEnabled) GlStateManager.disableTexture2D(); - if (cullEnabled) GlStateManager.enableCull(); - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - } else { - float f = (float) this.fontSize / 16.0f; - float inv = 1.0f / f; - x = Math.ceil(x * inv); - y = Math.ceil(y * inv); - GL11.glPushMatrix(); - GL11.glScalef(f, f, f); - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(text, (float) x, (float) y, color); - GL11.glPopMatrix(); - } - } - - @Override - public void drawStringWithShadow(String text, double x, double y, int color) { - drawString(text, x + 0.5, y + 0.5, Integer.MIN_VALUE); - renderString(text, x, y, color, false); - } - - @Override - public void drawStringWithShadow(String text, double x, double y, Color color, boolean fallbackToVanilla) { - if (!fallbackToVanilla) { - drawString(text, x + 0.5, y + 0.5, Integer.MIN_VALUE); - drawString(text, x, y, color); - } else { - float f = (float) this.fontSize / 16.0f; - float inv = 1.0f / f; - x = Math.ceil(x * inv); - y = Math.ceil(y * inv); - GL11.glPushMatrix(); - GL11.glScalef(f, f, f); - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(text, (float) x, (float) y, color.getRGB()); - GL11.glPopMatrix(); - } - } - - @Override - public double getStringHeight(String text, boolean fallbackToVanilla) { - if (!fallbackToVanilla) { - float f = 0.6f; - return (float) this.fontSize * f; - } - float f = (float) this.fontSize / 16.0f; - return 8.0f * f; - } - - @Override - public double getStringWidth(String text, boolean fallbackToVanilla) { - String stripped = this.strippedStringCache.get(text); - if (stripped == null) { - StringBuilder sb = new StringBuilder(); - for (char c : text.toCharArray()) { - if (c == '\u00a7') continue; - sb.append(c); - } - stripped = sb.toString(); - this.strippedStringCache.put(text, stripped); - } - text = stripped; - - if (!fallbackToVanilla) { - Double cached = this.stringWidthCache.get(text); - if (cached != null) return cached; - - float f = 0.6f; - double width = 0.0; - for (int i = 0; i < text.length(); ++i) { - char c = text.charAt(i); - SmoothFontGlyph glyph = this.glyphs.get((int) c); - if (glyph == null) glyph = this.glyphs.get(32); - if (glyph == null) continue; - width += glyph.advance * f; - } - this.stringWidthCache.put(text, width); - return width; - } - - float f = (float) this.fontSize / 16.0f; - return Minecraft.getMinecraft().fontRendererObj.getStringWidth(text) * f; - } - - @Override - public void renderStringWithShadow(String text, double x, double y, Color color, Color shadowColor, boolean fallbackToVanilla) { - int n = color.getRGB(); - int n2 = shadowColor.getRGB(); - if (!fallbackToVanilla) { - drawString(text, x + 0.5, y + 0.5, n2); - drawString(text, x, y, color); - } else { - float f = (float) this.fontSize / 16.0f; - float inv = 1.0f / f; - x = Math.ceil(x * inv); - y = Math.ceil(y * inv); - GL11.glPushMatrix(); - GL11.glScalef(f, f, f); - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(text, (float) x, (float) y, n); - GL11.glPopMatrix(); - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontGlyph.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontGlyph.java deleted file mode 100644 index 5da1776..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontGlyph.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -public class SmoothFontGlyph { - public float uMin; - public float vMin; - public float uMax; - public float vMax; - public float xOffset; - public float yOffset; - public float xMax; - public float yMax; - public float advance; - - public SmoothFontGlyph(float xOffset, float yOffset, float xMax, float yMax, float uMin, float vMin, float uMax, float vMax, float advance) { - this.xOffset = xOffset; - this.xMax = xMax; - this.yOffset = yOffset; - this.yMax = yMax; - this.uMin = uMin; - this.uMax = uMax; - this.vMin = vMin; - this.vMax = vMax; - this.advance = advance; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRasterState.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRasterState.java deleted file mode 100644 index fd4f7ba..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRasterState.java +++ /dev/null @@ -1,3406 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeActiveEdge; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeAlignedQuad; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeBakedChar; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeBitmap; -import cn.xiaozhou233.orangex.font.stb.StbByteBufferView; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeCharStringContext; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeEdge; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeFontInfo; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeGlyphPackNode; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeKerningEntry; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackAtlasState; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackContext; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackRange; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackRectangle; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePackedChar; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypePoint; -import cn.xiaozhou233.orangex.font.stb.StbTrueTypeVertex; -import java.util.Arrays; - -public class SmoothFontRasterState { - public static final int d = 0; - public static final int x; - public static final int O; - public static final int n; - public static final int M; - public static final int b = 1; - static final /* synthetic */ boolean G; - public static final int z; - public static final int m; - public static final int Fc; - public static final int P; - public static final int q; - public static final int J = 1; - public static final int j; - public static final int W; - public static final int R; - public static final int T; - public static final int e; - public static final int B; - public static final int u = 0; - public static final int i; - public static final int I; - public static final int k = 0; - public static final int Q; - public static final int h; - public static final int FM = 1; - public static final int a; - public static final int F1; - public static final int g; - public static final int Fb; - public static final int s = 0; - public static final int y = 1; - public static final int V; - public static final int FC; - private static final int c; - public static final int v; - public static final int E; - public static final int w = 1; - public static final int N; - public static final int p = 1; - public static final int D; - public static final int U; - public static final int Ff; - public static final int K = 0; - public static final int F; - public static final int L; - public static final int l = 0; - public static final int t; - public static final int f; - public static final int o; - public static final int A; - public static final int Z; - public static final int C; - public static final int X = 1; - public static final int S; - public static final int r; - public static final int H; - public static final int Fy; - public static final int Y; - - public static int F(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - if (stbTrueTypeFontInfo.g.y != 0) { - SmoothFontRasterState.m(stbTrueTypeFontInfo, n, nArray, nArray2, nArray3, nArray4); - } else { - int n2 = SmoothFontRasterState.G(stbTrueTypeFontInfo, n); - if (n2 < 0) { - return 0; - } - if (nArray != null) { - nArray[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n2 + 2); - } - if (nArray2 != null) { - nArray2[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n2 + 4); - } - if (nArray3 != null) { - nArray3[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n2 + 6); - } - if (nArray4 != null) { - nArray4[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n2 + 8); - } - } - return 1; - } - - static StbByteBufferView e(StbByteBufferView frame, int n) { - StbByteBufferView frame2 = frame.k(); - SmoothFontRasterState.i(frame2, 0); - int n2 = SmoothFontRasterState.p(frame2); - int n3 = SmoothFontRasterState.Q(frame2); - if (!(G || n >= 0 && n < n2)) { - throw new AssertionError(); - } - if (!(G || n3 >= 1 && n3 <= 4)) { - throw new AssertionError(); - } - SmoothFontRasterState.K(frame2, n * n3); - int n4 = (int)SmoothFontRasterState.u(frame2, n3); - int n5 = (int)SmoothFontRasterState.u(frame2, n3); - return SmoothFontRasterState.E(frame2, 2 + (n2 + 1) * n3 + n4, n5 - n4); - } - - public static int y(byte[] byArray, String string, int n) { - return SmoothFontRasterState.h(byArray, string.getBytes(), n); - } - - static int a(StbTrueTypeVertex[] stbTrueTypeVertexArray, int n, int n2, int n3, int n4, int n5, int n6, int n7, int n8, int n9) { - if (n3 != 0) { - if (n2 != 0) { - SmoothFontRasterState.d(stbTrueTypeVertexArray[n++], 3, n8 + n6 >> 1, n9 + n7 >> 1, n8, n9); - } - SmoothFontRasterState.d(stbTrueTypeVertexArray[n++], 3, n4, n5, n6, n7); - } else if (n2 != 0) { - SmoothFontRasterState.d(stbTrueTypeVertexArray[n++], 3, n4, n5, n8, n9); - } else { - SmoothFontRasterState.d(stbTrueTypeVertexArray[n++], 2, n4, n5, 0, 0); - } - return n; - } - - static void p(byte[] byArray, int n, int n2, int n3, int n4, int n5) { - byte[] byArray2 = new byte[8]; - int n6 = n3 - n5; - Arrays.fill(byArray2, (byte)0); - for (int i = 0; i < n2; ++i) { - int n7; - Arrays.fill(byArray2, 0, n5, (byte)0); - int n8 = 0; - switch (n5) { - case 2: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7 * n4]; - byArray[n + n7 * n4] = (byte)((n8 += (byArray[n + n7 * n4] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 2); - } - break; - } - case 3: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7 * n4]; - byArray[n + n7 * n4] = (byte)((n8 += (byArray[n + n7 * n4] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 3); - } - break; - } - case 4: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7 * n4]; - byArray[n + n7 * n4] = (byte)((n8 += (byArray[n + n7 * n4] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 4); - } - break; - } - case 5: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7 * n4]; - byArray[n + n7 * n4] = (byte)((n8 += (byArray[n + n7 * n4] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 5); - } - break; - } - default: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7 * n4]; - byArray[n + n7 * n4] = (byte)((n8 += (byArray[n + n7 * n4] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / n5); - } - } - } - while (n7 < n3) { - byArray[n + n7 * n4] = (byte)((n8 -= byArray2[n7 & 7] & 0xFF) / n5); - ++n7; - } - ++n; - } - } - - static int B(byte[] byArray, int n) { - return ((byArray[n] & 0xFF) << 24) + ((byArray[n + 1] & 0xFF) << 16) + ((byArray[n + 2] & 0xFF) << 8) + (byArray[n + 3] & 0xFF); - } - - static float A(float f, float f2, float f3) { - return (f2 + f3) / 2.0f * f; - } - - static void V(StbTrueTypeCharStringContext stbTrueTypeCharStringContext, int n, int n2) { - if (n > stbTrueTypeCharStringContext.c || stbTrueTypeCharStringContext.v == 0) { - stbTrueTypeCharStringContext.c = n; - } - if (n2 > stbTrueTypeCharStringContext.f || stbTrueTypeCharStringContext.v == 0) { - stbTrueTypeCharStringContext.f = n2; - } - if (n < stbTrueTypeCharStringContext.y || stbTrueTypeCharStringContext.v == 0) { - stbTrueTypeCharStringContext.y = n; - } - if (n2 < stbTrueTypeCharStringContext.Z || stbTrueTypeCharStringContext.v == 0) { - stbTrueTypeCharStringContext.Z = n2; - } - stbTrueTypeCharStringContext.v = 1; - } - - public static void m(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, float f, float f2, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - SmoothFontRasterState.p(stbTrueTypeFontInfo, n, f, f2, 0.0f, 0.0f, nArray, nArray2, nArray3, nArray4); - } - - public static void o(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n, int n2, int n3, int n4, float f, float f2, float f3, float f4, int n5, int n6, float[] fArray, float[] fArray2, int n7) { - SmoothFontRasterState.H(stbTrueTypeFontInfo, byArray, n, n2, n3, n4, f, f2, f3, f4, n5, n6, fArray, fArray2, SmoothFontRasterState.T(stbTrueTypeFontInfo, n7)); - } - - static StbByteBufferView x(byte[] byArray, int n, int n2) { - if (!G && n2 >= 0x40000000) { - throw new AssertionError(); - } - StbByteBufferView frame = new StbByteBufferView(); - frame.f = byArray; - frame.C = n; - frame.y = n2; - frame.h = 0; - return frame; - } - - public static int d(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int n2) { - int n3 = 0; - if (stbTrueTypeFontInfo.G != 0) { - n3 += SmoothFontRasterState.c(stbTrueTypeFontInfo, n, n2); - } else if (stbTrueTypeFontInfo.L != 0) { - n3 += SmoothFontRasterState.v(stbTrueTypeFontInfo, n, n2); - } - return n3; - } - - static void b(StbTrueTypePackAtlasState stbTrueTypePackAtlasState, int n, int n2, StbTrueTypeGlyphPackNode[] stbTrueTypeGlyphPackNodeArray, int n3) { - stbTrueTypePackAtlasState.f = n; - stbTrueTypePackAtlasState.F = n2; - stbTrueTypePackAtlasState.n = 0; - stbTrueTypePackAtlasState.a = 0; - stbTrueTypePackAtlasState.t = 0; - } - - public static String j(StbTrueTypeFontInfo stbTrueTypeFontInfo, int[] nArray, int n, int n2, int n3, int n4) { - byte[] byArray = stbTrueTypeFontInfo.S; - int n5 = stbTrueTypeFontInfo.U; - long l = SmoothFontRasterState.v(byArray, n5, "name"); - if (l == 0L) { - return null; - } - int n6 = SmoothFontRasterState.x(byArray, (int)l + 2); - int n7 = (int)l + SmoothFontRasterState.x(byArray, (int)l + 4); - for (int i = 0; i < n6; ++i) { - int n8 = (int)l + 6 + 12 * i; - if (n != SmoothFontRasterState.x(byArray, n8 + 0) || n2 != SmoothFontRasterState.x(byArray, n8 + 2) || n3 != SmoothFontRasterState.x(byArray, n8 + 4) || n4 != SmoothFontRasterState.x(byArray, n8 + 6)) continue; - nArray[0] = SmoothFontRasterState.x(byArray, n8 + 8); - int n9 = n7 + SmoothFontRasterState.x(byArray, n8 + 10); - byte[] byArray2 = new byte[nArray[0]]; - System.arraycopy(byArray, n9, byArray2, 0, nArray[0]); - return new String(byArray2); - } - return null; - } - - public static int c(byte[] byArray, int n) { - return SmoothFontRasterState.E(byArray, n); - } - - public static byte[] F(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f, float f2, float f3, float f4, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - int n2; - int[] nArray5 = new int[1]; - int[] nArray6 = new int[1]; - int[] nArray7 = new int[1]; - int[] nArray8 = new int[1]; - StbTrueTypeBitmap stbTrueTypeBitmap = new StbTrueTypeBitmap(); - StbTrueTypeVertex[] stbTrueTypeVertexArray = SmoothFontRasterState.m(stbTrueTypeFontInfo, n); - int n3 = n2 = stbTrueTypeVertexArray != null ? stbTrueTypeVertexArray.length : 0; - if (f == 0.0f) { - f = f2; - } - if (f2 == 0.0f) { - if (f == 0.0f) { - return null; - } - f2 = f; - } - SmoothFontRasterState.G(stbTrueTypeFontInfo, n, f, f2, f3, f4, nArray5, nArray6, nArray7, nArray8); - stbTrueTypeBitmap.K = nArray7[0] - nArray5[0]; - stbTrueTypeBitmap.c = nArray8[0] - nArray6[0]; - stbTrueTypeBitmap.E = null; - if (nArray != null) { - nArray[0] = stbTrueTypeBitmap.K; - } - if (nArray2 != null) { - nArray2[0] = stbTrueTypeBitmap.c; - } - if (nArray3 != null) { - nArray3[0] = nArray5[0]; - } - if (nArray4 != null) { - nArray4[0] = nArray6[0]; - } - if (stbTrueTypeBitmap.K != 0 && stbTrueTypeBitmap.c != 0) { - stbTrueTypeBitmap.E = new byte[stbTrueTypeBitmap.K * stbTrueTypeBitmap.c]; - stbTrueTypeBitmap.h = 0; - if (stbTrueTypeBitmap.E != null) { - stbTrueTypeBitmap.A = stbTrueTypeBitmap.K; - SmoothFontRasterState.b(stbTrueTypeBitmap, 0.35f, stbTrueTypeVertexArray, n2, f, f2, f3, f4, nArray5[0], nArray6[0], 1); - } - } - return stbTrueTypeBitmap.E; - } - - static void Q(StbTrueTypeCharStringContext stbTrueTypeCharStringContext, float f, float f2) { - SmoothFontRasterState.d(stbTrueTypeCharStringContext); - stbTrueTypeCharStringContext.s = stbTrueTypeCharStringContext.C += f; - stbTrueTypeCharStringContext.p = stbTrueTypeCharStringContext.o += f2; - SmoothFontRasterState.A(stbTrueTypeCharStringContext, 1, (int)stbTrueTypeCharStringContext.C, (int)stbTrueTypeCharStringContext.o, 0, 0, 0, 0); - } - - static void K(StbByteBufferView frame, int n) { - SmoothFontRasterState.i(frame, frame.h + n); - } - - static long v(byte[] byArray, int n, String string) { - int n2 = SmoothFontRasterState.x(byArray, n + 4); - long l = n + 12; - for (int i = 0; i < n2; ++i) { - long l2 = l + (long)(16 * i); - if (!SmoothFontRasterState.f(byArray, (int)l2, string)) continue; - return SmoothFontRasterState.c$src$J$1nktx4p(byArray, (int)l2 + 8); - } - return 0L; - } - - static StbTrueTypeVertex[] o(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - int n2; - byte[] byArray = stbTrueTypeFontInfo.S; - StbTrueTypeVertex[] stbTrueTypeVertexArray = null; - int n3 = 0; - int n4 = SmoothFontRasterState.G(stbTrueTypeFontInfo, n); - if (n4 < 0) { - return null; - } - short s = SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n4); - if (s > 0) { - int n5; - int n6; - n2 = 0; - int n7 = 0; - int n8 = 0; - int n9 = 0; - int n10 = n4 + 10; - int n11 = SmoothFontRasterState.x(byArray, n4 + 10 + s * 2); - int n12 = n4 + 10 + s * 2 + 2 + n11; - int n13 = 1 + SmoothFontRasterState.x(byArray, n10 + s * 2 - 2); - int n14 = n13 + 2 * s; - stbTrueTypeVertexArray = new StbTrueTypeVertex[n14]; - for (n6 = 0; n6 < n14; ++n6) { - stbTrueTypeVertexArray[n6] = new StbTrueTypeVertex(); - } - int n15 = 0; - int n16 = 0; - int n17 = n14 - n13; - int n18 = n12; - for (n6 = 0; n6 < n13; ++n6) { - if (n16 == 0) { - if (((n2 = byArray[n18++] & 0xFF) & 8) != 0) { - n16 = byArray[n18++] & 0xFF; - } - } else { - --n16; - } - stbTrueTypeVertexArray[n17 + n6].O = n2; - } - int n19 = 0; - for (n6 = 0; n6 < n13; ++n6) { - n2 = stbTrueTypeVertexArray[n17 + n6].O; - if ((n2 & 2) != 0) { - n5 = byArray[n18++] & 0xFF; - n19 += (n2 & 0x10) != 0 ? n5 : -n5; - } else if ((n2 & 0x10) == 0) { - n19 += (short)((byArray[n18] & 0xFF) * 256 + (byArray[n18 + 1] & 0xFF)); - n18 += 2; - } - stbTrueTypeVertexArray[n17 + n6].f = (short)n19; - } - int n20 = 0; - for (n6 = 0; n6 < n13; ++n6) { - n2 = stbTrueTypeVertexArray[n17 + n6].O; - if ((n2 & 4) != 0) { - n5 = byArray[n18++] & 0xFF; - n20 += (n2 & 0x20) != 0 ? n5 : -n5; - } else if ((n2 & 0x20) == 0) { - n20 += (short)((byArray[n18] & 0xFF) * 256 + (byArray[n18 + 1] & 0xFF)); - n18 += 2; - } - stbTrueTypeVertexArray[n17 + n6].H = (short)n20; - } - n3 = 0; - int n21 = 0; - int n22 = 0; - int n23 = 0; - int n24 = 0; - int n25 = 0; - int n26 = 0; - for (n6 = 0; n6 < n13; ++n6) { - n2 = stbTrueTypeVertexArray[n17 + n6].O; - n19 = stbTrueTypeVertexArray[n17 + n6].f; - n20 = stbTrueTypeVertexArray[n17 + n6].H; - if (n15 == n6) { - if (n6 != 0) { - n3 = SmoothFontRasterState.a(stbTrueTypeVertexArray, n3, n8, n9, n26, n25, n22, n21, n24, n23); - } - int n27 = n9 = (n2 & 1) == 0 ? 1 : 0; - if (n9 != 0) { - n22 = n19; - n21 = n20; - if ((stbTrueTypeVertexArray[n17 + n6 + 1].O & 1) == 0) { - n26 = n19 + stbTrueTypeVertexArray[n17 + n6 + 1].f >> 1; - n25 = n20 + stbTrueTypeVertexArray[n17 + n6 + 1].H >> 1; - } else { - n26 = stbTrueTypeVertexArray[n17 + n6 + 1].f; - n25 = stbTrueTypeVertexArray[n17 + n6 + 1].H; - ++n6; - } - } else { - n26 = n19; - n25 = n20; - } - SmoothFontRasterState.d(stbTrueTypeVertexArray[n3++], 1, n26, n25, 0, 0); - n8 = 0; - n15 = 1 + SmoothFontRasterState.x(byArray, n10 + n7 * 2); - ++n7; - continue; - } - if ((n2 & 1) == 0) { - if (n8 != 0) { - SmoothFontRasterState.d(stbTrueTypeVertexArray[n3++], 3, n24 + n19 >> 1, n23 + n20 >> 1, n24, n23); - } - n24 = n19; - n23 = n20; - n8 = 1; - continue; - } - if (n8 != 0) { - SmoothFontRasterState.d(stbTrueTypeVertexArray[n3++], 3, n19, n20, n24, n23); - } else { - SmoothFontRasterState.d(stbTrueTypeVertexArray[n3++], 2, n19, n20, 0, 0); - } - n8 = 0; - } - n3 = SmoothFontRasterState.a(stbTrueTypeVertexArray, n3, n8, n9, n26, n25, n22, n21, n24, n23); - } else if (s < 0) { - n2 = 1; - int n28 = n4 + 10; - n3 = 0; - stbTrueTypeVertexArray = null; - while (n2 != 0) { - int n29 = 0; - StbTrueTypeVertex[] stbTrueTypeVertexArray2 = null; - StbTrueTypeVertex[] stbTrueTypeVertexArray3 = null; - float[] fArray = new float[]{1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - int n30 = SmoothFontRasterState.x(byArray, n28); - int n31 = SmoothFontRasterState.x(byArray, n28 += 2); - n28 += 2; - if ((n30 & 2) != 0) { - if ((n30 & 1) != 0) { - fArray[4] = SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28); - fArray[5] = SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28 += 2); - n28 += 2; - } else { - fArray[4] = SmoothFontRasterState.u(byArray, n28); - fArray[5] = SmoothFontRasterState.u(byArray, ++n28); - ++n28; - } - } else if (!G) { - throw new AssertionError(); - } - if ((n30 & 8) != 0) { - fArray[0] = fArray[3] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28) / 16384.0f; - n28 += 2; - fArray[2] = 0.0f; - fArray[1] = 0.0f; - } else if ((n30 & 0x40) != 0) { - fArray[0] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28) / 16384.0f; - fArray[2] = 0.0f; - fArray[1] = 0.0f; - fArray[3] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28 += 2) / 16384.0f; - n28 += 2; - } else if ((n30 & 0x80) != 0) { - fArray[0] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28) / 16384.0f; - fArray[1] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28 += 2) / 16384.0f; - fArray[2] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28 += 2) / 16384.0f; - fArray[3] = (float)SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n28 += 2) / 16384.0f; - n28 += 2; - } - float f = (float)Math.sqrt(fArray[0] * fArray[0] + fArray[1] * fArray[1]); - float f2 = (float)Math.sqrt(fArray[2] * fArray[2] + fArray[3] * fArray[3]); - stbTrueTypeVertexArray2 = SmoothFontRasterState.m(stbTrueTypeFontInfo, n31); - if (stbTrueTypeVertexArray2 != null) { - n29 = stbTrueTypeVertexArray2.length; - } - if (n29 > 0) { - for (int i = 0; i < n29; ++i) { - StbTrueTypeVertex stbTrueTypeVertex = stbTrueTypeVertexArray2[i]; - short s2 = stbTrueTypeVertex.f; - short s3 = stbTrueTypeVertex.H; - stbTrueTypeVertex.f = (short)(f * (fArray[0] * (float)s2 + fArray[2] * (float)s3 + fArray[4])); - stbTrueTypeVertex.H = (short)(f2 * (fArray[1] * (float)s2 + fArray[3] * (float)s3 + fArray[5])); - s2 = stbTrueTypeVertex.h; - s3 = stbTrueTypeVertex.D; - stbTrueTypeVertex.h = (short)(f * (fArray[0] * (float)s2 + fArray[2] * (float)s3 + fArray[4])); - stbTrueTypeVertex.D = (short)(f2 * (fArray[1] * (float)s2 + fArray[3] * (float)s3 + fArray[5])); - } - stbTrueTypeVertexArray3 = new StbTrueTypeVertex[n3 + n29]; - if (n3 > 0 && stbTrueTypeVertexArray != null) { - System.arraycopy(stbTrueTypeVertexArray, 0, stbTrueTypeVertexArray3, 0, n3); - } - System.arraycopy(stbTrueTypeVertexArray2, 0, stbTrueTypeVertexArray3, n3, n29); - stbTrueTypeVertexArray = stbTrueTypeVertexArray3; - n3 += n29; - } - n2 = n30 & 0x20; - } - } - if (stbTrueTypeVertexArray != null && n3 < stbTrueTypeVertexArray.length) { - StbTrueTypeVertex[] stbTrueTypeVertexArray4 = new StbTrueTypeVertex[n3]; - System.arraycopy(stbTrueTypeVertexArray, 0, stbTrueTypeVertexArray4, 0, n3); - return stbTrueTypeVertexArray4; - } - return stbTrueTypeVertexArray; - } - - public static void w(StbTrueTypePackContext stbTrueTypePackContext, int n) { - stbTrueTypePackContext.h = n; - } - - public static void S(StbTrueTypePackContext stbTrueTypePackContext) { - } - - static int x(byte[] byArray, int n) { - return (byArray[n] & 0xFF) * 256 + (byArray[n + 1] & 0xFF); - } - - static boolean d(float[] fArray, float[] fArray2) { - return fArray[0] == fArray2[0] && fArray[1] == fArray2[1]; - } - - static StbByteBufferView B(StbByteBufferView frame) { - int n = frame.h; - int n2 = SmoothFontRasterState.p(frame); - if (n2 != 0) { - int n3 = SmoothFontRasterState.Q(frame); - if (!(G || n3 >= 1 && n3 <= 4)) { - throw new AssertionError(); - } - SmoothFontRasterState.K(frame, n3 * n2); - SmoothFontRasterState.K(frame, (int)SmoothFontRasterState.u(frame, n3) - 1); - } - return SmoothFontRasterState.E(frame, n, frame.h - n); - } - - public static byte[] Y(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f, float f2, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - return SmoothFontRasterState.q(stbTrueTypeFontInfo, f, f2, 0.0f, 0.0f, n, nArray, nArray2, nArray3, nArray4); - } - - static void c(float[] fArray, int n, float[] fArray2, int n2, int n3, StbTrueTypeActiveEdge stbTrueTypeActiveEdge, float f) { - float f2 = f + 1.0f; - while (stbTrueTypeActiveEdge != null) { - float f3; - if (!G && !(stbTrueTypeActiveEdge.m >= f)) { - throw new AssertionError(); - } - if (stbTrueTypeActiveEdge.L == 0.0f) { - f3 = stbTrueTypeActiveEdge.e; - if (f3 < (float)n3) { - if (f3 >= 0.0f) { - SmoothFontRasterState.A(fArray, n, (int)f3, stbTrueTypeActiveEdge, f3, f, f3, f2); - SmoothFontRasterState.A(fArray2, n2, (int)f3 + 1, stbTrueTypeActiveEdge, f3, f, f3, f2); - } else { - SmoothFontRasterState.A(fArray2, n2, 0, stbTrueTypeActiveEdge, f3, f, f3, f2); - } - } - } else { - float f4; - float f5; - float f6; - float f7; - float f8; - float f9; - float f10; - float f11; - float f12; - f3 = stbTrueTypeActiveEdge.e; - float f13 = stbTrueTypeActiveEdge.L; - float f14 = f3 + f13; - float f15 = stbTrueTypeActiveEdge.N; - if (!(G || stbTrueTypeActiveEdge.j <= f2 && stbTrueTypeActiveEdge.m >= f)) { - throw new AssertionError(); - } - if (stbTrueTypeActiveEdge.j > f) { - f12 = f3 + f13 * (stbTrueTypeActiveEdge.j - f); - f11 = stbTrueTypeActiveEdge.j; - } else { - f12 = f3; - f11 = f; - } - if (stbTrueTypeActiveEdge.m < f2) { - f10 = f3 + f13 * (stbTrueTypeActiveEdge.m - f); - f9 = stbTrueTypeActiveEdge.m; - } else { - f10 = f14; - f9 = f2; - } - if (f12 >= 0.0f && f10 >= 0.0f && f12 < (float)n3 && f10 < (float)n3) { - int n4; - if ((int)f12 == (int)f10) { - n4 = (int)f12; - float f16 = (f9 - f11) * stbTrueTypeActiveEdge.T; - int n5 = n + n4; - fArray[n5] = fArray[n5] + SmoothFontRasterState.E(f16, f12, (float)n4 + 1.0f, f10, (float)n4 + 1.0f); - int n6 = n2 + n4 + 1; - fArray2[n6] = fArray2[n6] + f16; - } else { - if (f12 > f10) { - f11 = f2 - (f11 - f); - f9 = f2 - (f9 - f); - float f17 = f11; - f11 = f9; - f9 = f17; - f17 = f10; - f10 = f12; - f12 = f17; - f13 = -f13; - f15 = -f15; - f17 = f3; - f3 = f14; - f14 = f17; - } - n4 = (int)f12; - int n7 = (int)f10; - f8 = f + f15 * ((float)(n4 + 1) - f3); - f7 = f + f15 * ((float)n7 - f3); - if (f8 > f2) { - f8 = f2; - } - f6 = stbTrueTypeActiveEdge.T; - f5 = f6 * (f8 - f11); - int n8 = n + n4; - fArray[n8] = fArray[n8] + SmoothFontRasterState.S(f5, (float)(n4 + 1) - f12); - if (f7 > f2) { - f7 = f2; - f15 = (f7 - f8) / (float)(n7 - (n4 + 1)); - } - f4 = f6 * f15 * 1.0f; - for (int i = n4 + 1; i < n7; ++i) { - int n9 = n + i; - fArray[n9] = fArray[n9] + (f5 + f4 / 2.0f); - f5 += f4; - } - int n10 = n + n7; - fArray[n10] = fArray[n10] + (f5 + f6 * SmoothFontRasterState.E(f9 - f7, n7, (float)n7 + 1.0f, f10, (float)n7 + 1.0f)); - int n11 = n2 + n7 + 1; - fArray2[n11] = fArray2[n11] + f6 * (f9 - f11); - } - } else { - for (int i = 0; i < n3; ++i) { - float f18 = f; - float f19 = i; - f8 = i + 1; - f7 = f14; - f4 = f2; - f6 = ((float)i - f3) / f13 + f; - f5 = ((float)(i + 1) - f3) / f13 + f; - if (f3 < f19 && f7 > f8) { - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f19, f6); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f19, f6, f8, f5); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f8, f5, f7, f4); - continue; - } - if (f7 < f19 && f3 > f8) { - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f8, f5); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f8, f5, f19, f6); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f19, f6, f7, f4); - continue; - } - if (f3 < f19 && f7 > f19) { - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f19, f6); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f19, f6, f7, f4); - continue; - } - if (f7 < f19 && f3 > f19) { - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f19, f6); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f19, f6, f7, f4); - continue; - } - if (f3 < f8 && f7 > f8) { - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f8, f5); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f8, f5, f7, f4); - continue; - } - if (f7 < f8 && f3 > f8) { - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f8, f5); - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f8, f5, f7, f4); - continue; - } - SmoothFontRasterState.A(fArray, n, i, stbTrueTypeActiveEdge, f3, f18, f7, f4); - } - } - } - stbTrueTypeActiveEdge = stbTrueTypeActiveEdge.l; - } - } - - static StbTrueTypeActiveEdge O(StbTrueTypeEdge stbTrueTypeEdge, int n, float f) { - float f2; - StbTrueTypeActiveEdge stbTrueTypeActiveEdge = new StbTrueTypeActiveEdge(); - stbTrueTypeActiveEdge.L = f2 = (stbTrueTypeEdge.i - stbTrueTypeEdge.d) / (stbTrueTypeEdge.u - stbTrueTypeEdge.X); - stbTrueTypeActiveEdge.N = f2 != 0.0f ? 1.0f / f2 : 0.0f; - stbTrueTypeActiveEdge.e = stbTrueTypeEdge.d + f2 * (f - stbTrueTypeEdge.X); - stbTrueTypeActiveEdge.e -= (float)n; - stbTrueTypeActiveEdge.T = stbTrueTypeEdge.W != 0 ? 1.0f : -1.0f; - stbTrueTypeActiveEdge.j = stbTrueTypeEdge.X; - stbTrueTypeActiveEdge.m = stbTrueTypeEdge.u; - stbTrueTypeActiveEdge.l = null; - return stbTrueTypeActiveEdge; - } - - public static int c(StbTrueTypePackContext stbTrueTypePackContext, byte[] byArray, int n, StbTrueTypePackRange[] stbTrueTypePackRangeArray, int n2) { - int n3; - StbTrueTypeFontInfo stbTrueTypeFontInfo = new StbTrueTypeFontInfo(); - int n4 = 1; - for (n3 = 0; n3 < n2; ++n3) { - for (int i = 0; i < stbTrueTypePackRangeArray[n3].b; ++i) { - stbTrueTypePackRangeArray[n3].M[i].p = 0; - stbTrueTypePackRangeArray[n3].M[i].q = 0; - stbTrueTypePackRangeArray[n3].M[i].k = 0; - stbTrueTypePackRangeArray[n3].M[i].b = 0; - } - } - int n5 = 0; - for (n3 = 0; n3 < n2; ++n3) { - n5 += stbTrueTypePackRangeArray[n3].b; - } - StbTrueTypePackRectangle[] stbTrueTypePackRectangleArray = new StbTrueTypePackRectangle[n5]; - for (n3 = 0; n3 < n5; ++n3) { - stbTrueTypePackRectangleArray[n3] = new StbTrueTypePackRectangle(); - } - SmoothFontRasterState.z(stbTrueTypeFontInfo, byArray, SmoothFontRasterState.c(byArray, n)); - n5 = SmoothFontRasterState.G(stbTrueTypePackContext, stbTrueTypeFontInfo, stbTrueTypePackRangeArray, n2, stbTrueTypePackRectangleArray); - SmoothFontRasterState.H(stbTrueTypePackContext, stbTrueTypePackRectangleArray, n5); - n4 = SmoothFontRasterState.E(stbTrueTypePackContext, stbTrueTypeFontInfo, stbTrueTypePackRangeArray, n2, stbTrueTypePackRectangleArray); - return n4; - } - - static int p(StbByteBufferView frame) { - return (int)SmoothFontRasterState.u(frame, 2); - } - - static short E$src$S$1b9gd7y(byte[] byArray, int n) { - return (short)((byArray[n] & 0xFF) * 256 + (byArray[n + 1] & 0xFF)); - } - - public static void N(byte[] byArray, int n, float f, float[] fArray, float[] fArray2, float[] fArray3) { - int[] nArray = new int[1]; - int[] nArray2 = new int[1]; - int[] nArray3 = new int[1]; - StbTrueTypeFontInfo stbTrueTypeFontInfo = new StbTrueTypeFontInfo(); - SmoothFontRasterState.z(stbTrueTypeFontInfo, byArray, SmoothFontRasterState.c(byArray, n)); - float f2 = f > 0.0f ? SmoothFontRasterState.V(stbTrueTypeFontInfo, f) : SmoothFontRasterState.b(stbTrueTypeFontInfo, -f); - SmoothFontRasterState.x(stbTrueTypeFontInfo, nArray, nArray2, nArray3); - fArray[0] = (float)nArray[0] * f2; - fArray2[0] = (float)nArray2[0] * f2; - fArray3[0] = (float)nArray3[0] * f2; - } - - public static StbTrueTypeVertex[] t(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - return SmoothFontRasterState.m(stbTrueTypeFontInfo, SmoothFontRasterState.T(stbTrueTypeFontInfo, n)); - } - - static long c$src$J$1nktx4p(byte[] byArray, int n) { - return ((long)(byArray[n] & 0xFF) << 24) + ((long)(byArray[n + 1] & 0xFF) << 16) + ((long)(byArray[n + 2] & 0xFF) << 8) + (long)(byArray[n + 3] & 0xFF); - } - - static int q(byte[] byArray, int n, int n2) { - int n3 = SmoothFontRasterState.x(byArray, n); - switch (n3) { - case 1: { - int n4 = SmoothFontRasterState.x(byArray, n + 2); - int n5 = SmoothFontRasterState.x(byArray, n + 4); - int n6 = n + 6; - if (n2 < n4 || n2 >= n4 + n5) break; - return SmoothFontRasterState.x(byArray, n6 + 2 * (n2 - n4)); - } - case 2: { - int n7 = SmoothFontRasterState.x(byArray, n + 2); - int n8 = n + 4; - int n9 = 0; - int n10 = n7 - 1; - int n11 = n2; - while (n9 <= n10) { - int n12 = n9 + n10 >> 1; - int n13 = n8 + 6 * n12; - int n14 = SmoothFontRasterState.x(byArray, n13); - int n15 = SmoothFontRasterState.x(byArray, n13 + 2); - if (n11 < n14) { - n10 = n12 - 1; - continue; - } - if (n11 > n15) { - n9 = n12 + 1; - continue; - } - return SmoothFontRasterState.x(byArray, n13 + 4); - } - break; - } - default: { - return -1; - } - } - return 0; - } - - static void M(StbByteBufferView frame) { - int n = SmoothFontRasterState.K(frame); - if (!G && n < 28) { - throw new AssertionError(); - } - if (n == 30) { - int n2; - SmoothFontRasterState.K(frame, 1); - while (frame.h < frame.y && ((n2 = SmoothFontRasterState.Q(frame)) & 0xF) != 15 && n2 >> 4 != 15) { - } - } else { - SmoothFontRasterState.v(frame); - } - } - - public static int J(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int n2) { - if (stbTrueTypeFontInfo.L == 0 && stbTrueTypeFontInfo.G == 0) { - return 0; - } - return SmoothFontRasterState.d(stbTrueTypeFontInfo, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), SmoothFontRasterState.T(stbTrueTypeFontInfo, n2)); - } - - static StbTrueTypeVertex[] a$src$ALgg_vape_ui_font_stb_StbTrueTypeVertex_$1sz52d4(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - StbTrueTypeCharStringContext stbTrueTypeCharStringContext = new StbTrueTypeCharStringContext(1); - StbTrueTypeCharStringContext stbTrueTypeCharStringContext2 = new StbTrueTypeCharStringContext(0); - if (SmoothFontRasterState.V(stbTrueTypeFontInfo, n, stbTrueTypeCharStringContext) != 0) { - StbTrueTypeVertex[] stbTrueTypeVertexArray = new StbTrueTypeVertex[stbTrueTypeCharStringContext.q]; - for (int i = 0; i < stbTrueTypeVertexArray.length; ++i) { - stbTrueTypeVertexArray[i] = new StbTrueTypeVertex(); - } - stbTrueTypeCharStringContext2.V = stbTrueTypeVertexArray; - if (SmoothFontRasterState.V(stbTrueTypeFontInfo, n, stbTrueTypeCharStringContext2) != 0) { - if (!G && stbTrueTypeCharStringContext2.q != stbTrueTypeCharStringContext.q) { - throw new AssertionError(); - } - return stbTrueTypeVertexArray; - } - } - return null; - } - - static int J(StbTrueTypeFontInfo stbTrueTypeFontInfo) { - if (stbTrueTypeFontInfo.Q < 0) { - long l = SmoothFontRasterState.v(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.U, "SVG "); - if (l != 0L) { - long l2 = SmoothFontRasterState.c$src$J$1nktx4p(stbTrueTypeFontInfo.S, (int)(l + 2L)); - stbTrueTypeFontInfo.Q = (int)(l + l2); - } else { - stbTrueTypeFontInfo.Q = 0; - } - } - return stbTrueTypeFontInfo.Q; - } - - static void b(StbTrueTypeBitmap stbTrueTypeBitmap, StbTrueTypeEdge[] stbTrueTypeEdgeArray, int n, int n2, int n3, int n4) { - StbTrueTypeActiveEdge stbTrueTypeActiveEdge = null; - float[] fArray = new float[129]; - float[] fArray2 = stbTrueTypeBitmap.K > 64 ? new float[stbTrueTypeBitmap.K * 2 + 1] : fArray; - int n5 = 0; - int n6 = stbTrueTypeBitmap.K; - int n7 = n4; - stbTrueTypeEdgeArray[n].X = (float)(n4 + stbTrueTypeBitmap.c) + 1.0f; - int n8 = 0; - for (int i = 0; i < stbTrueTypeBitmap.c; ++i) { - float f = (float)n7 + 0.0f; - float f2 = (float)n7 + 1.0f; - Arrays.fill(fArray2, n5, n5 + stbTrueTypeBitmap.K, 0.0f); - Arrays.fill(fArray2, n6, n6 + stbTrueTypeBitmap.K + 1, 0.0f); - StbTrueTypeActiveEdge stbTrueTypeActiveEdge2 = null; - StbTrueTypeActiveEdge stbTrueTypeActiveEdge3 = stbTrueTypeActiveEdge; - while (stbTrueTypeActiveEdge3 != null) { - if (stbTrueTypeActiveEdge3.m <= f) { - if (stbTrueTypeActiveEdge2 != null) { - stbTrueTypeActiveEdge2.l = stbTrueTypeActiveEdge3.l; - } else { - stbTrueTypeActiveEdge = stbTrueTypeActiveEdge3.l; - } - stbTrueTypeActiveEdge3 = stbTrueTypeActiveEdge2 != null ? stbTrueTypeActiveEdge2.l : stbTrueTypeActiveEdge; - continue; - } - stbTrueTypeActiveEdge2 = stbTrueTypeActiveEdge3; - stbTrueTypeActiveEdge3 = stbTrueTypeActiveEdge3.l; - } - while (n8 < n && stbTrueTypeEdgeArray[n8].X <= f2) { - if (stbTrueTypeEdgeArray[n8].X != stbTrueTypeEdgeArray[n8].u) { - StbTrueTypeActiveEdge stbTrueTypeActiveEdge4 = SmoothFontRasterState.O(stbTrueTypeEdgeArray[n8], n3, f); - if (i == 0 && n4 != 0 && stbTrueTypeActiveEdge4.m < f) { - stbTrueTypeActiveEdge4.m = f; - } - stbTrueTypeActiveEdge4.l = stbTrueTypeActiveEdge; - stbTrueTypeActiveEdge = stbTrueTypeActiveEdge4; - } - ++n8; - } - if (stbTrueTypeActiveEdge != null) { - SmoothFontRasterState.c(fArray2, n5, fArray2, n6, stbTrueTypeBitmap.K, stbTrueTypeActiveEdge, f); - } - float f3 = 0.0f; - for (int j = 0; j < stbTrueTypeBitmap.K; ++j) { - float f4 = fArray2[n5 + j] + (f3 += fArray2[n6 + j]); - int n9 = (int)(f4 = Math.abs(f4) * 255.0f + 0.5f); - if (n9 > 255) { - n9 = 255; - } - stbTrueTypeBitmap.E[stbTrueTypeBitmap.h + i * stbTrueTypeBitmap.A + j] = (byte)n9; - } - stbTrueTypeActiveEdge3 = stbTrueTypeActiveEdge; - while (stbTrueTypeActiveEdge3 != null) { - stbTrueTypeActiveEdge3.e += stbTrueTypeActiveEdge3.L; - stbTrueTypeActiveEdge3 = stbTrueTypeActiveEdge3.l; - } - ++n7; - } - } - - public static void K(StbTrueTypePackedChar[] stbTrueTypePackedCharArray, int n, int n2, int n3, float[] fArray, float[] fArray2, StbTrueTypeAlignedQuad stbTrueTypeAlignedQuad, int n4) { - float f = 1.0f / (float)n; - float f2 = 1.0f / (float)n2; - StbTrueTypePackedChar stbTrueTypePackedChar = stbTrueTypePackedCharArray[n3]; - if (n4 != 0) { - float f3 = (int)Math.floor(fArray[0] + stbTrueTypePackedChar.s + 0.5f); - float f4 = (int)Math.floor(fArray2[0] + stbTrueTypePackedChar.G + 0.5f); - stbTrueTypeAlignedQuad.v = f3; - stbTrueTypeAlignedQuad.x = f4; - stbTrueTypeAlignedQuad.K = f3 + stbTrueTypePackedChar.t - stbTrueTypePackedChar.s; - stbTrueTypeAlignedQuad.M = f4 + stbTrueTypePackedChar.R - stbTrueTypePackedChar.G; - } else { - stbTrueTypeAlignedQuad.v = fArray[0] + stbTrueTypePackedChar.s; - stbTrueTypeAlignedQuad.x = fArray2[0] + stbTrueTypePackedChar.G; - stbTrueTypeAlignedQuad.K = fArray[0] + stbTrueTypePackedChar.t; - stbTrueTypeAlignedQuad.M = fArray2[0] + stbTrueTypePackedChar.R; - } - stbTrueTypeAlignedQuad.G = (float)stbTrueTypePackedChar.b * f; - stbTrueTypeAlignedQuad.O = (float)stbTrueTypePackedChar.k * f2; - stbTrueTypeAlignedQuad.S = (float)stbTrueTypePackedChar.q * f; - stbTrueTypeAlignedQuad.C = (float)stbTrueTypePackedChar.p * f2; - fArray[0] = fArray[0] + stbTrueTypePackedChar.A; - } - - static int K(StbByteBufferView frame) { - if (frame.h >= frame.y) { - return 0; - } - return frame.f[frame.C + frame.h] & 0xFF; - } - - static StbByteBufferView W(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - StbByteBufferView frame = stbTrueTypeFontInfo.N.k(); - int n2 = -1; - SmoothFontRasterState.i(frame, 0); - int n3 = SmoothFontRasterState.Q(frame); - if (n3 == 0) { - SmoothFontRasterState.K(frame, n); - n2 = SmoothFontRasterState.Q(frame); - } else if (n3 == 3) { - int n4 = SmoothFontRasterState.p(frame); - int n5 = SmoothFontRasterState.p(frame); - for (int i = 0; i < n4; ++i) { - int n6 = SmoothFontRasterState.Q(frame); - int n7 = SmoothFontRasterState.p(frame); - if (n >= n5 && n < n7) { - n2 = n6; - break; - } - n5 = n7; - } - } - if (n2 == -1) { - return SmoothFontRasterState.x(null, 0, 0); - } - return SmoothFontRasterState.u(stbTrueTypeFontInfo.g, SmoothFontRasterState.e(stbTrueTypeFontInfo.H, n2)); - } - - public static int E(StbTrueTypePackContext stbTrueTypePackContext, StbTrueTypeFontInfo stbTrueTypeFontInfo, StbTrueTypePackRange[] stbTrueTypePackRangeArray, int n, StbTrueTypePackRectangle[] stbTrueTypePackRectangleArray) { - int n2 = -1; - int n3 = 1; - int n4 = stbTrueTypePackContext.c; - int n5 = stbTrueTypePackContext.m; - int n6 = 0; - for (int i = 0; i < n; ++i) { - float f = stbTrueTypePackRangeArray[i].E; - float f2 = f > 0.0f ? SmoothFontRasterState.V(stbTrueTypeFontInfo, f) : SmoothFontRasterState.b(stbTrueTypeFontInfo, -f); - stbTrueTypePackContext.c = stbTrueTypePackRangeArray[i].i; - stbTrueTypePackContext.m = stbTrueTypePackRangeArray[i].y; - float f3 = 1.0f / (float)stbTrueTypePackContext.c; - float f4 = 1.0f / (float)stbTrueTypePackContext.m; - float f5 = SmoothFontRasterState.U(stbTrueTypePackContext.c); - float f6 = SmoothFontRasterState.U(stbTrueTypePackContext.m); - for (int j = 0; j < stbTrueTypePackRangeArray[i].b; ++j) { - StbTrueTypePackRectangle stbTrueTypePackRectangle = stbTrueTypePackRectangleArray[n6]; - if (stbTrueTypePackRectangle.M != 0 && stbTrueTypePackRectangle.N != 0 && stbTrueTypePackRectangle.e != 0) { - StbTrueTypePackedChar stbTrueTypePackedChar = stbTrueTypePackRangeArray[i].M[j]; - int[] nArray = new int[1]; - int[] nArray2 = new int[1]; - int[] nArray3 = new int[1]; - int[] nArray4 = new int[1]; - int[] nArray5 = new int[1]; - int[] nArray6 = new int[1]; - int n7 = stbTrueTypePackRangeArray[i].N == null ? stbTrueTypePackRangeArray[i].R + j : stbTrueTypePackRangeArray[i].N[j]; - int n8 = SmoothFontRasterState.T(stbTrueTypeFontInfo, n7); - int n9 = stbTrueTypePackContext.G; - stbTrueTypePackRectangle.P += n9; - stbTrueTypePackRectangle.J += n9; - stbTrueTypePackRectangle.N -= n9; - stbTrueTypePackRectangle.e -= n9; - SmoothFontRasterState.q(stbTrueTypeFontInfo, n8, nArray, nArray2); - SmoothFontRasterState.Z(stbTrueTypeFontInfo, n8, f2 * (float)stbTrueTypePackContext.c, f2 * (float)stbTrueTypePackContext.m, nArray3, nArray4, nArray5, nArray6); - SmoothFontRasterState.j(stbTrueTypeFontInfo, stbTrueTypePackContext.X, stbTrueTypePackRectangle.P + stbTrueTypePackRectangle.J * stbTrueTypePackContext.b, stbTrueTypePackRectangle.N - stbTrueTypePackContext.c + 1, stbTrueTypePackRectangle.e - stbTrueTypePackContext.m + 1, stbTrueTypePackContext.b, f2 * (float)stbTrueTypePackContext.c, f2 * (float)stbTrueTypePackContext.m, 0.0f, 0.0f, n8); - if (stbTrueTypePackContext.c > 1) { - SmoothFontRasterState.H(stbTrueTypePackContext.X, stbTrueTypePackRectangle.P + stbTrueTypePackRectangle.J * stbTrueTypePackContext.b, stbTrueTypePackRectangle.N, stbTrueTypePackRectangle.e, stbTrueTypePackContext.b, stbTrueTypePackContext.c); - } - if (stbTrueTypePackContext.m > 1) { - SmoothFontRasterState.p(stbTrueTypePackContext.X, stbTrueTypePackRectangle.P + stbTrueTypePackRectangle.J * stbTrueTypePackContext.b, stbTrueTypePackRectangle.N, stbTrueTypePackRectangle.e, stbTrueTypePackContext.b, stbTrueTypePackContext.m); - } - stbTrueTypePackedChar.b = (short)stbTrueTypePackRectangle.P; - stbTrueTypePackedChar.k = (short)stbTrueTypePackRectangle.J; - stbTrueTypePackedChar.q = (short)(stbTrueTypePackRectangle.P + stbTrueTypePackRectangle.N); - stbTrueTypePackedChar.p = (short)(stbTrueTypePackRectangle.J + stbTrueTypePackRectangle.e); - stbTrueTypePackedChar.A = f2 * (float)nArray[0]; - stbTrueTypePackedChar.s = (float)nArray3[0] * f3 + f5; - stbTrueTypePackedChar.G = (float)nArray4[0] * f4 + f6; - stbTrueTypePackedChar.t = (float)(nArray3[0] + stbTrueTypePackRectangle.N) * f3 + f5; - stbTrueTypePackedChar.R = (float)(nArray4[0] + stbTrueTypePackRectangle.e) * f4 + f6; - if (n8 == 0) { - n2 = j; - } - } else if (stbTrueTypePackContext.h != 0) { - n3 = 0; - } else if (stbTrueTypePackRectangle.M != 0 && stbTrueTypePackRectangle.N == 0 && stbTrueTypePackRectangle.e == 0 && n2 >= 0) { - stbTrueTypePackRangeArray[i].M[j] = stbTrueTypePackRangeArray[i].M[n2]; - } else { - n3 = 0; - } - ++n6; - } - } - stbTrueTypePackContext.c = n4; - stbTrueTypePackContext.m = n5; - return n3; - } - - static boolean d(byte[] byArray, int n, int n2, int n3, int n4, int n5) { - return (byArray[n] & 0xFF) == n2 && (byArray[n + 1] & 0xFF) == n3 && (byArray[n + 2] & 0xFF) == n4 && (byArray[n + 3] & 0xFF) == n5; - } - - static int s(byte[] byArray) { - if (SmoothFontRasterState.c$src$Z$1nktxih(byArray, 0)) { - return 1; - } - if (SmoothFontRasterState.f(byArray, 0, "ttcf") && (SmoothFontRasterState.c$src$J$1nktx4p(byArray, 4) == 65536L || SmoothFontRasterState.c$src$J$1nktx4p(byArray, 4) == 131072L)) { - return SmoothFontRasterState.B(byArray, 8); - } - return 0; - } - - static void A(StbTrueTypeCharStringContext stbTrueTypeCharStringContext, int n, int n2, int n3, int n4, int n5, int n6, int n7) { - if (stbTrueTypeCharStringContext.J != 0) { - SmoothFontRasterState.V(stbTrueTypeCharStringContext, n2, n3); - if (n == 4) { - SmoothFontRasterState.V(stbTrueTypeCharStringContext, n4, n5); - SmoothFontRasterState.V(stbTrueTypeCharStringContext, n6, n7); - } - } else { - SmoothFontRasterState.d(stbTrueTypeCharStringContext.V[stbTrueTypeCharStringContext.q], n, n2, n3, n4, n5); - stbTrueTypeCharStringContext.V[stbTrueTypeCharStringContext.q].a = (short)n6; - stbTrueTypeCharStringContext.V[stbTrueTypeCharStringContext.q].s = (short)n7; - } - ++stbTrueTypeCharStringContext.q; - } - - static int Q(StbByteBufferView frame) { - if (frame.h >= frame.y) { - return 0; - } - return frame.f[frame.C + frame.h++] & 0xFF; - } - - static int E(byte[] byArray, int n, byte[] byArray2, int n2, int n3, int n4, int n5) { - int n6 = SmoothFontRasterState.x(byArray, n + 2); - int n7 = n + SmoothFontRasterState.x(byArray, n + 4); - for (int i = 0; i < n6; ++i) { - int n8 = n + 6 + 12 * i; - int n9 = SmoothFontRasterState.x(byArray, n8 + 6); - if (n9 != n4) continue; - int n10 = SmoothFontRasterState.x(byArray, n8 + 0); - int n11 = SmoothFontRasterState.x(byArray, n8 + 2); - int n12 = SmoothFontRasterState.x(byArray, n8 + 4); - if (n10 != 0 && (n10 != 3 || n11 != 1) && (n10 != 3 || n11 != 10)) continue; - int n13 = SmoothFontRasterState.x(byArray, n8 + 8); - int n14 = SmoothFontRasterState.x(byArray, n8 + 10); - int n15 = SmoothFontRasterState.Y(byArray2, n2, n3, byArray, n7 + n14, n13); - if (n15 < 0) continue; - if (i + 1 < n6 && SmoothFontRasterState.x(byArray, n8 + 12 + 6) == n5 && SmoothFontRasterState.x(byArray, n8 + 12) == n10 && SmoothFontRasterState.x(byArray, n8 + 12 + 2) == n11 && SmoothFontRasterState.x(byArray, n8 + 12 + 4) == n12) { - n13 = SmoothFontRasterState.x(byArray, n8 + 12 + 8); - n14 = SmoothFontRasterState.x(byArray, n8 + 12 + 10); - if (!(n13 == 0 ? n15 == n3 : n15 < n3 && (byArray2[n2 + n15] & 0xFF) == 32 && SmoothFontRasterState.d(byArray2, n2 + ++n15, n3 - n15, byArray, n7 + n14, n13))) continue; - return 1; - } - if (n15 != n3) continue; - return 1; - } - return 0; - } - - static int Y(byte[] byArray, int n, int n2, byte[] byArray2, int n3, int n4) { - int n5 = 0; - while (n4 > 0) { - int n6 = (byArray2[n3] & 0xFF) * 256 + (byArray2[n3 + 1] & 0xFF); - if (n6 < 128) { - if (n5 >= n2) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != n6) { - return -1; - } - } else if (n6 < 2048) { - if (n5 + 1 >= n2) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 192 + (n6 >> 6)) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 128 + (n6 & 0x3F)) { - return -1; - } - } else if (n6 >= 55296 && n6 < 56320) { - int n7 = (byArray2[n3 + 2] & 0xFF) * 256 + (byArray2[n3 + 3] & 0xFF); - if (n5 + 3 >= n2) { - return -1; - } - int n8 = (n6 - 55296 << 10) + (n7 - 56320) + 65536; - if ((byArray[n + n5++] & 0xFF) != 240 + (n8 >> 18)) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 128 + (n8 >> 12 & 0x3F)) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 128 + (n8 >> 6 & 0x3F)) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 128 + (n8 & 0x3F)) { - return -1; - } - n3 += 2; - n4 -= 2; - } else { - if (n6 >= 56320 && n6 < 57344) { - return -1; - } - if (n5 + 2 >= n2) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 224 + (n6 >> 12)) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 128 + (n6 >> 6 & 0x3F)) { - return -1; - } - if ((byArray[n + n5++] & 0xFF) != 128 + (n6 & 0x3F)) { - return -1; - } - } - n3 += 2; - n4 -= 2; - } - return n5; - } - - public static void j(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n, int n2, int n3, int n4, float f, float f2, float f3, float f4, int n5) { - int[] nArray = new int[1]; - int[] nArray2 = new int[1]; - StbTrueTypeVertex[] stbTrueTypeVertexArray = SmoothFontRasterState.m(stbTrueTypeFontInfo, n5); - int n6 = stbTrueTypeVertexArray != null ? stbTrueTypeVertexArray.length : 0; - StbTrueTypeBitmap stbTrueTypeBitmap = new StbTrueTypeBitmap(); - SmoothFontRasterState.G(stbTrueTypeFontInfo, n5, f, f2, f3, f4, nArray, nArray2, null, null); - stbTrueTypeBitmap.E = byArray; - stbTrueTypeBitmap.h = n; - stbTrueTypeBitmap.K = n2; - stbTrueTypeBitmap.c = n3; - stbTrueTypeBitmap.A = n4; - if (stbTrueTypeBitmap.K != 0 && stbTrueTypeBitmap.c != 0) { - SmoothFontRasterState.b(stbTrueTypeBitmap, 0.35f, stbTrueTypeVertexArray, n6, f, f2, f3, f4, nArray[0], nArray2[0], 1); - } - } - - public static float b(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f) { - int n = SmoothFontRasterState.x(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.c + 18); - return f / (float)n; - } - - public static byte[] q(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f, float f2, float f3, float f4, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - return SmoothFontRasterState.F(stbTrueTypeFontInfo, f, f2, f3, f4, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), nArray, nArray2, nArray3, nArray4); - } - - public static void Y(StbTrueTypeFontInfo stbTrueTypeFontInfo, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - nArray[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.c + 36); - nArray2[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.c + 38); - nArray3[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.c + 40); - nArray4[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.c + 42); - } - - static StbTrueTypePoint[] P(StbTrueTypeVertex[] stbTrueTypeVertexArray, int n, float f, int[][] nArray, int[] nArray2) { - int n2; - StbTrueTypePoint[] stbTrueTypePointArray = null; - int[] nArray3 = new int[]{0}; - float f2 = f * f; - int n3 = 0; - int n4 = 0; - for (n2 = 0; n2 < n; ++n2) { - if (stbTrueTypeVertexArray[n2].O != 1) continue; - ++n3; - } - nArray2[0] = n3; - if (n3 == 0) { - return null; - } - nArray[0] = new int[n3]; - for (int i = 0; i < 2; ++i) { - float f3 = 0.0f; - float f4 = 0.0f; - if (i == 1) { - stbTrueTypePointArray = new StbTrueTypePoint[nArray3[0]]; - for (n2 = 0; n2 < stbTrueTypePointArray.length; ++n2) { - stbTrueTypePointArray[n2] = new StbTrueTypePoint(); - } - } - nArray3[0] = 0; - n3 = -1; - block9: for (n2 = 0; n2 < n; ++n2) { - switch (stbTrueTypeVertexArray[n2].O) { - case 1: { - if (n3 >= 0) { - nArray[0][n3] = nArray3[0] - n4; - } - ++n3; - n4 = nArray3[0]; - f3 = stbTrueTypeVertexArray[n2].f; - f4 = stbTrueTypeVertexArray[n2].H; - int n5 = nArray3[0]; - nArray3[0] = n5 + 1; - SmoothFontRasterState.r(stbTrueTypePointArray, n5, f3, f4); - continue block9; - } - case 2: { - f3 = stbTrueTypeVertexArray[n2].f; - f4 = stbTrueTypeVertexArray[n2].H; - int n6 = nArray3[0]; - nArray3[0] = n6 + 1; - SmoothFontRasterState.r(stbTrueTypePointArray, n6, f3, f4); - continue block9; - } - case 3: { - SmoothFontRasterState.y(stbTrueTypePointArray, nArray3, f3, f4, stbTrueTypeVertexArray[n2].h, stbTrueTypeVertexArray[n2].D, stbTrueTypeVertexArray[n2].f, stbTrueTypeVertexArray[n2].H, f2, 0); - f3 = stbTrueTypeVertexArray[n2].f; - f4 = stbTrueTypeVertexArray[n2].H; - continue block9; - } - case 4: { - SmoothFontRasterState.w(stbTrueTypePointArray, nArray3, f3, f4, stbTrueTypeVertexArray[n2].h, stbTrueTypeVertexArray[n2].D, stbTrueTypeVertexArray[n2].a, stbTrueTypeVertexArray[n2].s, stbTrueTypeVertexArray[n2].f, stbTrueTypeVertexArray[n2].H, f2, 0); - f3 = stbTrueTypeVertexArray[n2].f; - f4 = stbTrueTypeVertexArray[n2].H; - } - } - } - nArray[0][n3] = nArray3[0] - n4; - } - return stbTrueTypePointArray; - } - - static int i(float f, float f2, int n, StbTrueTypeVertex[] stbTrueTypeVertexArray) { - float[] fArray = new float[2]; - float[] fArray2 = new float[]{1.0f, 0.0f}; - int n2 = 0; - float f3 = f2 % 1.0f; - if (f3 < 0.01f) { - f2 += 0.01f; - } else if (f3 > 0.99f) { - f2 -= 0.01f; - } - fArray[0] = f; - fArray[1] = f2; - for (int i = 0; i < n; ++i) { - short s; - short s2; - short s3; - short s4; - if (stbTrueTypeVertexArray[i].O == 2) { - float f4; - s4 = stbTrueTypeVertexArray[i - 1].f; - s3 = stbTrueTypeVertexArray[i - 1].H; - s2 = stbTrueTypeVertexArray[i].f; - s = stbTrueTypeVertexArray[i].H; - if (f2 > (float)Math.min(s3, s) && f2 < (float)Math.max(s3, s) && f > (float)Math.min(s4, s2) && (f4 = (f2 - (float)s3) / (float)(s - s3) * (float)(s2 - s4) + (float)s4) < f) { - n2 += s3 < s ? 1 : -1; - } - } - if (stbTrueTypeVertexArray[i].O != 3) continue; - s4 = stbTrueTypeVertexArray[i - 1].f; - s3 = stbTrueTypeVertexArray[i - 1].H; - s2 = stbTrueTypeVertexArray[i].h; - s = stbTrueTypeVertexArray[i].D; - short s5 = stbTrueTypeVertexArray[i].f; - short s6 = stbTrueTypeVertexArray[i].H; - int n3 = Math.min(s4, Math.min(s2, s5)); - int n4 = Math.min(s3, Math.min(s, s6)); - int n5 = Math.max(s3, Math.max(s, s6)); - if (!(f2 > (float)n4) || !(f2 < (float)n5) || !(f > (float)n3)) continue; - float[] fArray3 = new float[2]; - float[] fArray4 = new float[2]; - float[] fArray5 = new float[2]; - float[][] fArray6 = new float[2][2]; - fArray3[0] = s4; - fArray3[1] = s3; - fArray4[0] = s2; - fArray4[1] = s; - fArray5[0] = s5; - fArray5[1] = s6; - if (SmoothFontRasterState.d(fArray3, fArray4) || SmoothFontRasterState.d(fArray4, fArray5)) { - float f5; - s4 = stbTrueTypeVertexArray[i - 1].f; - s3 = stbTrueTypeVertexArray[i - 1].H; - s2 = stbTrueTypeVertexArray[i].f; - s = stbTrueTypeVertexArray[i].H; - if (!(f2 > (float)Math.min(s3, s)) || !(f2 < (float)Math.max(s3, s)) || !(f > (float)Math.min(s4, s2)) || !((f5 = (f2 - (float)s3) / (float)(s - s3) * (float)(s2 - s4) + (float)s4) < f)) continue; - n2 += s3 < s ? 1 : -1; - continue; - } - int n6 = SmoothFontRasterState.J(fArray, fArray2, fArray3, fArray4, fArray5, fArray6); - if (n6 >= 1 && fArray6[0][0] < 0.0f) { - n2 += fArray6[0][1] < 0.0f ? -1 : 1; - } - if (n6 < 2 || !(fArray6[1][0] < 0.0f)) continue; - n2 += fArray6[1][1] < 0.0f ? -1 : 1; - } - return n2; - } - - static boolean S(byte[] byArray, int n, byte[] byArray2, int n2, int n3, int n4) { - long l; - if (!SmoothFontRasterState.c$src$Z$1nktxih(byArray, n)) { - return false; - } - if (n4 != 0 && (SmoothFontRasterState.x(byArray, (int)(l = SmoothFontRasterState.v(byArray, n, "head")) + 44) & 7) != (n4 & 7)) { - return false; - } - l = SmoothFontRasterState.v(byArray, n, "name"); - if (l == 0L) { - return false; - } - if (n4 != 0) { - if (SmoothFontRasterState.E(byArray, (int)l, byArray2, n2, n3, 16, -1) != 0) { - return true; - } - if (SmoothFontRasterState.E(byArray, (int)l, byArray2, n2, n3, 1, -1) != 0) { - return true; - } - if (SmoothFontRasterState.E(byArray, (int)l, byArray2, n2, n3, 3, -1) != 0) { - return true; - } - } else { - if (SmoothFontRasterState.E(byArray, (int)l, byArray2, n2, n3, 16, 17) != 0) { - return true; - } - if (SmoothFontRasterState.E(byArray, (int)l, byArray2, n2, n3, 1, 2) != 0) { - return true; - } - if (SmoothFontRasterState.E(byArray, (int)l, byArray2, n2, n3, 3, -1) != 0) { - return true; - } - } - return false; - } - - static void A(float[] fArray, int n, int n2, StbTrueTypeActiveEdge stbTrueTypeActiveEdge, float f, float f2, float f3, float f4) { - if (f2 == f4) { - return; - } - if (!G && !(f2 < f4)) { - throw new AssertionError(); - } - if (!G && !(stbTrueTypeActiveEdge.j <= stbTrueTypeActiveEdge.m)) { - throw new AssertionError(); - } - if (f2 > stbTrueTypeActiveEdge.m) { - return; - } - if (f4 < stbTrueTypeActiveEdge.j) { - return; - } - if (f2 < stbTrueTypeActiveEdge.j) { - f += (f3 - f) * (stbTrueTypeActiveEdge.j - f2) / (f4 - f2); - f2 = stbTrueTypeActiveEdge.j; - } - if (f4 > stbTrueTypeActiveEdge.m) { - f3 += (f3 - f) * (stbTrueTypeActiveEdge.m - f4) / (f4 - f2); - f4 = stbTrueTypeActiveEdge.m; - } - if (f <= (float)n2 && f3 <= (float)n2) { - int n3 = n + n2; - fArray[n3] = fArray[n3] + stbTrueTypeActiveEdge.T * (f4 - f2); - } else if (!(f >= (float)(n2 + 1)) || !(f3 >= (float)(n2 + 1))) { - int n4 = n + n2; - fArray[n4] = fArray[n4] + stbTrueTypeActiveEdge.T * (f4 - f2) * (1.0f - (f - (float)n2 + (f3 - (float)n2)) / 2.0f); - } - } - - static int y(StbTrueTypePoint[] stbTrueTypePointArray, int[] nArray, float f, float f2, float f3, float f4, float f5, float f6, float f7, int n) { - float f8 = (f + 2.0f * f3 + f5) / 4.0f; - float f9 = (f2 + 2.0f * f4 + f6) / 4.0f; - float f10 = (f + f5) / 2.0f - f8; - float f11 = (f2 + f6) / 2.0f - f9; - if (n > 16) { - return 1; - } - if (f10 * f10 + f11 * f11 > f7) { - SmoothFontRasterState.y(stbTrueTypePointArray, nArray, f, f2, (f + f3) / 2.0f, (f2 + f4) / 2.0f, f8, f9, f7, n + 1); - SmoothFontRasterState.y(stbTrueTypePointArray, nArray, f8, f9, (f3 + f5) / 2.0f, (f4 + f6) / 2.0f, f5, f6, f7, n + 1); - } else { - SmoothFontRasterState.r(stbTrueTypePointArray, nArray[0], f5, f6); - nArray[0] = nArray[0] + 1; - } - return 1; - } - - public static void n(StbTrueTypePackContext stbTrueTypePackContext, int n, int n2) { - if (!G && n > 8) { - throw new AssertionError(); - } - if (!G && n2 > 8) { - throw new AssertionError(); - } - if (n <= 8) { - stbTrueTypePackContext.c = n; - } - if (n2 <= 8) { - stbTrueTypePackContext.m = n2; - } - } - - static int L(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n) { - long l; - stbTrueTypeFontInfo.S = byArray; - stbTrueTypeFontInfo.U = n; - stbTrueTypeFontInfo.g = SmoothFontRasterState.x(null, 0, 0); - long l2 = SmoothFontRasterState.v(byArray, n, "cmap"); - stbTrueTypeFontInfo.v = (int)SmoothFontRasterState.v(byArray, n, "loca"); - stbTrueTypeFontInfo.c = (int)SmoothFontRasterState.v(byArray, n, "head"); - stbTrueTypeFontInfo.p = (int)SmoothFontRasterState.v(byArray, n, "glyf"); - stbTrueTypeFontInfo.w = (int)SmoothFontRasterState.v(byArray, n, "hhea"); - stbTrueTypeFontInfo.d = (int)SmoothFontRasterState.v(byArray, n, "hmtx"); - stbTrueTypeFontInfo.L = (int)SmoothFontRasterState.v(byArray, n, "kern"); - stbTrueTypeFontInfo.G = (int)SmoothFontRasterState.v(byArray, n, "GPOS"); - if (l2 == 0L || stbTrueTypeFontInfo.c == 0 || stbTrueTypeFontInfo.w == 0 || stbTrueTypeFontInfo.d == 0) { - return 0; - } - if (stbTrueTypeFontInfo.p != 0) { - if (stbTrueTypeFontInfo.v == 0) { - return 0; - } - } else { - long l3 = 2L; - long l4 = 0L; - long l5 = 0L; - long l6 = 0L; - long l7 = SmoothFontRasterState.v(byArray, n, "CFF "); - if (l7 == 0L) { - return 0; - } - stbTrueTypeFontInfo.H = SmoothFontRasterState.x(null, 0, 0); - stbTrueTypeFontInfo.N = SmoothFontRasterState.x(null, 0, 0); - stbTrueTypeFontInfo.g = SmoothFontRasterState.x(byArray, (int)l7, 0x20000000); - StbByteBufferView frame = stbTrueTypeFontInfo.g.k(); - SmoothFontRasterState.K(frame, 2); - SmoothFontRasterState.i(frame, SmoothFontRasterState.Q(frame)); - SmoothFontRasterState.B(frame); - StbByteBufferView frame2 = SmoothFontRasterState.B(frame); - StbByteBufferView frame3 = SmoothFontRasterState.e(frame2, 0); - SmoothFontRasterState.B(frame); - stbTrueTypeFontInfo.j = SmoothFontRasterState.B(frame); - long[] lArray = new long[]{l4}; - SmoothFontRasterState.X(frame3, 17, 1, lArray); - l4 = lArray[0]; - long[] lArray2 = new long[]{l3}; - SmoothFontRasterState.X(frame3, 262, 1, lArray2); - l3 = lArray2[0]; - long[] lArray3 = new long[]{l5}; - SmoothFontRasterState.X(frame3, 292, 1, lArray3); - l5 = lArray3[0]; - long[] lArray4 = new long[]{l6}; - SmoothFontRasterState.X(frame3, 293, 1, lArray4); - l6 = lArray4[0]; - stbTrueTypeFontInfo.J = SmoothFontRasterState.u(frame, frame3); - if (l3 != 2L) { - return 0; - } - if (l4 == 0L) { - return 0; - } - if (l5 != 0L) { - if (l6 == 0L) { - return 0; - } - SmoothFontRasterState.i(frame, (int)l5); - stbTrueTypeFontInfo.H = SmoothFontRasterState.B(frame); - stbTrueTypeFontInfo.N = SmoothFontRasterState.E(frame, (int)l6, frame.y - (int)l6); - } - SmoothFontRasterState.i(frame, (int)l4); - stbTrueTypeFontInfo.z = SmoothFontRasterState.B(frame); - } - stbTrueTypeFontInfo.h = (l = SmoothFontRasterState.v(byArray, n, "maxp")) != 0L ? SmoothFontRasterState.x(byArray, (int)(l + 4L)) : 65535; - stbTrueTypeFontInfo.Q = -1; - int n2 = SmoothFontRasterState.x(byArray, (int)(l2 + 2L)); - stbTrueTypeFontInfo.Y = 0; - block7: for (int i = 0; i < n2; ++i) { - long l8 = l2 + 4L + (long)(8 * i); - switch (SmoothFontRasterState.x(byArray, (int)l8)) { - case 3: { - switch (SmoothFontRasterState.x(byArray, (int)l8 + 2)) { - case 1: - case 10: { - stbTrueTypeFontInfo.Y = (int)(l2 + SmoothFontRasterState.c$src$J$1nktx4p(byArray, (int)l8 + 4)); - } - } - continue block7; - } - case 0: { - stbTrueTypeFontInfo.Y = (int)(l2 + SmoothFontRasterState.c$src$J$1nktx4p(byArray, (int)l8 + 4)); - } - } - } - if (stbTrueTypeFontInfo.Y == 0) { - return 0; - } - stbTrueTypeFontInfo.T = SmoothFontRasterState.x(byArray, stbTrueTypeFontInfo.c + 50); - return 1; - } - - public static int v(StbTrueTypeFontInfo stbTrueTypeFontInfo) { - byte[] byArray = stbTrueTypeFontInfo.S; - int n = stbTrueTypeFontInfo.L; - if (n == 0) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n + 2) < 1) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n + 8) != 1) { - return 0; - } - return SmoothFontRasterState.x(byArray, n + 10); - } - - public static int z(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n) { - return SmoothFontRasterState.L(stbTrueTypeFontInfo, byArray, n); - } - - static int E(byte[] byArray, int n) { - if (SmoothFontRasterState.c$src$Z$1nktxih(byArray, 0)) { - return n == 0 ? 0 : -1; - } - if (SmoothFontRasterState.f(byArray, 0, "ttcf") && (SmoothFontRasterState.c$src$J$1nktx4p(byArray, 4) == 65536L || SmoothFontRasterState.c$src$J$1nktx4p(byArray, 4) == 131072L)) { - int n2 = SmoothFontRasterState.B(byArray, 8); - if (n >= n2) { - return -1; - } - return (int)SmoothFontRasterState.c$src$J$1nktx4p(byArray, 12 + n * 4); - } - return -1; - } - - static void d(StbTrueTypeCharStringContext stbTrueTypeCharStringContext) { - if (stbTrueTypeCharStringContext.s != stbTrueTypeCharStringContext.C || stbTrueTypeCharStringContext.p != stbTrueTypeCharStringContext.o) { - SmoothFontRasterState.A(stbTrueTypeCharStringContext, 2, (int)stbTrueTypeCharStringContext.s, (int)stbTrueTypeCharStringContext.p, 0, 0, 0, 0); - } - } - - static void H(byte[] byArray, int n, int n2, int n3, int n4, int n5) { - byte[] byArray2 = new byte[8]; - int n6 = n2 - n5; - Arrays.fill(byArray2, (byte)0); - for (int i = 0; i < n3; ++i) { - int n7; - Arrays.fill(byArray2, 0, n5, (byte)0); - int n8 = 0; - switch (n5) { - case 2: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7]; - byArray[n + n7] = (byte)((n8 += (byArray[n + n7] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 2); - } - break; - } - case 3: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7]; - byArray[n + n7] = (byte)((n8 += (byArray[n + n7] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 3); - } - break; - } - case 4: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7]; - byArray[n + n7] = (byte)((n8 += (byArray[n + n7] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 4); - } - break; - } - case 5: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7]; - byArray[n + n7] = (byte)((n8 += (byArray[n + n7] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / 5); - } - break; - } - default: { - for (n7 = 0; n7 <= n6; ++n7) { - byArray2[n7 + n5 & 7] = byArray[n + n7]; - byArray[n + n7] = (byte)((n8 += (byArray[n + n7] & 0xFF) - (byArray2[n7 & 7] & 0xFF)) / n5); - } - } - } - while (n7 < n2) { - byArray[n + n7] = (byte)((n8 -= byArray2[n7 & 7] & 0xFF) / n5); - ++n7; - } - n += n4; - } - } - - public static StbTrueTypeVertex[] m(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - if (stbTrueTypeFontInfo.g.y == 0) { - return SmoothFontRasterState.o(stbTrueTypeFontInfo, n); - } - return SmoothFontRasterState.a$src$ALgg_vape_ui_font_stb_StbTrueTypeVertex_$1sz52d4(stbTrueTypeFontInfo, n); - } - - public static void u(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n, int n2, int n3, int n4, float f, float f2, float f3, float f4, int n5) { - SmoothFontRasterState.j(stbTrueTypeFontInfo, byArray, n, n2, n3, n4, f, f2, f3, f4, SmoothFontRasterState.T(stbTrueTypeFontInfo, n5)); - } - - public static void F(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n, int n2, int n3, int n4, float f, float f2, int n5) { - SmoothFontRasterState.u(stbTrueTypeFontInfo, byArray, n, n2, n3, n4, f, f2, 0.0f, 0.0f, n5); - } - - static int L(byte[] byArray, int n, int n2) { - int n3 = SmoothFontRasterState.x(byArray, n); - switch (n3) { - case 1: { - int n4 = SmoothFontRasterState.x(byArray, n + 2); - int n5 = 0; - int n6 = n4 - 1; - int n7 = n2; - while (n5 <= n6) { - int n8 = n + 4; - int n9 = n5 + n6 >> 1; - int n10 = SmoothFontRasterState.x(byArray, n8 + 2 * n9); - int n11 = n10; - if (n7 < n11) { - n6 = n9 - 1; - continue; - } - if (n7 > n11) { - n5 = n9 + 1; - continue; - } - return n9; - } - break; - } - case 2: { - int n12 = SmoothFontRasterState.x(byArray, n + 2); - int n13 = n + 4; - int n14 = 0; - int n15 = n12 - 1; - int n16 = n2; - while (n14 <= n15) { - int n17 = n14 + n15 >> 1; - int n18 = n13 + 6 * n17; - int n19 = SmoothFontRasterState.x(byArray, n18); - int n20 = SmoothFontRasterState.x(byArray, n18 + 2); - if (n16 < n19) { - n15 = n17 - 1; - continue; - } - if (n16 > n20) { - n14 = n17 + 1; - continue; - } - int n21 = SmoothFontRasterState.x(byArray, n18 + 4); - return n21 + n2 - n19; - } - break; - } - default: { - return -1; - } - } - return -1; - } - - public static int g(String string, String string2) { - byte[] byArray; - byte[] byArray2 = string.getBytes(); - return SmoothFontRasterState.d(byArray2, 0, byArray2.length, byArray = string2.getBytes(), 0, byArray.length) ? 1 : 0; - } - - static int X(float f, float f2, float f3, float[] fArray) { - float f4 = -f / 3.0f; - float f5 = f * (2.0f * f * f - 9.0f * f2) / 27.0f + f3; - float f6 = f2 - f * f / 3.0f; - float f7 = f6 * f6 * f6; - float f8 = f5 * f5 + 4.0f * f7 / 27.0f; - if (f8 >= 0.0f) { - float f9 = (float)Math.sqrt(f8); - float f10 = (-f5 + f9) / 2.0f; - float f11 = (-f5 - f9) / 2.0f; - f10 = SmoothFontRasterState.w(f10); - f11 = SmoothFontRasterState.w(f11); - fArray[0] = f4 + f10 + f11; - return 1; - } - float f12 = (float)Math.sqrt(-f6 / 3.0f); - float f13 = (float)Math.acos(-Math.sqrt(-27.0f / f7) * (double)f5 / 2.0) / 3.0f; - float f14 = (float)Math.cos(f13); - float f15 = (float)Math.cos((double)f13 - 1.570796) * 1.7320508f; - fArray[0] = f4 + f12 * 2.0f * f14; - fArray[1] = f4 - f12 * (f14 + f15); - fArray[2] = f4 - f12 * (f14 - f15); - return 3; - } - - static long u(StbByteBufferView frame, int n) { - long l = 0L; - if (!(G || n >= 1 && n <= 4)) { - throw new AssertionError(); - } - for (int i = 0; i < n; ++i) { - l = l << 8 | (long)SmoothFontRasterState.Q(frame); - } - return l; - } - - public static int U(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray) { - return SmoothFontRasterState.B(stbTrueTypeFontInfo, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), nArray); - } - - public static int A(StbTrueTypeFontInfo stbTrueTypeFontInfo, StbTrueTypeKerningEntry[] stbTrueTypeKerningEntryArray, int n) { - byte[] byArray = stbTrueTypeFontInfo.S; - int n2 = stbTrueTypeFontInfo.L; - if (n2 == 0) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n2 + 2) < 1) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n2 + 8) != 1) { - return 0; - } - int n3 = SmoothFontRasterState.x(byArray, n2 + 10); - if (n < n3) { - n3 = n; - } - for (int i = 0; i < n3; ++i) { - stbTrueTypeKerningEntryArray[i].q = SmoothFontRasterState.x(byArray, n2 + 18 + i * 6); - stbTrueTypeKerningEntryArray[i].o = SmoothFontRasterState.x(byArray, n2 + 20 + i * 6); - stbTrueTypeKerningEntryArray[i].y = SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n2 + 22 + i * 6); - } - return n3; - } - - public static int G(StbTrueTypePackContext stbTrueTypePackContext, StbTrueTypeFontInfo stbTrueTypeFontInfo, StbTrueTypePackRange[] stbTrueTypePackRangeArray, int n, StbTrueTypePackRectangle[] stbTrueTypePackRectangleArray) { - boolean bl = false; - int n2 = 0; - for (int i = 0; i < n; ++i) { - float f = stbTrueTypePackRangeArray[i].E; - float f2 = f > 0.0f ? SmoothFontRasterState.V(stbTrueTypeFontInfo, f) : SmoothFontRasterState.b(stbTrueTypeFontInfo, -f); - stbTrueTypePackRangeArray[i].i = stbTrueTypePackContext.c; - stbTrueTypePackRangeArray[i].y = stbTrueTypePackContext.m; - for (int j = 0; j < stbTrueTypePackRangeArray[i].b; ++j) { - int[] nArray = new int[1]; - int[] nArray2 = new int[1]; - int[] nArray3 = new int[1]; - int[] nArray4 = new int[1]; - int n3 = stbTrueTypePackRangeArray[i].N == null ? stbTrueTypePackRangeArray[i].R + j : stbTrueTypePackRangeArray[i].N[j]; - int n4 = SmoothFontRasterState.T(stbTrueTypeFontInfo, n3); - if (n4 == 0 && (stbTrueTypePackContext.h != 0 || bl)) { - stbTrueTypePackRectangleArray[n2].e = 0; - stbTrueTypePackRectangleArray[n2].N = 0; - } else { - SmoothFontRasterState.G(stbTrueTypeFontInfo, n4, f2 * (float)stbTrueTypePackContext.c, f2 * (float)stbTrueTypePackContext.m, 0.0f, 0.0f, nArray, nArray2, nArray3, nArray4); - stbTrueTypePackRectangleArray[n2].N = nArray3[0] - nArray[0] + stbTrueTypePackContext.G + stbTrueTypePackContext.c - 1; - stbTrueTypePackRectangleArray[n2].e = nArray4[0] - nArray2[0] + stbTrueTypePackContext.G + stbTrueTypePackContext.m - 1; - if (n4 == 0) { - bl = true; - } - } - ++n2; - } - } - return n2; - } - - static StbByteBufferView p(StbByteBufferView frame, int n) { - int n2 = SmoothFontRasterState.q(frame); - int n3 = 107; - if (n2 >= 33900) { - n3 = 32768; - } else if (n2 >= 1240) { - n3 = 1131; - } - if ((n += n3) < 0 || n >= n2) { - return SmoothFontRasterState.x(null, 0, 0); - } - return SmoothFontRasterState.e(frame, n); - } - - static float E(float f, float f2, float f3, float f4, float f5) { - return SmoothFontRasterState.A(f, f3 - f2, f5 - f4); - } - - static int V(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, StbTrueTypeCharStringContext stbTrueTypeCharStringContext) { - boolean bl = true; - int n2 = 0; - int n3 = 0; - int n4 = 0; - boolean bl2 = false; - float[] fArray = new float[48]; - StbByteBufferView[] frameArray = new StbByteBufferView[10]; - StbByteBufferView frame = stbTrueTypeFontInfo.J.k(); - StbByteBufferView frame2 = SmoothFontRasterState.e(stbTrueTypeFontInfo.z, n); - while (frame2.h < frame2.y) { - boolean bl3 = true; - int n5 = SmoothFontRasterState.Q(frame2); - block0 : switch (n5) { - case 19: - case 20: { - if (bl) { - n2 += n4 / 2; - } - bl = false; - SmoothFontRasterState.K(frame2, (n2 + 7) / 8); - break; - } - case 1: - case 3: - case 18: - case 23: { - n2 += n4 / 2; - break; - } - case 21: { - bl = false; - if (n4 < 2) { - return 0; - } - SmoothFontRasterState.Q(stbTrueTypeCharStringContext, fArray[n4 - 2], fArray[n4 - 1]); - break; - } - case 4: { - bl = false; - if (n4 < 1) { - return 0; - } - SmoothFontRasterState.Q(stbTrueTypeCharStringContext, 0.0f, fArray[n4 - 1]); - break; - } - case 22: { - bl = false; - if (n4 < 1) { - return 0; - } - SmoothFontRasterState.Q(stbTrueTypeCharStringContext, fArray[n4 - 1], 0.0f); - break; - } - case 5: { - int n6 = 0; - if (n4 < 2) { - return 0; - } - while (n6 + 1 < n4) { - SmoothFontRasterState.z(stbTrueTypeCharStringContext, fArray[n6], fArray[n6 + 1]); - n6 += 2; - } - break; - } - case 7: { - int n6 = 0; - if (n4 < 1) { - return 0; - } - for (n6 = 0; n6 < n4; ++n6) { - SmoothFontRasterState.z(stbTrueTypeCharStringContext, 0.0f, fArray[n6]); - if (++n6 >= n4) break block0; - SmoothFontRasterState.z(stbTrueTypeCharStringContext, fArray[n6], 0.0f); - } - break; - } - case 6: { - int n6 = 0; - if (n4 < 1) { - return 0; - } - while (n6 < n4) { - SmoothFontRasterState.z(stbTrueTypeCharStringContext, fArray[n6], 0.0f); - if (++n6 >= n4) break block0; - SmoothFontRasterState.z(stbTrueTypeCharStringContext, 0.0f, fArray[n6]); - ++n6; - } - break; - } - case 31: { - int n6 = 0; - if (n4 < 4) { - return 0; - } - while (n6 + 3 < n4) { - SmoothFontRasterState.s(stbTrueTypeCharStringContext, fArray[n6], 0.0f, fArray[n6 + 1], fArray[n6 + 2], n4 - n6 == 5 ? fArray[n6 + 4] : 0.0f, fArray[n6 + 3]); - if ((n6 += 4) + 3 >= n4) break block0; - SmoothFontRasterState.s(stbTrueTypeCharStringContext, 0.0f, fArray[n6], fArray[n6 + 1], fArray[n6 + 2], fArray[n6 + 3], n4 - n6 == 5 ? fArray[n6 + 4] : 0.0f); - n6 += 4; - } - break; - } - case 30: { - int n6 = 0; - if (n4 < 4) { - return 0; - } - while (n6 + 3 < n4) { - SmoothFontRasterState.s(stbTrueTypeCharStringContext, 0.0f, fArray[n6], fArray[n6 + 1], fArray[n6 + 2], fArray[n6 + 3], n4 - n6 == 5 ? fArray[n6 + 4] : 0.0f); - if ((n6 += 4) + 3 >= n4) break block0; - SmoothFontRasterState.s(stbTrueTypeCharStringContext, fArray[n6], 0.0f, fArray[n6 + 1], fArray[n6 + 2], n4 - n6 == 5 ? fArray[n6 + 4] : 0.0f, fArray[n6 + 3]); - n6 += 4; - } - break; - } - case 8: { - int n6 = 0; - if (n4 < 6) { - return 0; - } - while (n6 + 5 < n4) { - SmoothFontRasterState.s(stbTrueTypeCharStringContext, fArray[n6], fArray[n6 + 1], fArray[n6 + 2], fArray[n6 + 3], fArray[n6 + 4], fArray[n6 + 5]); - n6 += 6; - } - break; - } - case 24: { - int n6 = 0; - if (n4 < 8) { - return 0; - } - while (n6 + 5 < n4 - 2) { - SmoothFontRasterState.s(stbTrueTypeCharStringContext, fArray[n6], fArray[n6 + 1], fArray[n6 + 2], fArray[n6 + 3], fArray[n6 + 4], fArray[n6 + 5]); - n6 += 6; - } - if (n6 + 1 >= n4) { - return 0; - } - SmoothFontRasterState.z(stbTrueTypeCharStringContext, fArray[n6], fArray[n6 + 1]); - break; - } - case 25: { - int n6 = 0; - if (n4 < 8) { - return 0; - } - while (n6 + 1 < n4 - 6) { - SmoothFontRasterState.z(stbTrueTypeCharStringContext, fArray[n6], fArray[n6 + 1]); - n6 += 2; - } - if (n6 + 5 >= n4) { - return 0; - } - SmoothFontRasterState.s(stbTrueTypeCharStringContext, fArray[n6], fArray[n6 + 1], fArray[n6 + 2], fArray[n6 + 3], fArray[n6 + 4], fArray[n6 + 5]); - break; - } - case 26: - case 27: { - int n6 = 0; - if (n4 < 4) { - return 0; - } - float f = 0.0f; - if ((n4 & 1) != 0) { - f = fArray[n6]; - ++n6; - } - while (n6 + 3 < n4) { - if (n5 == 27) { - SmoothFontRasterState.s(stbTrueTypeCharStringContext, fArray[n6], f, fArray[n6 + 1], fArray[n6 + 2], fArray[n6 + 3], 0.0f); - } else { - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f, fArray[n6], fArray[n6 + 1], fArray[n6 + 2], 0.0f, fArray[n6 + 3]); - } - f = 0.0f; - n6 += 4; - } - break; - } - case 10: { - if (!bl2) { - if (stbTrueTypeFontInfo.N.y != 0) { - frame = SmoothFontRasterState.W(stbTrueTypeFontInfo, n); - } - bl2 = true; - } - } - case 29: { - if (n4 < 1) { - return 0; - } - int n7 = (int)fArray[--n4]; - if (n3 >= 10) { - return 0; - } - frameArray[n3++] = frame2.k(); - frame2 = SmoothFontRasterState.p(n5 == 10 ? frame : stbTrueTypeFontInfo.j, n7); - if (frame2.y == 0) { - return 0; - } - frame2.h = 0; - bl3 = false; - break; - } - case 11: { - if (n3 <= 0) { - return 0; - } - frame2 = frameArray[--n3]; - bl3 = false; - break; - } - case 14: { - SmoothFontRasterState.d(stbTrueTypeCharStringContext); - return 1; - } - case 12: { - int n8 = SmoothFontRasterState.Q(frame2); - switch (n8) { - case 34: { - if (n4 < 7) { - return 0; - } - float f = fArray[0]; - float f2 = fArray[1]; - float f3 = fArray[2]; - float f4 = fArray[3]; - float f5 = fArray[4]; - float f6 = fArray[5]; - float f7 = fArray[6]; - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f, 0.0f, f2, f3, f4, 0.0f); - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f5, 0.0f, f6, -f3, f7, 0.0f); - break block0; - } - case 35: { - if (n4 < 13) { - return 0; - } - float f = fArray[0]; - float f8 = fArray[1]; - float f2 = fArray[2]; - float f3 = fArray[3]; - float f4 = fArray[4]; - float f9 = fArray[5]; - float f5 = fArray[6]; - float f10 = fArray[7]; - float f6 = fArray[8]; - float f11 = fArray[9]; - float f7 = fArray[10]; - float f12 = fArray[11]; - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f, f8, f2, f3, f4, f9); - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f5, f10, f6, f11, f7, f12); - break block0; - } - case 36: { - if (n4 < 9) { - return 0; - } - float f = fArray[0]; - float f8 = fArray[1]; - float f2 = fArray[2]; - float f3 = fArray[3]; - float f4 = fArray[4]; - float f5 = fArray[5]; - float f6 = fArray[6]; - float f11 = fArray[7]; - float f7 = fArray[8]; - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f, f8, f2, f3, f4, 0.0f); - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f5, 0.0f, f6, f11, f7, -(f8 + f3 + f11)); - break block0; - } - case 37: { - float f12; - if (n4 < 11) { - return 0; - } - float f = fArray[0]; - float f8 = fArray[1]; - float f2 = fArray[2]; - float f3 = fArray[3]; - float f4 = fArray[4]; - float f9 = fArray[5]; - float f5 = fArray[6]; - float f10 = fArray[7]; - float f6 = fArray[8]; - float f11 = fArray[9]; - float f7 = f12 = fArray[10]; - float f13 = f + f2 + f4 + f5 + f6; - float f14 = f8 + f3 + f9 + f10 + f11; - if (Math.abs(f13) > Math.abs(f14)) { - f12 = -f14; - } else { - f7 = -f13; - } - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f, f8, f2, f3, f4, f9); - SmoothFontRasterState.s(stbTrueTypeCharStringContext, f5, f10, f6, f11, f7, f12); - break block0; - } - } - return 0; - } - default: { - float f; - if (n5 != 255 && n5 != 28 && n5 < 32) { - return 0; - } - if (n5 == 255) { - f = (float)((int)SmoothFontRasterState.g(frame2)) / 65536.0f; - } else { - SmoothFontRasterState.K(frame2, -1); - f = (short)SmoothFontRasterState.v(frame2); - } - if (n4 >= 48) { - return 0; - } - fArray[n4++] = f; - bl3 = false; - } - } - if (!bl3) continue; - n4 = 0; - } - return 0; - } - - public static void b(StbTrueTypeBitmap stbTrueTypeBitmap, float f, StbTrueTypeVertex[] stbTrueTypeVertexArray, int n, float f2, float f3, float f4, float f5, int n2, int n3, int n4) { - int[] nArray; - int[][] nArrayArray; - float f6 = f2 > f3 ? f3 : f2; - StbTrueTypePoint[] stbTrueTypePointArray = SmoothFontRasterState.P(stbTrueTypeVertexArray, n, f / f6, nArrayArray = new int[][]{null}, nArray = new int[]{0}); - if (stbTrueTypePointArray != null) { - SmoothFontRasterState.b(stbTrueTypeBitmap, stbTrueTypePointArray, nArrayArray[0], nArray[0], f2, f3, f4, f5, n2, n3, n4); - } - } - - static int h(byte[] byArray, byte[] byArray2, int n) { - int n2 = 0; - int n3; - while ((n3 = SmoothFontRasterState.c(byArray, n2)) >= 0) { - if (SmoothFontRasterState.S(byArray, n3, byArray2, 0, byArray2.length, n)) { - return n3; - } - ++n2; - } - return n3; - } - - public static int C(StbTrueTypePackContext stbTrueTypePackContext, byte[] byArray, int n, int n2, int n3, int n4) { - StbTrueTypePackAtlasState stbTrueTypePackAtlasState = new StbTrueTypePackAtlasState(); - int n5 = n - n4; - StbTrueTypeGlyphPackNode[] stbTrueTypeGlyphPackNodeArray = new StbTrueTypeGlyphPackNode[n5]; - for (int i = 0; i < n5; ++i) { - stbTrueTypeGlyphPackNodeArray[i] = new StbTrueTypeGlyphPackNode(); - } - stbTrueTypePackContext.w = n; - stbTrueTypePackContext.d = n2; - stbTrueTypePackContext.X = byArray; - stbTrueTypePackContext.J = stbTrueTypePackAtlasState; - stbTrueTypePackContext.j = stbTrueTypeGlyphPackNodeArray; - stbTrueTypePackContext.G = n4; - stbTrueTypePackContext.b = n3 != 0 ? n3 : n; - stbTrueTypePackContext.c = 1; - stbTrueTypePackContext.m = 1; - stbTrueTypePackContext.h = 0; - SmoothFontRasterState.b(stbTrueTypePackAtlasState, n - n4, n2 - n4, stbTrueTypeGlyphPackNodeArray, n5); - if (byArray != null) { - Arrays.fill(byArray, 0, n * n2, (byte)0); - } - return 1; - } - - static int N(byte[] byArray, int n) { - return byArray[n] & 0xFF; - } - - static void w(StbTrueTypePoint[] stbTrueTypePointArray, int[] nArray, float f, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, int n) { - float f10 = f3 - f; - float f11 = f4 - f2; - float f12 = f5 - f3; - float f13 = f6 - f4; - float f14 = f7 - f5; - float f15 = f8 - f6; - float f16 = f7 - f; - float f17 = f8 - f2; - float f18 = (float)(Math.sqrt(f10 * f10 + f11 * f11) + Math.sqrt(f12 * f12 + f13 * f13) + Math.sqrt(f14 * f14 + f15 * f15)); - float f19 = (float)Math.sqrt(f16 * f16 + f17 * f17); - float f20 = f18 * f18 - f19 * f19; - if (n > 16) { - return; - } - if (f20 > f9) { - float f21 = (f + f3) / 2.0f; - float f22 = (f2 + f4) / 2.0f; - float f23 = (f3 + f5) / 2.0f; - float f24 = (f4 + f6) / 2.0f; - float f25 = (f5 + f7) / 2.0f; - float f26 = (f6 + f8) / 2.0f; - float f27 = (f21 + f23) / 2.0f; - float f28 = (f22 + f24) / 2.0f; - float f29 = (f23 + f25) / 2.0f; - float f30 = (f24 + f26) / 2.0f; - float f31 = (f27 + f29) / 2.0f; - float f32 = (f28 + f30) / 2.0f; - SmoothFontRasterState.w(stbTrueTypePointArray, nArray, f, f2, f21, f22, f27, f28, f31, f32, f9, n + 1); - SmoothFontRasterState.w(stbTrueTypePointArray, nArray, f31, f32, f29, f30, f25, f26, f7, f8, f9, n + 1); - } else { - SmoothFontRasterState.r(stbTrueTypePointArray, nArray[0], f7, f8); - nArray[0] = nArray[0] + 1; - } - } - - static int J(float[] fArray, float[] fArray2, float[] fArray3, float[] fArray4, float[] fArray5, float[][] fArray6) { - float f; - float f2; - float f3; - float f4 = fArray3[1] * fArray2[0] - fArray3[0] * fArray2[1]; - float f5 = fArray4[1] * fArray2[0] - fArray4[0] * fArray2[1]; - float f6 = fArray5[1] * fArray2[0] - fArray5[0] * fArray2[1]; - float f7 = fArray[1] * fArray2[0] - fArray[0] * fArray2[1]; - float f8 = f4 - 2.0f * f5 + f6; - float f9 = f5 - f4; - float f10 = f4 - f7; - float f11 = 0.0f; - float f12 = 0.0f; - int n = 0; - if ((double)f8 != 0.0) { - f3 = f9 * f9 - f8 * f10; - if ((double)f3 > 0.0) { - f2 = -1.0f / f8; - f = (float)Math.sqrt(f3); - f11 = (f9 + f) * f2; - f12 = (f9 - f) * f2; - if ((double)f11 >= 0.0 && (double)f11 <= 1.0) { - n = 1; - } - if ((double)f > 0.0 && (double)f12 >= 0.0 && (double)f12 <= 1.0) { - if (n == 0) { - f11 = f12; - } - ++n; - } - } - } else { - f11 = f10 / (-2.0f * f9); - if ((double)f11 >= 0.0 && (double)f11 <= 1.0) { - n = 1; - } - } - if (n == 0) { - return 0; - } - f3 = 1.0f / (fArray2[0] * fArray2[0] + fArray2[1] * fArray2[1]); - f2 = fArray2[0] * f3; - f = fArray2[1] * f3; - float f13 = fArray3[0] * f2 + fArray3[1] * f; - float f14 = fArray4[0] * f2 + fArray4[1] * f; - float f15 = fArray5[0] * f2 + fArray5[1] * f; - float f16 = fArray[0] * f2 + fArray[1] * f; - float f17 = f14 - f13; - float f18 = f15 - f13; - float f19 = f13 - f16; - fArray6[0][0] = f19 + f11 * (2.0f - 2.0f * f11) * f17 + f11 * f11 * f18; - fArray6[0][1] = f8 * f11 + f9; - if (n > 1) { - fArray6[1][0] = f19 + f12 * (2.0f - 2.0f * f12) * f17 + f12 * f12 * f18; - fArray6[1][1] = f8 * f12 + f9; - return 2; - } - return 1; - } - - static int i(byte[] byArray, int n, float f, byte[] byArray2, int n2, int n3, int n4, int n5, StbTrueTypeBakedChar[] stbTrueTypeBakedCharArray) { - StbTrueTypeFontInfo stbTrueTypeFontInfo = new StbTrueTypeFontInfo(); - if (SmoothFontRasterState.L(stbTrueTypeFontInfo, byArray, n) == 0) { - return -1; - } - Arrays.fill(byArray2, 0, n2 * n3, (byte)0); - int n6 = 1; - int n7 = 1; - int n8 = 1; - float f2 = SmoothFontRasterState.V(stbTrueTypeFontInfo, f); - for (int i = 0; i < n5; ++i) { - int[] nArray = new int[1]; - int[] nArray2 = new int[1]; - int[] nArray3 = new int[1]; - int[] nArray4 = new int[1]; - int[] nArray5 = new int[1]; - int[] nArray6 = new int[1]; - int n9 = SmoothFontRasterState.T(stbTrueTypeFontInfo, n4 + i); - SmoothFontRasterState.q(stbTrueTypeFontInfo, n9, nArray, nArray2); - SmoothFontRasterState.Z(stbTrueTypeFontInfo, n9, f2, f2, nArray3, nArray4, nArray5, nArray6); - int n10 = nArray5[0] - nArray3[0]; - int n11 = nArray6[0] - nArray4[0]; - if (n7 + n10 + 1 >= n2) { - n6 = n8; - n7 = 1; - } - if (n6 + n11 + 1 >= n3) { - return -i; - } - SmoothFontRasterState.I(stbTrueTypeFontInfo, byArray2, n7 + n6 * n2, n10, n11, n2, f2, f2, n9); - stbTrueTypeBakedCharArray[i].V = (short)n7; - stbTrueTypeBakedCharArray[i].Q = (short)n6; - stbTrueTypeBakedCharArray[i].U = (short)(n7 + n10); - stbTrueTypeBakedCharArray[i].D = (short)(n6 + n11); - stbTrueTypeBakedCharArray[i].l = f2 * (float)nArray[0]; - stbTrueTypeBakedCharArray[i].B = nArray3[0]; - stbTrueTypeBakedCharArray[i].k = nArray4[0]; - n7 = n7 + n10 + 1; - if (n6 + n11 + 1 <= n8) continue; - n8 = n6 + n11 + 1; - } - return n8; - } - - static int m(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - StbTrueTypeCharStringContext stbTrueTypeCharStringContext = new StbTrueTypeCharStringContext(1); - int n2 = SmoothFontRasterState.V(stbTrueTypeFontInfo, n, stbTrueTypeCharStringContext); - if (n2 != 0) { - if (nArray != null) { - int n3 = 0; - int[] nArray5 = nArray; - nArray5[n3] = stbTrueTypeCharStringContext.y; - } - if (nArray2 != null) { - int n4 = 0; - int[] nArray6 = nArray2; - nArray6[n4] = stbTrueTypeCharStringContext.Z; - } - if (nArray3 != null) { - int n5 = 0; - int[] nArray7 = nArray3; - nArray7[n5] = stbTrueTypeCharStringContext.c; - } - if (nArray4 != null) { - int n6 = 0; - int[] nArray8 = nArray4; - nArray8[n6] = stbTrueTypeCharStringContext.f; - } - return stbTrueTypeCharStringContext.q; - } - if (nArray != null) { - int n7 = 0; - int[] nArray9 = nArray; - nArray9[n7] = 0; - } - if (nArray2 != null) { - int n8 = 0; - int[] nArray10 = nArray2; - nArray10[n8] = 0; - } - if (nArray3 != null) { - int n9 = 0; - int[] nArray11 = nArray3; - nArray11[n9] = 0; - } - if (nArray4 != null) { - int n10 = 0; - int[] nArray12 = nArray4; - nArray12[n10] = 0; - } - return 0; - } - - static void i(StbByteBufferView frame, int n) { - if (!(G || n <= frame.y && n >= 0)) { - throw new AssertionError(); - } - frame.h = n > frame.y || n < 0 ? frame.y : n; - } - - public static byte[] N(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f, float f2, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - return SmoothFontRasterState.F(stbTrueTypeFontInfo, f, f2, 0.0f, 0.0f, n, nArray, nArray2, nArray3, nArray4); - } - - public static void G(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, float f, float f2, float f3, float f4, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - int[] nArray5 = new int[]{0}; - int[] nArray6 = new int[]{0}; - int[] nArray7 = new int[]{0}; - int[] nArray8 = new int[]{0}; - if (SmoothFontRasterState.F(stbTrueTypeFontInfo, n, nArray5, nArray6, nArray7, nArray8) == 0) { - if (nArray != null) { - nArray[0] = 0; - } - if (nArray2 != null) { - nArray2[0] = 0; - } - if (nArray3 != null) { - nArray3[0] = 0; - } - if (nArray4 != null) { - nArray4[0] = 0; - } - } else { - if (nArray != null) { - nArray[0] = (int)Math.floor((float)nArray5[0] * f + f3); - } - if (nArray2 != null) { - nArray2[0] = (int)Math.floor((float)(-nArray8[0]) * f2 + f4); - } - if (nArray3 != null) { - nArray3[0] = (int)Math.ceil((float)nArray7[0] * f + f3); - } - if (nArray4 != null) { - nArray4[0] = (int)Math.ceil((float)(-nArray6[0]) * f2 + f4); - } - } - } - - static long v(StbByteBufferView frame) { - int n = SmoothFontRasterState.Q(frame); - if (n >= 32 && n <= 246) { - return n - 139; - } - if (n >= 247 && n <= 250) { - return (n - 247) * 256 + SmoothFontRasterState.Q(frame) + 108; - } - if (n >= 251 && n <= 254) { - return -(n - 251) * 256 - SmoothFontRasterState.Q(frame) - 108; - } - if (n == 28) { - return SmoothFontRasterState.p(frame); - } - if (n == 29) { - return SmoothFontRasterState.g(frame); - } - if (!G) { - throw new AssertionError(); - } - return 0L; - } - - static void G(StbTrueTypeEdge[] stbTrueTypeEdgeArray, int n, int n2) { - while (n2 > 12) { - StbTrueTypeEdge stbTrueTypeEdge; - boolean bl; - int n3 = n2 >> 1; - boolean bl2 = stbTrueTypeEdgeArray[n].X < stbTrueTypeEdgeArray[n + n3].X; - boolean bl3 = bl = stbTrueTypeEdgeArray[n + n3].X < stbTrueTypeEdgeArray[n + n2 - 1].X; - if (bl2 != bl) { - boolean bl4 = stbTrueTypeEdgeArray[n].X < stbTrueTypeEdgeArray[n + n2 - 1].X; - int n4 = bl4 == bl ? 0 : n2 - 1; - stbTrueTypeEdge = stbTrueTypeEdgeArray[n + n4]; - stbTrueTypeEdgeArray[n + n4] = stbTrueTypeEdgeArray[n + n3]; - stbTrueTypeEdgeArray[n + n3] = stbTrueTypeEdge; - } - stbTrueTypeEdge = stbTrueTypeEdgeArray[n]; - stbTrueTypeEdgeArray[n] = stbTrueTypeEdgeArray[n + n3]; - stbTrueTypeEdgeArray[n + n3] = stbTrueTypeEdge; - int n5 = 1; - int n6 = n2 - 1; - while (true) { - if (stbTrueTypeEdgeArray[n + n5].X < stbTrueTypeEdgeArray[n].X) { - ++n5; - continue; - } - while (stbTrueTypeEdgeArray[n].X < stbTrueTypeEdgeArray[n + n6].X) { - --n6; - } - if (n5 >= n6) break; - stbTrueTypeEdge = stbTrueTypeEdgeArray[n + n5]; - stbTrueTypeEdgeArray[n + n5] = stbTrueTypeEdgeArray[n + n6]; - stbTrueTypeEdgeArray[n + n6] = stbTrueTypeEdge; - ++n5; - --n6; - } - if (n6 < n2 - n5) { - SmoothFontRasterState.G(stbTrueTypeEdgeArray, n, n6); - n += n5; - n2 -= n5; - continue; - } - SmoothFontRasterState.G(stbTrueTypeEdgeArray, n + n5, n2 - n5); - n2 = n6; - } - } - - public static byte[] a(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f, int n, int n2, int n3, float f2, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - return SmoothFontRasterState.A(stbTrueTypeFontInfo, f, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), n2, n3, f2, nArray, nArray2, nArray3, nArray4); - } - - public static int P(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - if (stbTrueTypeFontInfo.g.y != 0) { - return SmoothFontRasterState.m(stbTrueTypeFontInfo, n, null, null, null, null) == 0 ? 1 : 0; - } - int n2 = SmoothFontRasterState.G(stbTrueTypeFontInfo, n); - if (n2 < 0) { - return 1; - } - short s = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n2); - return s == 0 ? 1 : 0; - } - - public static void q(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray, int[] nArray2) { - int n2 = SmoothFontRasterState.x(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.w + 34); - if (n < n2) { - if (nArray != null) { - nArray[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.d + 4 * n); - } - if (nArray2 != null) { - nArray2[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.d + 4 * n + 2); - } - } else { - if (nArray != null) { - nArray[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.d + 4 * (n2 - 1)); - } - if (nArray2 != null) { - nArray2[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.d + 4 * n2 + 2 * (n - n2)); - } - } - } - - static int c(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int n2) { - if (stbTrueTypeFontInfo.G == 0) { - return 0; - } - byte[] byArray = stbTrueTypeFontInfo.S; - int n3 = stbTrueTypeFontInfo.G; - if (SmoothFontRasterState.x(byArray, n3 + 0) != 1) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n3 + 2) != 0) { - return 0; - } - int n4 = SmoothFontRasterState.x(byArray, n3 + 8); - int n5 = n3 + n4; - int n6 = SmoothFontRasterState.x(byArray, n5); - for (int i = 0; i < n6; ++i) { - int n7 = SmoothFontRasterState.x(byArray, n5 + 2 + 2 * i); - int n8 = n5 + n7; - int n9 = SmoothFontRasterState.x(byArray, n8); - int n10 = SmoothFontRasterState.x(byArray, n8 + 4); - int n11 = n8 + 6; - if (n9 != 2) continue; - block5: for (int j = 0; j < n10; ++j) { - int n12 = SmoothFontRasterState.x(byArray, n11 + 2 * j); - int n13 = n8 + n12; - int n14 = SmoothFontRasterState.x(byArray, n13); - int n15 = SmoothFontRasterState.x(byArray, n13 + 2); - int n16 = SmoothFontRasterState.L(byArray, n13 + n15, n); - if (n16 == -1) continue; - switch (n14) { - case 1: { - int n17; - int n18; - int n19; - int n20; - int n21; - int n22; - int n23; - int n24; - int n25; - int n26 = SmoothFontRasterState.x(byArray, n13 + 4); - int n27 = SmoothFontRasterState.x(byArray, n13 + 6); - if (n26 == 4 && n27 == 0) { - n25 = 2; - n24 = SmoothFontRasterState.x(byArray, n13 + 8); - n23 = SmoothFontRasterState.x(byArray, n13 + 10 + 2 * n16); - n22 = n13 + n23; - int n28 = SmoothFontRasterState.x(byArray, n22); - int n29 = n22 + 2; - if (n16 >= n24) { - return 0; - } - n21 = n2; - n20 = n28 - 1; - n19 = 0; - while (n19 <= n20) { - n18 = n19 + n20 >> 1; - int n30 = n29 + (2 + n25) * n18; - int n31 = SmoothFontRasterState.x(byArray, n30); - n17 = n31; - if (n21 < n17) { - n20 = n18 - 1; - continue; - } - if (n21 > n17) { - n19 = n18 + 1; - continue; - } - short s = SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n30 + 2); - return s; - } - continue block5; - } - return 0; - } - case 2: { - int n17; - int n18; - int n21; - int n22; - int n23; - int n24; - int n25; - int n27; - int n26; - int n19 = SmoothFontRasterState.x(byArray, n13 + 4); - int n20 = SmoothFontRasterState.x(byArray, n13 + 6); - if (n19 == 4 && n20 == 0) { - n18 = SmoothFontRasterState.x(byArray, n13 + 8); - n17 = SmoothFontRasterState.x(byArray, n13 + 10); - n21 = SmoothFontRasterState.q(byArray, n13 + n18, n); - n26 = SmoothFontRasterState.q(byArray, n13 + n17, n2); - n27 = SmoothFontRasterState.x(byArray, n13 + 12); - n25 = SmoothFontRasterState.x(byArray, n13 + 14); - if (n21 < 0 || n21 >= n27) { - return 0; - } - if (n26 < 0 || n26 >= n25) { - return 0; - } - n23 = n13 + 16; - n22 = n23 + 2 * (n21 * n25); - n24 = SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n22 + 2 * n26); - return n24; - } - return 0; - } - default: { - return 0; - } - } - } - } - return 0; - } - - static int G(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - int n2; - int n3; - if (!G && stbTrueTypeFontInfo.g.y != 0) { - throw new AssertionError(); - } - if (n >= stbTrueTypeFontInfo.h) { - return -1; - } - if (stbTrueTypeFontInfo.T >= 2) { - return -1; - } - if (stbTrueTypeFontInfo.T == 0) { - n3 = stbTrueTypeFontInfo.p + SmoothFontRasterState.x(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.v + n * 2) * 2; - n2 = stbTrueTypeFontInfo.p + SmoothFontRasterState.x(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.v + n * 2 + 2) * 2; - } else { - n3 = (int)((long)stbTrueTypeFontInfo.p + SmoothFontRasterState.c$src$J$1nktx4p(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.v + n * 4)); - n2 = (int)((long)stbTrueTypeFontInfo.p + SmoothFontRasterState.c$src$J$1nktx4p(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.v + n * 4 + 4)); - } - return n3 == n2 ? -1 : n3; - } - - static boolean c$src$Z$1nktxih(byte[] byArray, int n) { - if (SmoothFontRasterState.d(byArray, n, 49, 0, 0, 0)) { - return true; - } - if (SmoothFontRasterState.f(byArray, n, "typ1")) { - return true; - } - if (SmoothFontRasterState.f(byArray, n, "OTTO")) { - return true; - } - if (SmoothFontRasterState.d(byArray, n, 0, 1, 0, 0)) { - return true; - } - return SmoothFontRasterState.f(byArray, n, "true"); - } - - public static int X(byte[] byArray, int n, float f, byte[] byArray2, int n2, int n3, int n4, int n5, StbTrueTypeBakedChar[] stbTrueTypeBakedCharArray) { - return SmoothFontRasterState.i(byArray, n, f, byArray2, n2, n3, n4, n5, stbTrueTypeBakedCharArray); - } - - static void r(StbTrueTypePoint[] stbTrueTypePointArray, int n, float f, float f2) { - if (stbTrueTypePointArray == null) { - return; - } - stbTrueTypePointArray[n].M = f; - stbTrueTypePointArray[n].E = f2; - } - - public static int a(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - byte[] byArray = stbTrueTypeFontInfo.S; - int n2 = SmoothFontRasterState.J(stbTrueTypeFontInfo); - if (n2 == 0) { - return -1; - } - int n3 = SmoothFontRasterState.x(byArray, n2); - int n4 = n2 + 2; - for (int i = 0; i < n3; ++i) { - int n5 = n4 + 12 * i; - if (n < SmoothFontRasterState.x(byArray, n5) || n > SmoothFontRasterState.x(byArray, n5 + 2)) continue; - return n5; - } - return -1; - } - - public static void Z(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, float f, float f2, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - SmoothFontRasterState.G(stbTrueTypeFontInfo, n, f, f2, 0.0f, 0.0f, nArray, nArray2, nArray3, nArray4); - } - - public static int B(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray) { - byte[] byArray = stbTrueTypeFontInfo.S; - if (stbTrueTypeFontInfo.Q == 0) { - return 0; - } - int n2 = SmoothFontRasterState.a(stbTrueTypeFontInfo, n); - if (n2 >= 0) { - if (nArray != null) { - nArray[0] = stbTrueTypeFontInfo.Q + (int)SmoothFontRasterState.c$src$J$1nktx4p(byArray, n2 + 4); - } - return (int)SmoothFontRasterState.c$src$J$1nktx4p(byArray, n2 + 8); - } - return 0; - } - - public static int s(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - return SmoothFontRasterState.F(stbTrueTypeFontInfo, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), nArray, nArray2, nArray3, nArray4); - } - - static float U(int n) { - if (n == 0) { - return 0.0f; - } - return (float)(-(n - 1)) / (2.0f * (float)n); - } - - static int v(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int n2) { - byte[] byArray = stbTrueTypeFontInfo.S; - int n3 = stbTrueTypeFontInfo.L; - if (n3 == 0) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n3 + 2) < 1) { - return 0; - } - if (SmoothFontRasterState.x(byArray, n3 + 8) != 1) { - return 0; - } - int n4 = 0; - int n5 = SmoothFontRasterState.x(byArray, n3 + 10) - 1; - long l = (long)n << 16 | (long)n2; - while (n4 <= n5) { - int n6 = n4 + n5 >> 1; - long l2 = SmoothFontRasterState.c$src$J$1nktx4p(byArray, n3 + 18 + n6 * 6); - if (l < l2) { - n5 = n6 - 1; - continue; - } - if (l > l2) { - n4 = n6 + 1; - continue; - } - return SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n3 + 22 + n6 * 6); - } - return 0; - } - - public static void V(StbTrueTypeBakedChar[] stbTrueTypeBakedCharArray, int n, int n2, int n3, float[] fArray, float[] fArray2, StbTrueTypeAlignedQuad stbTrueTypeAlignedQuad, int n4) { - float f = n4 != 0 ? 0.0f : -0.5f; - float f2 = 1.0f / (float)n; - float f3 = 1.0f / (float)n2; - StbTrueTypeBakedChar stbTrueTypeBakedChar = stbTrueTypeBakedCharArray[n3]; - int n5 = (int)Math.floor(fArray[0] + stbTrueTypeBakedChar.B + 0.5f); - int n6 = (int)Math.floor(fArray2[0] + stbTrueTypeBakedChar.k + 0.5f); - stbTrueTypeAlignedQuad.v = (float)n5 + f; - stbTrueTypeAlignedQuad.x = (float)n6 + f; - stbTrueTypeAlignedQuad.K = (float)(n5 + stbTrueTypeBakedChar.U - stbTrueTypeBakedChar.V) + f; - stbTrueTypeAlignedQuad.M = (float)(n6 + stbTrueTypeBakedChar.D - stbTrueTypeBakedChar.Q) + f; - stbTrueTypeAlignedQuad.G = (float)stbTrueTypeBakedChar.V * f2; - stbTrueTypeAlignedQuad.O = (float)stbTrueTypeBakedChar.Q * f3; - stbTrueTypeAlignedQuad.S = (float)stbTrueTypeBakedChar.U * f2; - stbTrueTypeAlignedQuad.C = (float)stbTrueTypeBakedChar.D * f3; - fArray[0] = fArray[0] + stbTrueTypeBakedChar.l; - } - - static void s(StbTrueTypeEdge[] stbTrueTypeEdgeArray, int n) { - SmoothFontRasterState.G(stbTrueTypeEdgeArray, 0, n); - SmoothFontRasterState.N(stbTrueTypeEdgeArray, 0, n); - } - - static void d(StbTrueTypeVertex stbTrueTypeVertex, int n, int n2, int n3, int n4, int n5) { - stbTrueTypeVertex.O = n; - stbTrueTypeVertex.f = (short)n2; - stbTrueTypeVertex.H = (short)n3; - stbTrueTypeVertex.h = (short)n4; - stbTrueTypeVertex.D = (short)n5; - } - - static boolean d(byte[] byArray, int n, int n2, byte[] byArray2, int n3, int n4) { - return n2 == SmoothFontRasterState.Y(byArray, n, n2, byArray2, n3, n4); - } - - static void t(StbTrueTypePackAtlasState stbTrueTypePackAtlasState, StbTrueTypePackRectangle[] stbTrueTypePackRectangleArray, int n) { - int n2; - for (n2 = 0; n2 < n; ++n2) { - if (stbTrueTypePackAtlasState.n + stbTrueTypePackRectangleArray[n2].N > stbTrueTypePackAtlasState.f) { - stbTrueTypePackAtlasState.n = 0; - stbTrueTypePackAtlasState.a = stbTrueTypePackAtlasState.t; - } - if (stbTrueTypePackAtlasState.a + stbTrueTypePackRectangleArray[n2].e > stbTrueTypePackAtlasState.F) break; - stbTrueTypePackRectangleArray[n2].P = stbTrueTypePackAtlasState.n; - stbTrueTypePackRectangleArray[n2].J = stbTrueTypePackAtlasState.a; - stbTrueTypePackRectangleArray[n2].M = 1; - stbTrueTypePackAtlasState.n += stbTrueTypePackRectangleArray[n2].N; - if (stbTrueTypePackAtlasState.a + stbTrueTypePackRectangleArray[n2].e <= stbTrueTypePackAtlasState.t) continue; - stbTrueTypePackAtlasState.t = stbTrueTypePackAtlasState.a + stbTrueTypePackRectangleArray[n2].e; - } - while (n2 < n) { - stbTrueTypePackRectangleArray[n2].M = 0; - ++n2; - } - } - - - public static float N(float f) { - return -f; - } - - public static void x(StbTrueTypeFontInfo stbTrueTypeFontInfo, int[] nArray, int[] nArray2, int[] nArray3) { - if (nArray != null) { - nArray[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.w + 4); - } - if (nArray2 != null) { - nArray2[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.w + 6); - } - if (nArray3 != null) { - nArray3[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.w + 8); - } - } - - static void s(StbTrueTypeCharStringContext stbTrueTypeCharStringContext, float f, float f2, float f3, float f4, float f5, float f6) { - float f7 = stbTrueTypeCharStringContext.C + f; - float f8 = stbTrueTypeCharStringContext.o + f2; - float f9 = f7 + f3; - float f10 = f8 + f4; - stbTrueTypeCharStringContext.C = f9 + f5; - stbTrueTypeCharStringContext.o = f10 + f6; - SmoothFontRasterState.A(stbTrueTypeCharStringContext, 4, (int)stbTrueTypeCharStringContext.C, (int)stbTrueTypeCharStringContext.o, (int)f7, (int)f8, (int)f9, (int)f10); - } - - public static void I(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n, int n2, int n3, int n4, float f, float f2, int n5) { - SmoothFontRasterState.j(stbTrueTypeFontInfo, byArray, n, n2, n3, n4, f, f2, 0.0f, 0.0f, n5); - } - - public static void c(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, int[] nArray, int[] nArray2) { - SmoothFontRasterState.q(stbTrueTypeFontInfo, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), nArray, nArray2); - } - - static StbByteBufferView E(StbByteBufferView frame, int n, int n2) { - StbByteBufferView frame2 = SmoothFontRasterState.x(null, 0, 0); - if (n < 0 || n2 < 0 || n > frame.y || n2 > frame.y - n) { - return frame2; - } - frame2.f = frame.f; - frame2.C = frame.C + n; - frame2.y = n2; - return frame2; - } - - static int q(StbByteBufferView frame) { - SmoothFontRasterState.i(frame, 0); - return SmoothFontRasterState.p(frame); - } - - public static int J(StbTrueTypeFontInfo stbTrueTypeFontInfo, int[] nArray, int[] nArray2, int[] nArray3) { - int n = (int)SmoothFontRasterState.v(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.U, "OS/2"); - if (n == 0) { - return 0; - } - if (nArray != null) { - nArray[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n + 68); - } - if (nArray2 != null) { - nArray2[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n + 70); - } - if (nArray3 != null) { - nArray3[0] = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, n + 72); - } - return 1; - } - - static StbByteBufferView u(StbByteBufferView frame, StbByteBufferView frame2) { - long[] lArray = new long[]{0L}; - long[] lArray2 = new long[]{0L, 0L}; - SmoothFontRasterState.X(frame2, 18, 2, lArray2); - if (lArray2[1] == 0L || lArray2[0] == 0L) { - return SmoothFontRasterState.x(null, 0, 0); - } - StbByteBufferView frame3 = SmoothFontRasterState.E(frame, (int)lArray2[1], (int)lArray2[0]); - SmoothFontRasterState.X(frame3, 19, 1, lArray); - if (lArray[0] == 0L) { - return SmoothFontRasterState.x(null, 0, 0); - } - SmoothFontRasterState.i(frame, (int)(lArray2[1] + lArray[0])); - return SmoothFontRasterState.B(frame); - } - - public static void H(StbTrueTypePackContext stbTrueTypePackContext, StbTrueTypePackRectangle[] stbTrueTypePackRectangleArray, int n) { - SmoothFontRasterState.t(stbTrueTypePackContext.J, stbTrueTypePackRectangleArray, n); - } - - static void X(StbByteBufferView frame, int n, int n2, long[] lArray) { - StbByteBufferView frame2 = SmoothFontRasterState.C(frame, n); - for (int i = 0; i < n2 && frame2.h < frame2.y; ++i) { - lArray[i] = SmoothFontRasterState.v(frame2); - } - } - - public static void p(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n, float f, float f2, float f3, float f4, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - SmoothFontRasterState.G(stbTrueTypeFontInfo, SmoothFontRasterState.T(stbTrueTypeFontInfo, n), f, f2, f3, f4, nArray, nArray2, nArray3, nArray4); - } - - static void z(StbTrueTypeCharStringContext stbTrueTypeCharStringContext, float f, float f2) { - stbTrueTypeCharStringContext.C += f; - stbTrueTypeCharStringContext.o += f2; - SmoothFontRasterState.A(stbTrueTypeCharStringContext, 2, (int)stbTrueTypeCharStringContext.C, (int)stbTrueTypeCharStringContext.o, 0, 0, 0, 0); - } - - static float S(float f, float f2) { - return f * f2 / 2.0f; - } - - public static int T(StbTrueTypeFontInfo stbTrueTypeFontInfo, int n) { - byte[] byArray = stbTrueTypeFontInfo.S; - int n2 = stbTrueTypeFontInfo.Y; - int n3 = SmoothFontRasterState.x(byArray, n2 + 0); - if (n3 == 0) { - int n4 = SmoothFontRasterState.x(byArray, n2 + 2); - if (n < n4 - 6) { - return SmoothFontRasterState.N(byArray, n2 + 6 + n); - } - return 0; - } - if (n3 == 6) { - long l = SmoothFontRasterState.x(byArray, n2 + 6); - long l2 = SmoothFontRasterState.x(byArray, n2 + 8); - if ((long)n >= l && (long)n < l + l2) { - return SmoothFontRasterState.x(byArray, n2 + 10 + (n - (int)l) * 2); - } - return 0; - } - if (n3 == 2) { - if (!G) { - throw new AssertionError(); - } - return 0; - } - if (n3 == 4) { - int n5; - int n6; - int n7 = SmoothFontRasterState.x(byArray, n2 + 6) >> 1; - int n8 = SmoothFontRasterState.x(byArray, n2 + 8) >> 1; - int n9 = SmoothFontRasterState.x(byArray, n2 + 10); - int n10 = SmoothFontRasterState.x(byArray, n2 + 12) >> 1; - int n11 = n6 = n2 + 14; - if (n > 65535) { - return 0; - } - if (n >= SmoothFontRasterState.x(byArray, n11 + n10 * 2)) { - n11 += n10 * 2; - } - n11 -= 2; - while (n9 != 0) { - n5 = SmoothFontRasterState.x(byArray, n11 + (n8 >>= 1) * 2); - if (n > n5) { - n11 += n8 * 2; - } - --n9; - } - int n12 = (n11 += 2) - n6 >> 1; - int n13 = SmoothFontRasterState.x(byArray, n2 + 14 + n7 * 2 + 2 + 2 * n12); - int n14 = SmoothFontRasterState.x(byArray, n6 + 2 * n12); - if (n < n13 || n > n14) { - return 0; - } - n5 = SmoothFontRasterState.x(byArray, n2 + 14 + n7 * 6 + 2 + 2 * n12); - if (n5 == 0) { - return n + SmoothFontRasterState.E$src$S$1b9gd7y(byArray, n2 + 14 + n7 * 4 + 2 + 2 * n12) & 0xFFFF; - } - return SmoothFontRasterState.x(byArray, n5 + (n - n13) * 2 + n2 + 14 + n7 * 6 + 2 + 2 * n12); - } - if (n3 == 12 || n3 == 13) { - long l = SmoothFontRasterState.c$src$J$1nktx4p(byArray, n2 + 12); - int n15 = 0; - int n16 = (int)l; - while (n15 < n16) { - int n17 = n15 + (n16 - n15 >> 1); - long l3 = SmoothFontRasterState.c$src$J$1nktx4p(byArray, n2 + 16 + n17 * 12); - long l4 = SmoothFontRasterState.c$src$J$1nktx4p(byArray, n2 + 16 + n17 * 12 + 4); - if ((long)n < l3) { - n16 = n17; - continue; - } - if ((long)n > l4) { - n15 = n17 + 1; - continue; - } - long l5 = SmoothFontRasterState.c$src$J$1nktx4p(byArray, n2 + 16 + n17 * 12 + 8); - if (n3 == 12) { - return (int)(l5 + (long)n - l3); - } - return (int)l5; - } - return 0; - } - if (!G) { - throw new AssertionError(); - } - return 0; - } - - public static void H(StbTrueTypeFontInfo stbTrueTypeFontInfo, byte[] byArray, int n, int n2, int n3, int n4, float f, float f2, float f3, float f4, int n5, int n6, float[] fArray, float[] fArray2, int n7) { - SmoothFontRasterState.j(stbTrueTypeFontInfo, byArray, n, n2 - (n5 - 1), n3 - (n6 - 1), n4, f, f2, f3, f4, n7); - if (n5 > 1) { - SmoothFontRasterState.H(byArray, n, n2, n3, n4, n5); - } - if (n6 > 1) { - SmoothFontRasterState.p(byArray, n, n2, n3, n4, n6); - } - fArray[0] = SmoothFontRasterState.U(n5); - fArray2[0] = SmoothFontRasterState.U(n6); - } - - static { - j = 23; - S = 19; - L = 4; - q = 4; - o = 3; - C = 2; - B = 1053; - T = 11; - a = 6; - x = 2; - Fb = 1041; - i = 2; - E = 7; - R = 1042; - r = 10; - M = 1036; - Ff = 8; - z = 5; - I = 2; - A = 4; - n = 3; - f = 1049; - O = 6; - g = 1043; - Y = 10; - v = 2; - H = 12; - P = 1033; - F = 2052; - V = 2; - U = 1037; - c = 7; - m = 3; - Fc = 1033; - t = 3; - D = 5; - W = 32; - N = 1031; - FC = 3; - Fy = 2; - Q = 8; - F1 = 4; - h = 4; - Z = 1040; - e = 33; - boolean bl = SmoothFontRasterState.class.desiredAssertionStatus(); - boolean bl2 = true; - G = false; - } - - static void N(StbTrueTypeEdge[] stbTrueTypeEdgeArray, int n, int n2) { - for (int i = 1; i < n2; ++i) { - int n3; - StbTrueTypeEdge stbTrueTypeEdge = stbTrueTypeEdgeArray[n + i]; - for (n3 = i; n3 > 0; --n3) { - boolean bl; - StbTrueTypeEdge stbTrueTypeEdge2 = stbTrueTypeEdgeArray[n + n3 - 1]; - boolean bl2 = bl = stbTrueTypeEdge.X < stbTrueTypeEdge2.X; - if (!bl) break; - stbTrueTypeEdgeArray[n + n3] = stbTrueTypeEdgeArray[n + n3 - 1]; - } - if (i == n3) continue; - stbTrueTypeEdgeArray[n + n3] = stbTrueTypeEdge; - } - } - - static StbByteBufferView C(StbByteBufferView frame, int n) { - SmoothFontRasterState.i(frame, 0); - while (frame.h < frame.y) { - int n2 = frame.h; - while (SmoothFontRasterState.K(frame) >= 28) { - SmoothFontRasterState.M(frame); - } - int n3 = frame.h; - int n4 = SmoothFontRasterState.Q(frame); - if (n4 == 12) { - n4 = SmoothFontRasterState.Q(frame) | 0x100; - } - if (n4 != n) continue; - return SmoothFontRasterState.E(frame, n2, n3 - n2); - } - return SmoothFontRasterState.E(frame, 0, 0); - } - - static long g(StbByteBufferView frame) { - return SmoothFontRasterState.u(frame, 4); - } - - public static float V(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f) { - int n = SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.w + 4) - SmoothFontRasterState.E$src$S$1b9gd7y(stbTrueTypeFontInfo.S, stbTrueTypeFontInfo.w + 6); - return f / (float)n; - } - - static void b(StbTrueTypeBitmap stbTrueTypeBitmap, StbTrueTypePoint[] stbTrueTypePointArray, int[] nArray, int n, float f, float f2, float f3, float f4, int n2, int n3, int n4) { - int n5; - float f5 = n4 != 0 ? -f2 : f2; - int n6 = 1; - int n7 = 0; - for (n5 = 0; n5 < n; ++n5) { - n7 += nArray[n5]; - } - StbTrueTypeEdge[] stbTrueTypeEdgeArray = new StbTrueTypeEdge[n7 + 1]; - for (n5 = 0; n5 <= n7; ++n5) { - stbTrueTypeEdgeArray[n5] = new StbTrueTypeEdge(); - } - n7 = 0; - int n8 = 0; - for (n5 = 0; n5 < n; ++n5) { - int n9 = n8; - n8 += nArray[n5]; - int n10 = nArray[n5] - 1; - int n11 = 0; - while (n11 < nArray[n5]) { - int n12 = n11; - int n13 = n10; - if (stbTrueTypePointArray[n9 + n10].E != stbTrueTypePointArray[n9 + n11].E) { - stbTrueTypeEdgeArray[n7].W = 0; - if (n4 != 0 ? stbTrueTypePointArray[n9 + n10].E > stbTrueTypePointArray[n9 + n11].E : stbTrueTypePointArray[n9 + n10].E < stbTrueTypePointArray[n9 + n11].E) { - stbTrueTypeEdgeArray[n7].W = 1; - n12 = n10; - n13 = n11; - } - stbTrueTypeEdgeArray[n7].d = stbTrueTypePointArray[n9 + n12].M * f + f3; - stbTrueTypeEdgeArray[n7].X = (stbTrueTypePointArray[n9 + n12].E * f5 + f4) * (float)n6; - stbTrueTypeEdgeArray[n7].i = stbTrueTypePointArray[n9 + n13].M * f + f3; - stbTrueTypeEdgeArray[n7].u = (stbTrueTypePointArray[n9 + n13].E * f5 + f4) * (float)n6; - ++n7; - } - n10 = n11++; - } - } - SmoothFontRasterState.s(stbTrueTypeEdgeArray, n7); - SmoothFontRasterState.b(stbTrueTypeBitmap, stbTrueTypeEdgeArray, n7, n6, n2, n3); - } - - public static int G(StbTrueTypePackContext stbTrueTypePackContext, byte[] byArray, int n, float f, int n2, int n3, StbTrueTypePackedChar[] stbTrueTypePackedCharArray) { - StbTrueTypePackRange stbTrueTypePackRange = new StbTrueTypePackRange(); - stbTrueTypePackRange.R = n2; - stbTrueTypePackRange.N = null; - stbTrueTypePackRange.b = n3; - stbTrueTypePackRange.M = stbTrueTypePackedCharArray; - stbTrueTypePackRange.E = f; - return SmoothFontRasterState.c(stbTrueTypePackContext, byArray, n, new StbTrueTypePackRange[]{stbTrueTypePackRange}, 1); - } - - public static byte[] A(StbTrueTypeFontInfo stbTrueTypeFontInfo, float f, int n, int n2, int n3, float f2, int[] nArray, int[] nArray2, int[] nArray3, int[] nArray4) { - float f3; - float f4; - float f5; - float f6; - float f7; - float f8; - float f9; - float f10; - float f11 = f; - float f12 = f; - int[] nArray5 = new int[1]; - int[] nArray6 = new int[1]; - int[] nArray7 = new int[1]; - int[] nArray8 = new int[1]; - if (f == 0.0f) { - return null; - } - SmoothFontRasterState.G(stbTrueTypeFontInfo, n, f, f, 0.0f, 0.0f, nArray5, nArray6, nArray7, nArray8); - if (nArray5[0] == nArray7[0] || nArray6[0] == nArray8[0]) { - return null; - } - nArray5[0] = nArray5[0] - n2; - nArray6[0] = nArray6[0] - n2; - nArray7[0] = nArray7[0] + n2; - nArray8[0] = nArray8[0] + n2; - int n4 = nArray7[0] - nArray5[0]; - int n5 = nArray8[0] - nArray6[0]; - if (nArray != null) { - nArray[0] = n4; - } - if (nArray2 != null) { - nArray2[0] = n5; - } - if (nArray3 != null) { - nArray3[0] = nArray5[0]; - } - if (nArray4 != null) { - nArray4[0] = nArray6[0]; - } - f12 = -f12; - float f13 = 9.765625E-4f; - float f14 = 9.536743E-7f; - StbTrueTypeVertex[] stbTrueTypeVertexArray = SmoothFontRasterState.m(stbTrueTypeFontInfo, n); - int n6 = stbTrueTypeVertexArray != null ? stbTrueTypeVertexArray.length : 0; - byte[] byArray = new byte[n4 * n5]; - float[] fArray = new float[n6]; - int n7 = 0; - int n8 = n6 - 1; - while (n7 < n6) { - float f15; - fArray[n7] = stbTrueTypeVertexArray[n7].O == 2 ? ((f10 = (float)Math.sqrt(((f9 = (float)stbTrueTypeVertexArray[n8].f * f11) - (f8 = (float)stbTrueTypeVertexArray[n7].f * f11)) * (f9 - f8) + ((f7 = (float)stbTrueTypeVertexArray[n8].H * f12) - (f6 = (float)stbTrueTypeVertexArray[n7].H * f12)) * (f7 - f6))) < 9.765625E-4f ? 0.0f : 1.0f / f10) : (stbTrueTypeVertexArray[n7].O == 3 ? ((f5 = (f15 = (f10 = (float)stbTrueTypeVertexArray[n7].f * f11) - 2.0f * (f9 = (float)stbTrueTypeVertexArray[n7].h * f11) + (f8 = (float)stbTrueTypeVertexArray[n8].f * f11)) * f15 + (f4 = (f3 = (float)stbTrueTypeVertexArray[n7].H * f12) - 2.0f * (f7 = (float)stbTrueTypeVertexArray[n7].D * f12) + (f6 = (float)stbTrueTypeVertexArray[n8].H * f12)) * f4) >= 9.536743E-7f ? 1.0f / f5 : 0.0f) : 0.0f); - n8 = n7++; - } - for (int i = nArray6[0]; i < nArray8[0]; ++i) { - for (int j = nArray5[0]; j < nArray7[0]; ++j) { - f6 = 999999.0f; - f9 = (float)j + 0.5f; - f7 = (float)i + 0.5f; - f10 = f9 / f11; - f3 = f7 / f12; - int n9 = SmoothFontRasterState.i(f10, f3, n6, stbTrueTypeVertexArray); - for (n7 = 0; n7 < n6; ++n7) { - float f16; - float f17; - float f18; - float f19; - float f20; - float f21; - float f22; - float f23; - float f24; - float f25; - float f26; - float f27; - float f28; - float f29; - float f30; - f4 = (float)stbTrueTypeVertexArray[n7].f * f11; - f5 = (float)stbTrueTypeVertexArray[n7].H * f12; - if (stbTrueTypeVertexArray[n7].O == 2 && fArray[n7] != 0.0f) { - float f31; - f30 = (float)stbTrueTypeVertexArray[n7 - 1].f * f11; - f29 = (float)stbTrueTypeVertexArray[n7 - 1].H * f12; - f28 = (f4 - f9) * (f4 - f9) + (f5 - f7) * (f5 - f7); - if (f28 < f6 * f6) { - f6 = (float)Math.sqrt(f28); - } - if (!((f27 = Math.abs((f30 - f4) * (f5 - f7) - (f29 - f5) * (f4 - f9)) * fArray[n7]) < f6) || !((f31 = -((f26 = f4 - f9) * (f25 = f30 - f4) + (f24 = f5 - f7) * (f23 = f29 - f5)) / (f25 * f25 + f23 * f23)) >= 0.0f) || !(f31 <= 1.0f)) continue; - f6 = f27; - continue; - } - if (stbTrueTypeVertexArray[n7].O != 3) continue; - f30 = (float)stbTrueTypeVertexArray[n7 - 1].f * f11; - f29 = (float)stbTrueTypeVertexArray[n7 - 1].H * f12; - f27 = (float)stbTrueTypeVertexArray[n7].h * f11; - f28 = (float)stbTrueTypeVertexArray[n7].D * f12; - f25 = Math.min(Math.min(f4, f27), f30); - f23 = Math.min(Math.min(f5, f28), f29); - f26 = Math.max(Math.max(f4, f27), f30); - f24 = Math.max(Math.max(f5, f28), f29); - if (!(f9 > f25 - f6) || !(f9 < f26 + f6) || !(f7 > f23 - f6) || !(f7 < f24 + f6)) continue; - int n10 = 0; - float f32 = f27 - f4; - float f33 = f28 - f5; - float f34 = f4 - 2.0f * f27 + f30; - float f35 = f5 - 2.0f * f28 + f29; - float f36 = f4 - f9; - float f37 = f5 - f7; - float[] fArray2 = new float[]{0.0f, 0.0f, 0.0f}; - float f38 = fArray[n7]; - if ((double)f38 == 0.0) { - f22 = 3.0f * (f32 * f34 + f33 * f35); - f21 = 2.0f * (f32 * f32 + f33 * f33) + (f36 * f34 + f37 * f35); - f20 = f36 * f32 + f37 * f33; - if (Math.abs(f22) < 9.536743E-7f) { - if (Math.abs(f21) >= 9.536743E-7f) { - fArray2[n10++] = -f20 / f21; - } - } else { - float f39 = f21 * f21 - 4.0f * f22 * f20; - if (f39 < 0.0f) { - n10 = 0; - } else { - float f40 = (float)Math.sqrt(f39); - fArray2[0] = (-f21 - f40) / (2.0f * f22); - fArray2[1] = (-f21 + f40) / (2.0f * f22); - n10 = 2; - } - } - } else { - f22 = 3.0f * (f32 * f34 + f33 * f35) * f38; - f21 = (2.0f * (f32 * f32 + f33 * f33) + (f36 * f34 + f37 * f35)) * f38; - f20 = (f36 * f32 + f37 * f33) * f38; - n10 = SmoothFontRasterState.X(f22, f21, f20, fArray2); - } - float f41 = (f4 - f9) * (f4 - f9) + (f5 - f7) * (f5 - f7); - if (f41 < f6 * f6) { - f6 = (float)Math.sqrt(f41); - } - if (n10 >= 1 && fArray2[0] >= 0.0f && fArray2[0] <= 1.0f && (f41 = ((f19 = (f18 = 1.0f - (f17 = fArray2[0])) * f18 * f4 + 2.0f * f17 * f18 * f27 + f17 * f17 * f30) - f9) * (f19 - f9) + ((f16 = f18 * f18 * f5 + 2.0f * f17 * f18 * f28 + f17 * f17 * f29) - f7) * (f16 - f7)) < f6 * f6) { - f6 = (float)Math.sqrt(f41); - } - if (n10 >= 2 && fArray2[1] >= 0.0f && fArray2[1] <= 1.0f && (f41 = ((f19 = (f18 = 1.0f - (f17 = fArray2[1])) * f18 * f4 + 2.0f * f17 * f18 * f27 + f17 * f17 * f30) - f9) * (f19 - f9) + ((f16 = f18 * f18 * f5 + 2.0f * f17 * f18 * f28 + f17 * f17 * f29) - f7) * (f16 - f7)) < f6 * f6) { - f6 = (float)Math.sqrt(f41); - } - if (n10 < 3 || !(fArray2[2] >= 0.0f) || !(fArray2[2] <= 1.0f) || !((f41 = ((f19 = (f18 = 1.0f - (f17 = fArray2[2])) * f18 * f4 + 2.0f * f17 * f18 * f27 + f17 * f17 * f30) - f9) * (f19 - f9) + ((f16 = f18 * f18 * f5 + 2.0f * f17 * f18 * f28 + f17 * f17 * f29) - f7) * (f16 - f7)) < f6 * f6)) continue; - f6 = (float)Math.sqrt(f41); - } - if (n9 == 0) { - f6 = -f6; - } - if ((f8 = (float)n3 + f2 * f6) < 0.0f) { - f8 = 0.0f; - } else if (f8 > 255.0f) { - f8 = 255.0f; - } - byArray[(i - nArray6[0]) * n4 + (j - nArray5[0])] = (byte)f8; - } - } - return byArray; - } - - static float w(float f) { - if (f < 0.0f) { - return -((float)Math.pow(-f, 0.3333333432674408)); - } - return (float)Math.pow(f, 0.3333333432674408); - } - - static int u(byte[] byArray, int n) { - return byArray[n]; - } - - static boolean f(byte[] byArray, int n, String string) { - return SmoothFontRasterState.d(byArray, n, (int)string.charAt(0), (int)string.charAt(1), (int)string.charAt(2), (int)string.charAt(3)); - } - - public static int p(byte[] byArray) { - return SmoothFontRasterState.s(byArray); - } -} - diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRenderer.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRenderer.java deleted file mode 100644 index aa193de..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRenderer.java +++ /dev/null @@ -1,128 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import java.awt.Color; -import java.util.LinkedHashMap; -import java.util.Map; - -public abstract class SmoothFontRenderer { - protected Map strippedStringCache; - protected Map stringWidthCache = new SmoothFontRendererWidthCache(this, 16, 0.75f, true); - protected boolean fontSelectorEnabled = true; - protected int fontSize; - - public void drawString(String text, double x, double y, int color) { - drawStringStripped(text, x, y, color, false); - } - - public abstract void drawVerticalString(String text, double x, double y, Color color); - - protected void applyColorCode(char code, float[] rgb) { - if (code == '4') { rgb[0] = 1.0f; rgb[1] = 0.0f; rgb[2] = 0.0f; } - if (code == 'c') { rgb[0] = 1.0f; rgb[1] = 0.33f; rgb[2] = 0.33f; } - if (code == '6') { rgb[0] = 1.0f; rgb[1] = 0.66f; rgb[2] = 0.0f; } - if (code == 'e') { rgb[0] = 1.0f; rgb[1] = 1.0f; rgb[2] = 0.33f; } - if (code == '2') { rgb[0] = 0.0f; rgb[1] = 0.66f; rgb[2] = 0.0f; } - if (code == 'a') { rgb[0] = 0.33f; rgb[1] = 1.0f; rgb[2] = 0.33f; } - if (code == 'b') { rgb[0] = 0.33f; rgb[1] = 1.0f; rgb[2] = 1.0f; } - if (code == '3') { rgb[0] = 0.0f; rgb[1] = 0.66f; rgb[2] = 0.66f; } - if (code == '1') { rgb[0] = 0.0f; rgb[1] = 0.0f; rgb[2] = 0.66f; } - if (code == '9') { rgb[0] = 0.33f; rgb[1] = 0.33f; rgb[2] = 1.0f; } - if (code == 'd') { rgb[0] = 1.0f; rgb[1] = 0.33f; rgb[2] = 1.0f; } - if (code == '5') { rgb[0] = 0.66f; rgb[1] = 0.0f; rgb[2] = 0.66f; } - if (code == 'f') { rgb[0] = 1.0f; rgb[1] = 1.0f; rgb[2] = 1.0f; } - if (code == '7') { rgb[0] = 0.66f; rgb[1] = 0.66f; rgb[2] = 0.66f; } - if (code == '8') { rgb[0] = 0.33f; rgb[1] = 0.33f; rgb[2] = 0.33f; } - if (code == '0') { rgb[0] = 0.0f; rgb[1] = 0.0f; rgb[2] = 0.0f; } - } - - public void clearCaches() { - this.stringWidthCache.clear(); - this.strippedStringCache.clear(); - } - - public void drawString(String text, double x, double y, Color color) { - drawString(text, x, y, color.getRGB()); - } - - public int getStrippedStringCacheSize() { - return this.strippedStringCache.size(); - } - - public void drawCenteredString(String text, double x, double y, int color) { - drawString(text, x - getStringWidth(text) / 2.0, y, color); - } - - public void setFontSelectorEnabled(boolean enabled) { - this.fontSelectorEnabled = enabled; - } - - public abstract void drawStringWithShadow(String text, double x, double y, int color); - - public abstract void renderString(String text, double x, double y, int color, boolean fallbackToVanilla); - - public double getStringWidth(String text) { - return getStringWidth(text, false); - } - - public double getStringHeight(String text) { - return getStringHeight(text, false); - } - - public void drawString(String text, double x, double y, Color color, boolean fallbackToVanilla) { - int rgb = color.getRGB(); - renderString(text, x, y, rgb, fallbackToVanilla); - } - - public abstract double getStringHeight(String text, boolean fallbackToVanilla); - - public void drawStringStripped(String text, double x, double y, int color, boolean shadow) { - String stripped = this.strippedStringCache.get(text); - if (stripped == null) { - StringBuilder sb = new StringBuilder(); - char[] chars = text.toCharArray(); - for (int i = 0; i < chars.length; ++i) { - char c = chars[i]; - if (c == '\u00a7') { - ++i; - continue; - } - sb.append(c); - } - stripped = sb.toString(); - this.strippedStringCache.put(text, stripped); - } - text = stripped; - renderString(text, x, y, color, shadow); - } - - public int getWidthCacheSize() { - return this.stringWidthCache.size(); - } - - public void drawStringWithShadow(String text, double x, double y, Color color) { - drawString(text, x + 0.5, y + 0.5, Integer.MIN_VALUE); - drawString(text, x, y, color.getRGB()); - } - - public abstract void renderStringWithShadow(String text, double x, double y, Color color, Color shadowColor, boolean fallbackToVanilla); - - public void drawCenteredString(String text, double x, double y, Color color) { - drawCenteredString(text, x, y, color.getRGB()); - } - - public abstract void drawStringWithShadow(String text, double x, double y, Color color, boolean fallbackToVanilla); - - public int getFontSize() { - return this.fontSize; - } - - public void drawStringWithShadow(String text, double x, double y, Color color, Color shadowColor) { - renderStringWithShadow(text, x, y, color, shadowColor, false); - } - - public SmoothFontRenderer() { - this.strippedStringCache = new SmoothFontRendererStringCache(this, 16, 0.75f, true); - } - - public abstract double getStringWidth(String text, boolean fallbackToVanilla); -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRendererStringCache.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRendererStringCache.java deleted file mode 100644 index d5bf28b..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRendererStringCache.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import java.util.LinkedHashMap; -import java.util.Map; - -public class SmoothFontRendererStringCache extends LinkedHashMap { - final SmoothFontRenderer L; - - @Override - protected boolean removeEldestEntry(Map.Entry entry) { - return this.size() > 5120; - } - - public SmoothFontRendererStringCache(SmoothFontRenderer smoothFontRenderer, int n, float f, boolean bl) { - super(n, f, bl); - this.L = smoothFontRenderer; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRendererWidthCache.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRendererWidthCache.java deleted file mode 100644 index e1c11d9..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/SmoothFontRendererWidthCache.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import java.util.LinkedHashMap; -import java.util.Map; - -public class SmoothFontRendererWidthCache extends LinkedHashMap { - final SmoothFontRenderer s; - - @Override - protected boolean removeEldestEntry(Map.Entry entry) { - return this.size() > 5120; - } - - public SmoothFontRendererWidthCache(SmoothFontRenderer smoothFontRenderer, int n, float f, boolean bl) { - super(n, f, bl); - this.s = smoothFontRenderer; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/StbFontManager.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/StbFontManager.java deleted file mode 100644 index 63c7485..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/StbFontManager.java +++ /dev/null @@ -1,79 +0,0 @@ -package cn.xiaozhou233.orangex.font; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -public class StbFontManager { - private byte[] proximaData; - private byte[] proximaBoldData; - private byte[] notoData; - private byte[] poppinsData; - private byte[] jelloMediumData; - - private final ConcurrentMap regularFonts = new ConcurrentHashMap<>(); - private final ConcurrentMap boldFonts = new ConcurrentHashMap<>(); - private final ConcurrentMap notoFonts = new ConcurrentHashMap<>(); - private final ConcurrentMap poppinsFonts = new ConcurrentHashMap<>(); - private final ConcurrentMap jelloMediumFonts = new ConcurrentHashMap<>(); - - private boolean initialized = false; - - public void loadFonts() { - this.proximaData = readResource("proxima.ttf"); - this.proximaBoldData = readResource("proximabd.ttf"); - this.notoData = readResource("noto.ttf"); - this.poppinsData = readResource("poppins_rg.ttf"); - this.jelloMediumData = readResource("JelloMedium.ttf"); - this.initialized = true; - } - - private byte[] readResource(String path) { - try { - InputStream is = StbFontManager.class.getClassLoader().getResourceAsStream("fonts/" + path); - if (is == null) return null; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buf = new byte[8192]; - int len; - while ((len = is.read(buf)) != -1) { - baos.write(buf, 0, len); - } - is.close(); - return baos.toByteArray(); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public SmoothFontRenderer getProxima(int size) { - return getFont(regularFonts, proximaData, size, "Proxima"); - } - - public SmoothFontRenderer getProximaBold(int size) { - return getFont(boldFonts, proximaBoldData, size, "Proxima Bold"); - } - - public SmoothFontRenderer getNoto(int size) { - return getFont(notoFonts, notoData, size, "Noto"); - } - - public SmoothFontRenderer getPoppins(int size) { - return getFont(poppinsFonts, poppinsData, size, "Poppins"); - } - - public SmoothFontRenderer getJelloMedium(int size) { - return getFont(jelloMediumFonts, jelloMediumData, size, "Jello Medium"); - } - - private SmoothFontRenderer getFont(ConcurrentMap cache, byte[] data, int size, String name) { - if (!cache.containsKey(size)) { - if (data == null) return null; - LegacySmoothFontRenderer renderer = new LegacySmoothFontRenderer(data, size, name); - cache.put(size, renderer); - return renderer; - } - return cache.get(size); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/shader/ShaderProgram.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/shader/ShaderProgram.java deleted file mode 100644 index 944c514..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/shader/ShaderProgram.java +++ /dev/null @@ -1,65 +0,0 @@ -package cn.xiaozhou233.orangex.font.shader; - -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL20; - -import java.nio.IntBuffer; - -public class ShaderProgram { - private static int currentProgramId = -1; - int previousProgramId; - int vertexShaderId = 0; - int fragmentShaderId = 0; - boolean linked; - int programId = GL20.glCreateProgram(); - - public ShaderProgram(String vertexShaderSource, String fragmentShaderSource) { - this.vertexShaderId = GL20.glCreateShader(GL20.GL_VERTEX_SHADER); - this.fragmentShaderId = GL20.glCreateShader(GL20.GL_FRAGMENT_SHADER); - - GL20.glShaderSource(this.vertexShaderId, vertexShaderSource); - GL20.glShaderSource(this.fragmentShaderId, fragmentShaderSource); - GL20.glCompileShader(this.vertexShaderId); - GL20.glCompileShader(this.fragmentShaderId); - - GL20.glAttachShader(this.programId, this.vertexShaderId); - GL20.glAttachShader(this.programId, this.fragmentShaderId); - GL20.glLinkProgram(this.programId); - - IntBuffer linkStatus = BufferUtils.createIntBuffer(1); - GL20.glGetProgram(this.programId, GL20.GL_LINK_STATUS, linkStatus); - this.linked = linkStatus.get(0) == 1; - } - - public boolean isLinked() { - return this.linked; - } - - public int getProgramId() { - return this.programId; - } - - public void restorePreviousProgram() { - useProgram(this.previousProgramId); - } - - public static void useProgram(int programId) { - GL20.glUseProgram(programId); - currentProgramId = programId; - } - - public static int getCurrentProgramId() { - if (currentProgramId == -1) { - currentProgramId = GL11.glGetInteger(GL20.GL_CURRENT_PROGRAM); - } - return currentProgramId; - } - - public boolean bind() { - if (!this.linked) return false; - this.previousProgramId = getCurrentProgramId(); - useProgram(this.programId); - return true; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbByteBufferView.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbByteBufferView.java deleted file mode 100644 index 7aae2cc..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbByteBufferView.java +++ /dev/null @@ -1,28 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public final class StbByteBufferView { - public byte[] f; - public int y; - public int C; - public int h; - - public StbByteBufferView() { - this(null, 0, 0); - } - - public StbByteBufferView(byte[] data, int offset, int length) { - this.f = data; - this.C = offset; - this.h = 0; - this.y = length; - } - - public StbByteBufferView k() { - StbByteBufferView copy = new StbByteBufferView(); - copy.f = this.f; - copy.C = this.C; - copy.h = this.h; - copy.y = this.y; - return copy; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeActiveEdge.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeActiveEdge.java deleted file mode 100644 index 34bb61b..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeActiveEdge.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeActiveEdge { - public float j; - public float e; - public float N; - public float m; - public StbTrueTypeActiveEdge l; - public float T; - public float L; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeAlignedQuad.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeAlignedQuad.java deleted file mode 100644 index e3e6a1c..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeAlignedQuad.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeAlignedQuad { - public float K; - public float G; - public float C; - public float x; - public float v; - public float M; - public float O; - public float S; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeBakedChar.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeBakedChar.java deleted file mode 100644 index 12a3c7b..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeBakedChar.java +++ /dev/null @@ -1,11 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeBakedChar { - public int V; - public float k; - public float l; - public int D; - public float B; - public int U; - public int Q; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeBitmap.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeBitmap.java deleted file mode 100644 index 943911a..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeBitmap.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeBitmap { - public byte[] E; - public int c; - public int K; - public int h; - public int A; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeCharStringContext.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeCharStringContext.java deleted file mode 100644 index 027d68d..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeCharStringContext.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeCharStringContext { - public int Z; - public int c; - public int q; - public float p; - public int v; - public float o; - public float s; - public float C; - public int J; - public int y; - public int f; - public StbTrueTypeVertex[] V; - - public StbTrueTypeCharStringContext(int n) { - this.J = n; - this.v = 0; - this.s = 0.0f; - this.p = 0.0f; - this.C = 0.0f; - this.o = 0.0f; - this.y = 0; - this.c = 0; - this.Z = 0; - this.f = 0; - this.V = null; - this.q = 0; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeEdge.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeEdge.java deleted file mode 100644 index 40162d1..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeEdge.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeEdge { - public float u; - public float d; - public int W; - public float X; - public float i; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeFontInfo.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeFontInfo.java deleted file mode 100644 index 86ec8c9..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeFontInfo.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeFontInfo { - public int h; - public int G; - public StbByteBufferView H; - public int Y; - public int L; - public int Q; - public int U; - public StbByteBufferView g = new StbByteBufferView(); - public int c; - public StbByteBufferView j; - public byte[] S; - public StbByteBufferView z = new StbByteBufferView(); - public StbByteBufferView J; - public int d; - public int T; - public int w; - public StbByteBufferView N; - public int v; - public int p; - - public StbTrueTypeFontInfo() { - this.j = new StbByteBufferView(); - this.J = new StbByteBufferView(); - this.H = new StbByteBufferView(); - this.N = new StbByteBufferView(); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeGlyphPackNode.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeGlyphPackNode.java deleted file mode 100644 index 9c15a28..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeGlyphPackNode.java +++ /dev/null @@ -1,5 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeGlyphPackNode { - public int z; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeKerningEntry.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeKerningEntry.java deleted file mode 100644 index 609a342..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeKerningEntry.java +++ /dev/null @@ -1,7 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeKerningEntry { - public int y; - public int q; - public int o; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackAtlasState.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackAtlasState.java deleted file mode 100644 index 0e536fa..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackAtlasState.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypePackAtlasState { - public int F; - public int a; - public int n; - public int f; - public int t; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackContext.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackContext.java deleted file mode 100644 index dce6bdd..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackContext.java +++ /dev/null @@ -1,14 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypePackContext { - public int d; - public StbTrueTypeGlyphPackNode[] j; - public int m; - public int h; - public int G; - public int b; - public StbTrueTypePackAtlasState J; - public int c; - public int w; - public byte[] X; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackRange.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackRange.java deleted file mode 100644 index 2d6fa84..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackRange.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypePackRange { - public int y; - public int R; - public int[] N; - public StbTrueTypePackedChar[] M; - public int i; - public float E; - private static String[] j; - public int b; - - public static void t(String[] stringArray) { - j = stringArray; - } - - public static String[] x() { - return j; - } - - static { - if (StbTrueTypePackRange.x() != null) { - StbTrueTypePackRange.t(new String[1]); - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackRectangle.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackRectangle.java deleted file mode 100644 index 531a27e..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackRectangle.java +++ /dev/null @@ -1,10 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypePackRectangle { - public int e; - public int J; - public int P; - public int M; - public int N; - public int q; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackedChar.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackedChar.java deleted file mode 100644 index 5cf6b24..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePackedChar.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypePackedChar { - public int p; - public int q; - public float R; - public int k; - public float A; - public int b; - public float G; - public float t; - public float s; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePoint.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePoint.java deleted file mode 100644 index 2369b69..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypePoint.java +++ /dev/null @@ -1,6 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypePoint { - public float E; - public float M; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeVertex.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeVertex.java deleted file mode 100644 index baa9dd9..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/font/stb/StbTrueTypeVertex.java +++ /dev/null @@ -1,12 +0,0 @@ -package cn.xiaozhou233.orangex.font.stb; - -public class StbTrueTypeVertex { - public short h; - public int O; - public short H; - public short a; - public short D; - public short s; - public int v; - public short f; -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/manager/ThreadManager.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/manager/ThreadManager.java deleted file mode 100644 index 76d2de4..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/manager/ThreadManager.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.xiaozhou233.orangex.manager; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.EventTimerThread; -import lombok.Getter; - -@Getter -public class ThreadManager { - - private Thread timerThread; - private volatile boolean running = false; - - private static final long TIMER_INTERVAL_MS = 5L; - - public void init() { - if (running) { - return; - } - - running = true; - - timerThread = new Thread(() -> { - while (running && !Thread.currentThread().isInterrupted()) { - OrangeX.getInstance() - .getEventBus() - .post(new EventTimerThread()); - - try { - Thread.sleep(TIMER_INTERVAL_MS); - } catch (InterruptedException e) { - break; - } - } - }, "OrangeX-Timer"); - - timerThread.start(); - - Runtime.getRuntime().addShutdownHook( - new Thread(this::shutdown, "OrangeX-Timer-Shutdown") - ); - } - - public void shutdown() { - running = false; - if (timerThread != null) { - timerThread.interrupt(); - } - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/MixinManager.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/MixinManager.java deleted file mode 100644 index 6f6d174..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/MixinManager.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.xiaozhou233.orangex.mixin; - -import cn.xiaozhou233.orangex.utils.IOUtils; -import cn.xiaozhou233.orangex.mixin.impl.*; -import cn.xiaozhou233.orangex.utils.JuiceAgentFacade; -import cn.yapeteam.ymixin.Transformer; -import cn.yapeteam.ymixin.YMixin; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; - -public final class MixinManager { - - public void start() { - - ClassLoader cl = MixinManager.class.getClassLoader(); - - // Check Obfuscation - String content = null; - try { - Class.forName("net.minecraft.client.Minecraft"); - } catch (ClassNotFoundException e) { - System.out.println("[OrangeX] Obfuscation detected, use mapping."); - InputStream stream = MixinManager.class.getResourceAsStream("/joined.srg"); - - try { - content = new String( - IOUtils.toByteArray(stream), - StandardCharsets.UTF_8 - ); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - YMixin.init( - className -> { - try { - return Class.forName( - className.replace("/", "."), - false, - cl - ); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - }, - clazz -> { - byte[] classBytes = JuiceAgentFacade.getClassBytes(clazz); - if (classBytes == null) { - throw new RuntimeException( - "ClassBytes null: " + clazz.getName() - ); - } - return classBytes; - }, - null, - null, - content - ); - - Transformer transformer = new Transformer(); - try { - transformer.addMixin(MixinMinecraft.class); - transformer.addMixin(MixinGuiIngame.class); - transformer.addMixin(MixinEntityRenderer.class); - transformer.addMixin(MixinNetHandlerPlayClient.class); - } catch (Throwable e) { - throw new RuntimeException("Failed to add mixin", e); - } - - transformer.transform().forEach((name, bytes) -> { - try { - Class targetClass = Class.forName(name, false, cl); - boolean ok = JuiceAgentFacade.retransformClass(targetClass, bytes); - if (!ok) { - throw new RuntimeException("Redefine failed: " + name); - } - System.out.println("[OrangeX] Redefined class: " + name); - } catch (Throwable e) { - throw new RuntimeException( - "Failed to redefine class: " + name, - e - ); - } - }); - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinEntityRenderer.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinEntityRenderer.java deleted file mode 100644 index bcbee06..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinEntityRenderer.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.xiaozhou233.orangex.mixin.impl; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.EventRender3D; -import cn.yapeteam.ymixin.annotations.Inject; -import cn.yapeteam.ymixin.annotations.Local; -import cn.yapeteam.ymixin.annotations.Mixin; -import cn.yapeteam.ymixin.annotations.Target; -import net.minecraft.client.renderer.EntityRenderer; - -@Mixin(EntityRenderer.class) -public class MixinEntityRenderer { - - @Inject( - method = "renderWorldPass", desc = "(IFJ)V", - target = @Target( - value = "INVOKESTATIC", - target = "net/minecraft/client/renderer/GlStateManager.disableFog()V", - shift = Target.Shift.AFTER - ) - ) - private void render(@Local(source = "partialTicks", index = 2) float partialTicks) { - OrangeX.getInstance().getEventBus().post(new EventRender3D(partialTicks)); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinGuiIngame.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinGuiIngame.java deleted file mode 100644 index 60bbbdc..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinGuiIngame.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.xiaozhou233.orangex.mixin.impl; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.EventRender2D; -import cn.xiaozhou233.orangex.font.SmoothFontRenderer; -import cn.yapeteam.ymixin.annotations.Inject; -import cn.yapeteam.ymixin.annotations.Local; -import cn.yapeteam.ymixin.annotations.Mixin; -import cn.yapeteam.ymixin.annotations.Target; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiIngame; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import org.lwjgl.opengl.GL11; - -@Mixin(GuiIngame.class) -public class MixinGuiIngame { - - @Inject(method = "renderGameOverlay", desc = "(F)V", target = @Target("HEAD")) - public void onRenderGameOverlay(@Local(source = "partialTicks", index = 1) float partialTicks) { - Minecraft mc = Minecraft.getMinecraft(); - ScaledResolution sr = new ScaledResolution(mc); - - GlStateManager.pushMatrix(); - GlStateManager.disableDepth(); - GlStateManager.disableLighting(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate( - GL11.GL_SRC_ALPHA, - GL11.GL_ONE_MINUS_SRC_ALPHA, - GL11.GL_ONE, - GL11.GL_ZERO - ); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - mc.entityRenderer.setupOverlayRendering(); - - OrangeX.getInstance().getEventBus().post(new EventRender2D(partialTicks)); - - GlStateManager.enableDepth(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinMinecraft.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinMinecraft.java deleted file mode 100644 index d20311d..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinMinecraft.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.xiaozhou233.orangex.mixin.impl; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.*; -import cn.yapeteam.ymixin.annotations.Inject; -import cn.yapeteam.ymixin.annotations.Local; -import cn.yapeteam.ymixin.annotations.Mixin; -import cn.yapeteam.ymixin.annotations.Target; - -import net.minecraft.client.Minecraft; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -@Mixin(Minecraft.class) -public class MixinMinecraft { - int i = 0; - - @Inject(method = "runGameLoop", desc = "()V", target = @Target("HEAD")) - private void onLoop() { - OrangeX.getInstance().getEventBus().post(new EventLoop()); - } - - @Inject(method = "runTick", desc = "()V", target = @Target("HEAD")) - public void onTick() { - OrangeX.getInstance().getEventBus().post(new EventTick()); - } - - @Inject(method = "shutdownMinecraftApplet", desc = "()V", target = @Target("HEAD")) - public void onShutdown() { - OrangeX.getInstance().stop(); - } - - @Inject( - method = "runTick", desc = "()V", - target = @Target( - value = "INVOKESTATIC", - target = "org/lwjgl/input/Keyboard.getEventKeyState()Z", - shift = Target.Shift.AFTER - ) - ) - public void onKey(@Local(source = "key", index = 1) int key) { - if (Minecraft.getMinecraft().currentScreen == null && Keyboard.getEventKeyState()) - OrangeX.getInstance().getEventBus().post(new EventKey(key)); - } - - @Inject(method = "loadWorld", desc = "(Lnet/minecraft/client/multiplayer/WorldClient;Ljava/lang/String;)V", target = @Target("HEAD")) - public void onLoadWorld() { - OrangeX.getInstance().getEventBus().post(new EventWorldLoad()); - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinNetHandlerPlayClient.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinNetHandlerPlayClient.java deleted file mode 100644 index e70b4e4..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/mixin/impl/MixinNetHandlerPlayClient.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.xiaozhou233.orangex.mixin.impl; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.EventPacketSend; -import cn.yapeteam.ymixin.annotations.Inject; -import cn.yapeteam.ymixin.annotations.Local; -import cn.yapeteam.ymixin.annotations.Mixin; -import cn.yapeteam.ymixin.annotations.Target; -import net.minecraft.client.network.NetHandlerPlayClient; -import net.minecraft.network.Packet; - -@Mixin(NetHandlerPlayClient.class) -public class MixinNetHandlerPlayClient { - @Inject( - method = "addToSendQueue", - desc = "(Lnet/minecraft/network/Packet;)V", - target = @Target("HEAD") - ) - public void onSendPacket(@Local(source = "packet", index = 1) Packet packet) { - EventPacketSend eventPacketSend = new EventPacketSend(packet); - OrangeX.getInstance().getEventBus().post(eventPacketSend); - - if (eventPacketSend.isCancelled()) { - return; - } - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/Module.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/Module.java deleted file mode 100644 index 2dd1429..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/Module.java +++ /dev/null @@ -1,82 +0,0 @@ -package cn.xiaozhou233.orangex.module; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.module.option.Option; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import org.lwjgl.input.Keyboard; - -import java.util.ArrayList; -import java.util.List; - -@Getter -public class Module { - protected static final Minecraft mc = Minecraft.getMinecraft(); - protected final String name; - protected final String description; - protected final ModuleCategory category; - @Setter - protected int key = Keyboard.KEY_NONE; - protected boolean enabled = false; - protected final List> options = new ArrayList<>(); - - public Module(String name, String description, ModuleCategory category) { - this.name = name; - this.description = description; - this.category = category; - } - - public Module(String name, String description, ModuleCategory category, int key) { - this(name, description, category); - this.key = key; - } - - public Module(String name, String description, ModuleCategory category, int key, boolean enabled) { - this(name, description, category, key); - this.enabled = enabled; - } - - public void addOption(Option option) { - options.add(option); - } - - protected void onEnable() { - System.out.println("[OrangeX] Enable " + name); - } - - protected void onDisable() { - System.out.println("[OrangeX] Disable " + name); - } - - public void setEnabled(boolean setEnabled) { - if (this.enabled == setEnabled) return; - - this.enabled = setEnabled; - - if (this.enabled) { - if (OrangeX.getInstance().getEventBus().isRegistered(this)) - return; - try { OrangeX.getInstance().getEventBus().register(this); } catch (Exception ignored) {} - onEnable(); - } else { - if (!OrangeX.getInstance().getEventBus().isRegistered(this)) - return; - try { OrangeX.getInstance().getEventBus().unregister(this); } catch (Exception ignored) {} - onDisable(); - } - } - - public void toggle() { - setEnabled(!this.enabled); - } - - public > T getOption(String name, Class clazz) { - for (Option option : options) { - if (option.getName().equalsIgnoreCase(name) && clazz.isInstance(option)) { - return clazz.cast(option); - } - } - return null; - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/ModuleCategory.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/ModuleCategory.java deleted file mode 100644 index beab66e..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/ModuleCategory.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.xiaozhou233.orangex.module; - -import lombok.Getter; - -@Getter -public enum ModuleCategory { - RENDER("Render"), - COMBAT("Combat"), - WORLD("World"), - MOVEMENT("Movement"), - PLAYER("Player"), - MISC("Misc"), - FUN("Fun"), - MINIGAME("Minigame"); - - - private final String name; - - - ModuleCategory(String name){ - this.name = name; - } - - -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/ModuleManager.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/ModuleManager.java deleted file mode 100644 index 9ab63ec..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/ModuleManager.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.xiaozhou233.orangex.module; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.config.ModuleConfig; -import cn.xiaozhou233.orangex.event.impl.EventKey; -import cn.xiaozhou233.orangex.module.impl.TestModule; -import cn.xiaozhou233.orangex.module.impl.render.*; -import lombok.Getter; -import org.greenrobot.eventbus.Subscribe; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -@Getter -public class ModuleManager { - public static String userHome = System.getProperty("user.home"); - private final List modules = new CopyOnWriteArrayList<>(); - private final ModuleConfig config; - - public ModuleManager() { - config = new ModuleConfig(userHome + "/.orangex/profile.json"); - } - - public void addModule(Module module) { - modules.add(module); - } - - public void registerModules() { - OrangeX.getInstance().getEventBus().register(this); - addModule(new TestModule()); - - // Combat - - // Render - addModule(new HUD()); - addModule(new ClickGUI()); - addModule(new ESP()); - addModule(new NameTag()); - } - - public List getModulesByCategory(ModuleCategory category) { - List result = new ArrayList<>(); - for (Module module : modules) { - if (module.getCategory() == category) { - result.add(module); - } - } - return result; - } - - @SuppressWarnings("unchecked") - public T getModule(Class clazz) { - for (Module module : modules) { - if (module.getClass() == clazz) { - return (T) module; - } - } - return null; - } - - public Module getModule(String name) { - for (Module module : modules) { - if (module.getName().equalsIgnoreCase(name)) { - return module; - } - } - return null; - } - - public void saveConfig() { - config.save(modules); - } - - public void loadConfig() { - config.load(modules); - } - - @Subscribe - public void onKeyDown(EventKey event) { - for (Module module : OrangeX.getInstance().getModuleManager().getModules()) { - if (module.getKey() == event.getKey()) { - module.toggle(); - } - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/TestModule.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/TestModule.java deleted file mode 100644 index bf3e801..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/TestModule.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.xiaozhou233.orangex.module.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import cn.xiaozhou233.orangex.module.option.impl.*; -import org.greenrobot.eventbus.Subscribe; -import org.lwjgl.input.Keyboard; - -import java.awt.event.KeyEvent; - -public class TestModule extends Module { - public TestModule() { - super("Test", "A test module", ModuleCategory.MISC); - - addOption(new BooleanOption("boolean", "Boolean option", this, true)); - addOption(new DoubleOption("double", "Double slider", this, 0.5, 0.0, 1.0, 0.05, 2)); - addOption(new IntOption("int", "Int slider", this, 10, 1, 100, 5)); - addOption(new ModeOption("mode", "Mode selector", this, "A", "A", "B", "C")); - addOption(new ColorOption("color", "ARGB color", this, 0xFFFF0000)); - addOption(new StringOption("string", "Text input", this, "hello", 32)); - } - - @Override - protected void onEnable() { - System.out.println("[OrangeX] TestModule enabled"); - } - - @Override - protected void onDisable() { - System.out.println("[OrangeX] TestModule disabled"); - } - - @Subscribe - public void onKey(KeyEvent event) { - - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/ClickGUI.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/ClickGUI.java deleted file mode 100644 index 3befd02..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/ClickGUI.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.xiaozhou233.orangex.module.impl.render; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import cn.xiaozhou233.orangex.ui.clickgui.ClickGUIScreen; -import org.lwjgl.input.Keyboard; - -public class ClickGUI extends Module { - public ClickGUI() { - super("ClickGUI", "ClickGUI", ModuleCategory.RENDER); - setEnabled(false); - setKey(Keyboard.KEY_RSHIFT); - } - - @Override - protected void onEnable() { - mc.displayGuiScreen(new ClickGUIScreen()); - setEnabled(false); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/ESP.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/ESP.java deleted file mode 100644 index 70a28f1..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/ESP.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.xiaozhou233.orangex.module.impl.render; - -import cn.xiaozhou233.orangex.event.impl.EventRender3D; -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import cn.xiaozhou233.orangex.module.option.impl.BooleanOption; -import cn.xiaozhou233.orangex.utils.RenderUtils; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.entity.player.EntityPlayer; -import org.greenrobot.eventbus.Subscribe; - -public class ESP extends Module { - - public ESP() { - super("ESP", "See entities through walls", ModuleCategory.RENDER); - - addOption(new BooleanOption("Render Self", "Render self", this, false)); - addOption(new BooleanOption("Render Players", "Render players", this, true)); - addOption(new BooleanOption("Render Villagers", "Render villagers", this, false)); - addOption(new BooleanOption("Render Mobs", "Render mobs", this, false)); - addOption(new BooleanOption("Render Animals", "Render animals", this, false)); - addOption(new BooleanOption("Render Items", "Render items", this, false)); - } - - @Subscribe - public void onRender3D(EventRender3D event) { - if (mc.theWorld == null || mc.thePlayer == null) return; - - BooleanOption renderSelf = getOption("Render Self", BooleanOption.class); - BooleanOption renderPlayers = getOption("Render Players", BooleanOption.class); - BooleanOption renderVillagers = getOption("Render Villagers", BooleanOption.class); - BooleanOption renderMobs = getOption("Render Mobs", BooleanOption.class); - BooleanOption renderAnimals = getOption("Render Animals", BooleanOption.class); - BooleanOption renderItems = getOption("Render Items", BooleanOption.class); - - for (Entity entity : mc.theWorld.loadedEntityList) { - if (entity == mc.thePlayer && !renderSelf.getValue()) - continue; - - if (entity instanceof EntityPlayer) { - if (!renderPlayers.getValue()) continue; - } else if (entity instanceof EntityVillager) { - if (!renderVillagers.getValue()) continue; - } else if (entity instanceof EntityAnimal) { - if (!renderAnimals.getValue()) continue; - } else if (entity instanceof EntityMob) { - if (!renderMobs.getValue()) continue; - } else if (entity instanceof EntityItem) { - if (!renderItems.getValue()) continue; - } else { - continue; - } - - RenderUtils.drawEntityBox(entity, event.getPartialTicks()); - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/HUD.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/HUD.java deleted file mode 100644 index c2a6cfe..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/HUD.java +++ /dev/null @@ -1,137 +0,0 @@ -package cn.xiaozhou233.orangex.module.impl.render; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.EventRender2D; -import cn.xiaozhou233.orangex.font.SmoothFontRenderer; -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.gui.Gui; -import org.greenrobot.eventbus.Subscribe; - -import java.awt.*; -import java.util.Comparator; -import java.util.List; -import java.util.stream.Collectors; - -public class HUD extends Module { - - private SmoothFontRenderer font; - private SmoothFontRenderer listFont; - - @Getter - @Setter - private int x = 10; - - @Getter - @Setter - private int y = 10; - - @Getter - @Setter - private int listOffsetY = 10; - - @Getter - @Setter - private boolean rainbow = true; - - @Getter - @Setter - private boolean showList = true; - - @Getter - @Setter - private boolean listBackground = true; - - @Getter - @Setter - private int backgroundAlpha = 140; - - @Getter - @Setter - private int barWidth = 3; - - public HUD() { - super("HUD", "Render HUD", ModuleCategory.RENDER); - setEnabled(true); - } - - private void renderLogo() { - font.drawString("Orange",x,y,0xFFFFA500); - font.drawString("X",x + font.getStringWidth("Orange"),y,getRainbow(1500)); - } - - private void renderList() { - if (!showList) - return; - - List modules = - OrangeX.getInstance() - .getModuleManager() - .getModules() - .stream() - .filter(Module::isEnabled) - .sorted(Comparator.comparingDouble(m -> -listFont.getStringWidth(m.getName()))) - .collect(Collectors.toList()); - - int lineHeight = (int) listFont.getStringHeight("LOL"); - int listY = y + (int) font.getStringHeight("Orange") + listOffsetY; - - int height = modules.size() * lineHeight; - int width = 0; - - for (Module module : modules) { - width = (int) Math.max(width,listFont.getStringWidth(module.getName())); - } - - width += 12; - - if (listBackground) { - Gui.drawRect( - x - 5, - listY - 3, - x + width, - listY + height + 3, - (backgroundAlpha << 24) - ); - - for (int i = 0; i < height + 6; i++) { - Gui.drawRect( - x - 5, - listY - 3 + i, - x - 5 + barWidth, - listY - 2 + i, - getRainbow(i * 20) - ); - } - } - - int index = 0; - - for (Module module : modules) { - int color = rainbow ? getRainbow(index * 350) : 0xFFFFFFFF; - - listFont.drawString(module.getName(),x + 5,listY,color); - - listY += lineHeight; - index++; - } - } - - @Subscribe - public void onRender2D(EventRender2D event) { - if (font == null) { - font = OrangeX.getInstance().getStbFontManager().getJelloMedium(44); - listFont = OrangeX.getInstance().getStbFontManager().getProxima(22); - } - - renderLogo(); - renderList(); - } - - private int getRainbow(long offset) { - float hue = ((System.currentTimeMillis() + offset) % 8000L) / 8000.0f; - return Color.HSBtoRGB(hue,0.7f,1.0f); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/NameTag.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/NameTag.java deleted file mode 100644 index c25dec8..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/impl/render/NameTag.java +++ /dev/null @@ -1,191 +0,0 @@ -package cn.xiaozhou233.orangex.module.impl.render; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.event.impl.EventRender2D; -import cn.xiaozhou233.orangex.event.impl.EventRender3D; -import cn.xiaozhou233.orangex.font.SmoothFontRenderer; -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import cn.xiaozhou233.orangex.module.option.impl.BooleanOption; -import cn.xiaozhou233.orangex.module.option.impl.ColorOption; -import cn.xiaozhou233.orangex.module.option.impl.IntOption; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.player.EntityPlayer; -import org.greenrobot.eventbus.Subscribe; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL11; - -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.List; - -public class NameTag extends Module { - private SmoothFontRenderer font; - private final IntBuffer viewport = BufferUtils.createIntBuffer(16); - private final FloatBuffer modelview = BufferUtils.createFloatBuffer(16); - private final FloatBuffer projection = BufferUtils.createFloatBuffer(16); - private final FloatBuffer screenCoords = BufferUtils.createFloatBuffer(3); - private final List renderQueue = new ArrayList<>(); - - public NameTag() { - super("NameTag", "Render name tag", ModuleCategory.RENDER); - addOption(new BooleanOption("Render Players", "Render players", this, true)); - addOption(new BooleanOption("Render Self", "Render self", this, false)); - addOption(new BooleanOption("Show Health", "Show health", this, true)); - addOption(new BooleanOption("Background", "Show background", this, true)); - addOption(new IntOption("Font Size", "Font size", this, 18, 12, 30, 2)); - addOption(new ColorOption("Text Color", "Text color", this, 0xFFFFFFFF)); - addOption(new ColorOption("Background Color", "Background color", this, 0x80000000)); - } - - @Subscribe - public void onRender3D(EventRender3D event) { - if (mc.theWorld == null || mc.thePlayer == null) return; - - renderQueue.clear(); - - BooleanOption renderPlayers = getOption("Render Players", BooleanOption.class); - BooleanOption renderSelf = getOption("Render Self", BooleanOption.class); - BooleanOption showHealth = getOption("Show Health", BooleanOption.class); - - GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelview); - GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projection); - GL11.glGetInteger(GL11.GL_VIEWPORT, viewport); - - for (Object obj : mc.theWorld.loadedEntityList) { - if (!(obj instanceof EntityPlayer)) continue; - EntityPlayer player = (EntityPlayer) obj; - - if (player == mc.thePlayer && !renderSelf.getValue()) continue; - if (player != mc.thePlayer && !renderPlayers.getValue()) continue; - if (player.isDead) continue; - - double x = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks(); - double y = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks(); - double z = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks(); - - float height = player.height + 0.5f; - - project( - (float) (x - mc.getRenderManager().viewerPosX), - (float) (y - mc.getRenderManager().viewerPosY + height), - (float) (z - mc.getRenderManager().viewerPosZ), - modelview, projection, viewport, screenCoords - ); - - float screenZ = screenCoords.get(2); - if (screenZ >= 1.0f) continue; - - int scaleFactor = new ScaledResolution(mc).getScaleFactor(); - float screenX = (float) Math.floor(screenCoords.get(0) / scaleFactor); - float screenY = (float) Math.floor((mc.displayHeight - screenCoords.get(1)) / scaleFactor); - - String name = player.getDisplayName().getFormattedText(); - String healthText = ""; - - if (showHealth.getValue()) { - float health = player.getHealth(); - float maxHealth = player.getMaxHealth(); - String healthColor = health > maxHealth * 0.5f ? "\u00a7a" : - health > maxHealth * 0.25f ? "\u00a7e" : "\u00a7c"; - healthText = " " + healthColor + "[" + (int) Math.ceil(health) + "/" + (int) Math.ceil(maxHealth) + "]"; - } - - String fullText = name + healthText; - renderQueue.add(new NametagEntry(fullText, screenX, screenY)); - } - } - - @Subscribe - public void onRender2D(EventRender2D event) { - if (renderQueue.isEmpty()) return; - - IntOption fontSize = getOption("Font Size", IntOption.class); - int size = fontSize.getValue(); - if (font == null || font.getFontSize() != size) { - font = OrangeX.getInstance().getStbFontManager().getProxima(size); - } - - BooleanOption showBackground = getOption("Background", BooleanOption.class); - ColorOption textColor = getOption("Text Color", ColorOption.class); - ColorOption bgColor = getOption("Background Color", ColorOption.class); - - for (NametagEntry entry : renderQueue) { - String fullText = entry.text; - double textWidth = font.getStringWidth(fullText); - double textHeight = font.getStringHeight(fullText); - - double renderX = entry.screenX - textWidth / 2; - double renderY = entry.screenY - textHeight; - - if (showBackground.getValue()) { - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); - int bg = bgColor.getValue(); - GL11.glBegin(GL11.GL_QUADS); - GL11.glColor4f( - (float) (bg >> 16 & 0xFF) / 255.0f, - (float) (bg >> 8 & 0xFF) / 255.0f, - (float) (bg & 0xFF) / 255.0f, - (float) (bg >> 24 & 0xFF) / 255.0f - ); - double bw = textWidth / 2 + 3; - double bh = textHeight + 1; - GL11.glVertex2d(entry.screenX - bw, renderY - 1); - GL11.glVertex2d(entry.screenX - bw, renderY + bh); - GL11.glVertex2d(entry.screenX + bw, renderY + bh); - GL11.glVertex2d(entry.screenX + bw, renderY - 1); - GL11.glEnd(); - GlStateManager.disableBlend(); - GlStateManager.enableTexture2D(); - } - - font.renderString(fullText, renderX + 0.5, renderY + 0.5, 0x80000000, false); - font.renderString(fullText, renderX, renderY, textColor.getValue(), false); - } - - renderQueue.clear(); - } - - private static void project(float x, float y, float z, - FloatBuffer modelview, FloatBuffer projection, - IntBuffer viewport, FloatBuffer screenCoords) { - float[] v = new float[4]; - float[] c = new float[4]; - - v[0] = modelview.get(0) * x + modelview.get(4) * y + modelview.get(8) * z + modelview.get(12); - v[1] = modelview.get(1) * x + modelview.get(5) * y + modelview.get(9) * z + modelview.get(13); - v[2] = modelview.get(2) * x + modelview.get(6) * y + modelview.get(10) * z + modelview.get(14); - v[3] = modelview.get(3) * x + modelview.get(7) * y + modelview.get(11) * z + modelview.get(15); - - c[0] = projection.get(0) * v[0] + projection.get(4) * v[1] + projection.get(8) * v[2] + projection.get(12) * v[3]; - c[1] = projection.get(1) * v[0] + projection.get(5) * v[1] + projection.get(9) * v[2] + projection.get(13) * v[3]; - c[2] = projection.get(2) * v[0] + projection.get(6) * v[1] + projection.get(10) * v[2] + projection.get(14) * v[3]; - c[3] = projection.get(3) * v[0] + projection.get(7) * v[1] + projection.get(11) * v[2] + projection.get(15) * v[3]; - - if (c[3] == 0.0f) return; - - float ndcX = c[0] / c[3]; - float ndcY = c[1] / c[3]; - float ndcZ = c[2] / c[3]; - - screenCoords.put(0, viewport.get(0) + viewport.get(2) * (ndcX + 1.0f) / 2.0f); - screenCoords.put(1, viewport.get(1) + viewport.get(3) * (ndcY + 1.0f) / 2.0f); - screenCoords.put(2, (ndcZ + 1.0f) / 2.0f); - } - - private static class NametagEntry { - final String text; - final float screenX; - final float screenY; - - NametagEntry(String text, float screenX, float screenY) { - this.text = text; - this.screenX = screenX; - this.screenY = screenY; - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/Option.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/Option.java deleted file mode 100644 index b7f1bab..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/Option.java +++ /dev/null @@ -1,31 +0,0 @@ -package cn.xiaozhou233.orangex.module.option; - -import cn.xiaozhou233.orangex.module.Module; -import com.google.gson.JsonElement; -import lombok.Getter; -import lombok.Setter; - -@Getter -public abstract class Option { - protected final String name; - protected final String description; - protected final Module parent; - @Setter - protected T value; - protected final T defaultValue; - - public Option(String name, String description, Module parent, T defaultValue) { - this.name = name; - this.description = description; - this.parent = parent; - this.defaultValue = defaultValue; - this.value = defaultValue; - } - - public void reset() { - this.value = defaultValue; - } - - public abstract JsonElement serialize(); - public abstract void deserialize(JsonElement element); -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/OptionSerializer.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/OptionSerializer.java deleted file mode 100644 index 361d052..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/OptionSerializer.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.xiaozhou233.orangex.module.option; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -import java.util.List; - -public class OptionSerializer { - public static JsonObject toJson(List> options) { - JsonObject json = new JsonObject(); - for (Option option : options) { - json.add(option.getName(), option.serialize()); - } - return json; - } - - public static void fromJson(JsonObject json, List> options) { - if (json == null) return; - for (Option option : options) { - JsonElement element = json.get(option.getName()); - if (element != null) { - option.deserialize(element); - } - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/BooleanOption.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/BooleanOption.java deleted file mode 100644 index b82f207..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/BooleanOption.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.xiaozhou233.orangex.module.option.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class BooleanOption extends Option { - public BooleanOption(String name, String description, Module parent, Boolean defaultValue) { - super(name, description, parent, defaultValue); - } - - @Override - public JsonElement serialize() { - return new JsonPrimitive(value); - } - - @Override - public void deserialize(JsonElement element) { - this.value = element.getAsBoolean(); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/ColorOption.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/ColorOption.java deleted file mode 100644 index ff16ab2..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/ColorOption.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.xiaozhou233.orangex.module.option.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class ColorOption extends Option { - public ColorOption(String name, String description, Module parent, Integer defaultValue) { - super(name, description, parent, defaultValue); - } - - @Override - public JsonElement serialize() { - return new JsonPrimitive(String.format("0x%08X", value)); - } - - @Override - public void deserialize(JsonElement element) { - String raw = element.getAsString(); - if (raw.startsWith("0x") || raw.startsWith("0X")) { - this.value = (int) Long.parseLong(raw.substring(2), 16); - } else { - this.value = Integer.parseUnsignedInt(raw); - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/DoubleOption.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/DoubleOption.java deleted file mode 100644 index bd415dc..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/DoubleOption.java +++ /dev/null @@ -1,46 +0,0 @@ -package cn.xiaozhou233.orangex.module.option.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import lombok.Getter; - -@Getter -public class DoubleOption extends Option { - private final double min; - private final double max; - private final double step; - private final int precision; - - public DoubleOption(String name, String description, Module parent, - Double defaultValue, double min, double max, double step, int precision) { - super(name, description, parent, clamp(defaultValue, min, max)); - this.min = min; - this.max = max; - this.step = step; - this.precision = precision; - } - - @Override - public void setValue(Double value) { - double clamped = clamp(value, min, max); - double stepped = Math.round(clamped / step) * step; - double factor = Math.pow(10, precision); - this.value = Math.round(stepped * factor) / factor; - } - - @Override - public JsonElement serialize() { - return new JsonPrimitive(value); - } - - @Override - public void deserialize(JsonElement element) { - setValue(element.getAsDouble()); - } - - private static double clamp(double v, double min, double max) { - return Math.min(max, Math.max(min, v)); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/IntOption.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/IntOption.java deleted file mode 100644 index d02c58f..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/IntOption.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.xiaozhou233.orangex.module.option.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import lombok.Getter; - -@Getter -public class IntOption extends Option { - private final int min; - private final int max; - private final int step; - - public IntOption(String name, String description, Module parent, - Integer defaultValue, int min, int max, int step) { - super(name, description, parent, clamp(defaultValue, min, max)); - this.min = min; - this.max = max; - this.step = step; - } - - @Override - public void setValue(Integer value) { - this.value = clamp(value, min, max); - } - - @Override - public JsonElement serialize() { - return new JsonPrimitive(value); - } - - @Override - public void deserialize(JsonElement element) { - setValue(element.getAsInt()); - } - - private static int clamp(int v, int min, int max) { - return Math.min(max, Math.max(min, v)); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/ModeOption.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/ModeOption.java deleted file mode 100644 index cdd4df1..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/ModeOption.java +++ /dev/null @@ -1,83 +0,0 @@ -package cn.xiaozhou233.orangex.module.option.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; -import lombok.Getter; - -import java.util.Arrays; - -@Getter -public class ModeOption extends Option { - private final String[] modes; - - public ModeOption(String name, String description, Module parent, - String defaultValue, String... modes) { - super(name, description, parent, defaultValue); - this.modes = modes; - } - - @Override - public void setValue(String value) { - for (String mode : modes) { - if (mode.equalsIgnoreCase(value)) { - this.value = mode; - return; - } - } - this.value = modes.length > 0 ? modes[0] : value; - } - - public int getIndex() { - for (int i = 0; i < modes.length; i++) { - if (modes[i].equals(value)) return i; - } - return 0; - } - - public void cycle() { - int next = (getIndex() + 1) % modes.length; - this.value = modes[next]; - } - - public void cycleReverse() { - int prev = (getIndex() - 1 + modes.length) % modes.length; - this.value = modes[prev]; - } - - @Override - public JsonElement serialize() { - return new JsonPrimitive(value); - } - - @Override - public void deserialize(JsonElement element) { - setValue(element.getAsString()); - } - - public void next() { - - int index = getIndex(); - - index++; - - if(index >= modes.length) - index = 0; - - setValue(modes[index]); - } - - - public void previous() { - - int index = getIndex(); - - index--; - - if(index < 0) - index = modes.length - 1; - - setValue(modes[index]); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/StringOption.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/StringOption.java deleted file mode 100644 index 9a56eaf..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/module/option/impl/StringOption.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.xiaozhou233.orangex.module.option.impl; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import com.google.gson.JsonElement; -import com.google.gson.JsonPrimitive; - -public class StringOption extends Option { - private final int maxLength; - - public StringOption(String name, String description, Module parent, - String defaultValue, int maxLength) { - super(name, description, parent, defaultValue); - this.maxLength = maxLength; - } - - @Override - public void setValue(String value) { - if (maxLength > 0 && value.length() > maxLength) { - this.value = value.substring(0, maxLength); - } else { - this.value = value; - } - } - - @Override - public JsonElement serialize() { - return new JsonPrimitive(value); - } - - @Override - public void deserialize(JsonElement element) { - setValue(element.getAsString()); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/ClickGUIScreen.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/ClickGUIScreen.java deleted file mode 100644 index e8cba93..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/ClickGUIScreen.java +++ /dev/null @@ -1,222 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui; - -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.ui.clickgui.component.impl.ModuleButton; -import com.google.gson.JsonObject; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiScreen; - -import org.lwjgl.input.Mouse; - -import java.awt.*; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -public class ClickGUIScreen extends GuiScreen { - - private final List panels = new ArrayList<>(); - - @Override - public void initGui() { - panels.clear(); - - int x = 20; - int y = 30; - int panelWidth = 120; - int gap = 20; - int rowHeight = 30; - - for (ModuleCategory category : ModuleCategory.values()) { - List categoryModules = OrangeX.getInstance() - .getModuleManager() - .getModulesByCategory(category); - - if (categoryModules.isEmpty()) - continue; - - if (x + panelWidth > this.width) { - x = 20; - y += 300 + rowHeight; - } - - Panel panel = new Panel( - category, - x, - y, - panelWidth, - 20 - ); - - int moduleY = 20; - - for (Module module : categoryModules) { - panel.addComponent( - new ModuleButton( - panel, - module, - 0, - moduleY - ) - ); - - moduleY += 20; - } - - panels.add(panel); - - x += panelWidth + gap; - } - - loadPanelPositions(); - } - - @Override - public void drawScreen( - int mouseX, - int mouseY, - float partialTicks - ) { - Gui.drawRect(0, 0, width, height, new Color(50, 50, 50, 100).getRGB()); - - for (Panel panel : panels) { - panel.drawScreen( - mouseX, - mouseY, - partialTicks - ); - } - - super.drawScreen( - mouseX, - mouseY, - partialTicks - ); - } - - @Override - protected void mouseClicked( - int mouseX, - int mouseY, - int mouseButton - ) throws java.io.IOException { - for (Panel panel : panels) { - panel.mouseClicked( - mouseX, - mouseY, - mouseButton - ); - } - - super.mouseClicked( - mouseX, - mouseY, - mouseButton - ); - } - - @Override - protected void mouseReleased( - int mouseX, - int mouseY, - int mouseButton - ) { - for (Panel panel : panels) { - panel.mouseReleased( - mouseX, - mouseY, - mouseButton - ); - } - - super.mouseReleased( - mouseX, - mouseY, - mouseButton - ); - } - - @Override - protected void keyTyped( - char typedChar, - int keyCode - ) throws java.io.IOException { - boolean consumed = false; - for (Panel panel : panels) { - if (panel.keyTyped(typedChar, keyCode)) - consumed = true; - } - - if (keyCode == 1 && !consumed) { - mc.displayGuiScreen(null); - } - - if (!consumed) { - super.keyTyped(typedChar, keyCode); - } - } - - @Override - public void handleMouseInput() throws IOException { - super.handleMouseInput(); - int wheel = Mouse.getEventDWheel(); - if (wheel != 0) { - int mx = Mouse.getEventX() * this.width / this.mc.displayWidth; - int my = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; - for (Panel panel : panels) { - if (panel.isMouseOver(mx, my)) { - panel.mouseWheel(wheel); - break; - } - } - } - } - - @Override - public boolean doesGuiPauseGame() { - return false; - } - - @Override - public void onGuiClosed() { - savePanelPositions(); - } - - private void savePanelPositions() { - JsonObject data = new JsonObject(); - - for (Panel panel : panels) { - JsonObject panelObj = new JsonObject(); - panelObj.addProperty("x", panel.getX()); - panelObj.addProperty("y", panel.getY()); - panelObj.addProperty("open", panel.isOpen()); - data.add(panel.getCategory().getName(), panelObj); - } - - OrangeX.getInstance() - .getModuleManager() - .getConfig() - .saveClickGui(data); - } - - private void loadPanelPositions() { - JsonObject data = OrangeX.getInstance() - .getModuleManager() - .getConfig() - .loadClickGui(); - - for (Panel panel : panels) { - String categoryName = panel.getCategory().getName(); - if (data.has(categoryName)) { - JsonObject panelObj = data.getAsJsonObject(categoryName); - panel.setX(panelObj.get("x").getAsInt()); - panel.setY(panelObj.get("y").getAsInt()); - if (panelObj.has("open")) { - panel.setOpen(panelObj.get("open").getAsBoolean()); - } - } - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/Panel.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/Panel.java deleted file mode 100644 index f6218be..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/Panel.java +++ /dev/null @@ -1,219 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.module.ModuleCategory; -import cn.xiaozhou233.orangex.ui.clickgui.component.Component; -import lombok.Getter; -import lombok.Setter; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.ScaledResolution; -import org.lwjgl.opengl.GL11; - -import java.util.ArrayList; -import java.util.List; - -@Getter -public class Panel { - - private final ModuleCategory category; - - @Setter - private int x; - @Setter - private int y; - - private final int width; - private final int height; - - private final int headerHeight = 20; - - @Setter - private boolean open = true; - - private boolean dragging; - - private int dragX; - private int dragY; - - private final List components = new ArrayList<>(); - - private int scrollOffset; - - private static final int MAX_VISIBLE_CONTENT_HEIGHT = 300; - - - public Panel(ModuleCategory category, int x, int y, int width, int height) { - this.category = category; - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - if (dragging) { - x = mouseX - dragX; - y = mouseY - dragY; - } - - int contentHeight = calculateContentHeight(); - int visibleHeight = getVisibleHeight(contentHeight); - - if (open) { - Gui.drawRect(x, y + headerHeight, x + width, y + headerHeight + visibleHeight, 0xff1a1a1a); - - GL11.glEnable(GL11.GL_SCISSOR_TEST); - ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); - int scale = sr.getScaleFactor(); - GL11.glScissor( - x * scale, - Minecraft.getMinecraft().displayHeight - ((y + headerHeight + visibleHeight) * scale), - width * scale, - visibleHeight * scale - ); - - for (Component component : components) { - component.drawScreen(mouseX, mouseY, partialTicks); - } - - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - - // Header background - boolean headerHovered = isHovered(mouseX, mouseY); - Gui.drawRect(x + 1, y + 1, x + width - 1, y + headerHeight, headerHovered ? 0xff353535 : 0xff2d2d2d); - - // Category name - OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .drawString(category.getName(), x + 5, y + 5, 0xffffffff); - - // Collapse indicator - String indicator = open ? "-" : "+"; - int indicatorX = x + width - 5 - - (int) OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .getStringWidth(indicator); - OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .drawString(indicator, indicatorX, y + 5, 0xffaaaaaa); - - // Borders - int panelHeight = headerHeight + (open ? visibleHeight : 0); - Gui.drawRect(x, y, x + width, y + 1, 0xff3d3d3d); - Gui.drawRect(x, y + panelHeight - 1, x + width, y + panelHeight, 0xff3d3d3d); - Gui.drawRect(x, y, x + 1, y + panelHeight, 0xff3d3d3d); - Gui.drawRect(x + width - 1, y, x + width, y + panelHeight, 0xff3d3d3d); - } - - - public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (isHovered(mouseX, mouseY)) { - if (mouseButton == 0) { - dragging = true; - dragX = mouseX - x; - dragY = mouseY - y; - } - if (mouseButton == 1) { - open = !open; - } - } - - if (!open) - return; - - int visibleHeight = getVisibleHeight(calculateContentHeight()); - if (mouseY < y + headerHeight || mouseY > y + headerHeight + visibleHeight) - return; - - for (Component component : components) { - component.mouseClicked(mouseX, mouseY, mouseButton); - } - } - - - public void mouseReleased(int mouseX, int mouseY, int mouseButton) { - if (mouseButton == 0) - dragging = false; - - for (Component component : components) { - component.mouseReleased(mouseX, mouseY, mouseButton); - } - } - - - public boolean keyTyped(char typedChar, int keyCode) { - boolean consumed = false; - for (Component component : components) { - if (component.keyTyped(typedChar, keyCode)) - consumed = true; - } - return consumed; - } - - - public void mouseWheel(int delta) { - if (!open) return; - int contentHeight = calculateContentHeight(); - int visibleHeight = getVisibleHeight(contentHeight); - int maxScroll = Math.max(0, contentHeight - visibleHeight); - scrollOffset = Math.max(0, Math.min(maxScroll, scrollOffset - delta / 2)); - } - - - private int calculateContentHeight() { - int total = 0; - for (Component component : components) { - total += component.getHeight(); - } - return total; - } - - - private int getVisibleHeight(int contentHeight) { - return Math.min(MAX_VISIBLE_CONTENT_HEIGHT, contentHeight); - } - - - private boolean isHovered(int mouseX, int mouseY) { - return mouseX >= x && - mouseX <= x + width && - mouseY >= y && - mouseY <= y + headerHeight; - } - - public boolean isMouseOver(int mouseX, int mouseY) { - int visibleHeight = getVisibleHeight(calculateContentHeight()); - int panelHeight = headerHeight + (open ? visibleHeight : 0); - return mouseX >= x && - mouseX <= x + width && - mouseY >= y && - mouseY <= y + panelHeight; - } - - - public void addComponent(Component component) { - components.add(component); - updateLayout(); - } - - public void updateLayout() { - int offset = headerHeight; - - for (Component component : components) { - component.setOffsetY(offset); - offset += component.getHeight(); - } - - int contentHeight = calculateContentHeight(); - int visibleHeight = getVisibleHeight(contentHeight); - int maxScroll = Math.max(0, contentHeight - visibleHeight); - if (scrollOffset > maxScroll) scrollOffset = maxScroll; - } - - } \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/Component.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/Component.java deleted file mode 100644 index 5c407ba..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/Component.java +++ /dev/null @@ -1,108 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; -import lombok.Getter; -import lombok.Setter; - -@Getter -public abstract class Component { - - protected final Panel parent; - - protected final int offsetX; - @Setter - protected int offsetY; - - protected final int width; - protected int height; - - - public Component( - Panel parent, - int offsetX, - int offsetY, - int width, - int height - ) { - this.parent = parent; - this.offsetX = offsetX; - this.offsetY = offsetY; - this.width = width; - this.height = height; - } - - - public abstract void drawScreen( - int mouseX, - int mouseY, - float partialTicks - ); - - - public void mouseClicked( - int mouseX, - int mouseY, - int mouseButton - ) { - - } - - - public void mouseReleased( - int mouseX, - int mouseY, - int mouseButton - ) { - - } - - - public boolean keyTyped( - char typedChar, - int keyCode - ) { - return false; - } - - - public int getX() { - return parent.getX() + offsetX; - } - - - public int getY() { - return parent.getY() + offsetY - parent.getScrollOffset(); - } - - - protected boolean isHovered( - int mouseX, - int mouseY - ) { - - return mouseX >= getX() - && mouseX <= getX() + width - && mouseY >= getY() - && mouseY <= getY() + height; - } - - - protected void drawString( - String text, - int x, - int y, - int color - ) { - - OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .drawString( - text, - x, - y, - color - ); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/impl/ModuleButton.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/impl/ModuleButton.java deleted file mode 100644 index 2690c38..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/impl/ModuleButton.java +++ /dev/null @@ -1,125 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.impl; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.module.option.Option; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; -import cn.xiaozhou233.orangex.ui.clickgui.component.Component; -import cn.xiaozhou233.orangex.ui.clickgui.component.option.KeybindComponent; -import cn.xiaozhou233.orangex.ui.clickgui.component.option.OptionComponent; -import cn.xiaozhou233.orangex.ui.clickgui.component.option.OptionComponentFactory; -import lombok.Getter; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.renderer.GlStateManager; - -import java.util.ArrayList; -import java.util.List; - -public class ModuleButton extends Component { - - private final Module module; - - @Getter - private boolean expanded; - @Getter - private final List options = new ArrayList<>(); - - public ModuleButton(Panel parent, Module module, int offsetX, int offsetY) { - super(parent, offsetX, offsetY, 120, 20); - - this.module = module; - - int optionY = 20; - - for (Option option : module.getOptions()) { - OptionComponent component = - OptionComponentFactory.create( - parent, - option, - offsetX, - offsetY + optionY - ); - - if (component != null) - options.add(component); - - optionY += 18; - } - - options.add(new KeybindComponent(parent, module, offsetX, offsetY + optionY)); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - if (module.isEnabled()) { - GlStateManager.resetColor(); - Gui.drawRect(getX(), getY(), getX() + width, getY() + height, 0xff1a4a2a); - } - - drawString( - module.getName(), - getX() + 5, - getY() + 5, - 0xffffffff - ); - - if (expanded) { - int optionY = 20; - for (OptionComponent option : options) { - option.setOffsetY(getOffsetY() + optionY); - option.drawScreen(mouseX, mouseY, partialTicks); - optionY += 18; - } - } - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (isHovered(mouseX, mouseY)) { - if (mouseButton == 0) - module.toggle(); - - if (mouseButton == 1) { - expanded = !expanded; - parent.updateLayout(); - } - } - - if (expanded) { - int optionY = 20; - for (OptionComponent option : options) { - option.setOffsetY(getOffsetY() + optionY); - option.mouseClicked(mouseX, mouseY, mouseButton); - optionY += 18; - } - } - } - - @Override - public void mouseReleased(int mouseX, int mouseY, int mouseButton) { - if (expanded) { - for (OptionComponent option : options) { - option.mouseReleased(mouseX, mouseY, mouseButton); - } - } - } - - @Override - public boolean keyTyped(char typedChar, int keyCode) { - if (expanded) { - for (OptionComponent option : options) { - if (option.keyTyped(typedChar, keyCode)) - return true; - } - } - return false; - } - - @Override - public int getHeight() { - if (!expanded) - return 20; - - return 20 + options.size() * 18; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/BooleanComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/BooleanComponent.java deleted file mode 100644 index 099f13b..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/BooleanComponent.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.module.option.impl.BooleanOption; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; - -public class BooleanComponent extends OptionComponent{ - - private final BooleanOption option; - - - public BooleanComponent( - Panel parent, - BooleanOption option, - int offsetX, - int offsetY - ) { - super(parent,option,offsetX,offsetY,120,18); - this.option = option; - } - - - @Override - public void drawScreen(int mouseX,int mouseY,float partialTicks) { - drawRect(getX(), getY(), getX() + width, getY() + height, 0xff252525); - - drawString( - option.getName(), - getX() + 5, - getY() + 5, - 0xffffffff - ); - - - drawString( - option.getValue() ? "ON" : "OFF", - getX() + width - 25, - getY() + 5, - option.getValue() - ? 0xff55ffff - : 0xffffffff - ); - } - - - @Override - public void mouseClicked(int mouseX,int mouseY,int mouseButton) { - - if (!isHovered(mouseX,mouseY)) - return; - - - if (mouseButton == 0) { - option.setValue(!option.getValue()); - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/ColorComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/ColorComponent.java deleted file mode 100644 index ec7d1bf..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/ColorComponent.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.module.option.impl.ColorOption; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; - -import java.awt.*; - -public class ColorComponent extends OptionComponent { - - private final ColorOption option; - - - public ColorComponent( - Panel parent, - ColorOption option, - int offsetX, - int offsetY - ) { - super(parent,option,offsetX,offsetY,120,18); - this.option = option; - } - - - @Override - public void drawScreen(int mouseX,int mouseY,float partialTicks) { - drawRect(getX(), getY(), getX() + width, getY() + height, 0xff252525); - - drawString( - option.getName(), - getX() + 5, - getY() + 5, - 0xffffffff - ); - - - drawRect( - getX() + width - 25, - getY() + 3, - getX() + width - 5, - getY() + 15, - option.getValue() - ); - } - - - @Override - public void mouseClicked(int mouseX,int mouseY,int mouseButton) { - - if(!isHovered(mouseX,mouseY)) - return; - - - if(mouseButton == 0) { - - option.setValue( - getNextColor() - ); - } - } - - - private int getNextColor() { - - int color = option.getValue(); - - float[] hsb = - Color.RGBtoHSB( - (color >> 16) & 255, - (color >> 8) & 255, - color & 255, - null - ); - - - hsb[0] += 0.1f; - - - if(hsb[0] > 1) - hsb[0] = 0; - - - return Color.HSBtoRGB( - hsb[0], - hsb[1], - hsb[2] - ); - } - -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/KeybindComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/KeybindComponent.java deleted file mode 100644 index 6a94e19..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/KeybindComponent.java +++ /dev/null @@ -1,66 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.module.Module; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; -import org.lwjgl.input.Keyboard; - -public class KeybindComponent extends OptionComponent { - - private final Module module; - private boolean listening; - - public KeybindComponent(Panel parent, Module module, int offsetX, int offsetY) { - super(parent, null, offsetX, offsetY, 120, 16); - this.module = module; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - drawRect(getX(), getY(), getX() + width, getY() + height, 0xff252525); - drawString("Keybind", getX() + 4, getY() + 4, 0xffffffff); - - String keyName; - if (listening) { - keyName = "..."; - } else { - keyName = module.getKey() != Keyboard.KEY_NONE - ? Keyboard.getKeyName(module.getKey()) : "NONE"; - } - - int keyX = getX() + width - 4 - - (int) OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .getStringWidth(keyName); - int keyColor = listening ? 0xff55ffff : 0xffaaaaaa; - drawString(keyName, keyX, getY() + 4, keyColor); - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int mouseButton) { - if (!isHovered(mouseX, mouseY)) return; - if (mouseButton == 0) { - listening = true; - } - } - - @Override - public boolean keyTyped(char typedChar, int keyCode) { - if (!listening) return false; - - if (keyCode == 1) { - module.setKey(0); - listening = false; - return true; - } - - module.setKey(keyCode); - listening = false; - return true; - } - - @Override - public void mouseReleased(int mouseX, int mouseY, int mouseButton) { - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/ModeComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/ModeComponent.java deleted file mode 100644 index 574eb5e..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/ModeComponent.java +++ /dev/null @@ -1,61 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.module.option.impl.ModeOption; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; - -public class ModeComponent extends OptionComponent { - - private final ModeOption option; - - - public ModeComponent( - Panel parent, - ModeOption option, - int offsetX, - int offsetY - ) { - super(parent,option,offsetX,offsetY,120,18); - this.option = option; - } - - - @Override - public void drawScreen(int mouseX,int mouseY,float partialTicks) { - drawRect(getX(), getY(), getX() + width, getY() + height, 0xff252525); - - drawString( - option.getName(), - getX() + 5, - getY() + 5, - 0xffffffff - ); - - - drawString( - option.getValue(), - getX() + width - 45, - getY() + 5, - 0xff55ffff - ); - } - - - @Override - public void mouseClicked(int mouseX,int mouseY,int mouseButton) { - - if (!isHovered(mouseX,mouseY)) - return; - - - if(mouseButton == 0) { - - option.next(); - } - - - if(mouseButton == 1) { - - option.previous(); - } - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/OptionComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/OptionComponent.java deleted file mode 100644 index 7c8fa75..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/OptionComponent.java +++ /dev/null @@ -1,43 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.module.option.Option; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; -import cn.xiaozhou233.orangex.ui.clickgui.component.Component; -import lombok.Getter; -import net.minecraft.client.renderer.GlStateManager; - -@Getter -public abstract class OptionComponent extends Component { - - protected final Option option; - - - public OptionComponent( - Panel parent, - Option option, - int offsetX, - int offsetY, - int width, - int height - ) { - super(parent,offsetX,offsetY,width,height); - this.option = option; - } - - protected void drawRect( - int left, - int top, - int right, - int bottom, - int color - ) { - GlStateManager.resetColor(); - net.minecraft.client.gui.Gui.drawRect( - left, - top, - right, - bottom, - color - ); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/OptionComponentFactory.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/OptionComponentFactory.java deleted file mode 100644 index 3381a0d..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/OptionComponentFactory.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.module.option.Option; -import cn.xiaozhou233.orangex.module.option.impl.*; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; - -public class OptionComponentFactory { - - public static OptionComponent create( - Panel panel, - Option option, - int x, - int y - ) { - - if (option instanceof BooleanOption) { - return new BooleanComponent( - panel, - (BooleanOption) option, - x, - y - ); - } - - if (option instanceof IntOption) { - return new SliderComponent( - panel, - (IntOption) option, - x, - y - ); - } - - if (option instanceof DoubleOption) { - return new SliderComponent( - panel, - (DoubleOption) option, - x, - y - ); - } - - if (option instanceof ModeOption) { - return new ModeComponent( - panel, - (ModeOption) option, - x, - y - ); - } - - if (option instanceof ColorOption) { - return new ColorComponent( - panel, - (ColorOption) option, - x, - y - ); - } - - if (option instanceof StringOption) { - return new StringComponent( - panel, - (StringOption) option, - x, - y - ); - } - - return null; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/SliderComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/SliderComponent.java deleted file mode 100644 index 3d60362..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/SliderComponent.java +++ /dev/null @@ -1,159 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.module.option.impl.DoubleOption; -import cn.xiaozhou233.orangex.module.option.impl.IntOption; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; - -public class SliderComponent extends OptionComponent { - - private final double min; - private final double max; - - private boolean dragging; - - - public SliderComponent( - Panel parent, - IntOption option, - int offsetX, - int offsetY - ) { - super(parent,option,offsetX,offsetY,120,18); - - this.min = option.getMin(); - this.max = option.getMax(); - } - - public SliderComponent( - Panel parent, - DoubleOption option, - int offsetX, - int offsetY - ) { - super(parent,option,offsetX,offsetY,120,18); - - this.min = option.getMin(); - this.max = option.getMax(); - } - - - @Override - public void drawScreen(int mouseX,int mouseY,float partialTicks) { - drawRect(getX(), getY(), getX() + width, getY() + height, 0xff252525); - - double value = getValue(); - - double percent = - (value - min) / (max - min); - - - int barWidth = width - 10; - - - drawString( - option.getName(), - getX() + 5, - getY() + 3, - 0xffffffff - ); - - - // Background bar - drawRect( - getX() + 5, - getY() + 15, - getX() + 5 + barWidth, - getY() + 18, - 0xff555555 - ); - - - // Value bar - drawRect( - getX() + 5, - getY() + 15, - getX() + 5 + (int)(barWidth * percent), - getY() + 18, - 0xff55ffff - ); - - - drawString( - String.valueOf(value), - getX() + width - 25, - getY() + 3, - 0xffaaaaaa - ); - - - if(dragging) - updateValue(mouseX); - } - - - @Override - public void mouseClicked(int mouseX,int mouseY,int mouseButton) { - - if(mouseButton == 0 && isHovered(mouseX,mouseY)) { - dragging = true; - updateValue(mouseX); - } - } - - - @Override - public void mouseReleased(int mouseX,int mouseY,int mouseButton) { - - if(mouseButton == 0) - dragging = false; - } - - - private void updateValue(int mouseX) { - - double percent = - (mouseX - (getX() + 5)) - / (double)(width - 10); - - - percent = Math.max(0,Math.min(1,percent)); - - - double value = - min + (max - min) * percent; - - - if(option instanceof IntOption) { - - ((IntOption) option) - .setValue((int)value); - - } else if(option instanceof DoubleOption) { - - ((DoubleOption) option) - .setValue(value); - } - } - - - private double getValue() { - - if(option instanceof IntOption) { - - return ((IntOption) option) - .getValue(); - - } - - - if(option instanceof DoubleOption) { - - return ((DoubleOption) option) - .getValue(); - - } - - - return 0; - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/StringComponent.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/StringComponent.java deleted file mode 100644 index 69ae433..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/ui/clickgui/component/option/StringComponent.java +++ /dev/null @@ -1,149 +0,0 @@ -package cn.xiaozhou233.orangex.ui.clickgui.component.option; - -import cn.xiaozhou233.orangex.OrangeX; -import cn.xiaozhou233.orangex.module.option.impl.StringOption; -import cn.xiaozhou233.orangex.ui.clickgui.Panel; - - -public class StringComponent extends OptionComponent { - - private final StringOption option; - - private boolean typing; - - - public StringComponent( - Panel parent, - StringOption option, - int offsetX, - int offsetY - ) { - super(parent,option,offsetX,offsetY,120,18); - this.option = option; - } - - - @Override - public void drawScreen(int mouseX,int mouseY,float partialTicks) { - drawRect(getX(), getY(), getX() + width, getY() + height, 0xff252525); - - drawString( - option.getName(), - getX() + 5, - getY() + 5, - 0xffffffff - ); - - - String value = option.getValue(); - - if(typing) - value += "_"; - - - int maxValueWidth = 50; - int valueWidth = (int) OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .getStringWidth(value); - - if (valueWidth > maxValueWidth) { - while ((int) OrangeX.getInstance() - .getStbFontManager() - .getProxima(18) - .getStringWidth("..." + value) > maxValueWidth - && value.length() > 0) { - value = value.substring(1); - } - value = "..." + value; - } - - - drawString( - value, - getX() + width - 5 - maxValueWidth, - getY() + 5, - typing - ? 0xff55ffff - : 0xffaaaaaa - ); - - - - } - - - @Override - public void mouseClicked( - int mouseX, - int mouseY, - int mouseButton - ) { - if (typing && !isHovered(mouseX, mouseY)) { - typing = false; - return; - } - - if (!isHovered(mouseX,mouseY)) - return; - - if(mouseButton == 0) { - typing = true; - } - } - - - @Override - public boolean keyTyped( - char typedChar, - int keyCode - ) { - - if(!typing) - return false; - - - // Backspace - if(keyCode == 14) { - - String value = option.getValue(); - - if(value.length() > 0) { - option.setValue( - value.substring( - 0, - value.length() - 1 - ) - ); - } - return true; - } - - - // Enter - if(keyCode == 28) { - typing = false; - return true; - } - - - if(Character.isISOControl(typedChar)) - return true; - - - option.setValue( - option.getValue() + typedChar - ); - return true; - } - - - @Override - public void mouseReleased( - int mouseX, - int mouseY, - int mouseButton - ) { - - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/IOUtils.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/IOUtils.java deleted file mode 100644 index e482197..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/IOUtils.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.xiaozhou233.orangex.utils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -public class IOUtils { - - public static byte[] toByteArray(InputStream input) throws IOException { - if (input == null) { - return new byte[0]; - } - - byte[] buffer = new byte[8192]; // 8KB buffer - int len; - ByteArrayOutputStream output = new ByteArrayOutputStream(); - - while ((len = input.read(buffer)) != -1) { - output.write(buffer, 0, len); - } - - return output.toByteArray(); - } -} \ No newline at end of file diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/JuiceAgentFacade.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/JuiceAgentFacade.java deleted file mode 100644 index e0d3f7a..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/JuiceAgentFacade.java +++ /dev/null @@ -1,69 +0,0 @@ -package cn.xiaozhou233.orangex.utils; - -import java.lang.reflect.Method; - -public final class JuiceAgentFacade { - - private static final Class JL; - private static final Method GET_CLASS_BYTES; - private static final Method REDEFINE_CLASS; - private static final Method GET_LOADED_CLASSES; - private static final Method RETRANSFORM_CLASS; - - static { - try { - JL = Class.forName( - "cn.xiaozhou233.juiceagent.api.JuiceAgent", - true, - ClassLoader.getSystemClassLoader() - ); - - GET_CLASS_BYTES = JL.getMethod("getClassBytes", Class.class); - REDEFINE_CLASS = JL.getMethod( - "redefineClass", - Class.class, - byte[].class, - int.class - ); - GET_LOADED_CLASSES = JL.getMethod("getLoadedClasses"); - RETRANSFORM_CLASS = JL.getMethod("retransformClass", Class.class, byte[].class, int.class); - - } catch (Exception e) { - throw new RuntimeException("Failed to init JuiceFacade", e); - } - } - - private JuiceAgentFacade() {} - - public static byte[] getClassBytes(Class clazz) { - try { - return (byte[]) GET_CLASS_BYTES.invoke(null, clazz); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static boolean redefineClass(Class clazz, byte[] bytes) { - try { - return (boolean) REDEFINE_CLASS.invoke(null, clazz, bytes, bytes.length); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static Class[] getLoadedClasses() { - try { - return (Class[]) GET_LOADED_CLASSES.invoke(null); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public static boolean retransformClass(Class clazz, byte[] bytes) { - try { - return (boolean) RETRANSFORM_CLASS.invoke(null, clazz, bytes, bytes.length); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/RenderUtils.java b/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/RenderUtils.java deleted file mode 100644 index 8198a51..0000000 --- a/OrangeX/src/main/java/cn/xiaozhou233/orangex/utils/RenderUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -package cn.xiaozhou233.orangex.utils; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import net.minecraft.util.AxisAlignedBB; -import org.lwjgl.opengl.GL11; - -public class RenderUtils { - - private static final Minecraft mc = Minecraft.getMinecraft(); - - public static void drawEntityBox(Entity entity, float partialTicks) { - Entity view = mc.getRenderViewEntity(); - double renderPosX = view.lastTickPosX + (view.posX - view.lastTickPosX) * partialTicks; - double renderPosY = view.lastTickPosY + (view.posY - view.lastTickPosY) * partialTicks; - double renderPosZ = view.lastTickPosZ + (view.posZ - view.lastTickPosZ) * partialTicks; - - double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks - renderPosX; - double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks - renderPosY; - double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks - renderPosZ; - - AxisAlignedBB bb = entity.getEntityBoundingBox(); - double expand = 0.15; - bb = bb.expand(expand, expand, expand); - bb = bb.offset(-entity.posX, -entity.posY, -entity.posZ); - bb = bb.offset(x, y, z); - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.disableDepth(); - GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); - GL11.glLineWidth(2.0f); - - GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.5f); - drawBox(bb); - - GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - drawOutline(bb); - - GlStateManager.enableDepth(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - GlStateManager.popMatrix(); - } - - public static void drawBox(AxisAlignedBB bb) { - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); - - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); - - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); - - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); - - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); - - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); - GL11.glEnd(); - } - - public static void drawOutline(AxisAlignedBB bb) { - GL11.glBegin(GL11.GL_LINES); - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); - - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); - - GL11.glVertex3d(bb.minX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.minZ); - GL11.glVertex3d(bb.maxX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.maxX, bb.maxY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.minY, bb.maxZ); - GL11.glVertex3d(bb.minX, bb.maxY, bb.maxZ); - GL11.glEnd(); - } -} \ No newline at end of file