Let's do this differently, so that you can actually close the book at all when the search field is up

This commit is contained in:
Ellpeck 2016-03-18 16:00:36 +01:00
parent 92172c0fdc
commit efdb43bd5a

View file

@ -162,20 +162,6 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
@Override @Override
public void keyTyped(char theChar, int key){ public void keyTyped(char theChar, int key){
if(key == Keyboard.KEY_ESCAPE || (key == this.mc.gameSettings.keyBindInventory.getKeyCode() && this.hisNameIsAt <= 0 && !this.searchField.isFocused())){
if(this.parentScreen != null){
this.mc.displayGuiScreen(this.parentScreen);
}
else{
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
}
}
else if(this.searchField.isFocused()){
this.searchField.textboxKeyTyped(theChar, key);
BookletUtils.updateSearchBar(this);
}
else{
if(AND_HIS_NAME_IS.length > this.hisNameIsAt && AND_HIS_NAME_IS[this.hisNameIsAt] == key){ if(AND_HIS_NAME_IS.length > this.hisNameIsAt && AND_HIS_NAME_IS[this.hisNameIsAt] == key){
if(this.hisNameIsAt+1 >= AND_HIS_NAME_IS.length){ if(this.hisNameIsAt+1 >= AND_HIS_NAME_IS.length){
Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation(ModUtil.MOD_ID_LOWER, "duhDuhDuhDuuuh"))); Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation(ModUtil.MOD_ID_LOWER, "duhDuhDuhDuuuh")));
@ -188,8 +174,22 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
} }
else{ else{
this.hisNameIsAt = 0; this.hisNameIsAt = 0;
if(key == Keyboard.KEY_ESCAPE || (key == this.mc.gameSettings.keyBindInventory.getKeyCode() && !this.searchField.isFocused())){
if(this.parentScreen != null){
this.mc.displayGuiScreen(this.parentScreen);
}
else{
this.mc.displayGuiScreen(null);
this.mc.setIngameFocus();
} }
} }
else if(this.searchField.isFocused()){
this.searchField.textboxKeyTyped(theChar, key);
BookletUtils.updateSearchBar(this);
}
}
} }
@Override @Override