diff --git a/java/src/game/Game.java b/java/src/game/Game.java index c7d6eb1..d32293f 100755 --- a/java/src/game/Game.java +++ b/java/src/game/Game.java @@ -426,6 +426,7 @@ public class Game implements IThreadListener { private boolean cfgDirty; private String buffer = ""; private boolean crashed; + private boolean waitingForFile; private final int[] tickTimes = new int[240]; private final long[] frames = new long[240]; @@ -1151,6 +1152,7 @@ public class Game implements IThreadListener { public void displayGuiScreen(Gui gui) { + this.waitingForFile = false; if(this.thePlayer != null) this.thePlayer.setScreenClosed(); if (this.open != null) @@ -1867,8 +1869,11 @@ public class Game implements IThreadListener { GL11.glViewport(0, 0, x, y); fb_x = x; fb_y = y; - if(this.open != null) + if(this.open != null) { + boolean flag = this.waitingForFile; this.displayGuiScreen(this.open); + this.waitingForFile = flag; + } if(!fullscreen) { xsize = x; ysize = y; @@ -1970,8 +1975,11 @@ public class Game implements IThreadListener { } private void redraw() { - if(this.open != null) + if(this.open != null) { + boolean flag = this.waitingForFile; this.displayGuiScreen(this.open); + this.waitingForFile = flag; + } } private void closed() { @@ -3324,6 +3332,9 @@ public class Game implements IThreadListener { } public void showDirDialog(final FileMode mode, final String title, final File def, final FileCallback callback) { + if(this.waitingForFile) + return; + this.waitingForFile = true; new Thread(new Runnable() { public void run() { String output; @@ -3375,9 +3386,12 @@ public class Game implements IThreadListener { return; Game.this.schedule(new Runnable() { public void run() { - for(File file : files) { - callback.selected(file); + if(Game.this.waitingForFile) { + for(File file : files) { + callback.selected(file); + } } + Game.this.waitingForFile = false; } }); } @@ -3403,7 +3417,9 @@ public class Game implements IThreadListener { } Game.this.schedule(new Runnable() { public void run() { - callback.selected(file); + if(Game.this.waitingForFile) + callback.selected(file); + Game.this.waitingForFile = false; } }); } diff --git a/java/src/game/entity/npc/EntityNPC.java b/java/src/game/entity/npc/EntityNPC.java index 65b8e88..1d7afb7 100755 --- a/java/src/game/entity/npc/EntityNPC.java +++ b/java/src/game/entity/npc/EntityNPC.java @@ -1073,10 +1073,10 @@ public abstract class EntityNPC extends EntityLiving // return ; // } - protected boolean hasSlimSkin() - { - return this.getChar().startsWith("~"); - } +// protected boolean hasSlimSkin() +// { +// return this.getChar().startsWith("~"); +// } public String getLocationCape() { @@ -4670,7 +4670,7 @@ public abstract class EntityNPC extends EntityLiving public Item getItem() { for(int z = 0; z < this.species.chars.length; z++) { if(this.species.chars[z].spawner && this.species.chars[z].skin.equals(this.getChar())) { - return ItemRegistry.getRegisteredItem(this.species.chars[z].skin.replace("~", "") + "_spawner"); + return ItemRegistry.getRegisteredItem(this.species.chars[z].skin + "_spawner"); } } return super.getItem(); diff --git a/java/src/game/gui/GuiChar.java b/java/src/game/gui/GuiChar.java index 29058fd..54d96ab 100755 --- a/java/src/game/gui/GuiChar.java +++ b/java/src/game/gui/GuiChar.java @@ -188,14 +188,12 @@ public class GuiChar extends GuiList if(this.charinfo != null) { try { img = TextureUtil.readImage(FileUtils.getResource( - EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : - this.charinfo.skin))); + 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.startsWith("~") ? this.charinfo.skin.substring(1) : - this.charinfo.skin)); + EntityNPC.getSkinTexture(this.charinfo.skin)); else Log.JNI.error(e, "Konnte Textur nicht laden"); return; @@ -228,7 +226,7 @@ public class GuiChar extends GuiList public String getLocation() { - return this.charinfo == null ? null : (this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : this.charinfo.skin); + return this.charinfo == null ? null : this.charinfo.skin; } public boolean canCopy() @@ -306,9 +304,9 @@ public class GuiChar extends GuiList this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel()); this.add(new ActButton(4, 4, 194, 24, new ActButton.Callback() { public void use(ActButton elem, Mode action) { - GuiChar.this.gm.showDirDialog(FileMode.FILE_LOAD, "Skin konvertieren", new File("skins"), new FileCallback() { + GuiChar.this.gm.showDirDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", new File("skins"), new FileCallback() { public void selected(File file) { - if(SkinConverter.convertSkin(file, new File("skins"), false) && GuiChar.this.gm.open == GuiChar.this) + if(SkinConverter.convertSkin(file, new File("skins"), false)) GuiChar.this.gm.displayGuiScreen(GuiChar.this); } }); @@ -316,9 +314,9 @@ public class GuiChar extends GuiList }, "Importieren: Standard")); this.add(new ActButton(202, 4, 194, 24, new ActButton.Callback() { public void use(ActButton elem, Mode action) { - GuiChar.this.gm.showDirDialog(FileMode.FILE_LOAD, "Skin konvertieren (schlank)", new File("skins"), new FileCallback() { + GuiChar.this.gm.showDirDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", new File("skins"), new FileCallback() { public void selected(File file) { - if(SkinConverter.convertSkin(file, new File("skins"), true) && GuiChar.this.gm.open == GuiChar.this) + if(SkinConverter.convertSkin(file, new File("skins"), true)) GuiChar.this.gm.displayGuiScreen(GuiChar.this); } }); diff --git a/java/src/game/gui/world/GuiWorlds.java b/java/src/game/gui/world/GuiWorlds.java index 7cda5f7..45d1568 100755 --- a/java/src/game/gui/world/GuiWorlds.java +++ b/java/src/game/gui/world/GuiWorlds.java @@ -222,14 +222,39 @@ public class GuiWorlds extends GuiList implements ActButton. public void use(ActButton elem, ActButton.Mode action) { if(GuiWorlds.this.gm.theWorld != null) return; - GuiWorlds.this.gm.showDirDialog(FileMode.DIRECTORY_LOAD, "Welt öffnen", Region.SAVE_DIR, new FileCallback() { + GuiWorlds.this.gm.showDirDialog(FileMode.DIRECTORY_LOAD, "Welt importieren", Region.SAVE_DIR, new FileCallback() { public void selected(File file) { - if(GuiWorlds.this.gm.theWorld == null && GuiWorlds.this.gm.open instanceof GuiWorlds) - GuiWorlds.this.gm.startServer(file, "sen"); + File parent = file.getParentFile(); + if(parent != null && Region.SAVE_DIR.getAbsoluteFile().equals(parent.getAbsoluteFile())) { + GuiWorlds.this.warningTimer = 120; + GuiWorlds.this.warningMessage = "Ordner befindet sich bereits im Weltenorder"; + return; + } + FolderInfo info = Region.loadWorldInfo(file); + if(info == null) + info = Converter.convertMapFormat(file, null); + if(info == null || info.legacy == SaveVersion.RELEASE_1_13) { + GuiWorlds.this.warningTimer = 120; + GuiWorlds.this.warningMessage = info == null ? "Keine Weltdaten gefunden" : "Weltdaten haben inkompatible Version"; + return; + } + int n = 0; + File newDir; + do { + newDir = new File(Region.SAVE_DIR, file.getName() + (n > 0 ? "_" + n : "")); + n++; + } + while(newDir.exists()); + Log.IO.info("Kopiere Welt " + file + " nach " + newDir); + if(!copyFiles(file, newDir, file.listFiles())) + GuiWorlds.this.displayWarning("Fehler beim Kopieren der Welt, diese könnte unvollständig sein!"); + else + GuiWorlds.this.displayInfo("Welt wurde in den Weltenordner kopiert"); + GuiWorlds.this.gm.displayGuiScreen(GuiWorlds.this); } }); } - }, "Welt laden")); + }, "Welt importieren")); this.selectButton.enabled = false; this.deleteButton.enabled = false; @@ -241,6 +266,16 @@ public class GuiWorlds extends GuiList implements ActButton. this.dupeButton.enabled = false; this.createButton.enabled = create; } + + private void displayWarning(String msg) { + this.warningTimer = 120; + this.warningMessage = TextColor.DRED + msg; + } + + private void displayInfo(String msg) { + this.warningTimer = 40; + this.warningMessage = TextColor.DGREEN + msg; + } public String getTitle() { return "Welt auswählen"; @@ -419,6 +454,8 @@ public class GuiWorlds extends GuiList implements ActButton. this.warningTimer = 120; this.warningMessage = "Fehler beim Kopieren der Welt, diese könnte unvollständig sein!"; } + else + this.displayInfo("Welt wurde kopiert"); // try // { // this.loadLevelList(); @@ -443,6 +480,8 @@ public class GuiWorlds extends GuiList implements ActButton. this.warningTimer = 120; this.warningMessage = "Fehler beim Löschen der Welt!"; } + else + this.displayInfo("Welt wurde verschoben"); this.gm.displayGuiScreen(this); } @@ -456,7 +495,10 @@ public class GuiWorlds extends GuiList implements ActButton. } catch(Exception e) { Log.IO.error("Fehler beim Verarbeiten von " + file, e); + this.displayWarning("Konnte Spielernamen nicht ändern"); + return; } + this.displayInfo("Spielername wurde geändert"); } // this.gm.displayGuiScreen(this); } @@ -631,6 +673,8 @@ public class GuiWorlds extends GuiList implements ActButton. selectWorld.warningTimer = 120; selectWorld.warningMessage = "Fehler beim " + (prune ? "Leeren" : "Löschen") + " der Welt!"; } + else if(confirmed) + selectWorld.displayInfo("Welt wurde " + (prune ? "geleert" : "gelöscht")); selectWorld.gm.displayGuiScreen(selectWorld); } }, s, s1, s2, s3); diff --git a/java/src/game/init/ItemRegistry.java b/java/src/game/init/ItemRegistry.java index 4ad1d41..27b52e3 100755 --- a/java/src/game/init/ItemRegistry.java +++ b/java/src/game/init/ItemRegistry.java @@ -378,7 +378,7 @@ public abstract class ItemRegistry { for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { for(CharacterInfo charinfo : species.chars) { if(charinfo.spawner) - registerItem(charinfo.skin.replace("~", "") + "_spawner", (new ItemNpcSpawner(charinfo)).setDisplay("NSC-Spawner") + registerItem(charinfo.skin + "_spawner", (new ItemNpcSpawner(charinfo)).setDisplay("NSC-Spawner") .setMaxStackSize(ItemStack.MAX_SIZE)); } } diff --git a/java/src/game/init/SpeciesRegistry.java b/java/src/game/init/SpeciesRegistry.java index a5f3d63..16c9b7f 100755 --- a/java/src/game/init/SpeciesRegistry.java +++ b/java/src/game/init/SpeciesRegistry.java @@ -139,7 +139,7 @@ public abstract class SpeciesRegistry { ":knight_1", ":knight_2", ":knight_3", ":knight_4", ":knight_5", ":knight_6", ":knight_7", ":knight_8", EntityHuman.ClassType.PEASANT, ":peasant_1", ":peasant_2", ":peasant_3", - ":peasant_4", ":~peasant_5", ":peasant_6"); + ":peasant_4", ":peasant_5", ":peasant_6"); registerSpecies("Spirit", EntitySpirit.class, "yrdinath", "Geist", 1.65f, 0xdfdfff, 0xbfbfff); registerSpecies("Haunter", EntityHaunter.class, "warp", "Verfolger", 1.55f, 0xffdfdf, 0xffbfbf); registerSpecies("FireDemon", EntityFireDemon.class, "ahrd", "Feuerdämon", 2.55f, 0xff0000, 0xff7f00); diff --git a/java/src/game/renderer/texture/EntityTexManager.java b/java/src/game/renderer/texture/EntityTexManager.java index b8cce10..ff54b32 100755 --- a/java/src/game/renderer/texture/EntityTexManager.java +++ b/java/src/game/renderer/texture/EntityTexManager.java @@ -41,7 +41,7 @@ public abstract class EntityTexManager TextureManager manager = Game.getGame().getTextureManager(); for(Entry entry : SpeciesRegistry.SKINS.entrySet()) { String skin = entry.getKey(); - skin = skin.startsWith("~") ? skin.substring(1) : skin; +// skin = skin.startsWith("~") ? skin.substring(1) : skin; String loc = EntityNPC.getSkinTexture(skin); BufferedImage image; try { @@ -156,8 +156,8 @@ public abstract class EntityTexManager public static LayerExtra getNpcLayer(String skin, ModelType model) { - 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); + return Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(skin)) != null ? + NPC_LAYERS.get(skin.toLowerCase()) : DEF_LAYERS.get(model); } public static String getSkin(int id, ModelType model) @@ -168,7 +168,7 @@ public abstract class EntityTexManager public static String getNpcSkin(String skin, ModelType model) { - String loc = getNpcSkinLocation(skin.startsWith("~") ? skin.substring(1) : skin); + String loc = getNpcSkinLocation(skin); return Game.getGame().getTextureManager().getTexture(loc) != null ? loc : getDefault(model); }