|
|
|
@ -19,7 +19,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
package de.steamwar.advancedscripts.screen;
|
|
|
|
package de.steamwar.advancedscripts.screen;
|
|
|
|
|
|
|
|
|
|
|
|
import com.mojang.blaze3d.buffers.GpuBufferSlice;
|
|
|
|
|
|
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
|
|
|
import com.mojang.blaze3d.systems.RenderSystem;
|
|
|
|
import de.steamwar.advancedscripts.lexer.ScriptColorizer;
|
|
|
|
import de.steamwar.advancedscripts.lexer.ScriptColorizer;
|
|
|
|
import de.steamwar.advancedscripts.lexer.Token;
|
|
|
|
import de.steamwar.advancedscripts.lexer.Token;
|
|
|
|
@ -74,7 +73,7 @@ public class ScriptEditScreen extends Screen {
|
|
|
|
this.itemStack = itemStack;
|
|
|
|
this.itemStack = itemStack;
|
|
|
|
this.hand = hand;
|
|
|
|
this.hand = hand;
|
|
|
|
|
|
|
|
|
|
|
|
List<RawFilteredPair<String>> pages = itemStack.get(DataComponentTypes.WRITABLE_BOOK_CONTENT).pages();
|
|
|
|
List<RawFilteredPair<String>> pages = itemStack.getComponents().get(DataComponentTypes.WRITABLE_BOOK_CONTENT).pages();
|
|
|
|
pages.forEach(stringRawFilteredPair -> {
|
|
|
|
pages.forEach(stringRawFilteredPair -> {
|
|
|
|
for (String s : stringRawFilteredPair.raw().split("\n")) {
|
|
|
|
for (String s : stringRawFilteredPair.raw().split("\n")) {
|
|
|
|
if (s.isEmpty()) {
|
|
|
|
if (s.isEmpty()) {
|
|
|
|
@ -104,7 +103,7 @@ public class ScriptEditScreen extends Screen {
|
|
|
|
this.addDrawableChild(
|
|
|
|
this.addDrawableChild(
|
|
|
|
new Button(BOOK, this.width - 98 - 5, height - 20 - 5, () -> {
|
|
|
|
new Button(BOOK, this.width - 98 - 5, height - 20 - 5, () -> {
|
|
|
|
finalizeBook();
|
|
|
|
finalizeBook();
|
|
|
|
this.client.setScreen(new BookEditScreen(player, itemStack, hand, toContent(toPages())));
|
|
|
|
this.client.setScreen(new BookEditScreen(player, itemStack, hand));
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -157,9 +156,15 @@ public class ScriptEditScreen extends Screen {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void applyBlur(float delta) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
|
|
|
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
|
|
|
setFocused(null);
|
|
|
|
setFocused(null);
|
|
|
|
|
|
|
|
this.renderBackground(context, mouseX, mouseY, delta);
|
|
|
|
|
|
|
|
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
context.fill(23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND);
|
|
|
|
context.fill(23, 23, this.width - 23, this.height - 63, TokenTypeColors.BACKGROUND);
|
|
|
|
|
|
|
|
|
|
|
|
int lineNumberLength = textRenderer.getWidth(lines.size() + "");
|
|
|
|
int lineNumberLength = textRenderer.getWidth(lines.size() + "");
|
|
|
|
@ -189,7 +194,7 @@ public class ScriptEditScreen extends Screen {
|
|
|
|
if (lineTooLong(s)) {
|
|
|
|
if (lineTooLong(s)) {
|
|
|
|
context.fill(25 + lineNumberLength + 2, 25 + lineNumber.getValue() * 9, 25 + lineNumberLength + 3, 25 + lineNumber.getValue() * 9 + height, TokenTypeColors.ERROR);
|
|
|
|
context.fill(25 + lineNumberLength + 2, 25 + lineNumber.getValue() * 9, 25 + lineNumberLength + 3, 25 + lineNumber.getValue() * 9 + height, TokenTypeColors.ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
context.drawText(textRenderer, String.valueOf(lineNumberText), (int) (25f + lineNumberLength - textRenderer.getWidth(String.valueOf(lineNumberText))), (int) (25f + lineNumber.getValue() * 9f), 0xFFFFFFFF, false);
|
|
|
|
context.drawText(textRenderer, String.valueOf(lineNumberText), (int) (25f + lineNumberLength - textRenderer.getWidth(String.valueOf(lineNumberText))), (int) (25f + lineNumber.getValue() * 9f), 0xFFFFFF, false);
|
|
|
|
lineNumberText++;
|
|
|
|
lineNumberText++;
|
|
|
|
|
|
|
|
|
|
|
|
// Line text
|
|
|
|
// Line text
|
|
|
|
@ -629,7 +634,7 @@ public class ScriptEditScreen extends Screen {
|
|
|
|
private void finalizeBook() {
|
|
|
|
private void finalizeBook() {
|
|
|
|
List<String> pages = toPages();
|
|
|
|
List<String> pages = toPages();
|
|
|
|
this.writeNbtData(pages);
|
|
|
|
this.writeNbtData(pages);
|
|
|
|
int i = this.hand == Hand.MAIN_HAND ? this.player.getInventory().getSelectedSlot() : 40;
|
|
|
|
int i = this.hand == Hand.MAIN_HAND ? this.player.getInventory().selectedSlot : 40;
|
|
|
|
this.client.getNetworkHandler().sendPacket(new BookUpdateC2SPacket(i, pages, Optional.empty()));
|
|
|
|
this.client.getNetworkHandler().sendPacket(new BookUpdateC2SPacket(i, pages, Optional.empty()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|