diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index f4131c425..f93153c48 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -50,6 +50,7 @@ import noppes.npcs.client.gui.player.*; import noppes.npcs.client.gui.player.companion.GuiNpcCompanionInv; import noppes.npcs.client.gui.player.companion.GuiNpcCompanionStats; import noppes.npcs.client.gui.player.companion.GuiNpcCompanionTalents; +import noppes.npcs.client.gui.player.modern.BlurEventHandler; import noppes.npcs.client.gui.questtypes.GuiNpcQuestTypeItem; import noppes.npcs.client.gui.roles.*; import noppes.npcs.client.gui.script.GuiScriptBlock; @@ -113,6 +114,10 @@ public class ClientProxy extends CommonProxy { MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(CustomItems.scripted), new ScriptedBlockItemRenderer()); RenderingRegistry.registerBlockHandler(new BlockBorderRenderer()); + BlurEventHandler blurEventHandler = new BlurEventHandler(); + MinecraftForge.EVENT_BUS.register(blurEventHandler); + FMLCommonHandler.instance().bus().register(blurEventHandler); + if (!ConfigItem.DisableExtraBlock) { ClientRegistry.bindTileEntitySpecialRenderer(TileBanner.class, new BlockBannerRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileWallBanner.class, new BlockWallBannerRenderer()); diff --git a/src/main/java/noppes/npcs/client/NoppesUtil.java b/src/main/java/noppes/npcs/client/NoppesUtil.java index 3a343291e..6c6b074b0 100644 --- a/src/main/java/noppes/npcs/client/NoppesUtil.java +++ b/src/main/java/noppes/npcs/client/NoppesUtil.java @@ -17,10 +17,13 @@ import net.minecraft.util.Util; import noppes.npcs.CustomNpcs; import noppes.npcs.client.gui.player.GuiDialogInteract; import noppes.npcs.client.gui.player.GuiQuestCompletion; +import noppes.npcs.client.gui.player.modern.GuiModernDialogInteract; +import noppes.npcs.client.gui.player.modern.GuiModernQuestDialog; import noppes.npcs.client.gui.util.GuiContainerNPCInterface; import noppes.npcs.client.gui.util.GuiNPCInterface; import noppes.npcs.client.gui.util.IPlayerDataInfo; import noppes.npcs.client.gui.util.IScrollData; +import noppes.npcs.config.ConfigClient; import noppes.npcs.constants.EnumGuiType; import noppes.npcs.constants.EnumScrollData; import noppes.npcs.controllers.data.Dialog; @@ -191,8 +194,17 @@ public class NoppesUtil { Dialog dialog = new Dialog(); dialog.readNBT(compound); GuiScreen gui = Minecraft.getMinecraft().currentScreen; - if (gui == null || !(gui instanceof GuiDialogInteract)) - CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, dialog)); + if(!(gui instanceof GuiDialogInteract)) { + if (ConfigClient.ModernGuiSystem) { + if (dialog.hasQuest()) { + CustomNpcs.proxy.openGui(player, new GuiModernQuestDialog(npc, dialog.getQuest(), dialog, -2)); + } else { + CustomNpcs.proxy.openGui(player, new GuiModernDialogInteract(npc, dialog)); + } + } else { + CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, dialog)); + } + } else { GuiDialogInteract dia = (GuiDialogInteract) gui; dia.appendDialog(dialog); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java index 81892873c..4e32baa4f 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java @@ -8,6 +8,7 @@ import noppes.npcs.client.NoppesUtil; import noppes.npcs.client.gui.util.*; import noppes.npcs.config.ConfigMain; import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogColorData; import noppes.npcs.controllers.data.DialogImage; import java.util.ArrayList; @@ -40,7 +41,9 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis GuiMenuTopButton general = new GuiMenuTopButton(1, guiLeft + 4, guiTop - 17, "General"); GuiMenuTopButton spacing = new GuiMenuTopButton(2, general.xPosition + general.getWidth(), guiTop - 17, "Spacing"); GuiMenuTopButton images = new GuiMenuTopButton(3, spacing.xPosition + spacing.getWidth(), guiTop - 17, "Images"); - topButtons = new GuiMenuTopButton[]{general, images, spacing, close}; + GuiMenuTopButton colours = new GuiMenuTopButton(5, images.xPosition + images.getWidth(), guiTop - 17, "Colors"); + + topButtons = new GuiMenuTopButton[]{general,images,spacing,close,colours}; for (GuiMenuTopButton button : topButtons) { button.active = button.id == activeMenu; addButton(button); @@ -241,6 +244,53 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis getLabel(21).enabled = dialogImage.imageType == 0; } } + else if (activeMenu == 5) { + addButton(new GuiNpcButtonYesNo(10, guiLeft + 180, y += 22, 60, 20, dialog.colorData.getEnableColorSettings())); + addLabel(new GuiNpcLabel(10, "dialog.enableColorSettings", guiLeft + 4, y + 5)); + if (dialog.colorData.getEnableColorSettings()) { + String color = Integer.toHexString(dialog.colorData.getLineColor1()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(11, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(11, "gui.lineColor1", guiLeft + 4, y + 5)); + getButton(11).setTextColor(dialog.colorData.getLineColor1()); + + color = Integer.toHexString(dialog.colorData.getLineColor2()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(12, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(12, "gui.lineColor2", guiLeft + 4, y + 5)); + getButton(12).setTextColor(dialog.colorData.getLineColor2()); + + color = Integer.toHexString(dialog.colorData.getLineColor3()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(13, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(13, "gui.lineColor3", guiLeft + 4, y + 5)); + getButton(13).setTextColor(dialog.colorData.getLineColor3()); + + color = Integer.toHexString(dialog.colorData.getSlotColor()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(14, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(14, "gui.slotColor", guiLeft + 4, y + 5)); + getButton(14).setTextColor(dialog.colorData.getSlotColor()); + + color = Integer.toHexString(dialog.colorData.getButtonAcceptColor()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(15, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(15, "gui.buttonAcceptColor", guiLeft + 4, y + 5)); + getButton(15).setTextColor(dialog.colorData.getButtonAcceptColor()); + + color = Integer.toHexString(dialog.colorData.getButtonRejectColor()); + while (color.length() < 6) + color = 0 + color; + addButton(new GuiNpcButton(16, guiLeft + 180, y += 25, 60, 20, color)); + addLabel(new GuiNpcLabel(16, "gui.buttonRejectColor", guiLeft + 4, y + 5)); + getButton(16).setTextColor(dialog.colorData.getButtonRejectColor()); + } + } } public void updateScrollData() { @@ -379,7 +429,36 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis } } } - + if (activeMenu == 5) { + DialogColorData colData = dialog.colorData; + if (button.id == 10) { + colData.setEnableColorSettings(button.getValue()==1); + } + if (button.id == 11) { + setSubGui(new SubGuiColorSelector(colData.getLineColor1())); + lastColorClicked = 2; + } + if (button.id == 12) { + setSubGui(new SubGuiColorSelector(colData.getLineColor2())); + lastColorClicked = 3; + } + if (button.id == 13) { + setSubGui(new SubGuiColorSelector(colData.getLineColor3())); + lastColorClicked = 4; + } + if (button.id == 14) { + setSubGui(new SubGuiColorSelector(colData.getSlotColor())); + lastColorClicked = 5; + } + if (button.id == 15) { + setSubGui(new SubGuiColorSelector(colData.getButtonAcceptColor())); + lastColorClicked = 6; + } + if (button.id == 16) { + setSubGui(new SubGuiColorSelector(colData.getButtonRejectColor())); + lastColorClicked = 7; + } + } initGui(); } @@ -412,6 +491,23 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis initGui(); } } + if (activeMenu == 5) { + DialogColorData colData = dialog.colorData; + if (lastColorClicked == 2) { + colData.setLineColor1(((SubGuiColorSelector) subgui).color); + } else if (lastColorClicked == 3) { + colData.setLineColor2(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 4) { + colData.setLineColor3(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 5) { + colData.setSlotColor(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 6) { + colData.setButtonAcceptColor(((SubGuiColorSelector) subgui).color); + }else if (lastColorClicked == 7) { + colData.setButtonRejectColor(((SubGuiColorSelector) subgui).color); + } + initGui(); + } save(); } diff --git a/src/main/java/noppes/npcs/client/gui/player/modern/BlurEventHandler.java b/src/main/java/noppes/npcs/client/gui/player/modern/BlurEventHandler.java new file mode 100644 index 000000000..7726d9a3b --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/modern/BlurEventHandler.java @@ -0,0 +1,37 @@ +package noppes.npcs.client.gui.player.modern; + +import com.google.gson.JsonSyntaxException; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.EntityRenderer; +import net.minecraft.client.shader.ShaderGroup; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.GuiOpenEvent; + +import java.io.IOException; + +public class BlurEventHandler { + @SubscribeEvent + public void onGuiChange(GuiOpenEvent event) { + if (Minecraft.getMinecraft().theWorld != null) { + EntityRenderer er = Minecraft.getMinecraft().entityRenderer; + if (er.getShaderGroup() == null && (event.gui instanceof GuiModernDialogInteract) || (event.gui instanceof GuiModernQuestDialog)) { + loadEffect(er,new ResourceLocation("customnpcs", "shaders/post/blur.json")); + } else if (er.getShaderGroup()!=null && !(event.gui instanceof GuiModernDialogInteract)) { + er.deactivateShader(); + } + } + } + public static void loadEffect(EntityRenderer er, ResourceLocation p_175069_1_) { + if (er.theShaderGroup != null) { + er.theShaderGroup.deleteShaderGroup(); + } + Minecraft mc = Minecraft.getMinecraft(); + try { + er.theShaderGroup = new ShaderGroup(mc.getTextureManager(), mc.getResourceManager(), mc.getFramebuffer(), p_175069_1_); + er.theShaderGroup.createBindFramebuffers(mc.displayWidth, mc.displayHeight); + } catch (IOException | JsonSyntaxException ignored) { + + } + } +} diff --git a/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernDialogInteract.java new file mode 100644 index 000000000..ca4c98a14 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernDialogInteract.java @@ -0,0 +1,428 @@ +package noppes.npcs.client.gui.player.modern; + +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.player.CheckPlayerValue; +import kamkeel.npcs.network.packets.player.DialogSelectPacket; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.ResourceLocation; +import noppes.npcs.CustomNpcs; +import noppes.npcs.NoppesUtilPlayer; +import noppes.npcs.api.handler.data.IDialogImage; +import noppes.npcs.client.ClientProxy; +import noppes.npcs.client.NoppesUtil; +import noppes.npcs.client.TextBlockClient; +import noppes.npcs.client.controllers.MusicController; +import noppes.npcs.client.gui.player.GuiDialogImage; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.IGuiClose; +import noppes.npcs.constants.EnumOptionType; +import noppes.npcs.constants.EnumPlayerPacket; +import noppes.npcs.controllers.data.Dialog; +import noppes.npcs.controllers.data.DialogImage; +import noppes.npcs.controllers.data.DialogOption; +import noppes.npcs.controllers.data.Quest; +import noppes.npcs.entity.EntityNPCInterface; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +public class GuiModernDialogInteract extends GuiNPCInterface implements IGuiClose { + private Dialog dialog; + private int selected = 0; + private List lineBlocks = new ArrayList(); + private List options = new ArrayList(); + private int totalRows = 0; + + private ScaledResolution scaledResolution; + + private int optionStart = 0; + + private static int textSpeed = 10; + private static boolean textSoundEnabled = true; + + private int scrollY; + private final ResourceLocation decomposed = new ResourceLocation("customnpcs", "textures/gui/dialog_menu_decomposed.png"); + + private boolean isGrabbed = false; + + private final HashMap dialogImages = new HashMap<>(); + + public GuiModernDialogInteract(EntityNPCInterface npc, Dialog dialog) { + super(npc); + this.dialog = dialog; + + appendDialog(dialog); + ySize = 238; + } + + public void initGui() { + super.initGui(); + isGrabbed = false; + grabMouse(dialog.showWheel); + guiTop = (height - ySize); + calculateRowHeight(); + this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + this.drawDefaultBackground = dialog.darkenScreen; + setOptionOffset(); + } + + public void setOptionOffset() { + optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + dialog.optionSpaceY) - 20; + } + + public void grabMouse(boolean grab) { + if (grab && !isGrabbed) { + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + isGrabbed = true; + } else if (!grab && isGrabbed) { + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); + isGrabbed = false; + } + } + + public void drawLine(int x, int y, int width) { + drawRect(x, y, width, y + 1,0xff000000+ dialog.colorData.getLineColor1()); + drawRect(x, y + 1, width, y + 2, 0xff000000+ dialog.colorData.getLineColor2()); + drawRect(x, y + 2, width, y + 3, 0xff000000+ dialog.colorData.getLineColor3()); + } + + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GL11.glColor4f(1, 1, 1, 1); + this.drawGradientRect(0, 0, this.width, this.height, 0x66000000, 0x66000000); + super.drawScreen(mouseX, mouseY, partialTicks); + setOptionOffset(); + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.5f, 100.065F); + + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 0) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(image.x,image.y,0.0f); + GL11.glTranslatef(image.alignment % 3 * ((float) (scaledResolution.getScaledWidth()) / 2), (float) (Math.floor((float) (image.alignment / 3)) * ((float) (scaledResolution.getScaledHeight()) / 2)), 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glPushMatrix(); + for (IDialogImage dialogImage : dialog.dialogImages.values()) { + if (dialogImage.getImageType() != 1) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(image.x,image.y,0.0f); + GL11.glTranslatef(guiLeft + dialog.textOffsetX, optionStart + dialog.textOffsetY - image.height * image.scale, 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + GL11.glPopMatrix(); + if (!dialog.hideNPC) { + float scaleHeight = height / 509f; + float scaleWidth = width / 960f; + drawNpc(npc, -210 + dialog.npcOffsetX + (int) (300 * (1 - scaleWidth)), 350 + dialog.npcOffsetY - (int) (100 * (1 - scaleHeight)), 9.5F * dialog.npcScale * scaleHeight, -20); + } + int textBlockWidth = 700; + int lineCount = getLineCount(dialog.text, textBlockWidth); + int gap = Math.max(16, Math.min((int) (2.6f * (float) lineCount), 32)); + int textPartHeight = 23 + 3 + lineCount * ClientProxy.Font.height() + 2 * gap; + GL11.glPushMatrix(); + GL11.glTranslated(0.0, 0.5, 200.06500244140625); + drawGradientRect(0, height - textPartHeight, this.width, this.height, 0x99000000, 0x99000000); + drawLine(23, height - textPartHeight + 23, width - 23); + GL11.glScalef(1.5f, 1.5f, 1); + drawString(fontRendererObj, npc.getCommandSenderName(), (int) (47 / 1.5), (int) ((height - textPartHeight + 5) / 1.5), dialog.titleColor); + GL11.glScalef(1 / 1.5f, 1 / 1.5f, 1); + drawTextBlock(dialog.text, (width - textBlockWidth) / 2, height - textPartHeight + 23 + 3 + gap, textBlockWidth); + selected = -1; + for (int i = 0; i < this.options.size(); i++) { + int optionHeight = height/2-30 + i * (13 + 6); + int optionNum = options.get(i); + DialogOption option = dialog.options.get(optionNum); + if (mouseX >= width-237 && mouseX <= width-14 && mouseY >= optionHeight && mouseY <= optionHeight + 13) { + selected = i; + } + GL11.glEnable(GL11.GL_BLEND); + Minecraft.getMinecraft().getTextureManager().bindTexture(decomposed); + drawTexturedModalRect(width-233, optionHeight, 0, i == selected ? 13 : 0, 223, 13); + GL11.glDisable(GL11.GL_BLEND); + if (getQuestByOptionId(optionNum) != null) { + drawString(fontRendererObj, "!", width-229, optionHeight + 3, 0x76e85b); + } else { + drawString(fontRendererObj, ">", width-229, optionHeight + 3, -1); + } + drawString(fontRendererObj, option.title, width-221, optionHeight + 3, option.optionColor); + } + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public Quest getQuestByOptionId(int id) { + DialogOption option = dialog.options.get(id); + if (option != null && option.getDialog() != null && option.getDialog().hasQuest()) { + return option.getDialog().getQuest(); + } + return null; + } + + public void drawNpc(EntityNPCInterface entity, int x, int y, float zoomed, int rotation) { + EntityNPCInterface npc = entity; + + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f5 = entity.prevRotationYawHead; + float f6 = entity.rotationYawHead; + float scale = 1.0F; + if ((double) entity.height > 2.4) { + scale = 2.0F / entity.height; + } + float f7 = (float) (guiLeft + x); + entity.renderYawOffset = 0.0F; + entity.rotationYaw = (float) Math.atan((f7 / 80.0F)) * 40.0F + (float) rotation; + entity.rotationPitch = 0; + entity.rotationYawHead = 0.0F; + entity.prevRotationYawHead = 0.0F; + int orientation = 0; + orientation = npc.ais.orientation; + npc.ais.orientation = rotation; + int visibleName = npc.display.showName; + npc.display.showName = 1; + GL11.glPushMatrix(); + GL11.glTranslatef((float) guiLeft + (float) x, (float) (guiTop + y), 1050.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glTranslated(0.0, 0.0, 1000.0); + GL11.glScalef(30.0F * scale * zoomed, 30.0F * scale * zoomed, 30.0F * scale * zoomed); + GL11.glRotatef(180.0F, 0, 1, 0); + GL11.glRotatef(180.0F, 0, 0, 1); + GL11.glRotatef(-(float) rotation, 0, 1, 0); + RenderHelper.enableStandardItemLighting(); + RenderManager.instance.playerViewY = 180F; + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderManager.instance.renderEntityWithPosYaw(npc, 0.0, 0.0, 0.0, 0.0F, 1.0F); + GL11.glPopMatrix(); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + npc.ais.orientation = orientation; + npc.display.showName=visibleName; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public void drawWorldBackground(int p_238651_2_) { + } + + public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { + ClientProxy.Font.drawString(text, x, y, color); + } + + @Override + public void keyTyped(char c, int i) { + if (i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_UP) { + if (dialog.showWheel) { + selected--; + } else { + selected++; + } + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_DOWN) { + if (dialog.showWheel) { + selected++; + } else { + selected--; + } + } + + if (i == mc.gameSettings.keyBindForward.getKeyCode() || i == Keyboard.KEY_LEFT) { + textSpeed--; + if (textSpeed < 1) { + textSpeed = 1; + } + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == Keyboard.KEY_RIGHT) { + textSpeed++; + } + + if (i == mc.gameSettings.keyBindJump.getKeyCode() || i == Keyboard.KEY_SPACE) { + textSoundEnabled = !textSoundEnabled; + } + + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201 && scrollY < (totalRows - 2) * ClientProxy.Font.height()) {//Page up + scrollY += ClientProxy.Font.height() * 2; + } + if (i == mc.gameSettings.keyBindBack.getKeyCode() || i == 209 && scrollY > 0) {//Page down + scrollY -= ClientProxy.Font.height() * 2; + } + + if (i == 28) { + handleDialogSelection(); + } + if (closeOnEsc && (i == 1 || isInventoryKey(i))) { + PacketClient.sendClient(new DialogSelectPacket(dialog.id, -1)); + closed(); + close(); + } + super.keyTyped(c, i); + } + + @Override + public void mouseClicked(int i, int j, int k) { + if (selected == -1 && options.isEmpty() || selected >= 0) { + scrollY = 0; + handleDialogSelection(); + } + } + + private void handleDialogSelection() { + int optionId = -1; + if (dialog.showWheel) + optionId = selected; + else if (!options.isEmpty()) + optionId = options.get(selected); + if(getQuestByOptionId(optionId) == null){ + PacketClient.sendClient(new DialogSelectPacket(dialog.id, optionId)); + }else{ + CustomNpcs.proxy.openGui(player, new GuiModernQuestDialog(npc,getQuestByOptionId(optionId),dialog,optionId)); + } + + if (dialog == null || !dialog.hasOtherOptions() || options.isEmpty()) { + closed(); + close(); + return; + } + DialogOption option = dialog.options.get(optionId); + if (option == null || option.optionType != EnumOptionType.DialogOption) { + closed(); + close(); + return; + } + + if (!dialog.showPreviousBlocks) { + lineBlocks.clear(); + } + lineBlocks.add(new TextBlockClient(player.getDisplayName(), option.title, dialog.textWidth, option.optionColor, player, npc)); + + calculateRowHeight(); + + NoppesUtil.clickSound(); + } + + private void closed() { + grabMouse(false); + PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion)); + } + + public void save() { + + } + + public void appendDialog(Dialog dialog) { + closeOnEsc = !dialog.disableEsc; + this.dialogImages.clear(); + this.dialog = dialog; + this.options = new ArrayList(); + + if (dialog.sound != null && !dialog.sound.isEmpty()) { + MusicController.Instance.stopMusic(); + MusicController.Instance.playSound(dialog.sound, (float) npc.posX, (float) npc.posY, (float) npc.posZ); + } + + if (!dialog.showPreviousBlocks) { + lineBlocks.clear(); + } + lineBlocks.add(new TextBlockClient(npc, dialog, player, npc)); + + for (int slot : dialog.options.keySet()) { + DialogOption option = dialog.options.get(slot); + if (option == null || option.optionType == EnumOptionType.Disabled) + continue; + options.add(slot); + } + calculateRowHeight(); + + grabMouse(dialog.showWheel); + } + + private void calculateRowHeight() { + totalRows = 0; + for (TextBlockClient block : lineBlocks) { + totalRows += block.lines.size() + 1; + } + } + + public void drawTextBlock(String text, int x, int y, int width) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + + int count = 0; + for (Iterator var9 = block.lines.iterator(); var9.hasNext(); count++) { + IChatComponent line = (IChatComponent) var9.next(); + int height = y + count * ClientProxy.Font.height(); + drawCenteredString(fontRendererObj, line.getFormattedText(), x + width / 2, height, dialog.color); + } + } + + public void drawCenteredString(FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_) { + ClientProxy.Font.drawString(p_73732_2_, p_73732_3_ - ClientProxy.Font.width(p_73732_2_) / 2, p_73732_4_, p_73732_5_); + } + + public int getLineCount(String text, int width) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + return block.lines.size(); + } + + @Override + public void setClose(int i, NBTTagCompound data) { + grabMouse(false); + } +} diff --git a/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernQuestDialog.java b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernQuestDialog.java new file mode 100644 index 000000000..2d6d4c024 --- /dev/null +++ b/src/main/java/noppes/npcs/client/gui/player/modern/GuiModernQuestDialog.java @@ -0,0 +1,409 @@ +package noppes.npcs.client.gui.player.modern; + +import kamkeel.npcs.network.PacketClient; +import kamkeel.npcs.network.packets.data.npc.DialogPacket; +import kamkeel.npcs.network.packets.player.CheckPlayerValue; +import kamkeel.npcs.network.packets.player.DialogSelectPacket; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.ScaledResolution; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IChatComponent; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import noppes.npcs.CustomNpcs; +import noppes.npcs.NoppesUtilPlayer; +import noppes.npcs.api.handler.data.IDialogImage; +import noppes.npcs.api.handler.data.IQuestObjective; +import noppes.npcs.api.item.IItemStack; +import noppes.npcs.client.ClientProxy; +import noppes.npcs.client.TextBlockClient; +import noppes.npcs.client.gui.player.GuiDialogImage; +import noppes.npcs.client.gui.player.GuiDialogInteract; +import noppes.npcs.client.gui.util.GuiNPCInterface; +import noppes.npcs.client.gui.util.GuiNpcButton; +import noppes.npcs.client.gui.util.GuiTexturedButton; +import noppes.npcs.client.gui.util.IGuiClose; +import noppes.npcs.config.ConfigClient; +import noppes.npcs.constants.EnumPlayerPacket; +import noppes.npcs.controllers.FactionController; +import noppes.npcs.controllers.PlayerDataController; +import noppes.npcs.controllers.data.*; +import noppes.npcs.entity.EntityNPCInterface; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import java.util.*; + +public class GuiModernQuestDialog extends GuiNPCInterface implements IGuiClose { + private int selected = 0; + private List lineBlocks = new ArrayList(); + private List options = new ArrayList(); + private int totalRows = 0; + + private ScaledResolution scaledResolution; + + private int optionStart = 0; + + private static int textSpeed = 10; + private static boolean textSoundEnabled = true; + + private int scrollY; + private final ResourceLocation decomposed = new ResourceLocation("customnpcs", "textures/gui/dialog_menu_decomposed.png"); + + private boolean isGrabbed = false; + + private final HashMap dialogImages = new HashMap<>(); + private Dialog prevDialog; + private int optionId; + private Quest quest; + + public GuiModernQuestDialog(EntityNPCInterface npc, Quest quest, Dialog prevDialog, int optionId) { + super(npc); + ySize = 238; + this.prevDialog = prevDialog; + this.quest = quest; + this.optionId = optionId; + } + + public void initGui() { + super.initGui(); + isGrabbed = false; + guiTop = (height - ySize); + calculateRowHeight(); + this.scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + this.drawDefaultBackground = prevDialog.darkenScreen; + setOptionOffset(); + addButton(new GuiTexturedButton(0,"questgui.reject",720,326,156,40,decomposed.toString(),72,15)); + addButton(new GuiTexturedButton(1,"questgui.accept",812,326,156,40,decomposed.toString(),72,15)); + } + + public void setOptionOffset() { + optionStart = scaledResolution.getScaledHeight() - (options.size()) * (ClientProxy.Font.height() + prevDialog.optionSpaceY) - 20; + } + + public void grabMouse(boolean grab) { + if (grab && !isGrabbed) { + Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); + isGrabbed = true; + } else if (!grab && isGrabbed) { + Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); + isGrabbed = false; + } + } + + public void drawLine(int x, int y, int width) { + drawRect(x, y, width, y + 1,0xff000000+ prevDialog.colorData.getLineColor1());//0xff8d3800);// + drawRect(x, y + 1, width, y + 2, 0xff000000+ prevDialog.colorData.getLineColor2()); //0xfffea53b);// + drawRect(x, y + 2, width, y + 3, 0xff000000+ prevDialog.colorData.getLineColor3()); //0xff8d3800); + } + + public void drawScreen(int mouseX, int mouseY, float partialTicks) { + GL11.glColor4f(1, 1, 1, 1); + this.drawGradientRect(0, 0, this.width, this.height, 0x66000000, 0x66000000); + if (!prevDialog.hideNPC) { + float scaleHeight = height/509f; + float scaleWidth = width/960f; + drawNpc(npc, -210+prevDialog.npcOffsetX+(int)(300*(1-scaleWidth)), 350+prevDialog.npcOffsetY-(int)(100*(1-scaleHeight)), 9.5F*prevDialog.npcScale*scaleHeight, -20); + } + setOptionOffset(); + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.5f, 100.065F); + + for (IDialogImage dialogImage : prevDialog.dialogImages.values()) { + if (dialogImage.getImageType() != 0) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(image.alignment % 3 * ((float) (scaledResolution.getScaledWidth()) / 2), (float) (Math.floor((float) (image.alignment / 3)) * ((float) (scaledResolution.getScaledHeight()) / 2)), 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + + GL11.glPushMatrix(); + for (IDialogImage dialogImage : prevDialog.dialogImages.values()) { + if (dialogImage.getImageType() != 1) + continue; + + GuiDialogImage image; + if (dialogImages.containsKey(dialogImage.getId())) { + image = dialogImages.get(dialogImage.getId()); + } else { + image = new GuiDialogImage((DialogImage) dialogImage); + dialogImages.put(dialogImage.getId(), image); + } + + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0); + GL11.glDisable(GL11.GL_ALPHA_TEST); + + GL11.glTranslatef(guiLeft + prevDialog.textOffsetX, optionStart + prevDialog.textOffsetY - image.height * image.scale, 0.0F); + image.onRender(mc); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_ALPHA_TEST); + } + GL11.glPopMatrix(); + int textBlockWidth = 700; + String takeQuestString=translate("questgui.doyouaccept"); + int lineCount = getLineCount(takeQuestString, textBlockWidth); + int gap = Math.max(16, Math.min((int) (2.6f * (float) lineCount), 32)); + int textPartHeight = 23 + 3 + lineCount * ClientProxy.Font.height() + 2 * gap; + GL11.glPushMatrix(); + GL11.glTranslated(0.0, 0.5, 200.06500244140625); + drawGradientRect(0, height - textPartHeight, this.width, this.height, 0x99000000, 0x99000000); + drawLine(23, height - textPartHeight + 23, width - 23); + GL11.glScalef(1.5f, 1.5f, 1); + drawString(fontRendererObj, npc.getCommandSenderName(), (int) (47 / 1.5), (int) ((height - textPartHeight + 5) / 1.5), prevDialog.titleColor); + GL11.glScalef(1 / 1.5f, 1 / 1.5f, 1); + drawTextBlock(takeQuestString, (width - textBlockWidth) / 2, height - textPartHeight + 23 + 3 + gap, textBlockWidth,-1); + + Map activeQuests = PlayerDataController.Instance.getPlayerData(this.player).questData.activeQuests; + boolean hadQuest = activeQuests.containsKey(quest.id); + activeQuests.put(quest.id,new QuestData(quest)); + StringBuilder objectiveString = new StringBuilder(); + String[] questType = {translate("questgui.bringitems"), translate("questgui.readdialog"), + translate("questgui.killmobs"), translate("questgui.findlocation"), translate("questgui.defeat")}; + for (IQuestObjective objective : quest.questInterface.getObjectives(this.player)) { + if(objective!=null) + objectiveString.append("- " + questType[quest.getType()] + ": ").append(objective.getText()).append("\n"); + } + if(!hadQuest) + activeQuests.remove(quest.id); + int questLineCount = getLineCount(quest.logText, 180); + int objectivesLineCount = getLineCount(objectiveString.toString(),180); + int topToTextBottom = (int)(height*0.08) + 38+questLineCount*ClientProxy.Font.height()+20; + int topToObjectivesBottom = topToTextBottom+19+objectivesLineCount*ClientProxy.Font.height()+14; + int rewardCount = 0; + + List facIDs = new ArrayList(); + for (Integer facID : new Integer[]{quest.factionOptions.factionId, quest.factionOptions.faction2Id}) { + if (facID != -1) facIDs.add(facID); + } + for (IItemStack reward : quest.getRewards().getItems()) { + if (reward!=null && !(reward.getMCItemStack()==null)) rewardCount++; + } + int topToRewardsBottom = topToObjectivesBottom+(rewardCount==0?0:(36+13)); + int topToExpBottom = topToRewardsBottom+(quest.rewardExp==0?0:(12)); + int topToFactionBottom = topToExpBottom + (facIDs.size() * 15); + int questBlockHeight = topToFactionBottom+28; + drawGradientRect( width-285, (int)(height*0.08), width-285+260, questBlockHeight, 0x99000000, 0x99000000); + GL11.glScalef(1.5f, 1.5f, 1); + drawString(fontRendererObj, quest.getName(), (int) ((width-268) / 1.5), (int) ((height*0.095) / 1.5), -1); + GL11.glScalef(1 / 1.5f, 1 / 1.5f, 1); + drawLine(width-274,(int)(height*0.13),width-285+260-11); + drawTextBlock(quest.logText, width-245, (int)(height*0.157), 180,0xb8b8b8); + drawString(fontRendererObj, translate("questgui.objectives"),width-270, topToTextBottom, -1); + drawLeftAllignedTextBlock(objectiveString.toString(), width-255, topToTextBottom+12, 180,0xb8b8b8); + if(rewardCount!=0) + drawString(fontRendererObj, translate("questgui.rewards"),width-270, topToObjectivesBottom, -1); + for(int i=0;i> 16 & 0xff) / 255f, (color >> 8 & 0xff) / 255f, (color & 0xff) / 255f, 1); + drawTexturedModalRect(width-270+26*i, topToObjectivesBottom+16, 0, 27, 24, 24); + + itemRender.renderItemAndEffectIntoGUI(fontRendererObj,Minecraft.getMinecraft().renderEngine, rewardStack, width-266+26*i, topToObjectivesBottom+20); + itemRender.renderItemOverlayIntoGUI(fontRendererObj,Minecraft.getMinecraft().renderEngine, rewardStack, width-266+26*i, topToObjectivesBottom+20, ""+rewardStack.stackSize); + } + GL11.glDisable(GL11.GL_LIGHTING); + if(quest.rewardExp!=0) { + drawString(fontRendererObj, translate("questgui.experience"), width-270, topToRewardsBottom, 0xb8b8b8); + int expPosX = width-270+ClientProxy.Font.width(translate("questgui.experience")); + drawString(fontRendererObj, ""+quest.rewardExp, expPosX, topToRewardsBottom, -1); + int expSymbolPosX = expPosX+ClientProxy.Font.width(""+quest.rewardExp+" "); + Minecraft.getMinecraft().getTextureManager().bindTexture(decomposed); + drawTexturedModalRect(expSymbolPosX, topToRewardsBottom, 26, 27, 8, 8); + } + int fac1ID = quest.factionOptions.factionId; + if (fac1ID != -1) { + String fac1Name = FactionController.getInstance().getFaction(fac1ID).getName(); + String fac1Color = (quest.factionOptions.decreaseFactionPoints) ? "§c-" : "§a+"; + int fac1Point = quest.factionOptions.factionPoints; + int facIDIndex = facIDs.indexOf(fac1ID); + drawString(fontRendererObj, fac1Name + " " + fac1Color + fac1Point, width-270, topToExpBottom + (facIDIndex * 12), 0xb8b8b8); + } + int fac2ID = quest.factionOptions.faction2Id; + if (fac2ID != -1) { + String fac2Name = FactionController.getInstance().getFaction(fac2ID).getName(); + String fac2Color = (quest.factionOptions.decreaseFaction2Points) ? "§c-" : "§a+"; + int fac2Point = quest.factionOptions.faction2Points; + int facIDIndex = facIDs.indexOf(fac2ID); + drawString(fontRendererObj, fac2Name + " " + fac2Color + fac2Point, width-270, topToExpBottom + (facIDIndex * 12), 0xb8b8b8); + } + this.buttons.get(0).xPosition=width-240; + this.buttons.get(1).xPosition=width-148; + this.buttons.get(0).yPosition=topToFactionBottom; + this.buttons.get(1).yPosition=topToFactionBottom; + ((GuiTexturedButton)this.buttons.get(0)).scale=0.5f; + ((GuiTexturedButton)this.buttons.get(1)).scale=0.5f; + ((GuiTexturedButton)this.buttons.get(0)).color=prevDialog.colorData.getButtonRejectColor(); + ((GuiTexturedButton)this.buttons.get(1)).color=prevDialog.colorData.getButtonAcceptColor(); + super.drawScreen(mouseX, mouseY, partialTicks); + GL11.glColor4f(1,1,1,1); + GL11.glPopMatrix(); + GL11.glPopMatrix(); + } + + public String translate(String key){ + return StatCollector.translateToLocal(key); + } + + public void drawNpc(EntityNPCInterface entity, int x, int y, float zoomed, int rotation) { + EntityNPCInterface npc = entity; + + float f2 = entity.renderYawOffset; + float f3 = entity.rotationYaw; + float f4 = entity.rotationPitch; + float f5 = entity.prevRotationYawHead; + float f6 = entity.rotationYawHead; + float scale = 1.0F; + if ((double) entity.height > 2.4) { + scale = 2.0F / entity.height; + } + float f7 = (float) (guiLeft + x); + float f8 = (float) (guiTop + y) - 50.0F * scale * zoomed; + entity.renderYawOffset = 0.0F; + entity.rotationYaw = (float) Math.atan((double) (f7 / 80.0F)) * 40.0F + (float) rotation; + entity.rotationPitch = 0; + entity.rotationYawHead = 0.0F; + entity.prevRotationYawHead = 0.0F; + int orientation = 0; + orientation = npc.ais.orientation; + npc.ais.orientation = rotation; + int visibleName = npc.display.showName; + npc.display.showName = 1; + GL11.glPushMatrix(); + GL11.glTranslatef((float) guiLeft + (float) x, (float) (guiTop + y), 1050.0F); + GL11.glScalef(1.0F, 1.0F, -1.0F); + GL11.glTranslated(0.0, 0.0, 1000.0); + GL11.glScalef(30.0F * scale * zoomed, 30.0F * scale * zoomed, 30.0F * scale * zoomed); + GL11.glRotatef(180.0F, 0, 1, 0); + GL11.glRotatef(180.0F, 0, 0, 1); + GL11.glRotatef(-(float) rotation, 0, 1, 0); + RenderHelper.enableStandardItemLighting(); + RenderManager.instance.playerViewY = 180F; + GL11.glEnable(GL11.GL_DEPTH_TEST); + RenderManager.instance.renderEntityWithPosYaw(npc, 0.0, 0.0, 0.0, 0.0F, 1.0F); + GL11.glPopMatrix(); + entity.renderYawOffset = f2; + entity.rotationYaw = f3; + entity.rotationPitch = f4; + entity.prevRotationYawHead = f5; + entity.rotationYawHead = f6; + npc.ais.orientation = orientation; + npc.display.showName=visibleName; + RenderHelper.disableStandardItemLighting(); + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); + GL11.glDisable(GL11.GL_TEXTURE_2D); + OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); + } + + public void drawWorldBackground(int p_238651_2_) { + } + + public void drawString(FontRenderer fontRendererIn, String text, int x, int y, int color) { + ClientProxy.Font.drawString(text, x, y, color); + } + @Override + protected void actionPerformed(GuiButton guibutton) { + GuiNpcButton button = (GuiNpcButton) guibutton; + if(button.id==0){ + PacketClient.sendClient(new DialogSelectPacket(prevDialog.id, -1)); + closed(); + close(); + }else if(button.id==1){ + if(optionId!=-2){ + PacketClient.sendClient(new DialogSelectPacket(prevDialog.id, optionId)); + }else{ + if(ConfigClient.ModernGuiSystem) { + CustomNpcs.proxy.openGui(player, new GuiModernDialogInteract(npc, prevDialog)); + } + else { + CustomNpcs.proxy.openGui(player, new GuiDialogInteract(npc, prevDialog)); + } + } + + } + } + + private void closed() { + grabMouse(false); + PacketClient.sendClient(new CheckPlayerValue(CheckPlayerValue.Type.CheckQuestCompletion)); + } + + public void save() { + + } + + private void calculateRowHeight() { + totalRows = 0; + for (TextBlockClient block : lineBlocks) { + totalRows += block.lines.size() + 1; + } + } + + public void drawTextBlock(String text, int x, int y, int width, int color) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + + int count = 0; + for (Iterator var9 = block.lines.iterator(); var9.hasNext(); count++) { + IChatComponent line = (IChatComponent) var9.next(); + int height = y + count * ClientProxy.Font.height(); + drawCenteredString(fontRendererObj, line.getFormattedText(), x + width / 2, height, color); + } + } + public void drawLeftAllignedTextBlock(String text, int x, int y, int width, int color) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + + int count = 0; + for (Iterator var9 = block.lines.iterator(); var9.hasNext(); count++) { + IChatComponent line = (IChatComponent) var9.next(); + int height = y + count * ClientProxy.Font.height(); + drawString(fontRendererObj, line.getFormattedText(), x, height, color); + } + } + + public void drawCenteredString(FontRenderer p_73732_1_, String p_73732_2_, int p_73732_3_, int p_73732_4_, int p_73732_5_) { + ClientProxy.Font.drawString(p_73732_2_, p_73732_3_ - ClientProxy.Font.width(p_73732_2_) / 2, p_73732_4_, p_73732_5_); + } + + public int getLineCount(String text, int width) { + TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc); + return block.lines.size(); + } + + @Override + public void setClose(int i, NBTTagCompound data) { + grabMouse(false); + } +} diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java b/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java index 4ee005dd7..cf246292b 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiTexturedButton.java @@ -8,6 +8,8 @@ import net.minecraft.client.renderer.texture.ITextureObject; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.resources.IResource; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import noppes.npcs.client.ClientProxy; import noppes.npcs.client.ImageDownloadAlt; import noppes.npcs.client.renderer.ImageBufferDownloadAlt; import org.lwjgl.opengl.GL11; @@ -49,7 +51,7 @@ public class GuiTexturedButton extends GuiNpcButton { super(buttonId, x, y, width, height, buttonText); this.textureX = textureX; this.textureY = textureY; - this.label = buttonText; + this.label = StatCollector.translateToLocal(buttonText); this.scale = 1.0F; this.color = 0xFFFFFF; this.alpha = 1.0F; @@ -91,7 +93,8 @@ public class GuiTexturedButton extends GuiNpcButton { mc.getTextureManager().bindTexture(this.location); this.drawTexturedModalRect(0, 0, this.textureX, this.textureY, this.width, this.height); GL11.glTranslated(0.0D, 0.0D, 0.1D); - this.drawCenteredString(mc.fontRenderer, this.label, this.width / 2, (this.height - 8) / 2, this.color); + this.drawCenteredString(mc.fontRenderer, this.label, (int) (this.xPosition + ((float)this.width)*scale / 2f), + (int) (this.yPosition+(((float)this.height)*scale- ClientProxy.Font.height()+4) / 2f), this.color); } else { FontRenderer fontrenderer = mc.fontRenderer; mc.getTextureManager().bindTexture(buttonTextures); @@ -156,8 +159,14 @@ public class GuiTexturedButton extends GuiNpcButton { } @Override - public boolean mousePressed(Minecraft minecraft, int i, int j) { - return super.mousePressed(minecraft, i, j) || this.field_146123_n; + public boolean mousePressed(Minecraft minecraft, int i, int j) + { + boolean bo = this.enabled && this.visible && i >= this.xPosition && j >= this.yPosition + && i < this.xPosition + this.width*scale && j < this.yPosition + this.height*scale; + if(bo && display != null && display.length != 0){ + setDisplay((getValue()+1) % display.length); + } + return bo; } public void getWidthHeight() throws IOException { diff --git a/src/main/java/noppes/npcs/config/ConfigClient.java b/src/main/java/noppes/npcs/config/ConfigClient.java index c24a2e301..c83175a3b 100644 --- a/src/main/java/noppes/npcs/config/ConfigClient.java +++ b/src/main/java/noppes/npcs/config/ConfigClient.java @@ -49,6 +49,9 @@ public class ConfigClient { public static Property HideEffectsBarProperty; public static boolean HideEffectsBar = false; + public static Property ModernGuiSystemProperty; + public static boolean ModernGuiSystem = true; + /** * Questing Properties **/ @@ -222,6 +225,9 @@ public class ConfigClient { BannerAlertsProperty = config.get(VISUAL, "All Banner Alerts", true, "Universal enable/disable for Banner Alerts"); BannerAlerts = BannerAlertsProperty.getBoolean(true); + ModernGuiSystemProperty = config.get(VISUAL, "Modern GUI", true, "Enables the new CNPC+ Modern GUI for Dialog and Quest information"); + ModernGuiSystem = ModernGuiSystemProperty.getBoolean(true); + WoodTextures = config.get(TEXTURE, "Wood Textures", false, "Models like Chairs and Stools will use default MC Wood Textures").getBoolean(false); LegacyCampfire = config.get(MODEL, "Legacy Campfire Model", false).getBoolean(false); diff --git a/src/main/java/noppes/npcs/controllers/data/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java index ebb18c11c..884822098 100644 --- a/src/main/java/noppes/npcs/controllers/data/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -23,6 +23,7 @@ public class Dialog implements ICompatibilty, IDialog { public String text = ""; public int quest = -1; public DialogCategory category; + public DialogColorData colorData = new DialogColorData(); public HashMap options = new HashMap(); public Availability availability = new Availability(); public FactionOptions factionOptions = new FactionOptions(); @@ -167,6 +168,7 @@ public class Dialog implements ICompatibilty, IDialog { availability.readFromNBT(compound); factionOptions.readFromNBT(compound); + colorData.readFromNBT(compound); } @@ -202,6 +204,7 @@ public class Dialog implements ICompatibilty, IDialog { availability.writeToNBT(compound); factionOptions.writeToNBT(compound); + colorData.writeToNBT(compound); compound.setInteger("ModRev", version); compound.setInteger("Color", color); @@ -284,6 +287,7 @@ public class Dialog implements ICompatibilty, IDialog { dialog.npcOffsetX = npcOffsetX; dialog.npcOffsetY = npcOffsetY; dialog.dialogImages = dialogImages; + dialog.colorData = colorData; for (int slot : options.keySet()) { DialogOption option = options.get(slot); diff --git a/src/main/java/noppes/npcs/controllers/data/DialogColorData.java b/src/main/java/noppes/npcs/controllers/data/DialogColorData.java new file mode 100644 index 000000000..86c45e037 --- /dev/null +++ b/src/main/java/noppes/npcs/controllers/data/DialogColorData.java @@ -0,0 +1,94 @@ +package noppes.npcs.controllers.data; + +import net.minecraft.nbt.NBTTagCompound; + +public class DialogColorData { + private boolean enableColorSettings = false; + private int lineColor1 = 0xff8d3800; + private int lineColor2 = 0xfffea53b; + private int lineColor3 = 0xff8d3800; + private int slotColor = 0xfff96605; + private int buttonAcceptColor = 0xfff96605; + private int buttonRejectColor = 0xfff96605; + + public NBTTagCompound writeToNBT(NBTTagCompound compound) { + compound.setBoolean("ColorSettings", enableColorSettings); + if(enableColorSettings){ + compound.setInteger("LineColor1", lineColor1); + compound.setInteger("LineColor2", lineColor2); + compound.setInteger("LineColor3", lineColor3); + compound.setInteger("SlotColor", slotColor); + compound.setInteger("ButtonAcceptColor", buttonAcceptColor); + compound.setInteger("ButtonRejectColor", buttonRejectColor); + } + return compound; + } + + public void readFromNBT(NBTTagCompound compound) { + this.enableColorSettings = compound.getBoolean("ColorSettings"); + if(enableColorSettings){ + lineColor1 =compound.getInteger("LineColor1"); + lineColor2 =compound.getInteger("LineColor2"); + lineColor3 =compound.getInteger("LineColor3"); + slotColor =compound.getInteger("SlotColor"); + buttonAcceptColor =compound.getInteger("ButtonAcceptColor"); + buttonRejectColor =compound.getInteger("ButtonRejectColor"); + } + } + + public boolean getEnableColorSettings() { + return enableColorSettings; + } + + public void setEnableColorSettings(boolean enableColorSettings) { + this.enableColorSettings = enableColorSettings; + } + + public int getLineColor1() { + return lineColor1; + } + + public void setLineColor1(int lineColour1) { + this.lineColor1 = lineColour1; + } + + public int getLineColor2() { + return lineColor2; + } + + public void setLineColor2(int lineColour2) { + this.lineColor2 = lineColour2; + } + + public int getLineColor3() { + return lineColor3; + } + + public void setLineColor3(int lineColour3) { + this.lineColor3 = lineColour3; + } + + public int getSlotColor() { + return slotColor; + } + + public void setSlotColor(int slotColour) { + this.slotColor = slotColour; + } + + public int getButtonAcceptColor() { + return buttonAcceptColor; + } + + public void setButtonAcceptColor(int buttonAcceptColour) { + this.buttonAcceptColor = buttonAcceptColour; + } + + public int getButtonRejectColor() { + return buttonRejectColor; + } + + public void setButtonRejectColor(int buttonRejectColour) { + this.buttonRejectColor = buttonRejectColour; + } +} diff --git a/src/main/resources/assets/customnpcs/lang/en_US.lang b/src/main/resources/assets/customnpcs/lang/en_US.lang index d54546377..b291d8053 100644 --- a/src/main/resources/assets/customnpcs/lang/en_US.lang +++ b/src/main/resources/assets/customnpcs/lang/en_US.lang @@ -155,6 +155,24 @@ gui.create=Create gui.rename=Rename gui.playerMap=Regen PlayerMap +gui.lineColor1=Upper line color +gui.lineColor2=Middle line color +gui.lineColor3=Lower line color +gui.slotColour=Slots color +gui.buttonAcceptColour=Accept button color +gui.buttonRejectColour=Reject button color +questgui.doyouaccept=Do you accept the quest? +questgui.bringitems=Bring items +questgui.readdialog=Read dialog +questgui.killmobs=Kill mobs +questgui.findlocation=Find location +questgui.defeat=Defeat +questgui.objectives=Objectives: +questgui.rewards=Rewards: +questgui.experience=Experience: +questgui.reject=Reject +questgui.accept=Accept + party.accept=Accept party.allowParty=Allow Partying party.createParty=Create Party @@ -656,6 +674,7 @@ dialog.npcScale=NPC Scale dialog.npcOffset=NPC Offset dialog.titleColor=Title Color dialog.titlePos=Title Position +dialog.enableColorSettings=Enable Color Settings quest.quest=Quest quest.active=Active Quest diff --git a/src/main/resources/assets/customnpcs/lang/ru_RU.lang b/src/main/resources/assets/customnpcs/lang/ru_RU.lang index a729216e5..f0f552f84 100644 --- a/src/main/resources/assets/customnpcs/lang/ru_RU.lang +++ b/src/main/resources/assets/customnpcs/lang/ru_RU.lang @@ -997,3 +997,21 @@ markov.gender.female=Женский markov.gender.male=Мужской markov.generate=Сгенерировать +dialog.enableColorSettings=Включить настройки цвета +gui.lineColor1=Цвет верхней линии +gui.lineColor2=Цвет средней линии +gui.lineColor3=Цвет нижней линии +gui.slotColour=Цвет слотов +gui.buttonAcceptColour=Цвет кнопки принятия квеста +gui.buttonRejectColour=Цвет кнопки отклонения квеста +questgui.doyouaccept=Принимаешь задание? +questgui.bringitems=Принести +questgui.readdialog=Прочитать +questgui.killmobs=Убить +questgui.findlocation=Исследовать +questgui.defeat=Зачистить +questgui.objectives=Цели: +questgui.rewards=Награды: +questgui.experience=Опыт: +questgui.reject=Отменить +questgui.accept=Принять diff --git a/src/main/resources/assets/customnpcs/shaders/post/blur.json b/src/main/resources/assets/customnpcs/shaders/post/blur.json new file mode 100644 index 000000000..a6be10f40 --- /dev/null +++ b/src/main/resources/assets/customnpcs/shaders/post/blur.json @@ -0,0 +1,87 @@ +{ + "targets": [ + "swap" + ], + "passes": [ + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 1, + 0 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + }, + { + "name": "blur", + "intarget": "swap", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 0, + 1 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + }, + { + "name": "blur", + "intarget": "minecraft:main", + "outtarget": "swap", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 1, + 0 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + }, + { + "name": "blur", + "intarget": "swap", + "outtarget": "minecraft:main", + "uniforms": [ + { + "name": "BlurDir", + "values": [ + 0, + 1 + ] + }, + { + "name": "Radius", + "values": [ + 20 + ] + } + ] + } + ] +} diff --git a/src/main/resources/assets/customnpcs/textures/gui/dialog_menu_decomposed.png b/src/main/resources/assets/customnpcs/textures/gui/dialog_menu_decomposed.png new file mode 100644 index 000000000..96fa4fe9d Binary files /dev/null and b/src/main/resources/assets/customnpcs/textures/gui/dialog_menu_decomposed.png differ