chars, ...
This commit is contained in:
parent
eea23233f4
commit
3515fb1792
53 changed files with 688 additions and 543 deletions
|
@ -15,6 +15,7 @@ import org.lwjgl.opengl.GL13;
|
|||
|
||||
import game.Game;
|
||||
import game.Game.FileMode;
|
||||
import game.collect.Lists;
|
||||
import game.dimension.DimType;
|
||||
import game.dimension.Dimension;
|
||||
import game.entity.npc.Alignment;
|
||||
|
@ -44,17 +45,22 @@ import game.network.Player;
|
|||
import game.packet.CPacketAction;
|
||||
import game.packet.CPacketMessage;
|
||||
import game.packet.CPacketSkin;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.renderer.Drawing;
|
||||
import game.renderer.GlState;
|
||||
import game.renderer.ItemRenderer;
|
||||
import game.renderer.entity.RenderManager;
|
||||
import game.renderer.texture.EntityTexManager;
|
||||
import game.renderer.texture.TextureUtil;
|
||||
import game.rng.Random;
|
||||
import game.util.Displayable;
|
||||
import game.util.FileCallback;
|
||||
import game.util.FileUtils;
|
||||
import game.util.SkinConverter;
|
||||
import game.util.Util;
|
||||
import game.vars.CVarCategory;
|
||||
import game.vars.EnumVar;
|
||||
import game.vars.EnumVar.EnumFunction;
|
||||
import game.vars.Variable;
|
||||
import game.window.Button;
|
||||
|
||||
public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
||||
|
@ -74,11 +80,8 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.charinfo = charinfo;
|
||||
this.id = id;
|
||||
this.model = model;
|
||||
if(this.skinFile != null)
|
||||
if(this.skinFile != null) {
|
||||
this.skinImage = image;
|
||||
else
|
||||
this.skinImage = null;
|
||||
if(this.skinImage != null) {
|
||||
int w = this.skinImage.getWidth();
|
||||
int h = this.skinImage.getHeight();
|
||||
int[] data = new int[w * h];
|
||||
|
@ -87,6 +90,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
EntityTexManager.setTexture(this.dynId, EntityTexManager.imageToComp(data, model), model);
|
||||
}
|
||||
else {
|
||||
this.skinImage = null;
|
||||
this.dynId = -1;
|
||||
}
|
||||
}
|
||||
|
@ -94,16 +98,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
String str =
|
||||
(this.skinFile != null ? this.skinFile.getName()
|
||||
: (this.charinfo == null ? "Standard" : (
|
||||
(this.charinfo.species.prefix && this.charinfo.spclass != null && this.charinfo.spclass.type != null ?
|
||||
this.charinfo.spclass.type.toString() :
|
||||
(this.skinFile != null ? this.skinFile.getName() : (
|
||||
(this.charinfo.species.prefix && this.charinfo.type != null && !this.charinfo.type.toString().isEmpty() ?
|
||||
this.charinfo.type.toString() :
|
||||
EntityRegistry.getEntityName(this.charinfo.species.id))
|
||||
+ (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)))));
|
||||
+ (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name))));
|
||||
|
||||
Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ?
|
||||
(this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2));
|
||||
if(this.skinFile == null && this.charinfo != null)
|
||||
0xffffff : this.charinfo.color1 | this.charinfo.color2));
|
||||
if(this.charinfo != null)
|
||||
Drawing.drawText(this.charinfo.skin, x + 64 + 3, y + 18, 0xffc0c0c0);
|
||||
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -111,18 +114,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
if (hovered)
|
||||
Drawing.drawRect(x, y, 64, 64, -1601138544);
|
||||
|
||||
if (this.dynId != -1)
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityTexManager.getSkin(this.dynId, this.model));
|
||||
}
|
||||
else if(this.charinfo == null)
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityTexManager.getDefault(this.model));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityTexManager.getNpcSkin(this.charinfo.skin, this.model));
|
||||
}
|
||||
this.drawTextureAt(x, y, EntityTexManager.getSkin(this.dynId, this.charinfo != null ? this.charinfo.skin : null, this.model));
|
||||
}
|
||||
|
||||
protected void drawTextureAt(int x, int y, String tex)
|
||||
|
@ -152,39 +144,31 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
BufferedImage img = this.skinImage;
|
||||
if(this.charinfo != null) {
|
||||
try {
|
||||
img = TextureUtil.readImage(FileUtils.getResource(
|
||||
EntityNPC.getSkinTexture(this.charinfo.skin)));
|
||||
}
|
||||
catch(IOException e) {
|
||||
if(e instanceof FileNotFoundException)
|
||||
Log.JNI.warn("Textur für Skin ist nicht vorhanden: " +
|
||||
EntityNPC.getSkinTexture(this.charinfo.skin));
|
||||
else
|
||||
Log.JNI.error(e, "Konnte Textur nicht laden");
|
||||
return;
|
||||
}
|
||||
}
|
||||
GuiChar.this.templateButton.enabled = this.canCopy();
|
||||
GuiChar.this.selectSkin(img, this.model);
|
||||
// BufferedImage img = this.skinImage;
|
||||
// if(this.charinfo != null) {
|
||||
// try {
|
||||
// img = TextureUtil.readImage(FileUtils.getResource(
|
||||
// EntityNPC.getSkinTexture(this.charinfo.skin)));
|
||||
// }
|
||||
// catch(IOException e) {
|
||||
// if(e instanceof FileNotFoundException)
|
||||
// Log.JNI.warn("Textur für Skin ist nicht vorhanden: " +
|
||||
// EntityNPC.getSkinTexture(this.charinfo.skin));
|
||||
// else
|
||||
// Log.JNI.error(e, "Konnte Textur nicht laden");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
GuiChar.this.templateButton.enabled = this.charinfo != null;
|
||||
GuiChar.this.gm.getNetHandler().addToSendQueue(new CPacketSkin(this.skinImage, this.skinImage != null ? null : this.charinfo.skin, this.model));
|
||||
GuiChar.this.currentSkin = this.skinFile != null ? this.skinFile.getName() : this.charinfo.skin;
|
||||
GuiChar.this.waiting = false;
|
||||
}
|
||||
|
||||
public File getFile()
|
||||
{
|
||||
return this.skinFile;
|
||||
}
|
||||
|
||||
|
||||
public String getLocation()
|
||||
{
|
||||
return this.charinfo == null ? null : this.charinfo.skin;
|
||||
}
|
||||
|
||||
public boolean canCopy()
|
||||
{
|
||||
return this.charinfo != null;
|
||||
}
|
||||
}
|
||||
|
||||
private class DragAdjust extends Element {
|
||||
|
@ -221,7 +205,35 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}
|
||||
|
||||
public static enum FilterType implements IStringSerializable, Displayable {
|
||||
ALL("all", "Alle anzeigen"), CUSTOM("custom", "Nur eigene"), NPC("preset", "Nur vorgegebene"), SPECIES("species", "Nur Spezies"), SPECIES_CUSTOM("species_custom", "Spezies und eigene");
|
||||
|
||||
private final String name;
|
||||
private final String display;
|
||||
|
||||
private FilterType(String name, String display) {
|
||||
this.name = name;
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplay() {
|
||||
return this.display;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FilterFunction implements EnumFunction<FilterType> {
|
||||
public void apply(EnumVar cv, FilterType value) {
|
||||
if(Game.getGame().open instanceof GuiChar)
|
||||
Game.getGame().displayGuiScreen(Game.getGame().open);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiChar INSTANCE = new GuiChar();
|
||||
private static final File TEXTURE_FOLDER = new File("skins");
|
||||
|
||||
private ActButton templateButton;
|
||||
private DragAdjust adjust;
|
||||
|
@ -231,6 +243,10 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
private float pitch = -15.0f;
|
||||
private boolean waiting = true;
|
||||
private int dimension;
|
||||
private String currentSkin;
|
||||
|
||||
@Variable(name = "char_filter_species", category = CVarCategory.GUI, display = "Filtern", callback = FilterFunction.class, switched = true)
|
||||
private FilterType filterSpecies = FilterType.ALL;
|
||||
|
||||
private GuiChar() {
|
||||
}
|
||||
|
@ -245,12 +261,13 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.adjust = null;
|
||||
return;
|
||||
}
|
||||
this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel());
|
||||
this.currentSkin = this.gm.thePlayer != null && !EntityTexManager.hasCustomSkin(this.gm.thePlayer.getId()) ? this.gm.thePlayer.getChar() : null;
|
||||
this.load(this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel(), this.gm.thePlayer != null ? this.gm.thePlayer.getSpecies() : SpeciesRegistry.CLASSES.get(EntityHuman.class));
|
||||
this.add(new ActButton(4, 4, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", new File("skins"), new FileCallback() {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
if(SkinConverter.convertSkin(file, new File("skins"), false))
|
||||
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false))
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
}
|
||||
});
|
||||
|
@ -258,14 +275,15 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}, "Importieren: Standard"));
|
||||
this.add(new ActButton(202, 4, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", new File("skins"), new FileCallback() {
|
||||
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() {
|
||||
public void selected(File file) {
|
||||
if(SkinConverter.convertSkin(file, new File("skins"), true))
|
||||
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true))
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, "Importieren: Schlank"));
|
||||
this.addSelector("char_filter_species", 400, 4, 300, 24);
|
||||
this.add(new ActButton(4, height - 28, 194, 24, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
GuiChar.this.gm.displayGuiScreen(GuiChar.this);
|
||||
|
@ -276,10 +294,10 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
SkinEntry skin = GuiChar.this.getSelected();
|
||||
if(skin != null && skin.getLocation() != null) {
|
||||
String loc = skin.getLocation();
|
||||
File file = new File(new File("skins"), loc + ".png");
|
||||
File file = new File(TEXTURE_FOLDER, loc + ".png");
|
||||
int z = 1;
|
||||
while(file.exists()) {
|
||||
file = new File(new File("skins"), loc + "_" + (++z) + ".png");
|
||||
file = new File(TEXTURE_FOLDER, loc + "_" + (++z) + ".png");
|
||||
}
|
||||
InputStream in = null;
|
||||
try {
|
||||
|
@ -307,8 +325,12 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}, "Vorlage kopieren"));
|
||||
this.adjust = this.add(new DragAdjust(width / 2 - 230, height - 64 - 640, 460, 640));
|
||||
|
||||
this.add(new Label(width - 396, 36, 392, 20, this.gm.thePlayer == null ? "<?>" : this.gm.thePlayer.getSpecies().name, true));
|
||||
this.add(new Label(width - 396, 36, 392, 20, "Spezies: " + (this.gm.thePlayer == null ? "<?>" : this.gm.thePlayer.getSpecies().name), true));
|
||||
this.add(new NavButton(width - 396, 56, 392, 24, GuiSpecies.INSTANCE, "Spezies ändern"));
|
||||
this.add(new Label(width - 396, 36 + 92, 392, 20, "Klasse: " + (this.gm.thePlayer == null || this.gm.thePlayer.getSpecies().classEnum == null || this.gm.thePlayer.getNpcClass() == null || this.gm.thePlayer.getNpcClass().toString().isEmpty() ? "<Keine>" : this.gm.thePlayer.getNpcClass().toString()), true))
|
||||
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null;
|
||||
this.add(new NavButton(width - 396, 56 + 92, 392, 24, GuiClass.INSTANCE, "Klasse ändern"))
|
||||
.enabled = this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null;
|
||||
|
||||
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
|
||||
for (int z = 0; z < Alignment.values().length; z++)
|
||||
|
@ -398,11 +420,6 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.setDimButton();
|
||||
}
|
||||
|
||||
public void selectSkin(BufferedImage img, ModelType model)
|
||||
{
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model));
|
||||
}
|
||||
|
||||
private void setDimButton() {
|
||||
Dimension dim = UniverseRegistry.getBaseDimensions().get(this.dimension);
|
||||
this.dimButton.setText((dim.getType() == DimType.PLANET ? "Heimplanet" : "Heimdimension") + ": " + dim.getFormattedName(false));
|
||||
|
@ -457,19 +474,20 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
return img;
|
||||
}
|
||||
|
||||
public void load(String currentSkin, ModelType model)
|
||||
public void load(ModelType model, SpeciesInfo speciesOnly)
|
||||
{
|
||||
this.unload();
|
||||
File[] files = new File("skins").listFiles(new FileFilter() {
|
||||
TEXTURE_FOLDER.mkdirs();
|
||||
File[] files = this.filterSpecies == FilterType.NPC || this.filterSpecies == FilterType.SPECIES ? null : TEXTURE_FOLDER.listFiles(new FileFilter() {
|
||||
public boolean accept(File pathname) {
|
||||
return pathname.isFile() && pathname.getName().endsWith(".png");
|
||||
}
|
||||
});
|
||||
int pos = 0;
|
||||
this.elements.add(new SkinEntry("default", null, null, null, model));
|
||||
if("default".equals(currentSkin))
|
||||
this.setSelected(pos);
|
||||
pos++;
|
||||
// this.elements.add(new SkinEntry("default", null, null, null, model));
|
||||
// if("default".equals(currentSkin))
|
||||
// this.setSelected(pos);
|
||||
// pos++;
|
||||
if(files != null) {
|
||||
Arrays.sort(files);
|
||||
for(File file : files)
|
||||
|
@ -478,18 +496,20 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
if(img != null) {
|
||||
if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) {
|
||||
this.elements.add(new SkinEntry(file.getName(), file, null, img, model));
|
||||
if(file.getName().equals(currentSkin))
|
||||
if(file.getName().equals(this.currentSkin))
|
||||
this.setSelected(pos);
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {
|
||||
if(this.filterSpecies == FilterType.CUSTOM)
|
||||
return;
|
||||
for(SpeciesInfo species : this.filterSpecies == FilterType.SPECIES || this.filterSpecies == FilterType.SPECIES_CUSTOM ? Lists.newArrayList(speciesOnly) : SpeciesRegistry.SPECIMEN) {
|
||||
for(CharacterInfo charinfo : species.chars) {
|
||||
if(charinfo.species.renderer == model) {
|
||||
this.elements.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer));
|
||||
if(charinfo.skin.equals(currentSkin))
|
||||
if(charinfo.skin.equals(this.currentSkin))
|
||||
this.setSelected(pos);
|
||||
pos++;
|
||||
}
|
||||
|
|
77
java/src/game/gui/character/GuiClass.java
Normal file
77
java/src/game/gui/character/GuiClass.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package game.gui.character;
|
||||
|
||||
import game.gui.element.ActButton;
|
||||
import game.gui.element.ActButton.Mode;
|
||||
import game.gui.element.GuiList;
|
||||
import game.gui.element.ListEntry;
|
||||
import game.gui.element.NavButton;
|
||||
import game.packet.CPacketAction;
|
||||
import game.renderer.Drawing;
|
||||
|
||||
public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ActButton.Callback
|
||||
{
|
||||
protected class ClassEntry implements ListEntry
|
||||
{
|
||||
private final Enum clazz;
|
||||
|
||||
protected ClassEntry(Enum clazz)
|
||||
{
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public void draw(int x, int y, int mouseX, int mouseY, boolean hovered)
|
||||
{
|
||||
if(GuiClass.this.gm.thePlayer != null && this.clazz == GuiClass.this.gm.thePlayer.getNpcClass())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.clazz.toString().isEmpty() ? "<Keine>" : this.clazz.toString(), x + 3, y, 0xffffffff);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
{
|
||||
if((GuiClass.this.selectButton.enabled = GuiClass.this.gm.thePlayer == null || this.clazz != GuiClass.this.gm.thePlayer.getNpcClass()) && dclick)
|
||||
GuiClass.this.use(GuiClass.this.selectButton, Mode.PRIMARY);
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiClass INSTANCE = new GuiClass();
|
||||
|
||||
private ActButton selectButton;
|
||||
|
||||
private GuiClass() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(400, height, 32, height - 32);
|
||||
this.elements.clear();
|
||||
if(this.gm.thePlayer != null && this.gm.thePlayer.getSpecies().classEnum != null)
|
||||
for(Enum clazz : this.gm.thePlayer.getSpecies().classEnum.getEnumConstants()) {
|
||||
this.elements.add(new ClassEntry(clazz));
|
||||
}
|
||||
this.add(new NavButton(width - 198 * 2, height - 28, 194, 24, GuiChar.INSTANCE, "Zurück"));
|
||||
this.selectButton = this.add(new ActButton(width - 198, height - 28, 194, 24, this, "Klasse ändern"));
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Klasse wählen";
|
||||
}
|
||||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
{
|
||||
return 44 + 4;
|
||||
}
|
||||
|
||||
public void use(ActButton elem, Mode action) {
|
||||
ClassEntry entry = this.getSelected();
|
||||
if(entry != null && GuiClass.this.gm.thePlayer != null) {
|
||||
GuiClass.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
|
||||
this.gm.displayGuiScreen(GuiChar.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@ public class GuiSpecies extends GuiList<GuiSpecies.SpeciesEntry> implements ActB
|
|||
if(GuiSpecies.this.gm.thePlayer != null && this.species == GuiSpecies.this.gm.thePlayer.getSpecies())
|
||||
Drawing.drawRect(x, y, 1, 44, 0xffaf0000);
|
||||
Drawing.drawText(this.species.name, x + 3, y, 0xff000000 | this.species.color1 | this.species.color2);
|
||||
if(this.species.classEnum != null)
|
||||
Drawing.drawText(this.species.classEnum.getEnumConstants().length + " Klassen", x + 3, y + 18, 0xffc0c0c0);
|
||||
}
|
||||
|
||||
public void select(boolean dclick, int mx, int my)
|
||||
|
|
|
@ -115,6 +115,7 @@ public abstract class GuiContainer extends Gui
|
|||
private float currentScroll;
|
||||
private boolean isScrolling;
|
||||
private boolean wasClicking;
|
||||
private ItemStack cheatStack;
|
||||
|
||||
public void drawString(String text, int x, int y) {
|
||||
x = x * 2 + this.container_x;
|
||||
|
@ -175,6 +176,7 @@ public abstract class GuiContainer extends Gui
|
|||
public void init(int width, int height) {
|
||||
this.itemRender = this.gm.getRenderItem();
|
||||
this.tooltip = null;
|
||||
this.cheatStack = null;
|
||||
// this.width = width;
|
||||
// this.height = height;
|
||||
// this.initialize(this.gm.getGame());
|
||||
|
@ -361,6 +363,8 @@ public abstract class GuiContainer extends Gui
|
|||
ItemRenderer.enableGUIStandardItemLighting();
|
||||
InventoryPlayer inventoryplayer = this.gm.thePlayer.inventory;
|
||||
ItemStack itemstack = this.draggedStack == null ? inventoryplayer.getItemStack() : this.draggedStack;
|
||||
if(this.gm.itemCheat)
|
||||
itemstack = itemstack == null ? this.cheatStack : itemstack;
|
||||
|
||||
if (itemstack != null)
|
||||
{
|
||||
|
@ -383,6 +387,9 @@ public abstract class GuiContainer extends Gui
|
|||
s = "" + TextColor.YELLOW + "0";
|
||||
}
|
||||
}
|
||||
else if(itemstack == this.cheatStack) {
|
||||
s = TextColor.DGREEN + "+" + TextColor.GREEN + ItemStack.formatAmount(itemstack.stackSize);
|
||||
}
|
||||
|
||||
this.drawItemStack(itemstack, mouseX - j2, mouseY - k2, s);
|
||||
}
|
||||
|
@ -406,7 +413,7 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
// SKC.glPopMatrix();
|
||||
|
||||
if (inventoryplayer.getItemStack() == null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
if (inventoryplayer.getItemStack() == null && this.cheatStack == null && this.theSlot != null && this.theSlot.getHasStack())
|
||||
{
|
||||
ItemStack itemstack1 = this.theSlot.getStack();
|
||||
this.renderToolTip(itemstack1, mouseX, mouseY);
|
||||
|
@ -635,9 +642,17 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
if(this.gm == null)
|
||||
return;
|
||||
if(this.cheatStack != null) {
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.thePlayer != null && slot.inventory == this.gm.thePlayer.inventory)
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.stackSize > 1));
|
||||
if(mouseButton != 1 && !this.gm.ctrl())
|
||||
this.cheatStack = null;
|
||||
return;
|
||||
}
|
||||
if((mouseButton == 0 || mouseButton == 1 || mouseButton == 2) && this.clickSide(mouseX, mouseY, -1, this.gm.shift() || mouseButton == 1, this.gm.ctrl() || mouseButton == 2))
|
||||
return;
|
||||
if(mouseButton == 0) {
|
||||
if(this.clickSide(mouseX, mouseY, -1))
|
||||
return;
|
||||
if(this.gm.itemCheat && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null) {
|
||||
for (CheatTab tab : CheatTab.values())
|
||||
{
|
||||
|
@ -757,7 +772,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void mouseDragged(int mouseX, int mouseY)
|
||||
{
|
||||
if(this.gm == null)
|
||||
if(this.gm == null || this.cheatStack != null)
|
||||
return;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
ItemStack itemstack = this.gm.thePlayer.inventory.getItemStack();
|
||||
|
@ -809,7 +824,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void mouseReleased(int mouseX, int mouseY, int state)
|
||||
{
|
||||
if(this.gm == null)
|
||||
if(this.gm == null || this.cheatStack != null)
|
||||
return;
|
||||
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
|
||||
// int i = this.guiLeft;
|
||||
|
@ -1020,7 +1035,7 @@ public abstract class GuiContainer extends Gui
|
|||
*/
|
||||
public void useHotbar(int slot)
|
||||
{
|
||||
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot) && this.gm != null && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.theSlot != null)
|
||||
if (!this.clickSide((this.gm.mouse_x - this.container_x) / 2, (this.gm.mouse_y - this.container_y) / 2, slot, this.gm.shift(), this.gm.ctrl()) && this.gm != null && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null && this.theSlot != null)
|
||||
{
|
||||
// for (int i = 0; i < 9; ++i)
|
||||
// {
|
||||
|
@ -1167,8 +1182,8 @@ public abstract class GuiContainer extends Gui
|
|||
this.currentScroll = 0.0F;
|
||||
}
|
||||
|
||||
private boolean clickSide(int mouseX, int mouseY, int slot) {
|
||||
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null) {
|
||||
private boolean clickSide(int mouseX, int mouseY, int slot, boolean instant, boolean full) {
|
||||
if(this.gm.itemCheat && this.isPointInRegion(this.xSize + 2, 0, 18 * 12, 18 * 9, mouseX, mouseY) && this.gm.thePlayer != null && this.gm.thePlayer.inventory.getItemStack() == null && this.cheatStack == null) {
|
||||
int i = (ITEM_LIST.size() + 12 - 1) / 12 - 9;
|
||||
int j = (int)((double)(this.currentScroll * (float)i) + 0.5D);
|
||||
|
||||
|
@ -1182,7 +1197,13 @@ public abstract class GuiContainer extends Gui
|
|||
int i1 = sx + (sy + j) * 12;
|
||||
|
||||
if(i1 >= 0 && i1 < ITEM_LIST.size()) {
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, this.gm.ctrl()));
|
||||
if(slot >= 0 || instant) {
|
||||
this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketCheat(ITEM_LIST.get(i1), slot, full));
|
||||
}
|
||||
else {
|
||||
this.cheatStack = ITEM_LIST.get(i1).copy();
|
||||
this.cheatStack.stackSize = full ? this.cheatStack.getMaxStackSize() : 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue