diff --git a/core/assets-raw/sprites/ui/scroll-knob-horizontal-black.9.png b/core/assets-raw/sprites/ui/scroll-knob-horizontal-black.9.png deleted file mode 100644 index 7a3bac9b10..0000000000 Binary files a/core/assets-raw/sprites/ui/scroll-knob-horizontal-black.9.png and /dev/null differ diff --git a/core/assets-raw/sprites/ui/scroll-knob-horizontal-black.png b/core/assets-raw/sprites/ui/scroll-knob-horizontal-black.png new file mode 100644 index 0000000000..b5056d235a Binary files /dev/null and b/core/assets-raw/sprites/ui/scroll-knob-horizontal-black.png differ diff --git a/core/assets-raw/sprites/ui/scroll-knob-vertical-black.9.png b/core/assets-raw/sprites/ui/scroll-knob-vertical-black.9.png deleted file mode 100644 index 17d9dcf726..0000000000 Binary files a/core/assets-raw/sprites/ui/scroll-knob-vertical-black.9.png and /dev/null differ diff --git a/core/assets-raw/sprites/ui/scroll-knob-vertical-black.png b/core/assets-raw/sprites/ui/scroll-knob-vertical-black.png new file mode 100644 index 0000000000..1d1f180358 Binary files /dev/null and b/core/assets-raw/sprites/ui/scroll-knob-vertical-black.png differ diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index df7f7dc469..fbd1ab4b42 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -627,7 +627,7 @@ keybind.chat.name = Chat keybind.player_list.name = Player list keybind.console.name = Console keybind.rotate.name = Rotate -keybind.rotateplaced.name = Rotate Placed (Hold) +keybind.rotateplaced.name = Rotate Existing (Hold) keybind.toggle_menus.name = Toggle menus keybind.chat_history_prev.name = Chat history prev keybind.chat_history_next.name = Chat history next diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 06acf2f5d6..d35f68030d 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -15031,7 +15031,6 @@ scroll-knob-horizontal-black rotate: false xy: 1937, 749 size: 40, 24 - split: 11, 10, 10, 10 orig: 40, 24 offset: 0, 0 index: -1 @@ -15039,7 +15038,6 @@ scroll-knob-vertical-black rotate: false xy: 1832, 429 size: 24, 40 - split: 10, 10, 6, 10 orig: 24, 40 offset: 0, 0 index: -1 diff --git a/core/src/io/anuke/mindustry/content/UnitTypes.java b/core/src/io/anuke/mindustry/content/UnitTypes.java index 8d005ca4c3..9d164438cb 100644 --- a/core/src/io/anuke/mindustry/content/UnitTypes.java +++ b/core/src/io/anuke/mindustry/content/UnitTypes.java @@ -17,7 +17,7 @@ public class UnitTypes implements ContentList{ @Override public void load(){ - draug = new UnitType("draug", Draug.class, Draug::new){{ + draug = new UnitType("draug", Draug::new){{ flying = true; drag = 0.01f; speed = 0.3f; @@ -32,7 +32,7 @@ public class UnitTypes implements ContentList{ }}; }}; - spirit = new UnitType("spirit", Spirit.class, Spirit::new){{ + spirit = new UnitType("spirit", Spirit::new){{ flying = true; drag = 0.01f; speed = 0.4f; @@ -53,7 +53,7 @@ public class UnitTypes implements ContentList{ }}; }}; - phantom = new UnitType("phantom", Phantom.class, Phantom::new){{ + phantom = new UnitType("phantom", Phantom::new){{ flying = true; drag = 0.01f; mass = 2f; @@ -77,7 +77,7 @@ public class UnitTypes implements ContentList{ }}; }}; - dagger = new UnitType("dagger", Dagger.class, Dagger::new){{ + dagger = new UnitType("dagger", Dagger::new){{ maxVelocity = 1.1f; speed = 0.2f; drag = 0.4f; @@ -93,7 +93,7 @@ public class UnitTypes implements ContentList{ }}; }}; - crawler = new UnitType("crawler", Crawler.class, Crawler::new){{ + crawler = new UnitType("crawler", Crawler::new){{ maxVelocity = 1.27f; speed = 0.285f; drag = 0.4f; @@ -124,7 +124,7 @@ public class UnitTypes implements ContentList{ }}; }}; - titan = new UnitType("titan", Titan.class, Titan::new){{ + titan = new UnitType("titan", Titan::new){{ maxVelocity = 0.8f; speed = 0.22f; drag = 0.4f; @@ -146,7 +146,7 @@ public class UnitTypes implements ContentList{ }}; }}; - fortress = new UnitType("fortress", Fortress.class, Fortress::new){{ + fortress = new UnitType("fortress", Fortress::new){{ maxVelocity = 0.78f; speed = 0.15f; drag = 0.4f; @@ -168,7 +168,7 @@ public class UnitTypes implements ContentList{ }}; }}; - eruptor = new UnitType("eruptor", Eruptor.class, Eruptor::new){{ + eruptor = new UnitType("eruptor", Eruptor::new){{ maxVelocity = 0.81f; speed = 0.16f; drag = 0.4f; @@ -190,7 +190,7 @@ public class UnitTypes implements ContentList{ }}; }}; - chaosArray = new UnitType("chaos-array", Dagger.class, Dagger::new){{ + chaosArray = new UnitType("chaos-array", Dagger::new){{ maxVelocity = 0.68f; speed = 0.12f; drag = 0.4f; @@ -214,7 +214,7 @@ public class UnitTypes implements ContentList{ }}; }}; - eradicator = new UnitType("eradicator", Dagger.class, Dagger::new){{ + eradicator = new UnitType("eradicator", Dagger::new){{ maxVelocity = 0.68f; speed = 0.12f; drag = 0.4f; @@ -239,7 +239,7 @@ public class UnitTypes implements ContentList{ }}; }}; - wraith = new UnitType("wraith", Wraith.class, Wraith::new){{ + wraith = new UnitType("wraith", Wraith::new){{ speed = 0.3f; maxVelocity = 1.9f; drag = 0.01f; @@ -258,7 +258,7 @@ public class UnitTypes implements ContentList{ }}; }}; - ghoul = new UnitType("ghoul", Ghoul.class, Ghoul::new){{ + ghoul = new UnitType("ghoul", Ghoul::new){{ health = 220; speed = 0.2f; maxVelocity = 1.4f; @@ -282,7 +282,7 @@ public class UnitTypes implements ContentList{ }}; }}; - revenant = new UnitType("revenant", Revenant.class, Revenant::new){{ + revenant = new UnitType("revenant", Revenant::new){{ health = 1000; mass = 5f; hitsize = 20f; @@ -313,7 +313,7 @@ public class UnitTypes implements ContentList{ }}; }}; - lich = new UnitType("lich", Revenant.class, Revenant::new){{ + lich = new UnitType("lich", Revenant::new){{ health = 6000; mass = 20f; hitsize = 40f; @@ -346,7 +346,7 @@ public class UnitTypes implements ContentList{ }}; }}; - reaper = new UnitType("reaper", Revenant.class, Revenant::new){{ + reaper = new UnitType("reaper", Revenant::new){{ health = 11000; mass = 30f; hitsize = 56f; diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 8554a5abdf..c9b04ad256 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -215,14 +215,6 @@ public class MapEditorDialog extends Dialog implements Disposable{ return; } - Vector2 v = pane.stageToLocalCoordinates(Core.input.mouse()); - - if(v.x >= 0 && v.y >= 0 && v.x <= pane.getWidth() && v.y <= pane.getHeight()){ - Core.scene.setScrollFocus(pane); - }else{ - Core.scene.setScrollFocus(null); - } - if(Core.scene != null && Core.scene.getKeyboardFocus() == this){ doInput(); } diff --git a/core/src/io/anuke/mindustry/editor/MapInfoDialog.java b/core/src/io/anuke/mindustry/editor/MapInfoDialog.java index 084258120a..b2b942250b 100644 --- a/core/src/io/anuke/mindustry/editor/MapInfoDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapInfoDialog.java @@ -59,18 +59,25 @@ public class MapInfoDialog extends FloatingDialog{ t.row(); t.add("$editor.rules").padRight(8).left(); - t.addButton("$edit", () -> ruleInfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules())).left().width(200f); + t.addButton("$edit", () -> { + ruleInfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules()); + hide(); + }).left().width(200f); t.row(); t.add("$editor.waves").padRight(8).left(); - t.addButton("$edit", waveInfo::show).left().width(200f); + t.addButton("$edit", () -> { + waveInfo.show(); + hide(); + }).left().width(200f); t.row(); t.add("$editor.generation").padRight(8).left(); - t.addButton("$edit", - () -> generate.show(Vars.maps.readFilters(editor.getTags().get("genfilters", "")), - filters -> editor.getTags().put("genfilters", JsonIO.write(filters))) - ).left().width(200f); + t.addButton("$edit", () -> { + generate.show(Vars.maps.readFilters(editor.getTags().get("genfilters", "")), + filters -> editor.getTags().put("genfilters", JsonIO.write(filters))); + hide(); + }).left().width(200f); name.change(); description.change(); diff --git a/core/src/io/anuke/mindustry/mod/ContentParser.java b/core/src/io/anuke/mindustry/mod/ContentParser.java index 8beb9cd900..87f094e481 100644 --- a/core/src/io/anuke/mindustry/mod/ContentParser.java +++ b/core/src/io/anuke/mindustry/mod/ContentParser.java @@ -43,11 +43,9 @@ public class ContentParser{ private ObjectMap> parsers = ObjectMap.of( ContentType.block, (TypeParser)(mod, name, value) -> { - String clas = value.getString("type"); - Class type = resolve("io.anuke.mindustry.world." + clas, "io.anuke.mindustry.world.blocks." + clas, "io.anuke.mindustry.world.blocks.defense" + clas); + Class type = resolve(value.getString("type"), "io.anuke.mindustry.world", "io.anuke.mindustry.world.blocks", "io.anuke.mindustry.world.blocks.defense"); Block block = type.getDeclaredConstructor(String.class).newInstance(mod + "-" + name); - value.remove("type"); - readFields(block, value); + readFields(block, value, true); //make block visible if(block.buildRequirements != null){ @@ -57,29 +55,25 @@ public class ContentParser{ return block; }, ContentType.unit, (TypeParser)(mod, name, value) -> { - String clas = value.getString("type"); - Class type = resolve("io.anuke.mindustry.entities.type.base." + clas); - java.lang.reflect.Constructor cons = type.getDeclaredConstructor(); - UnitType unit = new UnitType(mod + "-" + name, type, () -> { - try{ - return cons.newInstance(); - }catch(Exception e){ - throw new RuntimeException(e); - } - }); - value.remove("type"); - readFields(unit, value); + Class type = resolve(value.getString("type"), "io.anuke.mindustry.entities.type.base"); + UnitType unit = new UnitType(mod + "-" + name, supply(type)); + readFields(unit, value, true); return unit; }, - ContentType.item, parser(Item::new), - ContentType.liquid, parser(Liquid::new), - ContentType.mech, parser(Mech::new) + ContentType.item, parser(ContentType.item, Item::new), + ContentType.liquid, parser(ContentType.liquid, Liquid::new), + ContentType.mech, parser(ContentType.mech, Mech::new) ); - private TypeParser parser(Function constructor){ + private TypeParser parser(ContentType type, Function constructor){ return (mod, name, value) -> { - T item = constructor.get(mod + "-" + name); + T item; + if(Vars.content.getByName(type, name) != null){ + item = (T)Vars.content.getByName(type, name); + }else{ + item = constructor.get(mod + "-" + name); + } readFields(item, value); return item; }; @@ -122,6 +116,21 @@ public class ContentParser{ return c; } + private Supplier supply(Class type){ + try{ + java.lang.reflect.Constructor cons = type.getDeclaredConstructor(); + return () -> { + try{ + return cons.newInstance(); + }catch(Exception e){ + throw new RuntimeException(e); + } + }; + }catch(Exception e){ + throw new RuntimeException(e); + } + } + private Object field(Class type, JsonValue value){ return field(type, value.asString()); } @@ -165,6 +174,11 @@ public class ContentParser{ }); } + private void readFields(Object object, JsonValue jsonMap, boolean stripType){ + if(stripType) jsonMap.remove("type"); + readFields(object, jsonMap); + } + private void readFields(Object object, JsonValue jsonMap){ Class type = object.getClass(); ObjectMap fields = parser.getFields(type); @@ -198,10 +212,10 @@ public class ContentParser{ } /** Tries to resolve a class from a list of potential class names. */ - private Class resolve(String... potentials) throws Exception{ + private Class resolve(String base, String... potentials) throws Exception{ for(String type : potentials){ try{ - return (Class)Class.forName(type); + return (Class)Class.forName(type + '.' + base); }catch(Exception ignored){ } } diff --git a/core/src/io/anuke/mindustry/net/Packets.java b/core/src/io/anuke/mindustry/net/Packets.java index 117c9348c4..e7e92a9a2b 100644 --- a/core/src/io/anuke/mindustry/net/Packets.java +++ b/core/src/io/anuke/mindustry/net/Packets.java @@ -65,6 +65,7 @@ public class Packets{ public static class ConnectPacket implements Packet{ public int version; public String versionType; + public String mods; public String name, uuid, usid; public boolean mobile; public int color; @@ -73,6 +74,7 @@ public class Packets{ public void write(ByteBuffer buffer){ buffer.putInt(Version.build); TypeIO.writeString(buffer, versionType); + TypeIO.writeString(buffer, mods); TypeIO.writeString(buffer, name); TypeIO.writeString(buffer, usid); buffer.put(mobile ? (byte)1 : 0); @@ -86,6 +88,7 @@ public class Packets{ versionType = TypeIO.readString(buffer); name = TypeIO.readString(buffer); usid = TypeIO.readString(buffer); + mods = TypeIO.readString(buffer); mobile = buffer.get() == 1; color = buffer.getInt(); byte[] idbytes = new byte[8]; diff --git a/core/src/io/anuke/mindustry/type/UnitType.java b/core/src/io/anuke/mindustry/type/UnitType.java index 74c51c5547..6a91aeadb7 100644 --- a/core/src/io/anuke/mindustry/type/UnitType.java +++ b/core/src/io/anuke/mindustry/type/UnitType.java @@ -14,9 +14,8 @@ import io.anuke.mindustry.gen.*; import io.anuke.mindustry.ui.*; public class UnitType extends UnlockableContent{ - public final @NonNull - TypeID typeID; - public final @NonNull Supplier constructor; + public @NonNull TypeID typeID; + public @NonNull Supplier constructor; public float health = 60; public float hitsize = 7f; @@ -43,8 +42,17 @@ public class UnitType extends UnlockableContent{ public TextureRegion iconRegion, legRegion, baseRegion, region; - public UnitType(String name, Class type, Supplier mainConstructor){ + public UnitType(String name, Supplier mainConstructor){ + this(name); + create(mainConstructor); + } + + public UnitType(String name){ super(name); + this.description = Core.bundle.getOrNull("unit." + name + ".description"); + } + + public void create(Supplier mainConstructor){ this.constructor = mainConstructor; this.description = Core.bundle.getOrNull("unit." + name + ".description"); this.typeID = new TypeID(name, mainConstructor); diff --git a/core/src/io/anuke/mindustry/ui/Minimap.java b/core/src/io/anuke/mindustry/ui/Minimap.java index 16acc67a57..d4cba3bc33 100644 --- a/core/src/io/anuke/mindustry/ui/Minimap.java +++ b/core/src/io/anuke/mindustry/ui/Minimap.java @@ -91,8 +91,8 @@ public class Minimap extends Table{ Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); if(e != null && e.isDescendantOf(this)){ - Core.scene.setScrollFocus(this); - }else if(Core.scene.getScrollFocus() == this){ + requestScroll(); + }else if(hasScroll()){ Core.scene.setScrollFocus(null); } }); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java index 58cf4cb4eb..10f418c1de 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java @@ -42,6 +42,8 @@ public class CustomRulesDialog extends FloatingDialog{ main.addButton("$settings.reset", () -> { rules = resetter.get(); setup(); + requestKeyboard(); + requestScroll(); }).size(300f, 50f); main.left().defaults().fillX().left().pad(5); main.row();