Commit ca0a0d5e authored by Christian Winter's avatar Christian Winter

instances can be copied

parent f9c0b949
Pipeline #4801176 passed with stage
in 56 seconds
......@@ -360,6 +360,11 @@ table#renderSettings {
margin-top: 15px;
margin-bottom: 5px;
}
#prefabsDiv{
background-color: rgba(0, 0, 0, 0.3);
padding-top: 6px;
padding-bottom: 1px;
}
.toolcategory {
margin: 10px;
......
......@@ -230,6 +230,7 @@
<button type="button" onclick="PrefabManager.createNewPrefabFromSelection()">Create Prefab from selection</button>
<div class="toolcategorycontainerlist" id="prefabsDiv">
</div>
<button type="button" id="onlyTransformPrefabInstancePositionToggle" onclick="GUI.onlyTransformPrefabInstancePositionTogglePressed()">Only manipulate positions</button>
</div>
</div>
......@@ -261,7 +262,6 @@
<button type="button" id="use2DCursorToggle" onclick="GUI.use2DCursorTogglePressed()">Use Pivot</button>
<button type="button" id="selectVerticesToggle" onclick="GUI.selectVerticesTogglePressed()">Select vertices</button>
<button type="button" id="selectEdgesToggle" onclick="GUI.selectEdgesTogglePressed()">Select edges</button>
<button type="button" id="onlyTransformPrefabInstancePositionToggle" onclick="GUI.onlyTransformPrefabInstancePositionTogglePressed()">Only transform instance positions</button>
</div>
</div>
......
......@@ -36,6 +36,10 @@ class PrefabInstance {
Utilities.deleteArrayEntry(this.reference.instances, this);
}
copy() {
return new PrefabInstance(this.reference, this.transform.position, this.transform.rotation, this.transform.scale);
}
selectionHit() {
for (let line of this.reference.lines) {
// prepare line
......
......@@ -202,7 +202,6 @@ class Utilities {
// TODO make it possible to pass in, position as Vector2 and rotate as angle
static makeSketchy(position, positionSteps, angle, angleStep) {
//File.duplicateLines();
let originalData = Selection.data.copy();
File.createNewLayer(true, File.currentLayer.name + "_Sketch");
......
......@@ -195,9 +195,7 @@
static selectAllToggle() {
this.currentLayer.selectAllToggle();
}
static duplicateLines() {
Selection.duplicateLines();
}
static growSelection(redraw) {
this.currentLayer.growSelection(redraw);
}
......
......@@ -49,7 +49,7 @@
if (Input.isKeyDown(Key.Shift)) {
if (Logic.currentState instanceof IdleState || Logic.currentState instanceof MoveLinesState) {
if (!Selection.noSelection()) {
File.duplicateLines();
Selection.duplicate();
Logic.setState(new MoveLinesState());
}
}
......@@ -127,7 +127,7 @@
case Key.D:
if (Logic.currentState instanceof ContinousDrawingState) {
if (!Logic.currentState.used && !Selection.noSelection()) {
File.duplicateLines();
Selection.duplicate();
Logic.setState(new MoveLinesState());
}
else
......
......@@ -580,7 +580,7 @@
tr.appendChild(td);
let button = document.createElement("button");
button.setAttribute("type", "button");
button.setAttribute("title", "Edit instace");
button.setAttribute("title", "Edit prefab");
button.setAttribute("onclick", "PrefabManager.editPrefab(" + i + ")");
button.innerHTML = "+";
td.appendChild(button);
......
......@@ -138,10 +138,12 @@
return points;
}
static duplicateLines() {
static duplicate() {
let newSelData = this.data.copy();
Selection.clearSelection();
Selection.data = newSelData;
//Logic.currentLayer.changed();
return newSelData;
}
......@@ -275,8 +277,8 @@ class SelectionData {
newSelData.addPoint(line.start);
}
// TODO copy()? foreach?
newSelData.prefabInstances = this.prefabInstances
for (let inst of this.prefabInstances)
newSelData.addPrefabInstance(inst.copy());
return newSelData;
}
......
......@@ -57,14 +57,14 @@
switch (keycode) {
case Key.D:
Utilities.movePointsBy(Selection.getAllSelectedPoints(), this.getDelta());
File.duplicateLines();
Utilities.movePointsBy(Selection.getAllSelectedPoints(), this.getDelta().flipped());
Utilities.movePointsBy(Selection.getAllPositions(), this.getDelta());
Selection.duplicate();
Utilities.movePointsBy(Selection.getAllPositions(), this.getDelta().flipped());
break;
case Key.K:
Utilities.movePointsBy(Selection.getAllSelectedPoints(), this.getDelta());
Utilities.movePointsBy(Selection.getAllPositions(), this.getDelta());
Utilities.cutWithSelection();
Utilities.movePointsBy(Selection.getAllSelectedPoints(), this.getDelta().flipped());
Utilities.movePointsBy(Selection.getAllPositions(), this.getDelta().flipped());
break;
}
}
......
......@@ -62,7 +62,7 @@
switch (keycode) {
case Key.D:
LineManipulator.rotateSelectionBy(this.getAngle());
File.duplicateLines();
Selection.duplicate();
LineManipulator.rotateSelectionBy(-this.getAngle());
break;
case Key.K:
......
......@@ -82,7 +82,7 @@
switch (keycode) {
case Key.D:
LineManipulator.scaleSelection(this.getScaleVector());
File.duplicateLines();
Selection.duplicate();
LineManipulator.scaleSelection(this.getScaleVector().oneDividedByThisVector());
break;
case Key.K:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment