1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-15 01:54:37 +03:00

Change scaling

This commit is contained in:
Anuken 2017-12-20 00:07:59 -05:00
parent 04fb64f60e
commit 096fae957b
22 changed files with 54 additions and 64 deletions

View File

@ -80,7 +80,7 @@ project(":core") {
apply plugin: "java"
dependencies {
compile 'com.github.anuken:ucore:4cb594bc68'
compile 'com.github.anuken:ucore:7938cb4bf9'
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
}

View File

@ -18,7 +18,6 @@ import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
@ -62,8 +61,8 @@ public class Tutorial{
}}.end();
prev.pad(Unit.dp.scl(16));
next.pad(Unit.dp.scl(16));
prev.pad(16);
next.pad(16);
prev.setDisabled(()->!canMove(false) || !stage.canBack);
next.setDisabled(()->!stage.canForward);

View File

@ -182,7 +182,7 @@ public class UI extends SceneModule{
//gameerror.setFillParent(true);
discord = new Dialog("Discord", "dialog");
discord.content().pad(Unit.dp.scl(12f));
discord.content().pad(12f);
discord.content().add("Join the mindustry discord!\n[orange]" + Vars.discordURL);
discord.buttons().defaults().size(200f, 50);
discord.buttons().addButton("Open link", () -> Mindustry.platforms.openLink(Vars.discordURL));
@ -367,7 +367,7 @@ public class UI extends SceneModule{
public void showError(String text){
new Dialog("[crimson]An error has occured", "dialog"){{
content().pad(Unit.dp.scl(15));
content().pad(15);
content().add(text);
getButtonTable().addButton("OK", ()->{
hide();

View File

@ -22,7 +22,6 @@ import io.anuke.ucore.graphics.Pixmaps;
import io.anuke.ucore.scene.builders.*;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MapEditorDialog extends Dialog{
private MapEditor editor;
@ -152,7 +151,7 @@ public class MapEditorDialog extends Dialog{
public void build(){
new table(){{
float isize = Unit.dp.scl(16*2f);
float isize = 16*2f;
aleft();
new table(){{
@ -220,7 +219,7 @@ public class MapEditorDialog extends Dialog{
for(EditorTool tool : EditorTool.values()){
ImageButton button = new ImageButton("icon-" + tool.name(), "toggle");
button.clicked(() -> view.setTool(tool));
button.resizeImage(Unit.dp.scl(16*2f));
button.resizeImage(16*2f);
group.add(button);
tools.add(button).size(80f, 85f).padBottom(-6f);
@ -312,7 +311,7 @@ public class MapEditorDialog extends Dialog{
ImageButton button = new ImageButton(Draw.hasRegion(block.name) ? Draw.region(block.name) : Draw.region(block.name + "1"), "toggle");
button.clicked(() -> editor.setDrawBlock(block));
button.resizeImage(Unit.dp.scl(8*4f));
button.resizeImage(8*4f);
group.add(button);
content.add(button).pad(4f).size(53f, 58f);
@ -321,7 +320,7 @@ public class MapEditorDialog extends Dialog{
}
}
content.padLeft(Unit.dp.scl(-5f));
content.padLeft(-5f);
group.getButtons().get(2).setChecked(true);

View File

@ -15,7 +15,6 @@ import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MapGenerateDialog extends FloatingDialog{
private MapEditor editor;
@ -46,7 +45,7 @@ public class MapGenerateDialog extends FloatingDialog{
image.setScaling(Scaling.fit);
Table preft = new Table();
preft.left();
preft.pad(Unit.dp.scl(4f)).padRight(Unit.dp.scl(25f));
preft.pad(4f).padRight(25f);
for(GenPref pref : editor.getFilter().getPrefs().values()){
CheckBox box = new CheckBox(pref.name);

View File

@ -9,7 +9,6 @@ import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MapLoadDialog extends FloatingDialog{
Map selected = Vars.world.maps().getMap(0);
@ -24,7 +23,7 @@ public class MapLoadDialog extends FloatingDialog{
Table table = new Table();
table.defaults().size(200f, 90f).pad(4f);
table.pad(Unit.dp.scl(10f));
table.pad(10f);
ScrollPane pane = new ScrollPane(table, "horizontal");
pane.setFadeScrollBars(false);
@ -33,7 +32,7 @@ public class MapLoadDialog extends FloatingDialog{
if(!map.visible) continue;
TextButton button = new TextButton(map.name, "toggle");
button.add(new BorderImage(map.texture, 2f)).size(Unit.dp.scl(16*4f));
button.add(new BorderImage(map.texture, 2f)).size(16*4f);
button.getCells().reverse();
button.clicked(() -> selected = map);
button.getLabelCell().grow().left().padLeft(5f);

View File

@ -124,7 +124,7 @@ public class MapView extends Element implements GestureListener{
if(pop) ScissorStack.popScissors();
Draw.color(Colors.get("accent"));
Draw.thick(Unit.dp.scl(3f));
Draw.thick(3f);
Draw.linerect(x + width/2 - size/2, y + height/2 - size/2, size, size);
Draw.reset();
}

View File

@ -43,8 +43,8 @@ public class FileChooser extends FloatingDialog{
}
private void setupWidgets(){
getCell(content()).maxWidth(Gdx.graphics.getWidth()/2);
content().pad(-Unit.dp.scl(10));
getCell(content()).width(Gdx.graphics.getWidth() / Unit.dp.scl(2f));
content().pad(-10);
Table content = new Table();
@ -87,7 +87,7 @@ public class FileChooser extends FloatingDialog{
Table icontable = new Table();
float isize = Unit.dp.scl(14*2);
float isize = 14*2;
ImageButton up = new ImageButton("icon-folder-parent");
up.resizeImage(isize);
@ -135,7 +135,7 @@ public class FileChooser extends FloatingDialog{
//content.add(navigation).colspan(3).left().padBottom(10f).expandX().fillX().height(40f);
//content.row();
content.center().add(pane).width(Gdx.graphics.getWidth()/2).colspan(3).units(Unit.px).grow();
content.center().add(pane).width(Gdx.graphics.getWidth()/2).colspan(3).grow();
content.row();
if(!open){

View File

@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.utils.Align;
import io.anuke.ucore.scene.ui.Dialog;
import io.anuke.ucore.scene.ui.layout.Unit;
public class FloatingDialog extends Dialog{
@ -20,7 +19,7 @@ public class FloatingDialog extends Dialog{
@Override
public void addCloseButton(){
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.scl(30f), ()->{
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, ()->{
hide();
}).size(230f, 64f);

View File

@ -11,7 +11,6 @@ import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.scene.utils.Elements;
public class LevelDialog extends FloatingDialog{
@ -106,7 +105,7 @@ public class LevelDialog extends FloatingDialog{
maps.add(stack).width(170).top().pad(4f);
maps.padRight(Unit.dp.scl(26));
maps.padRight(26);
i ++;
}

View File

@ -12,7 +12,6 @@ import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
//TODO unified save/load dialogs
public class LoadDialog extends FloatingDialog{
@ -44,13 +43,13 @@ public class LoadDialog extends FloatingDialog{
pane = new ScrollPane(slots);
pane.setFadeScrollBars(false);
slots.padRight(Unit.dp.scl(24));
slots.padRight(24);
for(int i = 0; i < Vars.saveSlots; i++){
final int slot = i;
TextButton button = new TextButton("[accent]Slot " + (i + 1));
button.pad(Unit.dp.scl(12));
button.pad(12);
button.getLabelCell().top().left().growX();
button.row();

View File

@ -11,7 +11,6 @@ import io.anuke.ucore.scene.builders.imagebutton;
import io.anuke.ucore.scene.ui.ConfirmDialog;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.layout.Cell;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MenuDialog extends FloatingDialog{
private SaveDialog save = new SaveDialog();
@ -74,7 +73,7 @@ public class MenuDialog extends FloatingDialog{
PressGroup group = new PressGroup();
content().defaults().size(120f).pad(5);
float isize = Unit.dp.scl(14f*4);
float isize = 14f*4;
new imagebutton("icon-play-2", isize, () -> {
hide();

View File

@ -6,7 +6,6 @@ import com.badlogic.gdx.utils.Align;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.KeybindDialog;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MindustryKeybindDialog extends KeybindDialog{
@ -22,7 +21,7 @@ public class MindustryKeybindDialog extends KeybindDialog{
@Override
public void addCloseButton(){
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.scl(30f), ()->{
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, ()->{
hide();
}).size(230f, 64f);

View File

@ -7,7 +7,6 @@ import com.badlogic.gdx.utils.Align;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.ScrollPane;
import io.anuke.ucore.scene.ui.SettingsDialog;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MindustrySettingsDialog extends SettingsDialog{
@ -32,7 +31,7 @@ public class MindustrySettingsDialog extends SettingsDialog{
@Override
public void addCloseButton(){
buttons().addImageTextButton("Back", "icon-arrow-left", Unit.dp.scl(30f), ()->{
buttons().addImageTextButton("Back", "icon-arrow-left", 30f, ()->{
hide();
}).size(230f, 64f);

View File

@ -20,7 +20,6 @@ import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Stack;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Mathf;
public class BlocksFragment implements Fragment{
@ -143,7 +142,7 @@ public class BlocksFragment implements Fragment{
desctable.defaults().left();
desctable.left();
desctable.pad(Unit.dp.scl(12));
desctable.pad(12);
Table header = new Table();

View File

@ -23,7 +23,6 @@ import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.layout.Cell;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class HudFragment implements Fragment{
private Table itemtable, respawntable;
@ -38,7 +37,7 @@ public class HudFragment implements Fragment{
new table(){{
left();
defaults().size(68).left();
float isize = Unit.dp.scl(40);
float isize = 40;
new imagebutton("icon-menu", isize, ()->{
ui.showMenu();
@ -92,7 +91,7 @@ public class HudFragment implements Fragment{
atop();
new table("pane"){{
new label("[orange]< paused >").scale(Unit.dp.scl(0.75f)).pad(6);
new label("[orange]< paused >").scale(0.75f).pad(6);
}}.end();
}}.end();
@ -181,7 +180,7 @@ public class HudFragment implements Fragment{
}
private void playButton(float uheight){
new imagebutton("icon-play", Unit.dp.scl(30f), ()->{
new imagebutton("icon-play", 30f, ()->{
Vars.control.runWave();
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36)
.padLeft(-10f).width(40f).update(l->{

View File

@ -11,7 +11,6 @@ import io.anuke.mindustry.ui.MenuButton;
import io.anuke.mindustry.ui.PressGroup;
import io.anuke.ucore.scene.builders.imagebutton;
import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class MenuFragment implements Fragment{
@ -46,7 +45,7 @@ public class MenuFragment implements Fragment{
if(!gwt){
add(new MenuButton("text-exit", group, Gdx.app::exit));
}
get().pad(Unit.dp.scl(16));
get().pad(16);
}}.end();
visible(()->GameState.is(State.menu));
@ -55,7 +54,7 @@ public class MenuFragment implements Fragment{
new table(){{
new table(){{
defaults().size(120f).pad(5);
float isize = Unit.dp.scl(14f*4);
float isize = 14f*4;
new imagebutton("icon-play-2", isize, () -> ui.showLevels()).text("Play").padTop(4f);
@ -84,11 +83,11 @@ public class MenuFragment implements Fragment{
new table(){{
atop().aright();
if(Mindustry.hasDiscord){
new imagebutton("icon-discord", Unit.dp.scl(30f), ()->{
new imagebutton("icon-discord", 30f, ()->{
ui.showDiscord();
}).margin(14);
}
new imagebutton("icon-info", Unit.dp.scl(30f), ()->{
new imagebutton("icon-info", 30f, ()->{
ui.showAbout();
}).margin(14);
}}.end().visible(()->GameState.is(State.menu));

View File

@ -12,7 +12,6 @@ import io.anuke.ucore.scene.builders.*;
import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Mathf;
public class PlacementFragment implements Fragment{
@ -57,7 +56,7 @@ public class PlacementFragment implements Fragment{
defaults().padBottom(-5.5f);
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.scl(10*3), ()->{
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
control.getInput().resetCursor();
player.placeMode = mode;
}).group(group);
@ -67,14 +66,14 @@ public class PlacementFragment implements Fragment{
Color color = Color.GRAY;//Colors.get("accent"); //Color.valueOf("4d4d4d")
new imagebutton("icon-cancel", Unit.dp.scl(14*3), ()->{
new imagebutton("icon-cancel", 14*3, ()->{
player.recipe = null;
}).imageColor(color)
.visible(()->player.recipe != null);
new button("", ()->{}).get().setTouchable(Touchable.disabled);;
new imagebutton("icon-arrow", Unit.dp.scl(14*3), ()->{
new imagebutton("icon-arrow", 14*3, ()->{
player.rotation = Mathf.mod(player.rotation + 1, 4);
}).imageColor(color).visible(() -> player.recipe != null).update(image ->{
image.getImage().setRotation(player.rotation*90);
@ -108,7 +107,7 @@ public class PlacementFragment implements Fragment{
defaults().padBottom(d < 2 ? -5.5f : 0);
new imagebutton("icon-" + mode.name(), "toggle", Unit.dp.scl(10*3), ()->{
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
control.getInput().resetCursor();
player.breakMode = mode;
}){{

View File

@ -10,23 +10,25 @@ import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.input.PlaceMode;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
public class ToolFragment implements Fragment{
private Table tools;
public void build(){
float isize = 14*3;
tools = new Table();
tools.addIButton("icon-cancel", Unit.dp.scl(42), ()->{
tools.addIButton("icon-cancel", isize, ()->{
player.recipe = null;
});
tools.addIButton("icon-rotate", Unit.dp.scl(42), ()->{
tools.addIButton("icon-rotate", isize, ()->{
player.rotation ++;
player.rotation %= 4;
});
tools.addIButton("icon-check", Unit.dp.scl(42), ()->{
tools.addIButton("icon-check", isize, ()->{
player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY());
});

View File

@ -13,7 +13,6 @@ import io.anuke.mindustry.world.blocks.types.Configurable;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
@ -93,7 +92,7 @@ public class Sorter extends Junction implements Configurable{
public void buildTable(Tile tile, Table table){
SorterEntity entity = tile.entity();
table.addIButton("icon-arrow-left", Unit.dp.scl(10*3), ()->{
table.addIButton("icon-arrow-left", 10*3, ()->{
int color = entity.sortItem.ordinal();
color --;
@ -105,7 +104,7 @@ public class Sorter extends Junction implements Configurable{
table.add().size(40f);
table.addIButton("icon-arrow-right", Unit.dp.scl(10*3), ()->{
table.addIButton("icon-arrow-right", 10*3, ()->{
int color = entity.sortItem.ordinal();
color ++;

View File

@ -16,7 +16,6 @@ import io.anuke.mindustry.world.blocks.types.Configurable;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Mathf;
public class Teleporter extends Block implements Configurable{
@ -69,13 +68,13 @@ public class Teleporter extends Block implements Configurable{
public void buildTable(Tile tile, Table table){
TeleporterEntity entity = tile.entity();
table.addIButton("icon-arrow-left", Unit.dp.scl(10*3), ()->{
table.addIButton("icon-arrow-left", 10*3, ()->{
entity.color = (byte)Mathf.mod(entity.color - 1, colors);
});
table.add().size(40f);
table.addIButton("icon-arrow-right", Unit.dp.scl(10*3), ()->{
table.addIButton("icon-arrow-right", 10*3, ()->{
entity.color = (byte)Mathf.mod(entity.color + 1, colors);
});
}

View File

@ -1,5 +1,9 @@
package io.anuke.mindustry.desktop;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.utils.Array;
import java.awt.Desktop;
import java.io.IOException;
import java.net.URI;
@ -7,18 +11,18 @@ import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.io.PlatformFunction;
import io.anuke.ucore.scene.ui.TextField;
import io.anuke.ucore.scene.ui.layout.Unit;
public class DesktopLauncher {
public static void main (String[] arg) {
Unit.dp.addition = 2f;
Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration();
config.setTitle("Mindustry");
config.setMaximized(true);