Skip to content
This repository was archived by the owner on Jun 19, 2026. It is now read-only.
Merged
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
29 changes: 0 additions & 29 deletions src/main/java/cn/pupperclient/PupperClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import cn.pupperclient.management.profile.ProfileManager;
import cn.pupperclient.management.websocket.WebSocketManager;
import cn.pupperclient.skia.font.Fonts;
import cn.pupperclient.utils.system.ExternalToolManager;
import cn.pupperclient.utils.minecraft.interfaces.IMinecraft;
import cn.pupperclient.utils.thread.Multithreading;
import cn.pupperclient.utils.file.FileLocation;
Expand Down Expand Up @@ -44,8 +43,6 @@ public class PupperClient implements IMinecraft {
public static final Logger LOGGER = PupperLogger.getLogger();

private final ViaFabricPlusBase viaPlatform = ViaFabricPlus.getImpl();
private ExternalToolManager toolManager;
private MusicToolStatus musicToolStatus = MusicToolStatus.CHECKING;
private long launchTime;

private ModManager modManager;
Expand Down Expand Up @@ -95,7 +92,6 @@ private void initializeManagers() {
hypixelManager = new HypixelManager();
keybindManager = KeybindManager.getInstance();
keybindManager.initialize();
toolManager = new ExternalToolManager();
PupperCommand.register();
capeManager = new CapeManager();
}
Expand All @@ -115,11 +111,6 @@ private void handleFirstLaunch() throws IOException {
firstLaunch = true;
createConfigFile(configFile);
}

if (!firstLaunch) {
setMusicToolStatus(MusicToolStatus.DONE);
}

registerTermsScreenCheck();
}

Expand Down Expand Up @@ -210,27 +201,7 @@ public void setProtocolVersion(ProtocolVersion version) {
viaPlatform.setTargetVersion(version);
}

public ExternalToolManager getToolManager() {
return toolManager;
}

public MusicToolStatus getMusicToolStatus() {
return musicToolStatus;
}

public void setMusicToolStatus(MusicToolStatus status) {
this.musicToolStatus = status;
}

public CapeManager getCapeManager() {
return capeManager;
}

public enum MusicToolStatus {
CHECKING,
INSTALLED,
DOWNLOADING,
FAILED,
DONE
}
}
18 changes: 11 additions & 7 deletions src/main/java/cn/pupperclient/gui/GuiResourcePackConvert.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
Expand All @@ -27,7 +28,7 @@

public class GuiResourcePackConvert extends Screen {

private String progress;
private String progress = "Converting...";
private Screen prevScreen;

public GuiResourcePackConvert(Screen prevScreen) {
Expand Down Expand Up @@ -133,11 +134,14 @@ private List<File> getOldResourcePacks() {
List<File> files = new ArrayList<>();
File packDir = new File(client.runDirectory, "resourcepacks");

for (File f : packDir.listFiles()) {
if (f.getName().endsWith(".zip")) {
files.add(f);
}
}
File[] packFiles = packDir.listFiles();
if (packFiles != null) {
for (File f : packFiles) {
if (f.getName().endsWith(".zip")) {
files.add(f);
}
}
}

return files;
}
Expand All @@ -149,7 +153,7 @@ private static JsonObject readJsonFromZip(ZipInputStream zipIn) throws IOExcepti
while ((len = zipIn.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
String jsonString = baos.toString("UTF-8");
String jsonString = baos.toString(StandardCharsets.UTF_8);
return JsonParser.parseString(jsonString).getAsJsonObject();
}
}
75 changes: 42 additions & 33 deletions src/main/java/cn/pupperclient/gui/MainMenuGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,17 @@
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.screen.world.SelectWorldScreen;
import net.minecraft.client.realms.gui.screen.RealmsMainScreen;
import net.minecraft.client.MinecraftClient;
import ru.vidtu.ias.screen.AccountScreen;

public class MainMenuGui extends SimpleSoarGui {

private final List<MainMenuButton> buttons = new ArrayList<>();
private MainMenuButton settingsButton;
private MainMenuButton backgroundButton;
private float lastWindowWidth = 0;
private float lastWindowHeight = 0;
private boolean wasMinimized = false;
private static boolean showCustomizationWindow = false;
private static boolean showBackgroundWindow = false;
private static Switch darkModeSwitch;
private boolean showCustomizationWindow = false;
private boolean showBackgroundWindow = false;
private Switch darkModeSwitch;
private Button exitCustomizationButton;
private Button exitBackgroundButton;
private IconButton addBackgroundButton;
Expand All @@ -65,9 +63,15 @@ public MainMenuGui() {

@Override
public void init() {
updateLayout();
loadBackgroundSettings();
initCustomizationComponents();
rebuildLayout();
loadExistingBackgrounds();
}

@Override
public void resize(MinecraftClient client, int width, int height) {
super.resize(client, width, height);
rebuildLayout();
}

private void loadBackgroundSettings() {
Expand All @@ -87,7 +91,7 @@ private void saveBackgroundSettings() {
PupperClient.getInstance().getConfigManager().save(ConfigType.MOD);
}

private void updateLayout() {
private void rebuildLayout() {
buttons.clear();

float scaleFactor = calculateScaleFactor();
Expand Down Expand Up @@ -130,12 +134,11 @@ private void updateLayout() {
client.getWindow().getWidth() - buttonSize - (20 * scaleFactor),
20 * scaleFactor, buttonSize - 5, scaleFactor, () -> showCustomizationWindow = true);

lastWindowWidth = client.getWindow().getWidth();
lastWindowHeight = client.getWindow().getHeight();

for (MainMenuButton button : buttons) {
button.setEnabled(true);
}

initCustomizationComponents();
}

private void initCustomizationComponents() {
Expand Down Expand Up @@ -196,8 +199,6 @@ public void onAction() {
});
}
});

loadExistingBackgrounds();
}

private void loadExistingBackgrounds() {
Expand All @@ -206,6 +207,9 @@ private void loadExistingBackgrounds() {
backgroundItems.add(new BackgroundItem("background.png", null, true));

File backgroundDir = FileLocation.BACKGROUND_DIR;
if (!backgroundDir.exists()) {
backgroundDir.mkdirs();
}
if (backgroundDir.exists() && backgroundDir.isDirectory()) {
File[] backgroundFiles = backgroundDir.listFiles((dir, name) ->
name.toLowerCase().endsWith(".png") || name.toLowerCase().endsWith(".jpg"));
Expand All @@ -225,16 +229,16 @@ private void copyBackgroundFile(File selectedFile) {
File targetFile = new File(FileLocation.BACKGROUND_DIR, processedName);

if (targetFile.exists()) {
System.out.println("background file already exists!");
PupperClient.LOGGER.warn("background file already exists: {}", processedName);
return;
}

Files.copy(selectedFile.toPath(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
loadExistingBackgrounds();

// 自动选择新添加的背景
selectedBackgroundId = processedName;
saveBackgroundSettings();
client.execute(() -> {
loadExistingBackgrounds();
selectedBackgroundId = processedName;
saveBackgroundSettings();
});

} catch (IOException e) {
PupperClient.LOGGER.error("Error copying background file: {}", e.getMessage(), e);
Expand Down Expand Up @@ -268,17 +272,7 @@ private float calculateScaleFactor() {

@Override
public void draw(double mouseX, double mouseY) {
boolean currentlyMinimized = isWindowMinimized();

if (client.getWindow().getWidth() != lastWindowWidth ||
client.getWindow().getHeight() != lastWindowHeight ||
wasMinimized != currentlyMinimized) {
updateLayout();
initCustomizationComponents();
wasMinimized = currentlyMinimized;
}

if (currentlyMinimized) {
if (isWindowMinimized()) {
return;
}

Expand Down Expand Up @@ -335,6 +329,8 @@ private void drawBackgroundWindow(double mouseX, double mouseY, ColorPalette pal
float panelX = centerX - panelWidth / 2;
float panelY = centerY - panelHeight / 2;

backgroundScrollHelper.onUpdate();

Skia.drawRect(0, 0, client.getWindow().getWidth(), client.getWindow().getHeight(),
ColorUtils.applyAlpha(palette.getSurface(), 0.3f));

Expand Down Expand Up @@ -382,6 +378,11 @@ private void drawBackgroundWindow(double mouseX, double mouseY, ColorPalette pal
Skia.drawOutline(itemX - 2, itemY - 2, itemWidth + 4, itemHeight + 4, 10, 3, palette.getPrimary());
}

if (!isSelected && isHovered) {
Skia.drawRoundedRect(itemX, itemY, itemWidth, itemHeight, 8,
ColorUtils.applyAlpha(palette.getPrimary(), item.focusAnimation.getValue() * 0.12f));
}

if (item.isDefault) {
Skia.drawRoundedImage("background.png", itemX, itemY, itemWidth, itemHeight, 8);
} else if (item.backgroundFile != null && item.backgroundFile.exists()) {
Expand All @@ -400,7 +401,6 @@ private void drawBackgroundWindow(double mouseX, double mouseY, ColorPalette pal
}

private void drawCustomBackground() {
// 计算视差效果
float parallaxStrength = 40;
float targetParallaxX = (float) (client.mouse.getX() - client.getWindow().getWidth() / 2F) / client.getWindow().getWidth() * parallaxStrength;
float targetParallaxY = (float) (client.mouse.getY() - client.getWindow().getHeight() / 2F) / client.getWindow().getHeight() * parallaxStrength;
Expand Down Expand Up @@ -442,6 +442,15 @@ private void drawLogoIcon() {
Skia.drawRoundedImage("logo.png", logoX, logoY, logoSize, logoSize, 10 * scaleFactor);
}

@Override
public boolean onMouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount) {
if (showBackgroundWindow) {
backgroundScrollHelper.onScroll(verticalAmount);
return true;
}
return super.onMouseScrolled(mouseX, mouseY, horizontalAmount, verticalAmount);
}

@Override
public boolean onMousePressed(double mouseX, double mouseY, int button) {
if (isWindowMinimized()) {
Expand Down Expand Up @@ -471,7 +480,7 @@ public boolean onMousePressed(double mouseX, double mouseY, int button) {

if (MouseUtils.isInside(mouseX, adjustedMouseY, itemX, itemY, itemWidth, itemHeight)) {
selectedBackgroundId = item.backgroundId;
saveBackgroundSettings(); // 保存新选择的背景
saveBackgroundSettings();
break;
}
}
Expand Down
Loading
Loading