mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-03 03:31:28 +03:00
Fixed PR
This commit is contained in:
@@ -189,8 +189,9 @@ buj
|
||||
Agzam4
|
||||
ItsKirby69
|
||||
TheCuber
|
||||
萌新-hhgs
|
||||
Jovinull
|
||||
Adleanogare
|
||||
萌新-hhgs
|
||||
Alon
|
||||
硫缺铅/PyratiteNoLead
|
||||
Space
|
||||
|
||||
@@ -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<MapObjective> objectives, Cons<Seq<MapObjective>> out){
|
||||
|
||||
Reference in New Issue
Block a user