Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package se.proxus.panels;
- import java.awt.Font;
- import java.util.ArrayList;
- import net.minecraft.src.ScaledResolution;
- import org.lwjgl.input.Mouse;
- import se.proxus.gui.*;
- import se.proxus.mods.*;
- import se.proxus.panels.list.panels.PPanels;
- import se.proxus.panels.list.utils.*;
- public abstract class BasePanel extends Methods {
- public BasePanel instance = null;
- public String name = "";
- public int x = 0;
- public int y = 0;
- public int width = 0;
- public int height = 0;
- public int rectY = 0;
- public int dragX = 0;
- public int dragY = 0;
- public int scrolled = 0;
- public boolean custom = false;
- public boolean dragging = false;
- public boolean open = false;
- public boolean pinned = false;
- public boolean buttonsSet = false;
- public ArrayList<BaseUtil> utilArray = new ArrayList<BaseUtil>();
- public BasePanel(String name, int x, int y, boolean custom) {
- this.name = name;
- this.x = x;
- this.y = y;
- this.width = 110;
- this.height = 12;
- this.custom = custom;
- this.instance = this;
- if(!(this.custom)) {
- this.setupPanel();
- }
- }
- public BasePanel(String name, int x, int y, int width, int height, boolean custom) {
- this.name = name;
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- this.custom = custom;
- this.instance = this;
- if(!(this.custom)) {
- this.setupPanel();
- }
- }
- public void setupPanel() {
- for(BaseMod var0 : this.pm.mods.modArray) {
- if(var0.getType().equalsIgnoreCase(this.name)) {
- this.addUtil(new UMod(this.width - 8, var0, this));
- }
- }
- }
- public void draw(int var0, int var1) {
- this.mouseDragged(var0, var1);
- this.drawRect(this.x + 0.5F, this.y + 0.5F, this.x + this.width - 0.5F, this.y + this.height + this.rectY + (this.open ? 0.5F : 0.0F), 0x40000000);
- this.drawHollowRect(this.x, this.y, this.x + this.width, this.y + this.height + this.rectY + (this.open ? 1.0F : 0.0F), 0xFF000000);
- this.drawGradientRect(this.x + 0.5F, this.y + 0.5F, this.x + this.width - 0.5F, this.y + this.height - 0.5F, 0xFF4F94CD, 0xFF436786);
- /*this.pm.ttf.drawString(this.name + "[§e" + this.utilArray.size() + "§r]", this.x + 1, this.y + 1.5F, 0xFF606060);
- this.pm.ttf.drawString(this.name, this.x + 1, this.y + 2.0F, 0xFFFFFFFF);*/
- this.drawPanelText(this.name + " [§e" + this.utilArray.size(), this.x + 1, this.y + 1.5F);
- this.drawPanelText("]", this.x + 1 + this.pm.ttf.getStringWidth(this.name + " [" + this.utilArray.size()), this.y + 1.5F);
- this.drawBox("X", this.x + this.width - 9, this.y + 1, 0xFFCD0000, 0xFF8B0000, false, var0, var1, false);
- this.drawBox("[]", this.x + this.width - 19, this.y + 1, 0xFFFFFFFF, 0xFFC0C0C0, true, var0, var1, this.pinned);
- this.drawBox("_", this.x + this.width - 29, this.y + 1, 0xFFFFFFFF, 0xFFC0C0C0, true, var0, var1, this.open);
- this.handleUtils(var0, var1);
- }
- public void handleUtils(int var0, int var1) {
- this.rectY = this.utilArray.size() * 12 + 2;
- if(this.open) {
- for(int var2 = 0; var2 < this.utilArray.size(); var2++) {
- BaseUtil var3 = (BaseUtil)this.utilArray.get(var2);
- var3.setPosition(this.x + 4, this.y + this.height + 1 + var2 * 12);
- this.pm.panels.startCut(this.x, this.y + this.height, this.x + this.width, this.y + this.height + this.rectY);
- var3.draw(var0, var1, this.scrolled);
- this.pm.panels.stopCut();
- this.buttonsSet = true;
- }
- } else {
- this.rectY = 0;
- this.buttonsSet = false;
- }
- }
- public void mouseClicked(int var0, int var1) {
- if(this.mouseInRec(var0, var1)) {
- this.dragX = var0 - this.x;
- this.dragY = var1 - this.y;
- this.dragging = true;
- this.pm.utils.playSound();
- this.pm.panels.sendPanelToTop(this);
- }
- if(this.mouseInBox(var0, var1, this.x + this.width - 9, this.y + 1) && !(this.instance instanceof PPanels)) {
- this.pm.panels.removePanel(this);
- this.pm.utils.playSound();
- this.pm.panels.sendPanelToTop(this);
- } if(this.mouseInBox(var0, var1, this.x + this.width - 19, this.y + 1)) {
- this.pinned =! this.pinned;
- this.pm.utils.playSound();
- this.pm.panels.sendPanelToTop(this);
- } if(this.mouseInBox(var0, var1, this.x + this.width - 29, this.y + 1)) {
- this.open =! this.open;
- this.pm.utils.playSound();
- this.pm.panels.sendPanelToTop(this);
- }
- if(this.buttonsSet) {
- for(BaseUtil var2 : this.utilArray) {
- var2.mouseClicked(var0, var1);
- }
- }
- }
- public void mouseDragged(int var0, int var1) {
- if(Mouse.isButtonDown(0) && this.dragging) {
- this.x = var0 - this.dragX;
- this.y = var1 - this.dragY;
- } else {
- this.dragging = false;
- }
- this.handleDraggingLogic(var0, var1);
- }
- public void handleDraggingLogic(int var0, int var1) {
- ScaledResolution var2 = new ScaledResolution(
- this.pm.wrapper.getMinecraft().gameSettings,
- this.pm.wrapper.getMinecraft().displayWidth,
- this.pm.wrapper.getMinecraft().displayHeight);
- /*for(BasePanel var3 : this.pm.panels.panelsArray) {
- if(var3 != this) {
- if(this.x + this.width + 1 >= var3.x && !(var3.x <= this.x - this.width) && !(this.y <= var3.y + 1)) {
- this.x = var3.x + this.width + 1;
- }
- }
- }*/
- if(this.x <= 0) {
- this.x = 0;
- } if(this.y <= 0) {
- this.y = 0;
- } if(this.y >= (var2.getScaledHeight() - this.height) && !(this.open)) {
- this.y = var2.getScaledHeight() - this.height;
- } if(this.y >= (var2.getScaledHeight() - this.height - this.rectY - 1) && this.open) {
- this.y = var2.getScaledHeight() - this.height - this.rectY - 1;
- } if(this.x >= (var2.getScaledWidth() - this.width)) {
- this.x = var2.getScaledWidth() - this.width;
- }
- }
- public void handleMouseInput() {
- /*if(this == this.pm.panels.current && this.utilArray.size() >= 5) {
- try {
- int var0 = Mouse.getEventDWheel();
- if(var0 != 0) {
- if(var0 > 1) {
- var0 = 1;
- }
- if(var0 < -1) {
- var0 = -1;
- }
- var0 *= 4;
- this.scrollPanel(var0);
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- }*/
- }
- public void scrollPanel(int var0) {
- this.scrolled -= var0;
- if(this.scrolled > this.utilArray.size() * this.utilArray.size() - this.utilArray.size()) {
- this.scrolled = this.utilArray.size() * this.utilArray.size() - this.utilArray.size();
- }
- if(this.scrolled <= 0) {
- this.scrolled = 0;
- }
- }
- public void keyTyped(char var0, int var1) {
- for(BaseUtil var2 : this.utilArray) {
- var2.keyTyped(var0, var1);
- }
- }
- public void addUtil(BaseUtil var0) {
- if(!(this.utilArray.contains(var0))) {
- this.utilArray.add(this.utilArray.size(), var0);
- }
- }
- public void removeUtil(BaseUtil var0) {
- if(this.utilArray.contains(var0)) {
- this.utilArray.remove(this.utilArray.indexOf(var0));
- }
- }
- public boolean mouseInRec(int var1, int var2) {
- return var1 >= this.x && var2 >= this.y && var1 <= this.x + this.width - 31 && var2 <= this.y + this.height;
- }
- public boolean mouseInRec(int var1, int var2, float x, float y, float x2, float y2) {
- return var1 >= x && var2 >= y && var1 <= x + x2 && var2 <= y + y2;
- }
- public boolean mouseInBox(int var0, int var1, float x, float y) {
- return var0 >= x && var1 >= y && var0 <= x + 7.5F && var1 <= y + 9.5F;
- }
- public void drawBox(String text, float x, float y, int hex0, int hex1, boolean flag, int var0, int var1, boolean state) {
- if(this.pm.wrapper.getMinecraft().currentScreen instanceof PanelHandler) {
- /*this.drawBorderedRect(x, y, x + 8, y + 10F, 0xFF000000, hex0);
- this.drawRect(x + 0.5F, y + 5F, x + 7.5F, y + 9.5F, hex1);
- this.drawRect(x + 1F, y + 1F, x + 7.5F, y + 9.5F, 0x20000000);*/
- //this.drawBorderedGradientRect(x, y, x + 8, y + 10, 0xFFA1A1A1, hex0, hex1);
- //this.drawGradientBox(x, y, x + 8, y + 10, state, text.equalsIgnoreCase("x"));
- if(this.mouseInBox(var0, var1, x, y) && this.pm.wrapper.getMinecraft().currentScreen instanceof PanelHandler) {
- this.drawRect(x, y, x + 7.5F, y + 9.5F, 0x20000000);
- }
- if(flag) {
- if(text.equalsIgnoreCase("[]")) {
- this.drawHollowRect(x + 1.5F, y + 1.5F, x + 6.5F, y + 8.5F, this.pinned ? 0xFFFFFFFF : 0xFF909090);
- this.drawHollowRect(x + 2F, y + 2F, x + 6.0F, y + 8.0F, this.pinned ? 0xFFFFFFFF : 0xFF909090);
- } if(text.equalsIgnoreCase("_")) {
- this.pm.ttf.drawString(text, x + 0.5F, y + 0.5F, this.open ? 0xFFFFFFFF : 0xFF909090);
- }
- } else {
- if(this.instance instanceof PPanels) {
- //this.pm.wrapper.getFontRenderer().drawString(text, x + 1.5F, y + 0.5F, 0xC0C0C0C0);
- this.pm.ttf.drawString(text, x + 0.5F, y + 1.0F, flag ? 0xFFFFFFFF : 0xFF909090);
- } else {
- this.pm.ttf.drawString(text, x + 0.5F, y + 0.5F, 0xFF808080);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement