begin work on cape chooser
This commit is contained in:
parent
9cfb18d0ba
commit
7cf3516828
39
src/main/java/dev/resent/cape/CapeManager.java
Normal file
39
src/main/java/dev/resent/cape/CapeManager.java
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
package dev.resent.cape;
|
||||||
|
|
||||||
|
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||||
|
import net.lax1dude.eaglercraft.v1_8.internal.FileChooserResult;
|
||||||
|
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
public class CapeManager {
|
||||||
|
|
||||||
|
public static void displayChooser(){
|
||||||
|
EagRuntime.displayFileChooser("image/png", "png");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResourceLocation capeLocation;
|
||||||
|
|
||||||
|
public static void loadCape(){
|
||||||
|
CapeManager.free();
|
||||||
|
if (EagRuntime.fileChooserHasResult()) {
|
||||||
|
FileChooserResult result = EagRuntime.getFileChooserResult();
|
||||||
|
if (result != null) {
|
||||||
|
ImageData loadedCape = ImageData.loadImageFile(result.fileData);
|
||||||
|
if(loadedCape != null){
|
||||||
|
capeLocation = Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("uploadedcape", new DynamicTexture(loadedCape));
|
||||||
|
Minecraft.getMinecraft().getTextureManager().bindTexture(capeLocation);
|
||||||
|
} else {
|
||||||
|
EagRuntime.showPopup("The selected file '" + result.fileName + "' is not a PNG file!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void free(){
|
||||||
|
Minecraft.getMinecraft().getTextureManager().deleteTexture(capeLocation);
|
||||||
|
capeLocation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
32
src/main/java/dev/resent/cape/CapeUi.java
Normal file
32
src/main/java/dev/resent/cape/CapeUi.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
package dev.resent.cape;
|
||||||
|
|
||||||
|
import dev.resent.client.Resent;
|
||||||
|
import dev.resent.module.base.RenderMod;
|
||||||
|
import dev.resent.ui.ClickGUI;
|
||||||
|
import net.lax1dude.eaglercraft.v1_8.Keyboard;
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
|
||||||
|
public class CapeUi extends GuiScreen {
|
||||||
|
|
||||||
|
public void initGui() {
|
||||||
|
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 148, "Back"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onGuiClosed() {
|
||||||
|
Keyboard.enableRepeatEvents(false);
|
||||||
|
mc.gameSettings.saveOptions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawScreen(int mx, int my, float par3) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
Resent.INSTANCE.modManager.modules.stream().filter(m -> m.isEnabled() && m instanceof RenderMod).forEach(rm -> ((RenderMod)rm).renderLayout(mx, my));
|
||||||
|
super.drawScreen(mx, my, par3);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||||
|
if (par1GuiButton.id == 200) {
|
||||||
|
this.mc.displayGuiScreen(new ClickGUI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user