The copy blocks now only appear for mobile. (Stilled need to be compilled and tested, desktop ctrl-c ctrl-v will come soon.)

This commit is contained in:
Arthur Schifano
2026-04-13 18:13:32 +02:00
parent 02ce0bc8a5
commit a5d076decc
2 changed files with 23 additions and 19 deletions
@@ -29,7 +29,7 @@ public class MapObjectivesCanvas extends WidgetGroup{
public final float unitSize = Scl.scl(48f);
public Seq<MapObjective> objectives = new Seq<>();
public int pasteX, pasteY;
public int pasteX = -999, pasteY = -999;
public ObjectiveTilemap tilemap;
protected MapObjective query;
@@ -387,10 +387,14 @@ public class MapObjectivesCanvas extends WidgetGroup{
dialog.addCloseButton();
dialog.show();
});
b.button(Icon.copySmall, () -> {
pasteX = obj.editorX;
pasteY = obj.editorY;
}); // Object position can be used as an ID.
if(mobile){
b.button(Icon.copySmall, () -> {
pasteX = obj.editorX;
pasteY = obj.editorY;
}); // Object position can be used as an ID.
}
b.button(Icon.trashSmall, () -> removeTile(this));
}).left().grow();
}).growX().height(unitSize / Scl.scl(1f) * 2).get().addCaptureListener(mover = new Mover());
@@ -488,20 +488,6 @@ public class MapObjectivesDialog extends BaseDialog{
buttons.defaults().size(160f, 64f).pad(2f);
buttons.button("@back", Icon.left, MapObjectivesDialog.this::hide);
buttons.button("@add", Icon.add, () -> getProvider(MapObjective.class).get(new TypeInfo(MapObjective.class), canvas::query));
buttons.button("@editor.paste", Icon.paste, () -> {
Core.app.setClipboardText(JsonIO.write(new MapObjectives(canvas.objectives)));
for(var obj : JsonIO.read(MapObjectives.class, Core.app.getClipboardText()).all){
if(obj.editorX == canvas.pasteX && obj.editorY == canvas.pasteY){
copy = obj;
}
};
if(copy == null){
ui.showErrorMessage("@error.objectivecopy");
}else{
canvas.tilemap.createTile(copy.editorX, copy.editorY, copy, true);
canvas.objectives.add(copy);
}
});
buttons.button("@waves.edit", Icon.edit, () -> {
BaseDialog dialog = new BaseDialog("@waves.edit");
dialog.addCloseButton();
@@ -536,6 +522,20 @@ public class MapObjectivesDialog extends BaseDialog{
});
if(mobile){
buttons.button("@editor.paste", Icon.paste, () -> {
Core.app.setClipboardText(JsonIO.write(new MapObjectives(canvas.objectives)));
for(var obj : JsonIO.read(MapObjectives.class, Core.app.getClipboardText()).all){
if(obj.editorX == canvas.pasteX && obj.editorY == canvas.pasteY){
copy = obj;
}
};
if(copy == null){
ui.showErrorMessage("@error.objectivecopy");
}else{
canvas.tilemap.createTile(copy.editorX, copy.editorY, copy, true);
canvas.objectives.add(copy);
}
}).visible(() -> copy != null || canvas.pasteX != -999 || canvas.pasteY != -999);
buttons.button("@cancel", Icon.cancel, canvas::stopQuery).visible(() -> canvas.isQuerying());
buttons.button("@ok", Icon.ok, canvas::placeQuery).visible(() -> canvas.isQuerying());
}