use of me.jellysquid.mods.sodium.client.util.Dim2i in project reeses-sodium-options by FlashyReese.
the class SodiumVideoOptionsScreen method parentFrameBuilder.
protected BasicFrame.Builder parentFrameBuilder() {
BasicFrame.Builder basicFrameBuilder;
Dim2i basicFrameDim = new Dim2i(0, 0, this.width, this.height);
Dim2i tabFrameDim = new Dim2i(basicFrameDim.width() / 20 / 2, basicFrameDim.height() / 4 / 2, basicFrameDim.width() - (basicFrameDim.width() / 20), basicFrameDim.height() / 4 * 3);
Dim2i undoButtonDim = new Dim2i(tabFrameDim.getLimitX() - 203, tabFrameDim.getLimitY() + 5, 65, 20);
Dim2i applyButtonDim = new Dim2i(tabFrameDim.getLimitX() - 134, tabFrameDim.getLimitY() + 5, 65, 20);
Dim2i closeButtonDim = new Dim2i(tabFrameDim.getLimitX() - 65, tabFrameDim.getLimitY() + 5, 65, 20);
Dim2i donateButtonDim = new Dim2i(tabFrameDim.getLimitX() - 122, tabFrameDim.y() - 26, 100, 20);
Dim2i hideDonateButtonDim = new Dim2i(tabFrameDim.getLimitX() - 20, tabFrameDim.y() - 26, 20, 20);
this.undoButton = new FlatButtonWidget(undoButtonDim, new TranslatableText("sodium.options.buttons.undo"), this::undoChanges);
this.applyButton = new FlatButtonWidget(applyButtonDim, new TranslatableText("sodium.options.buttons.apply"), this::applyChanges);
this.closeButton = new FlatButtonWidget(closeButtonDim, new TranslatableText("gui.done"), this::close);
this.donateButton = new FlatButtonWidget(donateButtonDim, new TranslatableText("sodium.options.buttons.donate"), this::openDonationPage);
this.hideDonateButton = new FlatButtonWidget(hideDonateButtonDim, new LiteralText("x"), this::hideDonationButton);
if (SodiumClientMod.options().notifications.hideDonationButton) {
this.setDonationButtonVisibility(false);
}
basicFrameBuilder = this.parentBasicFrameBuilder(basicFrameDim, tabFrameDim);
if (FabricLoader.getInstance().isModLoaded("iris")) {
int size = this.client.textRenderer.getWidth(new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()));
Dim2i shaderPackButtonDim;
if (!SodiumClientMod.options().notifications.hideDonationButton) {
shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - 134 - size, tabFrameDim.y() - 26, 10 + size, 20);
} else {
shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 10, tabFrameDim.y() - 26, 10 + size, 20);
}
FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()), () -> this.client.setScreen((Screen) IrisApi.getInstance().openMainIrisScreenObj(this)));
basicFrameBuilder.addChild(dim -> shaderPackButton);
}
return basicFrameBuilder;
}
use of me.jellysquid.mods.sodium.client.util.Dim2i in project reeses-sodium-options by FlashyReese.
the class OptionPageScrollFrame method buildFrame.
@Override
public void buildFrame() {
if (this.page == null)
return;
this.children.clear();
this.drawable.clear();
this.controlElements.clear();
int y = 0;
for (OptionGroup group : this.page.getGroups()) {
// Add each option's control element
for (Option<?> option : group.getOptions()) {
Control<?> control = option.getControl();
ControlElement<?> element = control.createElement(new Dim2i(this.dim.x(), this.dim.y() + y - (this.canScroll ? this.scrollBar.getOffset() : 0), this.dim.width() - (this.canScroll ? 11 : 0), 18));
this.children.add(element);
// Move down to the next option
y += 18;
}
// Add padding beneath each option group
y += 4;
}
if (this.canScroll) {
this.scrollBar.updateThumbPosition();
}
super.buildFrame();
}
use of me.jellysquid.mods.sodium.client.util.Dim2i in project reeses-sodium-options by FlashyReese.
the class TabFrame method rebuildTabs.
private void rebuildTabs() {
if (this.tabs == null)
return;
int offsetY = 0;
for (Tab<?> tab : this.tabs) {
int x = this.tabSection.x();
int y = this.tabSection.y() + offsetY - (this.tabSectionCanScroll ? this.tabSectionScrollBar.getOffset() : 0);
int width = this.tabSection.width() - (this.tabSectionCanScroll ? 12 : 4);
int height = 18;
Dim2i tabDim = new Dim2i(x, y, width, height);
FlatButtonWidget button = new FlatButtonWidget(tabDim, tab.getTitle(), () -> this.setTab(tab));
button.setSelected(this.selectedTab == tab);
this.children.add(button);
offsetY += 18;
}
}
use of me.jellysquid.mods.sodium.client.util.Dim2i in project reeses-sodium-options by FlashyReese.
the class OptionPageScrollFrame method setupFrame.
public void setupFrame() {
this.children.clear();
this.drawable.clear();
this.controlElements.clear();
int y = 0;
if (!this.page.getGroups().isEmpty()) {
OptionGroup lastGroup = this.page.getGroups().get(this.page.getGroups().size() - 1);
for (OptionGroup group : this.page.getGroups()) {
y += group.getOptions().size() * 18;
if (group != lastGroup) {
y += 4;
}
}
}
this.canScroll = this.dim.height() < y;
if (this.canScroll) {
this.scrollBar = new ScrollBarComponent(new Dim2i(this.dim.getLimitX() - 10, this.dim.y(), 10, this.dim.height()), ScrollBarComponent.Mode.VERTICAL, y, this.dim.height(), this::buildFrame, this.dim);
}
}
use of me.jellysquid.mods.sodium.client.util.Dim2i in project reeses-sodium-options by FlashyReese.
the class OptionPageScrollFrame method renderOptionTooltip.
private void renderOptionTooltip(MatrixStack matrixStack, int mouseX, int mouseY, ControlElement<?> element) {
if (this.lastTime + 500 > System.currentTimeMillis())
return;
Dim2i dim = element.getDimensions();
int textPadding = 3;
int boxPadding = 3;
int boxWidth = dim.width();
// Offset based on mouse position, width and height of content and width and height of the window
int boxY = dim.getLimitY();
int boxX = dim.x();
Option<?> option = element.getOption();
List<OrderedText> tooltip = new ArrayList<>(MinecraftClient.getInstance().textRenderer.wrapLines(option.getTooltip(), boxWidth - (textPadding * 2)));
OptionImpact impact = option.getImpact();
if (impact != null) {
tooltip.add(Language.getInstance().reorder(new TranslatableText("sodium.options.performance_impact_string", impact.getLocalizedName()).formatted(Formatting.GRAY)));
}
int boxHeight = (tooltip.size() * 12) + boxPadding;
int boxYLimit = boxY + boxHeight;
int boxYCutoff = this.dim.getLimitY();
// If the box is going to be cutoff on the Y-axis, move it back up the difference
if (boxYLimit > boxYCutoff) {
boxY -= boxHeight + dim.height();
}
if (boxY < 0) {
boxY = dim.getLimitY();
}
this.drawRect(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xE0000000);
this.drawRectOutline(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0xFF94E4D3);
for (int i = 0; i < tooltip.size(); i++) {
MinecraftClient.getInstance().textRenderer.draw(matrixStack, tooltip.get(i), boxX + textPadding, boxY + textPadding + (i * 12), 0xFFFFFFFF);
}
}
Aggregations