Add REI Exclusion zones. Closes #2626
This commit is contained in:
parent
5407295bed
commit
dde6da28e6
3 changed files with 46 additions and 4 deletions
|
@ -50,7 +50,7 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SlotConfigGui {
|
public class SlotConfigGui {
|
||||||
|
|
||||||
static HashMap<Integer, ConfigSlotElement> slotElementMap = new HashMap<>();
|
public static HashMap<Integer, ConfigSlotElement> slotElementMap = new HashMap<>();
|
||||||
|
|
||||||
public static int selectedSlot = 0;
|
public static int selectedSlot = 0;
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,11 @@ public class ReiPlugin implements REIClientPlugin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerExclusionZones(ExclusionZones zones) {
|
||||||
|
zones.register(GuiBase.class, new SlotConfigExclusionZones());
|
||||||
|
}
|
||||||
|
|
||||||
public static Widget createProgressBar(int x, int y, double animationDuration, GuiBuilder.ProgressDirection direction) {
|
public static Widget createProgressBar(int x, int y, double animationDuration, GuiBuilder.ProgressDirection direction) {
|
||||||
return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
|
return Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
|
||||||
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
|
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
|
||||||
|
@ -314,7 +319,7 @@ public class ReiPlugin implements REIClientPlugin {
|
||||||
drawTexture(matrices, bounds.x - 1, bounds.y - 1, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
|
drawTexture(matrices, bounds.x - 1, bounds.y - 1, displayPower.xBar - 15, displayPower.yBar - 1, width, height);
|
||||||
int innerDisplayHeight;
|
int innerDisplayHeight;
|
||||||
if (animation.animationType != EntryAnimationType.NONE) {
|
if (animation.animationType != EntryAnimationType.NONE) {
|
||||||
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / innerHeight) % innerHeight));
|
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) innerHeight) % innerHeight));
|
||||||
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||||
innerDisplayHeight = innerHeight - innerDisplayHeight;
|
innerDisplayHeight = innerHeight - innerDisplayHeight;
|
||||||
} else innerDisplayHeight = innerHeight;
|
} else innerDisplayHeight = innerHeight;
|
||||||
|
@ -342,13 +347,12 @@ public class ReiPlugin implements REIClientPlugin {
|
||||||
int width = bounds.width;
|
int width = bounds.width;
|
||||||
int height = bounds.height;
|
int height = bounds.height;
|
||||||
|
|
||||||
PowerSystem.EnergySystem displayPower = PowerSystem.getDisplayPower();
|
|
||||||
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
|
RenderSystem.setShaderTexture(0, GuiBuilder.defaultTextureSheet);
|
||||||
drawTexture(matrices, bounds.x - 4, bounds.y - 4, 194, 26, width + 8, height + 8);
|
drawTexture(matrices, bounds.x - 4, bounds.y - 4, 194, 26, width + 8, height + 8);
|
||||||
drawTexture(matrices, bounds.x - 1, bounds.y - 1, 194, 82, width + 2, height + 2);
|
drawTexture(matrices, bounds.x - 1, bounds.y - 1, 194, 82, width + 2, height + 2);
|
||||||
int innerDisplayHeight;
|
int innerDisplayHeight;
|
||||||
if (animation.animationType != EntryAnimationType.NONE) {
|
if (animation.animationType != EntryAnimationType.NONE) {
|
||||||
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / height) % height));
|
innerDisplayHeight = MathHelper.ceil((System.currentTimeMillis() / (animation.duration / (float) height) % height));
|
||||||
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
if (animation.animationType == EntryAnimationType.DOWNWARDS)
|
||||||
innerDisplayHeight = height - innerDisplayHeight;
|
innerDisplayHeight = height - innerDisplayHeight;
|
||||||
} else innerDisplayHeight = height;
|
} else innerDisplayHeight = height;
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
package techreborn.client.compat.rei;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import me.shedaniel.math.Rectangle;
|
||||||
|
import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import reborncore.client.gui.builder.GuiBase;
|
||||||
|
import reborncore.client.gui.builder.slot.SlotConfigGui;
|
||||||
|
import reborncore.client.gui.builder.slot.elements.ConfigSlotElement;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class SlotConfigExclusionZones implements ExclusionZonesProvider<GuiBase<?>> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Rectangle> provide(GuiBase screen) {
|
||||||
|
if (!screen.hideGuiElements()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (SlotConfigGui.selectedSlot == -1){
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
ConfigSlotElement element = SlotConfigGui.slotElementMap.get(SlotConfigGui.selectedSlot);
|
||||||
|
int slotX = element.x + screen.getGuiLeft() -50;
|
||||||
|
if (element.getWidth() + slotX > screen.getScreenWidth() ) {
|
||||||
|
int slotY = element.y + screen.getGuiTop() + 25;
|
||||||
|
int exclusionX = screen.getScreenWidth() + screen.getGuiLeft();
|
||||||
|
int exclusionY = slotY + screen.getGuiTop() - (element.getHeight()/2);
|
||||||
|
int exclusionWidth = element.getWidth() + slotX - screen.getScreenWidth() + 15;
|
||||||
|
return Lists.newArrayList(new Rectangle(exclusionX, exclusionY, exclusionWidth, element.getHeight()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue