Added some important stuff
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
package de.fullrisk.citrusDev.UI;
|
||||
|
||||
import io.wispforest.owo.ui.component.LabelComponent;
|
||||
import io.wispforest.owo.ui.component.UIComponents;
|
||||
import io.wispforest.owo.ui.container.FlowLayout;
|
||||
import io.wispforest.owo.ui.container.UIContainers;
|
||||
import io.wispforest.owo.ui.core.*;
|
||||
import io.wispforest.owo.ui.hud.Hud;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.Identifier;
|
||||
|
||||
public class Module_FPS {
|
||||
|
||||
private static LabelComponent fpsLabel;
|
||||
private static FlowLayout fpsContainer;
|
||||
static boolean toggle = true;
|
||||
private static boolean shown = false; // tracks current visible/built state
|
||||
|
||||
private static final Surface GLASS_PANEL = Surface.blur(5f, 15f)
|
||||
.and(Surface.flat(0x40FFFFFF));
|
||||
|
||||
public static void register() {
|
||||
Hud.add(Identifier.fromNamespaceAndPath("citrus-dev", "fps_display"), () -> {
|
||||
if (fpsContainer == null) {
|
||||
fpsLabel = UIComponents.label(Component.literal(""));
|
||||
|
||||
fpsContainer = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
|
||||
fpsContainer.gap(4);
|
||||
fpsContainer.verticalAlignment(VerticalAlignment.CENTER);
|
||||
fpsContainer.horizontalAlignment(HorizontalAlignment.CENTER);
|
||||
fpsContainer.positioning(Positioning.absolute(10, 10));
|
||||
// start hidden; tick()/first update will populate it
|
||||
fpsContainer.padding(Insets.of(0));
|
||||
}
|
||||
return fpsContainer;
|
||||
});
|
||||
}
|
||||
|
||||
public static void tick() {
|
||||
if (fpsContainer == null) return;
|
||||
|
||||
if (toggle && !shown) {
|
||||
// turning on: restore the panel chrome and label
|
||||
fpsContainer.surface(GLASS_PANEL);
|
||||
fpsContainer.padding(Insets.of(6));
|
||||
fpsContainer.child(fpsLabel);
|
||||
shown = true;
|
||||
} else if (!toggle && shown) {
|
||||
// turning off: strip everything so it collapses to nothing
|
||||
fpsContainer.clearChildren();
|
||||
fpsContainer.surface(Surface.flat(0));
|
||||
fpsContainer.padding(Insets.of(0));
|
||||
shown = false;
|
||||
}
|
||||
|
||||
if (!toggle) return;
|
||||
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
fpsLabel.text(Component.literal(client.getFps() + " FPS"));
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
|
||||
// ----- Sidebar -----
|
||||
FlowLayout sidebar = UIContainers.verticalFlow(Sizing.fixed(sidebarWidth), Sizing.fixed(innerHeight));
|
||||
sidebar.horizontalAlignment(HorizontalAlignment.CENTER);
|
||||
sidebar.verticalAlignment(VerticalAlignment.CENTER);
|
||||
sidebar.verticalAlignment(VerticalAlignment.TOP);
|
||||
sidebar.padding(Insets.of(4));
|
||||
sidebar.gap(2);
|
||||
|
||||
@@ -75,6 +75,22 @@ public class MyScreen extends BaseOwoScreen<FlowLayout> {
|
||||
sidebarButton.verticalSizing(Sizing.fixed(20));
|
||||
sidebarButton.scale().animate(300, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
||||
|
||||
var friendsButton = new ScalableButton(Component.literal("-"), btn -> {
|
||||
Minecraft.getInstance().getSoundManager().play(
|
||||
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
|
||||
);
|
||||
},
|
||||
0x80FFFFFF, // base fill
|
||||
0xA0FFFFFF, // hovered fill
|
||||
0xFFFFFFFF, // base outline
|
||||
0xFFFFFFFF, // hovered outline
|
||||
1 // outline width
|
||||
);
|
||||
friendsButton.horizontalSizing(Sizing.fixed(20));
|
||||
friendsButton.verticalSizing(Sizing.fixed(20));
|
||||
friendsButton.scale().animate(300, Easing.CUBIC, new ScaleValue(1f)).forwards();
|
||||
|
||||
sidebar.child(friendsButton);
|
||||
sidebar.child(sidebarButton);
|
||||
panel.child(sidebar);
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package de.fullrisk.citrusDev.UI;
|
||||
|
||||
import io.wispforest.owo.ui.base.BaseOwoScreen;
|
||||
import io.wispforest.owo.ui.component.UIComponents;
|
||||
import io.wispforest.owo.ui.container.FlowLayout;
|
||||
import io.wispforest.owo.ui.container.UIContainers;
|
||||
import io.wispforest.owo.ui.core.HorizontalAlignment;
|
||||
import io.wispforest.owo.ui.core.OwoUIAdapter;
|
||||
import io.wispforest.owo.ui.core.VerticalAlignment;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import io.wispforest.owo.ui.core.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
|
||||
public class OverviewScreen extends BaseOwoScreen<FlowLayout> {
|
||||
|
||||
@Override
|
||||
protected OwoUIAdapter<FlowLayout> createAdapter() {
|
||||
return OwoUIAdapter.create(this, UIContainers::verticalFlow);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void build(FlowLayout rootComponent) {
|
||||
rootComponent.gap(2);
|
||||
rootComponent
|
||||
.horizontalAlignment(HorizontalAlignment.CENTER)
|
||||
.verticalAlignment(VerticalAlignment.CENTER);
|
||||
|
||||
FlowLayout iconButton = UIContainers.horizontalFlow(Sizing.content(), Sizing.content());
|
||||
iconButton.gap(4);
|
||||
iconButton.verticalAlignment(VerticalAlignment.CENTER);
|
||||
iconButton.horizontalAlignment(HorizontalAlignment.CENTER);
|
||||
iconButton.padding(Insets.of(6));
|
||||
|
||||
Surface glassPanel = Surface.blur(5f, 15f)
|
||||
.and(Surface.flat(0x40FFFFFF))
|
||||
.and(Surface.outline(0xFFFFFFFF));
|
||||
iconButton.surface(glassPanel);
|
||||
iconButton.child(UIComponents.texture(
|
||||
Identifier.fromNamespaceAndPath("minecraft", "textures/item/diamond.png"),
|
||||
0, 0, 16, 16, 16, 16
|
||||
));
|
||||
iconButton.child(UIComponents.label(Component.literal("Click me")));
|
||||
|
||||
iconButton.mouseEnter().subscribe(() -> {
|
||||
iconButton.surface(Surface.blur(5f, 15f)
|
||||
.and(Surface.flat(0x70FFFFFF))
|
||||
.and(Surface.outline(0xFFFFFFFF)));
|
||||
});
|
||||
iconButton.mouseLeave().subscribe(() -> {
|
||||
iconButton.surface(Surface.blur(5f, 15f)
|
||||
.and(Surface.flat(0x40FFFFFF))
|
||||
.and(Surface.outline(0xFFFFFFFF)));
|
||||
});
|
||||
|
||||
iconButton.mouseDown().subscribe((click, doubled) -> {
|
||||
Module_FPS.toggle = !Module_FPS.toggle;
|
||||
Minecraft.getInstance().getSoundManager().play(
|
||||
SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK.value(), 2.0F, 2)
|
||||
);
|
||||
return true;
|
||||
});
|
||||
rootComponent.child(iconButton);
|
||||
}
|
||||
@Override
|
||||
public boolean isPauseScreen() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user