Removed all UI builders / Updated uCore and functional interfaces
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@ allprojects {
|
|||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
aiVersion = '1.8.1'
|
aiVersion = '1.8.1'
|
||||||
uCoreVersion = '3e5d498bd7'
|
uCoreVersion = 'b860a30db6'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ text.builtin=Built-In
|
|||||||
text.map.delete.confirm=Are you sure you want to delete this map? This action cannot be undone!
|
text.map.delete.confirm=Are you sure you want to delete this map? This action cannot be undone!
|
||||||
text.map.random=[accent]Random Map
|
text.map.random=[accent]Random Map
|
||||||
text.map.nospawn=This map does not have any cores for the player to spawn in! Add a [ROYAL]blue[] core to this map in the editor.
|
text.map.nospawn=This map does not have any cores for the player to spawn in! Add a [ROYAL]blue[] core to this map in the editor.
|
||||||
|
text.editor.brush=Brush
|
||||||
text.editor.slope=\\
|
text.editor.slope=\\
|
||||||
text.editor.openin=Open In Editor
|
text.editor.openin=Open In Editor
|
||||||
text.editor.oregen=Ore Generation
|
text.editor.oregen=Ore Generation
|
||||||
|
|||||||
@@ -11,102 +11,45 @@ import java.util.Date;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public abstract class Platform{
|
public abstract class Platform {
|
||||||
/**
|
/**Each separate game platform should set this instance to their own implementation.*/
|
||||||
* Each separate game platform should set this instance to their own implementation.
|
public static Platform instance = new Platform() {};
|
||||||
*/
|
|
||||||
public static Platform instance = new Platform(){
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**Format the date using the default date formatter.*/
|
||||||
* Format the date using the default date formatter.
|
public String format(Date date){return "invalid";}
|
||||||
*/
|
/**Format a number by adding in commas or periods where needed.*/
|
||||||
public String format(Date date){
|
public String format(int number){return "invalid";}
|
||||||
return "invalid";
|
/**Show a native error dialog.*/
|
||||||
}
|
public void showError(String text){}
|
||||||
|
/**Add a text input dialog that should show up after the field is tapped.*/
|
||||||
/**
|
|
||||||
* Format a number by adding in commas or periods where needed.
|
|
||||||
*/
|
|
||||||
public String format(int number){
|
|
||||||
return "invalid";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a native error dialog.
|
|
||||||
*/
|
|
||||||
public void showError(String text){
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a text input dialog that should show up after the field is tapped.
|
|
||||||
*/
|
|
||||||
public void addDialog(TextField field){
|
public void addDialog(TextField field){
|
||||||
addDialog(field, 16);
|
addDialog(field, 16);
|
||||||
}
|
}
|
||||||
|
/**See addDialog().*/
|
||||||
/**
|
public void addDialog(TextField field, int maxLength){}
|
||||||
* See addDialog().
|
/**Update discord RPC.*/
|
||||||
*/
|
public void updateRPC(){}
|
||||||
public void addDialog(TextField field, int maxLength){
|
/**Called when the game is exited.*/
|
||||||
}
|
public void onGameExit(){}
|
||||||
|
/**Open donation dialog. Currently android only.*/
|
||||||
/**
|
public void openDonations(){}
|
||||||
* Update discord RPC.
|
/**Whether donating is supported.*/
|
||||||
*/
|
|
||||||
public void updateRPC(){
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called when the game is exited.
|
|
||||||
*/
|
|
||||||
public void onGameExit(){
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open donation dialog. Currently android only.
|
|
||||||
*/
|
|
||||||
public void openDonations(){
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether donating is supported.
|
|
||||||
*/
|
|
||||||
public boolean canDonate(){
|
public boolean canDonate(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/**Whether the user has Discord installed. Defaults to true if unknown.*/
|
||||||
/**
|
public boolean hasDiscord(){return true;}
|
||||||
* Whether discord RPC is supported.
|
/**Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().*/
|
||||||
*/
|
|
||||||
public boolean hasDiscord(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().
|
|
||||||
*/
|
|
||||||
public String getLocaleName(Locale locale){
|
public String getLocaleName(Locale locale){
|
||||||
return locale.toString();
|
return locale.toString();
|
||||||
}
|
}
|
||||||
|
/**Whether joining games is supported.*/
|
||||||
/**
|
|
||||||
* Whether joining games is supported.
|
|
||||||
*/
|
|
||||||
public boolean canJoinGame(){
|
public boolean canJoinGame(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**Whether debug mode is enabled.*/
|
||||||
/**
|
public boolean isDebug(){return false;}
|
||||||
* Whether debug mode is enabled.
|
/**Must be a base64 string 8 bytes in length.*/
|
||||||
*/
|
|
||||||
public boolean isDebug(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be a base64 string 8 bytes in length.
|
|
||||||
*/
|
|
||||||
public String getUUID(){
|
public String getUUID(){
|
||||||
String uuid = Settings.getString("uuid", "");
|
String uuid = Settings.getString("uuid", "");
|
||||||
if(uuid.isEmpty()){
|
if(uuid.isEmpty()){
|
||||||
@@ -119,21 +62,12 @@ public abstract class Platform{
|
|||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
/**Only used for iOS or android: open the share menu for a map or save.*/
|
||||||
|
public void shareFile(FileHandle file){}
|
||||||
|
/**Download a file. Only used on GWT backend.*/
|
||||||
|
public void downloadFile(String name, byte[] bytes){}
|
||||||
|
|
||||||
/**
|
/**Show a file chooser. Desktop only.
|
||||||
* Only used for iOS or android: open the share menu for a map or save.
|
|
||||||
*/
|
|
||||||
public void shareFile(FileHandle file){
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Download a file. Only used on GWT backend.
|
|
||||||
*/
|
|
||||||
public void downloadFile(String name, byte[] bytes){
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Show a file chooser. Desktop only.
|
|
||||||
*
|
*
|
||||||
* @param text File chooser title text
|
* @param text File chooser title text
|
||||||
* @param content Description of the type of files to be loaded
|
* @param content Description of the type of files to be loaded
|
||||||
@@ -141,54 +75,24 @@ public abstract class Platform{
|
|||||||
* @param open Whether to open or save files
|
* @param open Whether to open or save files
|
||||||
* @param filetype File extension to filter
|
* @param filetype File extension to filter
|
||||||
*/
|
*/
|
||||||
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){
|
public void showFileChooser(String text, String content, Consumer<FileHandle> cons, boolean open, String filetype){}
|
||||||
}
|
/**Use the default thread provider from the kryonet module for this.*/
|
||||||
|
|
||||||
/**
|
|
||||||
* Use the default thread provider from the kryonet module for this.
|
|
||||||
*/
|
|
||||||
public ThreadProvider getThreadProvider(){
|
public ThreadProvider getThreadProvider(){
|
||||||
return new ThreadProvider(){
|
return new ThreadProvider() {
|
||||||
@Override
|
@Override public boolean isOnThread() {return true;}
|
||||||
public boolean isOnThread(){
|
@Override public void sleep(long ms) {}
|
||||||
return true;
|
@Override public void start(Runnable run) {}
|
||||||
}
|
@Override public void stop() {}
|
||||||
|
@Override public void notify(Object object) {}
|
||||||
@Override
|
@Override public void wait(Object object) {}
|
||||||
public void sleep(long ms){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void start(Runnable run){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop(){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void notify(Object object){
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void wait(Object object){
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO iOS implementation
|
//TODO iOS implementation
|
||||||
|
/**Forces the app into landscape mode. Currently Android only.*/
|
||||||
/**
|
public void beginForceLandscape(){}
|
||||||
* Forces the app into landscape mode. Currently Android only.
|
|
||||||
*/
|
|
||||||
public void beginForceLandscape(){
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO iOS implementation
|
//TODO iOS implementation
|
||||||
|
/**Stops forcing the app into landscape orientation. Currently Android only.*/
|
||||||
/**
|
public void endForceLandscape(){}
|
||||||
* Stops forcing the app into landscape orientation. Currently Android only.
|
|
||||||
*/
|
|
||||||
public void endForceLandscape(){
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -13,15 +13,12 @@ import io.anuke.mindustry.input.InputHandler;
|
|||||||
import io.anuke.mindustry.ui.dialogs.*;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
import io.anuke.mindustry.ui.fragments.*;
|
import io.anuke.mindustry.ui.fragments.*;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.function.Callable;
|
|
||||||
import io.anuke.ucore.function.Consumer;
|
import io.anuke.ucore.function.Consumer;
|
||||||
import io.anuke.ucore.function.Listenable;
|
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.modules.SceneModule;
|
import io.anuke.ucore.modules.SceneModule;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.Skin;
|
import io.anuke.ucore.scene.Skin;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.build;
|
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
import io.anuke.ucore.scene.ui.TextField;
|
import io.anuke.ucore.scene.ui.TextField;
|
||||||
import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
|
import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
|
||||||
@@ -32,9 +29,7 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
import static io.anuke.mindustry.Vars.players;
|
|
||||||
import static io.anuke.mindustry.Vars.threads;
|
|
||||||
import static io.anuke.ucore.scene.actions.Actions.*;
|
import static io.anuke.ucore.scene.actions.Actions.*;
|
||||||
|
|
||||||
public class UI extends SceneModule{
|
public class UI extends SceneModule{
|
||||||
@@ -162,10 +157,10 @@ public class UI extends SceneModule{
|
|||||||
levels = new LevelDialog();
|
levels = new LevelDialog();
|
||||||
language = new LanguageDialog();
|
language = new LanguageDialog();
|
||||||
settings = new SettingsMenuDialog();
|
settings = new SettingsMenuDialog();
|
||||||
|
host = new HostDialog();
|
||||||
paused = new PausedDialog();
|
paused = new PausedDialog();
|
||||||
changelog = new ChangelogDialog();
|
changelog = new ChangelogDialog();
|
||||||
about = new AboutDialog();
|
about = new AboutDialog();
|
||||||
host = new HostDialog();
|
|
||||||
bans = new BansDialog();
|
bans = new BansDialog();
|
||||||
admins = new AdminsDialog();
|
admins = new AdminsDialog();
|
||||||
traces = new TraceDialog();
|
traces = new TraceDialog();
|
||||||
@@ -175,8 +170,6 @@ public class UI extends SceneModule{
|
|||||||
unlocks = new UnlocksDialog();
|
unlocks = new UnlocksDialog();
|
||||||
content = new ContentInfoDialog();
|
content = new ContentInfoDialog();
|
||||||
|
|
||||||
build.begin(scene);
|
|
||||||
|
|
||||||
Group group = Core.scene.getRoot();
|
Group group = Core.scene.getRoot();
|
||||||
|
|
||||||
backfrag.build(group);
|
backfrag.build(group);
|
||||||
@@ -186,8 +179,6 @@ public class UI extends SceneModule{
|
|||||||
listfrag.build(group);
|
listfrag.build(group);
|
||||||
debugfrag.build(group);
|
debugfrag.build(group);
|
||||||
loadfrag.build(group);
|
loadfrag.build(group);
|
||||||
|
|
||||||
build.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -220,11 +211,11 @@ public class UI extends SceneModule{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadAnd(Callable call){
|
public void loadAnd(Runnable call){
|
||||||
loadAnd("$text.loading", call);
|
loadAnd("$text.loading", call);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadAnd(String text, Callable call){
|
public void loadAnd(String text, Runnable call){
|
||||||
loadfrag.show(text);
|
loadfrag.show(text);
|
||||||
Timers.runTask(7f, () -> {
|
Timers.runTask(7f, () -> {
|
||||||
call.run();
|
call.run();
|
||||||
@@ -232,11 +223,11 @@ public class UI extends SceneModule{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadLogic(Callable call){
|
public void loadLogic(Runnable call){
|
||||||
loadLogic("$text.loading", call);
|
loadLogic("$text.loading", call);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadLogic(String text, Callable call){
|
public void loadLogic(String text, Runnable call){
|
||||||
loadfrag.show();
|
loadfrag.show();
|
||||||
Timers.runTask(7f, () -> {
|
Timers.runTask(7f, () -> {
|
||||||
threads.run(() -> {
|
threads.run(() -> {
|
||||||
@@ -289,14 +280,14 @@ public class UI extends SceneModule{
|
|||||||
}}.show();
|
}}.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showConfirm(String title, String text, Listenable confirmed){
|
public void showConfirm(String title, String text, Runnable confirmed){
|
||||||
FloatingDialog dialog = new FloatingDialog(title);
|
FloatingDialog dialog = new FloatingDialog(title);
|
||||||
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
dialog.content().add(text).width(400f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
||||||
dialog.buttons().defaults().size(200f, 54f).pad(2f);
|
dialog.buttons().defaults().size(200f, 54f).pad(2f);
|
||||||
dialog.buttons().addButton("$text.cancel", dialog::hide);
|
dialog.buttons().addButton("$text.cancel", dialog::hide);
|
||||||
dialog.buttons().addButton("$text.ok", () -> {
|
dialog.buttons().addButton("$text.ok", () -> {
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
confirmed.listen();
|
confirmed.run();
|
||||||
});
|
});
|
||||||
dialog.keyDown(Keys.ESCAPE, dialog::hide);
|
dialog.keyDown(Keys.ESCAPE, dialog::hide);
|
||||||
dialog.keyDown(Keys.BACK, dialog::hide);
|
dialog.keyDown(Keys.BACK, dialog::hide);
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ import com.badlogic.gdx.utils.ObjectMap;
|
|||||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.maps.Map;
|
|
||||||
import io.anuke.mindustry.io.MapIO;
|
import io.anuke.mindustry.io.MapIO;
|
||||||
|
import io.anuke.mindustry.maps.Map;
|
||||||
import io.anuke.mindustry.maps.MapMeta;
|
import io.anuke.mindustry.maps.MapMeta;
|
||||||
import io.anuke.mindustry.maps.MapTileData;
|
import io.anuke.mindustry.maps.MapTileData;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
@@ -23,13 +23,9 @@ import io.anuke.ucore.core.Graphics;
|
|||||||
import io.anuke.ucore.core.Inputs;
|
import io.anuke.ucore.core.Inputs;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.Consumer;
|
import io.anuke.ucore.function.Consumer;
|
||||||
import io.anuke.ucore.function.Listenable;
|
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.input.Input;
|
import io.anuke.ucore.input.Input;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.build;
|
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
@@ -95,8 +91,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
t.addImageTextButton("$text.editor.import", "icon-load-map", isize, () ->
|
t.addImageTextButton("$text.editor.import", "icon-load-map", isize, () ->
|
||||||
createDialog("$text.editor.import",
|
createDialog("$text.editor.import",
|
||||||
"$text.editor.importmap", "$text.editor.importmap.description", "icon-load-map", (Listenable) loadDialog::show,
|
"$text.editor.importmap", "$text.editor.importmap.description", "icon-load-map", (Runnable) loadDialog::show,
|
||||||
"$text.editor.importfile", "$text.editor.importfile.description", "icon-file", (Listenable) () -> {
|
"$text.editor.importfile", "$text.editor.importfile.description", "icon-file", (Runnable) () -> {
|
||||||
Platform.instance.showFileChooser("$text.loadimage", "Map Files", file -> {
|
Platform.instance.showFileChooser("$text.loadimage", "Map Files", file -> {
|
||||||
ui.loadAnd(() -> {
|
ui.loadAnd(() -> {
|
||||||
try{
|
try{
|
||||||
@@ -135,7 +131,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
}*/));
|
}*/));
|
||||||
|
|
||||||
t.addImageTextButton("$text.editor.export", "icon-save-map", isize, () -> createDialog("$text.editor.export",
|
t.addImageTextButton("$text.editor.export", "icon-save-map", isize, () -> createDialog("$text.editor.export",
|
||||||
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Listenable) () -> {
|
"$text.editor.exportfile", "$text.editor.exportfile.description", "icon-file", (Runnable) () -> {
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
Platform.instance.showFileChooser("$text.saveimage", "Map Files", file -> {
|
Platform.instance.showFileChooser("$text.saveimage", "Map Files", file -> {
|
||||||
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
file = file.parent().child(file.nameWithoutExtension() + "." + mapExtension);
|
||||||
@@ -224,9 +220,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
clearChildren();
|
clearChildren();
|
||||||
margin(0);
|
margin(0);
|
||||||
build.begin(this);
|
|
||||||
build();
|
build();
|
||||||
build.end();
|
|
||||||
|
|
||||||
update(() -> {
|
update(() -> {
|
||||||
if(Core.scene.getKeyboardFocus() instanceof Dialog && Core.scene.getKeyboardFocus() != this){
|
if(Core.scene.getKeyboardFocus() instanceof Dialog && Core.scene.getKeyboardFocus() != this){
|
||||||
@@ -302,10 +296,10 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
String name = (String) arguments[i];
|
String name = (String) arguments[i];
|
||||||
String description = (String) arguments[i + 1];
|
String description = (String) arguments[i + 1];
|
||||||
String iconname = (String) arguments[i + 2];
|
String iconname = (String) arguments[i + 2];
|
||||||
Listenable listenable = (Listenable) arguments[i + 3];
|
Runnable listenable = (Runnable) arguments[i + 3];
|
||||||
|
|
||||||
TextButton button = dialog.content().addButton(name, () -> {
|
TextButton button = dialog.content().addButton(name, () -> {
|
||||||
listenable.listen();
|
listenable.run();
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
menu.hide();
|
menu.hide();
|
||||||
}).left().get();
|
}).left().get();
|
||||||
@@ -386,14 +380,13 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
float size = mobile ? (int) (Math.min(Gdx.graphics.getHeight(), Gdx.graphics.getWidth()) / amount / Unit.dp.scl(1f)) :
|
float size = mobile ? (int) (Math.min(Gdx.graphics.getHeight(), Gdx.graphics.getWidth()) / amount / Unit.dp.scl(1f)) :
|
||||||
Math.min(Gdx.graphics.getDisplayMode().height / amount, baseSize);
|
Math.min(Gdx.graphics.getDisplayMode().height / amount, baseSize);
|
||||||
|
|
||||||
new table(){{
|
table(cont -> {
|
||||||
aleft();
|
cont.left();
|
||||||
|
|
||||||
new table("button"){{
|
cont.table("button", mid -> {
|
||||||
margin(0);
|
mid.top();
|
||||||
Table tools = new Table();
|
|
||||||
tools.top();
|
Table tools = new Table().top();
|
||||||
atop();
|
|
||||||
|
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
|
|
||||||
@@ -411,8 +404,6 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
tools.defaults().size(size, size + 4f).padBottom(-5.1f);
|
tools.defaults().size(size, size + 4f).padBottom(-5.1f);
|
||||||
|
|
||||||
//tools.addImageButton("icon-back", 16*2, () -> tryExit());
|
|
||||||
|
|
||||||
tools.addImageButton("icon-menu-large", 16 * 2f, menu::show);
|
tools.addImageButton("icon-menu-large", 16 * 2f, menu::show);
|
||||||
|
|
||||||
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16 * 2f, () -> view.setGrid(!view.isGrid())).get();
|
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16 * 2f, () -> view.setGrid(!view.isGrid())).get();
|
||||||
@@ -452,9 +443,8 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
tools.row();
|
tools.row();
|
||||||
|
|
||||||
tools.table("button", t -> {
|
tools.table("button", t -> t.add("$text.editor.teams"))
|
||||||
t.add("$text.editor.teams");
|
.colspan(3).height(40).width(size * 3f);
|
||||||
}).colspan(3).height(40).width(size * 3f);
|
|
||||||
|
|
||||||
tools.row();
|
tools.row();
|
||||||
|
|
||||||
@@ -475,58 +465,48 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
if(i++ % 3 == 2) tools.row();
|
if(i++ % 3 == 2) tools.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
add(tools).top().padBottom(-6);
|
mid.add(tools).top().padBottom(-6);
|
||||||
|
|
||||||
row();
|
mid.row();
|
||||||
|
|
||||||
new table("button"){{
|
mid.table("button", t -> {
|
||||||
atop();
|
|
||||||
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
|
Slider slider = new Slider(0, MapEditor.brushSizes.length - 1, 1, false);
|
||||||
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f]));
|
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int) (float) f]));
|
||||||
new label("brush");
|
|
||||||
row();
|
|
||||||
add(slider).width(size * 3f - 20).padTop(4f);
|
|
||||||
}}.padTop(5).growX().growY().top().end();
|
|
||||||
|
|
||||||
row();
|
t.top();
|
||||||
|
t.add("$text.editor.brush");
|
||||||
|
t.row();
|
||||||
|
t.add(slider).width(size * 3f - 20).padTop(4f);
|
||||||
|
}).padTop(5).growX().growY().top();
|
||||||
|
|
||||||
get().table("button", t -> {
|
mid.row();
|
||||||
t.add("$text.editor.elevation");
|
|
||||||
}).colspan(3).height(40).width(size * 3f);
|
|
||||||
|
|
||||||
row();
|
mid.table("button", t -> t.add("$text.editor.elevation"))
|
||||||
|
.colspan(3).height(40).width(size * 3f);
|
||||||
|
|
||||||
get().table("button", t -> {
|
mid.row();
|
||||||
|
|
||||||
|
mid.table("button", t -> {
|
||||||
t.margin(0);
|
t.margin(0);
|
||||||
t.addImageButton("icon-arrow-left", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() - 1))
|
t.addImageButton("icon-arrow-left", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() - 1))
|
||||||
.disabled(b -> editor.getDrawElevation() <= -1).size(size);
|
.disabled(b -> editor.getDrawElevation() <= -1).size(size);
|
||||||
|
|
||||||
t.label(() -> editor.getDrawElevation() == -1 ? "$text.editor.slope" : (editor.getDrawElevation() + ""))
|
t.label(() -> editor.getDrawElevation() == -1 ? "$text.editor.slope" : (editor.getDrawElevation() + ""))
|
||||||
.size(size).get().setAlignment(Align.center, Align.center);
|
.size(size).get().setAlignment(Align.center, Align.center);
|
||||||
|
|
||||||
t.addImageButton("icon-arrow-right", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
|
t.addImageButton("icon-arrow-right", 16 * 2f, () -> editor.setDrawElevation(editor.getDrawElevation() + 1))
|
||||||
.disabled(b -> editor.getDrawElevation() >= 127).size(size);
|
.disabled(b -> editor.getDrawElevation() >= 127).size(size);
|
||||||
}).colspan(3).height(size).padTop(-5).width(size * 3f);
|
}).colspan(3).height(size).padTop(-5).width(size * 3f);
|
||||||
|
|
||||||
}}.left().growY().end();
|
}).margin(0).left().growY();
|
||||||
|
|
||||||
|
|
||||||
new table("button"){{
|
cont.table("button", t -> t.add(view).grow())
|
||||||
margin(5);
|
.margin(5).marginBottom(10).grow();
|
||||||
marginBottom(10);
|
|
||||||
add(view).grow();
|
|
||||||
}}.grow().end();
|
|
||||||
|
|
||||||
new table(){{
|
cont.table(this::addBlockSelection).right().growY();
|
||||||
|
|
||||||
row();
|
}).grow();
|
||||||
|
|
||||||
addBlockSelection(get());
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
}}.right().growY().end();
|
|
||||||
}}.grow().end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doInput(){
|
private void doInput(){
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import io.anuke.mindustry.world.meta.BlockBar;
|
|||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.core.Settings;
|
import io.anuke.ucore.core.Settings;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.Callable;
|
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
@@ -100,7 +99,7 @@ public class OverlayRenderer{
|
|||||||
int[] values = {0, 0};
|
int[] values = {0, 0};
|
||||||
boolean[] doDraw = {false};
|
boolean[] doDraw = {false};
|
||||||
|
|
||||||
Callable drawbars = () -> {
|
Runnable drawbars = () -> {
|
||||||
for(BlockBar bar : block.bars.list()){
|
for(BlockBar bar : block.bars.list()){
|
||||||
float offset = Mathf.sign(bar.top) * (block.size / 2f * tilesize + 2f + (bar.top ? values[0] : values[1]));
|
float offset = Mathf.sign(bar.top) * (block.size / 2f * tilesize + 2f + (bar.top ? values[0] : values[1]));
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package io.anuke.mindustry.input;
|
package io.anuke.mindustry.input;
|
||||||
|
|
||||||
import io.anuke.ucore.function.Callable;
|
|
||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,9 +11,9 @@ public enum CursorType{
|
|||||||
drill(() -> Cursors.set("drill")),
|
drill(() -> Cursors.set("drill")),
|
||||||
unload(() -> Cursors.set("unload"));
|
unload(() -> Cursors.set("unload"));
|
||||||
|
|
||||||
private final Callable call;
|
private final Runnable call;
|
||||||
|
|
||||||
CursorType(Callable call){
|
CursorType(Runnable call){
|
||||||
this.call = call;
|
this.call = call;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ import io.anuke.ucore.entities.Entities;
|
|||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
@@ -210,25 +208,23 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
public void buildUI(Group group){
|
public void buildUI(Group group){
|
||||||
|
|
||||||
//Create confirm/cancel table
|
//Create confirm/cancel table
|
||||||
new table(){{
|
group.fill(c -> {
|
||||||
abottom().aleft();
|
c.bottom().left().visible(() -> !state.is(State.menu));
|
||||||
|
|
||||||
new table("pane"){{
|
c.table("pane", act -> {
|
||||||
margin(5);
|
act.margin(5);
|
||||||
defaults().size(60f);
|
act.defaults().size(60f);
|
||||||
|
|
||||||
touchable(Touchable.enabled);
|
|
||||||
|
|
||||||
//Add a cancel button
|
//Add a cancel button
|
||||||
new imagebutton("icon-cancel", 16 * 2f, () -> {
|
act.addImageButton("icon-cancel", 16*2f, () -> {
|
||||||
mode = none;
|
mode = none;
|
||||||
recipe = null;
|
recipe = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
row();
|
act.row();
|
||||||
|
|
||||||
//Add an accept button, which places everything.
|
//Add an accept button, which places everything.
|
||||||
new imagebutton("icon-check", 16 * 2f, () -> {
|
act.addImageButton("icon-check", 16 * 2f, () -> {
|
||||||
for(PlaceRequest request : selection){
|
for(PlaceRequest request : selection){
|
||||||
Tile tile = request.tile();
|
Tile tile = request.tile();
|
||||||
|
|
||||||
@@ -248,48 +244,39 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
removals.addAll(selection);
|
removals.addAll(selection);
|
||||||
selection.clear();
|
selection.clear();
|
||||||
selecting = false;
|
selecting = false;
|
||||||
}).cell.disabled(i -> selection.size == 0);
|
}).disabled(i -> selection.size == 0);
|
||||||
|
|
||||||
row();
|
act.row();
|
||||||
|
|
||||||
//Add a rotate button
|
//Add a rotate button
|
||||||
new imagebutton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
|
act.addImageButton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
|
||||||
.update(i -> {
|
.update(i -> i.getImage().setRotationOrigin(rotation * 90, Align.center))
|
||||||
i.getImage().setRotation(rotation * 90);
|
.disabled(i -> recipe == null || !recipe.result.rotate);
|
||||||
i.getImage().setOrigin(Align.center);
|
}).visible(() -> mode != none).touchable(Touchable.enabled);;
|
||||||
}).cell.disabled(i -> recipe == null || !recipe.result.rotate);
|
|
||||||
}}.visible(() -> mode != none).end();
|
|
||||||
|
|
||||||
row();
|
c.row();
|
||||||
|
|
||||||
new table("pane"){{
|
c.table("pane", remove -> {
|
||||||
margin(5);
|
remove.defaults().size(60f);
|
||||||
defaults().size(60f);
|
|
||||||
|
|
||||||
touchable(Touchable.enabled);
|
|
||||||
|
|
||||||
//Add a break button.
|
//Add a break button.
|
||||||
new imagebutton("icon-break", "toggle", 16 * 2f, () -> {
|
remove.addImageButton("icon-break", "toggle", 16 * 2f, () -> {
|
||||||
mode = mode == breaking ? recipe == null ? none : placing : breaking;
|
mode = mode == breaking ? recipe == null ? none : placing : breaking;
|
||||||
lastRecipe = recipe;
|
lastRecipe = recipe;
|
||||||
if(mode == breaking){
|
if(mode == breaking){
|
||||||
showGuide("deconstruction");
|
showGuide("deconstruction");
|
||||||
}
|
}
|
||||||
}).update(l -> l.setChecked(mode == breaking));
|
}).update(l -> l.setChecked(mode == breaking));
|
||||||
}}.end();
|
}).margin(5).touchable(Touchable.enabled);;
|
||||||
|
|
||||||
new table("pane"){{
|
c.table("pane", cancel -> {
|
||||||
margin(5);
|
cancel.defaults().size(60f);
|
||||||
defaults().size(60f);
|
|
||||||
|
|
||||||
touchable(Touchable.enabled);
|
|
||||||
|
|
||||||
//Add a 'cancel building' button.
|
//Add a 'cancel building' button.
|
||||||
new imagebutton("icon-cancel", 16 * 2f, player::clearBuilding);
|
cancel.addImageButton("icon-cancel", 16 * 2f, player::clearBuilding);
|
||||||
|
|
||||||
visible(() -> player.getPlaceQueue().size > 0);
|
}).left().colspan(2).margin(5).touchable(Touchable.enabled).visible(() -> player.getPlaceQueue().size > 0);
|
||||||
}}.left().colspan(2).end();
|
});
|
||||||
}}.visible(() -> !state.is(State.menu)).end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,16 +2,15 @@ package io.anuke.mindustry.ui;
|
|||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import io.anuke.ucore.function.Listenable;
|
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
|
|
||||||
public class MenuButton extends TextButton{
|
public class MenuButton extends TextButton{
|
||||||
|
|
||||||
public MenuButton(String icon, String text, Listenable clicked){
|
public MenuButton(String icon, String text, Runnable clicked){
|
||||||
this(icon, text, null, clicked);
|
this(icon, text, null, clicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MenuButton(String icon, String text, String description, Listenable clicked){
|
public MenuButton(String icon, String text, String description, Runnable clicked){
|
||||||
super("default");
|
super("default");
|
||||||
float s = 66f;
|
float s = 66f;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package io.anuke.mindustry.ui;
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import io.anuke.ucore.function.Listenable;
|
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
|
||||||
public class MobileButton extends ImageButton{
|
public class MobileButton extends ImageButton{
|
||||||
|
|
||||||
public MobileButton(String icon, float isize, String text, Listenable listener){
|
public MobileButton(String icon, float isize, String text, Runnable listener){
|
||||||
super(icon);
|
super(icon);
|
||||||
resizeImage(isize);
|
resizeImage(isize);
|
||||||
clicked(listener);
|
clicked(listener);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package io.anuke.mindustry.ui.dialogs;
|
|||||||
|
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.ucore.scene.builders.build;
|
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -81,43 +79,28 @@ public class PausedDialog extends FloatingDialog{
|
|||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
build.begin(content());
|
|
||||||
|
|
||||||
content().defaults().size(120f).pad(5);
|
content().defaults().size(120f).pad(5);
|
||||||
float isize = 14f * 4;
|
float isize = 14f * 4;
|
||||||
|
|
||||||
new imagebutton("icon-play-2", isize, () -> {
|
content().addRowImageTextButton("$text.back", "icon-play-2", isize, () -> {
|
||||||
hide();
|
hide();
|
||||||
if(!wasPaused && !state.is(State.menu))
|
if(!wasPaused && !state.is(State.menu))
|
||||||
state.set(State.playing);
|
state.set(State.playing);
|
||||||
}).text("$text.back").padTop(4f);
|
});
|
||||||
|
content().addRowImageTextButton("$text.settings", "icon-tools", isize, ui.settings::show);
|
||||||
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
|
content().addRowImageTextButton("$text.save", "icon-save", isize, save::show);
|
||||||
|
|
||||||
imagebutton sa = new imagebutton("icon-save", isize, save::show);
|
|
||||||
sa.text("$text.save").padTop(4f);
|
|
||||||
|
|
||||||
content().row();
|
content().row();
|
||||||
|
|
||||||
imagebutton lo = new imagebutton("icon-load", isize, load::show);
|
content().addRowImageTextButton("$text.load", "icon-load", isize, load::show).disabled(b -> Net.active());
|
||||||
lo.text("$text.load").padTop(4f);
|
content().addRowImageTextButton("$text.host", "icon-host", isize, ui.host::show).disabled(b -> Net.active());
|
||||||
lo.cell.disabled(b -> Net.active());
|
content().addRowImageTextButton("$text.quit", "icon-quit", isize, () -> {
|
||||||
|
|
||||||
imagebutton ho = new imagebutton("icon-host", isize, () -> {
|
|
||||||
ui.host.show();
|
|
||||||
});
|
|
||||||
ho.text("$text.host").padTop(4f);
|
|
||||||
ho.cell.disabled(b -> Net.active());
|
|
||||||
|
|
||||||
new imagebutton("icon-quit", isize, () -> {
|
|
||||||
ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
ui.showConfirm("$text.confirm", "$text.quit.confirm", () -> {
|
||||||
if(Net.client()) netClient.disconnectQuietly();
|
if(Net.client()) netClient.disconnectQuietly();
|
||||||
runExitSave();
|
runExitSave();
|
||||||
hide();
|
hide();
|
||||||
});
|
});
|
||||||
}).text("Quit").padTop(4f);
|
});
|
||||||
|
|
||||||
build.end();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class BlockConsumeFragment extends Fragment{
|
|||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
table = new Table();
|
table = new Table();
|
||||||
table.setVisible(() -> !state.is(State.menu) && visible);
|
table.visible(() -> !state.is(State.menu) && visible);
|
||||||
table.setTransform(true);
|
table.setTransform(true);
|
||||||
parent.setTransform(true);
|
parent.setTransform(true);
|
||||||
parent.addChild(table);
|
parent.addChild(table);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class BlockInventoryFragment extends Fragment{
|
|||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
table = new Table();
|
table = new Table();
|
||||||
table.setVisible(() -> !state.is(State.menu));
|
table.visible(() -> !state.is(State.menu));
|
||||||
table.setTransform(true);
|
table.setTransform(true);
|
||||||
parent.setTransform(true);
|
parent.setTransform(true);
|
||||||
parent.addChild(table);
|
parent.addChild(table);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import io.anuke.ucore.core.Graphics;
|
|||||||
import io.anuke.ucore.scene.Element;
|
import io.anuke.ucore.scene.Element;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.event.ClickListener;
|
import io.anuke.ucore.scene.event.ClickListener;
|
||||||
import io.anuke.ucore.scene.event.InputEvent;
|
import io.anuke.ucore.scene.event.InputEvent;
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
@@ -37,60 +36,37 @@ public class BlocksFragment extends Fragment{
|
|||||||
private static final float size = 48;
|
private static final float size = 48;
|
||||||
//maximum recipe rows
|
//maximum recipe rows
|
||||||
private static final int maxrow = 3;
|
private static final int maxrow = 3;
|
||||||
/**
|
/** Table containing description that is shown on top.*/
|
||||||
* Table containing description that is shown on top.
|
|
||||||
*/
|
|
||||||
private Table descTable;
|
private Table descTable;
|
||||||
/**
|
/** Main table containing the whole menu.*/
|
||||||
* Main table containing the whole menu.
|
|
||||||
*/
|
|
||||||
private Table mainTable;
|
private Table mainTable;
|
||||||
/**
|
/** Table for all section buttons and blocks.*/
|
||||||
* Table for all section buttons and blocks.
|
|
||||||
*/
|
|
||||||
private Table selectTable;
|
private Table selectTable;
|
||||||
/**
|
/** Whether the whole thing is shown or hidden by the popup button.*/
|
||||||
* Whether the whole thing is shown or hidden by the popup button.
|
|
||||||
*/
|
|
||||||
private boolean shown = true;
|
private boolean shown = true;
|
||||||
/**
|
/** Recipe currently hovering over.*/
|
||||||
* Recipe currently hovering over.
|
|
||||||
*/
|
|
||||||
private Recipe hoverRecipe;
|
private Recipe hoverRecipe;
|
||||||
/**
|
/** Last category selected.*/
|
||||||
* Last category selected.
|
|
||||||
*/
|
|
||||||
private Category lastCategory;
|
private Category lastCategory;
|
||||||
/**
|
/** Last block pane scroll Y position.*/
|
||||||
* Last block pane scroll Y position.
|
|
||||||
*/
|
|
||||||
private float lastScroll;
|
private float lastScroll;
|
||||||
/**
|
/** Temporary recipe array for storage*/
|
||||||
* Temporary recipe array for storage
|
|
||||||
*/
|
|
||||||
private Array<Recipe> recipes = new Array<>();
|
private Array<Recipe> recipes = new Array<>();
|
||||||
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
InputHandler input = control.input(0);
|
InputHandler input = control.input(0);
|
||||||
|
|
||||||
//create container table
|
parent.fill(container -> {
|
||||||
new table(){{
|
container.bottom().right().visible(() -> !state.is(State.menu));
|
||||||
abottom();
|
|
||||||
aright();
|
|
||||||
|
|
||||||
//make it only be shown when needed.
|
mainTable = container.table(main -> {
|
||||||
visible(() -> !state.is(State.menu));
|
|
||||||
|
|
||||||
//create the main blocks table
|
|
||||||
mainTable = new table(){{
|
|
||||||
|
|
||||||
//add top description table
|
//add top description table
|
||||||
descTable = new Table("button");
|
descTable = new Table("button");
|
||||||
descTable.setVisible(() -> hoverRecipe != null || input.recipe != null); //make sure it's visible when necessary
|
descTable.visible(() -> hoverRecipe != null || input.recipe != null); //make sure it's visible when necessary
|
||||||
descTable.update(() -> {
|
descTable.update(() -> {
|
||||||
// note: This is required because there is no direct connection between
|
// note: This is required because there is no direct connection between input.recipe and the description ui.
|
||||||
// input.recipe and the description ui. If input.recipe gets set to null
|
// If input.recipe gets set to null, a proper cleanup of the ui elements is required.
|
||||||
// a proper cleanup of the ui elements is required.
|
|
||||||
boolean anyRecipeShown = input.recipe != null || hoverRecipe != null;
|
boolean anyRecipeShown = input.recipe != null || hoverRecipe != null;
|
||||||
boolean descriptionTableClean = descTable.getChildren().size == 0;
|
boolean descriptionTableClean = descTable.getChildren().size == 0;
|
||||||
boolean cleanupRequired = !anyRecipeShown && !descriptionTableClean;
|
boolean cleanupRequired = !anyRecipeShown && !descriptionTableClean;
|
||||||
@@ -99,26 +75,17 @@ public class BlocksFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add(descTable).fillX().uniformX();
|
container.add(descTable).fillX().uniformX();
|
||||||
|
|
||||||
row();
|
container.row();
|
||||||
|
|
||||||
//now add the block selection menu
|
//now add the block selection menu
|
||||||
selectTable = new table("pane"){{
|
selectTable = main.table("pane", select -> {})
|
||||||
touchable(Touchable.enabled);
|
.margin(10f).marginLeft(0f).marginRight(0f).marginTop(-5)
|
||||||
|
.touchable(Touchable.enabled).right().bottom().get();
|
||||||
|
|
||||||
margin(10f);
|
}).bottom().right().get();
|
||||||
marginLeft(0f);
|
});
|
||||||
marginRight(0f);
|
|
||||||
marginTop(-5);
|
|
||||||
|
|
||||||
}}.right().bottom().end().get();
|
|
||||||
|
|
||||||
visible(() -> !state.is(State.menu));
|
|
||||||
|
|
||||||
}}.end().get();
|
|
||||||
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
rebuild();
|
rebuild();
|
||||||
}
|
}
|
||||||
@@ -178,7 +145,7 @@ public class BlocksFragment extends Fragment{
|
|||||||
//scrollpane for recipes
|
//scrollpane for recipes
|
||||||
ScrollPane pane = new ScrollPane(recipeTable, "clear-black");
|
ScrollPane pane = new ScrollPane(recipeTable, "clear-black");
|
||||||
pane.setOverscroll(false, false);
|
pane.setOverscroll(false, false);
|
||||||
pane.setVisible(catb::isChecked);
|
pane.visible(catb::isChecked);
|
||||||
pane.setScrollYForce(lastScroll);
|
pane.setScrollYForce(lastScroll);
|
||||||
pane.update(() -> {
|
pane.update(() -> {
|
||||||
Element e = Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true);
|
Element e = Core.scene.hit(Graphics.mouse().x, Graphics.mouse().y, true);
|
||||||
@@ -288,7 +255,7 @@ public class BlocksFragment extends Fragment{
|
|||||||
selectTable.add(stack).growX().left().top().colspan(Category.values().length).padBottom(-5).height((size + 12) * rowsUsed);
|
selectTable.add(stack).growX().left().top().colspan(Category.values().length).padBottom(-5).height((size + 12) * rowsUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void toggle(boolean show, float t, Interpolation ip){
|
void toggle(float t, Interpolation ip){
|
||||||
if(shown){
|
if(shown){
|
||||||
shown = false;
|
shown = false;
|
||||||
mainTable.actions(Actions.translateBy(0, mainTable.getTranslation().y + (-mainTable.getHeight() - descTable.getHeight()), t, ip));
|
mainTable.actions(Actions.translateBy(0, mainTable.getTranslation().y + (-mainTable.getHeight() - descTable.getHeight()), t, ip));
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public class ChatFragment extends Table{
|
|||||||
setFillParent(true);
|
setFillParent(true);
|
||||||
font = Core.skin.getFont("default-font");
|
font = Core.skin.getFont("default-font");
|
||||||
|
|
||||||
setVisible(() -> !state.is(State.menu) && Net.active());
|
visible(() -> !state.is(State.menu) && Net.active());
|
||||||
|
|
||||||
update(() -> {
|
update(() -> {
|
||||||
if(!Net.active() && chatOpen){
|
if(!Net.active() && chatOpen){
|
||||||
|
|||||||
@@ -14,12 +14,8 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
|||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.EntityGroup;
|
import io.anuke.ucore.entities.EntityGroup;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.builders.button;
|
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
import io.anuke.ucore.scene.style.TextureRegionDrawable;
|
||||||
import io.anuke.ucore.scene.ui.Label;
|
import io.anuke.ucore.scene.ui.Label;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
import io.anuke.ucore.util.Log.LogHandler;
|
import io.anuke.ucore.util.Log.LogHandler;
|
||||||
@@ -43,10 +39,6 @@ public class DebugFragment extends Fragment{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printDebugInfo(){
|
|
||||||
Gdx.app.error("Minudstry Info Dump", debugInfo());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String debugInfo(){
|
public static String debugInfo(){
|
||||||
int totalUnits = 0;
|
int totalUnits = 0;
|
||||||
for(EntityGroup<?> group : unitGroups){
|
for(EntityGroup<?> group : unitGroups){
|
||||||
@@ -120,43 +112,41 @@ public class DebugFragment extends Fragment{
|
|||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
|
|
||||||
Player player = players[0];
|
Player player = players[0];
|
||||||
new table(){{
|
parent.fill(c -> {
|
||||||
visible(() -> debug);
|
c.bottom().left().visible(() -> debug);
|
||||||
|
|
||||||
abottom().aleft();
|
c.table("pane", t -> {
|
||||||
|
t.defaults().fillX().width(100f);
|
||||||
|
|
||||||
new table("pane"){{
|
t.label(() -> Gdx.app.getJavaHeap() / 1024 / 1024 + "MB");
|
||||||
defaults().fillX().width(100f);
|
t.row();
|
||||||
|
|
||||||
new label(() -> Gdx.app.getJavaHeap() / 1024 / 1024 + "MB");
|
t.add("Debug");
|
||||||
row();
|
t.row();
|
||||||
|
t.addButton("noclip", "toggle", () -> noclip = !noclip);
|
||||||
new label("Debug");
|
t.row();
|
||||||
row();
|
t.addButton("items", () -> {
|
||||||
new button("noclip", "toggle", () -> noclip = !noclip);
|
|
||||||
row();
|
|
||||||
new button("items", () -> {
|
|
||||||
for(int i = 0; i < 10; i++){
|
for(int i = 0; i < 10; i++){
|
||||||
ItemDrop.create(Item.all().random(), 5, player.x, player.y, Mathf.random(360f));
|
ItemDrop.create(Item.all().random(), 5, player.x, player.y, Mathf.random(360f));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
row();
|
t.row();
|
||||||
new button("team", "toggle", player::toggleTeam);
|
t.addButton("team", "toggle", player::toggleTeam);
|
||||||
row();
|
t.row();
|
||||||
new button("blocks", "toggle", () -> showBlockDebug = !showBlockDebug);
|
t.addButton("blocks", "toggle", () -> showBlockDebug = !showBlockDebug);
|
||||||
row();
|
t.row();
|
||||||
new button("fog", () -> showFog = !showFog);
|
t.addButton("fog", () -> showFog = !showFog);
|
||||||
row();
|
t.row();
|
||||||
new button("gameover", () -> {
|
t.addButton("gameover", () -> {
|
||||||
state.teams.get(Team.blue).cores.get(0).entity.health = 0;
|
state.teams.get(Team.blue).cores.get(0).entity.health = 0;
|
||||||
state.teams.get(Team.blue).cores.get(0).entity.damage(1);
|
state.teams.get(Team.blue).cores.get(0).entity.damage(1);
|
||||||
});
|
});
|
||||||
row();
|
t.row();
|
||||||
new button("wave", () -> state.wavetime = 0f);
|
t.addButton("wave", () -> state.wavetime = 0f);
|
||||||
row();
|
t.row();
|
||||||
new button("death", () -> player.damage(99999, true));
|
t.addButton("death", () -> player.damage(99999, true));
|
||||||
row();
|
t.row();
|
||||||
new button("spawn", () -> {
|
t.addButton("spawn", () -> {
|
||||||
FloatingDialog dialog = new FloatingDialog("debug spawn");
|
FloatingDialog dialog = new FloatingDialog("debug spawn");
|
||||||
for(UnitType type : UnitType.all()){
|
for(UnitType type : UnitType.all()){
|
||||||
dialog.content().addImageButton("white", 40, () -> {
|
dialog.content().addImageButton("white", 40, () -> {
|
||||||
@@ -171,27 +161,20 @@ public class DebugFragment extends Fragment{
|
|||||||
dialog.setFillParent(false);
|
dialog.setFillParent(false);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
});
|
});
|
||||||
row();
|
t.row();
|
||||||
}}.end();
|
});
|
||||||
|
});
|
||||||
row();
|
|
||||||
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
|
|
||||||
new table(){{
|
parent.fill(t -> {
|
||||||
visible(() -> console);
|
t.top().left().visible(() -> console);
|
||||||
|
|
||||||
atop().aleft();
|
t.table("pane", p -> {
|
||||||
|
p.defaults().fillX();
|
||||||
|
|
||||||
new table("pane"){{
|
p.pane("clear", new Label(DebugFragment::debugInfo));
|
||||||
defaults().fillX();
|
p.row();
|
||||||
|
p.addButton("dump", () -> {
|
||||||
ScrollPane pane = new ScrollPane(new Label(DebugFragment::debugInfo), "clear");
|
|
||||||
|
|
||||||
add(pane);
|
|
||||||
row();
|
|
||||||
new button("dump", () -> {
|
|
||||||
try{
|
try{
|
||||||
FileHandle file = Gdx.files.local("packet-dump.txt");
|
FileHandle file = Gdx.files.local("packet-dump.txt");
|
||||||
file.writeString("--INFO--\n", false);
|
file.writeString("--INFO--\n", false);
|
||||||
@@ -202,20 +185,16 @@ public class DebugFragment extends Fragment{
|
|||||||
ui.showError("Error dumping log.");
|
ui.showError("Error dumping log.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}.end();
|
});
|
||||||
}}.end();
|
});
|
||||||
|
|
||||||
new table(){{
|
parent.fill(t -> {
|
||||||
visible(() -> console);
|
t.top().visible(() -> console);
|
||||||
|
|
||||||
atop();
|
|
||||||
|
|
||||||
Table table = new Table("pane");
|
Table table = new Table("pane");
|
||||||
table.label(() -> log.toString());
|
table.label(() -> log.toString());
|
||||||
|
|
||||||
ScrollPane pane = new ScrollPane(table, "clear");
|
t.pane("clear", table);
|
||||||
|
});
|
||||||
get().add(pane);
|
|
||||||
}}.end();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
@@ -20,9 +19,6 @@ import io.anuke.ucore.core.Settings;
|
|||||||
import io.anuke.ucore.scene.Element;
|
import io.anuke.ucore.scene.Element;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.Image;
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
@@ -37,7 +33,6 @@ public class HudFragment extends Fragment{
|
|||||||
public final BlocksFragment blockfrag = new BlocksFragment();
|
public final BlocksFragment blockfrag = new BlocksFragment();
|
||||||
|
|
||||||
private ImageButton menu, flip;
|
private ImageButton menu, flip;
|
||||||
private Table respawntable;
|
|
||||||
private Table wavetable;
|
private Table wavetable;
|
||||||
private Table infolabel;
|
private Table infolabel;
|
||||||
private Table lastUnlockTable;
|
private Table lastUnlockTable;
|
||||||
@@ -49,124 +44,93 @@ public class HudFragment extends Fragment{
|
|||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
|
|
||||||
//menu at top left
|
//menu at top left
|
||||||
new table(){{
|
parent.fill(cont -> {
|
||||||
atop();
|
|
||||||
aleft();
|
|
||||||
|
|
||||||
new table(){{
|
cont.top().left().visible(() -> !state.is(State.menu));
|
||||||
|
|
||||||
new table(){{
|
cont.table(select -> {
|
||||||
left();
|
select.left();
|
||||||
defaults().size(dsize).left();
|
select.defaults().size(dsize).left();
|
||||||
|
|
||||||
menu = new imagebutton("icon-menu", isize, ui.paused::show).get();
|
menu = select.addImageButton("icon-menu", isize, ui.paused::show).get();
|
||||||
flip = new imagebutton("icon-arrow-up", isize, () -> toggleMenus()).get();
|
flip = select.addImageButton("icon-arrow-up", isize, this::toggleMenus).get();
|
||||||
|
|
||||||
update(t -> {
|
select.update(() -> {
|
||||||
if(Inputs.keyTap("toggle_menus") && !ui.chatfrag.chatOpen()){
|
if(Inputs.keyTap("toggle_menus") && !ui.chatfrag.chatOpen()){
|
||||||
toggleMenus();
|
toggleMenus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new imagebutton("icon-pause", isize, () -> {
|
select.addImageButton("icon-pause", isize, () -> {
|
||||||
if(Net.active()){
|
if(Net.active()){
|
||||||
ui.listfrag.toggle();
|
ui.listfrag.toggle();
|
||||||
|
}else{
|
||||||
|
state.set(state.is(State.paused) ? State.playing : State.paused);
|
||||||
|
}
|
||||||
|
}).update(i -> {
|
||||||
|
if(Net.active()){
|
||||||
|
i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
|
||||||
|
}else{
|
||||||
|
i.setDisabled(Net.active());
|
||||||
|
i.getStyle().imageUp = Core.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
|
||||||
|
select.addImageButton("icon-settings", isize, () -> {
|
||||||
|
if(Net.active() && mobile){
|
||||||
|
if(ui.chatfrag.chatOpen()){
|
||||||
|
ui.chatfrag.hide();
|
||||||
}else{
|
}else{
|
||||||
state.set(state.is(State.paused) ? State.playing : State.paused);
|
ui.chatfrag.toggle();
|
||||||
}
|
}
|
||||||
}).update(i -> {
|
}else{
|
||||||
if(Net.active()){
|
ui.settings.show();
|
||||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-players");
|
}
|
||||||
}else{
|
}).update(i -> {
|
||||||
i.setDisabled(Net.active());
|
if(Net.active() && mobile){
|
||||||
i.getStyle().imageUp = Core.skin.getDrawable(state.is(State.paused) ? "icon-play" : "icon-pause");
|
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
|
||||||
}
|
}else{
|
||||||
}).get();
|
i.getStyle().imageUp = Core.skin.getDrawable("icon-settings");
|
||||||
|
}
|
||||||
|
}).get();
|
||||||
|
});
|
||||||
|
|
||||||
new imagebutton("icon-settings", isize, () -> {
|
cont.row();
|
||||||
if(Net.active() && mobile){
|
|
||||||
if(ui.chatfrag.chatOpen()){
|
|
||||||
ui.chatfrag.hide();
|
|
||||||
}else{
|
|
||||||
ui.chatfrag.toggle();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
ui.settings.show();
|
|
||||||
}
|
|
||||||
}).update(i -> {
|
|
||||||
if(Net.active() && mobile){
|
|
||||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-chat");
|
|
||||||
}else{
|
|
||||||
i.getStyle().imageUp = Core.skin.getDrawable("icon-settings");
|
|
||||||
}
|
|
||||||
}).get();
|
|
||||||
|
|
||||||
}}.end();
|
cont.table(this::addWaveTable).touchable(Touchable.enabled).fillX().height(66f);
|
||||||
|
|
||||||
row();
|
cont.row();
|
||||||
|
|
||||||
new table(){{
|
//fps display
|
||||||
touchable(Touchable.enabled);
|
infolabel = cont.table(t -> {
|
||||||
addWaveTable();
|
IntFormat fps = new IntFormat("text.fps");
|
||||||
}}.fillX().end();
|
IntFormat tps = new IntFormat("text.tps");
|
||||||
|
IntFormat ping = new IntFormat("text.ping");
|
||||||
|
t.label(() -> fps.get(Gdx.graphics.getFramesPerSecond())).padRight(10);
|
||||||
|
t.label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled());
|
||||||
|
t.row();
|
||||||
|
t.label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
|
||||||
|
}).size(-1).visible(() -> Settings.getBool("fps")).get();
|
||||||
|
|
||||||
row();
|
//make wave box appear below rest of menu
|
||||||
|
cont.swapActor(wavetable, menu.getParent());
|
||||||
|
});
|
||||||
|
|
||||||
visible(() -> !state.is(State.menu));
|
//minimap
|
||||||
row();
|
parent.fill(t -> t.top().right().add(new Minimap())
|
||||||
new table(){{
|
.visible(() -> !state.is(State.menu) && Settings.getBool("minimap")));
|
||||||
IntFormat fps = new IntFormat("text.fps");
|
|
||||||
IntFormat tps = new IntFormat("text.tps");
|
|
||||||
IntFormat ping = new IntFormat("text.ping");
|
|
||||||
new label(() -> fps.get(Gdx.graphics.getFramesPerSecond())).padRight(10);
|
|
||||||
new label(() -> tps.get(threads.getTPS())).visible(() -> threads.isEnabled());
|
|
||||||
row();
|
|
||||||
new label(() -> ping.get(Net.getPing())).visible(() -> Net.client() && !gwt).colspan(2);
|
|
||||||
|
|
||||||
infolabel = get();
|
|
||||||
}}.size(-1).end().visible(() -> Settings.getBool("fps"));
|
|
||||||
|
|
||||||
}}.end();
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
new table(){{
|
|
||||||
visible(() -> !state.is(State.menu));
|
|
||||||
atop();
|
|
||||||
aright();
|
|
||||||
|
|
||||||
Minimap minimap = new Minimap();
|
|
||||||
|
|
||||||
add(minimap).visible(() -> Settings.getBool("minimap"));
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
//paused table
|
//paused table
|
||||||
new table(){{
|
parent.fill(t -> {
|
||||||
visible(() -> state.is(State.paused) && !Net.active());
|
t.top().visible(() -> state.is(State.paused) && !Net.active());
|
||||||
atop();
|
t.table(top -> top.add("[orange]< " + Bundles.get("text.paused") + " >").pad(6).get().setFontScale(fontScale * 0.75f));
|
||||||
|
});
|
||||||
|
|
||||||
new table("pane"){{
|
//'saving' indicator
|
||||||
new label("[orange]< " + Bundles.get("text.paused") + " >").scale(0.75f).pad(6);
|
parent.fill(t -> {
|
||||||
}}.end();
|
t.bottom().visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
||||||
}}.end();
|
t.add("$text.saveload");
|
||||||
|
});
|
||||||
//respawn background table
|
|
||||||
new table("white"){{
|
|
||||||
respawntable = get();
|
|
||||||
respawntable.setColor(Color.CLEAR);
|
|
||||||
update(t -> {
|
|
||||||
if(state.is(State.menu)){
|
|
||||||
respawntable.setColor(Color.CLEAR);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
new table(){{
|
|
||||||
abottom();
|
|
||||||
visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
|
||||||
|
|
||||||
new label("$text.saveload");
|
|
||||||
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
blockfrag.build(Core.scene.getRoot());
|
blockfrag.build(Core.scene.getRoot());
|
||||||
}
|
}
|
||||||
@@ -281,12 +245,12 @@ public class HudFragment extends Fragment{
|
|||||||
|
|
||||||
if(shown){
|
if(shown){
|
||||||
shown = false;
|
shown = false;
|
||||||
blockfrag.toggle(false, dur, in);
|
blockfrag.toggle(dur, in);
|
||||||
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + dsize) - wavetable.getTranslation().y, dur, in));
|
wavetable.actions(Actions.translateBy(0, (wavetable.getHeight() + dsize) - wavetable.getTranslation().y, dur, in));
|
||||||
infolabel.actions(Actions.translateBy(0, (wavetable.getHeight()) - wavetable.getTranslation().y, dur, in));
|
infolabel.actions(Actions.translateBy(0, (wavetable.getHeight()) - wavetable.getTranslation().y, dur, in));
|
||||||
}else{
|
}else{
|
||||||
shown = true;
|
shown = true;
|
||||||
blockfrag.toggle(true, dur, in);
|
blockfrag.toggle(dur, in);
|
||||||
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
|
wavetable.actions(Actions.translateBy(0, -wavetable.getTranslation().y, dur, in));
|
||||||
infolabel.actions(Actions.translateBy(0, -infolabel.getTranslation().y, dur, in));
|
infolabel.actions(Actions.translateBy(0, -infolabel.getTranslation().y, dur, in));
|
||||||
}
|
}
|
||||||
@@ -301,40 +265,30 @@ public class HudFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addWaveTable(){
|
private void addWaveTable(Table table){
|
||||||
|
wavetable = table;
|
||||||
float uheight = 66f;
|
float uheight = 66f;
|
||||||
|
|
||||||
IntFormat wavef = new IntFormat("text.wave");
|
IntFormat wavef = new IntFormat("text.wave");
|
||||||
IntFormat timef = new IntFormat("text.wave.waiting");
|
IntFormat timef = new IntFormat("text.wave.waiting");
|
||||||
|
|
||||||
wavetable = new table("button"){{
|
table.background("button");
|
||||||
aleft();
|
table.left().table(text -> {
|
||||||
new table(){{
|
text.left();
|
||||||
aleft();
|
text.label(() -> wavef.get(state.wave)).left().get().setFontScale(fontScale * 1.5f);
|
||||||
|
text.row();
|
||||||
|
text.label(() -> unitGroups[Team.red.ordinal()].size() > 0 && state.mode.disableWaveTimer ?
|
||||||
|
getEnemiesRemaining() : (state.mode.disableWaveTimer) ? "$text.waiting" :
|
||||||
|
timef.get((int) (state.wavetime / 60f))).minWidth(126).left();
|
||||||
|
});
|
||||||
|
|
||||||
new label(() -> wavef.get(state.wave)).scale(fontScale * 1.5f).left().padLeft(-6);
|
table.add().growX();
|
||||||
|
|
||||||
row();
|
playButton(uheight);
|
||||||
|
|
||||||
new label(() -> unitGroups[Team.red.ordinal()].size() > 0 && state.mode.disableWaveTimer ?
|
|
||||||
getEnemiesRemaining() :
|
|
||||||
(state.mode.disableWaveTimer) ? "$text.waiting"
|
|
||||||
: timef.get((int) (state.wavetime / 60f)))
|
|
||||||
.minWidth(126).padLeft(-6).left();
|
|
||||||
|
|
||||||
margin(10f);
|
|
||||||
get().marginLeft(6);
|
|
||||||
}}.left().end();
|
|
||||||
|
|
||||||
add().growX();
|
|
||||||
|
|
||||||
playButton(uheight);
|
|
||||||
}}.height(uheight).fillX().expandX().end().get();
|
|
||||||
wavetable.getParent().getParent().swapActor(wavetable.getParent(), menu.getParent());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void playButton(float uheight){
|
private void playButton(float uheight){
|
||||||
new imagebutton("icon-play", 30f, () -> {
|
wavetable.addImageButton("icon-play", 30f, () -> {
|
||||||
if(Net.client() && players[0].isAdmin){
|
if(Net.client() && players[0].isAdmin){
|
||||||
Call.onAdminRequest(players[0], AdminAction.wave);
|
Call.onAdminRequest(players[0], AdminAction.wave);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.ucore.function.Listenable;
|
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.Label;
|
import io.anuke.ucore.scene.ui.Label;
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
@@ -16,32 +13,24 @@ public class LoadingFragment extends Fragment{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
|
parent.fill("loadDim", t -> {
|
||||||
|
t.setVisible(false);
|
||||||
|
t.setTouchable(Touchable.enabled);
|
||||||
|
t.add().height(70f).row();
|
||||||
|
|
||||||
table = new table("loadDim"){{
|
t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
||||||
add().height(70f).row();
|
t.row();
|
||||||
|
t.add("$text.loading").name("namelabel").pad(10f);
|
||||||
|
t.row();
|
||||||
|
t.addImage("white").growX().height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
||||||
|
t.row();
|
||||||
|
|
||||||
touchable(Touchable.enabled);
|
button = t.addButton("$text.cancel", () -> {}).pad(20).size(250f, 70f).visible(false).get();
|
||||||
get().addImage("white").growX()
|
table = t;
|
||||||
.height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
});
|
||||||
row();
|
|
||||||
new label("$text.loading"){{
|
|
||||||
get().setName("namelabel");
|
|
||||||
}}.pad(10);
|
|
||||||
row();
|
|
||||||
get().addImage("white").growX()
|
|
||||||
.height(3f).pad(4f).growX().get().setColor(Palette.accent);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
button = get().addButton("$text.cancel", () -> {
|
|
||||||
}).pad(20).size(250f, 70f).get();
|
|
||||||
button.setVisible(false);
|
|
||||||
}}.end().get();
|
|
||||||
|
|
||||||
table.setVisible(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setButton(Listenable listener){
|
public void setButton(Runnable listener){
|
||||||
button.setVisible(true);
|
button.setVisible(true);
|
||||||
button.getListeners().removeIndex(button.getListeners().size - 1);
|
button.getListeners().removeIndex(button.getListeners().size - 1);
|
||||||
button.clicked(listener);
|
button.clicked(listener);
|
||||||
|
|||||||
@@ -10,65 +10,49 @@ import io.anuke.mindustry.ui.MobileButton;
|
|||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
import io.anuke.ucore.core.Events;
|
import io.anuke.ucore.core.Events;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.builders.build;
|
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class MenuFragment extends Fragment{
|
public class MenuFragment extends Fragment{
|
||||||
private Table mobileContainer;
|
private Table container;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
new table(){{
|
parent.fill(c -> {
|
||||||
visible(() -> state.is(State.menu));
|
container = c;
|
||||||
|
container.visible(() -> state.is(State.menu));
|
||||||
|
|
||||||
if(!mobile){
|
if(!mobile){
|
||||||
buildDesktop();
|
buildDesktop();
|
||||||
}else{
|
}else{
|
||||||
buildMobile();
|
buildMobile();
|
||||||
|
Events.on(ResizeEvent.class, this::buildMobile);
|
||||||
Events.on(ResizeEvent.class, () -> buildMobile());
|
|
||||||
}
|
}
|
||||||
}}.end();
|
});
|
||||||
|
|
||||||
//discord icon in top right
|
//discord icon in top right
|
||||||
if(Platform.instance.hasDiscord()){
|
parent.fill(c -> c.top().right().addButton("", "discord", ui.discord::show).size(81, 42)
|
||||||
new table(){{
|
.visible(() -> state.is(State.menu)));
|
||||||
abottom().atop().aright();
|
|
||||||
get().addButton("", "discord", ui.discord::show).size(81, 42);
|
|
||||||
}}.end().visible(() -> state.is(State.menu));
|
|
||||||
}
|
|
||||||
|
|
||||||
//info icon
|
//info icon
|
||||||
if(mobile){
|
if(mobile){
|
||||||
new table(){{
|
parent.fill(c -> c.top().left().addButton("", "info", ui.about::show).size(81, 42)
|
||||||
abottom().atop().aleft();
|
.visible(() -> state.is(State.menu)));
|
||||||
get().addButton("", "info", ui.about::show).size(81, 42);
|
|
||||||
}}.end().visible(() -> state.is(State.menu));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//version info
|
//version info
|
||||||
new table(){{
|
parent.fill(c -> c.bottom().left().add("Mindustry " + Version.code + " " + Version.type + " / " + Version.buildName)
|
||||||
visible(() -> state.is(State.menu));
|
.visible(() -> state.is(State.menu)));
|
||||||
abottom().aleft();
|
|
||||||
new label("Mindustry " + Version.code + " " + Version.type + " / " + Version.buildName);
|
|
||||||
}}.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildMobile(){
|
private void buildMobile(){
|
||||||
if(mobileContainer == null){
|
container.clear();
|
||||||
mobileContainer = build.getTable();
|
container.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
}
|
|
||||||
|
|
||||||
mobileContainer.clear();
|
|
||||||
mobileContainer.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
||||||
|
|
||||||
float size = 120f;
|
float size = 120f;
|
||||||
float isize = 14f * 4;
|
float isize = 14f * 4;
|
||||||
mobileContainer.defaults().size(size).pad(5).padTop(4f);
|
container.defaults().size(size).pad(5).padTop(4f);
|
||||||
|
|
||||||
MobileButton
|
MobileButton
|
||||||
play = new MobileButton("icon-play-2", isize, "$text.play", ui.levels::show),
|
play = new MobileButton("icon-play-2", isize, "$text.play", ui.levels::show),
|
||||||
@@ -81,14 +65,14 @@ public class MenuFragment extends Fragment{
|
|||||||
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
|
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
|
||||||
|
|
||||||
if(Gdx.graphics.getWidth() > Gdx.graphics.getHeight()){
|
if(Gdx.graphics.getWidth() > Gdx.graphics.getHeight()){
|
||||||
mobileContainer.add(play);
|
container.add(play);
|
||||||
mobileContainer.add(join);
|
container.add(join);
|
||||||
mobileContainer.add(load);
|
container.add(load);
|
||||||
mobileContainer.add(maps);
|
container.add(maps);
|
||||||
mobileContainer.row();
|
container.row();
|
||||||
|
|
||||||
mobileContainer.table(table -> {
|
container.table(table -> {
|
||||||
table.defaults().set(mobileContainer.defaults());
|
table.defaults().set(container.defaults());
|
||||||
|
|
||||||
table.add(editor);
|
table.add(editor);
|
||||||
table.add(tools);
|
table.add(tools);
|
||||||
@@ -97,18 +81,18 @@ public class MenuFragment extends Fragment{
|
|||||||
if(Platform.instance.canDonate()) table.add(donate);
|
if(Platform.instance.canDonate()) table.add(donate);
|
||||||
}).colspan(4);
|
}).colspan(4);
|
||||||
}else{
|
}else{
|
||||||
mobileContainer.add(play);
|
container.add(play);
|
||||||
mobileContainer.add(maps);
|
container.add(maps);
|
||||||
mobileContainer.row();
|
container.row();
|
||||||
mobileContainer.add(load);
|
container.add(load);
|
||||||
mobileContainer.add(join);
|
container.add(join);
|
||||||
mobileContainer.row();
|
container.row();
|
||||||
mobileContainer.add(editor);
|
container.add(editor);
|
||||||
mobileContainer.add(tools);
|
container.add(tools);
|
||||||
mobileContainer.row();
|
container.row();
|
||||||
|
|
||||||
mobileContainer.table(table -> {
|
container.table(table -> {
|
||||||
table.defaults().set(mobileContainer.defaults());
|
table.defaults().set(container.defaults());
|
||||||
|
|
||||||
table.add(unlocks);
|
table.add(unlocks);
|
||||||
|
|
||||||
@@ -118,41 +102,40 @@ public class MenuFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void buildDesktop(){
|
private void buildDesktop(){
|
||||||
new table(){{
|
container.table(out -> {
|
||||||
|
|
||||||
float w = 200f;
|
float w = 200f;
|
||||||
float bw = w * 2f + 10f;
|
float bw = w * 2f + 10f;
|
||||||
|
|
||||||
defaults().size(w, 66f).padTop(5).padRight(5);
|
out.margin(16);
|
||||||
|
out.defaults().size(w, 66f).padTop(5).padRight(5);
|
||||||
|
|
||||||
add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
out.add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
||||||
|
|
||||||
row();
|
out.row();
|
||||||
|
|
||||||
add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
|
out.add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
|
||||||
|
|
||||||
add(new MenuButton("icon-map", "$text.maps", ui.maps::show));
|
out.add(new MenuButton("icon-map", "$text.maps", ui.maps::show));
|
||||||
|
|
||||||
row();
|
out.row();
|
||||||
|
|
||||||
add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
out.add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
||||||
|
|
||||||
add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
out.add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
||||||
|
|
||||||
row();
|
out.row();
|
||||||
|
|
||||||
add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
out.add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
||||||
|
|
||||||
add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
out.add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
||||||
|
|
||||||
row();
|
out.row();
|
||||||
|
|
||||||
if(!gwt){
|
if(!gwt){
|
||||||
add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
out.add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
get().margin(16);
|
|
||||||
}}.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPlaySelect(){
|
private void showPlaySelect(){
|
||||||
|
|||||||
@@ -10,12 +10,8 @@ import io.anuke.mindustry.net.Packets.AdminAction;
|
|||||||
import io.anuke.mindustry.ui.BorderImage;
|
import io.anuke.mindustry.ui.BorderImage;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.builders.button;
|
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.Image;
|
import io.anuke.ucore.scene.ui.Image;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
@@ -24,44 +20,14 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
public class PlayerListFragment extends Fragment{
|
public class PlayerListFragment extends Fragment{
|
||||||
private boolean visible = false;
|
private boolean visible = false;
|
||||||
private Table content = new Table();
|
private Table content = new Table().marginRight(13f).marginLeft(13f);
|
||||||
private ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
private ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
new table(){{
|
parent.fill(cont -> {
|
||||||
new table("pane"){{
|
cont.visible(() -> visible);
|
||||||
touchable(Touchable.enabled);
|
cont.update(() -> {
|
||||||
margin(14f);
|
|
||||||
new label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" :
|
|
||||||
"text.players", playerGroup.size()));
|
|
||||||
row();
|
|
||||||
content.marginRight(13f).marginLeft(13f);
|
|
||||||
ScrollPane pane = new ScrollPane(content, "clear");
|
|
||||||
pane.setScrollingDisabled(true, false);
|
|
||||||
pane.setFadeScrollBars(false);
|
|
||||||
add(pane).grow();
|
|
||||||
row();
|
|
||||||
new table("pane"){{
|
|
||||||
margin(0f);
|
|
||||||
defaults().growX().height(50f).fillY();
|
|
||||||
|
|
||||||
//get().addCheck("$text.server.friendlyfire", b -> {
|
|
||||||
// CallClient.friendlyFireChange(b);
|
|
||||||
//}).left().padLeft(-12).pad(0).update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5);
|
|
||||||
|
|
||||||
new button("$text.server.bans", () -> {
|
|
||||||
ui.bans.show();
|
|
||||||
}).cell.disabled(b -> Net.client());
|
|
||||||
|
|
||||||
new button("$text.server.admins", () -> {
|
|
||||||
ui.admins.show();
|
|
||||||
}).cell.disabled(b -> Net.client());
|
|
||||||
|
|
||||||
}}.pad(10f).growX().end();
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
update(t -> {
|
|
||||||
if(!(Net.active() && !state.is(State.menu))){
|
if(!(Net.active() && !state.is(State.menu))){
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
@@ -85,8 +51,22 @@ public class PlayerListFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
visible(() -> visible);
|
cont.table("pane", pane -> {
|
||||||
}}.end();
|
pane.label(() -> Bundles.format(playerGroup.size() == 1 ? "text.players.single" : "text.players", playerGroup.size()));
|
||||||
|
pane.row();
|
||||||
|
pane.pane("clear", content)
|
||||||
|
.grow().get().setScrollingDisabled(true, false);
|
||||||
|
pane.row();
|
||||||
|
|
||||||
|
pane.table("pane", menu -> {
|
||||||
|
menu.defaults().growX().height(50f).fillY();
|
||||||
|
|
||||||
|
menu.addButton("$text.server.bans", ui.bans::show).disabled(b -> Net.client());
|
||||||
|
menu.addButton("$text.server.admins", ui.admins::show).disabled(b -> Net.client());
|
||||||
|
}).margin(0f).pad(10f).growX();
|
||||||
|
|
||||||
|
}).touchable(Touchable.enabled).margin(14f);
|
||||||
|
});
|
||||||
|
|
||||||
rebuild();
|
rebuild();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user