Skip to content

Commit

Permalink
checkForNewerAutoSaves
Browse files Browse the repository at this point in the history
  • Loading branch information
stibinator committed Jul 24, 2021
1 parent 52b8daa commit 9d95645
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 46 deletions.
98 changes: 52 additions & 46 deletions ScriptUI Panels/in-n-out.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -880,14 +880,14 @@
height: 22,
};
// panel sizes
orderPanel.size =
methodPanel.size =
inoutPanel.size =
orderPanel.preferredSize =
methodPanel.preferredSize =
inoutPanel.preferredSize =
{
width: 264,
height: 40,
};
orderPanel.size.height = 50;
orderPanel.preferredSize.height = 50;

theWindow.preferredSize = "width: -1, height: -1";
theWindow.alignChildren = ["left", "top"];
Expand Down Expand Up @@ -981,13 +981,17 @@
methodCheckBoxes[method.value].value = true;
firstSlider.value = 0;
lastSlider.value = 100;

firstSlider.textBox = firstHmsfText;
lastSlider.textBox = lastHmsfText;
firstHmsfText.slider = firstSlider;
lastHmsfText.slider = lastSlider;
fadeInEdit.slider = fadeInSlider;
fadeOutEdit.slider = fadeOutSlider;
updateHMSFEdit = function (theSlidr) {
//update the edit box
theSlidr.textBox.text = percentToHMSF(theSlidr.value, theComp);
theSlidr.textBox.text =
percentToHMSF(theSlidr.value, theComp) || "No Comp!";
};
firstSlider.onChanging = lastSlider.onChanging = function () {
updateHMSFEdit(this);
Expand Down Expand Up @@ -1020,14 +1024,6 @@
doTheThings();
};

moveChckBox.onChange = function () {
prefs.writePrefs({
name: this.name,
value: this.value,
});
doTheThings();
};

orderDropDown.onChange =
firstInOrOutPtDD.onChange =
lastInOrOutPtDD.onChange =
Expand Down Expand Up @@ -1153,27 +1149,35 @@
updateFirstLastDDs(firstInOrOutPtDD);
updateFirstLastDDs(lastInOrOutPtDD);


function updateMethods() {
updateFirstLastDDs(firstInOrOutPtDD);
updateFirstLastDDs(lastInOrOutPtDD);
fadePanel.enabled = fadePanel.visible = !keysChckBox.value;
if (keysChckBox.value) {
inChckBox.text = "first key";
outChckBox.text = "last key";
} else {
inChckBox.text = "in points";
outChckBox.text = "out points";
}

method.value =
methods.moveLayers * moveChckBox.value +
methods.trimLayers * trimChckBox.value +
methods.moveKeys * keysChckBox.value; //0 if move, 1 if trim, 2 if keys
prefs.writePrefs({
name: method.name,
value: method.value,
});
}
updateMethods();

trimChckBox.onClick =
moveChckBox.onClick =
keysChckBox.onClick =
function () {
updateFirstLastDDs(firstInOrOutPtDD);
updateFirstLastDDs(lastInOrOutPtDD);
if (keysChckBox.value) {
inChckBox.text = "first key";
outChckBox.text = "last key";
} else {
inChckBox.text = "in points";
outChckBox.text = "out points";
}
method.value =
methods.moveLayers * moveChckBox.value +
methods.trimLayers * trimChckBox.value +
methods.moveKeys * keysChckBox.value; //0 if move, 1 if trim, 2 if keys
prefs.writePrefs({
name: method.name,
value: method.value,
});
updateMethods();
};

inChckBox.onClick = outChckBox.onClick = function () {
Expand All @@ -1198,32 +1202,34 @@
}

function updateCFSlider(theEdit) {
// try {
theEdit.slider.value =
(100 *
currentFormatToTime(
theEdit.text,
app.project.activeItem.frameRate,
true
)) /
longestLayer;
theEdit.text = timeToCurrentFormat(
theEdit.slider.value,
app.project.activeItem.frameRate
);
// } catch (e) {
// updateCfText();
// }
try {
theEdit.slider.value =
(100 *
currentFormatToTime(
theEdit.text,
app.project.activeItem.frameRate,
true
)) /
longestLayer;
theEdit.text = timeToCurrentFormat(
theEdit.slider.value,
app.project.activeItem.frameRate
);
} catch (e) {
updateCfText();
}
}
updateCfText(fadeInSlider);
updateCfText(fadeOutSlider);

fadeOutSlider.onChange = fadeInSlider.onChange = function () {
updateCfText(this);
doTheThings();
prefs.writePrefs(this.name, this.value);
};
fadeOutEdit.onChange = fadeInEdit.onChange = function () {
updateCFSlider(this);
prefs.writePrefs(this.slider.name, this.slider.value);
doTheThings();
};

Expand Down
50 changes: 50 additions & 0 deletions checkForNewerAutoSaves.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//@target aftereffects
(function () {
this.name = "checkForNewerAutoSaves";
prefName = "lastQuitWasClean";
var lastQuitWasClean = true;
if (app.settings.haveSetting(this.name, prefName)) {
lastQuitWasClean =
app.settings.getSetting(this.name, prefName) === "true";
}
if (!lastQuitWasClean) {
findNewerAutoSaves();
}
app.settings.saveSetting(this.name, prefName, false);

function findNewerAutoSaves() {
var lastProjectPath = app.preferences.getPrefAsString(
"Most Recently Used (MRU) Search v2",
"MRU Project Path ID # 0, File Path"
);

var lastProjectFile = new File(lastProjectPath);
var autoSaveFolder = new Folder(
String(lastProjectFile.parent) + "/Adobe After Effects Auto-Save"
); //translations
if (autoSaveFolder.exists) {
var mask =
File.decode(lastProjectFile.name).replace(".aep", "") +
"*auto-save*.aep";
var autosaves = autoSaveFolder.getFiles(mask);
var lastVersion = 0;
var lastAutoSaveFile;
for (var a = 0; a < autosaves.length; a++) {
var vers = parseInt(
File.decode(autosaves[a].name).match(
/.*\s([0-9]+)\.aep$/
)[1]
);
if (vers > lastVersion) {
lastVersion = vers;
lastAutoSaveFile = autosaves[a];
}
}
if (lastAutoSaveFile) {
if (lastAutoSaveFile.modified.getTime() > lastProjectFile.modified.getTime()) {
alert("ohai");
}
}
}
}
})();

0 comments on commit 9d95645

Please sign in to comment.