More menu
This commit is contained in:
@@ -75,23 +75,8 @@ public class UI implements ApplicationListener{
|
||||
Core.scene = new Scene(skin);
|
||||
Core.input.addProcessor(Core.scene);
|
||||
|
||||
Dialog.setShowAction(() -> sequence(
|
||||
alpha(0f),
|
||||
originCenter(),
|
||||
moveToAligned(Core.graphics.getWidth() / 2f, Core.graphics.getHeight() / 2f, Align.center),
|
||||
scaleTo(0.0f, 1f),
|
||||
parallel(
|
||||
scaleTo(1f, 1f, 0.1f, Interpolation.fade),
|
||||
fadeIn(0.1f, Interpolation.fade)
|
||||
)
|
||||
));
|
||||
|
||||
Dialog.setHideAction(() -> sequence(
|
||||
parallel(
|
||||
scaleTo(0.01f, 0.01f, 0.1f, Interpolation.fade),
|
||||
fadeOut(0.1f, Interpolation.fade)
|
||||
)
|
||||
));
|
||||
Dialog.setShowAction(() -> sequence());
|
||||
Dialog.setHideAction(() -> sequence());
|
||||
|
||||
Tooltips.getInstance().animations = false;
|
||||
|
||||
|
||||
119
core/src/io/anuke/mindustry/graphics/MenuRenderer.java
Normal file
119
core/src/io/anuke/mindustry/graphics/MenuRenderer.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.Camera;
|
||||
import io.anuke.arc.graphics.Color;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.util.Disposable;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
|
||||
public class MenuRenderer implements Disposable{
|
||||
private static final int width = 30, height = 30;
|
||||
|
||||
private int cacheFloor, cacheWall;
|
||||
private Camera camera = new Camera();
|
||||
private FrameBuffer shadows;
|
||||
private CacheBatch batch;
|
||||
|
||||
public MenuRenderer(){
|
||||
generate();
|
||||
cache();
|
||||
}
|
||||
|
||||
private void generate(){
|
||||
Tile[][] tiles = world.createTiles(width, height);
|
||||
shadows = new FrameBuffer(width, height);
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Block floor = Blocks.metalFloor;
|
||||
Block ore = Blocks.oreCopper;
|
||||
Block wall = Mathf.chance(0.5) ? Blocks.air : Blocks.darkMetal;
|
||||
|
||||
tiles[x][y] = new Tile(x, y, floor.id, ore.id, wall.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cache(){
|
||||
|
||||
//draw shadows
|
||||
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
|
||||
shadows.beginDraw(Color.CLEAR);
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
if(world.rawTile(x, y).block() != Blocks.air){
|
||||
Fill.rect(x + 0.5f, y + 0.5f, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
shadows.endDraw();
|
||||
|
||||
batch = new CacheBatch(new SpriteCache(width * height * 5, true));
|
||||
batch.beginCache();
|
||||
|
||||
SpriteBatch prev = Core.batch;
|
||||
Core.batch = batch;
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
tile.floor().draw(tile);
|
||||
}
|
||||
}
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
if(tile.overlay() != Blocks.air){
|
||||
tile.overlay().draw(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cacheFloor = batch.endCache();
|
||||
batch.beginCache();
|
||||
|
||||
for(int x = 0; x < width; x++){
|
||||
for(int y = 0; y < height; y++){
|
||||
Tile tile = world.rawTile(x, y);
|
||||
if(tile.block() != Blocks.air){
|
||||
tile.block().draw(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cacheWall = batch.endCache();
|
||||
|
||||
Core.batch = prev;
|
||||
}
|
||||
|
||||
public void render(){
|
||||
camera.position.set(Core.graphics.getWidth()/2f, Core.graphics.getHeight()/2f);
|
||||
camera.resize(Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||
|
||||
Draw.flush();
|
||||
batch.setProjection(camera.projection());
|
||||
batch.beginDraw();
|
||||
batch.drawCache(cacheFloor);
|
||||
batch.endDraw();
|
||||
Draw.rect(Draw.wrap(shadows.getTexture()), width * tilesize/2f, height * tilesize/2f, width * tilesize, height * tilesize);
|
||||
Draw.flush();
|
||||
batch.beginDraw();
|
||||
batch.drawCache(cacheWall);
|
||||
batch.endDraw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
batch.dispose();
|
||||
shadows.dispose();
|
||||
}
|
||||
}
|
||||
@@ -88,15 +88,15 @@ public class DeployDialog extends FloatingDialog{
|
||||
button.row();
|
||||
button.label(() -> Core.bundle.format("save.playtime", color + slot.getPlayTime()));
|
||||
button.row();
|
||||
button.add().grow();
|
||||
button.row();
|
||||
|
||||
button.addButton("$abandon", () -> {
|
||||
row();
|
||||
|
||||
addButton("$abandon", () -> {
|
||||
ui.showConfirm("$warning", "$abandon.text", () -> {
|
||||
slot.delete();
|
||||
setup();
|
||||
});
|
||||
}).growX().height(50f).pad(-12).padTop(10);
|
||||
}).fillX().height(50f).pad(3);
|
||||
|
||||
}}, new ItemsDisplay()).grow();
|
||||
|
||||
|
||||
@@ -1,32 +1,12 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
public class BackgroundFragment extends Fragment{
|
||||
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
Draw.colorl(0.1f);
|
||||
Fill.crect(0, 0, w, h);
|
||||
//Draw.shader(Shaders.menu);
|
||||
// Fill.crect(0, 0, w, h);
|
||||
//Draw.shader();
|
||||
|
||||
boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight();
|
||||
float logoscl = (int)Unit.dp.scl(1);
|
||||
TextureRegion logo = Core.atlas.find("logotext");
|
||||
float logow = logo.getWidth() * logoscl;
|
||||
float logoh = logo.getHeight() * logoscl;
|
||||
|
||||
Draw.color();
|
||||
//Draw.rect(logo, (int)(w / 2), (int)(h - 10 - logoh - Unit.dp.scl(portrait ? 30f : 0)) + logoh / 2, logow, logoh);
|
||||
}).visible(() -> state.is(State.menu)).grow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
import io.anuke.arc.graphics.Texture;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.scene.Group;
|
||||
import io.anuke.arc.scene.event.Touchable;
|
||||
import io.anuke.arc.scene.ui.Button;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.arc.scene.ui.layout.Unit;
|
||||
import io.anuke.arc.util.Align;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
import io.anuke.mindustry.graphics.MenuRenderer;
|
||||
import io.anuke.mindustry.ui.MenuButton;
|
||||
import io.anuke.mindustry.ui.MobileButton;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuFragment extends Fragment{
|
||||
private Texture logo = new Texture("sprites/logo.png");
|
||||
private Table container, submenu;
|
||||
private Button currentMenu;
|
||||
private MenuRenderer renderer = new MenuRenderer();
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
renderer.render();
|
||||
});
|
||||
|
||||
parent.fill(c -> {
|
||||
container = c;
|
||||
container.visible(() -> state.is(State.menu));
|
||||
@@ -45,6 +59,20 @@ public class MenuFragment extends Fragment{
|
||||
//parent.fill(c -> c.bottom().left().add(Strings.format("v{0} {1}-{2} {3}{4}", Version.number, Version.modifier, Version.type,
|
||||
//(Version.build == -1 ? "custom build" : "build " + Version.build), Version.revision == 0 ? "" : "." + Version.revision)).color(Color.DARK_GRAY)
|
||||
//.visible(() -> state.is(State.menu)));
|
||||
|
||||
Core.scene.table().addRect((a, b, w, h) -> {
|
||||
//Draw.shader(Shaders.menu);
|
||||
// Fill.crect(0, 0, w, h);
|
||||
//Draw.shader();
|
||||
|
||||
boolean portrait = Core.graphics.getWidth() < Core.graphics.getHeight();
|
||||
float logoscl = (int)Unit.dp.scl(1);
|
||||
float logow = Math.min(logo.getWidth() * logoscl, 768);
|
||||
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(Draw.wrap(logo), (int)(w / 2), (int)(h - 10 - logoh - Unit.dp.scl(portrait ? 30f : 0)) + logoh / 2, logow, logoh);
|
||||
}).visible(() -> state.is(State.menu)).grow().get().touchable(Touchable.disabled);
|
||||
}
|
||||
|
||||
private void buildMobile(){
|
||||
|
||||
Reference in New Issue
Block a user