
import javax.annotation.Nonnull;
import net.teamfruit.bnnwidget.WBase;
import net.teamfruit.bnnwidget.WEvent;
import net.teamfruit.bnnwidget.WFrame;
import net.teamfruit.bnnwidget.WPanel;
import net.teamfruit.bnnwidget.WRenderer;
import net.teamfruit.bnnwidget.motion.Easings;
import net.teamfruit.bnnwidget.position.Area;
import net.teamfruit.bnnwidget.position.Point;
import net.teamfruit.bnnwidget.position.R;
import net.teamfruit.bnnwidget.render.OpenGL;
import net.teamfruit.bnnwidget.var.V;
import net.teamfruit.bnnwidget.var.VMotion;
// your main gui extends "WFrame"
public class MyGui extends WFrame {
// init widgets in "initWidget"
@Override
protected void initWidget() {
// add your panel extends "WPanel"
add(new WPanel(new R()) {
@Override
protected void initWidget() {
// "R" is a class that relatively expresses an area.
add(new WBase(new R()) {
// "VMotion" is a constantly changing value depending on the specified animation.
VMotion m = V.pm(0);
@Override
public void draw(final @Nonnull WEvent ev, final @Nonnull Area pgp, final @Nonnull Point p, final float frame, final float opacity) {
// Let's prepare before rendering with "WRenderer.startShape()"
WRenderer.startShape();
// BnnWidget provides a GL wrapper that absorbs differences in Minecraft versions.
// The value of the "V" class is retrieved by get () every time.
OpenGL.glColor4f(0f, 0f, 0f, this.m.get());
// "WGui" has drawing methods that can be specified in detail with a float value.
draw(getGuiPosition(pgp));
}
private boolean mouseinside;
@Override
public void update(final @Nonnull WEvent ev, final @Nonnull Area pgp, final @Nonnull Point p) {
// The area of the parent widget becomes get Area of the child widget by getGuiPosition.
final Area a = getGuiPosition(pgp);
// PointInside determines if the cursor is over the widget
if (a.pointInside(p)) {
if (!this.mouseinside) {
this.mouseinside = true;
// Add animation and start it. Release the queue with stop.
this.m.stop().add(Easings.easeLinear.move(.2f, 0f)).start();
}
} else if (this.mouseinside) {
this.mouseinside = false;
this.m.stop().add(Easings.easeLinear.move(.2f, .5f)).start();
}
super.update(ev, pgp, p);
}
// It is called when the GUI is closed. If you want to add closing animation, return false and let's wait.
@Override
public boolean onCloseRequest() {
this.m.stop().add(Easings.easeLinear.move(.25f, 0f)).start();
return false;
}
// The GUI will not exit until it returns true. Let's see if the animation has ended with isFinished.
@Override
public boolean onClosing(final @Nonnull WEvent ev, final @Nonnull Area pgp, final @Nonnull Point mouse) {
return this.m.isFinished();
}
});
}
});
}
}
No files available for download.