Move of stuffs

This commit is contained in:
WayofTime 2014-11-03 21:10:17 -05:00
parent 7946a7c226
commit 0051a43398
26 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,83 @@
package bloodutils.api.classes.guide;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import bloodutils.api.classes.guide.elements.ElementCategory;
import bloodutils.api.compact.Category;
import bloodutils.api.registries.EntryRegistry;
public class GuiCategories extends GuiScreen{
public GuiCategories(EntityPlayer player){
this.player = player;
}
private static final ResourceLocation gui = new ResourceLocation("bloodutils:textures/gui/front.png");
int gwidth = 192;
int gheight = 192;
int x, y;
ElementCategory[] categories = new ElementCategory[EntryRegistry.categories.size()];
EntityPlayer player;
@Override
public void initGui(){
super.initGui();
x = (this.width/2) - (gwidth/2);
y = (this.height/2) - (gheight/2);
this.buttonList.clear();
int pX = x - 1;
int pY = y + 12;
int iWidth = 20;
int iHeight = 20;
for(int i = 0; i < EntryRegistry.categories.size(); i++){
Category category = EntryRegistry.categories.get(i);
this.categories[i] = new ElementCategory(category, pX, pY + (i*iHeight) - 2, iWidth, iHeight, this.player);
}
}
@Override
public void drawScreen(int mX, int mY, float f1){
super.drawScreen(mX, mY, f1);
int fHeight = Minecraft.getMinecraft().fontRenderer.FONT_HEIGHT;
GL11.glColor4f(1F, 1F, 1F, 1F);
this.mc.renderEngine.bindTexture(gui);
drawTexturedModalRect(x, y, 0, 0, gwidth, gheight);
/** Title */
String str = "Categories";
this.drawCenteredString(fontRendererObj, str, this.x + gwidth / 2, y - 15, 0x336666);
for(int i = 0; i < EntryRegistry.categories.size(); i++){
ElementCategory category = this.categories[i];
category.drawElement();
if(category.isMouseInElement(mX, mY)){
category.onMouseEnter(mX, mY);
}
}
}
@Override
public void mouseClicked(int mX, int mY, int type){
super.mouseClicked(mX, mY, type);
for(int i = 0; i < EntryRegistry.categories.size(); i++){
ElementCategory category = this.categories[i];
if(category.isMouseInElement(mX, mY)){
category.onMouseClick(mX, mY, type);
}
}
}
@Override
public boolean doesGuiPauseGame(){
return false;
}
}

View file

@ -0,0 +1,150 @@
package bloodutils.api.classes.guide;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import bloodutils.api.classes.guide.buttons.ButtonNext;
import bloodutils.api.compact.Category;
import bloodutils.api.compact.Entry;
import bloodutils.api.entries.IEntry;
import bloodutils.api.registries.EntryRegistry;
public class GuiEntry extends GuiScreen{
public GuiEntry(String key, EntityPlayer player, Category category){
this.key = key;
this.player = player;
this.category = category;
}
public GuiEntry(String key, EntityPlayer player, Category category, int currPage){
this.key = key;
this.player = player;
this.category = category;
this.currPage = currPage;
}
private static final ResourceLocation gui = new ResourceLocation("bloodutils:textures/gui/guide.png");
int gwidth = 192;
int gheight = 192;
int prevPage;
int left, top;
String key;
int currPage = 1;
GuiButton next, prev, back;
EntityPlayer player;
Category category;
@SuppressWarnings("unchecked")
@Override
public void initGui(){
super.initGui();
left = (this.width/2) - (gwidth/2);
top = (this.height/2) - (gheight/2);
this.buttonList.clear();
int k = (this.width - this.gwidth) / 2;
this.buttonList.add(next = new ButtonNext(500, k + 120, top + 160, true));
this.buttonList.add(prev = new ButtonNext(501, k + 38, top + 160, false));
Entry e = EntryRegistry.entries.get(this.category).get(this.key);
if(e != null){
IEntry entry = e.entry[this.currPage - 1];
if(entry != null)
entry.initGui(gwidth, gheight, left, top, player, this.buttonList);
}else{
mc.displayGuiScreen(new GuiCategories(this.player));
}
}
@Override
public void drawScreen(int mX, int mY, float f1){
GL11.glColor4f(1F, 1F, 1F, 1F);
this.mc.renderEngine.bindTexture(gui);
drawTexturedModalRect(left, top, 0, 0, gwidth, gheight);
Entry e = EntryRegistry.entries.get(this.category).get(this.key);
/** Title */
String str = e.name;
this.drawCenteredString(fontRendererObj, str, this.left + gwidth / 2, top - 15, 0x336666);
/** Current Page */
this.drawCenteredString(fontRendererObj, (currPage) + "/" + (e.entry.length), this.left + gwidth / 2, top + 160, 0x336666);
IEntry entry = e.entry[currPage - 1];
if(entry != null){
entry.draw(this, gwidth, gheight, left, top, player, e.name, currPage, mX, mY);
}
super.drawScreen(mX, mY, f1);
}
@Override
public void mouseClicked(int mX, int mY, int type){
super.mouseClicked(mX, mY, type);
if(type == 1)
mc.displayGuiScreen(new GuiIndex(this.category, this.player));
}
@Override
public void keyTyped(char c, int i){
super.keyTyped(c, i);
if(Keyboard.getEventKeyState()){
if(i == 14){
mc.displayGuiScreen(new GuiIndex(this.category, this.player));
return;
}
}
}
@Override
public boolean doesGuiPauseGame(){
return false;
}
@Override
protected void actionPerformed(GuiButton button){
int id = button.id;
int maxPages = EntryRegistry.entries.get(this.category).get(this.key).entry.length;
if(id == 500){
if(currPage < maxPages){
currPage++;
initGui();
}
}else if(id == 501){
if(currPage > 1){
currPage--;
initGui();
}
}else{
Entry e = EntryRegistry.entries.get(this.category).get(this.key);
if(e != null){
IEntry entry = e.entry[this.currPage];
if(entry != null)
entry.actionPerformed(button);
}else{
mc.displayGuiScreen(new GuiCategories(this.player));
}
}
}
@Override
public void onGuiClosed(){
ItemStack held = player.getHeldItem();
if(held.hasTagCompound()){
held.getTagCompound().setString("CATEGORY", this.category.name);
held.getTagCompound().setString("KEY", this.key);
held.getTagCompound().setInteger("PAGE", this.currPage);
}
}
}

View file

@ -0,0 +1,213 @@
package bloodutils.api.classes.guide;
import java.util.HashMap;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import bloodutils.api.classes.guide.buttons.ButtonNext;
import bloodutils.api.classes.guide.buttons.ButtonPage;
import bloodutils.api.classes.guide.elements.ElementCategory;
import bloodutils.api.compact.Category;
import bloodutils.api.compact.Entry;
import bloodutils.api.registries.EntryRegistry;
public class GuiIndex extends GuiScreen{
public GuiIndex(Category category, EntityPlayer player){
this.category = category;
this.player = player;
}
public GuiIndex(Category category, EntityPlayer player, int currPage){
this.category = category;
this.player = player;
this.currPage = currPage;
}
private static final ResourceLocation gui = new ResourceLocation("bloodutils:textures/gui/guide.png");
GuiButton prev, next, back;
Category category;
EntityPlayer player;
ElementCategory[] categories = new ElementCategory[EntryRegistry.categories.size()];
int gwidth = 192;
int gheight = 192;
int left, top;
int currPage = 0;
@SuppressWarnings("unchecked")
@Override
public void initGui(){
super.initGui();
left = (this.width/2) - (gwidth/2);
top = (this.height/2) - (gheight/2);
this.buttonList.clear();
populate();
drawCategories();
int k = (this.width - this.gwidth) / 2;
this.buttonList.add(next = new ButtonNext(500, k + 120, top + 160, true));
this.buttonList.add(prev = new ButtonNext(501, k + 38, top + 160, false));
}
public void drawCategories(){
int pX = left - 1;
int pY = top + 12;
int iWidth = 20;
int iHeight = 20;
for(int i = 0; i < EntryRegistry.categories.size(); i++){
Category category = EntryRegistry.categories.get(i);
this.categories[i] = new ElementCategory(category, pX, pY + (i*iHeight) - 2, iWidth, iHeight, this.player);
}
}
@SuppressWarnings("unchecked")
public void populate(){
this.buttonList.clear();
HashMap<String, Entry> entries = EntryRegistry.entries.get(this.category);
int x, y;
if(entries != null && !entries.isEmpty()){
int j = 0;
for(int i = 0; i < entries.size(); i++){
Entry entry = (Entry)entries.values().toArray()[i];
if(entry != null && entry.indexPage == this.currPage){
x = this.left + gwidth / 2 - 75;
y = (top + 15) + (10*j);
buttonList.add(new ButtonPage(j, x, y, 110, 10, ""));
j++;
}
}
}
int k = (this.width - this.gwidth) / 2;
this.buttonList.add(next = new ButtonNext(500, k + 120, top + 160, true));
this.buttonList.add(prev = new ButtonNext(501, k + 38, top + 160, false));
}
@Override
public void drawScreen(int mX, int mY, float f1){
GL11.glColor4f(1F, 1F, 1F, 1F);
this.mc.renderEngine.bindTexture(gui);
drawTexturedModalRect(left, top, 0, 0, gwidth, gheight);
/** Title */
String str = category.name;
this.drawCenteredString(fontRendererObj, str, this.left + gwidth / 2, top - 15, 0x336666);
/** Current Page */
if(this.category != null && EntryRegistry.maxEntries.containsKey(this.category)){
int size = EntryRegistry.maxEntries.get(this.category);
this.drawCenteredString(fontRendererObj, (currPage + 1) + "/" + (size + 1), this.left + gwidth / 2, top + 160, 0x336666);
registerButtons();
}
for(int i = 0; i < EntryRegistry.categories.size(); i++){
ElementCategory category = this.categories[i];
category.drawElement();
if(category.isMouseInElement(mX, mY)){
category.onMouseEnter(mX, mY);
}
}
super.drawScreen(mX, mY, f1);
}
public void registerButtons(){
HashMap<String, Entry> entries = EntryRegistry.entries.get(this.category);
if(entries != null && !entries.isEmpty()){
int j = 0;
for(int i = 0; i < entries.size(); i++){
Entry entry = (Entry)entries.values().toArray()[i];
if(entry != null && entry.indexPage == this.currPage){
String title = entry.name;
if(title != null && buttonList.get(j) != null && buttonList.get(j) instanceof ButtonPage){
ButtonPage button = (ButtonPage) buttonList.get(j);
button.displayString = title;
j++;
}
}
}
}
}
@Override
public void mouseClicked(int mX, int mY, int type){
super.mouseClicked(mX, mY, type);
if(type == 1)
mc.displayGuiScreen(new GuiCategories(this.player));
for(int i = 0; i < EntryRegistry.categories.size(); i++){
ElementCategory category = this.categories[i];
if(category.isMouseInElement(mX, mY)){
category.onMouseClick(mX, mY, type);
}
}
}
@Override
public boolean doesGuiPauseGame(){
return false;
}
@Override
protected void actionPerformed(GuiButton button){
int id = button.id;
int size;
if(EntryRegistry.maxEntries.containsKey(this.category))
size = EntryRegistry.maxEntries.get(this.category);
else
size = 1;
if(id == 500){
if(currPage + 1 < size + 1){
currPage++;
populate();
registerButtons();
}
}else if(id == 501){
if(currPage > 0){
currPage--;
populate();
registerButtons();
}
}else{
mc.displayGuiScreen(new GuiEntry(button.displayString, player, category));
}
}
@Override
public void keyTyped(char c, int i){
super.keyTyped(c, i);
if(Keyboard.getEventKeyState()){
if(i == 14){
mc.displayGuiScreen(new GuiCategories(this.player));
return;
}
}
}
@Override
public void onGuiClosed(){
ItemStack held = player.getHeldItem();
if(held.hasTagCompound()){
held.getTagCompound().setString("CATEGORY", this.category.name);
held.getTagCompound().setString("KEY", "0");
held.getTagCompound().setInteger("PAGE", this.currPage);
}
}
}

View file

@ -0,0 +1,38 @@
package bloodutils.api.classes.guide.buttons;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
public class ButtonNext extends GuiButton {
private final boolean field_146151_o;
public ButtonNext(int id, int x, int y, boolean p_i1079_4_){
super(id, x, y, 23, 13, "");
this.field_146151_o = p_i1079_4_;
}
public void drawButton(Minecraft mc, int p_146112_2_, int p_146112_3_){
if (this.visible){
boolean flag = p_146112_2_ >= this.xPosition && p_146112_3_ >= this.yPosition && p_146112_2_ < this.xPosition + this.width && p_146112_3_ < this.yPosition + this.height;
GL11.glEnable(GL11.GL_BLEND);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(new ResourceLocation("bloodutils:textures/gui/guide.png"));
int k = 0;
int l = 192;
if (flag){
k += 23;
}
if (!this.field_146151_o){
l += 13;
}
this.drawTexturedModalRect(this.xPosition, this.yPosition, k, l, 23, 13);
GL11.glDisable(GL11.GL_BLEND);
}
}
}

View file

@ -0,0 +1,33 @@
package bloodutils.api.classes.guide.buttons;
import java.awt.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
public class ButtonPage extends GuiButton {
public ButtonPage(int id, int xPos, int yPos, int width, int height, String string) {
super(id, xPos, yPos, width, height, string);
}
int gwidth = 170;
int gheight = 180;
@Override
public void drawButton(Minecraft mc, int x, int y) {
field_146123_n = x >= xPosition && y >= yPosition && x < xPosition + width && y < yPosition + height;
int state = getHoverState(field_146123_n);
x = this.xPosition + width / 2 - 30;
y = this.yPosition + (height - 6) / 2;
mc.fontRenderer.setUnicodeFlag(true);
mc.fontRenderer.drawString(displayString, x + (state == 2 ? 5 : 0), y, calcColor(state));
mc.fontRenderer.setUnicodeFlag(false);
}
public int calcColor(int state){
if(state == 2)
return new Color(155, 155, 155).getRGB();
else
return new Color(55, 55, 55).getRGB();
}
}

View file

@ -0,0 +1,55 @@
package bloodutils.api.classes.guide.elements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import bloodutils.api.classes.guide.GuiIndex;
import bloodutils.api.compact.Category;
import bloodutils.api.helpers.GuiHelper;
import bloodutils.api.interfaces.IEntryElement;
public class ElementCategory extends GuiScreen implements IEntryElement{
public ElementCategory(Category category, int x, int y, int width, int height, EntityPlayer player) {
this.category = category;
this.player = player;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public Category category;
public EntityPlayer player;
public int x;
public int y;
public int width;
public int height;
@Override
public void drawElement() {
IIcon icon = category.iconStack.getIconIndex();
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("bloodutils:textures/misc/tab.png"));
GuiHelper.drawIconWithoutColor(x - 1, y - 1, width + 2 , height + 2, 0);
GuiHelper.renderIcon(x + 3, y + 2, 16, 16, icon, this.category.type);
}
@Override
public boolean isMouseInElement(int mX, int mY) {
return GuiHelper.isMouseBetween(mX, mY, x, y, width, height);
}
@Override
public void onMouseEnter(int mX, int mY) {
Minecraft.getMinecraft().fontRenderer.drawString(this.category.name, mX + 6, mY, 0);
}
@Override
public void onMouseClick(int mX, int mY, int type){
Minecraft.getMinecraft().displayGuiScreen(new GuiIndex(this.category, this.player));
}
}