diff --git a/test1/editorevents.d b/test1/editorevents.d index 0fb4f2a..91f88d0 100644 --- a/test1/editorevents.d +++ b/test1/editorevents.d @@ -178,11 +178,72 @@ public class RemovePresetEvent : UndoableEvent { } } public class AddSampleFile : UndoableEvent { - + ModuleConfig mcfg; + string modID; + int sampleID; + string path; + Tag backup; + public this (ModuleConfig mcfg, string modID, int sampleID, string path, Tag backup) { + this.mcfg = mcfg; + this.modID = modID; + this.sampleID = sampleID; + this.path = path; + this.backup = backup; + } + public void redo() { + if (backup is null) { + mcfg.addWaveFile(path, modID, sampleID, null, null); + } else { + mcfg.addWaveFromBackup(path, backup); + } + } + public void undo() { + backup = mcfg.removeWave(modID, sampleID); + } } public class AddSampleSlice : UndoableEvent { - + ModuleConfig mcfg; + string modID; + int sampleID; + int src; + int begin; + int len; + Tag backup; + public this (ModuleConfig mcfg, string modID, int sampleID, int src, int begin, int len, Tag backup) { + this.mcfg = mcfg; + this.modID = modID; + this.sampleID = sampleID; + this.src = src; + this.begin = begin; + this.len = len; + this.backup = backup; + } + public void redo() { + if (backup is null) { + mcfg.addWaveSlice(modID, sampleID, src, begin, len, null); + } else { + mcfg.addWaveFromBackup(path, backup); + } + } + public void undo() { + backup = mcfg.removeWave(modID, sampleID); + } } public class RemoveSample : UndoableEvent { - + ModuleConfig mcfg; + string modID; + int sampleID; + Tag backup; + public this (ModuleConfig mcfg, string modID, int sampleID, Tag backup) { + this.mcfg = mcfg; + this.modID = modID; + this.sampleID = sampleID; + this.backup = backup; + } + public void redo() { + backup = mcfg.removeWave(modID, sampleID); + } + public void undo() { + mcfg.addWaveFromBackup(path, backup); + } } \ No newline at end of file diff --git a/test1/sampleman.d b/test1/sampleman.d index 818057a..241db75 100644 --- a/test1/sampleman.d +++ b/test1/sampleman.d @@ -6,6 +6,7 @@ import pixelperfectengine.audio.base.func; import pixelperfectengine.audio.base.config; import std.math : floor; import std.conv; +import test1.app; public class WaveformViewer : WindowElement { int[] waveform; @@ -84,13 +85,15 @@ public class SampleMan : Window { Label label_slmpR; Label label_len; WaveformViewer wfv; + + AudioDevKit adk; WaveFileData[] waveFileData; string path; string moduleName; //TextBox textBox0; - public this(string moduleName){ + public this(string moduleName, AudioDevKit adk){ this.moduleName = moduleName; super(Box(0, 0, 520, 322), "Sample manager ["d ~ moduleName.to!dstring ~ "]"d);