mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
Public Release
This commit is contained in:
1 parent
666398e480
commit
61bb497a22
126 files changed
+8435
-1240
No files matched your search
@@ -4,10 +4,14 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef;
|
||||
import com.moulberry.flashback.screen.FlashbackButton;
|
||||
import com.moulberry.flashback.screen.SelectReplayScreen;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.Screens;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.AbstractButton;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.ImageButton;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
@@ -33,8 +37,34 @@ public class MixinTitleScreen extends Screen {
|
||||
@Unique
|
||||
private final List<AbstractWidget> normalMenuWidgets = new ArrayList<>();
|
||||
|
||||
@Unique
|
||||
private AbstractWidget openSelectReplayScreenButton = null;
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
public void init(CallbackInfo ci) {
|
||||
if (this.openSelectReplayScreenButton != null) {
|
||||
this.removeWidget(this.openSelectReplayScreenButton);
|
||||
this.openSelectReplayScreenButton = null;
|
||||
}
|
||||
}
|
||||
|
||||
// We do this on tick to ensure that our button is added after ever other mod's
|
||||
// Our button logic has automatic repositioning, whereas other mods (i.e. ModMenu)
|
||||
// might not implement repositioning logic, causing our button to render under theirs
|
||||
@Inject(method = "tick", at = @At("RETURN"))
|
||||
public void tick(CallbackInfo ci) {
|
||||
if (this.openSelectReplayScreenButton == null) {
|
||||
this.createOpenSelectReplayScreenButton();
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void createOpenSelectReplayScreenButton() {
|
||||
if (this.openSelectReplayScreenButton != null) {
|
||||
this.removeWidget(this.openSelectReplayScreenButton);
|
||||
this.openSelectReplayScreenButton = null;
|
||||
}
|
||||
|
||||
for (int offsetX = 0; offsetX < 5; offsetX++) {
|
||||
for (int i = this.normalMenuWidgets.size()-1; i >= 0; i--) {
|
||||
AbstractWidget widget = this.normalMenuWidgets.get(i);
|
||||
@@ -48,7 +78,7 @@ public class MixinTitleScreen extends Screen {
|
||||
for (Renderable renderable : this.renderables) {
|
||||
if (renderable instanceof AbstractWidget otherWidget) {
|
||||
if (x < otherWidget.getRight() && x+size > otherWidget.getX() &&
|
||||
y < otherWidget.getBottom() && y+size > otherWidget.getY()) {
|
||||
y < otherWidget.getBottom() && y+size > otherWidget.getY()) {
|
||||
overlapsWithExistingButton = true;
|
||||
break;
|
||||
}
|
||||
@@ -56,9 +86,10 @@ public class MixinTitleScreen extends Screen {
|
||||
}
|
||||
|
||||
if (!overlapsWithExistingButton) {
|
||||
this.addRenderableWidget(Button.builder(Component.literal("R"), button -> {
|
||||
this.openSelectReplayScreenButton = new FlashbackButton(x, y, size, size, Component.literal("Open Replays"), button -> {
|
||||
this.minecraft.setScreen(new SelectReplayScreen(this));
|
||||
}).bounds(x, y, size, size).build());
|
||||
});
|
||||
this.addRenderableWidget(this.openSelectReplayScreenButton);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user