mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-28 16:06:48 +01:00
Wrapped Hints
- Fixed goggle tooltips flipping to the left when too wide - Can no longer drag the goggle overlay off-screen in the config ui
This commit is contained in:
parent
5de2e1ea9d
commit
9ee42c1824
2 changed files with 74 additions and 16 deletions
|
@ -12,7 +12,9 @@ import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.ITextProperties;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
import net.minecraft.util.text.TextFormatting;
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
|
||||||
|
@ -25,24 +27,37 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
|
||||||
public GoggleConfigScreen() {
|
public GoggleConfigScreen() {
|
||||||
ITextComponent componentSpacing = new StringTextComponent(" ");
|
ITextComponent componentSpacing = new StringTextComponent(" ");
|
||||||
tooltip = new ArrayList<>();
|
tooltip = new ArrayList<>();
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay1")));
|
tooltip.add(componentSpacing.copy()
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay2").formatted(TextFormatting.GRAY)));
|
.append(Lang.translate("gui.config.overlay1")));
|
||||||
|
tooltip.add(componentSpacing.copy()
|
||||||
|
.append(Lang.translate("gui.config.overlay2")
|
||||||
|
.formatted(TextFormatting.GRAY)));
|
||||||
tooltip.add(StringTextComponent.EMPTY);
|
tooltip.add(StringTextComponent.EMPTY);
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay3")));
|
tooltip.add(componentSpacing.copy()
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay4")));
|
.append(Lang.translate("gui.config.overlay3")));
|
||||||
|
tooltip.add(componentSpacing.copy()
|
||||||
|
.append(Lang.translate("gui.config.overlay4")));
|
||||||
tooltip.add(StringTextComponent.EMPTY);
|
tooltip.add(StringTextComponent.EMPTY);
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay5").formatted(TextFormatting.GRAY)));
|
tooltip.add(componentSpacing.copy()
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay6").formatted(TextFormatting.GRAY)));
|
.append(Lang.translate("gui.config.overlay5")
|
||||||
|
.formatted(TextFormatting.GRAY)));
|
||||||
|
tooltip.add(componentSpacing.copy()
|
||||||
|
.append(Lang.translate("gui.config.overlay6")
|
||||||
|
.formatted(TextFormatting.GRAY)));
|
||||||
tooltip.add(StringTextComponent.EMPTY);
|
tooltip.add(StringTextComponent.EMPTY);
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay7")));
|
tooltip.add(componentSpacing.copy()
|
||||||
tooltip.add(componentSpacing.copy().append(Lang.translate("gui.config.overlay8")));
|
.append(Lang.translate("gui.config.overlay7")));
|
||||||
|
tooltip.add(componentSpacing.copy()
|
||||||
|
.append(Lang.translate("gui.config.overlay8")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
Minecraft mc = Minecraft.getInstance();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
this.width = mc.getWindow().getScaledWidth();
|
this.width = mc.getWindow()
|
||||||
this.height = mc.getWindow().getScaledHeight();
|
.getScaledWidth();
|
||||||
|
this.height = mc.getWindow()
|
||||||
|
.getScaledHeight();
|
||||||
|
|
||||||
offsetX = AllConfigs.CLIENT.overlayOffsetX.get();
|
offsetX = AllConfigs.CLIENT.overlayOffsetX.get();
|
||||||
offsetY = AllConfigs.CLIENT.overlayOffsetY.get();
|
offsetY = AllConfigs.CLIENT.overlayOffsetY.get();
|
||||||
|
@ -62,7 +77,8 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(double p_mouseDragged_1_, double p_mouseDragged_3_, int p_mouseDragged_5_, double p_mouseDragged_6_, double p_mouseDragged_8_) {
|
public boolean mouseDragged(double p_mouseDragged_1_, double p_mouseDragged_3_, int p_mouseDragged_5_,
|
||||||
|
double p_mouseDragged_6_, double p_mouseDragged_8_) {
|
||||||
updateOffset(p_mouseDragged_1_, p_mouseDragged_3_);
|
updateOffset(p_mouseDragged_1_, p_mouseDragged_3_);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -71,6 +87,23 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
|
||||||
private void updateOffset(double windowX, double windowY) {
|
private void updateOffset(double windowX, double windowY) {
|
||||||
offsetX = (int) (windowX - (this.width / 2));
|
offsetX = (int) (windowX - (this.width / 2));
|
||||||
offsetY = (int) (windowY - (this.height / 2));
|
offsetY = (int) (windowY - (this.height / 2));
|
||||||
|
|
||||||
|
int titleLinesCount = 1;
|
||||||
|
int tooltipTextWidth = 0;
|
||||||
|
for (ITextProperties textLine : tooltip) {
|
||||||
|
int textLineWidth = getMinecraft().fontRenderer.getWidth(textLine);
|
||||||
|
if (textLineWidth > tooltipTextWidth)
|
||||||
|
tooltipTextWidth = textLineWidth;
|
||||||
|
}
|
||||||
|
int tooltipHeight = 8;
|
||||||
|
if (tooltip.size() > 1) {
|
||||||
|
tooltipHeight += (tooltip.size() - 1) * 10;
|
||||||
|
if (tooltip.size() > titleLinesCount)
|
||||||
|
tooltipHeight += 2; // gap between title lines and next lines
|
||||||
|
}
|
||||||
|
|
||||||
|
offsetX = MathHelper.clamp(offsetX, -(width / 2) - 5, (width / 2) - tooltipTextWidth - 20);
|
||||||
|
offsetY = MathHelper.clamp(offsetY, -(height / 2) + 17, (height / 2) - tooltipHeight + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,11 +112,13 @@ public class GoggleConfigScreen extends AbstractSimiScreen {
|
||||||
int posY = this.height / 2 + offsetY;
|
int posY = this.height / 2 + offsetY;
|
||||||
renderTooltip(ms, tooltip, posX, posY);
|
renderTooltip(ms, tooltip, posX, posY);
|
||||||
|
|
||||||
//UIRenderHelper.breadcrumbArrow(ms, 50, 50, 100, 50, 20, 10, 0x80aa9999, 0x10aa9999);
|
// UIRenderHelper.breadcrumbArrow(ms, 50, 50, 100, 50, 20, 10, 0x80aa9999, 0x10aa9999);
|
||||||
//UIRenderHelper.breadcrumbArrow(ms, 100, 80, 0, -50, 20, -10, 0x80aa9999, 0x10aa9999);
|
// UIRenderHelper.breadcrumbArrow(ms, 100, 80, 0, -50, 20, -10, 0x80aa9999, 0x10aa9999);
|
||||||
|
|
||||||
ItemStack item = AllItems.GOGGLES.asStack();
|
ItemStack item = AllItems.GOGGLES.asStack();
|
||||||
GuiGameElement.of(item).at(posX + 10, posY - 16, 450).render(ms);
|
GuiGameElement.of(item)
|
||||||
//GuiGameElement.of(item).at(0, 0, 450).render(ms);
|
.at(posX + 10, posY - 16, 450)
|
||||||
|
.render(ms);
|
||||||
|
// GuiGameElement.of(item).at(0, 0, 450).render(ms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,9 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.BlockRayTraceResult;
|
import net.minecraft.util.math.BlockRayTraceResult;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.ITextProperties;
|
||||||
import net.minecraft.util.text.StringTextComponent;
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.Style;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||||
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
|
||||||
|
@ -114,7 +116,8 @@ public class GoggleOverlayRenderer {
|
||||||
int poles = 1;
|
int poles = 1;
|
||||||
boolean pistonFound = false;
|
boolean pistonFound = false;
|
||||||
for (Direction dir : directions) {
|
for (Direction dir : directions) {
|
||||||
int attachedPoles = PistonExtensionPoleBlock.PlacementHelper.get().attachedPoles(world, pos, dir);
|
int attachedPoles = PistonExtensionPoleBlock.PlacementHelper.get()
|
||||||
|
.attachedPoles(world, pos, dir);
|
||||||
poles += attachedPoles;
|
poles += attachedPoles;
|
||||||
pistonFound |= world.getBlockState(pos.offset(dir, attachedPoles + 1))
|
pistonFound |= world.getBlockState(pos.offset(dir, attachedPoles + 1))
|
||||||
.getBlock() instanceof MechanicalPistonBlock;
|
.getBlock() instanceof MechanicalPistonBlock;
|
||||||
|
@ -139,8 +142,28 @@ public class GoggleOverlayRenderer {
|
||||||
.getScaledWidth(),
|
.getScaledWidth(),
|
||||||
mc.getWindow()
|
mc.getWindow()
|
||||||
.getScaledHeight());
|
.getScaledHeight());
|
||||||
|
|
||||||
|
int titleLinesCount = 1;
|
||||||
|
int tooltipTextWidth = 0;
|
||||||
|
for (ITextProperties textLine : tooltip) {
|
||||||
|
int textLineWidth = mc.fontRenderer.getWidth(textLine);
|
||||||
|
if (textLineWidth > tooltipTextWidth)
|
||||||
|
tooltipTextWidth = textLineWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tooltipHeight = 8;
|
||||||
|
if (tooltip.size() > 1) {
|
||||||
|
tooltipHeight += (tooltip.size() - 1) * 10;
|
||||||
|
if (tooltip.size() > titleLinesCount)
|
||||||
|
tooltipHeight += 2; // gap between title lines and next lines
|
||||||
|
}
|
||||||
|
|
||||||
int posX = tooltipScreen.width / 2 + AllConfigs.CLIENT.overlayOffsetX.get();
|
int posX = tooltipScreen.width / 2 + AllConfigs.CLIENT.overlayOffsetX.get();
|
||||||
int posY = tooltipScreen.height / 2 + AllConfigs.CLIENT.overlayOffsetY.get();
|
int posY = tooltipScreen.height / 2 + AllConfigs.CLIENT.overlayOffsetY.get();
|
||||||
|
|
||||||
|
posX = Math.min(posX, tooltipScreen.width - tooltipTextWidth - 20);
|
||||||
|
posY = Math.min(posY, tooltipScreen.height - tooltipHeight - 20);
|
||||||
|
|
||||||
tooltipScreen.renderTooltip(ms, tooltip, posX, posY);
|
tooltipScreen.renderTooltip(ms, tooltip, posX, posY);
|
||||||
|
|
||||||
ItemStack item = AllItems.GOGGLES.asStack();
|
ItemStack item = AllItems.GOGGLES.asStack();
|
||||||
|
|
Loading…
Reference in a new issue