mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-15 05:43:02 -08:00
Add Discord link and fix more placement bugs
This commit is contained in:
parent
93f58bb458
commit
7ecbd3afd0
21 changed files with 344 additions and 275 deletions
|
|
@ -3,7 +3,8 @@
|
|||
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).
|
||||
|
||||
_[TODO list](TODO.md)_
|
||||
_[Wiki](http://mindustry.wikia.com/wiki/Mindustry_Wiki)_
|
||||
_[Wiki](http://mindustry.wikia.com/wiki/Mindustry_Wiki)_
|
||||
_[Discord](https://discord.gg/r8BkXNd)_
|
||||
|
||||
### Building
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.anuke.mindustry"
|
||||
android:versionCode="33"
|
||||
android:versionName="3.1" >
|
||||
android:versionCode="34"
|
||||
android:versionName="3.1b1" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@ import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import io.anuke.mindustry.io.Formatter;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
import io.anuke.ucore.function.Callable;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
|
||||
public class AndroidLauncher extends AndroidApplication{
|
||||
|
|
@ -23,8 +25,9 @@ public class AndroidLauncher extends AndroidApplication{
|
|||
super.onCreate(savedInstanceState);
|
||||
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
|
||||
config.useImmersiveMode = true;
|
||||
|
||||
Mindustry.formatter = new Formatter(){
|
||||
|
||||
Mindustry.hasDiscord = isPackageInstalled("com.discord");
|
||||
Mindustry.platforms = new PlatformFunction(){
|
||||
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm");
|
||||
|
||||
@Override
|
||||
|
|
@ -36,9 +39,16 @@ public class AndroidLauncher extends AndroidApplication{
|
|||
public String format(int number){
|
||||
return NumberFormat.getIntegerInstance().format(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLink(String link){
|
||||
Uri marketUri = Uri.parse(link);
|
||||
Intent intent = new Intent( Intent.ACTION_VIEW, marketUri );
|
||||
startActivity(intent);
|
||||
}
|
||||
};
|
||||
|
||||
Mindustry.donationsCallable = this::showDonations;
|
||||
Mindustry.donationsCallable = new Callable(){ @Override public void run(){ showDonations(); } };
|
||||
|
||||
if(doubleScaleTablets){
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
|
|
@ -63,6 +73,15 @@ public class AndroidLauncher extends AndroidApplication{
|
|||
initialize(new Mindustry(), config);
|
||||
}
|
||||
|
||||
private boolean isPackageInstalled(String packagename) {
|
||||
try {
|
||||
getPackageManager().getPackageInfo(packagename, 0);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void showDonations(){
|
||||
Intent intent = new Intent(this, DonationsActivity.class);
|
||||
startActivity(intent);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ project(":core") {
|
|||
apply plugin: "java"
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.Anuken:ucore:5984abc'
|
||||
compile 'com.github.anuken:ucore:d56206b7c0'
|
||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||
}
|
||||
|
|
|
|||
BIN
core/assets-raw/sprites/ui/icon-discord.png
Normal file
BIN
core/assets-raw/sprites/ui/icon-discord.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 214 B |
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
|
|
@ -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<>();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package io.anuke.mindustry.desktop;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
|
@ -9,7 +12,8 @@ import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
|||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.io.Formatter;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
|
||||
public class DesktopLauncher {
|
||||
|
||||
|
|
@ -21,7 +25,7 @@ public class DesktopLauncher {
|
|||
config.setWindowIcon("sprites/icon.png");
|
||||
//config.useVsync(false);
|
||||
|
||||
Mindustry.formatter = new Formatter(){
|
||||
Mindustry.platforms = new PlatformFunction(){
|
||||
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm");
|
||||
|
||||
@Override
|
||||
|
|
@ -33,6 +37,16 @@ public class DesktopLauncher {
|
|||
public String format(int number){
|
||||
return NumberFormat.getIntegerInstance().format(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLink(String link){
|
||||
try{
|
||||
Desktop.getDesktop().browse(URI.create(link));
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
Vars.ui.showError("Error opening link.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Mindustry.args = Array.with(arg);
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ import com.google.gwt.dom.client.*;
|
|||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.i18n.client.NumberFormat;
|
||||
import com.google.gwt.i18n.shared.DateTimeFormat;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.*;
|
||||
|
||||
import io.anuke.mindustry.Mindustry;
|
||||
import io.anuke.mindustry.io.Formatter;
|
||||
import io.anuke.mindustry.io.PlatformFunction;
|
||||
|
||||
public class HtmlLauncher extends GwtApplication {
|
||||
static final int WIDTH = 800;
|
||||
|
|
@ -88,7 +89,7 @@ public class HtmlLauncher extends GwtApplication {
|
|||
}
|
||||
});
|
||||
|
||||
Mindustry.formatter = new Formatter(){
|
||||
Mindustry.platforms = new PlatformFunction(){
|
||||
DateTimeFormat format = DateTimeFormat.getFormat("EEE, dd MMM yyyy HH:mm:ss");
|
||||
|
||||
@Override
|
||||
|
|
@ -100,6 +101,11 @@ public class HtmlLauncher extends GwtApplication {
|
|||
public String format(int number){
|
||||
return NumberFormat.getDecimalFormat().format(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openLink(String link){
|
||||
Window.open(link, "_blank", "");
|
||||
}
|
||||
};
|
||||
|
||||
return new Mindustry();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue