From f2662045ed74e5c2834415df880113f09f9fa7f8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 13 Mar 2019 21:26:53 -0400 Subject: [PATCH] New item bars / Map bugfixes / Stub wave editing --- .../blocks/environment/shale-boulder1.png | Bin 0 -> 132 bytes .../blocks/environment/shale-boulder2.png | Bin 0 -> 129 bytes .../sprites/blocks/environment/shale1.png | Bin 0 -> 1070 bytes .../sprites/blocks/environment/shale2.png | Bin 0 -> 1066 bytes .../sprites/blocks/environment/shale3.png | Bin 0 -> 1085 bytes .../blocks/environment/shalerocks-large.png | Bin 0 -> 182 bytes .../blocks/environment/shalerocks1.png | Bin 0 -> 117 bytes .../blocks/environment/shalerocks2.png | Bin 0 -> 117 bytes core/assets/bundles/bundle.properties | 5 +++ .../io/anuke/mindustry/content/Blocks.java | 2 +- .../mindustry/editor/MapEditorDialog.java | 2 +- .../anuke/mindustry/editor/MapInfoDialog.java | 25 ++++++----- .../anuke/mindustry/editor/MapLoadDialog.java | 2 +- .../mindustry/editor/WaveInfoDialog.java | 18 ++++++++ .../io/anuke/mindustry/game/SpawnGroup.java | 38 +++++++++++++++- core/src/io/anuke/mindustry/game/Stats.java | 6 +-- core/src/io/anuke/mindustry/graphics/Pal.java | 1 + core/src/io/anuke/mindustry/io/SaveMeta.java | 2 +- .../anuke/mindustry/io/versions/Save16.java | 4 +- core/src/io/anuke/mindustry/maps/Map.java | 18 +++----- core/src/io/anuke/mindustry/maps/Maps.java | 41 ++++++++++++++---- .../ui/dialogs/CustomGameDialog.java | 2 +- .../mindustry/ui/dialogs/LoadDialog.java | 2 +- .../mindustry/ui/dialogs/MapsDialog.java | 20 +++++---- core/src/io/anuke/mindustry/world/Block.java | 4 ++ .../blocks/distribution/LiquidJunction.java | 6 +++ .../world/blocks/sandbox/ItemSource.java | 6 +++ .../world/blocks/storage/Unloader.java | 6 +++ .../mindustry/desktop/DesktopLauncher.java | 1 + .../mindustry/desktop/DesktopPlatform.java | 4 +- .../anuke/mindustry/server/ServerControl.java | 4 +- 31 files changed, 163 insertions(+), 56 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/environment/shale-boulder1.png create mode 100644 core/assets-raw/sprites/blocks/environment/shale-boulder2.png create mode 100644 core/assets-raw/sprites/blocks/environment/shale1.png create mode 100644 core/assets-raw/sprites/blocks/environment/shale2.png create mode 100644 core/assets-raw/sprites/blocks/environment/shale3.png create mode 100644 core/assets-raw/sprites/blocks/environment/shalerocks-large.png create mode 100644 core/assets-raw/sprites/blocks/environment/shalerocks1.png create mode 100644 core/assets-raw/sprites/blocks/environment/shalerocks2.png create mode 100644 core/src/io/anuke/mindustry/editor/WaveInfoDialog.java diff --git a/core/assets-raw/sprites/blocks/environment/shale-boulder1.png b/core/assets-raw/sprites/blocks/environment/shale-boulder1.png new file mode 100644 index 0000000000000000000000000000000000000000..66f88b2a064ae0c7bbd833a872af346ba002ae66 GIT binary patch literal 132 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4mJh`h9ms@x)~T4yggkULn>}1pEx(?aKP=& zoGt&I4VjJ7I{I^%9{zV|{XbFUplGvdqQo)|PeUh04}rFcq6d53!&-89yO?si0%SUK jgf>Y(=(=DKA;S>M+V?M5AnX_e0|SGntDnm{r-UW|>$@sL literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shale-boulder2.png b/core/assets-raw/sprites/blocks/environment/shale-boulder2.png new file mode 100644 index 0000000000000000000000000000000000000000..4b45697887a3cb9f00b39143b774f9cc921d6e02 GIT binary patch literal 129 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4mJh`h9ms@x)~T4JUm?-Ln>}1pEx(?aKP=& zoGt&A6K6;;JJ+NLbNpx5`qRJcg}o1Bgiu?dmV-I#F*a?7V=vSU6}%IIk2Lt2`xtiV gZ%AMZ5MW?9<~*^=N_b@q0|Nttr>mdKI;Vst02L1>4FCWD literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shale1.png b/core/assets-raw/sprites/blocks/environment/shale1.png new file mode 100644 index 0000000000000000000000000000000000000000..5b44a22c0b993c52e94b603fb37b44fc58c0d8dd GIT binary patch literal 1070 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4kiW$2Jc+WI}8lWO;sTgB|(Yh3I#>^X_+~x z3MG{VsS2qTnQ06R6}Q$-k1Tqkz|(fWw9ArdlECT04Thn`&6fZEBwVT%`ku5(H(E^S z((y?bzP-<1Y`?=o-Tht?mnBR4>Gb(aA1LnpdrQ^Y{@wIl|LT@5zs%m~rC3_edwYxi zh1)xwzXb1(d9Atbvj42UeM`jK<`-^*`z z-9;8l{aHC7=hUkLf7`AkmRVaJwBD_`)O(?;%Jh!w{*|(GmQ!;g2O?bqWBx)kQWva#I1-E)_!}ab|NEba7b^fx+vqdD*wOucBiq7kXN7awj z1S_;MnL0(Uh-6vzwz}W3d9-$pz)mBb)`vap$7j3sPg%cZ^5Sd1uB4W|4AJiK{x#>A zfz{5scF~4{*``|q?_Ye8bZ-au2CgQvQ*$OH6rO&UWN3F@S9XqQ*)yA+wV4HLE;D+y z+-N(vp{ap;&9TN}JA^LY$clh_Wu7qJO}rNcwC6nc8co$7kI`PbEJ8;+T-t<()& z6{hoFDr?ECtaYi6d4n@Q&(2Nkj=uFNOzK(GVW9cIM;K!b8 zg+CwGo43+Y_VIM?ceguB(-hR^Iogyl)fT@x6O;6Q>EzdEV#IW~gaeXa7ig6yDZDTj z%dSZ(SNpDPZuDQo{AZs`X~}#AciFot<>%irZjCzDxrjL+zIE?1KWQ_w5+B!~n;S%S zA30c}y)^XOv9L|AFU{UPIc4|9OW)T$TrXd!@A2zkLZ))mfr;tL8+K29Q-0f2_e-qV zc`vI8{}#S^*_*R2-~v0FvC3Za8Jm|}_o|MMtWut>?Roypp81=WGryFd^u*3&;)}Uo zOK0ltW&0g>DSN|v)!Oe5Zx&s&-hE=}lKVV-)3}dceE(8@(wA$ucAS{Ux1?U98e+Eb zheDZJwtb3Q{STC<#&7YT_Be6dmv@}im6z`sfV`g3^U6BjBtZNw<80NDhfYTRS c6c`xZKb2fnrF&0=fq{X+)78&qol`;+00NctkpKVy literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shale2.png b/core/assets-raw/sprites/blocks/environment/shale2.png new file mode 100644 index 0000000000000000000000000000000000000000..bd6746d7a7c4ab0ab92227d4c20fefba48e4489c GIT binary patch literal 1066 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4kiW$2Jc+WI}8lW^;IDeB|(Yh3I#>^X_+~x z3MG{VsS2qTnQ06R6}Q$-kDhc`gU9v%)~-mVNdo;(6Ovb@v2XsfGvSfnrI#g>wylha zn5Me$@M5Ri_5aO&v5P-fd7`^)f^)%+ns1R@Rwv(H*Sq<%aR0Th&!uf;^;xu9ulzO4 zxxCLIKVII&{_E+r^B!6KUGnmUP^HxsxyTDM%QCHkZhp0yuX+A`*M6_sf48(AZ`J+1 z`ggi~U{BVE%=vzg-lS4_N6?958)hj~q|nxxhY_ z@`I(z+v;R=7pw9VvTo#>#eK_bPGrE_WAn7d^Y-xW{M03~H%Ca(HSFR-Zz@OZaJ*{Q7UR$oW+1q{Xgy~-_ zdrho%*0qZ^6wEf=8hHQWi>!M)v^Q`ynVp(raNyCjyGN7$m~JmA2)i-!^OJ8&4{r2h z*APsSo|MSSC?3(vyjw$PX5euaJJy-qRgn%2XO|e6ZV2RUn7ripG4qM-YiGR4%F#`3 zWa)KiW@U-EC;iO-3up0)8MD-lxy5uNw+Wg2NKkB%_$3#*$W30iO(MC=a@vxU>fVY+ zrv&+_dWYpCPIK;?5`1o_2#an(?1$1uSIusnT|bUa+i*lxw^CDk+4)!D(TAn3Z+W&g zWM$OGKiMlLX06&et=HUV>Dl~kt-5)cr=v4xWc$v}zvk4fyY{x!>LHEKO5To9Ad###CGU>P$@1`=yg#pNSFE;Svr=eqEqdo}}=? zTr9h0!*8YUQ>16schCOg(r2~H_(Y()`N`Vn-x{KHAG=&+T(SO8T<~&UX=ytj*Pxpl zM0OuJ_@!~la<)ra)ydj7OJAO?oxJU~-WBux69ep(|0}#a*uAtjgE4(s?}2x5o9^dc z-x4!vx%j64nI`7V3xy|1?!3TxlE*V&<#WiT?3@4X^j}PU6Yn|A&m+y_SFw??nJxFf zz9sg082V;9wg(WATM|NKQ=^((*FuR76N)W9Yw z#K6G7S>O>_%)p?h48n{ROYO@T7#P?~Jbhi+A2ahZ>1zDH>i&y?fx*tx#W95AdU6lv z>Ldr&JAWqe@bKsqh%qxCzTSWS;U%ApMFQ`x_n(ivaOIGs&IzuGPiI_kdDy@jtQ*1< c%)!Lq!Y%zE<>J$q3=9kmp00i_>zopr0Jg62g#Z8m literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shale3.png b/core/assets-raw/sprites/blocks/environment/shale3.png new file mode 100644 index 0000000000000000000000000000000000000000..f8678bd05f627e4f1c16314f7bd4de40fce1974b GIT binary patch literal 1085 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4kiW$2Jc+WI}8lWZB-!=B|(Yh3I#>^X_+~x z3MG{VsS2qTnQ06R6}Q$-k1cwl#nXC!Ygc5Gs-nQ@gU3Sd%HDZ;o^i6@f7Qn&yH-X- zur+?+3|#p4|9`2!2m3d3vwF)F_i)!Kw(GFU#`oP%Mmgkl$PIW&2dG4n<;fJnXdmeu~rDogL zA0_|ggqi|*zlC^|rN(~vvac(Neb!b7t$AxMu`d+m&8p~n_I%@F@9%mQ)9=N;nP&90 zN}4O`k&M9mB$KZ>=abEqO7<%Mi~0G?*>k$8T=Ml*+qcQzn<^l<(&O?<{%|*bX2Ej{ zlA~N+yYc=tiE=C6v7<49^{i;F@;RN3vd0Iea+}|4zf*Botoh9(1y{3+3yXaxrAh}l z<=;_Z^j9sNaKpiO;k46n6>DZ6uadS7Th}x3kioI$$FYmkPlew)8jx*UI#YcA5w72p z=3Tzwrha|C1gpZGG@slf8cqKz4pc4?CD1>qM3A$Uwja< zoUw%?TiWa}7n662Y2O}|iAQ=YtbT~Ri7`3B#gwBqb!B637K_aEeP+*86KJi^y67!@t>p2mYf$eyZvaI+5Jyp zt3uXV{4>4gay5Hh>T}tZTiWk_+p+xa_dV0wVzO^JZ5E5px>uwvo;CTEuIWDI@3yA% zu2^j}IJVS3D`5GT#HMP?jpulds2FrC_gf&o{9H~UpQF{zb2%rQoD-R{a%BCU`th(F zK9|(1|HkfQ?de{fKOM7cT>Gqcl}}jQmp7^U$+wm$-N$Yh8CT3dBzM_WnoC-(N>Jar zFKPOY8UIw5hVmT?`*bOFLtIw+^EF!z-?){1H)4N$=Y%g8Efueu^|;0~n!V8rpY%@D zU$y=4jc2dJ?_J{j?(b>!@Smoq`W<`Kmo2}StJKQR`+V=xr_Tj7i7yOo^eesX+y1w1 zf0FN&`^bE$+1{c{^F6DcF0r2s5&E4E!kDF|^&J>P#8Q%Kq=H72rp1XJU)kW`!Uffl$`%+)av$t~k zrd~+~1_sUokH}&M20djEW~^9hU&g?|z+U3%>&pI^nU_gdc4b=gO$G)AFHaZ85RU7~ zJ)EnP5_^AK@ literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shalerocks-large.png b/core/assets-raw/sprites/blocks/environment/shalerocks-large.png new file mode 100644 index 0000000000000000000000000000000000000000..ec311cc1fc7f1b4f529162cc1e1f1c7685816505 GIT binary patch literal 182 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7YCT;XLn>}1pEx(?^Zsq= z!Z&9q+HHDiujlOWs6~fCx*>FVdQ&MBb@0GGl)8~^|S literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shalerocks1.png b/core/assets-raw/sprites/blocks/environment/shalerocks1.png new file mode 100644 index 0000000000000000000000000000000000000000..d8af4693e92bdd7e2d990a8e11955164510fa742 GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4mJh`h9ms@x)~T4Y&=~YLn>}1d-%`&vwuyg zsNWd@;jpjrEfYnRHcKWyv5sN7W`XvEwTCt^-4rQt<+)LESR{EXQ!F!sr{j$B VXTkDE7#J8BJYD@<);T3K0RTU3BqIO- literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/environment/shalerocks2.png b/core/assets-raw/sprites/blocks/environment/shalerocks2.png new file mode 100644 index 0000000000000000000000000000000000000000..7a8d8b178b84030466aafa058b537035873c9b0d GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0y~yVBi2@4mJh`h9ms@x)~T4Y&=~YLn>}1d-%`&vwuyg zsNWd@;jpjrEs0zgO%I435IJZNCOknk(S+GYC{nOZ)PVJdNMc0eI*y|gZx}GhE}gL| Uev{A=1_lNOPgg&ebxsLQ0REpM%K!iX literal 0 HcmV?d00001 diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 0eed7a6252..e172c8b8ed 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -194,11 +194,15 @@ editor.oregen.info = Ore Generation: editor.mapinfo = Map Info editor.author = Author: editor.description = Description: +editor.waves = Waves: +editor.default = [LIGHT_GRAY] +edit = Edit... editor.name = Name: editor.teams = Teams editor.elevation = Elevation editor.errorload = Error loading file:\n[accent]{0} editor.errorsave = Error saving file:\n[accent]{0} +editor.errorname = Map has no name defined. editor.generate = Generate editor.resize = Resize editor.loadmap = Load Map @@ -309,6 +313,7 @@ blocks.poweroutput = Power Output: {0} blocks.powercapacity = Power Capacity blocks.powershot = Power/Shot blocks.targetsair = Targets Air +blocks.items = Items: {0} blocks.itemsmoved = Move Speed blocks.shootrange = Range blocks.size = Size diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index 97611cf371..5e4bb6cf0b 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -250,7 +250,7 @@ public class Blocks implements ContentList{ shale = new Floor("shale"){{ variants = 3; - attributes.set(Attribute.oil, 0.3f); + attributes.set(Attribute.oil, 0.15f); }}; shaleRocks = new StaticWall("shalerocks"){{ diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 3124248a32..240b293ce2 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -199,7 +199,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ } private void save(){ - String name = editor.getTags().get("name", ""); + String name = editor.getTags().get("name", "").trim(); if(name.isEmpty()){ infoDialog.show(); diff --git a/core/src/io/anuke/mindustry/editor/MapInfoDialog.java b/core/src/io/anuke/mindustry/editor/MapInfoDialog.java index f1e81e7ab0..a422552312 100644 --- a/core/src/io/anuke/mindustry/editor/MapInfoDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapInfoDialog.java @@ -9,22 +9,16 @@ import io.anuke.mindustry.ui.dialogs.FloatingDialog; public class MapInfoDialog extends FloatingDialog{ private final MapEditor editor; - - private TextArea description; - private TextField author; - private TextField name; + private final WaveInfoDialog waveinfo; public MapInfoDialog(MapEditor editor){ super("$editor.mapinfo"); this.editor = editor; + this.waveinfo = new WaveInfoDialog(editor); addCloseButton(); shown(this::setup); - - hidden(() -> { - - }); } private void setup(){ @@ -36,7 +30,7 @@ public class MapInfoDialog extends FloatingDialog{ cont.defaults().padTop(15); - name = cont.addField(tags.get("name", ""), text -> { + TextField name = cont.addField(tags.get("name", ""), text -> { tags.put("name", text); }).size(400, 55f).get(); name.setMessageText("$unknown"); @@ -45,7 +39,7 @@ public class MapInfoDialog extends FloatingDialog{ cont.add("$editor.description").padRight(8).left(); - description = cont.addArea(tags.get("description", ""), "textarea", text -> { + TextArea description = cont.addArea(tags.get("description", ""), "textarea", text -> { tags.put("description", text); }).size(400f, 140f).get(); @@ -53,13 +47,22 @@ public class MapInfoDialog extends FloatingDialog{ cont.add("$editor.author").padRight(8).left(); - author = cont.addField(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> { + TextField author = cont.addField(tags.get("author", Core.settings.getString("mapAuthor", "")), text -> { tags.put("author", text); Core.settings.put("mapAuthor", text); Core.settings.save(); }).size(400, 55f).get(); author.setMessageText("$unknown"); + cont.row(); + cont.add("$editor.waves").padRight(8).left(); + cont.table(t -> { + t.add().growX(); + t.label(() -> tags.containsKey("waves") ? "" : Core.bundle.get("editor.default")).left(); + t.add().growX(); + t.addButton("$edit", waveinfo::show).growY().width(200f); + }).size(400, 55f); + name.change(); description.change(); author.change(); diff --git a/core/src/io/anuke/mindustry/editor/MapLoadDialog.java b/core/src/io/anuke/mindustry/editor/MapLoadDialog.java index 0955dcdc6a..edca8d7868 100644 --- a/core/src/io/anuke/mindustry/editor/MapLoadDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapLoadDialog.java @@ -56,7 +56,7 @@ public class MapLoadDialog extends FloatingDialog{ for(Map map : world.maps.all()){ - TextButton button = new TextButton(map.getDisplayName(), "toggle"); + TextButton button = new TextButton(map.name(), "toggle"); button.add(new BorderImage(map.texture, 2f).setScaling(Scaling.fit)).size(16 * 4f); button.getCells().reverse(); button.clicked(() -> selected = map); diff --git a/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java b/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java new file mode 100644 index 0000000000..f2527cc6bb --- /dev/null +++ b/core/src/io/anuke/mindustry/editor/WaveInfoDialog.java @@ -0,0 +1,18 @@ +package io.anuke.mindustry.editor; + +import io.anuke.mindustry.ui.dialogs.FloatingDialog; + +public class WaveInfoDialog extends FloatingDialog{ + private final MapEditor editor; + + public WaveInfoDialog(MapEditor editor){ + super("$editor.waves"); + this.editor = editor; + + shown(this::setup); + } + + void setup(){ + + } +} diff --git a/core/src/io/anuke/mindustry/game/SpawnGroup.java b/core/src/io/anuke/mindustry/game/SpawnGroup.java index 64e399b3db..cfde9724b2 100644 --- a/core/src/io/anuke/mindustry/game/SpawnGroup.java +++ b/core/src/io/anuke/mindustry/game/SpawnGroup.java @@ -1,20 +1,26 @@ package io.anuke.mindustry.game; +import io.anuke.arc.util.serialization.Json; +import io.anuke.arc.util.serialization.Json.Serializable; +import io.anuke.arc.util.serialization.JsonValue; import io.anuke.mindustry.entities.type.BaseUnit; +import io.anuke.mindustry.type.ContentType; import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.type.StatusEffect; import io.anuke.mindustry.type.UnitType; +import static io.anuke.mindustry.Vars.content; + /** * A spawn group defines spawn information for a specific type of unit, with optional extra information like * weapon equipped, ammo used, and status effects. * Each spawn group can have multiple sub-groups spawned in different areas of the map. */ -public class SpawnGroup{ +public class SpawnGroup implements Serializable{ protected static final int never = Integer.MAX_VALUE; /**The unit type spawned*/ - public final UnitType type; + public UnitType type; /**When this spawn should end*/ protected int end = never; /**When this spawn should start*/ @@ -36,6 +42,10 @@ public class SpawnGroup{ this.type = type; } + public SpawnGroup(){ + //serialization use only + } + /**Returns the amount of units spawned on a specific wave.*/ public int getUnitsSpawned(int wave){ if(wave < begin || wave > end || (wave - begin) % spacing != 0){ @@ -64,6 +74,30 @@ public class SpawnGroup{ return unit; } + @Override + public void write (Json json) { + json.writeObjectStart(); + json.writeValue("type", type.name); + json.writeValue("begin", begin); + json.writeValue("end", end); + json.writeValue("spacing", spacing); + json.writeValue("max", max); + json.writeValue("scaling", unitScaling); + json.writeValue("amount", unitAmount); + json.writeObjectEnd(); + } + + @Override + public void read (Json json, JsonValue data) { + type = content.getByName(ContentType.unit, data.getString("type", "dagger")); + begin = data.getInt("begin", 0); + end = data.getInt("end", never); + spacing = data.getInt("spacing", 1); + max = data.getInt("spacing", 40); + unitScaling = data.getFloat("scaling", never); + unitAmount = data.getInt("amount", 1); + } + @Override public String toString(){ return "SpawnGroup{" + diff --git a/core/src/io/anuke/mindustry/game/Stats.java b/core/src/io/anuke/mindustry/game/Stats.java index 63e632440c..d99edd78ce 100644 --- a/core/src/io/anuke/mindustry/game/Stats.java +++ b/core/src/io/anuke/mindustry/game/Stats.java @@ -28,9 +28,9 @@ public class Stats{ public RankResult calculateRank(Zone zone, boolean launched){ float score = 0; - //each new launch period adds onto the rank 1.5 'points' + //each new launch period adds onto the rank 'points' if(wavesLasted >= zone.conditionWave){ - score += (float)((wavesLasted - zone.conditionWave) / zone.launchPeriod + 1) * 1.5f; + score += (float)((wavesLasted - zone.conditionWave) / zone.launchPeriod + 1) * 1.3f; } int capacity = zone.loadout.core().itemCapacity; @@ -42,7 +42,7 @@ public class Stats{ frac += Mathf.clamp((float)itemsDelivered.get(item, 0) / capacity) / (float)obtainable.size; } - score += frac*2.4f; + score += frac*2.0f; if(!launched){ score *= 0.5f; diff --git a/core/src/io/anuke/mindustry/graphics/Pal.java b/core/src/io/anuke/mindustry/graphics/Pal.java index b5c17c8604..37de7b50b0 100644 --- a/core/src/io/anuke/mindustry/graphics/Pal.java +++ b/core/src/io/anuke/mindustry/graphics/Pal.java @@ -5,6 +5,7 @@ import io.anuke.arc.graphics.Color; public class Pal{ public static final Color + items = Color.valueOf("2ea756"), command = Color.valueOf("eab678"), bulletYellow = Color.valueOf("ffeec9"), diff --git a/core/src/io/anuke/mindustry/io/SaveMeta.java b/core/src/io/anuke/mindustry/io/SaveMeta.java index d7a97510dc..f88746605f 100644 --- a/core/src/io/anuke/mindustry/io/SaveMeta.java +++ b/core/src/io/anuke/mindustry/io/SaveMeta.java @@ -19,7 +19,7 @@ public class SaveMeta{ this.build = build; this.timestamp = timestamp; this.timePlayed = timePlayed; - this.map = world.maps.all().find(m -> m.fileName().equals(map)); + this.map = world.maps.all().find(m -> m.name().equals(map)); this.wave = wave; this.rules = rules; } diff --git a/core/src/io/anuke/mindustry/io/versions/Save16.java b/core/src/io/anuke/mindustry/io/versions/Save16.java index c1452a21ca..a560d630dc 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save16.java +++ b/core/src/io/anuke/mindustry/io/versions/Save16.java @@ -34,7 +34,7 @@ public class Save16 extends SaveFileVersion{ state.rules.spawns = content.getByID(ContentType.zone, state.rules.zone).rules.get().spawns; } String mapname = stream.readUTF(); - Map map = world.maps.all().find(m -> m.fileName().equals(mapname)); + Map map = world.maps.all().find(m -> m.name().equals(mapname)); if(map == null) map = new Map(customMapDirectory.child(mapname), 1, 1, new ObjectMap<>(), true); world.setMap(map); @@ -62,7 +62,7 @@ public class Save16 extends SaveFileVersion{ //--GENERAL STATE-- Serialization.writeRules(stream, state.rules); - stream.writeUTF(world.getMap().fileName()); //map name + stream.writeUTF(world.getMap().name()); //map name stream.writeInt(state.wave); //wave stream.writeFloat(state.wavetime); //wave countdown diff --git a/core/src/io/anuke/mindustry/maps/Map.java b/core/src/io/anuke/mindustry/maps/Map.java index d73c234169..6b29b43704 100644 --- a/core/src/io/anuke/mindustry/maps/Map.java +++ b/core/src/io/anuke/mindustry/maps/Map.java @@ -12,7 +12,7 @@ public class Map{ public final boolean custom; /** Metadata. Author description, display name, etc.*/ public final ObjectMap tags; - /** Base file of this map.*/ + /** Base file of this map. File can be named anything at all.*/ public final FileHandle file; /** Format version.*/ public final int version; @@ -41,23 +41,15 @@ public class Map{ this(file, width, height, tags, custom, MapIO.version); } - public String fileName(){ - return file.nameWithoutExtension(); - } - public int getHightScore(){ - return Core.settings.getInt("hiscore" + fileName(), 0); + return Core.settings.getInt("hiscore" + file.nameWithoutExtension(), 0); } public void setHighScore(int score){ - Core.settings.put("hiscore" + fileName(), score); + Core.settings.put("hiscore" + file.nameWithoutExtension(), score); Vars.data.modified(); } - public String getDisplayName(){ - return tags.get("name", fileName()); - } - public String author(){ return tag("author"); } @@ -74,6 +66,10 @@ public class Map{ return tags.containsKey(name) && !tags.get(name).trim().isEmpty() ? tags.get(name): Core.bundle.get("unknown"); } + public boolean hasTag(String name){ + return tags.containsKey(name); + } + @Override public String toString(){ return "Map{" + diff --git a/core/src/io/anuke/mindustry/maps/Maps.java b/core/src/io/anuke/mindustry/maps/Maps.java index 18e29d8cee..8331bc987a 100644 --- a/core/src/io/anuke/mindustry/maps/Maps.java +++ b/core/src/io/anuke/mindustry/maps/Maps.java @@ -8,6 +8,7 @@ import io.anuke.arc.graphics.Texture; import io.anuke.arc.util.Disposable; import io.anuke.arc.util.Log; import io.anuke.arc.util.Time; +import io.anuke.arc.util.serialization.Json; import io.anuke.mindustry.io.MapIO; import io.anuke.mindustry.world.Tile; @@ -16,10 +17,15 @@ import java.io.IOException; import static io.anuke.mindustry.Vars.*; public class Maps implements Disposable{ - /** List of all built-in maps. */ + /** List of all built-in maps. Filenames only.*/ private static final String[] defaultMapNames = {"Fortress"}; /** All maps stored in an ordered array. */ private Array maps = new Array<>(); + /** Serializer for meta.*/ + private Json json = new Json(); + + public Maps(){ + } /** Returns a list of all maps, including custom ones. */ public Array all(){ @@ -78,10 +84,11 @@ public class Maps implements Disposable{ ObjectMap tags = new ObjectMap<>(baseTags); String name = tags.get("name"); if(name == null) throw new IllegalArgumentException("Can't save a map with no name. How did this happen?"); - FileHandle file = customMapDirectory.child(name + "." + mapExtension); + //FileHandle file = customMapDirectory.child(name + "." + mapExtension); + FileHandle file; //find map with the same exact display name - Map other = maps.find(m -> m.getDisplayName().equals(name)); + Map other = maps.find(m -> m.name().equals(name)); if(other != null){ //dispose of map if it's already there @@ -90,6 +97,9 @@ public class Maps implements Disposable{ other.texture = null; } maps.remove(other); + file = other.file; + }else{ + file = findFile(); } //create map, write it, etc etc etc @@ -106,12 +116,11 @@ public class Maps implements Disposable{ } /** Import a map, then save it. This updates all values and stored data necessary. */ - public void importMap(FileHandle file, Map map) throws IOException{ - file.copyTo(customMapDirectory.child(map.name() + ".mmap")); - if(!headless){ - map.texture = new Texture(MapIO.generatePreview(map)); - } - maps.add(map); + public void importMap(FileHandle file) throws IOException{ + FileHandle dest = findFile(); + file.copyTo(dest); + + loadMap(dest, true); } /** Removes a map completely. */ @@ -125,9 +134,23 @@ public class Maps implements Disposable{ map.file.delete(); } + /** Find a new filename to put a map to.*/ + private FileHandle findFile(){ + //find a map name that isn't used. + int i = maps.size; + while(customMapDirectory.child("map_" + i + "." + mapExtension).exists()){ + i ++; + } + return customMapDirectory.child("map_" + i + "." + mapExtension); + } + private void loadMap(FileHandle file, boolean custom) throws IOException{ Map map = MapIO.readMap(file, custom); + if(map.name() == null){ + throw new IOException("Map name cannot be empty! File: " + file); + } + if(!headless){ map.texture = new Texture(MapIO.generatePreview(map)); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java index d5012b49d9..18f05306c8 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/CustomGameDialog.java @@ -104,7 +104,7 @@ public class CustomGameDialog extends FloatingDialog{ image.getImageCell().size(images); image.top(); image.row(); - image.add("[accent]" + map.getDisplayName()).pad(3f).growX().wrap().get().setAlignment(Align.center, Align.center); + image.add("[accent]" + map.name()).pad(3f).growX().wrap().get().setAlignment(Align.center, Align.center); image.row(); image.label((() -> Core.bundle.format("level.highscore", map.getHightScore()))).pad(3f); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java index 5a9c007437..5b4b7f778c 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/LoadDialog.java @@ -113,7 +113,7 @@ public class LoadDialog extends FloatingDialog{ button.defaults().padBottom(3); button.row(); - button.add(Core.bundle.format("save.map", color + (slot.getMap() == null ? Core.bundle.get("unknown") : slot.getMap().getDisplayName()))); + button.add(Core.bundle.format("save.map", color + (slot.getMap() == null ? Core.bundle.get("unknown") : slot.getMap().name()))); button.row(); button.add(Core.bundle.format("save.wave", color + slot.getWave())); button.row(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java index bf64a6a35e..a98770f023 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java @@ -30,29 +30,33 @@ public class MapsDialog extends FloatingDialog{ Platform.instance.showFileChooser("$editor.importmap", "Map File", file -> { try{ Map map = MapIO.readMap(file, true); - String name = map.tags.get("name", file.nameWithoutExtension()); + String name = map.tags.get("name"); + if(name == null){ + ui.showError("$editor.errorname"); + return; + } - Map conflict = world.maps.all().find(m -> m.fileName().equals(file.nameWithoutExtension()) || m.name().equals(file.name())); + Map conflict = world.maps.all().find(m -> m.name().equals(name)); if(conflict != null && !conflict.custom){ ui.showError(Core.bundle.format("editor.import.exists", name)); }else if(conflict != null){ ui.showConfirm("$confirm", "$editor.overwrite.confirm", () -> { try{ - world.maps.importMap(file, map); + world.maps.importMap(file); setup(); }catch(Exception e){ - ui.showError(Core.bundle.format("editor.errorimageload", Strings.parseException(e, false))); + ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); Log.err(e); } }); }else{ - world.maps.importMap(file, map); + world.maps.importMap(file); setup(); } }catch(Exception e){ - ui.showError(Core.bundle.format("editor.errorimageload", Strings.parseException(e, false))); + ui.showError(Core.bundle.format("editor.errorload", Strings.parseException(e, false))); Log.err(e); } }, true, mapExtension); @@ -88,7 +92,7 @@ public class MapsDialog extends FloatingDialog{ TextButton button = maps.addButton("", "clear", () -> showMapInfo(map)).width(mapsize).pad(8).get(); button.clearChildren(); button.margin(9); - button.add(map.getDisplayName()).width(mapsize - 18f).center().get().setEllipsis(true); + button.add(map.name()).width(mapsize - 18f).center().get().setEllipsis(true); button.row(); button.addImage("white").growX().pad(4).color(Color.GRAY); button.row(); @@ -128,7 +132,7 @@ public class MapsDialog extends FloatingDialog{ t.add("$editor.name").padRight(10).color(Color.GRAY).padTop(0); t.row(); - t.add(map.getDisplayName()).growX().wrap().padTop(2); + t.add(map.name()).growX().wrap().padTop(2); t.row(); t.add("$editor.author").padRight(10).color(Color.GRAY); t.row(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 9652ca9146..95bfcb99eb 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -398,6 +398,10 @@ public class Block extends BlockStorage{ bars.add("power", entity -> new Bar(() -> buffered ? Core.bundle.format("blocks.powerbalance", Float.isNaN(entity.power.satisfaction * capacity) ? "" : (int)(entity.power.satisfaction * capacity)) : Core.bundle.get("blocks.power"), () -> Pal.powerBar, () -> entity.power.satisfaction)); } + + if(hasItems && configurable){ + bars.add("items", entity -> new Bar(() -> Core.bundle.format("blocks.items", entity.items.total()), () -> Pal.items, () -> (float)entity.items.total() / itemCapacity)); + } } public boolean isSolidFor(Tile tile){ diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java index 49ab325cd2..7dfd439bc6 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidJunction.java @@ -21,6 +21,12 @@ public class LiquidJunction extends LiquidBlock{ stats.remove(BlockStat.liquidCapacity); } + @Override + public void setBars(){ + super.setBars(); + bars.remove("liquid"); + } + @Override public void draw(Tile tile){ Draw.rect(name, tile.worldx(), tile.worldy()); diff --git a/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java b/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java index 51a39117ec..c9b4e55d12 100644 --- a/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java +++ b/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java @@ -13,6 +13,12 @@ public class ItemSource extends Sorter{ solid = true; } + @Override + public void setBars(){ + super.setBars(); + bars.remove("items"); + } + @Override public boolean outputsItems(){ return true; diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java index 083751bd10..b60fed4eba 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java @@ -41,6 +41,12 @@ public class Unloader extends Block implements SelectionTrait{ return !(block instanceof StorageBlock); } + @Override + public void setBars(){ + super.setBars(); + bars.remove("items"); + } + @Override public void playerPlaced(Tile tile){ Core.app.post(() -> Call.setSortedUnloaderItem(null, tile, lastItem)); diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java index 28179d163b..8be38a1feb 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java @@ -20,6 +20,7 @@ public class DesktopLauncher extends Lwjgl3Application{ Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setTitle("Mindustry"); config.setMaximized(true); + config.setBackBufferConfig(8, 8, 8, 8, 0, 0, 0); config.setWindowedMode(960, 540); config.setWindowIcon("sprites/icon.png"); diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index b262f854ea..b1b855d048 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -54,9 +54,9 @@ public class DesktopPlatform extends Platform{ if(world.getMap() == null){ presence.details = "Unknown Map"; }else if(!state.rules.waves){ - presence.details = Strings.capitalize(world.getMap().getDisplayName()); + presence.details = Strings.capitalize(world.getMap().name()); }else{ - presence.details = Strings.capitalize(world.getMap().getDisplayName()) + " | Wave " + state.wave; + presence.details = Strings.capitalize(world.getMap().name()) + " | Wave " + state.wave; presence.largeImageText = "Wave " + state.wave; } diff --git a/server/src/io/anuke/mindustry/server/ServerControl.java b/server/src/io/anuke/mindustry/server/ServerControl.java index 0fce04de7a..4fd507e487 100644 --- a/server/src/io/anuke/mindustry/server/ServerControl.java +++ b/server/src/io/anuke/mindustry/server/ServerControl.java @@ -228,7 +228,7 @@ public class ServerControl implements ApplicationListener{ host(); }catch(MapException e){ - Log.err(e.map.getDisplayName() + ": " + e.getMessage()); + Log.err(e.map.name() + ": " + e.getMessage()); } }); @@ -664,7 +664,7 @@ public class ServerControl implements ApplicationListener{ try{ r.run(); }catch(MapException e){ - Log.err(e.map.getDisplayName() + ": " + e.getMessage()); + Log.err(e.map.name() + ": " + e.getMessage()); Net.closeServer(); } }