Start of work on portrait mode / Made fragments abstract classes
This commit is contained in:
@@ -20,7 +20,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="io.anuke.mindustry.AndroidLauncher"
|
android:name="io.anuke.mindustry.AndroidLauncher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:screenOrientation="sensorLandscape"
|
android:screenOrientation="sensor"
|
||||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.anuke.mindustry;
|
|||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -153,6 +154,16 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
requestPermissions(perms.toArray(new String[perms.size()]), PERMISSION_REQUEST_CODE);
|
requestPermissions(perms.toArray(new String[perms.size()]), PERMISSION_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beginForceLandscape() {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endForceLandscape() {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ allprojects {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
versionNumber = '4.0'
|
versionNumber = '4.0'
|
||||||
versionType = 'pre-alpha'
|
versionType = 'alpha'
|
||||||
appName = 'Mindustry'
|
appName = 'Mindustry'
|
||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
|
|||||||
@@ -86,4 +86,12 @@ public abstract class Platform {
|
|||||||
@Override public <T extends Entity> void switchContainer(EntityGroup<T> group) {}
|
@Override public <T extends Entity> void switchContainer(EntityGroup<T> group) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO iOS implementation
|
||||||
|
/**Forces the app into landscape mode. Currently Android only.*/
|
||||||
|
public void beginForceLandscape(){}
|
||||||
|
|
||||||
|
//TODO iOS implementation
|
||||||
|
/**Stops forcing the app into landscape orientation. Currently Android only.*/
|
||||||
|
public void endForceLandscape(){}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
@@ -34,7 +35,8 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
import static io.anuke.mindustry.Vars.players;
|
||||||
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{
|
||||||
@@ -69,6 +71,7 @@ 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(
|
||||||
@@ -185,7 +188,7 @@ public class UI extends SceneModule{
|
|||||||
backfrag.build(group);
|
backfrag.build(group);
|
||||||
hudfrag.build(group);
|
hudfrag.build(group);
|
||||||
menufrag.build(group);
|
menufrag.build(group);
|
||||||
chatfrag.build(group);
|
chatfrag.container().build(group);
|
||||||
listfrag.build(group);
|
listfrag.build(group);
|
||||||
debugfrag.build(group);
|
debugfrag.build(group);
|
||||||
loadfrag.build(group);
|
loadfrag.build(group);
|
||||||
@@ -198,6 +201,10 @@ public class UI extends SceneModule{
|
|||||||
return super.hasMouse();
|
return super.hasMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addFragment(Fragment fragment){
|
||||||
|
fragments.add(fragment);
|
||||||
|
}
|
||||||
|
|
||||||
public Locale getLocale(){
|
public Locale getLocale(){
|
||||||
String loc = Settings.getString("locale");
|
String loc = Settings.getString("locale");
|
||||||
if(loc.equals("default")){
|
if(loc.equals("default")){
|
||||||
|
|||||||
@@ -248,6 +248,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
shown(() -> {
|
shown(() -> {
|
||||||
saved = true;
|
saved = true;
|
||||||
|
Platform.instance.beginForceLandscape();
|
||||||
view.clearStack();
|
view.clearStack();
|
||||||
Core.scene.setScrollFocus(view);
|
Core.scene.setScrollFocus(view);
|
||||||
if(!shownWithMap){
|
if(!shownWithMap){
|
||||||
@@ -258,7 +259,10 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
Timers.runTask(10f, Platform.instance::updateRPC);
|
Timers.runTask(10f, Platform.instance::updateRPC);
|
||||||
});
|
});
|
||||||
|
|
||||||
hidden(() -> Platform.instance.updateRPC());
|
hidden(() -> {
|
||||||
|
Platform.instance.updateRPC();
|
||||||
|
Platform.instance.endForceLandscape();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save(){
|
private void save(){
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Vars.state;
|
||||||
|
|
||||||
public class BackgroundFragment implements Fragment {
|
public class BackgroundFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Group parent) {
|
public void build(Group parent) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
|||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Vars.state;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class BlockConfigFragment implements Fragment {
|
public class BlockConfigFragment extends Fragment {
|
||||||
private Table table = new Table();
|
private Table table = new Table();
|
||||||
private InputHandler input;
|
private InputHandler input;
|
||||||
private Tile configTile;
|
private Tile configTile;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ import static io.anuke.mindustry.Vars.mobile;
|
|||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Vars.state;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class BlockInventoryFragment implements Fragment {
|
public class BlockInventoryFragment extends Fragment {
|
||||||
private final static float holdWithdraw = 40f;
|
private final static float holdWithdraw = 40f;
|
||||||
|
|
||||||
private Table table;
|
private Table table;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import io.anuke.ucore.util.Strings;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class BlocksFragment implements Fragment{
|
public class BlocksFragment extends Fragment{
|
||||||
/**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.*/
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import static io.anuke.mindustry.Vars.state;
|
|||||||
import static io.anuke.ucore.core.Core.scene;
|
import static io.anuke.ucore.core.Core.scene;
|
||||||
import static io.anuke.ucore.core.Core.skin;
|
import static io.anuke.ucore.core.Core.skin;
|
||||||
|
|
||||||
public class ChatFragment extends Table implements Fragment{
|
public class ChatFragment extends Table{
|
||||||
private final static int messagesShown = 10;
|
private final static int messagesShown = 10;
|
||||||
private Array<ChatMessage> messages = new Array<>();
|
private Array<ChatMessage> messages = new Array<>();
|
||||||
private float fadetime;
|
private float fadetime;
|
||||||
@@ -43,6 +43,12 @@ public class ChatFragment extends Table implements Fragment{
|
|||||||
private Array<String> history = new Array<>();
|
private Array<String> history = new Array<>();
|
||||||
private int historyPos = 0;
|
private int historyPos = 0;
|
||||||
private int scrollPos = 0;
|
private int scrollPos = 0;
|
||||||
|
private Fragment container = new Fragment() {
|
||||||
|
@Override
|
||||||
|
public void build(Group parent) {
|
||||||
|
scene.add(ChatFragment.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public ChatFragment(){
|
public ChatFragment(){
|
||||||
super();
|
super();
|
||||||
@@ -79,9 +85,8 @@ public class ChatFragment extends Table implements Fragment{
|
|||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Fragment container() {
|
||||||
public void build(Group parent) {
|
return container;
|
||||||
scene.add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMessages(){
|
public void clearMessages(){
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import io.anuke.ucore.util.Mathf;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class DebugFragment implements Fragment {
|
public class DebugFragment extends Fragment {
|
||||||
private static StringBuilder log = new StringBuilder();
|
private static StringBuilder log = new StringBuilder();
|
||||||
|
|
||||||
static{
|
static{
|
||||||
|
|||||||
@@ -1,7 +1,18 @@
|
|||||||
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 interface Fragment{
|
public abstract class Fragment{
|
||||||
void build(Group parent);
|
|
||||||
|
public Fragment(){
|
||||||
|
Gdx.app.postRunnable(() -> Vars.ui.addFragment(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void build(Group parent);
|
||||||
|
|
||||||
|
public void onResize(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import io.anuke.ucore.util.Bundles;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class HudFragment implements Fragment{
|
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;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import io.anuke.ucore.scene.ui.Label;
|
|||||||
import io.anuke.ucore.scene.ui.TextButton;
|
import io.anuke.ucore.scene.ui.TextButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
public class LoadingFragment implements Fragment {
|
public class LoadingFragment extends Fragment {
|
||||||
private Table table;
|
private Table table;
|
||||||
private TextButton button;
|
private TextButton button;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import io.anuke.ucore.scene.builders.table;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class MenuFragment implements Fragment{
|
public class MenuFragment extends Fragment{
|
||||||
|
|
||||||
public void build(Group parent){
|
public void build(Group parent){
|
||||||
new table(){{
|
new table(){{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.anuke.mindustry.input.InputHandler;
|
|||||||
import io.anuke.ucore.scene.Group;
|
import io.anuke.ucore.scene.Group;
|
||||||
|
|
||||||
/**Fragment for displaying overlays such as block inventories. One is created for each input handler.*/
|
/**Fragment for displaying overlays such as block inventories. One is created for each input handler.*/
|
||||||
public class OverlayFragment implements Fragment{
|
public class OverlayFragment extends Fragment{
|
||||||
public final BlockInventoryFragment inv;
|
public final BlockInventoryFragment inv;
|
||||||
public final BlockConfigFragment config;
|
public final BlockConfigFragment config;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import io.anuke.ucore.util.Bundles;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class PlayerListFragment implements Fragment{
|
public class PlayerListFragment extends Fragment{
|
||||||
private boolean visible = false;
|
private boolean visible = false;
|
||||||
private Table content = new Table();
|
private Table content = new Table();
|
||||||
private ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
private ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user