-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge the rewritten config screen into 1.20.4
- Loading branch information
Showing
39 changed files
with
1,522 additions
and
1,365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 52 additions & 63 deletions
115
src/main/java/io/github/ennuil/ok_zoomer/commands/OkZoomerCommandScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.