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
13 changes: 8 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Snapper 1.1.2
## Snapper 1.1.3

### Features
- 26.1 support
- Parallel image loading (much faster!)
- Reload Button
- 26.2 support

### Changes
- Moved View Screenshots button to align with vanilla.
- Changed default key mapping for `Open Latest Screenshot` from O to B as O is now used for the friends menu in vanilla.

### Bug Fixes
- Many many bugfixes related to reloading
- Changes to the `View Mode` setting will now apply immediately after exiting the config menu.
- Exiting the Screenshot Viewer screen now correctly returns to the previous screen instead of closing all screens.
20 changes: 11 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
alias(libs.plugins.modpublish)
}

val modVersion = "1.1.2"
val modVersion = "1.1.3"
val modId = "snapper"
val modName = "Snapper"

Expand Down Expand Up @@ -34,11 +34,6 @@ repositories {
content { includeGroupAndSubgroups("lgbt.greenhouse") }
}

maven("https://maven.greenhouse.lgbt/snapshots/") {
name = "Greenhouse Snapshots"
content { includeGroupAndSubgroups("lgbt.greenhouse") }
}

mavenCentral()
}

Expand Down Expand Up @@ -73,16 +68,23 @@ loom {
runs.configureEach { jvmArguments.addAll(debugArgs) }
}

val greenhouseModdingApiAttribute = Attribute.of("lgbt.greenhouse.modding.api", String::class.java)
val greenhouseModdingPlatformAttribute = Attribute.of("lgbt.greenhouse.modding.platform", String::class.java)

dependencies {
minecraft(libs.minecraft)

implementation(libs.fabric.loader)
implementation(libs.fabric.api)

compileOnlyApi(libs.greenhouse.config.api)
compileOnly(libs.greenhouse.config) {
attributes {
attribute(greenhouseModdingApiAttribute, "") // The value of the attribute must remain an empty string.
}
}

runtimeOnly(libs.greenhouse.config.fabric)
include(libs.greenhouse.config.fabric)
runtimeOnly(libs.greenhouse.config)
include(libs.greenhouse.config)

compileOnly(libs.modmenu)

Expand Down
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
fabric_loom = "1.17-SNAPSHOT"
modpublish = "2.0.0"

minecraft = "26.1.2"
minecraft = "26.2"

fabric_loader = "0.18.4"
fabric_api = "0.151.0+26.1.2"
fabric_loader = "0.19.3"
fabric_api = "0.154.2+26.2"

greenhouse_config = "3.0.0-beta.5+26.1.x"
modmenu = "18.0.0-beta.1"
greenhouse_config = "3.0.1+26.2.x"
modmenu = "20.0.0-beta.4"

objc_bridge = "1.0.0"

Expand All @@ -22,8 +22,7 @@ minecraft = { group = "mojang", name = "minecraft", version.ref = "minecraft" }
fabric_loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fabric_loader" }
fabric_api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fabric_api" }

greenhouse_config_api = { group = "lgbt.greenhouse.config", name = "greenhouse-config-api", version.ref = "greenhouse_config" }
greenhouse_config_fabric = { group = "lgbt.greenhouse.config", name = "greenhouse-config-fabric", version.ref = "greenhouse_config" }
greenhouse_config = { group = "lgbt.greenhouse.config", name = "greenhouse-config", version.ref = "greenhouse_config" }

modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu" }

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 12 additions & 23 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions src/client/java/dev/spiritstudios/snapper/Snapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import dev.spiritstudios.snapper.util.uploading.ScreenshotUploading;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.SpriteIconButton;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -20,6 +23,19 @@ public void onInitializeClient() {
ClientLifecycleEvents.CLIENT_STOPPING.register(_ -> ScreenshotUploading.close());
}

public static SpriteIconButton createSnapperButton(final int width, final Button.OnPress onPress) {
return SpriteIconButton.builder(
Component.translatable("button.snapper.screenshots"),
onPress,
true
)
.width(width)
.sprite(Snapper.id("screenshots/screenshot"), 15, 15)
.tooltip(Component.translatable("button.snapper.screenshots"))
.narration(_ -> Component.translatable("button.snapper.screenshots"))
.build();
}

public static Identifier id(String path) {
return Identifier.fromNamespaceAndPath(MOD_ID, path);
}
Expand Down
35 changes: 24 additions & 11 deletions src/client/java/dev/spiritstudios/snapper/SnapperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.serialization.Codec;
import dev.spiritstudios.snapper.gui.screen.ScreenshotListScreen;
import dev.spiritstudios.snapper.gui.toast.SnapperToast;
import dev.spiritstudios.snapper.util.SnapperUtil;
import dev.spiritstudios.snapper.util.DirectoryConfigUtil;
import dev.spiritstudios.snapper.util.uploading.AxolotlClientApi;
Expand All @@ -12,6 +13,8 @@
import lgbt.greenhouse.config.api.v3.dfu.fix.GreenhouseConfigRelocateFieldsFix;
import lgbt.greenhouse.config.api.v3.lang.GreenhouseConfigJsonCLang;
import lgbt.greenhouse.config.api.v3.lang.GreenhouseConfigJsonLang;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Util;

import java.nio.file.Path;
Expand Down Expand Up @@ -175,15 +178,10 @@ public static Mutable mutable() {
return new Mutable();
}

public static void edit(Consumer<Mutable> editor) {
var mutable = mutable();
editor.accept(mutable);
mutable.save();
}

public static CompletableFuture<Void> editAsync(Consumer<Mutable> editor) {
var mutable = mutable();
Mutable mutable = mutable();
editor.accept(mutable);

return mutable.saveAsync();
}

Expand Down Expand Up @@ -219,12 +217,27 @@ public Mutable() {
termsAccepted = config.axolotlClient.termsStatus;
}

public void save() {
HOLDER.save(build(), null);
}

public CompletableFuture<Void> saveAsync() {
return CompletableFuture.runAsync(this::save, Util.ioPool());
SnapperConfig newValue = this.build();

var oldValue = HOLDER.get();
HOLDER.set(newValue, null);

return CompletableFuture.runAsync(
() -> HOLDER.save(newValue, null),
Util.ioPool()
).exceptionallyCompose(error -> Minecraft.getInstance().submit(() -> {
Snapper.LOGGER.error("Failed to save configuration file.", error);

HOLDER.set(oldValue, null);

SnapperToast.push(
SnapperToast.Type.DENY,
Component.translatable("toast.snapper.config.failure.title"),
Component.translatable("toast.snapper.config.failure.description")
);
}));
}

private SnapperConfig build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public final class SnapperKeyMappings {

public static final KeyMapping RECENT_SCREENSHOT_KEY = new KeyMapping(
"key.snapper.recent",
GLFW.GLFW_KEY_O,
GLFW.GLFW_KEY_B,
SNAPPER_CATEGORY
);

Expand All @@ -41,10 +41,10 @@ public static void init() {
KeyMappingHelper.registerKeyMapping(RECENT_SCREENSHOT_KEY);
KeyMappingHelper.registerKeyMapping(SCREENSHOT_MENU_KEY);

ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (PANORAMA_KEY.consumeClick()) SnapperKeyMappings.takePanorama(client);
while (RECENT_SCREENSHOT_KEY.consumeClick()) SnapperKeyMappings.openRecentScreenshot(client);
while (SCREENSHOT_MENU_KEY.consumeClick()) client.setScreen(new ScreenshotListScreen(client.screen));
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
while (PANORAMA_KEY.consumeClick()) SnapperKeyMappings.takePanorama(minecraft);
while (RECENT_SCREENSHOT_KEY.consumeClick()) SnapperKeyMappings.openRecentScreenshot(minecraft);
while (SCREENSHOT_MENU_KEY.consumeClick()) minecraft.gui.setScreen(new ScreenshotListScreen(minecraft.gui.screen()));
});
}

Expand All @@ -62,7 +62,7 @@ private static void takePanorama(Minecraft client) {
);
}

private static void openRecentScreenshot(Minecraft client) {
private static void openRecentScreenshot(Minecraft minecraft) {
List<Path> screenshots = ScreenshotActions.getScreenshots();
if (screenshots.isEmpty()) {
SnapperToast.push(
Expand All @@ -74,12 +74,12 @@ private static void openRecentScreenshot(Minecraft client) {
}

Path latestPath = screenshots.getFirst();
ScreenshotTexture.createScreenshot(client.getTextureManager(), latestPath)
ScreenshotTexture.createScreenshot(minecraft.getTextureManager(), latestPath)
.ifPresentOrElse(
image -> {
client.setScreen(new ScreenshotViewerScreen(
minecraft.gui.setScreen(new ScreenshotViewerScreen(
image,
client.screen
minecraft.gui.screen()
));
},
() -> SnapperToast.push(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public SnapperButtonBar(

bottomRow.addChild(SpriteIconButton.builder(
Component.translatable("config.snapper.title"),
_ -> minecraft.setScreen(new ConfigScreen(screen)),
_ -> minecraft.gui.setScreen(new ConfigScreen(screen)),
true
).width(20).sprite(SETTINGS_ICON, 15, 15).build());

Expand Down Expand Up @@ -95,7 +95,7 @@ public SnapperButtonBar(
SpriteIconButton panoramaButton = bottomRow.addChild(
SpriteIconButton.builder(
Component.translatable("button.snapper.screenshots"),
_ -> minecraft.setScreen(new PanoramaViewerScreen(Component.translatable("menu.snapper.panorama").getString(), screen)),
_ -> minecraft.gui.setScreen(new PanoramaViewerScreen(Component.translatable("menu.snapper.panorama").getString(), screen)),
true
).width(20).sprite(hasPanorama ? PANORAMA_BUTTON_ICON : PANORAMA_BUTTON_DISABLED_ICON, 15, 15).build());

Expand Down Expand Up @@ -135,7 +135,7 @@ public SnapperButtonBar(
ScreenshotTexture selected = getTexture.get();

if (selected != null) {
minecraft.setScreen(new ScreenshotRenameScreen(selected.path, screen));
minecraft.gui.setScreen(new ScreenshotRenameScreen(selected.path, screen));
}
}
).width(buttonWidth).build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class ExternalDialogOverlay extends Overlay {

@Override
public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mouseY, float a) {
if (this.minecraft.screen != null) {
this.minecraft.screen.extractRenderStateWithTooltipAndSubtitles(graphics, mouseX, mouseY, a);
if (this.minecraft.gui.screen() != null) {
this.minecraft.gui.screen().extractRenderStateWithTooltipAndSubtitles(graphics, 0, 0, a);
} else {
this.minecraft.gui.hud.extractDeferredSubtitles();
}

graphics.nextStratum();
Expand All @@ -43,6 +45,6 @@ public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mo
}

public void close() {
this.minecraft.setOverlay(null);
this.minecraft.gui.setOverlay(null);
}
}
Loading