Added more zoom levels

This commit is contained in:
Anuken
2017-07-27 13:27:11 -04:00
parent a05f63343c
commit 53b812dde4
9 changed files with 54 additions and 29 deletions

View File

@@ -85,6 +85,14 @@ public class Control extends RendererModule{
player = new Player();
}
public void setCameraScale(int scale){
this.cameraScale = scale;
resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
setCamera(player.x, player.y);
Draw.getSurface("pixel").setScale(cameraScale);
Draw.getSurface("shadow").setScale(cameraScale);
}
public void reset(){
weapons.clear();
Renderer.clearTiles();

View File

@@ -35,14 +35,13 @@ import io.anuke.ucore.scene.ui.layout.*;
import io.anuke.ucore.util.Timers;
public class UI extends SceneModule{
Table itemtable, weapontable, tools;
Table itemtable, weapontable, tools, loadingtable;
SettingsDialog prefs;
KeybindDialog keys;
Dialog about, menu, restart, tutorial, levels, upgrades;
Tooltip tooltip;
VisibilityProvider play = () -> !GameState.is(State.menu);
VisibilityProvider nplay = () -> GameState.is(State.menu);
public UI() {
@@ -368,23 +367,17 @@ public class UI extends SceneModule{
aleft();
abottom();
int base = baseCameraScale;
int min = base-zoomScale*2;
int max = base+zoomScale;
new button("+", ()->{
if(control.cameraScale < base){
control.cameraScale = base;
control.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
control.setCamera(player.x, player.y);
Draw.getSurface("pixel").setScale(control.cameraScale);
Draw.getSurface("shadow").setScale(control.cameraScale);
if(control.cameraScale < max){
control.setCameraScale(control.cameraScale+zoomScale);
}
}).size(Unit.dp.inPixels(40));
new button("-", ()->{
if(control.cameraScale > base-zoomScale){
control.cameraScale = base-zoomScale;
control.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
control.setCamera(player.x, player.y);
Draw.getSurface("pixel").setScale(control.cameraScale);
Draw.getSurface("shadow").setScale(control.cameraScale);
if(control.cameraScale > min){
control.setCameraScale(control.cameraScale-zoomScale);
}
}).size(Unit.dp.inPixels(40));
@@ -453,6 +446,14 @@ public class UI extends SceneModule{
}};
}}.end();
loadingtable = new table("loadDim"){{
new table("button"){{
new label("[yellow]Loading...").scale(1).pad(10);
}}.end();
}}.end().get();
loadingtable.setVisible(false);
tools = new Table();
tools.addIButton("icon-cancel", Unit.dp.inPixels(42), ()->{
player.recipe = null;
@@ -466,7 +467,6 @@ public class UI extends SceneModule{
AndroidInput.place();
});
scene.add(tools);
tools.setVisible(()->{
@@ -515,6 +515,14 @@ public class UI extends SceneModule{
}
}
public void showLoading(){
loadingtable.setVisible(true);
}
public void hideLoading(){
loadingtable.setVisible(false);
}
public void showPrefs(){
prefs.show();
}

View File

@@ -87,6 +87,7 @@ public class World{
}
public static void loadMap(int id){
spawnpoints.clear();
int size = mapPixmaps[id].getWidth();

View File

@@ -9,6 +9,7 @@ import io.anuke.mindustry.World;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Timers;
public class LevelDialog extends Dialog{
Label[] scores = new Label[maps.length];
@@ -28,8 +29,15 @@ public class LevelDialog extends Dialog{
addCloseButton();
getButtonTable().addButton("Play", ()->{
hide();
World.loadMap(selectedMap);
Vars.control.play();
Vars.ui.showLoading();
Timers.run(16, ()->{
World.loadMap(selectedMap);
Vars.control.play();
});
Timers.run(18, ()->{
Vars.ui.hideLoading();
});
});
ButtonGroup<ImageButton> mapgroup = new ButtonGroup<>();