diff --git a/core/assets/contributors b/core/assets/contributors index 594e62e91b..f3048de1a6 100644 --- a/core/assets/contributors +++ b/core/assets/contributors @@ -189,8 +189,9 @@ buj Agzam4 ItsKirby69 TheCuber -萌新-hhgs Jovinull +Adleanogare +萌新-hhgs Alon 硫缺铅/PyratiteNoLead Space diff --git a/core/src/mindustry/editor/MapObjectivesDialog.java b/core/src/mindustry/editor/MapObjectivesDialog.java index e915bb3810..3000e23924 100644 --- a/core/src/mindustry/editor/MapObjectivesDialog.java +++ b/core/src/mindustry/editor/MapObjectivesDialog.java @@ -3,6 +3,8 @@ package mindustry.editor; import arc.*; import arc.func.*; import arc.graphics.*; +import arc.input.*; +import arc.math.*; import arc.math.geom.*; import arc.scene.event.*; import arc.scene.ui.*; @@ -538,6 +540,46 @@ public class MapObjectivesDialog extends BaseDialog{ out.get(canvas.objectives); out = arr -> {}; }); + + update(() -> { + if(hasKeyboard()){ + doInput(); + } + }); + } + + private void doInput(){ + if(Core.input.ctrl() && Core.input.keyTap(KeyCode.c)){ + Vec2 pos = screenToLocalCoordinates(Core.input.mouse()); + int pasteX = Mathf.round((pos.x - objWidth * canvas.unitSize / 2f) / canvas.unitSize); + int pasteY = Mathf.floor((pos.y - canvas.unitSize) / canvas.unitSize); + Tmp.r1.set(pasteX, pasteY, 1, 1).grow(-0.001f); + for(var obj : canvas.objectives){ + if(Tmp.r2.set(obj.editorX - 2, obj.editorY - 1, objWidth, objHeight).overlaps(Tmp.r1)){ + Core.app.setClipboardText(JsonIO.json.toJson(obj, Object.class)); + break; + } + } + } + + if(Core.input.ctrl() && Core.input.keyTap(KeyCode.v)){ + String text = Core.app.getClipboardText(); + if(text == null) return; + + try{ + MapObjective obj = JsonIO.read(MapObjective.class, text); + Vec2 pos = screenToLocalCoordinates(Core.input.mouse()); + int tx = Mathf.round((pos.x - objWidth * canvas.unitSize / 2f) / canvas.unitSize); + int ty = Mathf.floor((pos.y - canvas.unitSize) / canvas.unitSize); + if(obj != null && canvas.tilemap.validPlace(tx, ty, null)){ + obj.editorX = tx; + obj.editorY = ty; + canvas.tilemap.createTile(tx, ty, obj, true); + canvas.objectives.add(obj); + } + }catch(Exception e){ //in case serialization fails + } + } } public void show(Seq objectives, Cons> out){