use of me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget 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.gui.widgets.FlatButtonWidget 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.gui.widgets.FlatButtonWidget in project sodium-fabric by CaffeineMC.
the class SodiumOptionsGUI method rebuildGUI.
private void rebuildGUI() {
this.controls.clear();
this.children.clear();
this.drawable.clear();
if (this.currentPage == null) {
if (this.pages.isEmpty()) {
throw new IllegalStateException("No pages are available?!");
}
// Just use the first page for now
this.currentPage = this.pages.get(0);
}
this.rebuildGUIPages();
this.rebuildGUIOptions();
this.applyButton = new FlatButtonWidget(new Rect2i(10, this.height - 30, 80, 20), "Apply", this::applyChanges);
this.closeButton = new FlatButtonWidget(new Rect2i(96, this.height - 30, 80, 20), "Close", this::popScreen);
this.children.add(this.applyButton);
this.children.add(this.closeButton);
this.resetButton = new FlatButtonWidget(new Rect2i(this.width - 96, this.height - 30, 80, 20), "Reset", this::resetChanges);
this.children.add(this.resetButton);
for (Element element : this.children) {
if (element instanceof Drawable) {
this.drawable.add((Drawable) element);
}
}
}
use of me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget in project sodium-fabric by CaffeineMC.
the class SodiumOptionsGUI method rebuildGUIPages.
private void rebuildGUIPages() {
int x = 10;
int y = 6;
for (OptionPage page : this.pages) {
int width = 10 + this.font.getStringWidth(page.getName());
FlatButtonWidget button = new FlatButtonWidget(new Rect2i(x, y, width, 16), page.getName(), () -> {
this.setPage(page);
});
button.setSelected(this.currentPage == page);
x += width + 6;
this.children.add(button);
}
}
Aggregations