mirror of
https://github.com/xiaozhou233/OrangeX-Client.git
synced 2026-12-05 13:05:52 +08:00
[Feat] ClickGUI Font
This commit is contained in:
1 parent
547f57fc4c
commit
20dcc72c92
5 files changed
+24
-12
No files matched your search
@@ -3,10 +3,14 @@ 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);
|
||||
|
||||
|
||||
@@ -10,8 +10,10 @@ import cn.xiaozhou233.orangex.ui.clickgui.component.impl.BooleanComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.NumberComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.ModeComponent;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.component.impl.KeybindComponent;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,7 +24,6 @@ public class ClickGuiScreen extends GuiScreen {
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
System.out.println("ClickGui init");
|
||||
panels.clear();
|
||||
|
||||
// build panels for each category
|
||||
@@ -57,18 +58,18 @@ public class ClickGuiScreen extends GuiScreen {
|
||||
panels.add(panel);
|
||||
startX += panelWidth + gap;
|
||||
}
|
||||
|
||||
System.out.println("Panels count: " + panels.size());
|
||||
for (Panel p : panels) {
|
||||
System.out.println("Panel " + p.getTitle() + " components: " + p.getComponents().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
// background
|
||||
drawDefaultBackground();
|
||||
Gui.drawRect(
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
new Color(50, 50, 50, 100).getRGB()
|
||||
);
|
||||
|
||||
// update and render panels
|
||||
for (Panel panel : panels) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.xiaozhou233.orangex.ui.clickgui.component.Component;
|
||||
import cn.xiaozhou233.orangex.ui.clickgui.render.GuiRenderUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,10 +37,10 @@ public class Panel extends Component {
|
||||
|
||||
// draw header background
|
||||
GuiRenderUtils.enableBlend();
|
||||
GuiRenderUtils.drawRect(ax, ay, width, headerHeight, 0x80000000);
|
||||
GuiRenderUtils.drawRect(ax, ay, width, headerHeight, new Color(32, 32, 32, 255).getRGB());
|
||||
|
||||
// draw title
|
||||
GuiRenderUtils.drawString(title, ax + 4, ay + 4, 0xFFFFFFFF);
|
||||
GuiRenderUtils.drawCenteredString(title, ax + width / 2, ay + 5, new Color(255, 255, 255, 255).getRGB());
|
||||
GuiRenderUtils.disableBlend();
|
||||
|
||||
if (!open) return;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.xiaozhou233.orangex.ui.clickgui.render;
|
||||
|
||||
import cn.xiaozhou233.orangex.OrangeX;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
@@ -14,8 +15,13 @@ public class GuiRenderUtils {
|
||||
}
|
||||
|
||||
public static void drawString(String text, double x, double y, int color) {
|
||||
FontRenderer fr = mc.fontRendererObj;
|
||||
fr.drawString(text, (int) x, (int) y, color);
|
||||
OrangeX.getFontManager().MontserratRegular18
|
||||
.drawString(text, (float) x, (float) y, color);
|
||||
}
|
||||
|
||||
public static void drawCenteredString(String text, double x, double y, int color) {
|
||||
OrangeX.getFontManager().MontserratRegular18
|
||||
.drawString(text, (float) x - (float) OrangeX.getFontManager().MontserratLight18.getStringWidth(text) / 2, (float) y, color);
|
||||
}
|
||||
|
||||
public static void enableBlend() {
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user