Start of work on portrait mode / Made fragments abstract classes
This commit is contained in:
@@ -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<>();
|
||||
|
||||
Reference in New Issue
Block a user