From d6b2096d3adaa6615090ea8d97c7c83197131063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 4 May 2025 13:53:56 +0200 Subject: [PATCH] Fixed: Editing shape points when first edge has no moveTo flag (coordinates 0, 0) --- CHANGELOG.md | 1 + .../decompiler/flash/gui/PreviewPanel.java | 77 ++++++++++++++++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb779ab79..ca0067803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ All notable changes to this project will be documented in this file. - AS 1/2/3 - Fast switching of scripts causing incorrect caret position remembered - AS 1/2 - Remembering caret position for frames - Cleaner file association +- Editing shape points when first edge has no moveTo flag (coordinates 0, 0) ### Removed - Windows installer does not associate SWF files anymore as it caused false positives on some AVs. diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java index 56caa9634..d5f55e291 100644 --- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java @@ -996,15 +996,31 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel int pointsPos = 0; int x = 0; int y = 0; + StyleChangeRecord lastStyleChangeRecord = null; + boolean wasMoveTo = false; for (int i = 0; i < selectedRecords.size(); i++) { SHAPERECORD rec = selectedRecords.get(i); if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateMoveTo) { scr.moveDeltaX = points.get(pointsPos).x; scr.moveDeltaY = points.get(pointsPos).y; scr.calculateBits(); pointsPos++; + wasMoveTo = true; + } + } + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + lastStyleChangeRecord.moveDeltaX = points.get(pointsPos).x; + lastStyleChangeRecord.moveDeltaY = points.get(pointsPos).y; + if (lastStyleChangeRecord.moveDeltaX != 0 || lastStyleChangeRecord.moveDeltaY != 0) { + lastStyleChangeRecord.stateMoveTo = true; + lastStyleChangeRecord.calculateBits(); + } + pointsPos++; + wasMoveTo = true; } } if (rec instanceof StraightEdgeRecord) { @@ -1073,13 +1089,25 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel int importantRecordPos = importantRecordPosRef.getVal(); int otherPosition = 0; int otherImportantRecordPos = 0; + boolean wasMoveTo = false; + StyleChangeRecord lastStyleChangeRecord = null; for (int i = 0; i < otherRecords.size(); i++) { SHAPERECORD rec = otherRecords.get(i); if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateMoveTo) { otherPosition++; otherImportantRecordPos++; + wasMoveTo = true; + } + } + + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + otherPosition++; + otherImportantRecordPos++; + wasMoveTo = true; } } if (rec instanceof StraightEdgeRecord) { @@ -1108,13 +1136,24 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel int x = 0; int y = 0; int importantRecordPos = 0; + boolean wasMoveTo = false; + StyleChangeRecord lastStyleChangeRecord = null; for (int i = 0; i < selectedRecords.size(); i++) { SHAPERECORD rec = selectedRecords.get(i); if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateMoveTo) { pointsPos++; importantRecordPos++; + wasMoveTo = true; + } + } + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + pointsPos++; + importantRecordPos++; + wasMoveTo = true; } } if (rec instanceof StraightEdgeRecord) { @@ -1212,13 +1251,24 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel int importantRecordPos = importantRecordPosRef.getVal(); int otherPosition = 0; int otherImportantRecordPos = 0; + StyleChangeRecord lastStyleChangeRecord = null; + boolean wasMoveTo = false; for (int i = 0; i < otherRecords.size(); i++) { SHAPERECORD rec = otherRecords.get(i); if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateMoveTo) { otherPosition++; otherImportantRecordPos++; + wasMoveTo = true; + } + } + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + otherPosition++; + otherImportantRecordPos++; + wasMoveTo = true; } } if (rec instanceof StraightEdgeRecord) { @@ -1247,7 +1297,10 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel int importantRecordPos = 0; int x = 0; int y = 0; - + + + StyleChangeRecord lastStyleChangeRecord = null; + boolean wasMoveTo = false; for (int i = 0; i < selectedRecords.size(); i++) { SHAPERECORD rec = selectedRecords.get(i); SHAPERECORD prevRec = i == 0 ? null : selectedRecords.get(i - 1); @@ -1255,9 +1308,18 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateMoveTo) { pointsPos++; importantRecordPos++; + wasMoveTo = true; + } + } + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + pointsPos++; + importantRecordPos++; + wasMoveTo = true; } } if (rec instanceof StraightEdgeRecord) { @@ -2820,7 +2882,17 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel int y = 0; List points = new ArrayList<>(); + boolean wasMoveTo = false; + StyleChangeRecord lastStyleChangeRecord = null; for (SHAPERECORD rec : selectedRecords) { + if (((rec instanceof StraightEdgeRecord) || (rec instanceof CurvedEdgeRecord)) && !wasMoveTo) { + if (lastStyleChangeRecord != null) { + DisplayPoint point = new DisplayPoint(0, 0); + points.add(point); + wasMoveTo = true; + } + } + if (rec instanceof StraightEdgeRecord) { StraightEdgeRecord ser = (StraightEdgeRecord) rec; DisplayPoint point = new DisplayPoint(x + ser.deltaX, y + ser.deltaY); @@ -2833,11 +2905,14 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel points.add(controlPoint); points.add(anchorPoint); } + if (rec instanceof StyleChangeRecord) { StyleChangeRecord scr = (StyleChangeRecord) rec; + lastStyleChangeRecord = scr; if (scr.stateMoveTo) { DisplayPoint point = new DisplayPoint(scr.moveDeltaX, scr.moveDeltaY); points.add(point); + wasMoveTo = true; } }