aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/kr/syeyoung')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/EventListener.java2
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java4
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java16
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java41
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java3
5 files changed, 51 insertions, 15 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
index ac3f3432..fd210c82 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/EventListener.java
@@ -17,6 +17,7 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
+import org.lwjgl.opengl.GL11;
import java.awt.*;
@@ -53,7 +54,6 @@ public class EventListener {
dynamicTexture.updateDynamicTexture();
Minecraft.getMinecraft().getTextureManager().bindTexture(location);
- GlStateManager.enableBlend();
GlStateManager.enableAlpha();
GuiScreen.drawModalRectWithCustomSizedTexture(0,0, 0, 0, 128, 128, 128, 128);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
index 4f196b80..b1f15300 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/commands/CommandEditRoom.java
@@ -32,7 +32,7 @@ public class CommandEditRoom extends CommandBase {
}
@Override
- public void processCommand(ICommandSender sender, String[] args) throws CommandException {
+ public void processCommand(ICommandSender sender, String[] args) {
SkyblockStatus skyblockStatus = DungeonsGuide.getDungeonsGuide().getSkyblockStatus();
if (!skyblockStatus.isOnDungeon()) {
sender.addChatMessage(new ChatComponentText("You're not in dungeons"));
@@ -58,7 +58,7 @@ public class CommandEditRoom extends CommandBase {
openit = new GuiDungeonRoomEdit(dungeonRoom);
}
- GuiScreen openit;
+ GuiScreen openit = null;
@SubscribeEvent
public void tick(TickEvent.ClientTickEvent tick){
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
index 0ce2b72b..ba674d81 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/GuiDungeonRoomEdit.java
@@ -6,7 +6,9 @@ import kr.syeyoung.dungeonsguide.roomedit.elements.MLabel;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
import java.awt.*;
import java.io.IOException;
@@ -24,17 +26,19 @@ public class GuiDungeonRoomEdit extends GuiScreen {
MLabel label = new MLabel();
label.setText("blah blah is great!");
label.setBackgroundColor(Color.BLACK);
+ label.setForeground(Color.white);
label.setBounds(new Rectangle(0,0,50,10));
mainPanel.add(label);
MButton mButton = new MButton();
mButton.setText("this is awesome");
- label.setBounds(new Rectangle(30,20,50,10));
- mainPanel.add(label);
+ mButton.setBounds(new Rectangle(30,20,50,10));
+ mainPanel.add(mButton);
}
@Override
public void initGui() {
+ super.initGui();
// update bounds
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
mainPanel.setBounds(new Rectangle((scaledResolution.getScaledWidth() - 500) / 2, (scaledResolution.getScaledHeight() - 300) / 2,500,300));
@@ -43,16 +47,22 @@ public class GuiDungeonRoomEdit extends GuiScreen {
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.render0(new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
+ GL11.glPushMatrix();
+ GlStateManager.pushAttrib();
+ mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
+ GlStateManager.popAttrib();
+ GL11.glPopMatrix();
}
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
+ super.keyTyped(typedChar, keyCode);
mainPanel.keyTyped0(typedChar, keyCode);
}
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
+ super.mouseClicked(mouseX, mouseY, mouseButton);
mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
index 6c8a1f50..a7bb008e 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/MPanel.java
@@ -2,6 +2,9 @@ package kr.syeyoung.dungeonsguide.roomedit;
import lombok.AccessLevel;
import lombok.Getter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.opengl.GL11;
import org.w3c.dom.css.Rect;
@@ -22,6 +25,7 @@ public class MPanel {
protected boolean isFocused;
public void setBackgroundColor(Color c) {
+ if (c == null) return;
this.backgroundColor = c;
}
@@ -40,6 +44,7 @@ public class MPanel {
}
public void setBounds(Rectangle bounds) {
+ if (bounds == null) return;
this.bounds.x = bounds.x;
this.bounds.y = bounds.y;
this.bounds.width = bounds.width;
@@ -54,23 +59,36 @@ public class MPanel {
this.childComponents.remove(panel);
}
- public void render0(Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a
+ public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a
+
+
int relMousex = relMousex0 - bounds.x;
int relMousey = relMousey0 - bounds.y;
- Rectangle absParent = parentClip.getBounds();
-
GL11.glPushAttrib(GL11.GL_SCISSOR_BIT);
GL11.glTranslated(bounds.x, bounds.y, 0);
- absParent.add(-bounds.x, -bounds.y);
Rectangle absBound = bounds.getBounds(); // 0,0 - a a
+ absBound.setLocation(absBound.x + parentPoint.x, absBound.y + parentPoint.y);
Rectangle clip = determineClip(parentClip, absBound);
+ GlStateManager.enableBlend();
+ GlStateManager.disableTexture2D();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ clip(resolution, clip.x, clip.y, clip.width, clip.height);
GL11.glEnable(GL11.GL_SCISSOR_TEST);
- GL11.glScissor(clip.x, clip.y, clip.width, clip.height);
+ if (backgroundColor != null)
+ GL11.glColor4ub((byte)backgroundColor.getRed(), (byte)backgroundColor.getGreen() , (byte)backgroundColor.getBlue() , (byte)backgroundColor.getAlpha() );
+
+ GL11.glBegin(GL11.GL_QUADS);
+ GL11.glVertex3i(0, 0,0);
+ GL11.glVertex3i(0, bounds.height,0);
+ GL11.glVertex3i(bounds.width, bounds.height,0);
+ GL11.glVertex3i(bounds.width, 0,0);
+ GL11.glEnd();
- GL11.glClearColor(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), backgroundColor.getAlpha());
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
GL11.glPushMatrix();
render(absMousex, absMousey, relMousex, relMousey, partialTicks);
@@ -80,13 +98,20 @@ public class MPanel {
GL11.glPopAttrib();
+ Point newPt = new Point(parentPoint.x + bounds.x, parentPoint.y + bounds.y);
+
for (MPanel mPanel : childComponents){
GL11.glPushMatrix();
- mPanel.render0(clip, absMousex, absMousey, relMousex, relMousey, partialTicks);
+ mPanel.render0(resolution, newPt, clip, absMousex, absMousey, relMousex, relMousey, partialTicks);
GL11.glPopMatrix();
}
}
+ public void clip(ScaledResolution resolution, int x, int y, int width, int height) {
+ int scale = resolution.getScaleFactor();
+ GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width + x) * scale, height * scale);
+ }
+
private Rectangle determineClip(Rectangle rect1, Rectangle rect2) {
int minX = Math.max(rect1.x, rect2.x);
int minY = Math.max(rect1.y, rect2.y);
@@ -107,7 +132,7 @@ public class MPanel {
if (isFocused)
keyTyped(typedChar, keyCode);
}
- protected void keyTyped(char typedChar, int keyCode) {};
+ protected void keyTyped(char typedChar, int keyCode) {}
protected boolean mouseClicked0(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int mouseButton) {
int relMousex = relMouseX0 - bounds.x;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java
index e6c675ca..430ca07f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/roomedit/elements/MButton.java
@@ -5,6 +5,7 @@ import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
import org.lwjgl.opengl.GL11;
import org.w3c.dom.css.Rect;
@@ -33,7 +34,7 @@ public class MButton extends MPanel {
} else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) {
bg = hover;
}
- GL11.glClearColor(bg.getRed(), bg.getGreen(), bg.getBlue(), bg.getAlpha());
+ Gui.drawRect(0,0,bounds.width, bounds.height, bg.getRGB());
FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj;
int width = renderer.getStringWidth(text);