本文整理汇总了Java中de.lessvoid.nifty.builder.PanelBuilder类的典型用法代码示例。如果您正苦于以下问题:Java PanelBuilder类的具体用法?Java PanelBuilder怎么用?Java PanelBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PanelBuilder类属于de.lessvoid.nifty.builder包,在下文中一共展示了PanelBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildScreenNow
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
public void buildScreenNow(String uniqueScreenId) {
new ScreenBuilder(uniqueScreenId) {
{
controller(screenController); // Screen properties
// <layer>
layer(new LayerBuilder("Layer_ID") {
{
childLayoutVertical(); // layer properties, add more...
text(new TextBuilder("text") {
{
text("Screen made " + ++counter + " times from Generator2 with name " + uniqueScreenId);
style("nifty-label");
alignCenter();
valignCenter();
height("20%");
}
});
panel(new PanelBuilder("Panel_ID") {
{
height("20%");
childLayoutHorizontal();
control(new ButtonBuilder("PreviousButton", "Back") {
{
alignCenter();
valignCenter();
interactOnClick("back()");
}
});
control(new ButtonBuilder("NextButton", "Next") {
{
alignCenter();
valignCenter();
interactOnClick("next()");
}
});
}
});
}
});
// </layer>
}
}.build(nifty);
}
示例2: makeLabel
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
public void makeLabel() {
parent = screen.findElementByName("panelChat");
label = new PanelBuilder() {{
childLayoutHorizontal();
width("100%");
backgroundColor("#0004");
control(new LabelBuilder() {{
text(text);
}});
}}.build(nifty, screen, parent);
}
示例3: addNotification
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
public void addNotification(final String text, final ColorRGBA color, NotificationControl control) {
final Color niftyColor = new Color(color.r, color.g, color.b, color.a);
Element e = new PanelBuilder() {{
childLayoutCenter();
control(new LabelBuilder() {{
text(text);
color(niftyColor);
}});
}}.build(nifty, screen, layerHUD);
layerHUD.resetLayout();
notificationElements.add(e);
notificationControls.put(e, control);
}
示例4: generateScreen
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/**Generates the StartScreen and binds elements**/
public void generateScreen(){
nifty.addScreen("start", new ScreenBuilder("start") {{
controller(screenController);
layer(new LayerBuilder("background") {{
childLayoutCenter();
image(new ImageBuilder() {{
filename("Interface/outPostStartScreen.png");
}});
}});
//Sets up spacing elements, image, and image button to commence game
layer(new LayerBuilder("foreground") {{
childLayoutVertical();
width("100%");
height("100%");
panel(new PanelBuilder(){{
height("80%");
alignCenter();
}});
image(new ImageBuilder("StartButton"){{
height("10%");
width("15%");
filename("Interface/StartButton.png");
alignCenter();
visibleToMouse(true);
interactOnClick("startGame(loading)");
onHoverEffect(new HoverEffectBuilder("changeImage"){{
effectParameter("active", "Interface/StartButtonGlow.png");
effectParameter("inactive", "Interface/StartButton.png");
}});
}});
}});
}}.build(nifty));
}
示例5: addContainerSlots
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/**
* Adds slot elements to a given Draggable for a container
* @param drag - the Draggable object to build slots upon
* @param item - the item with the id associated to the container slot
* @param nifty - the main nifty element
*/
public static void addContainerSlots(DraggableBuilder drag, Item item, Nifty nifty){
int screenWidth = nifty.getRenderEngine().getWidth();
int screenHeight = nifty.getRenderEngine().getHeight();
PanelBuilder superPan = new PanelBuilder("container-"+item.getId());
superPan.childLayoutAbsolute();
//build the hover stats
PanelBuilder pan = new PanelBuilder();
pan.backgroundColor("#ffff");
//set properties for popup panel
pan.childLayoutAbsolute();
pan.width(""+(int)(screenWidth*0.1));
pan.height(""+(int)(screenHeight*0.25));
pan.x(""+-(int)(screenWidth*0.2));
pan.y(""+-(int)(screenWidth*0.2));
superPan.panel(pan);
superPan.renderOrder(1000);
superPan.visible(true); //don't show popup on creation
drag.panel(superPan);
}
示例6: addHoverPanel
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/**
* Adds the mouse-over hover panel to the given Draggable. Hover panel displays
* item stats.
*
* @param drag - the Draggable object to build the hover stats upon
* @param item - the Item with stats to display
* @param nifty - the main Nifty class
*/
public static void addHoverPanel(DraggableBuilder drag, Item item, Nifty nifty){
//set hover effects for the popup stats
HoverEffectBuilder onHover = new HoverEffectBuilder("show");
onHover.effectParameter("targetElement", "hoverstats-"+item.getId());
HoverEffectBuilder offHover = new HoverEffectBuilder("hide");
offHover.effectParameter("targetElement", "hoverstats-"+item.getId());
drag.onHoverEffect(onHover);
drag.onEndHoverEffect(offHover);
//add elements to the base draggable
drag.visible(true);
drag.x(""+0);
drag.y(""+0);
PanelBuilder superPan = new PanelBuilder("hoverstats-"+item.getId());
superPan.childLayoutAbsolute();
//build the hover stats
PanelBuilder pan = new PanelBuilder();
pan.backgroundColor("#969a");
addItemStats(pan,item,nifty);
//set properties for popup panel
pan.childLayoutAbsolute();
pan.width("200");
pan.height("100");
pan.x("-150");
pan.y("-100");
superPan.panel(pan);
superPan.renderOrder(1000);
superPan.visible(false); //don't show popup on creation
drag.panel(superPan);
}
示例7: addItemStats
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/**
* Adds particular stats to a hover panel given an item
*
* @param panel - the panel to add stats to
* @param item - the item with stats to add
* @param nifty - the main Nifty class
*/
public static void addItemStats(PanelBuilder panel, Item item, Nifty nifty){
ImageBuilder im = new ImageBuilder();
im.childLayoutVertical();
//set image for text
im.y("50");
im.x("0");
//build image stats on text
im.backgroundColor("#0002");
TextBuilder tb = new TextBuilder();
String stats = " ";
for (ItemDisplayTuple p : item) {
stats += p.stat+": "+p.string+"\n ";
}
//set text properties
addText(im, stats);
tb.font("Interface/Fonts/ItemText.fnt");
tb.wrap(true);
tb.textHAlignLeft();
im.text(tb);
panel.image(im);
}
示例8: makeWorldChest
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/**Creates the PanelBuilder used to build the world chest panel element
* on the HUD screen.
*/
public PanelBuilder makeWorldChest(){
//create chest and set position and dimensions
PanelBuilder chest = new PanelBuilder("WorldChest");
chest.childLayoutVertical();
chest.x(""+(int)(screenWidth*.40));
chest.y(""+(int)(screenHeight*.1));
chest.width(""+(int)(screenWidth*.30));
chest.height("70%");
//create image for hud screen and set dimensions
ImageBuilder im = new ImageBuilder("WorldChestImagePanel");
im.alignRight();
im.width("100%");
im.height("100%");
im.filename("Interface/WorldChest.png");
im.childLayoutAbsolute();
//add the 4x45 drop slots for the worldchest
addDropSlots(im);
chest.image(im);
//set initial state of world chest panel to closed.
chest.visible(false);
return chest;
}
示例9: makeContainer
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/** Returns a PanelBuilder to build with the appropriate elements
* and drag drop slots
*
* @return The PanelBuilder with the Container elements to build
*/
public PanelBuilder makeContainer(){
//set up container panel and position
PanelBuilder invent = new PanelBuilder("ContainerPanel");
invent.childLayoutOverlay();
invent.x(""+(int)(screenWidth*.57));
invent.y(""+(int)(screenHeight*.3));
invent.width(""+(int)(screenWidth*.13));
invent.height("30%");
//set up container image and size
ImageBuilder im = new ImageBuilder();
im.alignRight();
im.width("100%");
im.height("100%");
im.filename("Interface/Container.png");
im.childLayoutAbsolute();
//add container item slots
addDropSlots(im);
//set container text
TextBuilder tb = new TextBuilder("ContainerText");
tb.text("");
tb.font("Interface/Fonts/ItemText.fnt");
tb.wrap(true);
tb.width(""+(int)(screenWidth*.13));
tb.x(""+0);
tb.y(""+(int)(screenHeight*.02));
//add text to image, set non-visible before displayed
im.text(tb);
invent.image(im);
invent.visible(false);
return invent;
}
示例10: makeInventory
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
/** Returns a PanelBuilder to build the Inventory panel with the appropriate elements
* and drop slots
*
* @return The PanelBuilder with the Inventory panel elements to build
*/
public PanelBuilder makeInventory(){
//create panel and set location and size
PanelBuilder invent = new PanelBuilder("InventoryPanel");
invent.childLayoutVertical();
invent.x(""+(int)(screenWidth*.70));
invent.y(""+(int)(screenHeight*.1));
invent.width(""+(int)(screenWidth*.25));
invent.height("70%");
//create the inventory panel image and set size
ImageBuilder im = new ImageBuilder("InventoryPaneliamge");
im.alignRight();
im.width("100%");
im.height("100%");
im.filename("Interface/InventoryPanel2.png");
im.childLayoutAbsolute();
//add the drop slots to the inventory panel;s
addDropSlots(im);
invent.image(im);
//set non-visible to begin with
invent.visible(false);
return invent;
}
示例11: createDesktop
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
ScreenBuilder createDesktop(final String title, final String message) {
final ScreenController controller = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(controller);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
width("400");
height("125");
control(new LabelBuilder("title", title) {
{
x("0");
y("0");
width("400");
height("30");
}
});
control(new TextFieldBuilder("message") {
{
x("0");
y("45");
width("100%");
height("30");
text(message);
}
});
}
});
}
});
}
};
}
示例12: createMobile
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
ScreenBuilder createMobile(final String title, final String message) {
final ScreenController controller = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(controller);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
width("90%");
height("300");
control(new LabelBuilder("title", title) {
{
x("0");
y("0");
width("100%");
height("60");
}
});
control(new TextFieldBuilder("message") {
{
x("0");
y("150");
width("100%");
height("60");
text(message);
}
});
}
});
}
});
}
};
}
示例13: createAndroid
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
private ScreenBuilder createAndroid(final String message) {
final ScreenController This = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(This);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
//x("100px");
//y("100px");
width("750px");
height("175px");
control(new LabelBuilder("title", message) {
{
x("0");
y("0");
width("600px");
height("60px");
}
});
control(new TextFieldBuilder("textField") {
{
maxLength(20);
x("10");
y("75");
width("450px");
height("60px");
}
});
control(new ButtonBuilder("enter", "Enter") {
{
x("500");
y("75");
height("60px");
width("200px");
interactOnClick("enter()");
}
});
}
});
}
});
}
};
}
示例14: createDesktop
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
private ScreenBuilder createDesktop(final String message) {
final ScreenController This = this;
return new ScreenBuilder(SCREEN_ID) {
{
controller(This);
layer(new LayerBuilder("foreground") {
{
childLayoutCenter();
panel(new PanelBuilder("panel") {
{
style("nifty-panel-simple");
childLayoutAbsolute();
//x("100px");
// y("100px");
width("350px");
height("100px");
control(new LabelBuilder("title", message) {
{
x("0");
y("0");
width("350px");
height("40px");
}
});
control(new TextFieldBuilder("textField") {
{
maxLength(20);
x("10");
y("45");
width("200px");
height("25px");
}
});
control(new ButtonBuilder("enter", "Enter") {
{
x("225");
y("45");
height("25px");
interactOnClick("enter()");
}
});
}
});
}
});
}
};
}
示例15: buildScreenNow
import de.lessvoid.nifty.builder.PanelBuilder; //导入依赖的package包/类
public void buildScreenNow(String uniqueScreenId) {
new ScreenBuilder(uniqueScreenId) {
{
controller(screenController); // Screen properties
// <layer>
layer(new LayerBuilder("Layer_ID") {
{
childLayoutVertical(); // layer properties, add more...
panel(new PanelBuilder("Panel_ID") {
{
height("20%");
childLayoutHorizontal();
text(new TextBuilder("text") {
{
text("Screen made one time only from Generator4 with name " + uniqueScreenId);
style("nifty-label");
alignCenter();
valignCenter();
height("20%");
}});
control(new ButtonBuilder("PreviousButton", "Back") {
{
alignCenter();
valignCenter();
interactOnClick("back()");
}
});
}
});
}
});
// </layer>
}
}.build(nifty);
}