Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/noppes/npcs/CustomNpcs.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public static <T, E> void setPrivateValue(final Class<? super T> classToAccess,
CustomNpcs.EnableChatBubbles = true;
CustomNpcs.NpcNavRange = 32;
CustomNpcs.NpcNaturalSpawningChunkLimit = 4;
CustomNpcs.NpcUseOpCommands = false;
CustomNpcs.NpcUseOpCommands = true;
CustomNpcs.NoppesCommandOpOnly = false;
CustomNpcs.InventoryGuiEnabled = true;
CustomNpcs.FixUpdateFromPre_1_12 = false;
Expand All @@ -333,12 +333,12 @@ public static <T, E> void setPrivateValue(final Class<? super T> classToAccess,
CustomNpcs.SoulStoneAnimals = true;
CustomNpcs.SoulStoneNPCs = false;
CustomNpcs.HeadWearType = 1;
CustomNpcs.FontType = "Default";
CustomNpcs.FontType = "Minecraft";
CustomNpcs.FontSize = 18;
CustomNpcs.EnableInvisibleNpcs = true;
CustomNpcs.NpcSpeachTriggersChatEvent = false;
CustomNpcs.VerboseDebug = false;
CustomNpcs.EnabledForgeEventPackages = "net.minecraftforge.event";
CustomNpcs.EnableNewDialogSystem = false;
CustomNpcs.EnableNewDialogSystem = true;
}
}
13 changes: 13 additions & 0 deletions src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
private String[] tacts;
private DataAI ai;

private boolean useCenteredText = false;

public GuiNpcAI(final EntityNPCInterface npc) {
super(npc, 3);
this.tacts = new String[] { "aitactics.rush", "aitactics.stagger", "aitactics.orbit", "aitactics.hitandrun", "aitactics.ambush", "aitactics.stalk", "gui.none" };
Expand Down Expand Up @@ -52,10 +54,15 @@ public void init() {
this.addLabel(new GuiLabel(2, "ai.movement", this.guiLeft + 4, this.guiTop + 165));
this.addButton(new GuiButtonNop(this, 2, this.guiLeft + 86, this.guiTop + 160, 60, 20, "selectServer.edit"));

this.addLabel(new GuiLabel(27, "Texto Centrado", this.guiLeft + 150, this.guiTop + 120));
this.addButton(new GuiButtonNop(this, 27, this.guiLeft + 230, this.guiTop + 120, 60, 20, new String[] { "gui.no", "gui.yes" }, npc.ais.textoCentrado ? 1 : 0));
this.useCenteredText = npc.ais.textoCentrado;

this.addLabel(new GuiLabel(25, "Mount Control", this.guiLeft + 150, this.guiTop + 90));
this.addButton(new GuiButtonNop(this, 16, this.guiLeft + 230, this.guiTop + 85, 60, 20, new String[] { "gui.no", "gui.yes" }, (int)(this.npc.ais.mountControl ? 1 : 0)));
// this.addLabel(new GuiLabel(26, "ai.lookattarget", this.guiLeft + 150, this.guiTop + 115));
// this.addButton(new GuiButtonNop(this, 17, this.guiLeft + 230, this.guiTop + 110, 60, 20, new String[] { "gui.no", "gui.yes" }, (int)(this.npc.ais.lookAtTarget ? 1 : 0)));

}

@Override
Expand Down Expand Up @@ -102,6 +109,12 @@ else if (button.id == 16) {
else if (button.id == 17) {
this.ai.lookAtTarget = (button.getValue() == 1);
}
else if (button.id == 27) {
this.useCenteredText = (button.getValue() == 1);
this.npc.ais.textoCentrado = this.useCenteredText; // Actualiza el estado en el modelo de datos
save(); // Guarda los cambios
this.init(); // Actualiza la interfaz para reflejar el estado actualizado
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package noppes.npcs.client.gui.player;

import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.text.ITextComponent;
import noppes.npcs.api.handler.data.IQuest;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.TextBlockClient;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.packets.Packets;
import noppes.npcs.packets.server.SPacketQuestCompletionCheck;
import noppes.npcs.shared.client.gui.components.GuiButtonNop;
import noppes.npcs.shared.client.gui.components.GuiLabel;
import noppes.npcs.shared.client.gui.listeners.IGuiInterface;
import noppes.npcs.shared.client.gui.listeners.ITopButtonListener;

public class GuiQuestCompletion extends GuiNPCInterface implements ITopButtonListener {
private IQuest quest;

public GuiQuestCompletion(IQuest quest) {
super();
this.imageWidth = 300;
this.imageHeight = 170;
this.quest = quest;
this.drawDefaultBackground = false;
this.title = "";
this.closeOnEsc = false;
}

@Override
public void init() {
super.init();
String questTitle = I18n.get(this.quest.getName());
int left = (this.imageWidth - this.font.width(questTitle)) / 2;
addLabel(new GuiLabel(0, questTitle, this.guiLeft + left, this.guiTop + 4, 0xFFFFFFFF));
addButton(new GuiButtonNop((IGuiInterface) this, 0, this.guiLeft + 178, this.guiTop + this.imageHeight - 24, 100, 20, I18n.get("gui.done")));
}

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
renderBackground(matrixStack);
drawBackground(matrixStack); // Dibuja el fondo semitransparente limitado al área específica
drawQuestText(matrixStack);
super.render(matrixStack, mouseX, mouseY, partialTicks); // Renderiza los botones y otros elementos de interfaz
}

private void drawQuestText(MatrixStack matrixStack) {
TextBlockClient block = new TextBlockClient(this.quest.getCompleteText(), 272, true, this.player);
int yoffset = this.guiTop + 20;
for (int i = 0; i < block.lines.size(); i++) {
ITextComponent line = block.lines.get(i);
this.font.draw(matrixStack, line, this.guiLeft + 4, this.guiTop + 16 + i * 9, 0xFFFFFFFF);
}
}

@Override
public void buttonEvent(GuiButtonNop guibutton) {
if (guibutton.id == 0) {
Packets.sendServer(new SPacketQuestCompletionCheck(this.quest.getId()));
close();
}
}

@Override
public void save() {}

@Override
public void renderBackground(MatrixStack matrixStack) {
// No dibuja el fondo semitransparente por defecto, ya que se controlará en drawBackground()
}

private void drawBackground(MatrixStack matrixStack) {
int xStart = (this.width - this.imageWidth) / 2;
int yStart = (this.height - this.imageHeight) / 2;
fill(matrixStack, xStart, yStart, xStart + this.imageWidth, yStart + this.imageHeight, 0xBB000000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,22 @@ public class GuiDialogModern extends GuiNPCInterface implements IGuiClose {
private final ResourceLocation decomposed = new ResourceLocation("customnpcs", "textures/gui/dialog_menu_decomposed.png");
private boolean isGrabbed = false;

private boolean useCenteredText = false;

public GuiDialogModern(EntityNPCInterface npc, Dialog dialog) {
super(npc);
this.dialog = dialog;
this.appendDialog(dialog);
this.imageHeight = 238;
this.useCenteredText = npc.ais.textoCentrado;
}

public void init() {
super.init();
this.isGrabbed = false;
this.grabMouse(this.dialog.showWheel);
this.guiTop = this.height - this.imageHeight;
this.useCenteredText = this.npc.ais.textoCentrado;
}

public void grabMouse(boolean grab) {
Expand Down Expand Up @@ -87,7 +91,8 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partia
drawNpc(npc, -210 + (int) (300 * (1 - wcoeff)), 350 - (int) (100 * (1 - hcoeff)), (float) (9.5F * hcoeff), -20);
}
}
int textBlockWidth = 700;
int screenWidth = this.width; // Obtén el ancho de la pantalla
int textBlockWidth = (int) (screenWidth * 0.7); // Ajusta el ancho del cuadro de texto al 70% del ancho de la pantalla
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(null) + 2 * gap;
Expand All @@ -98,30 +103,53 @@ public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partia
matrixStack.scale(1.5f, 1.5f, 1);
AbstractGui.drawString(matrixStack, font, npc.getDisplayName(), (int) (47 / 1.5), (int) ((height - textPartHeight + 5) / 1.5), -1);
matrixStack.scale(1 / 1.5f, 1 / 1.5f, 1);
drawTextBlock(matrixStack, dialog.text, (width - textBlockWidth) / 2, height - textPartHeight + 23 + 3 + gap, textBlockWidth);
int textX = (width - textBlockWidth) / 2; // Centra el texto horizontalmente
int textY = height - textPartHeight + 23 + 3 + gap; //auto escalado de temaño de interfaz
drawTextBlock(matrixStack, dialog.text, textX, textY, textBlockWidth); //auto escalado de temaño de interfaz
selected = -1;
matrixStack.scale((float) wcoeff, (float) wcoeff, (float) wcoeff);
int accumulatedHeight = 0; // Altura acumulada de las opciones anteriores
for (int i = 0; i < this.options.size(); i++) {
int optionHeight = (int) (220 * hcoeff + i * (13 + 6));
int optionNum = options.get(i);
DialogOption option = dialog.options.get(optionNum);
int optionHeight = (int) (220 * hcoeff + accumulatedHeight);

// Calcular el ancho máximo necesario para todas las líneas del título
String[] titleLines = option.title.split("\\\\n");
int optionWidth = 0;
for (String line : titleLines) {
int lineWidth = this.font.width(line);
optionWidth = Math.max(optionWidth, lineWidth);
}
optionWidth += 32; // Ajustar según necesidades visuales

if (mouseX >= 723 * wcoeff && mouseX <= 946 * wcoeff && mouseY >= optionHeight * wcoeff && mouseY <= (optionHeight + 13) * wcoeff) {
selected = i;
}
RenderSystem.enableBlend();
this.minecraft.getTextureManager().bind(decomposed);
this.blit(matrixStack, 723, optionHeight, 0, i == selected ? 13 : 0, 223, 13);
this.blit(matrixStack, 723, optionHeight, 0, i == selected ? 13 : 0, optionWidth, 13);
RenderSystem.disableBlend();
if (getQuestByOptionId(optionNum) != null) {
drawString(matrixStack, this.font, "!", 727, optionHeight + 3, 0x76e85b);
} else {
drawString(matrixStack, this.font, ">", 727, optionHeight + 3, -1);
}
drawString(matrixStack, this.font, option.title, 735, optionHeight + 3, option.optionColor);

// Renderizar cada línea del título
int lineOffset = 0;
for (String line : titleLines) {
if (!line.isEmpty()) {
drawString(matrixStack, this.font, line, 735, optionHeight + 3 + lineOffset, option.optionColor);
lineOffset += 12; // Ajustar según el tamaño de fuente y el espaciado deseado
}
}
accumulatedHeight += 13 + 6 + lineOffset;
}
matrixStack.popPose();
}


public Quest getQuestByOptionId(int id) {
DialogOption option = dialog.options.get(id);
if (option != null && option.getDialog() != null && option.getDialog().hasQuest()) {
Expand Down Expand Up @@ -261,18 +289,30 @@ private void closed() {
this.grabMouse(false);
Packets.sendServer(new SPacketQuestCompletionCheckAll());
}
// Método para manejar el evento de un botón u otro evento que cambie la configuración

public void toggleTextAlignment() {
useCenteredText = !useCenteredText;
npc.ais.textoCentrado = useCenteredText;
}

public void drawTextBlock(MatrixStack stack, String text, int x, int y, int width) {
TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc);

int count = 0;
for (Iterator<ITextComponent> var9 = block.lines.iterator(); var9.hasNext(); count++) {
ITextComponent line = var9.next();
for (Iterator<ITextComponent> iterator = block.lines.iterator(); iterator.hasNext(); count++) {
ITextComponent line = iterator.next();
int height = y + count * ClientProxy.Font.height(null);
AbstractGui.drawCenteredString(stack, font, line, x + width / 2, height, -1);

if (useCenteredText) {
AbstractGui.drawCenteredString(stack, font, line, x + width / 2, height, -1);
} else {
AbstractGui.drawString(stack, font, line, x, height, -1);
}
}
}


public int getLineCount(String text, int width) {
TextBlockClient block = new TextBlockClient("", text, width, -1, player, npc);
return block.lines.size();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/noppes/npcs/entity/EntityNPCInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,7 @@ public CompoundNBT writeSpawnData() {
compound.put("Weapons", NBTTags.nbtIItemStackMap(this.inventory.weapons));
compound.putInt("Speed", this.ais.getWalkingSpeed());
compound.putBoolean("MountControl", this.ais.mountControl);
compound.putBoolean("TextoCentrado", this.ais.textoCentrado);
compound.putBoolean("DeadBody", this.stats.hideKilledBody);
compound.putInt("StandingState", this.ais.getStandingType());
compound.putInt("MovingState", this.ais.getMovingType());
Expand Down Expand Up @@ -1539,6 +1540,7 @@ public void readSpawnData(CompoundNBT compound) {
this.stats.hideKilledBody = compound.getBoolean("DeadBody");
this.ais.setStandingType(compound.getInt("StandingState"));
this.ais.mountControl = compound.getBoolean("MountControl");
this.ais.textoCentrado = compound.getBoolean("TextoCentrado");
this.ais.setMovingType(compound.getInt("MovingState"));
this.ais.orientation = compound.getInt("Orientation");
this.ais.bodyOffsetX = compound.getFloat("PositionXOffset");
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/noppes/npcs/entity/data/DataAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class DataAI implements INPCAi {
public int movingPattern;
public boolean movingPause;

public boolean textoCentrado;

public boolean mountControl;

public boolean lookAtTarget;
Expand Down Expand Up @@ -85,6 +87,7 @@ public DataAI(final EntityNPCInterface npc) {
this.movingPattern = 0;
this.movingPause = true;
this.mountControl = false;
this.textoCentrado = false;
this.lookAtTarget = false;
this.npc = npc;
}
Expand Down Expand Up @@ -123,6 +126,7 @@ public void readToNBT(final CompoundNBT compound) {
this.setStartPos(new BlockPos(startPos[0], startPos[1], startPos[2]));
}
this.mountControl = compound.getBoolean("MountControl");
this.textoCentrado = compound.getBoolean("TextoCentrado");
this.lookAtTarget = compound.getBoolean("LookAtTarget");
}

Expand Down Expand Up @@ -158,6 +162,7 @@ public CompoundNBT save(final CompoundNBT compound) {
compound.putIntArray("StartPosNew", this.getStartArray());
compound.putBoolean("AttackInvisible", this.attackInvisible);
compound.putBoolean("MountControl", this.mountControl);
compound.putBoolean("TextoCentrado", this.textoCentrado);
compound.putBoolean("LookAtTarget", this.lookAtTarget);
return compound;
}
Expand Down
Loading