Social Icons

Tuesday, 6 August 2013

[Release] Minecraft GUI API

Minecraft GUI API

This project gives you the ability to easily create user interfaces to display on-screen in Minecraft. It is the only GUI framework that is completely themeable and is open-source. Themes have lots of control over the positioning of components by defining areas in which child components are to be placed. Layout managers allow control of positioning of components within their containers. The API works similar to Swing but is simplified for usage on Minecraft.

Screenshots


Simple Theme 
[Image: bh08iPC.png]
Wrath Theme 
* Ignore the combo box, I never wrote a renderer for the component in this theme
[Image: UTxBU3u.png]
Laced Theme 
* Ignore the combo box, I never wrote a renderer for the component in this theme
[Image: Qm5q9ka.png]

Credits to azami
[Image: 3qX3o]

Credits to shoebox
[Image: LxLgKMt.png]
FAQ

Q: What clients currently use this API?
A: Cobalt, Laced, Nero, and Wrath, and Awareness are well-known examples.

Q: How themeable is this?
A: Themes define controls for any component (e.g. frame minimize/maximize and close/open buttons), control the rendering process, and set boundaries for positioning of a container component's children. Changing themes works perfectly; doing so will cause the components to be laid out again to fit the new theme's boundaries.

Q: Why should I use this in my client?
A: You don't have to rewrite all component positioning if you want to redo the visual portion of the GUI, you can just write a new theme and all components will work fine. Unicode font rendering support is also included.

Q: How do I properly instantiate and set up my GuiManager instance? / My GuiManager isn't rendering anything. / My GuiManager instance crashes when I attempt to call setup(). Credits to WhyMeMan for pointing out that I didn't demonstrate how to do this.
A: In this case, manager is a private instance variable in your client's main class.
Copy ExampleGuiManager into your project, rename it, and modify it to your liking. Call this in your constructor:
Code:
manager = new YourGuiManager();
Where YourGuiManager is the renamed ExampleGuiManager that you created. Then call this when Minecraft is enabled:
Code:
manager.setTheme(new SimpleTheme());
manager.setup();
(Or just call both when Minecraft is enabled.)

Q: How do I create frames?
A: An example setup for modules is included in org.darkstorm.minecraft.gui.GuiManagerImpl. Here is a simple example of a frame with a few components:
Code:
Frame testFrame = new BasicFrame("Test");
testFrame.setTheme(theme);
testFrame.add(new BasicLabel("TEST LOL"));
testFrame.add(new BasicLabel("abcdefghijklmnopqrstuvwxyz"));
testFrame.add(new BasicButton("This is a button, you can press it!"));
testFrame.add(new BasicComboBox("This", "is", "a", "combo", "box"));
Dimension defaultDimension = theme.getUIForComponent(testFrame).getDefaultSize(testFrame);
testFrame.setWidth(defaultDimension.width);
testFrame.setHeight(defaultDimension.height);
testFrame.layoutChildren();
guiManager.addFrame(testFrame);

Q: How do I render these frames?
A: Create an instance of the provided GuiScreen implementation, org.darkstorm.minecraft.gui.util.GuiManagerDisplayScreen, and display it. You can register a keybind to display this screen, if you want.

Q: How do I get pinned frames to render?
A: Do the following every render (not in a GuiScreen's render method):
Code:
manager.renderPinned();
Make sure you call manager.update() method each tick.

Source Location

The code is hosted on github: Click here

This is released under the BSD license- do whatever you want with it as long as you ensure that the license is retained everywhere it is used.

If you use this in your client, I'd be glad to hear it! If you have any questions, send me a PM, contact me on IRC in irc.rizon.net #darkstorm, or add me on skype at darkstorm652.
Found a bug? Submit a pull request! Wrote a new component? Submit a pull request! Created a new layout manager? Submit a pull request! I'll happily add them in.

3 comments:

  1. Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers!
    Minecraft Servers

    ReplyDelete
  2. Ayee dude! Are you interested in new Minecraft server that you can play to receive money? Checkout play. universemc. us. You can play the server to succeed upto $1, 000 UNITED STATES DOLLAR just for being the best player on the network! The network contains Factions, Prison, Skyblock, Kitmap and many more gamemodes! They have big youtubers participating in on the network!

    IP: PLAY. UNIVERSEMC. US
    IP ADDRESS: FACTIONPVP . US

    ReplyDelete
  3. Ayee dude! Are you looking for new Minecraft server that you can play to get money? Checkout play. universemc. us. You can play the server to succeed upto $1, 000 CHF just for being the best player on the network! The network involves Factions, Prison, Skyblock, Kitmap and many more gamemodes! It includes big youtubers taking part in on the network!

    IP: PLAY. UNIVERSEMC. US
    IP ADDRESS: FACTIONPVP. US

    WEBSITE Link and LINK to join with!: https://universemc.us/

    ReplyDelete