Easy but powerful Minecraft GUI widget
Downloads can be found on github.
Change the package name to anything you want and include these files!
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();
}
});
}
});
}
}
BnnWidget crashing, have a suggestion, found a bug? Create an issue now!
- Make sure your issue has not already been answered or fixed and you are using the latest version. Also think about whether your issue is a valid one before submitting it.
- Go to the issues page and click new issue
- Enter your a title of your issue (something that summarizes your issue), and then create a detailed description of the issue.
- The following details are required. Not including them can cause the issue to be closed.
- Forge version
- BnnWidget version
- Crash log, when reporting a crash (Please make sure to use pastebin)
- Do not post an excerpt of what you consider important, instead:
- Post the full log
- Other mods and their version, when reporting an issue between BnnWidget and another mod
- Also consider updating these before submitting a new issue, it might be already fixed
- A detailed description of the bug or feature
- To further help in resolving your issues please try to include the follow if applicable:
- What was expected?
- How to reproduce the problem?
- This is usually a great detail and allows us to fix it way faster
- Screen shots or Pictures of the problem
- The following details are required. Not including them can cause the issue to be closed.
- Click
Submit New Issue
, and wait for feedback!
Providing as many details as possible does help us to find and resolve the issue faster and also you getting a fixed version as fast as possible.
- Clone this repository via
- SSH
git clone [email protected]:Team-Fruit/BnnWidget.git
or - HTTPS
git clone https://github.com/Team-Fruit/BnnWidget.git
- Setup workspace
- Decompiled source
gradlew setupDecompWorkspace
- Obfuscated source
gradlew setupDevWorkspace
- CI server
gradlew setupCIWorkspace
- Build
gradlew build
. Jar will be inbuild/libs
- For core developer: Setup IDE
- IntelliJ: Import into IDE and execute
gradlew genIntellijRuns
afterwards - Eclipse: execute
gradlew eclipse
Before you want to add major changes, you might want to discuss them with us first, before wasting your time. If you are still willing to contribute to this project, you can contribute via Pull-Request.
The guidelines for contributing contain more detailed information about topics like the used code style and should also be considered.
Here are a few things to keep in mind that will help get your PR approved.
- A PR should be focused on content.
- Use the file you are editing as a style guide.
- Consider your feature.
- Is your suggestion already possible using Vanilla + Sign Picture?
- Make sure your feature isn't already in the works, or hasn't been rejected previously.
- Does your feature simplify another feature of Sing Picture? These changes will not be accepted.
- If your feature can be done by any popular mod, discuss with us first.
Getting Started
- Fork this repository
- Clone the fork via
- SSH
git clone [email protected]:<your username>/BnnWidget.git
or - HTTPS
git clone https://github.com/<your username>/BnnWidget.git
- Change code base
- Add changes to git
git add -A
- Commit changes to your clone
git commit -m "<summery of made changes>"
- Push to your fork
git push
- Create a Pull-Request on GitHub
- Wait for review
- Squash commits for cleaner history
If you are only doing single file pull requests, GitHub supports using a quick way without the need of cloning your fork. Also read up about synching if you plan to contribute on regular basis.
en_US
is included in this repository, fixes to typos are welcome.
Files must be encoded as UTF-8.
You can provide any additional languages by creating a new file with the appropriate language code.
Thanks to
- Notch et al for Minecraft
- Lex et al for MinecraftForge
- Kamesuta, sjcl for BnnWidget
- all contributors