mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-03-01 03:21:03 -08:00
Start of work on portrait mode / Made fragments abstract classes
This commit is contained in:
parent
cf0a25fdfc
commit
fb2bb5a4bc
18 changed files with 67 additions and 21 deletions
|
|
@ -20,7 +20,7 @@
|
|||
<activity
|
||||
android:name="io.anuke.mindustry.AndroidLauncher"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="sensorLandscape"
|
||||
android:screenOrientation="sensor"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
|
||||
<intent-filter>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package io.anuke.mindustry;
|
|||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
|
@ -153,6 +154,16 @@ public class AndroidLauncher extends AndroidApplication{
|
|||
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 {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ allprojects {
|
|||
|
||||
ext {
|
||||
versionNumber = '4.0'
|
||||
versionType = 'pre-alpha'
|
||||
versionType = 'alpha'
|
||||
appName = 'Mindustry'
|
||||
gdxVersion = '1.9.8'
|
||||
roboVMVersion = '2.3.0'
|
||||
|
|
|
|||
|
|
@ -86,4 +86,12 @@ public abstract class Platform {
|
|||
@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.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.editor.MapEditorDialog;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
|
|
@ -34,7 +35,8 @@ import io.anuke.ucore.util.Mathf;
|
|||
|
||||
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.*;
|
||||
|
||||
public class UI extends SceneModule{
|
||||
|
|
@ -69,6 +71,7 @@ public class UI extends SceneModule{
|
|||
public final DebugFragment debugfrag = new DebugFragment();
|
||||
|
||||
private Locale lastLocale;
|
||||
private Array<Fragment> fragments = new Array<>();
|
||||
|
||||
public UI() {
|
||||
Dialog.setShowAction(()-> sequence(
|
||||
|
|
@ -185,7 +188,7 @@ public class UI extends SceneModule{
|
|||
backfrag.build(group);
|
||||
hudfrag.build(group);
|
||||
menufrag.build(group);
|
||||
chatfrag.build(group);
|
||||
chatfrag.container().build(group);
|
||||
listfrag.build(group);
|
||||
debugfrag.build(group);
|
||||
loadfrag.build(group);
|
||||
|
|
@ -198,6 +201,10 @@ public class UI extends SceneModule{
|
|||
return super.hasMouse();
|
||||
}
|
||||
|
||||
public void addFragment(Fragment fragment){
|
||||
fragments.add(fragment);
|
||||
}
|
||||
|
||||
public Locale getLocale(){
|
||||
String loc = Settings.getString("locale");
|
||||
if(loc.equals("default")){
|
||||
|
|
|
|||
|
|
@ -248,6 +248,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||
|
||||
shown(() -> {
|
||||
saved = true;
|
||||
Platform.instance.beginForceLandscape();
|
||||
view.clearStack();
|
||||
Core.scene.setScrollFocus(view);
|
||||
if(!shownWithMap){
|
||||
|
|
@ -258,7 +259,10 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||
Timers.runTask(10f, Platform.instance::updateRPC);
|
||||
});
|
||||
|
||||
hidden(() -> Platform.instance.updateRPC());
|
||||
hidden(() -> {
|
||||
Platform.instance.updateRPC();
|
||||
Platform.instance.endForceLandscape();
|
||||
});
|
||||
}
|
||||
|
||||
private void save(){
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
|||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
public class BackgroundFragment implements Fragment {
|
||||
public class BackgroundFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
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.tilesize;
|
||||
|
||||
public class BlockConfigFragment implements Fragment {
|
||||
public class BlockConfigFragment extends Fragment {
|
||||
private Table table = new Table();
|
||||
private InputHandler input;
|
||||
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.tilesize;
|
||||
|
||||
public class BlockInventoryFragment implements Fragment {
|
||||
public class BlockInventoryFragment extends Fragment {
|
||||
private final static float holdWithdraw = 40f;
|
||||
|
||||
private Table table;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import io.anuke.ucore.util.Strings;
|
|||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class BlocksFragment implements Fragment{
|
||||
public class BlocksFragment extends Fragment{
|
||||
/**Table containing description that is shown on top.*/
|
||||
private Table descTable;
|
||||
/**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.skin;
|
||||
|
||||
public class ChatFragment extends Table implements Fragment{
|
||||
public class ChatFragment extends Table{
|
||||
private final static int messagesShown = 10;
|
||||
private Array<ChatMessage> messages = new Array<>();
|
||||
private float fadetime;
|
||||
|
|
@ -43,6 +43,12 @@ public class ChatFragment extends Table implements Fragment{
|
|||
private Array<String> history = new Array<>();
|
||||
private int historyPos = 0;
|
||||
private int scrollPos = 0;
|
||||
private Fragment container = new Fragment() {
|
||||
@Override
|
||||
public void build(Group parent) {
|
||||
scene.add(ChatFragment.this);
|
||||
}
|
||||
};
|
||||
|
||||
public ChatFragment(){
|
||||
super();
|
||||
|
|
@ -79,9 +85,8 @@ public class ChatFragment extends Table implements Fragment{
|
|||
setup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Group parent) {
|
||||
scene.add(this);
|
||||
public Fragment container() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void clearMessages(){
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import io.anuke.ucore.util.Mathf;
|
|||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class DebugFragment implements Fragment {
|
||||
public class DebugFragment extends Fragment {
|
||||
private static StringBuilder log = new StringBuilder();
|
||||
|
||||
static{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,18 @@
|
|||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
|
||||
public interface Fragment{
|
||||
void build(Group parent);
|
||||
public abstract class Fragment{
|
||||
|
||||
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.*;
|
||||
|
||||
public class HudFragment implements Fragment{
|
||||
public class HudFragment extends Fragment{
|
||||
public final BlocksFragment blockfrag = new BlocksFragment();
|
||||
|
||||
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.layout.Table;
|
||||
|
||||
public class LoadingFragment implements Fragment {
|
||||
public class LoadingFragment extends Fragment {
|
||||
private Table table;
|
||||
private TextButton button;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import io.anuke.ucore.scene.builders.table;
|
|||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuFragment implements Fragment{
|
||||
public class MenuFragment extends Fragment{
|
||||
|
||||
public void build(Group parent){
|
||||
new table(){{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import io.anuke.mindustry.input.InputHandler;
|
|||
import io.anuke.ucore.scene.Group;
|
||||
|
||||
/**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 BlockConfigFragment config;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import io.anuke.ucore.util.Bundles;
|
|||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class PlayerListFragment implements Fragment{
|
||||
public class PlayerListFragment extends Fragment{
|
||||
private boolean visible = false;
|
||||
private Table content = new Table();
|
||||
private ObjectMap<Player, Boolean> checkmap = new ObjectMap<>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue