Revert "Easier access to adding custom buttons to existing vanilla menu categories. (#9835)"
This reverts commit c5cd3e32f8.
This commit is contained in:
@@ -28,28 +28,6 @@ public class MenuFragment{
|
|||||||
private Button currentMenu;
|
private Button currentMenu;
|
||||||
private MenuRenderer renderer;
|
private MenuRenderer renderer;
|
||||||
private Seq<MenuButton> customButtons = new Seq<>();
|
private Seq<MenuButton> customButtons = new Seq<>();
|
||||||
public Seq<MenuButton> desktopButtons = new Seq();
|
|
||||||
|
|
||||||
public MenuFragment(){
|
|
||||||
if(!mobile){
|
|
||||||
desktopButtons = Seq.with(
|
|
||||||
new MenuButton("@play", Icon.play,
|
|
||||||
new MenuButton("@campaign", Icon.play, () -> checkPlay(ui.planet::show)),
|
|
||||||
new MenuButton("@joingame", Icon.add, () -> checkPlay(ui.join::show)),
|
|
||||||
new MenuButton("@customgame", Icon.terrain, () -> checkPlay(ui.custom::show)),
|
|
||||||
new MenuButton("@loadgame", Icon.download, () -> checkPlay(ui.load::show))
|
|
||||||
),
|
|
||||||
new MenuButton("@database.button", Icon.menu,
|
|
||||||
new MenuButton("@schematics", Icon.paste, ui.schematics::show),
|
|
||||||
new MenuButton("@database", Icon.book, ui.database::show),
|
|
||||||
new MenuButton("@about.button", Icon.info, ui.about::show)
|
|
||||||
),
|
|
||||||
new MenuButton("@editor", Icon.terrain, () -> checkPlay(ui.maps::show)), steam ? new MenuButton("@workshop", Icon.steam, platform::openWorkshop) : null,
|
|
||||||
new MenuButton("@mods", Icon.book, ui.mods::show),
|
|
||||||
new MenuButton("@settings", Icon.settings, ui.settings::show)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
renderer = new MenuRenderer();
|
renderer = new MenuRenderer();
|
||||||
@@ -209,7 +187,22 @@ public class MenuFragment{
|
|||||||
t.defaults().width(width).height(70f);
|
t.defaults().width(width).height(70f);
|
||||||
t.name = "buttons";
|
t.name = "buttons";
|
||||||
|
|
||||||
buttons(t, desktopButtons.toArray(MenuButton.class));
|
buttons(t,
|
||||||
|
new MenuButton("@play", Icon.play,
|
||||||
|
new MenuButton("@campaign", Icon.play, () -> checkPlay(ui.planet::show)),
|
||||||
|
new MenuButton("@joingame", Icon.add, () -> checkPlay(ui.join::show)),
|
||||||
|
new MenuButton("@customgame", Icon.terrain, () -> checkPlay(ui.custom::show)),
|
||||||
|
new MenuButton("@loadgame", Icon.download, () -> checkPlay(ui.load::show))
|
||||||
|
),
|
||||||
|
new MenuButton("@database.button", Icon.menu,
|
||||||
|
new MenuButton("@schematics", Icon.paste, ui.schematics::show),
|
||||||
|
new MenuButton("@database", Icon.book, ui.database::show),
|
||||||
|
new MenuButton("@about.button", Icon.info, ui.about::show)
|
||||||
|
),
|
||||||
|
new MenuButton("@editor", Icon.terrain, () -> checkPlay(ui.maps::show)), steam ? new MenuButton("@workshop", Icon.steam, platform::openWorkshop) : null,
|
||||||
|
new MenuButton("@mods", Icon.book, ui.mods::show),
|
||||||
|
new MenuButton("@settings", Icon.settings, ui.settings::show)
|
||||||
|
);
|
||||||
buttons(t, customButtons.toArray(MenuButton.class));
|
buttons(t, customButtons.toArray(MenuButton.class));
|
||||||
buttons(t, new MenuButton("@quit", Icon.exit, Core.app::exit));
|
buttons(t, new MenuButton("@quit", Icon.exit, Core.app::exit));
|
||||||
}).width(width).growY();
|
}).width(width).growY();
|
||||||
@@ -264,7 +257,7 @@ public class MenuFragment{
|
|||||||
//correctly offset the button
|
//correctly offset the button
|
||||||
submenu.add().height((Core.graphics.getHeight() - Core.scene.marginTop - Core.scene.marginBottom - out[0].getY(Align.topLeft)) / Scl.scl(1f));
|
submenu.add().height((Core.graphics.getHeight() - Core.scene.marginTop - Core.scene.marginBottom - out[0].getY(Align.topLeft)) / Scl.scl(1f));
|
||||||
submenu.row();
|
submenu.row();
|
||||||
buttons(submenu, b.submenu.toArray());
|
buttons(submenu, b.submenu);
|
||||||
}else{
|
}else{
|
||||||
currentMenu = null;
|
currentMenu = null;
|
||||||
fadeOutMenu();
|
fadeOutMenu();
|
||||||
@@ -303,7 +296,7 @@ public class MenuFragment{
|
|||||||
/** Runnable ran when the button is clicked. Ignored on desktop if {@link #submenu} is not null. */
|
/** Runnable ran when the button is clicked. Ignored on desktop if {@link #submenu} is not null. */
|
||||||
public final Runnable runnable;
|
public final Runnable runnable;
|
||||||
/** Submenu shown when this button is clicked. Used instead of {@link #runnable} on desktop. */
|
/** Submenu shown when this button is clicked. Used instead of {@link #runnable} on desktop. */
|
||||||
public final @Nullable Seq<MenuButton> submenu;
|
public final @Nullable MenuButton[] submenu;
|
||||||
|
|
||||||
/** Constructs a simple menu button, which behaves the same way on desktop and mobile. */
|
/** Constructs a simple menu button, which behaves the same way on desktop and mobile. */
|
||||||
public MenuButton(String text, Drawable icon, Runnable runnable){
|
public MenuButton(String text, Drawable icon, Runnable runnable){
|
||||||
@@ -318,7 +311,7 @@ public class MenuFragment{
|
|||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
this.submenu = Seq.with(submenu);
|
this.submenu = submenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Comstructs a desktop-only button; used internally. */
|
/** Comstructs a desktop-only button; used internally. */
|
||||||
@@ -326,7 +319,7 @@ public class MenuFragment{
|
|||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.runnable = () -> {};
|
this.runnable = () -> {};
|
||||||
this.submenu = Seq.with(submenu);
|
this.submenu = submenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user