1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-22 13:57:46 +03:00

Merge branch 'master' into weapon-upgrade-rework

This commit is contained in:
Anuken 2018-01-08 17:32:44 -05:00 committed by GitHub
commit b1cb107c1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 48 additions and 34 deletions

View File

@ -6,7 +6,7 @@
A pixelated sandbox tower defense game made using [LibGDX](https://libgdx.badlogicgames.com/). Winner of the [GDL Metal Monstrosity Jam](https://itch.io/jam/gdl---metal-monstrosity-jam).
_[Issue tracker](https://waffle.io/Anuken/Mindustry)_
_[Issue tracker](https://waffle.io/Anuken/Mindustry)_
_[TODO list](TODO.md)_
_[Wiki](http://mindustry.wikia.com/wiki/Mindustry_Wiki)_
_[Discord](https://discord.gg/r8BkXNd)_
@ -33,7 +33,7 @@ _Building:_ `./gradlew desktop:dist`
---
Gradle may take up to several minutes to download files. Be patient. <br>
After building, the output .JAR file should be in the output JAR file should be in `/desktop/build/libs/desktop-1.0.jar.`
After building, the output .JAR file should be in the output JAR file should be in `/desktop/build/libs/desktop-release.jar.`
### Downloads

View File

@ -56,8 +56,8 @@ public class AndroidLauncher extends AndroidApplication{
}
@Override
public void addDialog(TextField field){
TextFieldDialogListener.add(field);
public void addDialog(TextField field, int length){
TextFieldDialogListener.add(field, 0, length);
}
@Override

View File

@ -22,6 +22,7 @@ import io.anuke.ucore.scene.ui.TextField;
import io.anuke.ucore.scene.ui.TextField.TextFieldFilter;
import io.anuke.ucore.scene.ui.TooltipManager;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.control;
import static io.anuke.ucore.scene.actions.Actions.*;
@ -68,11 +69,6 @@ public class UI extends SceneModule{
)
));
skin.font().setUseIntegerPositions(false);
skin.font().getData().setScale(Vars.fontscale);
skin.font().getData().down += 4f;
skin.font().getData().lineHeight -= 2f;
TooltipManager.getInstance().animations = false;
Settings.setErrorHandler(()-> Timers.run(1f, ()-> showError("[crimson]Failed to access local storage.\nSettings will not be saved.")));
@ -104,6 +100,12 @@ public class UI extends SceneModule{
@Override
protected void loadSkin(){
skin = new Skin(Gdx.files.internal("ui/uiskin.json"), Core.atlas);
Mathf.each(font -> {
font.setUseIntegerPositions(false);
font.getData().setScale(Vars.fontscale);
font.getData().down += Unit.dp.scl(4f);
font.getData().lineHeight -= Unit.dp.scl(2f);
}, skin.font(), skin.getFont("default-font-chat"));
}
@Override

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.resource.ItemStack;
@ -27,6 +28,7 @@ import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.player;
public abstract class InputHandler extends InputAdapter{
public float breaktime = 0;
@ -106,9 +108,11 @@ public abstract class InputHandler extends InputAdapter{
return false;
}
}
if(!Vars.android && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){
return false;
for(Player player : Vars.control.playerGroup.all()){
if(!player.isAndroid && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))){
return false;
}
}
Tile tile = world.tile(x, y);

View File

@ -8,7 +8,10 @@ public abstract class PlatformFunction{
public String format(Date date){return "invalid";}
public String format(int number){return "invalid";}
public void openLink(String link){}
public void addDialog(TextField field){}
public void addDialog(TextField field){
addDialog(field, 16);
}
public void addDialog(TextField field, int maxLength){}
public void updateRPC(){}
public void onGameExit(){}
public void openDonations(){}

View File

@ -5,7 +5,7 @@ import static io.anuke.mindustry.Vars.aboutText;
public class AboutDialog extends FloatingDialog {
public AboutDialog(){
super("$text.about");
super("$text.about.button");
addCloseButton();

View File

@ -50,6 +50,7 @@ public class FileChooser extends FloatingDialog {
Table content = new Table();
filefield = new TextField();
filefield.setOnlyFontChars(false);
if(!open) Mindustry.platforms.addDialog(filefield);
filefield.setDisabled(open);

View File

@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Mindustry;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState;
import io.anuke.mindustry.core.GameState.State;
@ -19,6 +20,7 @@ import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.Label.LabelStyle;
import io.anuke.ucore.scene.ui.TextField;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import static io.anuke.ucore.core.Core.scene;
import static io.anuke.ucore.core.Core.skin;
@ -29,16 +31,15 @@ public class ChatFragment extends Table implements Fragment{
private final static int maxLength = 150;
private Array<ChatMessage> messages = new Array<>();
private float fadetime;
private float lastfadetime;
private boolean chatOpen = false;
private TextField chatfield;
private Label fieldlabel = new Label(">");
private BitmapFont font;
private GlyphLayout layout = new GlyphLayout();
private float offsetx = 4, offsety = 4, fontoffsetx = 2, chatspace = 50;
private float textWidth = 600;
private float offsetx = Unit.dp.scl(4), offsety = Unit.dp.scl(4), fontoffsetx = Unit.dp.scl(2), chatspace = Unit.dp.scl(50);
private float textWidth = Unit.dp.scl(600);
private Color shadowColor = new Color(0, 0, 0, 0.4f);
private float textspacing = 10;
private float textspacing = Unit.dp.scl(10);
public ChatFragment(){
super();
@ -73,6 +74,8 @@ public class ChatFragment extends Table implements Fragment{
chatfield.getStyle().background = skin.getDrawable("chatfield");
chatfield.getStyle().fontColor = Color.WHITE;
chatfield.getStyle().font = skin.getFont("default-font-chat");
chatfield.setStyle(chatfield.getStyle());
Mindustry.platforms.addDialog(chatfield, maxLength);
bottom().left().marginBottom(offsety).marginLeft(offsetx*2).add(fieldlabel).padBottom(4f);
@ -87,8 +90,9 @@ public class ChatFragment extends Table implements Fragment{
if(chatOpen)
batch.draw(skin.getRegion("white"), offsetx, chatfield.getY(), Gdx.graphics.getWidth()-offsetx*2, chatfield.getHeight()-1);
font.getData().down = -21.5f;
font.getData().lineHeight = 22f;
//font.getData().down = Unit.dp.scl(-21.5f);
//font.getData().lineHeight = 22f;
//chatfield.getStyle().font.getData().setScale(Vars.fontscale);
super.draw(batch, alpha);
@ -114,7 +118,7 @@ public class ChatFragment extends Table implements Fragment{
batch.setColor(0, 0, 0, shadowColor.a*(fadetime-i));
}
batch.draw(skin.getRegion("white"), offsetx, theight-layout.height+1-4, textWidth, layout.height+textspacing);
batch.draw(skin.getRegion("white"), offsetx, theight-layout.height+1-4, textWidth + Unit.dp.scl(4f), layout.height+textspacing);
batch.setColor(shadowColor);
font.getCache().draw(batch);
@ -141,7 +145,6 @@ public class ChatFragment extends Table implements Fragment{
if(!chatOpen && (scene.getKeyboardFocus() == null || !scene.getKeyboardFocus().getParent().isVisible())){
scene.setKeyboardFocus(chatfield);
chatOpen = !chatOpen;
lastfadetime = fadetime;
fadetime = messagesShown + 1;
}else if(chatOpen){
scene.setKeyboardFocus(null);
@ -170,7 +173,7 @@ public class ChatFragment extends Table implements Fragment{
public ChatMessage(String message, String sender){
this.message = message;
this.sender = sender;
if(sender == null){ //no sender, this is a server message
if(sender == null){ //no sender, this is a server message?
formattedMessage = message;
}else{
formattedMessage = "[ROYAL]["+sender+"]: [YELLOW]"+message;

View File

@ -65,6 +65,7 @@ public class HudFragment implements Fragment{
pause = new imagebutton("icon-pause", isize, ()->{
if(Net.active() && Vars.android){
//TODO open android chat
ui.chatfrag.toggle();
}else {
GameState.set(GameState.is(State.paused) ? State.playing : State.paused);
}
@ -134,8 +135,7 @@ public class HudFragment implements Fragment{
//profiling table
if(debug){
new table(){{
abottom();
aleft();
atop();
new label("[green]density: " + Gdx.graphics.getDensity()).left();
row();
new label(() -> "[blue]requests: " + renderer.getBlocks().getRequests()).left();

View File

@ -9,19 +9,19 @@ public class DefenseBlocks{
static final int wallHealthMultiplier = 4;
public static final Block
stonewall = new Wall("stonewall"){{
health = 50*wallHealthMultiplier;
}},
ironwall = new Wall("ironwall"){{
health = 80*wallHealthMultiplier;
}},
steelwall = new Wall("steelwall"){{
health = 110*wallHealthMultiplier;
}},
titaniumwall = new Wall("titaniumwall"){{
health = 150*wallHealthMultiplier;
}},
@ -46,24 +46,25 @@ public class DefenseBlocks{
titaniumshieldwall = new ShieldedWallBlock("titaniumshieldwall"){{
health = 150*wallHealthMultiplier;
}},
repairturret = new RepairTurret("repairturret"){
{
range = 30;
reload = 40f;
health = 60;
powerUsed = 0.08f;
}
},
megarepairturret = new RepairTurret("megarepairturret"){
{
range = 44;
reload = 20f;
powerUsed = 0.15f;
reload = 20f;
health = 90;
powerUsed = 0.13f;
}
},
shieldgenerator = new ShieldBlock("shieldgenerator"){
{
health = 100*wallHealthMultiplier;