mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 06:28:48 +00:00
Public Release
This commit is contained in:
1 parent
666398e480
commit
61bb497a22
126 files changed
+8435
-1240
No files matched your search
@@ -1,11 +1,14 @@
|
||||
package com.moulberry.flashback.mixin.ui;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.screen.BottomTextWidget;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.layouts.GridLayout;
|
||||
import net.minecraft.client.gui.layouts.LayoutElement;
|
||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screens.PauseScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -19,8 +22,8 @@ public class MixinPauseScreen {
|
||||
|
||||
@Inject(method = "createPauseMenu", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/layouts/GridLayout;arrangeElements()V", shift = At.Shift.BEFORE))
|
||||
public void createPauseMenu(CallbackInfo ci, @Local GridLayout.RowHelper rowHelper) {
|
||||
if (!Flashback.isInReplay()) {
|
||||
rowHelper.addChild(new BottomTextWidget(204, 10, Component.literal("Flashback"), Minecraft.getInstance().font), 2);
|
||||
if (!Flashback.isInReplay() && !Flashback.getConfig().hidePauseMenuControls) {
|
||||
rowHelper.addChild(new BottomTextWidget(204, 30, Component.literal("Flashback"), Minecraft.getInstance().font), 2);
|
||||
if (Flashback.RECORDER == null) {
|
||||
rowHelper.addChild(Button.builder(Component.literal("Start Recording"), (button) -> {
|
||||
Flashback.startRecordingReplay();
|
||||
@@ -59,4 +62,12 @@ public class MixinPauseScreen {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "createPauseMenu", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/layouts/FrameLayout;alignInRectangle(Lnet/minecraft/client/gui/layouts/LayoutElement;IIIIFF)V"))
|
||||
public void createPauseMenu_alignInRectangle(LayoutElement layoutElement, int i, int j, int k, int l, float f, float g, Operation<Void> original) {
|
||||
if (!Flashback.isInReplay() && !Flashback.getConfig().hidePauseMenuControls) {
|
||||
g += 0.05f;
|
||||
}
|
||||
original.call(layoutElement, i, j, k, l, f, g);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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