-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-1.7.10 version is here. -Bug fixes. -Code cleanup.
- Loading branch information
Showing
35 changed files
with
2,479 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
1.7.10/src/main/java/code/elix_x/excore/utils/client/cursor/CursorHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package code.elix_x.excore.utils.client.cursor; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.nio.IntBuffer; | ||
|
||
import javax.imageio.ImageIO; | ||
|
||
import org.lwjgl.LWJGLException; | ||
import org.lwjgl.input.Cursor; | ||
import org.lwjgl.input.Mouse; | ||
|
||
import com.google.common.base.Throwables; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.util.ResourceLocation; | ||
|
||
public class CursorHelper { | ||
|
||
public static final Cursor defaultCursor = Mouse.getNativeCursor(); | ||
|
||
public static Cursor createCursor(ResourceLocation texture){ | ||
try { | ||
BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(texture).getInputStream()); | ||
return new Cursor(image.getWidth(), image.getHeight(), image.getWidth() / 2, image.getHeight() / 2, 1, IntBuffer.wrap(image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth())), null); | ||
} catch(Exception e){ | ||
throw Throwables.propagate(e); | ||
} | ||
} | ||
|
||
public static Cursor createCursor(ResourceLocation texture, int hotSpotX, int hotSpotY){ | ||
try { | ||
BufferedImage image = ImageIO.read(Minecraft.getMinecraft().getResourceManager().getResource(texture).getInputStream()); | ||
return new Cursor(image.getWidth(), image.getHeight(), hotSpotX, hotSpotY, 1, IntBuffer.wrap(image.getRGB(0, 0, image.getWidth(), image.getHeight(), null, 0, image.getWidth())), null); | ||
} catch(Exception e){ | ||
throw Throwables.propagate(e); | ||
} | ||
} | ||
|
||
public static void setCursor(Cursor cursor){ | ||
try { | ||
Mouse.setNativeCursor(cursor); | ||
} catch(LWJGLException e){ | ||
Throwables.propagate(e); | ||
} | ||
} | ||
|
||
public static void resetCursor(){ | ||
setCursor(defaultCursor); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
1.7.10/src/main/java/code/elix_x/excore/utils/client/gui/BasicGuiScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package code.elix_x.excore.utils.client.gui; | ||
|
||
import net.minecraft.client.gui.GuiScreen; | ||
|
||
public class BasicGuiScreen extends GuiScreen { | ||
|
||
public final GuiScreen parent; | ||
|
||
protected int guiWidth; | ||
protected int guiHeight; | ||
|
||
protected int xPos; | ||
protected int yPos; | ||
|
||
public BasicGuiScreen(GuiScreen parent, int guiWidth, int guiHeight){ | ||
this.parent = parent; | ||
this.guiWidth = guiWidth; | ||
this.guiHeight = guiHeight; | ||
} | ||
|
||
@Override | ||
public void initGui(){ | ||
xPos = (width - guiWidth) / 2; | ||
yPos = (height - guiHeight) / 2; | ||
} | ||
|
||
@Override | ||
protected void keyTyped(char c, int key){ | ||
if(key == 1){ | ||
onClose(); | ||
this.mc.displayGuiScreen(parent); | ||
return; | ||
} | ||
} | ||
|
||
protected void onClose(){ | ||
|
||
} | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
1.7.10/src/main/java/code/elix_x/excore/utils/client/gui/ColorSelectorGuiScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package code.elix_x.excore.utils.client.gui; | ||
|
||
import code.elix_x.excore.utils.client.gui.elements.ColoredRectangleGuiElement; | ||
import code.elix_x.excore.utils.client.gui.elements.IntegralSliderGuiElement; | ||
import code.elix_x.excore.utils.color.RGBA; | ||
import net.minecraft.client.gui.GuiScreen; | ||
|
||
public class ColorSelectorGuiScreen extends ElementalGuiScreen { | ||
|
||
protected RGBA color; | ||
|
||
public ColorSelectorGuiScreen(GuiScreen parent, RGBA color){ | ||
super(parent, 256, 104); | ||
this.color = color; | ||
} | ||
|
||
@Override | ||
protected void addElements(){ | ||
add(new ColoredRectangleGuiElement("Color Display", xPos + (guiWidth - 20) / 2, yPos, 20, 20, 0, 2, color)); | ||
|
||
nextY += 2 + 20 + 2; | ||
|
||
add(new ColoredRectangleGuiElement("Red Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(255, 0, 0, 255), new RGBA(0, 0, 0, 0), new RGBA(255, 0, 0, 255))); | ||
add(new IntegralSliderGuiElement("Red Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.r, true){ | ||
|
||
@Override | ||
protected void checkSliderValue(){ | ||
super.checkSliderValue(); | ||
color.r = getValue(); | ||
} | ||
|
||
}); | ||
|
||
nextY += 2 + 16 + 2; | ||
|
||
add(new ColoredRectangleGuiElement("Green Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(0, 255, 0, 255), new RGBA(0, 0, 0, 0), new RGBA(0, 255, 0, 255))); | ||
add(new IntegralSliderGuiElement("Green Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.g, true){ | ||
|
||
@Override | ||
protected void checkSliderValue(){ | ||
super.checkSliderValue(); | ||
color.g = getValue(); | ||
} | ||
|
||
}); | ||
|
||
nextY += 2 + 16 + 2; | ||
|
||
add(new ColoredRectangleGuiElement("Blue Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(0, 0, 255, 255), new RGBA(0, 0, 0, 0), new RGBA(0, 0, 255, 255))); | ||
add(new IntegralSliderGuiElement("Blue Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.b, true){ | ||
|
||
@Override | ||
protected void checkSliderValue(){ | ||
super.checkSliderValue(); | ||
color.b = getValue(); | ||
} | ||
|
||
}); | ||
|
||
nextY += 2 + 16 + 2; | ||
|
||
add(new ColoredRectangleGuiElement("Alpha Gradient", xPos, nextY, guiWidth, 16, 0, 2, new RGBA(0, 0, 0, 0), new RGBA(0, 0, 0, 255), new RGBA(0, 0, 0, 0), new RGBA(0, 0, 0, 255))); | ||
add(new IntegralSliderGuiElement("Alpha Slider", xPos, nextY, guiWidth, 16, 0, 2, 4, 0, 255, color.a, true){ | ||
|
||
@Override | ||
protected void checkSliderValue(){ | ||
super.checkSliderValue(); | ||
color.a = getValue(); | ||
} | ||
|
||
}); | ||
|
||
nextY += 2 + 16 + 2; | ||
} | ||
|
||
} |
111 changes: 111 additions & 0 deletions
111
1.7.10/src/main/java/code/elix_x/excore/utils/client/gui/ElementalGuiScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package code.elix_x.excore.utils.client.gui; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.lwjgl.input.Mouse; | ||
|
||
import code.elix_x.excore.utils.client.gui.elements.IGuiElement; | ||
import code.elix_x.excore.utils.client.gui.elements.IGuiElementsHandler; | ||
import net.minecraft.client.gui.GuiScreen; | ||
|
||
public class ElementalGuiScreen extends BasicGuiScreen implements IGuiElementsHandler<IGuiElement<ElementalGuiScreen>> { | ||
|
||
protected List<IGuiElement<ElementalGuiScreen>> elements = new ArrayList<IGuiElement<ElementalGuiScreen>>(); | ||
|
||
protected IGuiElement<ElementalGuiScreen> focused; | ||
|
||
protected int nextY; | ||
|
||
public ElementalGuiScreen(GuiScreen parent, int guiWidth, int guiHeight){ | ||
super(parent, guiWidth, guiHeight); | ||
} | ||
|
||
@Override | ||
public void add(IGuiElement<ElementalGuiScreen> element){ | ||
elements.add(element); | ||
} | ||
|
||
@Override | ||
public IGuiElement<ElementalGuiScreen> getFocused(){ | ||
return focused; | ||
} | ||
|
||
@Override | ||
public void setFocused(IGuiElement element){ | ||
focused = element; | ||
} | ||
|
||
@Override | ||
public void looseFocus(){ | ||
setFocused(null); | ||
} | ||
|
||
@Override | ||
public void initGui(){ | ||
super.initGui(); | ||
elements.clear(); | ||
nextY = yPos; | ||
addElements(); | ||
for(IGuiElement<ElementalGuiScreen> element : elements) element.initGui(this, parent); | ||
} | ||
|
||
protected void addElements(){ | ||
|
||
} | ||
|
||
@Override | ||
public void drawScreen(int mouseX, int mouseY, float partialTicks){ | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
element.drawGuiPre(this, this, mouseX, mouseY); | ||
} | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
element.drawBackground(this, this, mouseX, mouseY); | ||
} | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
element.drawGuiPost(this, this, mouseX, mouseY); | ||
} | ||
} | ||
|
||
@Override | ||
protected void keyTyped(char c, int key){ | ||
super.keyTyped(c, key); | ||
if(focused != null && focused.handleKeyboardEvent(this, this, true, key, c)) return; | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
if(element != focused && element.handleKeyboardEvent(this, this, true, key, c)) return; | ||
} | ||
} | ||
|
||
@Override | ||
public void handleMouseInput(){ | ||
super.handleMouseInput(); | ||
int dWheel = Mouse.getEventDWheel(); | ||
if(dWheel != 0){ | ||
int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth; | ||
int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; | ||
if(focused != null && focused.handleMouseEvent(this, this, mouseX, mouseY, dWheel)) return; | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
if(element != focused && element.handleMouseEvent(this, this, mouseX, mouseY, dWheel)) return; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
protected void mouseClicked(int mouseX, int mouseY, int key){ | ||
if(focused != null && focused.handleMouseEvent(this, this, mouseX, mouseY, true, key)) return; | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
if(element != focused && element.handleMouseEvent(this, this, mouseX, mouseY, true, key)) return; | ||
} | ||
super.mouseClicked(mouseX, mouseY, key); | ||
} | ||
|
||
@Override | ||
protected void mouseMovedOrUp(int mouseX, int mouseY, int key){ | ||
if(focused != null && focused.handleMouseEvent(this, this, mouseX, mouseY, false, key)) return; | ||
for(IGuiElement<ElementalGuiScreen> element : elements){ | ||
if(element != focused && element.handleMouseEvent(this, this, mouseX, mouseY, false, key)) return; | ||
} | ||
super.mouseMovedOrUp(mouseX, mouseY, key); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
1.7.10/src/main/java/code/elix_x/excore/utils/client/gui/elements/ButtonGuiElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package code.elix_x.excore.utils.client.gui.elements; | ||
|
||
import cpw.mods.fml.client.config.GuiButtonExt; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
|
||
public class ButtonGuiElement<H extends IGuiElementsHandler<? extends IGuiElement<H>>> extends RectangularGuiElement<H> { | ||
|
||
protected GuiButtonExt button; | ||
|
||
public ButtonGuiElement(String name, int xPos, int yPos, int width, int height, int borderX, int borderY, String buttonText){ | ||
super(name, xPos, yPos, width, height, borderX, borderY); | ||
this.button = new GuiButtonExt(0, xPos + borderX, yPos + borderY, width, height, buttonText); | ||
} | ||
|
||
@Override | ||
public void openGui(H handler, GuiScreen gui){ | ||
|
||
} | ||
|
||
@Override | ||
public void initGui(H handler, GuiScreen gui){ | ||
|
||
} | ||
|
||
@Override | ||
public void drawGuiPre(H handler, GuiScreen gui, int mouseX, int mouseY){ | ||
|
||
} | ||
|
||
@Override | ||
public void drawBackground(H handler, GuiScreen gui, int mouseX, int mouseY){ | ||
|
||
} | ||
|
||
@Override | ||
public void drawGuiPost(H handler, GuiScreen gui, int mouseX, int mouseY){ | ||
button.drawButton(gui.mc, mouseX, mouseY); | ||
} | ||
|
||
@Override | ||
public void drawGuiPostPost(H handler, GuiScreen gui, int mouseX, int mouseY){ | ||
|
||
} | ||
|
||
@Override | ||
public boolean handleKeyboardEvent(H handler, GuiScreen gui, boolean down, int key, char c){ | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean handleMouseEvent(H handler, GuiScreen gui, int mouseX, int mouseY, boolean down, int key){ | ||
if(down && key == 0 && button.mousePressed(gui.mc, mouseX, mouseY)){ | ||
onButtonPressed(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public void onButtonPressed(){ | ||
button.func_146113_a(Minecraft.getMinecraft().getSoundHandler()); | ||
} | ||
|
||
@Override | ||
public boolean handleMouseEvent(H handler, GuiScreen gui, int mouseX, int mouseY, int dWheel){ | ||
return false; | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
.../src/main/java/code/elix_x/excore/utils/client/gui/elements/CenteredStringGuiElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package code.elix_x.excore.utils.client.gui.elements; | ||
|
||
import code.elix_x.excore.utils.color.RGBA; | ||
import net.minecraft.client.gui.FontRenderer; | ||
|
||
public class CenteredStringGuiElement<H extends IGuiElementsHandler<? extends IGuiElement<H>>> extends StringGuiElement<H> { | ||
|
||
public CenteredStringGuiElement(String name, int xPos, int yPos, int borderX, int borderY, String text, FontRenderer fontRenderer, RGBA color){ | ||
super(name, xPos - fontRenderer.getStringWidth(text) / 2, yPos, borderX, borderY, text, fontRenderer, color); | ||
} | ||
|
||
} |
Oops, something went wrong.