Skip to content
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
5 changes: 0 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ loom {
repositories {
mavenCentral()
maven("https://maven.spiritstudios.dev/releases/")
maven("https://maven.bawnorton.com/releases")
maven("https://moehreag.duckdns.org/maven/releases") {
content {
includeGroup("io.github.axolotlclient.AxolotlClient")
Expand All @@ -51,10 +50,6 @@ dependencies {
modImplementation(libs.bundles.specter)

implementation(libs.objc.bridge)

include("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.3")
implementation("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.3")
annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.3.3")
}

tasks.processResources {
Expand Down
5 changes: 1 addition & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel=true

mod.version = 1.1
mod.version = 1.1_215-rc2
mod.group = dev.spiritstudios
mod.id = snapper

deps.minecraft=1.21.4
deps.loader=0.16.5
8 changes: 4 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
fabric_loom = "1.11-SNAPSHOT"
minotaur = "2.+"

minecraft = "1.21.4"
yarn = "1.21.4+build.3"
minecraft = "1.21.5"
yarn = "1.21.5+build.1"

fabric_loader = "0.16.14"
fabric_api = "0.119.3+1.21.4"
fabric_api = "0.128.1+1.21.5"

specter = "1.1.3"
specter = "1.1.7"
objc_bridge = "1.0.0"

[plugins]
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/client/java/dev/spiritstudios/snapper/Snapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import dev.spiritstudios.snapper.util.WindowsActions;
import dev.spiritstudios.snapper.util.config.DirectoryConfigUtil;
import dev.spiritstudios.snapper.util.uploading.ScreenshotUploading;
import dev.spiritstudios.specter.api.config.ConfigScreenWidgets;
import dev.spiritstudios.specter.api.config.ModMenuHelper;
import dev.spiritstudios.specter.api.config.client.ConfigScreenWidgets;
import dev.spiritstudios.specter.api.config.client.ModMenuHelper;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.loader.api.FabricLoader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class SnapperConfig extends Config<SnapperConfig> {
.comment("Whether to show Snapper button in game menu.")
.build();

public final Value<ScreenshotViewerScreen.ViewMode> viewMode = enumValue(ScreenshotViewerScreen.ViewMode.LIST, ScreenshotViewerScreen.ViewMode.class)
public final Value<ScreenshotViewerScreen.ViewMode> viewMode = enumValue(ScreenshotViewerScreen.ViewMode.GRID, ScreenshotViewerScreen.ViewMode.class)
.comment("Whether to show screenshot menu with grid or list.")
.build();

Expand Down
17 changes: 10 additions & 7 deletions src/client/java/dev/spiritstudios/snapper/SnapperKeybindings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dev.spiritstudios.snapper.gui.screen.ScreenshotViewerScreen;
import dev.spiritstudios.snapper.util.ScreenshotActions;
import dev.spiritstudios.snapper.util.ScreenshotImage;
import dev.spiritstudios.specter.api.core.util.ClientKeybindEvents;
import dev.spiritstudios.specter.api.core.client.event.ClientKeybindEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
Expand Down Expand Up @@ -61,7 +61,7 @@ private static void takePanorama(MinecraftClient client) {
}

private static void openRecentScreenshot(MinecraftClient client) {
List<Path> screenshots = ScreenshotActions.getScreenshots(client);
List<Path> screenshots = ScreenshotActions.getScreenshots();
if (screenshots.isEmpty()) {
if (client.player != null)
client.player.sendMessage(Text.translatable("text.snapper.screenshot_not_exists"), true);
Expand All @@ -71,11 +71,14 @@ private static void openRecentScreenshot(MinecraftClient client) {
Path latestPath = screenshots.getFirst();
ScreenshotImage.createScreenshot(client.getTextureManager(), latestPath)
.ifPresentOrElse(
image -> client.setScreen(new ScreenshotViewerScreen(
image,
latestPath,
client.currentScreen
)),
image -> {
client.setScreen(new ScreenshotViewerScreen(
image,
latestPath,
client.currentScreen
));
image.load();
},
() -> {
if (client.player != null)
client.player.sendMessage(Text.translatable("text.snapper.screenshot_open_failure"), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ public boolean pausesGame() {
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
if (this.client.currentScreen != null) {
this.client.currentScreen.render(context, mouseX, mouseY, delta);
context.draw();
}

this.client.gameRenderer.renderBlur();
this.client.getFramebuffer().beginWrite(false);

context.drawTexture(
RenderLayer::getGuiTexturedOverlay,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import dev.spiritstudios.snapper.util.SafeFiles;
import dev.spiritstudios.snapper.util.ScreenshotImage;
import dev.spiritstudios.snapper.util.SnapperUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.CubeMapRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.RotatingCubeMapRenderer;
Expand All @@ -18,6 +19,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
Expand All @@ -30,10 +32,31 @@ public class PanoramaViewerScreen extends Screen {
private final String title;
private final Screen parent;

private final List<ScreenshotImage> images = new ArrayList<>();

protected PanoramaViewerScreen(String title, Screen parent) {
super(Text.translatable("menu.snapper.viewer_menu"));
this.title = title;
this.parent = parent;
this.client = MinecraftClient.getInstance();
assert this.client != null;

List<Path> panorama = this.getImagePaths();
if (panorama == null) {
Snapper.LOGGER.error("No panorama found");
close();
return;
}

for (Path path : panorama) {
ScreenshotImage.createPanoramaFace(this.client.getTextureManager(), path)
.ifPresent(screenshotImage -> {
images.add(screenshotImage);
screenshotImage
.load()
.thenAccept(ignored -> screenshotImage.enableFiltering());
});
}
}

@Nullable
Expand Down Expand Up @@ -61,6 +84,10 @@ private List<Path> getImagePaths() {
public void close() {
Objects.requireNonNull(this.client);

for (ScreenshotImage image : images) {
image.close();
}

client.setScreen(this.parent);
}

Expand All @@ -83,18 +110,6 @@ protected void init() {
ScreenTexts.DONE,
button -> this.close()
).dimensions(width / 2 + 4, height - 32, 150, 20).build());

List<Path> panorama = this.getImagePaths();
if (panorama == null) {
Snapper.LOGGER.error("No panorama found");
close();
return;
}

for (Path path : panorama) {
ScreenshotImage.createPanoramaFace(this.client.getTextureManager(), path)
.ifPresent(ScreenshotImage::enableFiltering);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
import dev.spiritstudios.snapper.util.ScreenshotActions;
import dev.spiritstudios.snapper.util.SnapperUtil;
import dev.spiritstudios.snapper.util.uploading.ScreenshotUploading;
import dev.spiritstudios.specter.api.config.RootConfigScreen;
import net.minecraft.client.MinecraftClient;
import dev.spiritstudios.specter.api.config.client.RootConfigScreen;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.*;
import net.minecraft.client.gui.widget.AxisGridWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.DirectionalLayoutWidget;
import net.minecraft.client.gui.widget.SimplePositioningWidget;
import net.minecraft.client.gui.widget.TextIconButtonWidget;
import net.minecraft.client.util.InputUtil;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -77,7 +80,7 @@ protected void init() {
Text.translatable("button.snapper.open"),
button -> {
if (selectedScreenshot != null)
Util.getOperatingSystem().open(selectedScreenshot.path);
Util.getOperatingSystem().open(selectedScreenshot.icon.getPath());
}
).width(secondRowButtonWidth).build());

Expand All @@ -92,23 +95,23 @@ protected void init() {
Text.translatable("button.snapper.delete"),
button -> {
if (selectedScreenshot != null)
ScreenshotActions.deleteScreenshot(selectedScreenshot.path, this);
ScreenshotActions.deleteScreenshot(selectedScreenshot.icon.getPath(), this);
}
).width(firstRowButtonWidth).build());

this.renameButton = addDrawableChild(ButtonWidget.builder(
Text.translatable("button.snapper.rename"),
button -> {
if (this.selectedScreenshot != null)
client.setScreen(new RenameScreenshotScreen(this.selectedScreenshot.path, this));
client.setScreen(new RenameScreenshotScreen(this.selectedScreenshot.icon.getPath(), this));
}
).width(firstRowButtonWidth).build());

this.copyButton = addDrawableChild(ButtonWidget.builder(
Text.translatable("button.snapper.copy"),
button -> {
if (selectedScreenshot != null)
Snapper.getPlatformHelper().copyScreenshot(selectedScreenshot.path);
Snapper.getPlatformHelper().copyScreenshot(selectedScreenshot.icon.getPath());
}
).width(firstRowButtonWidth).build());

Expand All @@ -118,7 +121,7 @@ protected void init() {
if (selectedScreenshot != null)
this.client.setScreen(new ScreenshotViewerScreen(
selectedScreenshot.icon,
selectedScreenshot.path,
selectedScreenshot.icon.getPath(),
selectedScreenshot.screenParent
));
}
Expand All @@ -128,7 +131,7 @@ protected void init() {
if (selectedScreenshot == null) return;

button.active = false;
ScreenshotUploading.upload(selectedScreenshot.path)
ScreenshotUploading.upload(selectedScreenshot.icon.getPath())
.thenRun(() -> button.active = true);
}).width(firstRowButtonWidth).build());

Expand Down Expand Up @@ -241,12 +244,12 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (selectedScreenshot == null) return false;

if ((modifiers & GLFW.GLFW_MOD_CONTROL) != 0 && keyCode == InputUtil.GLFW_KEY_C) {
Snapper.getPlatformHelper().copyScreenshot(selectedScreenshot.path);
Snapper.getPlatformHelper().copyScreenshot(selectedScreenshot.icon.getPath());
return true;
}

if (keyCode == GLFW.GLFW_KEY_ENTER) {
client.setScreen(new ScreenshotViewerScreen(selectedScreenshot.icon, selectedScreenshot.path, this));
client.setScreen(new ScreenshotViewerScreen(selectedScreenshot.icon, selectedScreenshot.icon.getPath(), this));
}

return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.spiritstudios.snapper.gui.screen;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.spiritstudios.snapper.Snapper;
import dev.spiritstudios.snapper.util.ScreenshotActions;
import dev.spiritstudios.snapper.util.ScreenshotImage;
Expand Down Expand Up @@ -37,7 +36,7 @@ public class ScreenshotViewerScreen extends Screen {
private static final Identifier MENU_DECOR_BACKGROUND_TEXTURE = Identifier.ofVanilla("textures/gui/menu_list_background.png");
private static final Identifier INWORLD_MENU_DECOR_BACKGROUND_TEXTURE = Identifier.ofVanilla("textures/gui/inworld_menu_list_background.png");
private final MinecraftClient client = MinecraftClient.getInstance();
private final ScreenshotImage icon;
private final ScreenshotImage image;
private final String title;
private final int imageWidth;
private final int imageHeight;
Expand Down Expand Up @@ -65,7 +64,7 @@ public ScreenshotViewerScreen(ScreenshotImage icon, Path iconPath, Screen parent
this.client.setScreen(parent);
}

this.icon = icon;
this.image = icon;
this.title = iconPath.getFileName().toString();

this.imageWidth = image != null ? image.getWidth() : 0;
Expand Down Expand Up @@ -196,7 +195,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {

context.drawTexture(
RenderLayer::getGuiTextured,
this.icon.getTextureId(),
this.image.getTextureId(),
(this.width / 2) - (finalWidth / 2), this.height - 68 - finalHeight,
0, 0,
finalWidth, finalHeight,
Expand Down Expand Up @@ -260,10 +259,14 @@ private void drawMenuBackground(DrawContext context) {
this.client.world == null ?
MENU_DECOR_BACKGROUND_TEXTURE :
INWORLD_MENU_DECOR_BACKGROUND_TEXTURE,
width, height - 68 - 48,
0, 0,
32, 32,
0, 48
0,
48,
0,
0,
width,
height - 68 - 48,
32,
32
);
}

Expand Down Expand Up @@ -307,13 +310,15 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
};

if (imagePath == null) return super.keyPressed(keyCode, scanCode, modifiers);

ScreenshotImage.createScreenshot(client.getTextureManager(), imagePath)
.ifPresent(image -> client.setScreen(new ScreenshotViewerScreen(
image, imagePath,
this.parent,
this.screenshots
)));
.ifPresent(image -> {
client.setScreen(new ScreenshotViewerScreen(
image, imagePath,
this.parent,
this.screenshots
));
image.load();
});

return super.keyPressed(keyCode, scanCode, modifiers);
}
Expand Down
Loading