char gui
This commit is contained in:
parent
09ce79e666
commit
868a5ed9ea
7 changed files with 366 additions and 2087 deletions
File diff suppressed because it is too large
Load diff
|
@ -4608,7 +4608,7 @@ public abstract class EntityNPC extends EntityLiving
|
||||||
|
|
||||||
public LayerExtra getExtrasLayer()
|
public LayerExtra getExtrasLayer()
|
||||||
{
|
{
|
||||||
return this.isPlayer() ? EntityTexManager.getLayer(this.getId()) : EntityTexManager.getNpcLayer(this.getChar());
|
return this.isPlayer() ? EntityTexManager.getLayer(this.getId(), this.species.renderer) : EntityTexManager.getNpcLayer(this.getChar(), this.species.renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocationSkin()
|
public String getLocationSkin()
|
||||||
|
|
|
@ -106,7 +106,8 @@ public class GuiMenu extends Gui {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.add(new ActButton(0, 0, 400, 24, (Gui)null, "Zurück zum Spiel"));
|
this.add(new ActButton(0, 0, 400, 24, (Gui)null, "Zurück zum Spiel"));
|
||||||
this.add(new ActButton(0, 28, 400, 24, GuiOptions.getPage(), "Einstellungen"));
|
this.add(new ActButton(0, 28, 198, 24, GuiOptions.getPage(), "Einstellungen"));
|
||||||
|
this.add(new ActButton(202, 28, 198, 24, GuiSkin.INSTANCE, "Charakter"));
|
||||||
if(!this.gm.isRemote() && !this.gm.debugWorld) {
|
if(!this.gm.isRemote() && !this.gm.debugWorld) {
|
||||||
this.add(new Textbox(0, 56, 96, 24, 5, true, new Textbox.Callback() {
|
this.add(new Textbox(0, 56, 96, 24, 5, true, new Textbox.Callback() {
|
||||||
public void use(Textbox elem, Action value) {
|
public void use(Textbox elem, Action value) {
|
||||||
|
|
|
@ -8,66 +8,66 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL13;
|
||||||
|
|
||||||
import game.Game;
|
import game.Game;
|
||||||
import game.audio.SoundManager;
|
|
||||||
import game.collect.Lists;
|
|
||||||
import game.collect.Sets;
|
|
||||||
import game.entity.npc.Alignment;
|
import game.entity.npc.Alignment;
|
||||||
import game.entity.npc.CharacterInfo;
|
import game.entity.npc.CharacterInfo;
|
||||||
import game.entity.npc.EntityNPC;
|
import game.entity.npc.EntityNPC;
|
||||||
import game.entity.npc.ModelPart;
|
|
||||||
import game.entity.npc.SpeciesInfo;
|
import game.entity.npc.SpeciesInfo;
|
||||||
import game.gui.element.Button;
|
import game.entity.types.EntityLiving;
|
||||||
|
import game.gui.element.ActButton;
|
||||||
|
import game.gui.element.ActButton.Mode;
|
||||||
|
import game.gui.element.Element;
|
||||||
|
import game.gui.element.GuiList;
|
||||||
|
import game.gui.element.Label;
|
||||||
|
import game.gui.element.ListEntry;
|
||||||
import game.gui.element.Slider;
|
import game.gui.element.Slider;
|
||||||
import game.gui.element.TextField;
|
import game.gui.element.Textbox;
|
||||||
import game.gui.element.Slider.SliderReceiver;
|
import game.gui.element.Textbox.Action;
|
||||||
import game.gui.inventory.GuiInventory;
|
|
||||||
import game.init.EntityRegistry;
|
import game.init.EntityRegistry;
|
||||||
import game.init.SpeciesRegistry;
|
import game.init.SpeciesRegistry;
|
||||||
import game.init.SpeciesRegistry.ModelType;
|
import game.init.SpeciesRegistry.ModelType;
|
||||||
import game.io.FileUtils;
|
import game.log.Log;
|
||||||
import game.io.Log;
|
|
||||||
import game.lib.input.Keyboard;
|
|
||||||
import game.network.NetHandlerPlayServer;
|
import game.network.NetHandlerPlayServer;
|
||||||
import game.packet.CPacketAction;
|
import game.packet.CPacketAction;
|
||||||
import game.packet.CPacketMessage;
|
import game.packet.CPacketMessage;
|
||||||
import game.renderer.FontRenderer;
|
import game.packet.CPacketSkin;
|
||||||
|
import game.renderer.Drawing;
|
||||||
import game.renderer.GlState;
|
import game.renderer.GlState;
|
||||||
import game.renderer.texture.DynamicTexture;
|
import game.renderer.ItemRenderer;
|
||||||
|
import game.renderer.entity.Render;
|
||||||
|
import game.renderer.entity.RenderManager;
|
||||||
import game.renderer.texture.EntityTexManager;
|
import game.renderer.texture.EntityTexManager;
|
||||||
import game.renderer.texture.TextureUtil;
|
import game.renderer.texture.TextureUtil;
|
||||||
import game.util.Predicate;
|
import game.util.FileUtils;
|
||||||
|
import game.util.SkinConverter;
|
||||||
|
import game.window.Button;
|
||||||
|
|
||||||
public class GuiSkin extends GuiScreen
|
public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
|
||||||
{
|
{
|
||||||
private static class SkinEntry implements GuiListExtended.IGuiListEntry
|
protected class SkinEntry implements ListEntry
|
||||||
{
|
{
|
||||||
private static final String SKINS_BUTTONS = "textures/gui/server_selection.png";
|
|
||||||
|
|
||||||
private final GuiSkin owner;
|
|
||||||
private final Game gm;
|
|
||||||
private final File skinFile;
|
private final File skinFile;
|
||||||
private final String id;
|
private final String id;
|
||||||
private final ModelType model;
|
private final ModelType model;
|
||||||
private final CharacterInfo charinfo;
|
private final CharacterInfo charinfo;
|
||||||
private final BufferedImage skinImage;
|
private final BufferedImage skinImage;
|
||||||
private final String icon;
|
// private final String icon;
|
||||||
private DynamicTexture dyntex;
|
// private DynamicTexture dyntex;
|
||||||
private long clickTime;
|
private final int dynId;
|
||||||
|
|
||||||
protected SkinEntry(GuiSkin parent, String id, File file, CharacterInfo charinfo, BufferedImage image, ModelType model)
|
protected SkinEntry(String id, File file, CharacterInfo charinfo, BufferedImage image, ModelType model)
|
||||||
{
|
{
|
||||||
this.owner = parent;
|
// this.owner = parent;
|
||||||
this.skinFile = file;
|
this.skinFile = file;
|
||||||
this.charinfo = charinfo;
|
this.charinfo = charinfo;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.gm = Game.getGame();
|
// this.gm = Game.getGame();
|
||||||
if(this.skinFile != null) // {
|
if(this.skinFile != null) // {
|
||||||
this.skinImage = image;
|
this.skinImage = image;
|
||||||
// this.skin = skin.getName().substring(0, skin.getName().length() - 4);
|
// this.skin = skin.getName().substring(0, skin.getName().length() - 4);
|
||||||
|
@ -77,43 +77,61 @@ public class GuiSkin extends GuiScreen
|
||||||
// this.skin = null;
|
// this.skin = null;
|
||||||
// }
|
// }
|
||||||
if(this.skinImage != null) {
|
if(this.skinImage != null) {
|
||||||
this.icon = "skins/" + this.id + "/icon";
|
int w = this.skinImage.getWidth();
|
||||||
this.dyntex = new DynamicTexture(this.skinImage);
|
int h = this.skinImage.getHeight();
|
||||||
this.gm.getTextureManager().loadTexture(this.icon, this.dyntex);
|
int[] data = new int[w * h];
|
||||||
|
this.skinImage.getRGB(0, 0, w, h, data, 0, w);
|
||||||
|
this.dynId = 0xffff0000 + GuiSkin.this.elements.size();
|
||||||
|
EntityTexManager.setTexture(this.dynId, EntityTexManager.imageToComp(data, model), model);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.icon = null;
|
this.dynId = -1;
|
||||||
this.dyntex = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected)
|
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||||
{
|
{
|
||||||
// FontRenderer.drawString(this.skin == null ? "---" : this.skin, x + 32 + 3, y + 1, 16777215);
|
// FontRenderer.drawString(this.skin == null ? "---" : this.skin, x + 32 + 3, y + 1, 16777215);
|
||||||
List<String> list = FontRenderer.listFormattedStringToWidth((this.skinFile != null ? this.skinFile.getName()
|
String str = // List<String> list = FontRenderer.listFormattedStringToWidth(
|
||||||
|
(this.skinFile != null ? this.skinFile.getName()
|
||||||
: (this.charinfo == null ? "Standard" : (
|
: (this.charinfo == null ? "Standard" : (
|
||||||
(this.charinfo.species.prefix && this.charinfo.spclass != null && this.charinfo.spclass.type != null ?
|
(this.charinfo.species.prefix && this.charinfo.spclass != null && this.charinfo.spclass.type != null ?
|
||||||
this.charinfo.spclass.type.toString() :
|
this.charinfo.spclass.type.toString() :
|
||||||
EntityRegistry.getEntityName(this.charinfo.species.id))
|
EntityRegistry.getEntityName(this.charinfo.species.id))
|
||||||
+ (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)) + " (" + this.charinfo.skin + ")")))
|
+ (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)) + " (" + this.charinfo.skin + ")")));
|
||||||
// + TextColor.LIGHT_GRAY + " (" + TextColor.GREEN +
|
// + TextColor.LIGHT_GRAY + " (" + TextColor.GREEN +
|
||||||
// this.model.display + TextColor.LIGHT_GRAY +")"
|
// this.model.display + TextColor.LIGHT_GRAY +")"
|
||||||
, listWidth - 16 - 2);
|
// , listWidth - 16 - 2);
|
||||||
|
//
|
||||||
for (int i = 0; i < Math.min(list.size(), 2); ++i)
|
// for (int i = 0; i < Math.min(list.size(), 2); ++i)
|
||||||
{
|
// {
|
||||||
FontRenderer.drawString((String)list.get(i), x + 16 + 3, y + FontRenderer.FONT_HEIGHT * i, this.charinfo == null ?
|
Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ?
|
||||||
(this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2);
|
(this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2));
|
||||||
}
|
// }
|
||||||
|
|
||||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
// if(this.model != ModelType.HUMANOID) {
|
// if(this.model != ModelType.HUMANOID) {
|
||||||
// this.drawTextureAt(x, y, EntitySkinManager.HEAD_DEF);
|
// this.drawTextureAt(x, y, EntitySkinManager.HEAD_DEF);
|
||||||
// }
|
// }
|
||||||
if (this.dyntex != null)
|
|
||||||
|
if (/* this.gm.touchscreen || */ hovered)
|
||||||
{
|
{
|
||||||
this.drawTextureAt(x, y, this.icon);
|
// GuiSkin.this.gm.getTextureManager().bindTexture(SKINS_BUTTONS);
|
||||||
|
Drawing.drawRectColor(x, y, 64, 64, -1601138544);
|
||||||
|
// GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
// int k1 = mouseX - x;
|
||||||
|
// int l1 = mouseY - y;
|
||||||
|
//
|
||||||
|
// if (k1 < 16 && k1 > 0)
|
||||||
|
// {
|
||||||
|
// Gui.drawScaledCustomSizeModalRect(x, y, 0.0F, 32.0F, 32, 32, 16, 16, 256.0F, 256.0F);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dynId != -1)
|
||||||
|
{
|
||||||
|
this.drawTextureAt(x, y, EntityTexManager.getSkin(this.dynId, this.model));
|
||||||
}
|
}
|
||||||
else if(this.charinfo == null)
|
else if(this.charinfo == null)
|
||||||
{
|
{
|
||||||
|
@ -124,76 +142,74 @@ public class GuiSkin extends GuiScreen
|
||||||
this.drawTextureAt(x, y, EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ?
|
this.drawTextureAt(x, y, EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ?
|
||||||
this.charinfo.skin.substring(1) : this.charinfo.skin));
|
this.charinfo.skin.substring(1) : this.charinfo.skin));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (/* this.gm.touchscreen || */ isSelected)
|
|
||||||
{
|
|
||||||
this.gm.getTextureManager().bindTexture(SKINS_BUTTONS);
|
|
||||||
Gui.drawRect(x, y, x + 16, y + 16, -1601138544);
|
|
||||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
int k1 = mouseX - x;
|
|
||||||
int l1 = mouseY - y;
|
|
||||||
|
|
||||||
if (k1 < 16 && k1 > 0)
|
|
||||||
{
|
|
||||||
Gui.drawScaledCustomSizeModalRect(x, y, 0.0F, 32.0F, 32, 32, 16, 16, 256.0F, 256.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void drawTextureAt(int x, int y, String tex)
|
protected void drawTextureAt(int x, int y, String tex)
|
||||||
{
|
{
|
||||||
this.gm.getTextureManager().bindTexture(tex);
|
// GuiSkin.this.gm.getTextureManager().bindTexture(tex);
|
||||||
GlState.enableBlend();
|
GlState.enableBlend();
|
||||||
this.gm.getRenderManager().getRenderObject(this.model).renderHead(x, y, this.model.texWidth, this.model.texHeight, 2);
|
GlState.enableDepth();
|
||||||
|
Render.drawNames = false;
|
||||||
|
EntityTexManager.altTexture = tex;
|
||||||
|
EntityTexManager.altLayer = this.dynId;
|
||||||
|
EntityTexManager.altNpcLayer = this.dynId == -1 && this.charinfo != null ? this.charinfo.skin : null;
|
||||||
|
drawEntity(x + 32, y + 56, 28.0f
|
||||||
|
/ GuiSkin.this.gm.thePlayer.getHeight(), -45.0f, -20.0f, GuiSkin.this.gm.thePlayer);
|
||||||
|
Render.drawNames = true;
|
||||||
|
EntityTexManager.altTexture = null;
|
||||||
|
EntityTexManager.altLayer = -1;
|
||||||
|
EntityTexManager.altNpcLayer = null;
|
||||||
|
// GuiSkin.this.gm.getRenderManager().getRenderObject(this.model).renderHead(x, y, this.model.texWidth, this.model.texHeight, 2);
|
||||||
GlState.disableBlend();
|
GlState.disableBlend();
|
||||||
|
GlState.disableDepth();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTexture() {
|
public void deleteTexture() {
|
||||||
if(this.dyntex != null) {
|
if(this.dynId != -1) {
|
||||||
this.gm.getTextureManager().deleteTexture(this.icon);
|
EntityTexManager.setTexture(this.dynId, null, null);
|
||||||
this.dyntex = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void select(boolean dclick, int mx, int my)
|
||||||
* Returns true if the mouse has been pressed on this control.
|
|
||||||
*/
|
|
||||||
public boolean mousePressed(int slotIndex, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_)
|
|
||||||
{
|
{
|
||||||
if (Game.getSystemTime() - this.clickTime < 250L)
|
// if(GuiSkin.this.adjust.dragging)
|
||||||
|
// return;
|
||||||
|
if (dclick)
|
||||||
{
|
{
|
||||||
this.owner.close();
|
GuiSkin.this.gm.displayGuiScreen(GuiMenu.INSTANCE);
|
||||||
return true;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BufferedImage img = this.skinImage;
|
BufferedImage img = this.skinImage;
|
||||||
boolean slim = false;
|
// boolean slim = false;
|
||||||
if(this.charinfo != null) {
|
if(this.charinfo != null) {
|
||||||
try {
|
try {
|
||||||
img = TextureUtil.readImage(FileUtils.getStream(
|
img = TextureUtil.readImage(FileUtils.getResource(
|
||||||
EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) :
|
EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) :
|
||||||
this.charinfo.skin)));
|
this.charinfo.skin)));
|
||||||
}
|
}
|
||||||
catch(IOException e) {
|
catch(IOException e) {
|
||||||
if(e instanceof FileNotFoundException)
|
if(e instanceof FileNotFoundException)
|
||||||
Log.warn("Textur für Skin ist nicht vorhanden: " +
|
Log.JNI.warn("Textur für Skin ist nicht vorhanden: " +
|
||||||
EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) :
|
EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) :
|
||||||
this.charinfo.skin));
|
this.charinfo.skin));
|
||||||
else
|
else
|
||||||
Log.error("Konnte Textur nicht laden", e);
|
Log.JNI.error(e, "Konnte Textur nicht laden");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
slim = this.charinfo.skin.startsWith("~");
|
// slim = this.charinfo.skin.startsWith("~");
|
||||||
}
|
}
|
||||||
else if(this.skinFile != null) {
|
// else if(this.skinFile != null) {
|
||||||
slim = this.skinFile.getName().startsWith("slim_");
|
// slim = this.skinFile.getName().startsWith("slim_");
|
||||||
}
|
// }
|
||||||
this.owner.selectEntry(slotIndex, slim);
|
// GuiSkin.this.selectEntry(slotIndex, slim);
|
||||||
this.owner.selectSkin(this.id, img, slim, this.model);
|
GuiSkin.this.convertButton1.enabled = this.canConvert();
|
||||||
if(p_148278_5_ < 16 && p_148278_5_ > 0)
|
GuiSkin.this.convertButton2.enabled = this.canConvert();
|
||||||
this.owner.close();
|
GuiSkin.this.templateButton.enabled = this.canCopy();
|
||||||
this.clickTime = Game.getSystemTime();
|
GuiSkin.this.selectSkin(img, this.model);
|
||||||
return false;
|
if(mx < 16 && mx > 0)
|
||||||
|
GuiSkin.this.gm.displayGuiScreen(GuiMenu.INSTANCE);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,19 +234,6 @@ public class GuiSkin extends GuiScreen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SkinSelector extends GuiListExtended
|
|
||||||
{
|
|
||||||
private final GuiSkin owner;
|
|
||||||
private final List<SkinEntry> skinList = Lists.<SkinEntry>newArrayList();
|
|
||||||
private int selectedSlotIndex = -1;
|
|
||||||
|
|
||||||
public SkinSelector(GuiSkin ownerIn, ModelType model, String currentSkin, Game gmIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn)
|
|
||||||
{
|
|
||||||
super(gmIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn);
|
|
||||||
this.owner = ownerIn;
|
|
||||||
// this.setBackgroundDrawing(false);
|
|
||||||
this.load(currentSkin, model);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BufferedImage loadSkin(File file)
|
public static BufferedImage loadSkin(File file)
|
||||||
{
|
{
|
||||||
|
@ -260,9 +263,9 @@ public class GuiSkin extends GuiScreen
|
||||||
});
|
});
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
// for(ModelType model : ModelType.values()) {
|
// for(ModelType model : ModelType.values()) {
|
||||||
this.skinList.add(new SkinEntry(this.owner, "default", null, null, null, model));
|
this.elements.add(new SkinEntry("default", null, null, null, model));
|
||||||
if("default".equals(currentSkin))
|
if("default".equals(currentSkin))
|
||||||
this.setSelectedSlotIndex(pos);
|
this.setSelected(pos);
|
||||||
pos++;
|
pos++;
|
||||||
// }
|
// }
|
||||||
if(files != null) {
|
if(files != null) {
|
||||||
|
@ -273,9 +276,9 @@ public class GuiSkin extends GuiScreen
|
||||||
if(img != null) {
|
if(img != null) {
|
||||||
// for(ModelType model : ModelType.values()) {
|
// for(ModelType model : ModelType.values()) {
|
||||||
if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) {
|
if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) {
|
||||||
this.skinList.add(new SkinEntry(this.owner, file.getName(), file, null, img, model));
|
this.elements.add(new SkinEntry(file.getName(), file, null, img, model));
|
||||||
if(file.getName().equals(currentSkin))
|
if(file.getName().equals(currentSkin))
|
||||||
this.setSelectedSlotIndex(pos);
|
this.setSelected(pos);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
// }
|
// }
|
||||||
|
@ -286,9 +289,9 @@ public class GuiSkin extends GuiScreen
|
||||||
for(CharacterInfo charinfo : species.chars) {
|
for(CharacterInfo charinfo : species.chars) {
|
||||||
if(charinfo.species.renderer == model) {
|
if(charinfo.species.renderer == model) {
|
||||||
// for(Entry<String, ModelType> entry : SpeciesRegistry.SKINS.entrySet()) {
|
// for(Entry<String, ModelType> entry : SpeciesRegistry.SKINS.entrySet()) {
|
||||||
this.skinList.add(new SkinEntry(this.owner, charinfo.skin, null, charinfo, null, charinfo.species.renderer));
|
this.elements.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer));
|
||||||
if(charinfo.skin.equals(currentSkin))
|
if(charinfo.skin.equals(currentSkin))
|
||||||
this.setSelectedSlotIndex(pos);
|
this.setSelected(pos);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,313 +300,108 @@ public class GuiSkin extends GuiScreen
|
||||||
|
|
||||||
public void unload()
|
public void unload()
|
||||||
{
|
{
|
||||||
for (SkinEntry entry : this.skinList)
|
for (SkinEntry entry : this.elements)
|
||||||
{
|
{
|
||||||
entry.deleteTexture();
|
entry.deleteTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.skinList.clear();
|
this.elements.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getScrollBarX()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the width of the list
|
|
||||||
*/
|
|
||||||
public int getListWidth()
|
public int getListWidth()
|
||||||
{
|
{
|
||||||
return 274 - 20;
|
return 254;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isInList(int x, int y)
|
public int getSlotHeight()
|
||||||
{
|
{
|
||||||
return x >= 6;
|
return 64 + 4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DragAdjust extends Button {
|
private class DragAdjust extends Element {
|
||||||
private int mouseX;
|
private int mouseX;
|
||||||
private int mouseY;
|
private int mouseY;
|
||||||
private float yawOffset;
|
private float yawOffset;
|
||||||
private float pitchOffset;
|
private float pitchOffset;
|
||||||
public boolean dragging;
|
// public boolean dragging;
|
||||||
|
|
||||||
public DragAdjust(int id, int x, int y, int w, int h) {
|
public DragAdjust(int x, int y, int w, int h) {
|
||||||
super(id, x, y, w, h, "");
|
super(x, y, w, h, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawButton(Game gm, int mouseX, int mouseY) {
|
protected void drawBackground() {
|
||||||
if(this.visible && this.dragging) {
|
// if(this.dragging) {
|
||||||
GuiSkin.this.yaw = this.yawOffset + (this.mouseX - mouseX) * 2.0f;
|
//
|
||||||
GuiSkin.this.pitch = this.pitchOffset + (this.mouseY - mouseY) * 2.0f;
|
// }
|
||||||
}
|
Drawing.drawRectColor(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x20ffffff);
|
||||||
if(this.visible)
|
|
||||||
drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0x20ffffff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mousePressed(Game gm, int mouseX, int mouseY) {
|
protected void drawForeground(int x1, int y1, int x2, int y2) {
|
||||||
if(super.mousePressed(gm, mouseX, mouseY)) {
|
}
|
||||||
this.mouseX = mouseX;
|
|
||||||
this.mouseY = mouseY;
|
public void drag(int x, int y) {
|
||||||
|
GuiSkin.this.yaw = this.yawOffset + (this.mouseX - x) * 2.0f;
|
||||||
|
GuiSkin.this.pitch = this.pitchOffset + (this.mouseY - y) * 2.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
|
||||||
|
this.mouseX = x;
|
||||||
|
this.mouseY = y;
|
||||||
this.yawOffset = GuiSkin.this.yaw;
|
this.yawOffset = GuiSkin.this.yaw;
|
||||||
this.pitchOffset = GuiSkin.this.pitch;
|
this.pitchOffset = GuiSkin.this.pitch;
|
||||||
this.dragging = true;
|
// this.dragging = true;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
// public void mouserel() {
|
||||||
|
// this.dragging = false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public boolean canHover() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased(int mouseX, int mouseY) {
|
public static final GuiSkin INSTANCE = new GuiSkin();
|
||||||
this.dragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playPressSound(SoundManager soundHandlerIn) {
|
private ActButton convertButton1;
|
||||||
}
|
private ActButton convertButton2;
|
||||||
}
|
private ActButton templateButton;
|
||||||
|
|
||||||
private class ButtonPart extends Button
|
|
||||||
{
|
|
||||||
private final ModelPart part;
|
|
||||||
|
|
||||||
private ButtonPart(int id, int x, int y, int width, int height, ModelPart part)
|
|
||||||
{
|
|
||||||
super(id, x, y, width, height, GuiSkin.this.formatPart(part));
|
|
||||||
this.part = part;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ButtonAlign extends Button
|
|
||||||
{
|
|
||||||
private final Alignment align;
|
|
||||||
|
|
||||||
private ButtonAlign(int id, int x, int y, int width, int height, Alignment align)
|
|
||||||
{
|
|
||||||
super(id, x, y, width, height, align.color + align.display);
|
|
||||||
this.align = align;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class HeightReceiver implements SliderReceiver {
|
|
||||||
private int height;
|
|
||||||
|
|
||||||
private HeightReceiver(int value) {
|
|
||||||
this.height = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getValue(Game gm) {
|
|
||||||
return this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(Game gm, float value) {
|
|
||||||
this.height = (int)value;
|
|
||||||
if(gm.thePlayer != null)
|
|
||||||
gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, this.height));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String formatValue(Game gm) {
|
|
||||||
return "Spieler-Größe: " + (int)this.height + " cm";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Set<ModelPart> parts = Sets.newHashSet(ModelPart.values());
|
|
||||||
private final GuiScreen parentScreen;
|
|
||||||
|
|
||||||
private SkinSelector listSelector;
|
|
||||||
private Button convertButton;
|
|
||||||
private Button templateButton;
|
|
||||||
private Button modelButton;
|
|
||||||
private DragAdjust adjust;
|
private DragAdjust adjust;
|
||||||
private TextField nameField;
|
|
||||||
private boolean initialized;
|
|
||||||
// private int update;
|
|
||||||
private float yaw;
|
private float yaw;
|
||||||
private float pitch;
|
private float pitch;
|
||||||
|
|
||||||
public GuiSkin(GuiScreen parentScreen)
|
private GuiSkin() {
|
||||||
{
|
|
||||||
this.parentScreen = parentScreen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateScreen()
|
public void init(int width, int height)
|
||||||
{
|
{
|
||||||
// if(this.update > 0)
|
super.init(width, height);
|
||||||
// this.update -= 1;
|
this.setDimensions(274, height, 52, height - 52);
|
||||||
this.nameField.updateCursorCounter();
|
this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel());
|
||||||
// if(this.gm.nickChanged) {
|
this.convertButton1 = this.add(new ActButton(4, 4, 266, 20, new ActButton.Callback() {
|
||||||
// this.nameField.setText(this.gm.nickname);
|
public void use(ActButton elem, Mode action) {
|
||||||
// this.gm.nickChanged = false;
|
SkinEntry skin = GuiSkin.this.getSelected();
|
||||||
// }
|
if(skin != null && skin.getFile() != null && SkinConverter.convertSkin(skin.getFile(), new File("skins"), false))
|
||||||
|
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
|
||||||
}
|
}
|
||||||
|
}, "Konvertieren: Standard"));
|
||||||
public void initGui()
|
this.convertButton2 = this.add(new ActButton(4, 28, 266, 20, new ActButton.Callback() {
|
||||||
{
|
public void use(ActButton elem, Mode action) {
|
||||||
Keyboard.enableRepeatEvents(true);
|
SkinEntry skin = GuiSkin.this.getSelected();
|
||||||
this.buttonList.clear();
|
if(skin != null && skin.getFile() != null && SkinConverter.convertSkin(skin.getFile(), new File("skins"), true))
|
||||||
|
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
|
||||||
if (!this.initialized)
|
|
||||||
{
|
|
||||||
this.initialized = true;
|
|
||||||
this.listSelector = new SkinSelector(this, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel(), this.gm.skinId.isEmpty() ? null : this.gm.skinId,
|
|
||||||
this.gm, 274, this.height, 32, this.height - 32, 20);
|
|
||||||
}
|
}
|
||||||
else
|
}, "Konvertieren: Schlank"));
|
||||||
{
|
this.add(new ActButton(4, height - 48, 266, 20, new ActButton.Callback() {
|
||||||
this.listSelector.setDimensions(274, this.height, 32, this.height - 32);
|
public void use(ActButton elem, Mode action) {
|
||||||
|
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
|
||||||
}
|
}
|
||||||
|
}, "Neu laden"));
|
||||||
this.buttonList.add(new Button(8, 164, this.height - 28, 274 - 164, 20, "Neu laden"));
|
this.templateButton = this.add(new ActButton(4, height - 24, 266, 20, new ActButton.Callback() {
|
||||||
int flags = this.gm.thePlayer == null ? ~ModelPart.ARMS_SLIM.getMask() : this.gm.thePlayer.getModelParts();
|
public void use(ActButton elem, Mode action) {
|
||||||
this.parts.clear();
|
SkinEntry skin = GuiSkin.this.getSelected();
|
||||||
for(ModelPart part : ModelPart.values()) {
|
if(skin != null && skin.getLocation() != null) {
|
||||||
if((flags & part.getMask()) == part.getMask())
|
String loc = skin.getLocation();
|
||||||
this.parts.add(part);
|
|
||||||
}
|
|
||||||
this.buttonList.add(this.convertButton = new Button(9, 10, this.height - 28, 150, 20,
|
|
||||||
"Konvertieren: " +
|
|
||||||
(this.parts.contains(ModelPart.ARMS_SLIM) ? "Schlank" : "Standard")));
|
|
||||||
this.buttonList.add(this.templateButton = new Button(10, this.width - 274, this.height - 28, 150, 20,
|
|
||||||
"Vorlage kopieren"));
|
|
||||||
this.buttonList.add(this.adjust = new DragAdjust(20, 274 + 10, 64, this.width - 274 - 274 - 20, this.height - 128));
|
|
||||||
for (int z = 0; z < ModelPart.values().length; z++)
|
|
||||||
{
|
|
||||||
ModelPart part = ModelPart.values()[z];
|
|
||||||
Button button = new ButtonPart(z + 500, this.width - 274 + (z & 1) * 134, 32 + 24 * (z >> 1), 130, 20, part);
|
|
||||||
if(part == ModelPart.ARMS_SLIM)
|
|
||||||
this.modelButton = button;
|
|
||||||
this.buttonList.add(button);
|
|
||||||
}
|
|
||||||
for (int z = 0; z < Alignment.values().length; z++)
|
|
||||||
{
|
|
||||||
Button button;
|
|
||||||
this.buttonList.add(button = new ButtonAlign(z + 600, this.width - 274 + (z % 3) * 89, this.height - 158 + 23 * (z / 3), 86, 20,
|
|
||||||
Alignment.values()[z]));
|
|
||||||
button.enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != Alignment.values()[z];
|
|
||||||
}
|
|
||||||
// this.gm.setFloatValue(Options.PLAYER_HEIGHT, );
|
|
||||||
this.buttonList.add(new Slider(30, this.width - 274, this.height - 28 - 54, 264, 20,
|
|
||||||
new HeightReceiver(this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f)),
|
|
||||||
120.0f, 320.0f, 1.0f)
|
|
||||||
// protected void mouseDragged(Game gm, int mouseX, int mouseY) {
|
|
||||||
// if(this.visible && this.dragging)
|
|
||||||
// GuiSkin.this.update = 2;
|
|
||||||
// super.mouseDragged(gm, mouseX, mouseY);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public boolean mouseScrolled(Game gm, int mouseX, int mouseY, int offset) {
|
|
||||||
// if(super.mouseScrolled(gm, mouseX, mouseY, offset)) {
|
|
||||||
// GuiSkin.this.update = 2;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
);
|
|
||||||
this.buttonList.add(new Button(0, this.width - 274 + 154, this.height - 28, 264 - 154, 20, "Fertig"));
|
|
||||||
this.convertButton.enabled = false;
|
|
||||||
this.templateButton.enabled = false;
|
|
||||||
this.nameField = new TextField(this.width - 274 + 2, this.height + 2 - 28 - 24, 260, 16);
|
|
||||||
this.nameField.setMaxStringLength(32);
|
|
||||||
this.nameField.setText(this.gm.thePlayer == null ? "" : this.gm.thePlayer.getCustomNameTag());
|
|
||||||
this.nameField.setValidator(new Predicate<String>()
|
|
||||||
{
|
|
||||||
public boolean apply(String name)
|
|
||||||
{
|
|
||||||
return NetHandlerPlayServer.isValidNick(name);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// this.gm.nickChanged = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendNameToServer()
|
|
||||||
{
|
|
||||||
String name = this.nameField.getText();
|
|
||||||
if(name.isEmpty())
|
|
||||||
this.nameField.setText(this.gm.thePlayer == null ? "..." : this.gm.thePlayer.getCustomNameTag());
|
|
||||||
else if(this.gm.thePlayer != null)
|
|
||||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectSkin(String id, BufferedImage img, boolean slim, ModelType model)
|
|
||||||
{
|
|
||||||
this.gm.setSkin(img, id, model, slim);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close() {
|
|
||||||
this.gm.displayGuiScreen(this.parentScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectEntry(int index, boolean slim)
|
|
||||||
{
|
|
||||||
this.listSelector.setSelectedSlotIndex(index);
|
|
||||||
if(this.listSelector.getSelectedIndex() >= 0) {
|
|
||||||
SkinEntry entry = this.listSelector.getListEntry(this.listSelector.getSelectedIndex());
|
|
||||||
if(slim != this.parts.contains(ModelPart.ARMS_SLIM))
|
|
||||||
try {
|
|
||||||
this.actionPerformed(this.modelButton);
|
|
||||||
}
|
|
||||||
catch(IOException e) {
|
|
||||||
}
|
|
||||||
// this.update = 2;
|
|
||||||
this.convertButton.enabled = entry.canConvert();
|
|
||||||
this.templateButton.enabled = entry.canCopy();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.convertButton.enabled = false;
|
|
||||||
this.templateButton.enabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean doesGuiPauseGame()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleMouseInput() throws IOException
|
|
||||||
{
|
|
||||||
super.handleMouseInput();
|
|
||||||
if(!this.adjust.dragging)
|
|
||||||
this.listSelector.handleMouseInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onGuiClosed()
|
|
||||||
{
|
|
||||||
Keyboard.enableRepeatEvents(false);
|
|
||||||
|
|
||||||
this.listSelector.unload();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void actionPerformed(Button button) throws IOException
|
|
||||||
{
|
|
||||||
if (button.enabled)
|
|
||||||
{
|
|
||||||
if (button.id == 0)
|
|
||||||
{
|
|
||||||
this.gm.displayGuiScreen(this.parentScreen);
|
|
||||||
}
|
|
||||||
else if (button.id == 8)
|
|
||||||
{
|
|
||||||
this.refreshList();
|
|
||||||
}
|
|
||||||
else if (button.id == 9)
|
|
||||||
{
|
|
||||||
if(this.listSelector.getSelectedIndex() >= 0) {
|
|
||||||
SkinEntry entry = this.listSelector.getListEntry(this.listSelector.getSelectedIndex());
|
|
||||||
if(entry.getFile() != null && SkinConverter.convertSkin(entry.getFile(), new File("skins"),
|
|
||||||
this.parts.contains(ModelPart.ARMS_SLIM))) {
|
|
||||||
this.refreshList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (button.id == 10)
|
|
||||||
{
|
|
||||||
if(this.listSelector.getSelectedIndex() >= 0) {
|
|
||||||
SkinEntry entry = this.listSelector.getListEntry(this.listSelector.getSelectedIndex());
|
|
||||||
if(entry.getLocation() != null) {
|
|
||||||
String loc = (this.parts.contains(ModelPart.ARMS_SLIM) ? "slim_" : "") + entry.getLocation();
|
|
||||||
File file = new File(new File("skins"), loc + ".png");
|
File file = new File(new File("skins"), loc + ".png");
|
||||||
int z = 1;
|
int z = 1;
|
||||||
while(file.exists()) {
|
while(file.exists()) {
|
||||||
|
@ -611,118 +409,173 @@ public class GuiSkin extends GuiScreen
|
||||||
}
|
}
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
try {
|
try {
|
||||||
in = FileUtils.getStream(EntityNPC.getSkinTexture(entry.getLocation()));
|
in = FileUtils.getResource(EntityNPC.getSkinTexture(loc));
|
||||||
Files.copy(in, file.toPath());
|
Files.copy(in, file.toPath());
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
if(e instanceof FileNotFoundException)
|
if(e instanceof FileNotFoundException)
|
||||||
Log.warn("Textur ist nicht zum Kopieren vorhanden: " + FileUtils.getStream(EntityNPC.getSkinTexture(entry.getLocation())));
|
Log.JNI.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(loc));
|
||||||
else
|
else
|
||||||
Log.error("Konnte Textur nicht kopieren", e);
|
Log.JNI.error(e, "Konnte Textur nicht kopieren");
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
FileUtils.closeQuietly(in);
|
if(in != null) {
|
||||||
|
try {
|
||||||
|
in.close();
|
||||||
}
|
}
|
||||||
this.refreshList();
|
catch(Throwable e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (button.id == 30)
|
GuiSkin.this.gm.displayGuiScreen(GuiSkin.this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "Vorlage kopieren"));
|
||||||
|
this.adjust = this.add(new DragAdjust(274 + 10, 64, width - 274 - 274 - 20, height - 128));
|
||||||
|
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
|
||||||
|
for (int z = 0; z < Alignment.values().length; z++)
|
||||||
{
|
{
|
||||||
// this.update = 2;
|
final Alignment align = Alignment.values()[z];
|
||||||
}
|
alignBtns[z] = this.add(new ActButton(width - 274 + (z % 3) * 89, height - 158 + 23 * (z / 3), 86, 20, new ActButton.Callback() {
|
||||||
else if (button instanceof ButtonPart)
|
public void use(ActButton elem, Mode action) {
|
||||||
{
|
if(GuiSkin.this.gm.thePlayer != null) {
|
||||||
ModelPart part = ((ButtonPart)button).part;
|
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal()));
|
||||||
// this.switchModelPartEnabled(part);
|
for(ActButton btn : alignBtns) {
|
||||||
if(!this.parts.contains(part))
|
btn.enabled = btn != elem;
|
||||||
this.parts.add(part);
|
|
||||||
else
|
|
||||||
this.parts.remove(part);
|
|
||||||
if(this.gm.thePlayer != null) {
|
|
||||||
int n = 0;
|
|
||||||
for(ModelPart p : this.parts) {
|
|
||||||
n |= p.getMask();
|
|
||||||
}
|
|
||||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_MODELPARTS, n));
|
|
||||||
}
|
|
||||||
button.display = this.formatPart(part);
|
|
||||||
// this.update = 2;
|
|
||||||
if(part == ModelPart.ARMS_SLIM)
|
|
||||||
this.convertButton.display = "Konvertieren: " +
|
|
||||||
(this.parts.contains(ModelPart.ARMS_SLIM) ? "Schlank" : "Standard");
|
|
||||||
}
|
|
||||||
else if (button instanceof ButtonAlign)
|
|
||||||
{
|
|
||||||
if(this.gm.thePlayer != null) {
|
|
||||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN,
|
|
||||||
((ButtonAlign)button).align.ordinal()));
|
|
||||||
for(Button btn : this.buttonList) {
|
|
||||||
if(btn instanceof ButtonAlign)
|
|
||||||
btn.enabled = ((ButtonAlign)button).align != ((ButtonAlign)btn).align;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, align.color + align.display));
|
||||||
|
alignBtns[z].enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != align;
|
||||||
}
|
}
|
||||||
|
this.add(new Slider(width - 274, height - 28 - 54, 264, 20, 1, 120, 320, 180, this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f), new Slider.Callback() {
|
||||||
|
public void use(Slider elem, int value) {
|
||||||
|
if(GuiSkin.this.gm.thePlayer != null)
|
||||||
|
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value));
|
||||||
|
}
|
||||||
|
}, "Spieler-Größe", "cm"));
|
||||||
|
this.add(new Label(width - 274 + 2, height + 2 - 28 - 24 - 10, 200, 20, "Anzeigename", true));
|
||||||
|
this.add(new ActButton(width - 274 + 154, height - 28, 264 - 154, 20, GuiMenu.INSTANCE, "Fertig"));
|
||||||
|
Textbox nameField = this.add(new Textbox(width - 274 + 2, height + 2 - 28 - 24, 260, 16, NetHandlerPlayServer.MAX_NICK_LENGTH, true, new Textbox.Callback() {
|
||||||
|
public void use(Textbox elem, Action value) {
|
||||||
|
if(value == Action.SEND || value == Action.UNFOCUS) {
|
||||||
|
String name = elem.getText();
|
||||||
|
if(name.isEmpty())
|
||||||
|
elem.setText(GuiSkin.this.gm.thePlayer == null ? "..." : GuiSkin.this.gm.thePlayer.getCustomNameTag());
|
||||||
|
else if(GuiSkin.this.gm.thePlayer != null)
|
||||||
|
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, NetHandlerPlayServer.VALID_NICK, this.gm.thePlayer == null ? "" : this.gm.thePlayer.getCustomNameTag()));
|
||||||
|
this.convertButton1.enabled = false;
|
||||||
|
this.convertButton2.enabled = false;
|
||||||
|
this.templateButton.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refreshList()
|
public void selectSkin(BufferedImage img, ModelType model)
|
||||||
{
|
{
|
||||||
this.gm.displayGuiScreen(new GuiSkin(this.parentScreen));
|
this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void keyTyped(char typedChar, int keyCode) throws IOException
|
public void onGuiClosed()
|
||||||
{
|
{
|
||||||
if(this.nameField.isFocused() && keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER) {
|
this.unload();
|
||||||
this.sendNameToServer();
|
|
||||||
this.nameField.setFocused(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.nameField.textboxKeyTyped(typedChar, keyCode);
|
|
||||||
}
|
|
||||||
if(keyCode == Keyboard.KEY_F5)
|
|
||||||
this.refreshList();
|
|
||||||
else
|
|
||||||
super.keyTyped(typedChar, keyCode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
public void drawOverlays()
|
||||||
{
|
{
|
||||||
this.drawBackground();
|
drawEntity(274 + (this.gm.fb_x - 274 - 274) / 2, this.gm.fb_y / 2 + 160, 160.0f
|
||||||
// this.drawGradientRect(0, 0, this.width, this.height - 32, 0xC0101010, 0xD0101010);
|
/ this.gm.thePlayer.getHeight(), this.yaw, this.pitch, this.gm.thePlayer);
|
||||||
this.listSelector.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
// this.drawBackground(0, this.height - 32, this.width, 32);
|
|
||||||
// drawRect(284, 64, this.width - 284, this.height - 64, 0x20000000);
|
|
||||||
FontRenderer.drawCenteredString("Charakter anpassen", this.width / 2, 20, 0xffffff);
|
|
||||||
FontRenderer.drawStringWithShadow("Anzeigename", this.nameField.xPosition, this.nameField.yPosition - 10, 10526880);
|
|
||||||
this.nameField.drawTextBox();
|
|
||||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
|
||||||
GuiInventory.drawEntity(274 + (this.width - 274 - 274) / 2, this.height / 2 + 80, 80.0f /* *
|
|
||||||
1.8f */ / this.gm.thePlayer.getHeight(), this.yaw, this.pitch, this.gm.thePlayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
|
public String getTitle() {
|
||||||
{
|
return "Charakter anpassen";
|
||||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
this.listSelector.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
boolean flag = this.nameField.isFocused();
|
|
||||||
this.nameField.mouseClicked(mouseX, mouseY, mouseButton);
|
|
||||||
if(flag && !this.nameField.isFocused())
|
|
||||||
this.sendNameToServer();
|
|
||||||
// else if(!flag && this.nameField.isFocused())
|
|
||||||
// this.nameField.setText(TextColor.getCodes(this.nameField.getText()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void mouseReleased(int mouseX, int mouseY, int state)
|
|
||||||
{
|
|
||||||
super.mouseReleased(mouseX, mouseY, state);
|
|
||||||
this.listSelector.mouseReleased(mouseX, mouseY, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatPart(ModelPart part)
|
|
||||||
|
|
||||||
|
// public static void drawEntityOnScreen(int posX, int posY, float scale, float mouseX, float mouseY, EntityLiving ent)
|
||||||
|
// {
|
||||||
|
// GlState.enableColorMaterial();
|
||||||
|
// SKC.glPushMatrix();
|
||||||
|
// SKC.glTranslatef((float)posX, (float)posY, 50.0F);
|
||||||
|
// SKC.glScalef(-scale, scale, scale);
|
||||||
|
// SKC.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||||
|
// float f = ent.yawOffset;
|
||||||
|
// float f1 = ent.rotYaw;
|
||||||
|
// float f2 = ent.rotPitch;
|
||||||
|
// float f3 = ent.prevHeadYaw;
|
||||||
|
// float f4 = ent.headYaw;
|
||||||
|
// SKC.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
// ItemRenderer.enableStandardItemLighting();
|
||||||
|
// SKC.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
// SKC.glRotatef(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
|
||||||
|
// ent.yawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F;
|
||||||
|
// ent.rotYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F;
|
||||||
|
// ent.rotPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F;
|
||||||
|
// ent.headYaw = ent.rotYaw;
|
||||||
|
// ent.prevHeadYaw = ent.rotYaw;
|
||||||
|
// SKC.glTranslatef(0.0F, 0.0F, 0.0F);
|
||||||
|
// RenderManager rendermanager = Game.getGame().getRenderManager();
|
||||||
|
// rendermanager.setPlayerViewY(180.0F);
|
||||||
|
//// rendermanager.setRenderShadow(false);
|
||||||
|
// rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F);
|
||||||
|
//// rendermanager.setRenderShadow(true);
|
||||||
|
// ent.yawOffset = f;
|
||||||
|
// ent.rotYaw = f1;
|
||||||
|
// ent.rotPitch = f2;
|
||||||
|
// ent.prevHeadYaw = f3;
|
||||||
|
// ent.headYaw = f4;
|
||||||
|
// SKC.glPopMatrix();
|
||||||
|
// ItemRenderer.disableStandardItemLighting();
|
||||||
|
// GlState.disableRescaleNormal();
|
||||||
|
// GlState.setActiveTexture(SKC.GL_TEXTURE1);
|
||||||
|
// GlState.disableTexture2D();
|
||||||
|
// GlState.setActiveTexture(SKC.GL_TEXTURE0);
|
||||||
|
// }
|
||||||
|
|
||||||
|
public static void drawEntity(int posX, int posY, float scale, float yaw, float pitch, EntityLiving ent)
|
||||||
{
|
{
|
||||||
return part.getName() + ": " + (
|
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
this.parts.contains(part) ? (part == ModelPart.ARMS_SLIM ? "Schlank" : "An") :
|
GlState.enableDepth();
|
||||||
(part == ModelPart.ARMS_SLIM ? "Standard" : "Aus"));
|
GlState.enableColorMaterial();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float)posX, (float)posY, 200.0F);
|
||||||
|
GL11.glScalef(-scale, scale, scale);
|
||||||
|
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
|
||||||
|
float f = ent.yawOffset;
|
||||||
|
float f1 = ent.rotYaw;
|
||||||
|
float f2 = ent.rotPitch;
|
||||||
|
float f3 = ent.prevHeadYaw;
|
||||||
|
float f4 = ent.headYaw;
|
||||||
|
GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
ItemRenderer.enableStandardItemLighting();
|
||||||
|
GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glTranslatef(0.0F, ent.height / 2, 0.0F);
|
||||||
|
GL11.glRotatef(-pitch, 1.0F, 0.0F, 0.0F);
|
||||||
|
ent.yawOffset = yaw;
|
||||||
|
ent.rotYaw = yaw;
|
||||||
|
ent.rotPitch = 0.0f;
|
||||||
|
ent.headYaw = ent.rotYaw;
|
||||||
|
ent.prevHeadYaw = ent.rotYaw;
|
||||||
|
GL11.glTranslatef(0.0F, -(ent.height / 2), 0.0F);
|
||||||
|
RenderManager rendermanager = Game.getGame().getRenderManager();
|
||||||
|
rendermanager.setPlayerViewY(180.0F);
|
||||||
|
rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F);
|
||||||
|
// GL11.glTranslatef(0.0F, 0.0F, 0.0F);
|
||||||
|
ent.yawOffset = f;
|
||||||
|
ent.rotYaw = f1;
|
||||||
|
ent.rotPitch = f2;
|
||||||
|
ent.prevHeadYaw = f3;
|
||||||
|
ent.headYaw = f4;
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
ItemRenderer.disableStandardItemLighting();
|
||||||
|
GlState.disableRescaleNormal();
|
||||||
|
GlState.setActiveTexture(GL13.GL_TEXTURE1);
|
||||||
|
GlState.disableTexture2D();
|
||||||
|
GlState.setActiveTexture(GL13.GL_TEXTURE0);
|
||||||
|
GlState.disableDepth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,10 @@ public abstract class GuiList<T extends ListEntry> extends Gui
|
||||||
return this.elements.size();
|
return this.elements.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void setSelected(int index) {
|
||||||
|
this.selectedElement = index;
|
||||||
|
}
|
||||||
|
|
||||||
protected int getContentHeight()
|
protected int getContentHeight()
|
||||||
{
|
{
|
||||||
return this.getSize() * this.getSlotHeight();
|
return this.getSize() * this.getSlotHeight();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import game.world.World;
|
||||||
|
|
||||||
public abstract class Render<T extends Entity>
|
public abstract class Render<T extends Entity>
|
||||||
{
|
{
|
||||||
|
public static boolean drawNames = true;
|
||||||
// private static final String shadowTextures = "textures/world/shadow.png";
|
// private static final String shadowTextures = "textures/world/shadow.png";
|
||||||
|
|
||||||
protected final RenderManager renderManager;
|
protected final RenderManager renderManager;
|
||||||
|
@ -310,7 +311,7 @@ public abstract class Render<T extends Entity>
|
||||||
|
|
||||||
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) {
|
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) {
|
||||||
double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
|
double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer);
|
||||||
if (d0 <= (double)(maxDistance * maxDistance)) {
|
if (d0 <= (double)(maxDistance * maxDistance) && drawNames) {
|
||||||
// WCF.glPushMatrix();
|
// WCF.glPushMatrix();
|
||||||
// WCF.glTranslatef((float)x, (float)y + entityIn.height + 0.5f, (float)z);
|
// WCF.glTranslatef((float)x, (float)y + entityIn.height + 0.5f, (float)z);
|
||||||
// float f = 1.0f / 64.0f;
|
// float f = 1.0f / 64.0f;
|
||||||
|
|
|
@ -25,12 +25,17 @@ import game.util.FileUtils;
|
||||||
|
|
||||||
public abstract class EntityTexManager
|
public abstract class EntityTexManager
|
||||||
{
|
{
|
||||||
|
public static String altTexture = null;
|
||||||
|
public static int altLayer = -1;
|
||||||
|
public static String altNpcLayer = null;
|
||||||
|
|
||||||
public static final int MAX_SKIN_SIZE = 65536;
|
public static final int MAX_SKIN_SIZE = 65536;
|
||||||
|
|
||||||
private static final Set<Integer> USER_TEXTURES = Sets.newHashSet();
|
private static final Set<Integer> USER_TEXTURES = Sets.newHashSet();
|
||||||
private static final Map<Integer, LayerExtra> USER_LAYERS = Maps.newHashMap();
|
private static final Map<Integer, LayerExtra> USER_LAYERS = Maps.newHashMap();
|
||||||
private static final Map<String, LayerExtra> NPC_LAYERS = Maps.newHashMap();
|
private static final Map<String, LayerExtra> NPC_LAYERS = Maps.newHashMap();
|
||||||
private static final Map<ModelType, String> DEF_TEXTURES = Maps.newEnumMap(ModelType.class);
|
private static final Map<ModelType, String> DEF_TEXTURES = Maps.newEnumMap(ModelType.class);
|
||||||
|
private static final Map<ModelType, LayerExtra> DEF_LAYERS = Maps.newEnumMap(ModelType.class);
|
||||||
|
|
||||||
public static void loadNpcTextures() {
|
public static void loadNpcTextures() {
|
||||||
TextureManager manager = Game.getGame().getTextureManager();
|
TextureManager manager = Game.getGame().getTextureManager();
|
||||||
|
@ -75,6 +80,9 @@ public abstract class EntityTexManager
|
||||||
}
|
}
|
||||||
dyntex.updateDynamicTexture();
|
dyntex.updateDynamicTexture();
|
||||||
LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), dyntex.getWidth(), dyntex.getHeight(), entry.getValue());
|
LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), dyntex.getWidth(), dyntex.getHeight(), entry.getValue());
|
||||||
|
if(EntityNPC.getSkinTexture(skin).equals(getDefault(entry.getValue()))) {
|
||||||
|
DEF_LAYERS.put(entry.getValue(), extra);
|
||||||
|
}
|
||||||
if(extra != null) {
|
if(extra != null) {
|
||||||
extra = NPC_LAYERS.put(skin, extra);
|
extra = NPC_LAYERS.put(skin, extra);
|
||||||
}
|
}
|
||||||
|
@ -116,6 +124,10 @@ public abstract class EntityTexManager
|
||||||
dyntex.updateDynamicTexture();
|
dyntex.updateDynamicTexture();
|
||||||
// setCape(cape, image);
|
// setCape(cape, image);
|
||||||
}
|
}
|
||||||
|
// for(ModelType model : ModelType.values()) {
|
||||||
|
// if(DEF_TEXTURES.get(model) == null)
|
||||||
|
// Log.IO.warn(altNpcLayer);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDefault(ModelType model) {
|
public static String getDefault(ModelType model) {
|
||||||
|
@ -137,19 +149,20 @@ public abstract class EntityTexManager
|
||||||
return "capes/" + name.toLowerCase() + "/dyn";
|
return "capes/" + name.toLowerCase() + "/dyn";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LayerExtra getLayer(int id)
|
public static LayerExtra getLayer(int id, ModelType model)
|
||||||
{
|
{
|
||||||
return USER_LAYERS.get(id);
|
return altNpcLayer != null ? getNpcLayer(altNpcLayer, model) : (altLayer != -1 ? USER_LAYERS.get(altLayer) : (USER_TEXTURES.contains(id) ? USER_LAYERS.get(id) : DEF_LAYERS.get(model)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LayerExtra getNpcLayer(String skin)
|
public static LayerExtra getNpcLayer(String skin, ModelType model)
|
||||||
{
|
{
|
||||||
return NPC_LAYERS.get((skin.startsWith("~") ? skin.substring(1) : skin).toLowerCase());
|
return Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(skin.startsWith("~") ? skin.substring(1) : skin)) != null ?
|
||||||
|
NPC_LAYERS.get((skin.startsWith("~") ? skin.substring(1) : skin).toLowerCase()) : DEF_LAYERS.get(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSkin(int id, ModelType model)
|
public static String getSkin(int id, ModelType model)
|
||||||
{
|
{
|
||||||
String loc = getSkinLocation(id);
|
String loc = altTexture != null ? altTexture : getSkinLocation(id);
|
||||||
return Game.getGame().getTextureManager().getTexture(loc) != null ? loc : getDefault(model);
|
return Game.getGame().getTextureManager().getTexture(loc) != null ? loc : getDefault(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue