Skip to content

Commit

Permalink
修改模型切换界面和下载界面
Browse files Browse the repository at this point in the history
- 添加翻页按钮,方便手机玩家
  • Loading branch information
TartaricAcid committed Oct 25, 2023
1 parent e7f3fde commit 5f211e2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -93,6 +94,13 @@ protected void init() {
}));
}

this.addRenderableWidget(new ImageButton(startX + 194 - 21, startY + 1, 8, 10, 128, 224, 10, BG, 484, 256, b -> {
this.mouseScrolled(0, 0, 1);
}));
this.addRenderableWidget(new ImageButton(startX + 194 - 21, startY + 2 + 175, 8, 10, 136, 224, 10, BG, 484, 256, b -> {
this.mouseScrolled(0, 0, -1);
}));

this.addRenderableWidget(Button.builder(Component.translatable("spectatorMenu.close"), b -> {
if (minecraft != null) {
minecraft.setScreen(null);
Expand All @@ -111,7 +119,7 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTi
graphics.drawCenteredString(font, Component.translatable("gui.touhou_little_maid.resources_download.fail.2"), this.width / 2, this.height / 2, 0xfffff);
} else {
graphics.blit(BG, middleX - 200, middleY - 85, 0, 0, 400, 200, 484, 256);
graphics.blit(BG, middleX - 19, middleY - 77 + (int) (169 * scroll), 400, 0, 4, 15, 484, 256);
graphics.blit(BG, middleX - 19, middleY - 66 + (int) (147 * scroll), 400, 0, 4, 15, 484, 256);
for (int i = 0; i < 4; i++) {
graphics.blit(BG, middleX - 196 + (28 * i), middleY - 110, 456, 194, 28, 25, 484, 256);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public void init() {

// 添加切换模型的按钮
addModelButton(startX, startY);

// 模型包翻页
addScrollButton(startX, startY);
}

private void addModelButton(int startX, int startY) {
Expand Down Expand Up @@ -147,6 +150,25 @@ private void addModelButton(int startX, int startY) {
}
}

private void addScrollButton(int startX, int startY) {
ImageButton upButton = new ImageButton(startX - 256 / 2 + 253, startY - 73, 14, 10, 24, 15, 10, SIDE, b -> {
int row = Mth.clamp(getRowIndex() - 1, 0, guiNumber.getRowSize(getPackIndex()));
if (row != getRowIndex()) {
setRowIndex(row);
this.init();
}
});
Button downButton = new ImageButton(startX - 256 / 2 + 253, startY - 73 + 156, 14, 10, 38, 15, 10, SIDE, b -> {
int row = Mth.clamp(getRowIndex() + 1, 0, guiNumber.getRowSize(getPackIndex()));
if (row != getRowIndex()) {
setRowIndex(row);
this.init();
}
});
this.addRenderableWidget(upButton);
this.addRenderableWidget(downButton);
}

private Button.OnPress onModelButtonClick(E modelItem) {
return (button) -> {
if (hasShiftDown()) {
Expand Down Expand Up @@ -244,11 +266,11 @@ private void drawButton(GuiGraphics graphics, int mouseX, int mouseY, float part
private void drawScrollSide(GuiGraphics graphics, int middleX, int middleY) {
if (guiNumber.canScroll(getPackIndex(), getRowIndex())) {
graphics.blit(SIDE, middleX - 256 / 2 + 254,
middleY - 72 + (int) (149 * guiNumber.getCurrentScroll(getPackIndex(), getRowIndex())),
middleY - 61 + (int) (127 * guiNumber.getCurrentScroll(getPackIndex(), getRowIndex())),
24, 0, 12, 15);
} else {
graphics.blit(SIDE, middleX - 256 / 2 + 254,
middleY - 72 + (int) (149 * guiNumber.getCurrentScroll(getPackIndex(), getRowIndex())),
middleY - 61 + (int) (127 * guiNumber.getCurrentScroll(getPackIndex(), getRowIndex())),
36, 0, 12, 15);
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5f211e2

Please sign in to comment.