Added width and height to hud component configs, Fixed a bug with scrollbars when resized, Display zoom level on OverView

This commit is contained in:
Rigamortis 2019-12-11 14:56:50 -09:00
parent ef31fe9fa4
commit 4a166efefa
4 changed files with 27 additions and 11 deletions

View File

@ -33,6 +33,12 @@ public final class HudConfig extends Configurable {
case "Y":
hudComponent.setY(entry.getValue().getAsFloat());
break;
case "W":
hudComponent.setW(entry.getValue().getAsFloat());
break;
case "H":
hudComponent.setH(entry.getValue().getAsFloat());
break;
case "Visible":
hudComponent.setVisible(entry.getValue().getAsBoolean());
break;
@ -65,6 +71,8 @@ public final class HudConfig extends Configurable {
componentsListJsonObject.addProperty("Name", hudComponent.getName());
componentsListJsonObject.addProperty("X", hudComponent.getX());
componentsListJsonObject.addProperty("Y", hudComponent.getY());
componentsListJsonObject.addProperty("W", hudComponent.getW());
componentsListJsonObject.addProperty("H", hudComponent.getH());
componentsListJsonObject.addProperty("Visible", hudComponent.isVisible());
componentsListJsonObject.addProperty("Anchor", hudComponent.getAnchorPoint() == null ? "NONE" : hudComponent.getAnchorPoint().getPoint().name());
componentsListJsonObject.addProperty("Glue", hudComponent.getGlued() == null ? "NONE" : hudComponent.getGlued().getName());

View File

@ -1,19 +1,20 @@
package me.rigamortis.seppuku.impl.gui.hud.component;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import me.rigamortis.seppuku.api.gui.hud.component.HudComponent;
import me.rigamortis.seppuku.api.gui.hud.component.ResizableHudComponent;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.math.MathHelper;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
/**
* created by noil on 9/29/2019 at 12:23 PM
*/
public final class HubComponent extends DraggableHudComponent {
public final class HubComponent extends ResizableHudComponent {
private int scroll;
@ -24,7 +25,7 @@ public final class HubComponent extends DraggableHudComponent {
private final int TEXT_GAP = 1;
public HubComponent() {
super("Hub");
super("Hub", 100, 100);
this.setVisible(true);
this.setSnappable(false);
this.setW(100);
@ -66,7 +67,7 @@ public final class HubComponent extends DraggableHudComponent {
// Scrollbar
RenderUtil.drawRect(this.getX() + this.getW() - SCROLL_WIDTH, this.getY() + offsetY + BORDER, this.getX() + this.getW() - BORDER, this.getY() + this.getH() - BORDER, 0xFF101010);
RenderUtil.drawRect(this.getX() + this.getW() - SCROLL_WIDTH, (this.getY() + offsetY + BORDER) + ((this.getH() * this.scroll) / this.totalHeight), this.getX() + this.getW() - BORDER, (this.getY() + this.getH() - BORDER) - (this.getH() * (this.totalHeight - this.getH() - this.scroll) / this.totalHeight), 0xFF909090);
RenderUtil.drawRect(this.getX() + this.getW() - SCROLL_WIDTH, MathHelper.clamp((this.getY() + offsetY + BORDER) + ((this.getH() * this.scroll) / this.totalHeight), (this.getY() + offsetY + BORDER), (this.getY() + this.getH() - BORDER)), this.getX() + this.getW() - BORDER, MathHelper.clamp((this.getY() + this.getH() - BORDER) - (this.getH() * (this.totalHeight - this.getH() - this.scroll) / this.totalHeight), (this.getY() + offsetY + BORDER), (this.getY() + this.getH() - BORDER)), 0xFF909090);
RenderUtil.glScissor(this.getX() + BORDER, this.getY() + offsetY + BORDER, this.getX() + this.getW() - BORDER - SCROLL_WIDTH, this.getY() + this.getH() - BORDER, sr);
GL11.glEnable(GL11.GL_SCISSOR_TEST);

View File

@ -51,6 +51,11 @@ public final class OverViewComponent extends ResizableHudComponent {
this.overviewCamera.render(this.getX() + 2, this.getY() + 12, this.getX() + this.getW() - 2, this.getY() + this.getH() - 2);
}
}
final boolean inside = mouseX >= this.getX() && mouseX <= this.getX() + this.getW() && mouseY >= this.getY() && mouseY <= this.getY() + this.getH();
if (inside)
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow("Zoom: " + this.distance, this.getX() + 4, this.getY() + this.getH() - Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT - 2, 0xFFFFFFFF);
}
private Vec3d getGround(float partialTicks) {
@ -82,15 +87,15 @@ public final class OverViewComponent extends ResizableHudComponent {
if (inside && Mouse.hasWheel()) {
this.scroll += -(Mouse.getDWheel() / 100);
if(this.scroll <= 0) {
if (this.scroll <= 0) {
this.scroll = 0;
}
if(this.scroll >= 8) {
this.scroll = 8;
if (this.scroll >= 10) {
this.scroll = 10;
}
if(this.lastScroll != this.scroll) {
if (this.lastScroll != this.scroll) {
this.lastScroll = this.scroll;
this.distance = this.scroll * 10;
//TODO update fbo

View File

@ -2,6 +2,7 @@ package me.rigamortis.seppuku.impl.gui.hud.component.module;
import me.rigamortis.seppuku.Seppuku;
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
import me.rigamortis.seppuku.api.gui.hud.component.ResizableHudComponent;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.util.RenderUtil;
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
@ -9,6 +10,7 @@ import me.rigamortis.seppuku.impl.module.ui.HudEditorModule;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.math.MathHelper;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
@ -16,7 +18,7 @@ import org.lwjgl.opengl.GL11;
/**
* created by noil on 11/4/19 at 12:02 PM
*/
public final class ModuleListComponent extends DraggableHudComponent {
public final class ModuleListComponent extends ResizableHudComponent {
private Module.ModuleType type;
@ -31,7 +33,7 @@ public final class ModuleListComponent extends DraggableHudComponent {
private final HudEditorModule hudEditorModule = (HudEditorModule) Seppuku.INSTANCE.getModuleManager().find(HudEditorModule.class);
public ModuleListComponent(Module.ModuleType type) {
super(StringUtils.capitalize(type.name().toLowerCase()));
super(StringUtils.capitalize(type.name().toLowerCase()), 100, 100);
this.type = type;
this.setSnappable(false);
this.setW(100);
@ -73,7 +75,7 @@ public final class ModuleListComponent extends DraggableHudComponent {
// Scrollbar
RenderUtil.drawRect(this.getX() + this.getW() - SCROLL_WIDTH, this.getY() + offsetY + BORDER, this.getX() + this.getW() - BORDER, this.getY() + this.getH() - BORDER, 0xFF101010);
RenderUtil.drawRect(this.getX() + this.getW() - SCROLL_WIDTH, (this.getY() + offsetY + BORDER) + ((this.getH() * this.scroll) / this.totalHeight), this.getX() + this.getW() - BORDER, (this.getY() + this.getH() - BORDER) - (this.getH() * (this.totalHeight - this.getH() - this.scroll) / this.totalHeight), 0xFF909090);
RenderUtil.drawRect(this.getX() + this.getW() - SCROLL_WIDTH, MathHelper.clamp((this.getY() + offsetY + BORDER) + ((this.getH() * this.scroll) / this.totalHeight), (this.getY() + offsetY + BORDER), (this.getY() + this.getH() - BORDER)), this.getX() + this.getW() - BORDER, MathHelper.clamp((this.getY() + this.getH() - BORDER) - (this.getH() * (this.totalHeight - this.getH() - this.scroll) / this.totalHeight), (this.getY() + offsetY + BORDER), (this.getY() + this.getH() - BORDER)), 0xFF909090);
RenderUtil.glScissor(this.getX() + BORDER, this.getY() + offsetY + BORDER, this.getX() + this.getW() - BORDER - SCROLL_WIDTH, this.getY() + this.getH() - BORDER, sr);
GL11.glEnable(GL11.GL_SCISSOR_TEST);