Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement E-Tracker format import #25

Merged
merged 6 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/compiler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,18 @@ export default class Compiler extends CompilerRender implements CompilerOptions
'data-dismiss': 'modal'
}).text('\xd7');

keys.inDialog = true;
dialog.on('shown.bs.modal', () => {
keys.inDialog = true;
}).on('hidden.bs.modal', () => {
$(dialog).off().find('.modal-body').empty();
keys.inDialog = false;
});

dialog.modal('show')
.find('.modal-body')
.html('<pre>\n</pre>')
.prepend(button)
.on('hidden.bs.modal', () => {
keys.inDialog = false;
$(this).find('.modal-body').empty();
});
.scrollTop(0)
.prepend(button);
}

private composeSongData(): void {
Expand Down
4 changes: 2 additions & 2 deletions src/player/Sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class Sample {

for (let i = 255; i >= 0; i--) {
const o = this.data[i];
const k = +o.enable_freq | (+o.enable_noise << 1) | (o.noise_value << 2);
const k = +o.enable_freq | (+o.enable_noise << 1) | ((o.noise_value & 3) << 2);

if (pack && !arr.length && !k && !o.volume.byte && !o.shift) {
continue;
Expand All @@ -88,7 +88,7 @@ export default class Sample {

o.enable_freq = !!(k & 1);
o.enable_noise = !!(k & 2);
o.noise_value = (k >> 2);
o.noise_value = (k >> 2) & 3;
o.volume.byte = parseInt(s.substr(1, 2), 16) || 0;

o.shift = parseInt(s.substr(3), 16) || 0;
Expand Down
17 changes: 13 additions & 4 deletions src/tracker/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,27 @@ Tracker.prototype.onCmdFileSave = function(as) {
}
};
//---------------------------------------------------------------------------------------
Tracker.prototype.onCmdFileImport = function(demosong) {
Tracker.prototype.onCmdFileImport = function(type) {
const keys = this.globalKeyState;
if (this.modePlay || keys.lastPlayMode) {
return;
}

let fnToCall: () => void;
if (demosong) {
fnToCall = this.file.importDemosong.bind(this.file, demosong, `demosongs/${demosong}.json`);
if (type === 'ETrk') {
fnToCall = () => {
this.file.importETracker();
};
}
else if (type) {
fnToCall = () => {
this.file.importDemosong(type, `demosongs/${type}.json`);
};
}
else {
fnToCall = this.file.importFile.bind(this.file);
fnToCall = () => {
this.file.importFile();
};
}

if (this.file.modified) {
Expand Down