Skip to content

Commit

Permalink
Fix button positioning
Browse files Browse the repository at this point in the history
- Overview button is now positioned correctly again
- Updated to 24w13a (also works on 24w14a)
  • Loading branch information
Motschen committed Apr 4, 2024
1 parent 2f1bfbf commit 0241f81
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
import eu.midnightdust.core.config.MidnightLibConfig;
import eu.midnightdust.core.screen.MidnightConfigOverviewScreen;
import eu.midnightdust.lib.util.PlatformFunctions;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.TextIconButtonWidget;
import net.minecraft.client.gui.widget.ThreePartsLayoutWidget;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -17,17 +22,27 @@

@Mixin(OptionsScreen.class)
public class MixinOptionsScreen extends Screen {
@Shadow @Final private ThreePartsLayoutWidget layout;
@Unique TextIconButtonWidget button = TextIconButtonWidget.builder(Text.translatable("midnightlib.overview.title"), (
buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), true)
.texture(new Identifier("midnightlib","icon/midnightlib"), 16, 16).dimension(20, 20).build();

protected MixinOptionsScreen(Text title) {super(title);}
@Inject(at = @At("HEAD"), method = "init")
public void midnightlib$onInit(CallbackInfo ci) {
this.midnightlib$setupButton();
this.addDrawableChild(button);
}

@Inject(at = @At("HEAD"),method = "init")
private void midnightlib$init(CallbackInfo ci) {
@Override
public void resize(MinecraftClient client, int width, int height) {
super.resize(client, width, height);
this.midnightlib$setupButton();
}
@Unique
public void midnightlib$setupButton() {
if (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.TRUE) || (MidnightLibConfig.config_screen_list.equals(MidnightLibConfig.ConfigButton.MODMENU) && !PlatformFunctions.isModLoaded("modmenu"))) {
TextIconButtonWidget button = TextIconButtonWidget.builder(Text.translatable("midnightlib.overview.title"), (
buttonWidget) -> Objects.requireNonNull(client).setScreen(new MidnightConfigOverviewScreen(this)), true)
.texture(new Identifier("midnightlib","icon/midnightlib"), 16, 16).dimension(20, 20).build();
//button.setPosition(this.width / 2 + 158, this.height / 6 - 17);
button.setPosition(this.width / 2 + 158, this.height / 2 - 105);
this.addDrawableChild(button);
button.setPosition(layout.getWidth() / 2 + 158, layout.getY() + layout.getFooterHeight() - 4);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.minecraft.client.gui.tab.TabManager;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.OrderedText;
Expand Down Expand Up @@ -393,7 +392,7 @@ public MidnightConfigListWidget(MinecraftClient client, int width, int height, i
super(client, width, height, y, itemHeight);
}
@Override
public int getScrollbarPositionX() { return this.width -7; }
public int getScrollbarX() { return this.width -7; }

public void addButton(List<ClickableWidget> buttons, Text text, EntryInfo info) {
this.addEntry(new ButtonEntry(buttons, text, info));
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
org.gradle.jvmargs=-Xmx4096M

minecraft_version=24w09a
yarn_mappings=24w09a+build.11
minecraft_version=24w13a
yarn_mappings=24w13a+build.5
enabled_platforms=fabric

archives_base_name=midnightlib
mod_version=1.5.3
mod_version=1.5.4
maven_group=eu.midnightdust

fabric_loader_version=0.15.7
fabric_api_version=0.96.7+1.20.5
fabric_loader_version=0.15.9
fabric_api_version=0.96.13+1.20.5

neoforge_version=20.4.12-beta

Expand Down

0 comments on commit 0241f81

Please sign in to comment.