Skip to content

Commit

Permalink
Merge the rewritten config screen into 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed May 19, 2024
2 parents 8206697 + 509d464 commit 7f723d2
Show file tree
Hide file tree
Showing 39 changed files with 1,522 additions and 1,365 deletions.
68 changes: 35 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def javaVersion = 17
group = project.maven_group_id

def ENV = System.getenv()
def NOW = new Date();
def NOW = new Date()
def buildTime = ENV.BUILD_TIME ?: NOW.format('yyyyMMddHHmmss')

boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches(".+-.+")
def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}") : ""
version = (ENV.TAG ?: "${libs.versions.minecraft.get()}-development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : "")
boolean isPreviewBuild = !ENV.TAG || ENV.TAG.matches('.+-.+')
def buildNumber = !ENV.TAG ? ("${ENV.BUILD_NUMBER ? "build.${ENV.BUILD_NUMBER}" : buildTime}") : ''
version = (ENV.TAG ?: "${libs.versions.minecraft.get()}-development") + ((isPreviewBuild && !ENV.TAG) ? "+${buildNumber}" : '')

base {
archivesName = "${rootProject.name}-Quilt"
Expand All @@ -28,30 +28,33 @@ base {
repositories {
mavenCentral()
maven {
name = "Gegy"
url = "https://maven.gegy.dev"
name = 'TerraformersMC'
url = 'https://maven.terraformersmc.com/releases'
}
maven {
name = "TerraformersMC"
url = "https://maven.terraformersmc.com/releases"
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
content {
includeGroupByRegex 'org\\.parchmentmc(\\..*)?'
}
}
maven {
name = "ParchmentMC"
url = "https://maven.parchmentmc.org"
name = 'Modrinth'
url = 'https://api.modrinth.com/maven'
content {
includeGroupByRegex "org\\.parchmentmc(\\..*)?"
includeGroupByRegex "maven.modrinth"
}
}
}

loom {
mods {
"${project.mod_id}" {
sourceSet("main")
sourceSet('main')
}
}
mixin {
defaultRefmapName.set("${project.mod_id}.refmap.json")
useLegacyMixinAp = false
}
}

Expand All @@ -60,7 +63,7 @@ loom {
dependencies {
minecraft libs.minecraft
mappings(loom.layered {
it.parchment("${libs.parchment.mappings.get()}@zip")
it.parchment("${libs.parchment.get()}@zip")
it.officialMojangMappings()
})
modImplementation libs.quilt.loader
Expand All @@ -72,23 +75,20 @@ dependencies {

modImplementation libs.libzoomer
include libs.libzoomer

modImplementation libs.spruceui
include libs.spruceui
}

processResources {
filteringCharset "UTF-8"
filteringCharset 'UTF-8'

def expandProps = [
"version" : version,
"maven_group_id" : maven_group_id,
"mod_id" : mod_id,
"minecraft_version" : libs.versions.minecraft.get(),
"curseforge_id" : curseforge_id,
"modrinth_id" : modrinth_id,

"quilt_loader_version" : libs.versions.quilt.loader.get(),
'version' : version,
'maven_group_id' : maven_group_id,
'mod_id' : mod_id,
'minecraft_version' : libs.versions.minecraft.get(),
'curseforge_id' : curseforge_id,
'modrinth_id' : modrinth_id,

'quilt_loader_version' : libs.versions.quilt.loader.get(),
]

filesMatching(['*.mod.json', '*.mixins.json']) {
Expand All @@ -98,13 +98,15 @@ processResources {
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.MICROSOFT
}
withSourcesJar()
// withJavadocJar()
}
/*
toolchain {
languageVersion = JavaLanguageVersion.of(javaVersion)
vendor = JvmVendorSpec.MICROSOFT
}
*/
withSourcesJar()
// withJavadocJar()
}

jar {
from('LICENSE.md') {
Expand Down
21 changes: 10 additions & 11 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# The latest versions are available at https://quiltmc.org/en/usage/latest-versions/
[versions]
# Latest version is available at https://lambdaurora.dev/tools/import_quilt.html
minecraft = "1.20.4"
quilt_loader = "0.24.0"
parchment = "2024.04.14"

parchment = "2024.02.25"
quilt_loom = "1.6.7"
quilt_loader = "0.26.0-beta.1"

quilted_fabric_api = "9.0.0-alpha.5+0.96.11-1.20.4"
libzoomer = "0.8.0+1.20.1"
modmenu = "9.0.0"
spruceui = "5.0.3+1.20.4"
quilted_fabric_api = "9.0.0-alpha.8+0.97.0-1.20.4"
libzoomer = "0.8.1+1.20.1"
modmenu = "9.2.0-beta.2"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
parchment_mappings = { module = "org.parchmentmc.data:parchment-1.20.4", version.ref = "parchment" }
parchment = { module = "org.parchmentmc.data:parchment-1.20.4", version.ref = "parchment" }
quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loader" }

quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" }
libzoomer = { module = "io.github.ennuil:LibZoomer", version.ref = "libzoomer" }
libzoomer = { module = "maven.modrinth:libzoomer", version.ref = "libzoomer" }
modmenu = { module = "com.terraformersmc:modmenu", version.ref = "modmenu" }
spruceui = { module = "dev.lambdaurora:spruceui", version.ref = "spruceui" }

[plugins]
quilt_loom = { id = "org.quiltmc.loom", version = "1.5.+" }
quilt_loom = { id = "org.quiltmc.loom", version.ref = "quilt_loom" }
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// This class is responsible for registering the commands and packets
public class OkZoomerClientMod implements ClientModInitializer {

public static final String MODID = "ok_zoomer";

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,105 +1,94 @@
package io.github.ennuil.ok_zoomer.commands;

import dev.lambdaurora.spruceui.Position;
import dev.lambdaurora.spruceui.SpruceTexts;
import dev.lambdaurora.spruceui.background.SimpleColorBackground;
import dev.lambdaurora.spruceui.option.SpruceSeparatorOption;
import dev.lambdaurora.spruceui.option.SpruceSimpleActionOption;
import dev.lambdaurora.spruceui.screen.SpruceScreen;
import dev.lambdaurora.spruceui.widget.SpruceButtonWidget;
import dev.lambdaurora.spruceui.widget.container.SpruceOptionListWidget;
import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager;
import io.github.ennuil.ok_zoomer.config.screen.OkZoomerConfigScreen;
import io.github.ennuil.ok_zoomer.config.screen.widgets.SpruceLabelOption;
import io.github.ennuil.ok_zoomer.config.screen.components.OkZoomerAbstractSelectionList;
import io.github.ennuil.ok_zoomer.packets.ZoomPackets;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.util.CommonColors;

public class OkZoomerCommandScreen extends SpruceScreen {
private static final SimpleColorBackground DARKENED_BACKGROUND = new SimpleColorBackground(0, 0, 0, 128);
public class OkZoomerCommandScreen extends Screen {
private OkZoomerAbstractSelectionList entryListWidget;

public OkZoomerCommandScreen() {
super(Component.translatable("command.ok_zoomer.title"));
}

@Override
protected void init() {
super.init();
var list = new SpruceOptionListWidget(Position.of(0, 22), this.width, this.height - 36 - 22);
list.setBackground(DARKENED_BACKGROUND);

var configButton = SpruceSimpleActionOption.of(
"command.ok_zoomer.config",
button -> this.minecraft.setScreen(new OkZoomerConfigScreen(this)),
null);

var restrictionsSeparator = new SpruceSeparatorOption(
"command.ok_zoomer.restrictions",
true,
Component.translatable("command.ok_zoomer.restrictions.tooltip"));

list.addSingleOptionEntry(configButton);
list.addSingleOptionEntry(restrictionsSeparator);


if (ZoomPackets.getHasRestrictions()) {
list.addSingleOptionEntry(new SpruceLabelOption("command.ok_zoomer.restrictions.acknowledgement", true));
this.entryListWidget = new OkZoomerAbstractSelectionList(this.minecraft, this.width, this.height - 64, 0, 32);
this.entryListWidget.addButton(
Button.builder(
Component.translatable("command.ok_zoomer.config"),
button -> this.minecraft.setScreen(new OkZoomerConfigScreen(this))
)
.build()
);
this.entryListWidget.addCategory(Component.translatable("command.ok_zoomer.restrictions"));

if (ZoomPackets.hasRestrictions()) {
this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.acknowledgement"));
}

if (ZoomPackets.getDisableZoom()) {
list.addSingleOptionEntry(new SpruceLabelOption("command.ok_zoomer.restrictions.disable_zoom", true));
if (ZoomPackets.shouldDisableZoom()) {
this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.disable_zoom"));
}

if (ZoomPackets.getDisableZoomScrolling()) {
list.addSingleOptionEntry(new SpruceLabelOption("command.ok_zoomer.restrictions.disable_zoom_scrolling", true));
if (ZoomPackets.shouldDisableZoomScrolling()) {
this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.disable_zoom_scrolling"));
}

if (ZoomPackets.getForceClassicMode()) {
list.addSingleOptionEntry(new SpruceLabelOption("command.ok_zoomer.restrictions.force_classic_mode", true));
if (ZoomPackets.shouldForceClassicMode()) {
this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.force_classic_mode"));
}

if (ZoomPackets.getForceZoomDivisors()) {
if (ZoomPackets.shouldForceZoomDivisors()) {
double minimumZoomDivisor = ZoomPackets.getMinimumZoomDivisor();
double maximumZoomDivisor = ZoomPackets.getMaximumZoomDivisor();
list.addSingleOptionEntry(new SpruceLabelOption(
"command.ok_zoomer.restrictions.force_zoom_divisors",
minimumZoomDivisor != maximumZoomDivisor
this.entryListWidget.addServerEffectEntry(minimumZoomDivisor != maximumZoomDivisor
? Component.translatable("command.ok_zoomer.restrictions.force_zoom_divisors", minimumZoomDivisor, maximumZoomDivisor)
: Component.translatable("command.ok_zoomer.restrictions.force_zoom_divisor", minimumZoomDivisor),
true)
);
: Component.translatable("command.ok_zoomer.restrictions.force_zoom_divisor", minimumZoomDivisor));
}

if (ZoomPackets.getSpyglassDependency()) {
var key = switch (OkZoomerConfigManager.CONFIG.features.spyglass_dependency.value()) {
case REQUIRE_ITEM -> "command.ok_zoomer.restrictions.force_spyglass.require_item";
case REPLACE_ZOOM -> "command.ok_zoomer.restrictions.force_spyglass.replace_zoom";
case BOTH -> "command.ok_zoomer.restrictions.force_spyglass.both";
default -> "";
if (ZoomPackets.shouldForceSpyglassMode()) {
var text = switch (OkZoomerConfigManager.CONFIG.features.spyglassMode.value()) {
case REQUIRE_ITEM -> Component.translatable("command.ok_zoomer.restrictions.force_spyglass.require_item");
case REPLACE_ZOOM -> Component.translatable("command.ok_zoomer.restrictions.force_spyglass.replace_zoom");
case BOTH -> Component.translatable("command.ok_zoomer.restrictions.force_spyglass.both");
default -> CommonComponents.EMPTY;
};
list.addSingleOptionEntry(new SpruceLabelOption(key, true));
this.entryListWidget.addServerEffectEntry(text);
}

if (ZoomPackets.getSpyglassOverlay()) {
list.addSingleOptionEntry(new SpruceLabelOption("command.ok_zoomer.restrictions.force_spyglass_overlay", true));
if (ZoomPackets.shouldForceSpyglassOverlay()) {
this.entryListWidget.addServerEffectEntry(Component.translatable("command.ok_zoomer.restrictions.force_spyglass_overlay"));
}

if (!ZoomPackets.getHasRestrictions()) {
if (!ZoomPackets.hasRestrictions()) {
boolean acknowledged = ZoomPackets.getAcknowledgement().equals(ZoomPackets.Acknowledgement.HAS_NO_RESTRICTIONS);
list.addSingleOptionEntry(new SpruceLabelOption(acknowledged
this.entryListWidget.addServerEffectEntry(Component.translatable(acknowledged
? "command.ok_zoomer.restrictions.no_restrictions.acknowledged"
: "command.ok_zoomer.restrictions.no_restrictions",
true)
);
: "command.ok_zoomer.restrictions.no_restrictions"));
}

this.addRenderableWidget(list);
this.addRenderableWidget(new SpruceButtonWidget(Position.of(this, this.width / 2 - 100, this.height - 28), 200, 20, SpruceTexts.GUI_DONE,
btn -> this.minecraft.setScreen(null)).asVanilla());
this.entryListWidget.finish();
this.addRenderableWidget(this.entryListWidget);

this.addRenderableWidget(
Button.builder(CommonComponents.GUI_DONE, button -> this.onClose())
.bounds(this.width / 2 - 100, this.height - 27, 200, 20)
.build());
}

@Override
public void renderTitle(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
graphics.drawCenteredString(this.font, this.title, this.width / 2, 8, 0xFFFFFF);
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
this.renderBackground(graphics, mouseX, mouseY, delta);
graphics.drawCenteredString(this.font, this.getTitle(), this.width / 2, 15, CommonColors.WHITE);
this.entryListWidget.render(graphics, mouseX, mouseY, delta);
super.render(graphics, mouseX, mouseY, delta);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public Enum<?> next() {
}
}

public enum SpyglassDependency implements ConfigEnum {
public enum SpyglassMode implements ConfigEnum {
OFF,
REQUIRE_ITEM,
REPLACE_ZOOM,
Expand Down
Loading

0 comments on commit 7f723d2

Please sign in to comment.