Add Discord link and fix more placement bugs
This commit is contained in:
@@ -6,7 +6,7 @@ import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.io.Formatter;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
@@ -16,10 +16,12 @@ import io.anuke.ucore.modules.ModuleCore;
|
||||
|
||||
public class Mindustry extends ModuleCore {
|
||||
public static Callable donationsCallable;
|
||||
public static boolean hasDiscord = true;
|
||||
public static Array<String> args = new Array<>();
|
||||
public static Formatter formatter = new Formatter(){
|
||||
public static PlatformFunction platforms = new PlatformFunction(){
|
||||
@Override public String format(Date date){ return "invalid date"; }
|
||||
@Override public String format(int number){ return number + ""; }
|
||||
@Override public void openLink(String link){ }
|
||||
};
|
||||
|
||||
//always initialize blocks in this order, otherwise there are ID errors
|
||||
|
||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class Vars{
|
||||
public static final boolean testAndroid = true;
|
||||
public static final boolean testAndroid = false;
|
||||
//shorthand for whether or not this is running on android
|
||||
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
|
||||
//shorthand for whether or not this is running on GWT
|
||||
@@ -26,6 +26,8 @@ public class Vars{
|
||||
public static final float aheadPathfinding = 60*20;
|
||||
//how far away from spawn points the player can't place blocks
|
||||
public static final float enemyspawnspace = 65;
|
||||
//discord group URL
|
||||
public static final String discordURL = "https://discord.gg/r8BkXNd";
|
||||
//scale of the font
|
||||
public static float fontscale = Unit.dp.inPixels(1f)/2f;
|
||||
//camera zoom displayed on startup
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Tutorial{
|
||||
|
||||
new table("pane"){{
|
||||
atop();
|
||||
get().pad(Unit.dp.inPixels(12));
|
||||
margin(12);
|
||||
|
||||
info = new label(()->stage.text).pad(10f).padBottom(5f).width(340f).units(Unit.dp).colspan(2).get();
|
||||
info.setWrap(true);
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.badlogic.gdx.math.Vector2;
|
||||
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.State;
|
||||
import io.anuke.mindustry.ui.*;
|
||||
@@ -37,7 +38,7 @@ public class UI extends SceneModule{
|
||||
Table loadingtable, desctable, configtable;
|
||||
MindustrySettingsDialog prefs;
|
||||
MindustryKeybindDialog keys;
|
||||
Dialog about, restart, levels, upgrades, load, settingserror, gameerror;
|
||||
Dialog about, restart, levels, upgrades, load, settingserror, gameerror, discord;
|
||||
MenuDialog menu;
|
||||
Tooltip tooltip;
|
||||
Tile configTile;
|
||||
@@ -170,9 +171,16 @@ public class UI extends SceneModule{
|
||||
+ "\n[ORANGE]anukendev@gmail.com[]"){{
|
||||
setWrap(true);
|
||||
}}).width(600f).units(Unit.dp).pad(10f);
|
||||
gameerror.buttons().addButton("OK", ()-> gameerror.hide()).size(200f, 50).units(Unit.dp);
|
||||
gameerror.buttons().addButton("OK", gameerror::hide).size(200f, 50).units(Unit.dp);
|
||||
//gameerror.setFillParent(true);
|
||||
|
||||
discord = new Dialog("Discord", "dialog");
|
||||
discord.content().pad(Unit.dp.inPixels(12f));
|
||||
discord.content().add("Join the mindustry discord!\n[orange]" + Vars.discordURL);
|
||||
discord.buttons().defaults().size(200f, 50).units(Unit.dp);
|
||||
discord.buttons().addButton("Open link", () -> Mindustry.platforms.openLink(Vars.discordURL));
|
||||
discord.buttons().addButton("Back", discord::hide);
|
||||
|
||||
load = new LoadDialog();
|
||||
|
||||
upgrades = new UpgradeDialog();
|
||||
@@ -426,6 +434,10 @@ public class UI extends SceneModule{
|
||||
public void showUpgrades(){
|
||||
upgrades.show();
|
||||
}
|
||||
|
||||
public void showDiscord(){
|
||||
discord.show();
|
||||
}
|
||||
|
||||
public void updateItems(){
|
||||
((HudFragment)hudfrag).updateItems();
|
||||
|
||||
@@ -42,7 +42,7 @@ public class EditorUI extends SceneModule{
|
||||
}).left();
|
||||
row();
|
||||
}
|
||||
get().pad(16);
|
||||
margin(16);
|
||||
}}.end();
|
||||
}}.end();
|
||||
build.end();
|
||||
|
||||
@@ -313,10 +313,7 @@ public class Fx{
|
||||
breakBlock = new Effect(12, e -> {
|
||||
Draw.thickness(2f);
|
||||
Draw.color(Color.WHITE, Colors.get("break"), e.ifract());
|
||||
Draw.spikes(e.x, e.y, e.ifract() * 5f, 2, 5, 90);
|
||||
|
||||
Draw.thickness(2f - e.ifract() * 2f);
|
||||
Draw.polygon(4, e.x, e.y, Vars.tilesize / 1.6f + e.ifract() * 5f, 45);
|
||||
Draw.spikes(e.x, e.y, e.ifract() * 6f, 2, 5, 90);
|
||||
Draw.reset();
|
||||
}),
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ package io.anuke.mindustry.io;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface Formatter{
|
||||
public interface PlatformFunction{
|
||||
public String format(Date date);
|
||||
public String format(int number);
|
||||
public void openLink(String link);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class SaveIO{
|
||||
try(DataInputStream stream = new DataInputStream(fileFor(slot).read())){
|
||||
stream.readInt();
|
||||
Date date = new Date(stream.readLong());
|
||||
return Mindustry.formatter.format(date);
|
||||
return Mindustry.platforms.format(date);
|
||||
}catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class BlocksFragment implements Fragment{
|
||||
|
||||
row();
|
||||
add(stack).colspan(Section.values().length);
|
||||
get().pad(10f);
|
||||
margin(10f);
|
||||
|
||||
get().padLeft(0f);
|
||||
get().padRight(0f);
|
||||
|
||||
@@ -169,7 +169,7 @@ public class HudFragment implements Fragment{
|
||||
(control.getTutorial().active() || Vars.control.getMode() == GameMode.sandbox) ? "waiting..." : "Wave in " + (int) (control.getWaveCountdown() / 60f))
|
||||
.minWidth(140).units(Unit.dp).left();
|
||||
|
||||
get().pad(Unit.dp.inPixels(12));
|
||||
margin(12f);
|
||||
get().padLeft(6);
|
||||
}}.left().end();
|
||||
|
||||
@@ -206,7 +206,7 @@ public class HudFragment implements Fragment{
|
||||
for(int i = 0; i < control.getItems().length; i ++){
|
||||
int amount = control.getItems()[i];
|
||||
if(amount == 0) continue;
|
||||
String formatted = Mindustry.formatter.format(amount);
|
||||
String formatted = Mindustry.platforms.format(amount);
|
||||
if(amount > 99999999){
|
||||
formatted = "inf";
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
@@ -14,6 +12,11 @@ import io.anuke.ucore.scene.builders.imagebutton;
|
||||
import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
import static io.anuke.mindustry.Vars.android;
|
||||
import static io.anuke.mindustry.Vars.control;
|
||||
import static io.anuke.mindustry.Vars.gwt;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
|
||||
public class MenuFragment implements Fragment{
|
||||
|
||||
public void build(){
|
||||
@@ -77,9 +80,14 @@ public class MenuFragment implements Fragment{
|
||||
//settings icon
|
||||
new table(){{
|
||||
atop().aright();
|
||||
if(Mindustry.hasDiscord){
|
||||
new imagebutton("icon-discord", Unit.dp.inPixels(30f), ()->{
|
||||
ui.showDiscord();
|
||||
}).margin(14);
|
||||
}
|
||||
new imagebutton("icon-info", Unit.dp.inPixels(30f), ()->{
|
||||
ui.showAbout();
|
||||
}).get().pad(Unit.dp.inPixels(14));
|
||||
}).margin(14);
|
||||
}}.end().visible(()->GameState.is(State.menu));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PlacementFragment implements Fragment{
|
||||
row();
|
||||
|
||||
new table("pane"){{
|
||||
get().pad(5);
|
||||
margin(5f);
|
||||
aleft();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
@@ -94,7 +94,7 @@ public class PlacementFragment implements Fragment{
|
||||
row();
|
||||
|
||||
new table("pane"){{
|
||||
get().pad(5);
|
||||
margin(5f);
|
||||
touchable(Touchable.enabled);
|
||||
aleft();
|
||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||
|
||||
Reference in New Issue
Block a user