rounded theme stuff
This commit is contained in:
@@ -19,8 +19,9 @@ public interface MeteorWidget extends BaseWidget {
|
||||
default void renderBackground(GuiRenderer renderer, WWidget widget, boolean pressed, boolean mouseOver) {
|
||||
MeteorRoundedGuiTheme theme = theme();
|
||||
int r = theme.roundAmount();
|
||||
double s = theme.scale(2);
|
||||
Color outlineColor = theme.outlineColor.get(pressed, mouseOver);
|
||||
GuiUtils.quadRounded(renderer, widget, theme.backgroundColor.get(pressed, mouseOver), r);
|
||||
GuiUtils.quadOutlineRounded(renderer, widget, outlineColor, r, theme.scale(2));
|
||||
GuiUtils.quadRounded(renderer, widget.x + s, widget.y + s, widget.width - s * 2, widget.height - s * 2, theme.backgroundColor.get(pressed, mouseOver), r);
|
||||
GuiUtils.quadOutlineRounded(renderer, widget, outlineColor, r, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,22 @@
|
||||
|
||||
package cloudburst.rejects.gui.themes.rounded.widgets;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
import cloudburst.rejects.gui.themes.rounded.MeteorRoundedGuiTheme;
|
||||
import cloudburst.rejects.gui.themes.rounded.MeteorWidget;
|
||||
import cloudburst.rejects.utils.gui.GuiUtils;
|
||||
import meteordevelopment.meteorclient.gui.renderer.GuiRenderer;
|
||||
import meteordevelopment.meteorclient.gui.tabs.Tab;
|
||||
import meteordevelopment.meteorclient.gui.tabs.TabScreen;
|
||||
import meteordevelopment.meteorclient.gui.tabs.Tabs;
|
||||
import meteordevelopment.meteorclient.gui.widgets.WTopBar;
|
||||
import meteordevelopment.meteorclient.gui.widgets.pressable.WPressable;
|
||||
import meteordevelopment.meteorclient.utils.render.color.Color;
|
||||
|
||||
import static meteordevelopment.meteorclient.utils.Utils.mc;
|
||||
import static org.lwjgl.glfw.GLFW.glfwSetCursorPos;
|
||||
|
||||
public class WMeteorTopBar extends WTopBar implements MeteorWidget {
|
||||
@Override
|
||||
protected Color getButtonColor(boolean pressed, boolean hovered) {
|
||||
@@ -19,4 +31,72 @@ public class WMeteorTopBar extends WTopBar implements MeteorWidget {
|
||||
protected Color getNameColor() {
|
||||
return theme().textColor.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
for (Tab tab : Tabs.get()) {
|
||||
add(new WTopBarButton(tab));
|
||||
}
|
||||
}
|
||||
|
||||
protected int getState(WTopBarButton btn) {
|
||||
int a = 0;
|
||||
if (btn.equals(cells.get(0).widget()))
|
||||
a |= 1;
|
||||
if (btn.equals(cells.get(cells.size() - 1).widget()))
|
||||
a |= 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
protected class WTopBarButton extends WPressable {
|
||||
private final Tab tab;
|
||||
|
||||
public WTopBarButton(Tab tab) {
|
||||
this.tab = tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCalculateSize() {
|
||||
double pad = pad();
|
||||
|
||||
width = pad + theme.textWidth(tab.name) + pad;
|
||||
height = pad + theme.textHeight() + pad;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPressed(int button) {
|
||||
Screen screen = mc.currentScreen;
|
||||
|
||||
if (!(screen instanceof TabScreen) || ((TabScreen) screen).tab != tab) {
|
||||
double mouseX = mc.mouse.getX();
|
||||
double mouseY = mc.mouse.getY();
|
||||
|
||||
tab.openScreen(theme);
|
||||
glfwSetCursorPos(mc.getWindow().getHandle(), mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRender(GuiRenderer renderer, double mouseX, double mouseY, double delta) {
|
||||
double pad = pad();
|
||||
Color color = getButtonColor(pressed || (mc.currentScreen instanceof TabScreen && ((TabScreen) mc.currentScreen).tab == tab), mouseOver);
|
||||
|
||||
//renderer.quad(x, y, width, height, color);
|
||||
switch (getState(this)) {
|
||||
case 1:
|
||||
GuiUtils.quadRoundedSide(renderer, this, color, ((MeteorRoundedGuiTheme)theme).roundAmount(), false);
|
||||
break;
|
||||
case 2:
|
||||
GuiUtils.quadRoundedSide(renderer, this, color, ((MeteorRoundedGuiTheme)theme).roundAmount(), true);
|
||||
break;
|
||||
case 3:
|
||||
GuiUtils.quadRounded(renderer, this, color, ((MeteorRoundedGuiTheme)theme).roundAmount());
|
||||
break;
|
||||
default:
|
||||
renderer.quad(this, color);
|
||||
break;
|
||||
}
|
||||
renderer.text(tab.name, x + pad, y + pad, getNameColor(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,35 +95,33 @@ public class RoundedRenderer2D {
|
||||
int cirDepth = getCirDepth(r, angle);
|
||||
double cirPart = angle / cirDepth;
|
||||
int center = mb.triangles.vec2(x, y).color(color).next();
|
||||
int prev = mb.triangles.vec2(x + Math.sin(startAngle) * r, y - Math.cos(startAngle) * r).color(color).next();
|
||||
int prev = vecOnCircle(mb, x, y, r, startAngle, color);
|
||||
for (int i = 1; i < cirDepth + 1; i++) {
|
||||
double xV = x + Math.sin(startAngle + cirPart * i) * r;
|
||||
double yV = y - Math.cos(startAngle + cirPart * i) * r;
|
||||
int next = mb.triangles.vec2(xV, yV).color(color).next();
|
||||
int next = vecOnCircle(mb, x, y, r, startAngle + cirPart * i, color);
|
||||
mb.triangles.quad(prev, center, next, next);
|
||||
prev = next;
|
||||
}
|
||||
}
|
||||
|
||||
public static void circlePartOutline(Renderer2D mb, double x, double y, double r, double startAngle, double angle, Color color, double outlineWidth) {
|
||||
if (outlineWidth >= r) {
|
||||
circlePart(mb, x, y, r, startAngle, angle, color);
|
||||
return;
|
||||
}
|
||||
int cirDepth = getCirDepth(r, angle);
|
||||
double cirPart = angle / cirDepth;
|
||||
for (int i = 0; i < cirDepth; i++) {
|
||||
double xOC = x + Math.sin(startAngle + cirPart * i) * r;
|
||||
double yOC = y - Math.cos(startAngle + cirPart * i) * r;
|
||||
double xIC = x + Math.sin(startAngle + cirPart * i) * (r - outlineWidth);
|
||||
double yIC = y - Math.cos(startAngle + cirPart * i) * (r - outlineWidth);
|
||||
double xON = x + Math.sin(startAngle + cirPart * (i + 1)) * r;
|
||||
double yON = y - Math.cos(startAngle + cirPart * (i + 1)) * r;
|
||||
double xIN = x + Math.sin(startAngle + cirPart * (i + 1)) * (r - outlineWidth);
|
||||
double yIN = y - Math.cos(startAngle + cirPart * (i + 1)) * (r - outlineWidth);
|
||||
|
||||
mb.triangles.quad(
|
||||
mb.triangles.vec2(xOC, yOC).color(color).next(),
|
||||
mb.triangles.vec2(xON, yON).color(color).next(),
|
||||
mb.triangles.vec2(xIC, yIC).color(color).next(),
|
||||
mb.triangles.vec2(xIN, yIN).color(color).next()
|
||||
);
|
||||
int innerPrev = vecOnCircle(mb, x, y, r - outlineWidth, startAngle, color);
|
||||
int outerPrev = vecOnCircle(mb, x, y, r, startAngle, color);
|
||||
for (int i = 1; i < cirDepth + 1; i++) {
|
||||
int inner = vecOnCircle(mb, x, y, r - outlineWidth, startAngle + cirPart * i, color);
|
||||
int outer = vecOnCircle(mb, x, y, r, startAngle + cirPart * i, color);
|
||||
mb.triangles.quad(inner, innerPrev, outerPrev, outer);
|
||||
innerPrev = inner;
|
||||
outerPrev = outer;
|
||||
}
|
||||
}
|
||||
|
||||
private static int vecOnCircle(Renderer2D mb, double x, double y, double r, double angle, Color color) {
|
||||
return mb.triangles.vec2(x + Math.sin(angle) * r, y - Math.cos(angle) * r).color(color).next();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user