Portrait mode support / Mobile fixes
This commit is contained in:
@@ -164,6 +164,11 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
public void endForceLandscape() {
|
public void endForceLandscape() {
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDonate(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -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 = 'd28a0e7969'
|
uCoreVersion = '2e6aa0a1df'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
BIN
core/assets-raw/sprites/ui/info-banner.png
Normal file
BIN
core/assets-raw/sprites/ui/info-banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 B |
@@ -352,6 +352,7 @@ setting.vsync.name=VSync
|
|||||||
setting.lasers.name=Show Power Lasers
|
setting.lasers.name=Show Power Lasers
|
||||||
setting.previewopacity.name=Placing Preview Opacity
|
setting.previewopacity.name=Placing Preview Opacity
|
||||||
setting.healthbars.name=Show Entity Health bars
|
setting.healthbars.name=Show Entity Health bars
|
||||||
|
setting.minimap.name=Show Minimap
|
||||||
setting.pixelate.name=Pixelate Screen
|
setting.pixelate.name=Pixelate Screen
|
||||||
setting.musicvol.name=Music Volume
|
setting.musicvol.name=Music Volume
|
||||||
setting.mutemusic.name=Mute Music
|
setting.mutemusic.name=Mute Music
|
||||||
@@ -425,7 +426,9 @@ item.biomatter.description=A clump of organic mush; used for conversion into oil
|
|||||||
item.sand.name=Sand
|
item.sand.name=Sand
|
||||||
item.sand.description=A common material that is used extensively in smelting, both in alloying and as a flux.
|
item.sand.description=A common material that is used extensively in smelting, both in alloying and as a flux.
|
||||||
item.blast-compound.name=Blast Compound
|
item.blast-compound.name=Blast Compound
|
||||||
item.thermite.name=Thermite
|
item.blast-compound.description=A volatile compound used in bombs and explosives. While it can burned as fuel, this is not advised.
|
||||||
|
item.pyratite.name=Pyratite
|
||||||
|
item.pyratite.description=An extremely flammable substance used in incendiary weapons.
|
||||||
|
|
||||||
liquid.water.name=Water
|
liquid.water.name=Water
|
||||||
liquid.lava.name=Lava
|
liquid.lava.name=Lava
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 132 KiB |
@@ -53,6 +53,7 @@ io.anuke.ucore.scene.ui.Button$ButtonStyle: {
|
|||||||
io.anuke.ucore.scene.ui.TextButton$TextButtonStyle: {
|
io.anuke.ucore.scene.ui.TextButton$TextButtonStyle: {
|
||||||
default: {over: button-over, disabled: button, font: default-font, fontColor: white, disabledFontColor: grey, down: button-down, up: button, transition: 0 },
|
default: {over: button-over, disabled: button, font: default-font, fontColor: white, disabledFontColor: grey, down: button-down, up: button, transition: 0 },
|
||||||
discord: {over: discord-banner-over, font: default-font, fontColor: white, up: discord-banner},
|
discord: {over: discord-banner-over, font: default-font, fontColor: white, up: discord-banner},
|
||||||
|
info: {font: default-font, fontColor: white, up: info-banner},
|
||||||
clear: {down: clear-down, up: clear, over: clear-over, font: default-font, fontColor: white, disabledFontColor: grey },
|
clear: {down: clear-down, up: clear, over: clear-over, font: default-font, fontColor: white, disabledFontColor: grey },
|
||||||
empty: {font: default-font},
|
empty: {font: default-font},
|
||||||
toggle: {font: default-font, fontColor: white, checked: button-down, down: button-down, up: button, over: button-over, disabled: button, disabledFontColor: grey }
|
toggle: {font: default-font, fontColor: white, checked: button-down, down: button-down, up: button, over: button-over, disabled: button, disabledFontColor: grey }
|
||||||
@@ -72,7 +73,7 @@ io.anuke.ucore.scene.ui.ScrollPane$ScrollPaneStyle: {
|
|||||||
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
default: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
||||||
horizontal: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical, hScroll: scroll-horizontal, hScrollKnob: scroll-knob-horizontal},
|
horizontal: {background: border, vScroll: scroll, vScrollKnob: scroll-knob-vertical, hScroll: scroll-horizontal, hScrollKnob: scroll-knob-horizontal},
|
||||||
volume: {background: button-map, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
volume: {background: button-map, vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
||||||
clear: {vScroll: scroll, vScrollKnob: scroll-knob-vertical},
|
clear: {vScroll: scroll, vScrollKnob: scroll-knob-vertical-black},
|
||||||
clear-black: {vScroll: scroll, vScrollKnob: scroll-knob-vertical-black}
|
clear-black: {vScroll: scroll, vScrollKnob: scroll-knob-vertical-black}
|
||||||
},
|
},
|
||||||
io.anuke.ucore.scene.ui.Window$WindowStyle: {
|
io.anuke.ucore.scene.ui.Window$WindowStyle: {
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ public abstract class Platform {
|
|||||||
public void onGameExit(){}
|
public void onGameExit(){}
|
||||||
/**Open donation dialog. Currently android only.*/
|
/**Open donation dialog. Currently android only.*/
|
||||||
public void openDonations(){}
|
public void openDonations(){}
|
||||||
|
/**Whether donating is supported.*/
|
||||||
|
public boolean canDonate(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
/**Whether discord RPC is supported.*/
|
/**Whether discord RPC is supported.*/
|
||||||
public boolean hasDiscord(){return true;}
|
public boolean hasDiscord(){return true;}
|
||||||
/**Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().*/
|
/**Return the localized name for the locale. This is basically a workaround for GWT not supporting getName().*/
|
||||||
|
|||||||
@@ -5,17 +5,14 @@ import com.badlogic.gdx.Input.Keys;
|
|||||||
import com.badlogic.gdx.graphics.Colors;
|
import com.badlogic.gdx.graphics.Colors;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.badlogic.gdx.utils.Array;
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.editor.MapEditorDialog;
|
import io.anuke.mindustry.editor.MapEditorDialog;
|
||||||
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
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.Core;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.core.Graphics;
|
|
||||||
import io.anuke.ucore.core.Settings;
|
|
||||||
import io.anuke.ucore.core.Timers;
|
|
||||||
import io.anuke.ucore.function.Callable;
|
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.function.Listenable;
|
||||||
@@ -71,7 +68,6 @@ public class UI extends SceneModule{
|
|||||||
public final DebugFragment debugfrag = new DebugFragment();
|
public final DebugFragment debugfrag = new DebugFragment();
|
||||||
|
|
||||||
private Locale lastLocale;
|
private Locale lastLocale;
|
||||||
private Array<Fragment> fragments = new Array<>();
|
|
||||||
|
|
||||||
public UI() {
|
public UI() {
|
||||||
Dialog.setShowAction(()-> sequence(
|
Dialog.setShowAction(()-> sequence(
|
||||||
@@ -158,7 +154,6 @@ public class UI extends SceneModule{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
|
|
||||||
editor = new MapEditorDialog();
|
editor = new MapEditorDialog();
|
||||||
controls = new ControlsDialog();
|
controls = new ControlsDialog();
|
||||||
restart = new RestartDialog();
|
restart = new RestartDialog();
|
||||||
@@ -201,8 +196,11 @@ public class UI extends SceneModule{
|
|||||||
return super.hasMouse();
|
return super.hasMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFragment(Fragment fragment){
|
@Override
|
||||||
fragments.add(fragment);
|
public void resize(int width, int height) {
|
||||||
|
super.resize(width, height);
|
||||||
|
|
||||||
|
Events.fire(ResizeEvent.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getLocale(){
|
public Locale getLocale(){
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
public void build(){
|
public void build(){
|
||||||
float amount = 10f, baseSize = 60f;
|
float amount = 10f, baseSize = 60f;
|
||||||
|
|
||||||
float size = mobile ? (int)(Gdx.graphics.getHeight() / 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(){{
|
new table(){{
|
||||||
|
|||||||
@@ -55,5 +55,9 @@ public class EventType {
|
|||||||
public interface BlockBuildEvent extends Event{
|
public interface BlockBuildEvent extends Event{
|
||||||
void handle(Team team, Tile tile);
|
void handle(Team team, Tile tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ResizeEvent extends Event{
|
||||||
|
void handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -690,11 +690,6 @@ public class AndroidInput extends InputHandler implements GestureListener{
|
|||||||
pinch2.set(initialPointer2);
|
pinch2.set(initialPointer2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 vec = (vector.set(pointer1).add(pointer2).scl(0.5f)).sub(pinch1.add(pinch2).scl(0.5f));
|
|
||||||
|
|
||||||
player.x -= vec.x*Core.camera.zoom/Core.cameraScale;
|
|
||||||
player.y += vec.y*Core.camera.zoom/Core.cameraScale;
|
|
||||||
|
|
||||||
pinch1.set(pointer1);
|
pinch1.set(pointer1);
|
||||||
pinch2.set(pointer2);
|
pinch2.set(pointer2);
|
||||||
|
|
||||||
|
|||||||
15
core/src/io/anuke/mindustry/ui/MobileButton.java
Normal file
15
core/src/io/anuke/mindustry/ui/MobileButton.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import io.anuke.ucore.function.Listenable;
|
||||||
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
|
||||||
|
public class MobileButton extends ImageButton {
|
||||||
|
|
||||||
|
public MobileButton(String icon, float isize, String text, Listenable listener) {
|
||||||
|
super(icon);
|
||||||
|
resizeImage(isize);
|
||||||
|
clicked(listener);
|
||||||
|
row();
|
||||||
|
add(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,9 @@ import io.anuke.mindustry.ui.Links.LinkEntry;
|
|||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
|
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import io.anuke.ucore.scene.utils.UIUtils;
|
||||||
import io.anuke.ucore.util.OS;
|
import io.anuke.ucore.util.OS;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.ios;
|
import static io.anuke.mindustry.Vars.ios;
|
||||||
@@ -20,10 +22,16 @@ public class AboutDialog extends FloatingDialog {
|
|||||||
public AboutDialog(){
|
public AboutDialog(){
|
||||||
super("$text.about.button");
|
super("$text.about.button");
|
||||||
|
|
||||||
addCloseButton();
|
shown(this::setup);
|
||||||
|
onResize(this::setup);
|
||||||
|
}
|
||||||
|
|
||||||
float h = 80f;
|
void setup(){
|
||||||
float w = 600f;
|
content().clear();
|
||||||
|
buttons().clear();
|
||||||
|
|
||||||
|
float h = UIUtils.portrait() ? 90f : 80f;
|
||||||
|
float w = UIUtils.portrait() ? 330f : 600f;
|
||||||
|
|
||||||
Table in = new Table();
|
Table in = new Table();
|
||||||
ScrollPane pane = new ScrollPane(in, "clear");
|
ScrollPane pane = new ScrollPane(in, "clear");
|
||||||
@@ -66,12 +74,20 @@ public class AboutDialog extends FloatingDialog {
|
|||||||
|
|
||||||
content().add(pane).growX();
|
content().add(pane).growX();
|
||||||
|
|
||||||
|
addCloseButton();
|
||||||
|
|
||||||
buttons().addButton("$text.credits", this::showCredits).size(200f, 64f);
|
buttons().addButton("$text.credits", this::showCredits).size(200f, 64f);
|
||||||
|
|
||||||
if(!ios && !OS.isMac){
|
if(!ios && !OS.isMac){
|
||||||
buttons().addButton("$text.changelog.title", ui.changelog::show).size(200f, 64f);
|
buttons().addButton("$text.changelog.title", ui.changelog::show).size(200f, 64f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(UIUtils.portrait()){
|
||||||
|
for(Cell<?> cell : buttons().getCells()){
|
||||||
|
cell.width(140f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showCredits(){
|
public void showCredits(){
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import io.anuke.ucore.scene.event.Touchable;
|
|||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
|
import io.anuke.ucore.scene.utils.UIUtils;
|
||||||
import io.anuke.ucore.util.OS;
|
import io.anuke.ucore.util.OS;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -47,7 +48,7 @@ public class FileChooser extends FloatingDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupWidgets(){
|
private void setupWidgets(){
|
||||||
getCell(content()).maxWidth(Gdx.graphics.getWidth()/Unit.dp.scl(2f));
|
//getCell(content()).maxWidth(UIUtils.portrait() ? Gdx.graphics.getWidth() : Gdx.graphics.getWidth()/Unit.dp.scl(2f));
|
||||||
content().margin(-10);
|
content().margin(-10);
|
||||||
|
|
||||||
Table content = new Table();
|
Table content = new Table();
|
||||||
@@ -79,6 +80,8 @@ public class FileChooser extends FloatingDialog {
|
|||||||
navigation.setTouchable(Touchable.disabled);
|
navigation.setTouchable(Touchable.disabled);
|
||||||
|
|
||||||
files = new Table();
|
files = new Table();
|
||||||
|
files.marginRight(10);
|
||||||
|
files.marginLeft(3);
|
||||||
|
|
||||||
pane = new ScrollPane(files){
|
pane = new ScrollPane(files){
|
||||||
public float getPrefHeight(){
|
public float getPrefHeight(){
|
||||||
@@ -142,7 +145,7 @@ public class FileChooser extends FloatingDialog {
|
|||||||
content.add(icontable).expandX().fillX();
|
content.add(icontable).expandX().fillX();
|
||||||
content.row();
|
content.row();
|
||||||
|
|
||||||
content.center().add(pane).width(Gdx.graphics.getWidth()/Unit.dp.scl(2)).colspan(3).grow();
|
content.center().add(pane).width(UIUtils.portrait() ? Gdx.graphics.getWidth() : Gdx.graphics.getWidth()/Unit.dp.scl(2)).colspan(3).grow();
|
||||||
content.row();
|
content.row();
|
||||||
|
|
||||||
if(!open){
|
if(!open){
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ package io.anuke.mindustry.ui.dialogs;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Keys;
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
|
import io.anuke.ucore.core.Events;
|
||||||
import io.anuke.ucore.scene.ui.Dialog;
|
import io.anuke.ucore.scene.ui.Dialog;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
|
|
||||||
@@ -31,6 +33,14 @@ public class FloatingDialog extends Dialog{
|
|||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onResize(Runnable run){
|
||||||
|
Events.on(ResizeEvent.class, () -> {
|
||||||
|
if(isShown()){
|
||||||
|
run.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addCloseButton(){
|
public void addCloseButton(){
|
||||||
buttons().addImageTextButton("$text.back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
buttons().addImageTextButton("$text.back", "icon-arrow-left", 30f, this::hide).size(230f, 64f);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import io.anuke.ucore.scene.ui.ScrollPane;
|
|||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Cell;
|
import io.anuke.ucore.scene.ui.layout.Cell;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import io.anuke.ucore.scene.utils.UIUtils;
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
@@ -31,7 +32,6 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
Table local = new Table();
|
Table local = new Table();
|
||||||
Table remote = new Table();
|
Table remote = new Table();
|
||||||
Table hosts = new Table();
|
Table hosts = new Table();
|
||||||
float w = 500;
|
|
||||||
|
|
||||||
public JoinDialog(){
|
public JoinDialog(){
|
||||||
super("$text.joingame");
|
super("$text.joingame");
|
||||||
@@ -77,12 +77,13 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
add.getTitleLabel().setText(renaming != null ? "$text.server.edit" : "$text.server.add");
|
add.getTitleLabel().setText(renaming != null ? "$text.server.edit" : "$text.server.add");
|
||||||
});
|
});
|
||||||
|
|
||||||
setup();
|
|
||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
|
setup();
|
||||||
refreshLocal();
|
refreshLocal();
|
||||||
refreshRemote();
|
refreshRemote();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onResize(this::setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupRemote(){
|
void setupRemote(){
|
||||||
@@ -93,7 +94,7 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
|
|
||||||
TextButton button = buttons[0] = remote.addButton("[accent]"+server.ip, "clear", () -> {
|
TextButton button = buttons[0] = remote.addButton("[accent]"+server.ip, "clear", () -> {
|
||||||
if(!buttons[0].childrenPressed()) connect(server.ip, Vars.port);
|
if(!buttons[0].childrenPressed()) connect(server.ip, Vars.port);
|
||||||
}).width(w).height(150f).pad(4f).get();
|
}).width(targetWidth()).height(150f).pad(4f).get();
|
||||||
|
|
||||||
button.getLabel().setWrap(true);
|
button.getLabel().setWrap(true);
|
||||||
|
|
||||||
@@ -187,6 +188,8 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
|
float w = targetWidth();
|
||||||
|
|
||||||
Player player = players[0];
|
Player player = players[0];
|
||||||
|
|
||||||
hosts.clear();
|
hosts.clear();
|
||||||
@@ -246,6 +249,8 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addLocalHosts(Array<Host> array){
|
void addLocalHosts(Array<Host> array){
|
||||||
|
float w = targetWidth();
|
||||||
|
|
||||||
local.clear();
|
local.clear();
|
||||||
|
|
||||||
if(array.size == 0){
|
if(array.size == 0){
|
||||||
@@ -310,6 +315,10 @@ public class JoinDialog extends FloatingDialog {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float targetWidth(){
|
||||||
|
return UIUtils.portrait() ? 350f : 500f;
|
||||||
|
}
|
||||||
|
|
||||||
private void loadServers(){
|
private void loadServers(){
|
||||||
servers = Settings.getJson("server-list", Array.class);
|
servers = Settings.getJson("server-list", Array.class);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,19 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import io.anuke.mindustry.game.Difficulty;
|
import io.anuke.mindustry.game.Difficulty;
|
||||||
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.game.GameMode;
|
import io.anuke.mindustry.game.GameMode;
|
||||||
import io.anuke.mindustry.io.Map;
|
import io.anuke.mindustry.io.Map;
|
||||||
import io.anuke.mindustry.ui.BorderImage;
|
import io.anuke.mindustry.ui.BorderImage;
|
||||||
|
import io.anuke.ucore.core.Events;
|
||||||
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.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
import io.anuke.ucore.scene.utils.Elements;
|
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
@@ -29,6 +28,8 @@ public class LevelDialog extends FloatingDialog{
|
|||||||
super("$text.level.select");
|
super("$text.level.select");
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
shown(this::setup);
|
shown(this::setup);
|
||||||
|
|
||||||
|
onResize(this::setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
@@ -39,9 +40,9 @@ public class LevelDialog extends FloatingDialog{
|
|||||||
ScrollPane pane = new ScrollPane(maps, "clear-black");
|
ScrollPane pane = new ScrollPane(maps, "clear-black");
|
||||||
pane.setFadeScrollBars(false);
|
pane.setFadeScrollBars(false);
|
||||||
|
|
||||||
int maxwidth = 4;
|
int maxwidth = (Gdx.graphics.getHeight() > Gdx.graphics.getHeight() ? 2 : 4);
|
||||||
|
|
||||||
Table selmode = new Table();
|
/*Table selmode = new Table();
|
||||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||||
selmode.add("$text.level.mode").padRight(15f);
|
selmode.add("$text.level.mode").padRight(15f);
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ public class LevelDialog extends FloatingDialog{
|
|||||||
selmode.addButton("?", this::displayGameModeHelp).size(50f, 54f).padLeft(18f);
|
selmode.addButton("?", this::displayGameModeHelp).size(50f, 54f).padLeft(18f);
|
||||||
|
|
||||||
content().add(selmode);
|
content().add(selmode);
|
||||||
content().row();
|
content().row();*/
|
||||||
|
|
||||||
Difficulty[] ds = Difficulty.values();
|
Difficulty[] ds = Difficulty.values();
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
import io.anuke.mindustry.io.Saves.SaveSlot;
|
import io.anuke.mindustry.io.Saves.SaveSlot;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
|
import io.anuke.ucore.core.Events;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
@@ -124,8 +126,7 @@ public class LoadDialog extends FloatingDialog{
|
|||||||
button.row();
|
button.row();
|
||||||
button.label(() -> Bundles.format("text.save.autosave", color + Bundles.get(slot.isAutosave() ? "text.on" : "text.off")));
|
button.label(() -> Bundles.format("text.save.autosave", color + Bundles.get(slot.isAutosave() ? "text.on" : "text.off")));
|
||||||
button.row();
|
button.row();
|
||||||
button.add();
|
button.add(Bundles.format("text.save.date", color+slot.getDate())).colspan(2).padTop(5).right();
|
||||||
button.add(Bundles.format("text.save.date", color+slot.getDate()));
|
|
||||||
button.row();
|
button.row();
|
||||||
modifyButton(button, slot);
|
modifyButton(button, slot);
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
|||||||
graphics.sliderPref("previewopacity", 50, 0, 100, i -> i + "%");
|
graphics.sliderPref("previewopacity", 50, 0, 100, i -> i + "%");
|
||||||
graphics.checkPref("indicators", true);
|
graphics.checkPref("indicators", true);
|
||||||
graphics.checkPref("healthbars", true);
|
graphics.checkPref("healthbars", true);
|
||||||
|
graphics.checkPref("minimap", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void back(){
|
private void back(){
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import io.anuke.ucore.scene.ui.Image;
|
|||||||
import io.anuke.ucore.scene.ui.ScrollPane;
|
import io.anuke.ucore.scene.ui.ScrollPane;
|
||||||
import io.anuke.ucore.scene.ui.Tooltip;
|
import io.anuke.ucore.scene.ui.Tooltip;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
import io.anuke.ucore.scene.utils.UIUtils;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ public class UnlocksDialog extends FloatingDialog {
|
|||||||
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
shown(this::rebuild);
|
shown(this::rebuild);
|
||||||
|
onResize(this::rebuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rebuild(){
|
void rebuild(){
|
||||||
@@ -43,7 +45,7 @@ public class UnlocksDialog extends FloatingDialog {
|
|||||||
table.table(list -> {
|
table.table(list -> {
|
||||||
list.left();
|
list.left();
|
||||||
|
|
||||||
int maxWidth = 14;
|
int maxWidth = UIUtils.portrait() ? 6 : 14;
|
||||||
int size = 8*6;
|
int size = 8*6;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
|
|
||||||
public abstract class Fragment{
|
public abstract class Fragment{
|
||||||
|
|
||||||
public Fragment(){
|
|
||||||
Gdx.app.postRunnable(() -> Vars.ui.addFragment(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void build(Group parent);
|
public abstract void build(Group parent);
|
||||||
|
|
||||||
public void onResize(){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import io.anuke.mindustry.ui.IntFormat;
|
|||||||
import io.anuke.mindustry.ui.Minimap;
|
import io.anuke.mindustry.ui.Minimap;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.core.Inputs;
|
import io.anuke.ucore.core.Inputs;
|
||||||
|
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;
|
||||||
@@ -132,7 +133,7 @@ public class HudFragment extends Fragment{
|
|||||||
|
|
||||||
Minimap minimap = new Minimap();
|
Minimap minimap = new Minimap();
|
||||||
|
|
||||||
add(minimap);
|
add(minimap).visible(() -> Settings.getBool("minimap"));
|
||||||
}}.end();
|
}}.end();
|
||||||
|
|
||||||
//paused table
|
//paused table
|
||||||
|
|||||||
@@ -3,94 +3,34 @@ package io.anuke.mindustry.ui.fragments;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.Platform;
|
||||||
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.io.Version;
|
import io.anuke.mindustry.io.Version;
|
||||||
import io.anuke.mindustry.ui.MenuButton;
|
import io.anuke.mindustry.ui.MenuButton;
|
||||||
|
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.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
import io.anuke.ucore.scene.builders.build;
|
||||||
import io.anuke.ucore.scene.builders.label;
|
import io.anuke.ucore.scene.builders.label;
|
||||||
import io.anuke.ucore.scene.builders.table;
|
import io.anuke.ucore.scene.builders.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;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
new table(){{
|
new table(){{
|
||||||
visible(() -> state.is(State.menu));
|
visible(() -> state.is(State.menu));
|
||||||
|
|
||||||
if(!mobile){
|
if(!mobile){
|
||||||
new table(){{
|
buildDesktop();
|
||||||
|
}else{
|
||||||
|
buildMobile();
|
||||||
|
|
||||||
float w = 200f;
|
Events.on(ResizeEvent.class, () -> buildMobile());
|
||||||
float bw = w * 2f + 10f;
|
|
||||||
|
|
||||||
defaults().size(w, 66f).padTop(5).padRight(5);
|
|
||||||
|
|
||||||
add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
|
|
||||||
|
|
||||||
add(new MenuButton("icon-map", "$text.maps", ui.maps::show));
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
|
||||||
|
|
||||||
add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
|
||||||
|
|
||||||
add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
if(!gwt){
|
|
||||||
add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
get().margin(16);
|
|
||||||
}}.end();
|
|
||||||
|
|
||||||
}else {
|
|
||||||
new table() {{
|
|
||||||
float size = 120f;
|
|
||||||
defaults().size(size).pad(5);
|
|
||||||
float isize = 14f * 4;
|
|
||||||
|
|
||||||
new imagebutton("icon-play-2", isize, ui.levels::show).text("$text.play").padTop(4f);
|
|
||||||
|
|
||||||
//new imagebutton("icon-tutorial", isize, () -> ui.showInfo("The tutorial is currently not yet implemented."))
|
|
||||||
// .text("$text.tutorial").padTop(4f);
|
|
||||||
|
|
||||||
new imagebutton("icon-map", isize, ui.maps::show).text("$text.maps").padTop(4f);
|
|
||||||
|
|
||||||
new imagebutton("icon-load", isize, ui.load::show).text("$text.load").padTop(4f);
|
|
||||||
|
|
||||||
new imagebutton("icon-add", isize, ui.join::show).text("$text.joingame").padTop(4f);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
new table(){{
|
|
||||||
|
|
||||||
defaults().size(size).pad(5);
|
|
||||||
|
|
||||||
new imagebutton("icon-editor", isize, () -> ui.loadAnd(ui.editor::show)).text("$text.editor").padTop(4f);
|
|
||||||
|
|
||||||
new imagebutton("icon-tools", isize, ui.settings::show).text("$text.settings").padTop(4f);
|
|
||||||
|
|
||||||
new imagebutton("icon-info", isize, ui.about::show).text("$text.about.button").padTop(4f);
|
|
||||||
|
|
||||||
if (!ios) {
|
|
||||||
new imagebutton("icon-donate", isize, Platform.instance::openDonations).text("$text.donate").padTop(4f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}}.colspan(4).end();
|
|
||||||
}}.end();
|
|
||||||
}
|
}
|
||||||
}}.end();
|
}}.end();
|
||||||
|
|
||||||
@@ -102,6 +42,14 @@ public class MenuFragment extends Fragment{
|
|||||||
}}.end().visible(() -> state.is(State.menu));
|
}}.end().visible(() -> state.is(State.menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//info icon
|
||||||
|
if(mobile) {
|
||||||
|
new table() {{
|
||||||
|
abottom().atop().aleft();
|
||||||
|
get().addButton("", "info", ui.about::show);
|
||||||
|
}}.end().visible(() -> state.is(State.menu));
|
||||||
|
}
|
||||||
|
|
||||||
//version info
|
//version info
|
||||||
new table(){{
|
new table(){{
|
||||||
visible(() -> state.is(State.menu));
|
visible(() -> state.is(State.menu));
|
||||||
@@ -110,6 +58,103 @@ public class MenuFragment extends Fragment{
|
|||||||
}}.end();
|
}}.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buildMobile(){
|
||||||
|
if(mobileContainer == null){
|
||||||
|
mobileContainer = build.getTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
mobileContainer.clear();
|
||||||
|
mobileContainer.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
|
||||||
|
float size = 120f;
|
||||||
|
float isize = 14f * 4;
|
||||||
|
mobileContainer.defaults().size(size).pad(5).padTop(4f);
|
||||||
|
|
||||||
|
MobileButton
|
||||||
|
play = new MobileButton("icon-play-2", isize, "$text.play", ui.levels::show),
|
||||||
|
maps = new MobileButton("icon-map", isize, "$text.maps", ui.maps::show),
|
||||||
|
load = new MobileButton("icon-load", isize, "$text.load", ui.load::show),
|
||||||
|
join = new MobileButton("icon-add", isize, "$text.joingame", ui.join::show),
|
||||||
|
editor = new MobileButton("icon-editor", isize, "$text.editor", () -> ui.loadAnd(ui.editor::show)),
|
||||||
|
tools = new MobileButton("icon-tools", isize, "$text.settings", ui.settings::show),
|
||||||
|
unlocks = new MobileButton("icon-unlocks", isize, "$text.unlocks", ui.unlocks::show),
|
||||||
|
donate = new MobileButton("icon-donate", isize, "$text.donate", Platform.instance::openDonations);
|
||||||
|
|
||||||
|
if(Gdx.graphics.getWidth() > Gdx.graphics.getHeight()){
|
||||||
|
mobileContainer.add(play);
|
||||||
|
mobileContainer.add(join);
|
||||||
|
mobileContainer.add(load);
|
||||||
|
mobileContainer.add(maps);
|
||||||
|
mobileContainer.row();
|
||||||
|
|
||||||
|
mobileContainer.table(table -> {
|
||||||
|
table.defaults().set(mobileContainer.defaults());
|
||||||
|
|
||||||
|
table.add(editor);
|
||||||
|
table.add(tools);
|
||||||
|
table.add(unlocks);
|
||||||
|
|
||||||
|
if(Platform.instance.canDonate()) table.add(donate);
|
||||||
|
}).colspan(4);
|
||||||
|
}else{
|
||||||
|
mobileContainer.add(play);
|
||||||
|
mobileContainer.add(maps);
|
||||||
|
mobileContainer.row();
|
||||||
|
mobileContainer.add(load);
|
||||||
|
mobileContainer.add(join);
|
||||||
|
mobileContainer.row();
|
||||||
|
mobileContainer.add(editor);
|
||||||
|
mobileContainer.add(tools);
|
||||||
|
mobileContainer.row();
|
||||||
|
|
||||||
|
mobileContainer.table(table -> {
|
||||||
|
table.defaults().set(mobileContainer.defaults());
|
||||||
|
|
||||||
|
table.add(unlocks);
|
||||||
|
|
||||||
|
if(Platform.instance.canDonate()) table.add(donate);
|
||||||
|
}).colspan(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildDesktop(){
|
||||||
|
new table(){{
|
||||||
|
|
||||||
|
float w = 200f;
|
||||||
|
float bw = w * 2f + 10f;
|
||||||
|
|
||||||
|
defaults().size(w, 66f).padTop(5).padRight(5);
|
||||||
|
|
||||||
|
add(new MenuButton("icon-play-2", "$text.play", MenuFragment.this::showPlaySelect)).width(bw).colspan(2);
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
add(new MenuButton("icon-editor", "$text.editor", () -> ui.loadAnd(ui.editor::show)));
|
||||||
|
|
||||||
|
add(new MenuButton("icon-map", "$text.maps", ui.maps::show));
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
add(new MenuButton("icon-info", "$text.about.button", ui.about::show));
|
||||||
|
|
||||||
|
add(new MenuButton("icon-tools", "$text.settings", ui.settings::show));
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
add(new MenuButton("icon-menu", "$text.changelog.title", ui.changelog::show));
|
||||||
|
|
||||||
|
add(new MenuButton("icon-unlocks", "$text.unlocks", ui.unlocks::show));
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
if(!gwt){
|
||||||
|
add(new MenuButton("icon-exit", "$text.quit", Gdx.app::exit)).width(bw).colspan(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
get().margin(16);
|
||||||
|
}}.end();
|
||||||
|
}
|
||||||
|
|
||||||
private void showPlaySelect(){
|
private void showPlaySelect(){
|
||||||
float w = 200f;
|
float w = 200f;
|
||||||
float bw = w * 2f + 10f;
|
float bw = w * 2f + 10f;
|
||||||
|
|||||||
Reference in New Issue
Block a user