2022-02-15 03:12:20 +00:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
|
|
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2022-01-17 23:18:28 +00:00
|
|
|
#define _USE_MATH_DEFINES
|
2021-12-11 07:10:09 +00:00
|
|
|
#include "gui.h"
|
2022-02-18 03:59:11 +00:00
|
|
|
#include "util.h"
|
2022-01-07 08:29:56 +00:00
|
|
|
#include "icon.h"
|
2021-12-11 08:11:40 +00:00
|
|
|
#include "../ta-log.h"
|
2022-01-20 10:04:03 +00:00
|
|
|
#include "../fileutils.h"
|
2021-12-11 08:11:40 +00:00
|
|
|
#include "imgui.h"
|
2022-04-02 20:07:47 +00:00
|
|
|
#include "imgui_internal.h"
|
2021-12-19 21:01:24 +00:00
|
|
|
#include "imgui_impl_sdl.h"
|
|
|
|
#include "imgui_impl_sdlrenderer.h"
|
2021-12-15 05:37:27 +00:00
|
|
|
#include "ImGuiFileDialog.h"
|
2021-12-21 05:30:55 +00:00
|
|
|
#include "IconsFontAwesome4.h"
|
2021-12-11 22:41:32 +00:00
|
|
|
#include "misc/cpp/imgui_stdlib.h"
|
2022-03-14 05:26:27 +00:00
|
|
|
#include "plot_nolerp.h"
|
2022-02-17 18:08:17 +00:00
|
|
|
#include "guiConst.h"
|
|
|
|
#include "intConst.h"
|
2022-01-18 02:08:14 +00:00
|
|
|
#include <stdint.h>
|
2021-12-15 19:15:44 +00:00
|
|
|
#include <zlib.h>
|
2021-12-11 21:44:02 +00:00
|
|
|
#include <fmt/printf.h>
|
2021-12-14 22:45:37 +00:00
|
|
|
#include <stdexcept>
|
2021-12-11 07:10:09 +00:00
|
|
|
|
2022-01-22 21:34:44 +00:00
|
|
|
#ifdef __APPLE__
|
2022-02-08 07:04:23 +00:00
|
|
|
extern "C" {
|
|
|
|
#include "macstuff.h"
|
|
|
|
}
|
2022-01-22 21:34:44 +00:00
|
|
|
#endif
|
|
|
|
|
2021-12-15 05:37:27 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <windows.h>
|
2022-01-19 10:44:19 +00:00
|
|
|
#include <shlobj.h>
|
|
|
|
#include <shlwapi.h>
|
|
|
|
#include "../utfutils.h"
|
2021-12-19 08:16:24 +00:00
|
|
|
#define LAYOUT_INI "\\layout.ini"
|
2022-03-21 19:11:28 +00:00
|
|
|
#define BACKUP_FUR "\\backup.fur"
|
2021-12-15 05:37:27 +00:00
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
2021-12-31 03:34:42 +00:00
|
|
|
#include <pwd.h>
|
2022-01-19 10:44:19 +00:00
|
|
|
#include <sys/stat.h>
|
2021-12-19 08:16:24 +00:00
|
|
|
#define LAYOUT_INI "/layout.ini"
|
2022-03-21 19:11:28 +00:00
|
|
|
#define BACKUP_FUR "/backup.fur"
|
2021-12-15 05:37:27 +00:00
|
|
|
#endif
|
|
|
|
|
2022-03-21 22:34:43 +00:00
|
|
|
#include "actionUtil.h"
|
|
|
|
|
2022-03-02 05:38:32 +00:00
|
|
|
bool Particle::update(float frameTime) {
|
|
|
|
pos.x+=speed.x*frameTime;
|
|
|
|
pos.y+=speed.y*frameTime;
|
|
|
|
speed.x*=1.0-((1.0-friction)*frameTime);
|
|
|
|
speed.y*=1.0-((1.0-friction)*frameTime);
|
|
|
|
speed.y+=gravity*frameTime;
|
|
|
|
life-=lifeSpeed*frameTime;
|
2022-02-15 23:52:12 +00:00
|
|
|
return (life>0);
|
|
|
|
}
|
|
|
|
|
2021-12-11 07:10:09 +00:00
|
|
|
void FurnaceGUI::bindEngine(DivEngine* eng) {
|
|
|
|
e=eng;
|
|
|
|
}
|
|
|
|
|
2021-12-13 07:03:36 +00:00
|
|
|
const char* FurnaceGUI::noteName(short note, short octave) {
|
|
|
|
if (note==100) {
|
|
|
|
return "OFF";
|
2022-02-08 08:50:42 +00:00
|
|
|
} else if (note==101) { // note off and envelope release
|
|
|
|
return "===";
|
|
|
|
} else if (note==102) { // envelope release only
|
|
|
|
return "REL";
|
2021-12-13 07:03:36 +00:00
|
|
|
} else if (octave==0 && note==0) {
|
|
|
|
return "...";
|
2022-02-20 04:11:20 +00:00
|
|
|
} else if (note==0 && octave!=0) {
|
|
|
|
return "BUG";
|
2021-12-13 07:03:36 +00:00
|
|
|
}
|
2022-01-18 21:55:32 +00:00
|
|
|
int seek=(note+(signed char)octave*12)+60;
|
|
|
|
if (seek<0 || seek>=180) {
|
|
|
|
return "???";
|
|
|
|
}
|
2022-02-03 19:40:09 +00:00
|
|
|
if (settings.germanNotation) return noteNamesG[seek];
|
2021-12-13 07:03:36 +00:00
|
|
|
return noteNames[seek];
|
|
|
|
}
|
|
|
|
|
2021-12-19 07:12:19 +00:00
|
|
|
bool FurnaceGUI::decodeNote(const char* what, short& note, short& octave) {
|
|
|
|
if (strlen(what)!=3) return false;
|
|
|
|
if (strcmp(what,"...")==0) {
|
|
|
|
note=0;
|
|
|
|
octave=0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (strcmp(what,"???")==0) {
|
|
|
|
note=0;
|
|
|
|
octave=0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (strcmp(what,"OFF")==0) {
|
|
|
|
note=100;
|
|
|
|
octave=0;
|
|
|
|
return true;
|
|
|
|
}
|
2022-02-13 01:58:39 +00:00
|
|
|
if (strcmp(what,"===")==0) {
|
|
|
|
note=101;
|
|
|
|
octave=0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (strcmp(what,"REL")==0) {
|
|
|
|
note=102;
|
|
|
|
octave=0;
|
|
|
|
return true;
|
|
|
|
}
|
2022-01-20 02:53:21 +00:00
|
|
|
for (int i=0; i<180; i++) {
|
2021-12-19 07:12:19 +00:00
|
|
|
if (strcmp(what,noteNames[i])==0) {
|
|
|
|
if ((i%12)==0) {
|
|
|
|
note=12;
|
2022-01-19 09:32:40 +00:00
|
|
|
octave=(unsigned char)((i/12)-6);
|
2021-12-19 07:12:19 +00:00
|
|
|
} else {
|
|
|
|
note=i%12;
|
2022-01-19 09:32:40 +00:00
|
|
|
octave=(unsigned char)((i/12)-5);
|
2021-12-19 07:12:19 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-18 18:11:41 +00:00
|
|
|
String FurnaceGUI::encodeKeyMap(std::map<int,int>& map) {
|
|
|
|
String ret;
|
|
|
|
for (std::map<int,int>::value_type& i: map) {
|
2022-02-21 23:01:41 +00:00
|
|
|
ret+=fmt::sprintf("%d:%d;",i.first,i.second);
|
2022-02-18 18:11:41 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FurnaceGUI::decodeKeyMap(std::map<int,int>& map, String source) {
|
|
|
|
map.clear();
|
|
|
|
bool inValue=false;
|
|
|
|
bool negateKey=false;
|
|
|
|
bool negateValue=false;
|
|
|
|
int key=0;
|
|
|
|
int val=0;
|
|
|
|
for (char& i: source) {
|
|
|
|
switch (i) {
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
|
|
if (inValue) {
|
|
|
|
val*=10;
|
|
|
|
val+=i-'0';
|
|
|
|
} else {
|
|
|
|
key*=10;
|
|
|
|
key+=i-'0';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
if (inValue) {
|
|
|
|
negateValue=true;
|
|
|
|
} else {
|
|
|
|
negateKey=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ':':
|
|
|
|
inValue=true;
|
|
|
|
break;
|
|
|
|
case ';':
|
|
|
|
if (inValue) {
|
|
|
|
map[negateKey?-key:key]=negateValue?-val:val;
|
|
|
|
}
|
|
|
|
key=0;
|
|
|
|
val=0;
|
|
|
|
inValue=false;
|
|
|
|
negateKey=false;
|
|
|
|
negateValue=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-08 08:50:42 +00:00
|
|
|
void FurnaceGUI::encodeMMLStr(String& target, unsigned char* macro, unsigned char macroLen, signed char macroLoop, signed char macroRel) {
|
2022-01-26 22:22:29 +00:00
|
|
|
target="";
|
|
|
|
char buf[32];
|
|
|
|
for (int i=0; i<macroLen; i++) {
|
|
|
|
if (i==macroLoop) target+="| ";
|
2022-02-08 08:50:42 +00:00
|
|
|
if (i==macroRel) target+="/ ";
|
2022-01-26 22:22:29 +00:00
|
|
|
if (i==macroLen-1) {
|
|
|
|
snprintf(buf,31,"%d",macro[i]);
|
|
|
|
} else {
|
|
|
|
snprintf(buf,31,"%d ",macro[i]);
|
|
|
|
}
|
|
|
|
target+=buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-30 05:28:49 +00:00
|
|
|
void FurnaceGUI::encodeMMLStr(String& target, int* macro, int macroLen, int macroLoop, int macroRel, bool hex) {
|
2022-01-26 18:13:17 +00:00
|
|
|
target="";
|
|
|
|
char buf[32];
|
|
|
|
for (int i=0; i<macroLen; i++) {
|
|
|
|
if (i==macroLoop) target+="| ";
|
2022-02-08 08:50:42 +00:00
|
|
|
if (i==macroRel) target+="/ ";
|
2022-03-30 05:28:49 +00:00
|
|
|
if (hex) {
|
|
|
|
if (i==macroLen-1) {
|
|
|
|
snprintf(buf,31,"%.2X",macro[i]);
|
|
|
|
} else {
|
|
|
|
snprintf(buf,31,"%.2X ",macro[i]);
|
|
|
|
}
|
2022-01-26 18:13:17 +00:00
|
|
|
} else {
|
2022-03-30 05:28:49 +00:00
|
|
|
if (i==macroLen-1) {
|
|
|
|
snprintf(buf,31,"%d",macro[i]);
|
|
|
|
} else {
|
|
|
|
snprintf(buf,31,"%d ",macro[i]);
|
|
|
|
}
|
2022-01-26 18:13:17 +00:00
|
|
|
}
|
|
|
|
target+=buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-30 05:28:49 +00:00
|
|
|
void FurnaceGUI::decodeMMLStrW(String& source, int* macro, int& macroLen, int macroMax, bool hex) {
|
2022-01-26 21:29:49 +00:00
|
|
|
int buf=0;
|
|
|
|
bool negaBuf=false;
|
|
|
|
bool hasVal=false;
|
|
|
|
macroLen=0;
|
|
|
|
for (char& i: source) {
|
|
|
|
switch (i) {
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
|
|
hasVal=true;
|
2022-03-30 05:28:49 +00:00
|
|
|
buf*=hex?16:10;
|
2022-01-26 21:29:49 +00:00
|
|
|
buf+=i-'0';
|
|
|
|
break;
|
2022-03-30 05:28:49 +00:00
|
|
|
case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
|
|
|
|
if (hex) {
|
|
|
|
hasVal=true;
|
|
|
|
buf*=16;
|
|
|
|
buf+=10+i-'A';
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
|
|
|
|
if (hex) {
|
|
|
|
hasVal=true;
|
|
|
|
buf*=16;
|
|
|
|
buf+=10+i-'a';
|
|
|
|
}
|
|
|
|
break;
|
2022-01-26 21:29:49 +00:00
|
|
|
case '-':
|
|
|
|
if (!hasVal) {
|
|
|
|
hasVal=true;
|
|
|
|
negaBuf=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
if (hasVal) {
|
|
|
|
hasVal=false;
|
|
|
|
negaBuf=false;
|
|
|
|
macro[macroLen]=negaBuf?-buf:buf;
|
|
|
|
if (macro[macroLen]<0) macro[macroLen]=0;
|
|
|
|
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
|
|
|
macroLen++;
|
|
|
|
buf=0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (macroLen>=256) break;
|
|
|
|
}
|
|
|
|
if (hasVal && macroLen<256) {
|
|
|
|
hasVal=false;
|
|
|
|
negaBuf=false;
|
|
|
|
macro[macroLen]=negaBuf?-buf:buf;
|
|
|
|
if (macro[macroLen]<0) macro[macroLen]=0;
|
|
|
|
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
|
|
|
macroLen++;
|
|
|
|
buf=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-08 08:50:42 +00:00
|
|
|
void FurnaceGUI::decodeMMLStr(String& source, unsigned char* macro, unsigned char& macroLen, signed char& macroLoop, int macroMin, int macroMax, signed char& macroRel) {
|
2022-01-26 22:22:29 +00:00
|
|
|
int buf=0;
|
|
|
|
bool hasVal=false;
|
|
|
|
macroLen=0;
|
|
|
|
macroLoop=-1;
|
2022-02-13 02:01:28 +00:00
|
|
|
macroRel=-1;
|
2022-01-26 22:22:29 +00:00
|
|
|
for (char& i: source) {
|
|
|
|
switch (i) {
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
|
|
hasVal=true;
|
|
|
|
buf*=10;
|
|
|
|
buf+=i-'0';
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
if (hasVal) {
|
|
|
|
hasVal=false;
|
|
|
|
macro[macroLen]=buf;
|
|
|
|
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
|
|
|
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
|
|
|
macroLen++;
|
|
|
|
buf=0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '|':
|
|
|
|
if (macroLoop==-1) {
|
|
|
|
macroLoop=macroLen;
|
|
|
|
}
|
|
|
|
break;
|
2022-02-08 08:50:42 +00:00
|
|
|
case '/':
|
|
|
|
if (macroRel==-1) {
|
|
|
|
macroRel=macroLen;
|
|
|
|
}
|
|
|
|
break;
|
2022-01-26 22:22:29 +00:00
|
|
|
}
|
|
|
|
if (macroLen>=128) break;
|
|
|
|
}
|
|
|
|
if (hasVal && macroLen<128) {
|
|
|
|
hasVal=false;
|
|
|
|
macro[macroLen]=buf;
|
|
|
|
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
|
|
|
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
|
|
|
macroLen++;
|
|
|
|
buf=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-08 08:50:42 +00:00
|
|
|
void FurnaceGUI::decodeMMLStr(String& source, int* macro, unsigned char& macroLen, signed char& macroLoop, int macroMin, int macroMax, signed char& macroRel) {
|
2022-01-26 18:13:17 +00:00
|
|
|
int buf=0;
|
|
|
|
bool negaBuf=false;
|
|
|
|
bool hasVal=false;
|
|
|
|
macroLen=0;
|
|
|
|
macroLoop=-1;
|
2022-02-13 02:01:28 +00:00
|
|
|
macroRel=-1;
|
2022-01-26 18:13:17 +00:00
|
|
|
for (char& i: source) {
|
|
|
|
switch (i) {
|
|
|
|
case '0': case '1': case '2': case '3': case '4':
|
|
|
|
case '5': case '6': case '7': case '8': case '9':
|
|
|
|
hasVal=true;
|
|
|
|
buf*=10;
|
|
|
|
buf+=i-'0';
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
if (!hasVal) {
|
|
|
|
hasVal=true;
|
|
|
|
negaBuf=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
if (hasVal) {
|
|
|
|
hasVal=false;
|
|
|
|
macro[macroLen]=negaBuf?-buf:buf;
|
2022-02-04 20:51:25 +00:00
|
|
|
negaBuf=false;
|
2022-01-26 18:13:17 +00:00
|
|
|
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
|
|
|
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
|
|
|
macroLen++;
|
|
|
|
buf=0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '|':
|
|
|
|
if (macroLoop==-1) {
|
|
|
|
macroLoop=macroLen;
|
|
|
|
}
|
|
|
|
break;
|
2022-02-08 08:50:42 +00:00
|
|
|
case '/':
|
|
|
|
if (macroRel==-1) {
|
|
|
|
macroRel=macroLen;
|
|
|
|
}
|
|
|
|
break;
|
2022-01-26 18:13:17 +00:00
|
|
|
}
|
|
|
|
if (macroLen>=128) break;
|
|
|
|
}
|
|
|
|
if (hasVal && macroLen<128) {
|
|
|
|
hasVal=false;
|
|
|
|
macro[macroLen]=negaBuf?-buf:buf;
|
2022-02-04 20:51:25 +00:00
|
|
|
negaBuf=false;
|
2022-01-26 18:13:17 +00:00
|
|
|
if (macro[macroLen]<macroMin) macro[macroLen]=macroMin;
|
|
|
|
if (macro[macroLen]>macroMax) macro[macroLen]=macroMax;
|
|
|
|
macroLen++;
|
|
|
|
buf=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-02 05:11:44 +00:00
|
|
|
#define CW_ADDITION(T) \
|
|
|
|
if (p_min!=NULL && p_max!=NULL) { \
|
|
|
|
if (*((T*)p_min)>*((T*)p_max)) { \
|
|
|
|
if (wheelY<0) { \
|
|
|
|
if ((*((T*)p_data)-wheelY)>*((T*)p_min)) { \
|
|
|
|
*((T*)p_data)=*((T*)p_min); \
|
|
|
|
} else { \
|
|
|
|
*((T*)p_data)-=wheelY; \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if ((*((T*)p_data)-wheelY)<*((T*)p_max)) { \
|
|
|
|
*((T*)p_data)=*((T*)p_max); \
|
|
|
|
} else { \
|
|
|
|
*((T*)p_data)-=wheelY; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if (wheelY>0) { \
|
|
|
|
if ((*((T*)p_data)+wheelY)>*((T*)p_max)) { \
|
|
|
|
*((T*)p_data)=*((T*)p_max); \
|
|
|
|
} else { \
|
|
|
|
*((T*)p_data)+=wheelY; \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
if ((*((T*)p_data)+wheelY)<*((T*)p_min)) { \
|
|
|
|
*((T*)p_data)=*((T*)p_min); \
|
|
|
|
} else { \
|
|
|
|
*((T*)p_data)+=wheelY; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FurnaceGUI::CWSliderScalar(const char* label, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) {
|
|
|
|
if (ImGui::SliderScalar(label,data_type,p_data,p_min,p_max,format,flags)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (ImGui::IsItemHovered() && ctrlWheeling) {
|
|
|
|
switch (data_type) {
|
|
|
|
case ImGuiDataType_U8:
|
|
|
|
CW_ADDITION(unsigned char);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_S8:
|
|
|
|
CW_ADDITION(signed char);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_U16:
|
|
|
|
CW_ADDITION(unsigned short);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_S16:
|
|
|
|
CW_ADDITION(short);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_U32:
|
|
|
|
CW_ADDITION(unsigned int);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_S32:
|
|
|
|
CW_ADDITION(int);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_Float:
|
|
|
|
CW_ADDITION(float);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_Double:
|
|
|
|
CW_ADDITION(double);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FurnaceGUI::CWVSliderScalar(const char* label, const ImVec2& size, ImGuiDataType data_type, void* p_data, const void* p_min, const void* p_max, const char* format, ImGuiSliderFlags flags) {
|
|
|
|
if (ImGui::VSliderScalar(label,size,data_type,p_data,p_min,p_max,format,flags)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (ImGui::IsItemHovered() && ctrlWheeling) {
|
|
|
|
switch (data_type) {
|
|
|
|
case ImGuiDataType_U8:
|
|
|
|
CW_ADDITION(unsigned char);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_S8:
|
|
|
|
CW_ADDITION(signed char);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_U16:
|
|
|
|
CW_ADDITION(unsigned short);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_S16:
|
|
|
|
CW_ADDITION(short);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_U32:
|
|
|
|
CW_ADDITION(unsigned int);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_S32:
|
|
|
|
CW_ADDITION(int);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_Float:
|
|
|
|
CW_ADDITION(float);
|
|
|
|
break;
|
|
|
|
case ImGuiDataType_Double:
|
|
|
|
CW_ADDITION(double);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FurnaceGUI::CWSliderInt(const char* label, int* v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) {
|
|
|
|
return CWSliderScalar(label,ImGuiDataType_S32,v,&v_min,&v_max,format,flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FurnaceGUI::CWSliderFloat(const char* label, float* v, float v_min, float v_max, const char* format, ImGuiSliderFlags flags) {
|
|
|
|
return CWSliderScalar(label,ImGuiDataType_Float,v,&v_min,&v_max,format,flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FurnaceGUI::CWVSliderInt(const char* label, const ImVec2& size, int* v, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) {
|
|
|
|
return CWVSliderScalar(label,size,ImGuiDataType_S32,v,&v_min,&v_max,format,flags);
|
|
|
|
}
|
|
|
|
|
2022-01-28 08:17:35 +00:00
|
|
|
const char* FurnaceGUI::getSystemName(DivSystem which) {
|
|
|
|
if (settings.chipNames) {
|
|
|
|
return e->getSystemChips(which);
|
|
|
|
}
|
|
|
|
return e->getSystemName(which);
|
|
|
|
}
|
|
|
|
|
2021-12-13 22:09:46 +00:00
|
|
|
void FurnaceGUI::updateScroll(int amount) {
|
2022-01-22 08:15:43 +00:00
|
|
|
float lineHeight=(patFont->FontSize+2*dpiScale);
|
2021-12-13 22:09:46 +00:00
|
|
|
nextScroll=lineHeight*amount;
|
2022-04-13 23:16:55 +00:00
|
|
|
haveHitBounds=false;
|
2021-12-13 22:09:46 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 03:14:59 +00:00
|
|
|
void FurnaceGUI::addScroll(int amount) {
|
2022-01-22 08:15:43 +00:00
|
|
|
float lineHeight=(patFont->FontSize+2*dpiScale);
|
2021-12-24 03:14:59 +00:00
|
|
|
nextAddScroll=lineHeight*amount;
|
2022-04-13 23:16:55 +00:00
|
|
|
haveHitBounds=false;
|
2021-12-24 03:14:59 +00:00
|
|
|
}
|
|
|
|
|
2022-02-02 06:14:21 +00:00
|
|
|
void FurnaceGUI::setFileName(String name) {
|
|
|
|
#ifdef _WIN32
|
|
|
|
wchar_t ret[4096];
|
|
|
|
WString ws=utf8To16(name.c_str());
|
|
|
|
int index=0;
|
|
|
|
for (wchar_t& i: ws) {
|
|
|
|
ret[index++]=i;
|
|
|
|
if (index>=4095) break;
|
|
|
|
}
|
|
|
|
ret[index]=0;
|
|
|
|
if (GetFullPathNameW(ws.c_str(),4095,ret,NULL)==0) {
|
|
|
|
curFileName=name;
|
|
|
|
} else {
|
|
|
|
curFileName=utf16To8(ret);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
char ret[4096];
|
|
|
|
if (realpath(name.c_str(),ret)==NULL) {
|
|
|
|
curFileName=name;
|
|
|
|
} else {
|
|
|
|
curFileName=ret;
|
|
|
|
}
|
|
|
|
#endif
|
2022-04-04 18:25:38 +00:00
|
|
|
updateWindowTitle();
|
2022-02-02 06:14:21 +00:00
|
|
|
}
|
|
|
|
|
2021-12-15 22:32:08 +00:00
|
|
|
void FurnaceGUI::updateWindowTitle() {
|
2022-04-04 18:25:38 +00:00
|
|
|
String title;
|
|
|
|
switch (settings.titleBarInfo) {
|
|
|
|
case 0:
|
|
|
|
title="Furnace";
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (e->song.name.empty()) {
|
|
|
|
title="Furnace";
|
|
|
|
} else {
|
|
|
|
title=fmt::sprintf("%s - Furnace",e->song.name);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (curFileName.empty()) {
|
|
|
|
title="Furnace";
|
|
|
|
} else {
|
|
|
|
String shortName;
|
|
|
|
size_t pos=curFileName.rfind(DIR_SEPARATOR);
|
|
|
|
if (pos==String::npos) {
|
|
|
|
shortName=curFileName;
|
|
|
|
} else {
|
|
|
|
shortName=curFileName.substr(pos+1);
|
|
|
|
}
|
|
|
|
title=fmt::sprintf("%s - Furnace",shortName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (curFileName.empty()) {
|
|
|
|
title="Furnace";
|
|
|
|
} else {
|
|
|
|
title=fmt::sprintf("%s - Furnace",curFileName);
|
|
|
|
}
|
|
|
|
break;
|
2021-12-15 22:32:08 +00:00
|
|
|
}
|
2022-04-04 18:25:38 +00:00
|
|
|
|
|
|
|
if (settings.titleBarSys) {
|
|
|
|
title+=fmt::sprintf(" (%s)",e->getSongSystemName());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sdlWin!=NULL) SDL_SetWindowTitle(sdlWin,title.c_str());
|
2021-12-15 22:32:08 +00:00
|
|
|
}
|
|
|
|
|
2021-12-19 21:01:24 +00:00
|
|
|
const char* defaultLayout="[Window][DockSpaceViewport_11111111]\n\
|
|
|
|
Pos=0,24\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Size=1280,731\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Debug##Default]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=54,0\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Size=400,400\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Play/Edit Controls]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=181,208\n\
|
|
|
|
Size=45,409\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Song Information]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=978,24\n\
|
|
|
|
Size=302,217\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
DockId=0x00000004,0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Orders]\n\
|
|
|
|
Pos=0,24\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Size=345,217\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
DockId=0x00000007,0\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
\n\
|
|
|
|
[Window][Instruments]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=653,24\n\
|
|
|
|
Size=323,217\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
DockId=0x00000006,2\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
\n\
|
|
|
|
[Window][Wavetables]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=653,24\n\
|
|
|
|
Size=323,217\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
DockId=0x00000006,1\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
\n\
|
|
|
|
[Window][Samples]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=653,24\n\
|
|
|
|
Size=323,217\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
DockId=0x00000006,0\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
\n\
|
|
|
|
[Window][Pattern]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=0,243\n\
|
|
|
|
Size=1246,512\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
Collapsed=0\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
DockId=0x0000000B,0\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
[Window][Instrument Editor]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=372,102\n\
|
|
|
|
Size=682,604\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Warning]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=481,338\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Size=346,71\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Sample Editor]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Pos=531,176\n\
|
|
|
|
Size=613,416\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][About Furnace]\n\
|
|
|
|
Size=1280,755\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Save File##FileDialog]\n\
|
|
|
|
Pos=340,177\n\
|
|
|
|
Size=600,400\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Wavetable Editor]\n\
|
|
|
|
Pos=253,295\n\
|
|
|
|
Size=748,378\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Settings]\n\
|
|
|
|
Pos=655,224\n\
|
|
|
|
Size=601,508\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Error]\n\
|
|
|
|
Pos=491,342\n\
|
|
|
|
Size=514,71\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Mixer]\n\
|
|
|
|
Pos=63,55\n\
|
|
|
|
Size=450,215\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Oscilloscope]\n\
|
|
|
|
Pos=347,94\n\
|
|
|
|
Size=304,105\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
DockId=0x0000000E,0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Volume Meter]\n\
|
|
|
|
Pos=1248,243\n\
|
|
|
|
Size=32,512\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
DockId=0x0000000C,0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Debug]\n\
|
|
|
|
Pos=113,148\n\
|
|
|
|
Size=945,473\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Load Sample##FileDialog]\n\
|
|
|
|
Pos=40,0\n\
|
|
|
|
Size=1200,755\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Open File##FileDialog]\n\
|
|
|
|
Pos=250,143\n\
|
|
|
|
Size=779,469\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Export Audio##FileDialog]\n\
|
|
|
|
Pos=339,177\n\
|
|
|
|
Size=601,400\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Rendering...]\n\
|
|
|
|
Pos=585,342\n\
|
|
|
|
Size=114,71\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
2021-12-19 21:01:24 +00:00
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Export VGM##FileDialog]\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Pos=340,177\n\
|
|
|
|
Size=600,400\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Warning##Save FileFileDialogOverWriteDialog]\n\
|
|
|
|
Pos=390,351\n\
|
|
|
|
Size=500,71\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Statistics]\n\
|
|
|
|
Pos=596,307\n\
|
|
|
|
Size=512,219\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Warning##Export VGMFileDialogOverWriteDialog]\n\
|
|
|
|
Pos=390,351\n\
|
|
|
|
Size=500,71\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Compatibility Flags]\n\
|
|
|
|
Pos=682,287\n\
|
|
|
|
Size=347,262\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Song Comments]\n\
|
|
|
|
Pos=60,60\n\
|
|
|
|
Size=395,171\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Warning##Export AudioFileDialogOverWriteDialog]\n\
|
|
|
|
Pos=381,351\n\
|
|
|
|
Size=500,71\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Select Font##FileDialog]\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Pos=340,177\n\
|
|
|
|
Size=600,400\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Channels]\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Pos=60,60\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
Size=368,449\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Register View]\n\
|
|
|
|
Pos=847,180\n\
|
|
|
|
Size=417,393\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][New Song]\n\
|
|
|
|
Pos=267,110\n\
|
|
|
|
Size=746,534\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
|
|
|
\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
[Window][Edit Controls]\n\
|
|
|
|
Pos=347,24\n\
|
|
|
|
Size=304,68\n\
|
|
|
|
Collapsed=0\n\
|
|
|
|
DockId=0x0000000D,0\n\
|
|
|
|
\n\
|
|
|
|
[Window][Play Controls]\n\
|
|
|
|
Pos=347,201\n\
|
|
|
|
Size=304,40\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
Collapsed=0\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
DockId=0x0000000A,0\n\
|
2022-01-30 23:17:46 +00:00
|
|
|
\n\
|
|
|
|
[Docking][Data]\n\
|
2022-03-14 22:40:22 +00:00
|
|
|
DockSpace ID=0x8B93E3BD Window=0xA787BDB4 Pos=0,24 Size=1280,731 Split=Y Selected=0x6C01C512\n\
|
|
|
|
DockNode ID=0x00000001 Parent=0x8B93E3BD SizeRef=1280,217 Split=X Selected=0xF3094A52\n\
|
|
|
|
DockNode ID=0x00000003 Parent=0x00000001 SizeRef=976,231 Split=X Selected=0x65CC51DC\n\
|
|
|
|
DockNode ID=0x00000007 Parent=0x00000003 SizeRef=345,231 HiddenTabBar=1 Selected=0x8F5BFC9A\n\
|
|
|
|
DockNode ID=0x00000008 Parent=0x00000003 SizeRef=629,231 Split=X Selected=0xD2AD486B\n\
|
|
|
|
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=304,406 Split=Y Selected=0x6D682373\n\
|
|
|
|
DockNode ID=0x00000009 Parent=0x00000005 SizeRef=292,175 Split=Y Selected=0x6D682373\n\
|
|
|
|
DockNode ID=0x0000000D Parent=0x00000009 SizeRef=292,68 HiddenTabBar=1 Selected=0xE57B1A9D\n\
|
|
|
|
DockNode ID=0x0000000E Parent=0x00000009 SizeRef=292,105 HiddenTabBar=1 Selected=0x6D682373\n\
|
|
|
|
DockNode ID=0x0000000A Parent=0x00000005 SizeRef=292,40 HiddenTabBar=1 Selected=0x0DE44CFF\n\
|
|
|
|
DockNode ID=0x00000006 Parent=0x00000008 SizeRef=323,406 Selected=0xD2AD486B\n\
|
|
|
|
DockNode ID=0x00000004 Parent=0x00000001 SizeRef=302,231 Selected=0x60B9D088\n\
|
|
|
|
DockNode ID=0x00000002 Parent=0x8B93E3BD SizeRef=1280,512 Split=X Selected=0x6C01C512\n\
|
|
|
|
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1246,503 CentralNode=1 HiddenTabBar=1 Selected=0xB9ADD0D5\n\
|
|
|
|
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=32,503 HiddenTabBar=1 Selected=0x644DA2C1\n\n";
|
2021-12-19 21:01:24 +00:00
|
|
|
|
|
|
|
void FurnaceGUI::prepareLayout() {
|
|
|
|
FILE* check;
|
2022-01-20 10:04:03 +00:00
|
|
|
check=ps_fopen(finalLayoutPath,"r");
|
2021-12-19 21:01:24 +00:00
|
|
|
if (check!=NULL) {
|
|
|
|
fclose(check);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy initial layout
|
2022-04-11 03:12:02 +00:00
|
|
|
logI("loading default layout.");
|
2022-01-20 10:04:03 +00:00
|
|
|
check=ps_fopen(finalLayoutPath,"w");
|
2021-12-19 21:01:24 +00:00
|
|
|
if (check==NULL) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logW("could not write default layout!");
|
2021-12-19 21:01:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fwrite(defaultLayout,1,strlen(defaultLayout),check);
|
|
|
|
fclose(check);
|
|
|
|
}
|
|
|
|
|
2022-03-16 04:30:15 +00:00
|
|
|
float FurnaceGUI::calcBPM(int s1, int s2, float hz) {
|
|
|
|
float hl=e->song.hilightA;
|
|
|
|
if (hl<=0.0f) hl=4.0f;
|
|
|
|
float timeBase=e->song.timeBase+1;
|
|
|
|
float speedSum=s1+s2;
|
|
|
|
if (timeBase<1.0f) timeBase=1.0f;
|
|
|
|
if (speedSum<1.0f) speedSum=1.0f;
|
|
|
|
return 120.0f*hz/(timeBase*hl*speedSum);
|
|
|
|
}
|
|
|
|
|
2022-03-21 22:34:43 +00:00
|
|
|
void FurnaceGUI::play(int row) {
|
|
|
|
e->walkSong(loopOrder,loopRow,loopEnd);
|
|
|
|
memset(lastIns,-1,sizeof(int)*DIV_MAX_CHANS);
|
2022-04-14 07:58:29 +00:00
|
|
|
if (!followPattern) e->setOrder(curOrder);
|
2022-03-21 22:34:43 +00:00
|
|
|
if (row>0) {
|
|
|
|
e->playToRow(row);
|
|
|
|
} else {
|
|
|
|
e->play();
|
2022-01-13 06:03:57 +00:00
|
|
|
}
|
2022-03-21 22:34:43 +00:00
|
|
|
curNibble=false;
|
|
|
|
orderNibble=false;
|
|
|
|
activeNotes.clear();
|
2022-01-13 06:03:57 +00:00
|
|
|
}
|
|
|
|
|
2022-04-14 07:58:29 +00:00
|
|
|
void FurnaceGUI::setOrder(unsigned char order, bool forced) {
|
|
|
|
curOrder=order;
|
|
|
|
if (followPattern || forced) {
|
|
|
|
e->setOrder(order);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-21 22:34:43 +00:00
|
|
|
void FurnaceGUI::stop() {
|
|
|
|
e->walkSong(loopOrder,loopRow,loopEnd);
|
|
|
|
e->stop();
|
|
|
|
curNibble=false;
|
|
|
|
orderNibble=false;
|
|
|
|
activeNotes.clear();
|
2022-01-27 22:49:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-31 06:51:57 +00:00
|
|
|
void FurnaceGUI::previewNote(int refChan, int note, bool autoNote) {
|
2022-04-14 18:54:47 +00:00
|
|
|
e->setMidiBaseChan(refChan);
|
|
|
|
e->synchronized([this,note]() {
|
|
|
|
e->autoNoteOn(-1,curIns,note);
|
|
|
|
});
|
2022-01-29 23:56:08 +00:00
|
|
|
}
|
|
|
|
|
2022-03-31 06:51:57 +00:00
|
|
|
void FurnaceGUI::stopPreviewNote(SDL_Scancode scancode, bool autoNote) {
|
2022-03-21 22:34:43 +00:00
|
|
|
try {
|
|
|
|
int key=noteKeys.at(scancode);
|
|
|
|
int num=12*curOctave+key;
|
2022-03-30 09:49:15 +00:00
|
|
|
if (num<-60) num=-60; // C-(-5)
|
|
|
|
if (num>119) num=119; // B-9
|
2022-02-19 21:15:57 +00:00
|
|
|
|
2022-03-21 22:34:43 +00:00
|
|
|
if (key==100) return;
|
|
|
|
if (key==101) return;
|
|
|
|
if (key==102) return;
|
2022-01-20 06:32:16 +00:00
|
|
|
|
2022-04-14 18:54:47 +00:00
|
|
|
e->synchronized([this,num]() {
|
|
|
|
e->autoNoteOff(-1,num);
|
|
|
|
});
|
2022-03-21 22:34:43 +00:00
|
|
|
} catch (std::out_of_range& e) {
|
2022-02-11 23:20:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-31 20:25:58 +00:00
|
|
|
void FurnaceGUI::noteInput(int num, int key, int vol) {
|
2022-04-14 07:58:29 +00:00
|
|
|
DivPattern* pat=e->song.pat[cursor.xCoarse].getPattern(e->song.orders.ord[cursor.xCoarse][curOrder],true);
|
2022-03-30 20:44:27 +00:00
|
|
|
|
|
|
|
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
|
|
|
|
|
|
|
if (key==100) { // note off
|
|
|
|
pat->data[cursor.y][0]=100;
|
|
|
|
pat->data[cursor.y][1]=0;
|
|
|
|
} else if (key==101) { // note off + env release
|
|
|
|
pat->data[cursor.y][0]=101;
|
|
|
|
pat->data[cursor.y][1]=0;
|
|
|
|
} else if (key==102) { // env release only
|
|
|
|
pat->data[cursor.y][0]=102;
|
|
|
|
pat->data[cursor.y][1]=0;
|
|
|
|
} else {
|
|
|
|
pat->data[cursor.y][0]=num%12;
|
|
|
|
pat->data[cursor.y][1]=num/12;
|
|
|
|
if (pat->data[cursor.y][0]==0) {
|
|
|
|
pat->data[cursor.y][0]=12;
|
|
|
|
pat->data[cursor.y][1]--;
|
|
|
|
}
|
|
|
|
pat->data[cursor.y][1]=(unsigned char)pat->data[cursor.y][1];
|
|
|
|
if (latchIns==-2) {
|
|
|
|
pat->data[cursor.y][2]=curIns;
|
|
|
|
} else if (latchIns!=-1 && !e->song.ins.empty()) {
|
|
|
|
pat->data[cursor.y][2]=MIN(((int)e->song.ins.size())-1,latchIns);
|
|
|
|
}
|
2022-03-31 20:25:58 +00:00
|
|
|
int maxVol=e->getMaxVolumeChan(cursor.xCoarse);
|
2022-03-30 20:44:27 +00:00
|
|
|
if (latchVol!=-1) {
|
|
|
|
pat->data[cursor.y][3]=MIN(maxVol,latchVol);
|
2022-03-31 20:25:58 +00:00
|
|
|
} else if (vol!=-1) {
|
|
|
|
pat->data[cursor.y][3]=(vol*maxVol)/127;
|
2022-03-30 20:44:27 +00:00
|
|
|
}
|
|
|
|
if (latchEffect!=-1) pat->data[cursor.y][4]=latchEffect;
|
|
|
|
if (latchEffectVal!=-1) pat->data[cursor.y][5]=latchEffectVal;
|
|
|
|
}
|
|
|
|
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
|
|
|
editAdvance();
|
|
|
|
curNibble=false;
|
|
|
|
}
|
|
|
|
|
2022-04-01 06:50:01 +00:00
|
|
|
void FurnaceGUI::valueInput(int num, bool direct, int target) {
|
2022-04-14 07:58:29 +00:00
|
|
|
DivPattern* pat=e->song.pat[cursor.xCoarse].getPattern(e->song.orders.ord[cursor.xCoarse][curOrder],true);
|
2022-04-01 06:50:01 +00:00
|
|
|
prepareUndo(GUI_UNDO_PATTERN_EDIT);
|
|
|
|
if (target==-1) target=cursor.xFine+1;
|
|
|
|
if (direct) {
|
|
|
|
pat->data[cursor.y][target]=num&0xff;
|
|
|
|
} else {
|
|
|
|
if (pat->data[cursor.y][target]==-1) pat->data[cursor.y][target]=0;
|
2022-04-13 22:42:55 +00:00
|
|
|
if (!settings.pushNibble && !curNibble) {
|
|
|
|
pat->data[cursor.y][target]=num;
|
|
|
|
} else {
|
|
|
|
pat->data[cursor.y][target]=((pat->data[cursor.y][target]<<4)|num)&0xff;
|
|
|
|
}
|
2022-04-01 06:50:01 +00:00
|
|
|
}
|
|
|
|
if (cursor.xFine==1) { // instrument
|
|
|
|
if (pat->data[cursor.y][target]>=(int)e->song.ins.size()) {
|
|
|
|
pat->data[cursor.y][target]&=0x0f;
|
|
|
|
if (pat->data[cursor.y][target]>=(int)e->song.ins.size()) {
|
|
|
|
pat->data[cursor.y][target]=(int)e->song.ins.size()-1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
|
|
|
if (direct) {
|
|
|
|
curNibble=false;
|
|
|
|
} else {
|
|
|
|
if (e->song.ins.size()<16) {
|
|
|
|
curNibble=false;
|
|
|
|
editAdvance();
|
|
|
|
} else {
|
|
|
|
curNibble=!curNibble;
|
|
|
|
if (!curNibble) editAdvance();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (cursor.xFine==2) {
|
|
|
|
if (curNibble) {
|
|
|
|
if (pat->data[cursor.y][target]>e->getMaxVolumeChan(cursor.xCoarse)) pat->data[cursor.y][target]=e->getMaxVolumeChan(cursor.xCoarse);
|
|
|
|
} else {
|
|
|
|
pat->data[cursor.y][target]&=15;
|
|
|
|
}
|
|
|
|
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
|
|
|
if (direct) {
|
|
|
|
curNibble=false;
|
|
|
|
} else {
|
|
|
|
if (e->getMaxVolumeChan(cursor.xCoarse)<16) {
|
|
|
|
curNibble=false;
|
|
|
|
editAdvance();
|
|
|
|
} else {
|
|
|
|
curNibble=!curNibble;
|
|
|
|
if (!curNibble) editAdvance();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
makeUndo(GUI_UNDO_PATTERN_EDIT);
|
|
|
|
if (direct) {
|
|
|
|
curNibble=false;
|
|
|
|
} else {
|
|
|
|
curNibble=!curNibble;
|
2022-04-04 00:20:30 +00:00
|
|
|
if (!curNibble) {
|
|
|
|
if (!settings.effectCursorDir) {
|
|
|
|
editAdvance();
|
|
|
|
} else {
|
2022-04-08 07:16:57 +00:00
|
|
|
if (settings.effectCursorDir==2) {
|
|
|
|
if (++cursor.xFine>=(3+(e->song.pat[cursor.xCoarse].effectRows*2))) {
|
|
|
|
cursor.xFine=3;
|
|
|
|
}
|
2022-04-04 00:20:30 +00:00
|
|
|
} else {
|
2022-04-08 07:16:57 +00:00
|
|
|
if (cursor.xFine&1) {
|
|
|
|
cursor.xFine++;
|
|
|
|
} else {
|
|
|
|
editAdvance();
|
|
|
|
cursor.xFine--;
|
|
|
|
}
|
2022-04-04 00:20:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-01 06:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-11 23:20:39 +00:00
|
|
|
void FurnaceGUI::keyDown(SDL_Event& ev) {
|
|
|
|
if (ImGuiFileDialog::Instance()->IsOpened()) return;
|
2022-02-12 07:14:25 +00:00
|
|
|
if (aboutOpen) return;
|
2022-02-11 23:20:39 +00:00
|
|
|
|
|
|
|
int mapped=ev.key.keysym.sym;
|
|
|
|
if (ev.key.keysym.mod&KMOD_CTRL) {
|
|
|
|
mapped|=FURKMOD_CTRL;
|
|
|
|
}
|
|
|
|
if (ev.key.keysym.mod&KMOD_ALT) {
|
|
|
|
mapped|=FURKMOD_ALT;
|
|
|
|
}
|
|
|
|
if (ev.key.keysym.mod&KMOD_GUI) {
|
|
|
|
mapped|=FURKMOD_META;
|
|
|
|
}
|
|
|
|
if (ev.key.keysym.mod&KMOD_SHIFT) {
|
|
|
|
mapped|=FURKMOD_SHIFT;
|
2021-12-21 22:42:27 +00:00
|
|
|
}
|
2022-02-12 06:57:55 +00:00
|
|
|
|
|
|
|
if (bindSetActive) {
|
|
|
|
if (!ev.key.repeat) {
|
|
|
|
switch (ev.key.keysym.sym) {
|
|
|
|
case SDLK_LCTRL: case SDLK_RCTRL:
|
|
|
|
case SDLK_LALT: case SDLK_RALT:
|
|
|
|
case SDLK_LGUI: case SDLK_RGUI:
|
|
|
|
case SDLK_LSHIFT: case SDLK_RSHIFT:
|
|
|
|
bindSetPending=false;
|
|
|
|
actionKeys[bindSetTarget]=(mapped&(~FURK_MASK))|0xffffff;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
actionKeys[bindSetTarget]=mapped;
|
|
|
|
bindSetActive=false;
|
|
|
|
bindSetPending=false;
|
|
|
|
bindSetTarget=0;
|
|
|
|
bindSetPrevValue=0;
|
|
|
|
parseKeybinds();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-21 22:42:27 +00:00
|
|
|
// PER-WINDOW KEYS
|
2021-12-14 22:45:37 +00:00
|
|
|
switch (curWindow) {
|
2022-02-11 23:20:39 +00:00
|
|
|
case GUI_WINDOW_PATTERN:
|
|
|
|
try {
|
|
|
|
int action=actionMapPat.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
// pattern input otherwise
|
|
|
|
if (mapped&(FURKMOD_ALT|FURKMOD_CTRL|FURKMOD_META|FURKMOD_SHIFT)) break;
|
|
|
|
if (!ev.key.repeat) {
|
|
|
|
if (cursor.xFine==0) { // note
|
|
|
|
try {
|
|
|
|
int key=noteKeys.at(ev.key.keysym.scancode);
|
|
|
|
int num=12*curOctave+key;
|
|
|
|
|
2022-03-21 03:16:20 +00:00
|
|
|
if (num<-60) num=-60; // C-(-5)
|
|
|
|
if (num>119) num=119; // B-9
|
|
|
|
|
2022-02-11 23:20:39 +00:00
|
|
|
if (edit) {
|
2022-03-30 20:44:27 +00:00
|
|
|
noteInput(num,key);
|
2022-03-30 23:18:39 +00:00
|
|
|
}
|
2022-02-11 23:20:39 +00:00
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
} else if (edit) { // value
|
|
|
|
try {
|
|
|
|
int num=valueKeys.at(ev.key.keysym.sym);
|
2022-04-01 06:50:01 +00:00
|
|
|
valueInput(num);
|
2022-02-11 23:20:39 +00:00
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WINDOW_ORDERS:
|
|
|
|
try {
|
|
|
|
int action=actionMapOrders.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
// order input otherwise
|
|
|
|
if (mapped&(FURKMOD_ALT|FURKMOD_CTRL|FURKMOD_META|FURKMOD_SHIFT)) break;
|
2022-01-20 07:11:03 +00:00
|
|
|
if (orderEditMode!=0) {
|
|
|
|
try {
|
|
|
|
int num=valueKeys.at(ev.key.keysym.sym);
|
|
|
|
if (orderCursor>=0 && orderCursor<e->getTotalChannelCount()) {
|
2022-04-14 07:58:29 +00:00
|
|
|
e->lockSave([this,num]() {
|
2022-04-08 22:21:36 +00:00
|
|
|
e->song.orders.ord[orderCursor][curOrder]=((e->song.orders.ord[orderCursor][curOrder]<<4)|num);
|
2022-03-21 21:17:51 +00:00
|
|
|
});
|
2022-01-20 07:11:03 +00:00
|
|
|
if (orderEditMode==2 || orderEditMode==3) {
|
|
|
|
curNibble=!curNibble;
|
|
|
|
if (!curNibble) {
|
|
|
|
if (orderEditMode==2) {
|
|
|
|
orderCursor++;
|
|
|
|
if (orderCursor>=e->getTotalChannelCount()) orderCursor=0;
|
|
|
|
} else if (orderEditMode==3) {
|
|
|
|
if (curOrder<e->song.ordersLen-1) {
|
2022-04-14 07:58:29 +00:00
|
|
|
setOrder(curOrder+1);
|
2022-01-20 07:11:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-01-27 06:04:26 +00:00
|
|
|
e->walkSong(loopOrder,loopRow,loopEnd);
|
2022-01-20 07:11:03 +00:00
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2022-03-22 09:54:01 +00:00
|
|
|
case GUI_WINDOW_SAMPLE_EDIT:
|
|
|
|
try {
|
|
|
|
int action=actionMapSample.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
break;
|
2022-02-11 23:20:39 +00:00
|
|
|
case GUI_WINDOW_INS_LIST:
|
|
|
|
try {
|
|
|
|
int action=actionMapInsList.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
2021-12-19 07:12:19 +00:00
|
|
|
}
|
2022-02-11 23:20:39 +00:00
|
|
|
} catch (std::out_of_range& e) {
|
2021-12-14 22:45:37 +00:00
|
|
|
}
|
|
|
|
break;
|
2022-02-11 23:20:39 +00:00
|
|
|
case GUI_WINDOW_WAVE_LIST:
|
|
|
|
try {
|
|
|
|
int action=actionMapWaveList.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WINDOW_SAMPLE_LIST:
|
|
|
|
try {
|
|
|
|
int action=actionMapSampleList.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// GLOBAL KEYS
|
|
|
|
try {
|
|
|
|
int action=actionMapGlobal.at(mapped);
|
|
|
|
if (action>0) {
|
|
|
|
doAction(action);
|
|
|
|
return;
|
2021-12-14 22:45:37 +00:00
|
|
|
}
|
2022-02-11 23:20:39 +00:00
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
2021-12-14 22:45:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FurnaceGUI::keyUp(SDL_Event& ev) {
|
2022-04-16 03:22:47 +00:00
|
|
|
// nothing for now
|
2021-12-14 22:45:37 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 10:44:19 +00:00
|
|
|
bool dirExists(String what) {
|
|
|
|
#ifdef _WIN32
|
|
|
|
WString ws=utf8To16(what.c_str());
|
|
|
|
return (PathIsDirectoryW(ws.c_str())!=FALSE);
|
|
|
|
#else
|
|
|
|
struct stat st;
|
|
|
|
if (stat(what.c_str(),&st)<0) return false;
|
|
|
|
return (st.st_mode&S_IFDIR);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-12-17 08:33:12 +00:00
|
|
|
void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
2022-03-14 04:10:43 +00:00
|
|
|
bool hasOpened=false;
|
2021-12-17 08:33:12 +00:00
|
|
|
switch (type) {
|
|
|
|
case GUI_FILE_OPEN:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirSong)) workingDirSong=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Open File",
|
2022-03-14 14:57:54 +00:00
|
|
|
{"compatible files", "*.fur *.dmf *.mod",
|
2022-03-14 04:10:43 +00:00
|
|
|
"all files", ".*"},
|
2022-03-14 14:57:54 +00:00
|
|
|
"compatible files{.fur,.dmf,.mod},.*",
|
2022-03-14 04:10:43 +00:00
|
|
|
workingDirSong,
|
|
|
|
dpiScale
|
|
|
|
);
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_SAVE:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirSong)) workingDirSong=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Save File",
|
|
|
|
{"Furnace song", "*.fur",
|
2022-04-08 01:13:11 +00:00
|
|
|
"DefleMask 1.1.3 module", "*.dmf"},
|
|
|
|
"Furnace song{.fur},DefleMask 1.1.3 module{.dmf}",
|
2022-03-14 04:10:43 +00:00
|
|
|
workingDirSong,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-02-20 08:18:20 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_SAVE_DMF_LEGACY:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirSong)) workingDirSong=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Save File",
|
|
|
|
{"DefleMask 1.0/legacy module", "*.dmf"},
|
|
|
|
"DefleMask 1.0/legacy module{.dmf}",
|
|
|
|
workingDirSong,
|
|
|
|
dpiScale
|
|
|
|
);
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
2022-01-19 08:15:20 +00:00
|
|
|
case GUI_FILE_INS_OPEN:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Load Instrument",
|
2022-04-10 12:16:33 +00:00
|
|
|
{"compatible files", "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.ff",
|
2022-03-14 04:10:43 +00:00
|
|
|
"all files", ".*"},
|
2022-04-10 12:16:33 +00:00
|
|
|
"compatible files{.fui,.dmp,.tfi,.vgi,.s3i,.sbi,.ff},.*",
|
2022-03-14 04:10:43 +00:00
|
|
|
workingDirIns,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-19 08:15:20 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_INS_SAVE:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Save Instrument",
|
|
|
|
{"Furnace instrument", "*.fui"},
|
|
|
|
"Furnace instrument{.fui}",
|
|
|
|
workingDirIns,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-19 08:15:20 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_WAVE_OPEN:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirWave)) workingDirWave=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Load Wavetable",
|
|
|
|
{"compatible files", "*.fuw *.dmw",
|
|
|
|
"all files", ".*"},
|
|
|
|
"compatible files{.fuw,.dmw},.*",
|
|
|
|
workingDirWave,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-19 08:15:20 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_WAVE_SAVE:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirWave)) workingDirWave=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Save Wavetable",
|
|
|
|
{"Furnace wavetable", ".fuw"},
|
|
|
|
"Furnace wavetable{.fuw}",
|
|
|
|
workingDirWave,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-19 08:15:20 +00:00
|
|
|
break;
|
2021-12-17 08:33:12 +00:00
|
|
|
case GUI_FILE_SAMPLE_OPEN:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirSample)) workingDirSample=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Load Sample",
|
2022-04-12 08:34:53 +00:00
|
|
|
{"compatible files", "*.wav *.dmc",
|
2022-03-14 04:10:43 +00:00
|
|
|
"all files", ".*"},
|
2022-04-12 08:34:53 +00:00
|
|
|
"compatible files{.wav,.dmc},.*",
|
2022-03-14 04:10:43 +00:00
|
|
|
workingDirSample,
|
|
|
|
dpiScale
|
|
|
|
);
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_SAMPLE_SAVE:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirSample)) workingDirSample=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Save Sample",
|
|
|
|
{"Wave file", "*.wav"},
|
|
|
|
"Wave file{.wav}",
|
|
|
|
workingDirSample,
|
|
|
|
dpiScale
|
|
|
|
);
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
2022-01-18 04:34:29 +00:00
|
|
|
case GUI_FILE_EXPORT_AUDIO_ONE:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirAudioExport)) workingDirAudioExport=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export Audio",
|
|
|
|
{"Wave file", "*.wav"},
|
|
|
|
"Wave file{.wav}",
|
|
|
|
workingDirAudioExport,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-18 04:34:29 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_PER_SYS:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirAudioExport)) workingDirAudioExport=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export Audio",
|
|
|
|
{"Wave file", "*.wav"},
|
|
|
|
"Wave file{.wav}",
|
|
|
|
workingDirAudioExport,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-18 04:34:29 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_PER_CHANNEL:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirAudioExport)) workingDirAudioExport=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export Audio",
|
|
|
|
{"Wave file", "*.wav"},
|
|
|
|
"Wave file{.wav}",
|
|
|
|
workingDirAudioExport,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-18 04:34:29 +00:00
|
|
|
break;
|
2022-01-24 06:10:38 +00:00
|
|
|
case GUI_FILE_EXPORT_VGM:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirVGMExport)) workingDirVGMExport=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export VGM",
|
|
|
|
{"VGM file", "*.vgm"},
|
|
|
|
"VGM file{.vgm}",
|
|
|
|
workingDirVGMExport,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-01-24 06:10:38 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_ROM:
|
2022-01-18 04:34:29 +00:00
|
|
|
showError("Coming soon!");
|
|
|
|
break;
|
2022-02-14 23:18:30 +00:00
|
|
|
case GUI_FILE_LOAD_MAIN_FONT:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirFont)) workingDirFont=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Select Font",
|
|
|
|
{"compatible files", "*.ttf *.otf *.ttc"},
|
|
|
|
"compatible files{.ttf,.otf,.ttc}",
|
|
|
|
workingDirFont,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-02-14 23:18:30 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_LOAD_PAT_FONT:
|
2022-03-02 05:02:52 +00:00
|
|
|
if (!dirExists(workingDirFont)) workingDirFont=getHomeDir();
|
2022-03-14 04:10:43 +00:00
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Select Font",
|
|
|
|
{"compatible files", "*.ttf *.otf *.ttc"},
|
|
|
|
"compatible files{.ttf,.otf,.ttc}",
|
|
|
|
workingDirFont,
|
|
|
|
dpiScale
|
|
|
|
);
|
2022-02-14 23:18:30 +00:00
|
|
|
break;
|
2022-04-06 18:53:39 +00:00
|
|
|
case GUI_FILE_IMPORT_COLORS:
|
|
|
|
if (!dirExists(workingDirColors)) workingDirColors=getHomeDir();
|
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Select Color File",
|
2022-04-06 19:17:29 +00:00
|
|
|
{"configuration files", "*.cfgc"},
|
|
|
|
"configuration files{.cfgc}",
|
2022-04-06 18:53:39 +00:00
|
|
|
workingDirColors,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_IMPORT_KEYBINDS:
|
|
|
|
if (!dirExists(workingDirKeybinds)) workingDirKeybinds=getHomeDir();
|
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Select Keybind File",
|
2022-04-06 19:17:29 +00:00
|
|
|
{"configuration files", "*.cfgk"},
|
|
|
|
"configuration files{.cfgk}",
|
2022-04-06 18:53:39 +00:00
|
|
|
workingDirKeybinds,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_IMPORT_LAYOUT:
|
|
|
|
if (!dirExists(workingDirKeybinds)) workingDirKeybinds=getHomeDir();
|
|
|
|
hasOpened=fileDialog->openLoad(
|
|
|
|
"Select Layout File",
|
|
|
|
{".ini files", "*.ini"},
|
|
|
|
".ini files{.ini}",
|
|
|
|
workingDirKeybinds,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_COLORS:
|
|
|
|
if (!dirExists(workingDirColors)) workingDirColors=getHomeDir();
|
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export Colors",
|
2022-04-06 19:17:29 +00:00
|
|
|
{"configuration files", "*.cfgc"},
|
|
|
|
"configuration files{.cfgc}",
|
2022-04-06 18:53:39 +00:00
|
|
|
workingDirColors,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_KEYBINDS:
|
|
|
|
if (!dirExists(workingDirKeybinds)) workingDirKeybinds=getHomeDir();
|
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export Keybinds",
|
2022-04-06 19:17:29 +00:00
|
|
|
{"configuration files", "*.cfgk"},
|
|
|
|
"configuration files{.cfgk}",
|
2022-04-06 18:53:39 +00:00
|
|
|
workingDirKeybinds,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_LAYOUT:
|
|
|
|
if (!dirExists(workingDirKeybinds)) workingDirKeybinds=getHomeDir();
|
|
|
|
hasOpened=fileDialog->openSave(
|
|
|
|
"Export Layout",
|
|
|
|
{".ini files", "*.ini"},
|
|
|
|
".ini files{.ini}",
|
|
|
|
workingDirKeybinds,
|
|
|
|
dpiScale
|
|
|
|
);
|
|
|
|
break;
|
2021-12-17 08:33:12 +00:00
|
|
|
}
|
2022-03-14 04:10:43 +00:00
|
|
|
if (hasOpened) curFileDialog=type;
|
2022-02-01 07:52:36 +00:00
|
|
|
//ImGui::GetIO().ConfigFlags|=ImGuiConfigFlags_NavEnableKeyboard;
|
2021-12-17 08:33:12 +00:00
|
|
|
}
|
|
|
|
|
2021-12-15 19:15:44 +00:00
|
|
|
#define FURNACE_ZLIB_COMPRESS
|
|
|
|
|
2022-02-20 08:18:20 +00:00
|
|
|
int FurnaceGUI::save(String path, int dmfVersion) {
|
2022-01-09 08:52:41 +00:00
|
|
|
SafeWriter* w;
|
2022-02-20 08:18:20 +00:00
|
|
|
if (dmfVersion) {
|
|
|
|
w=e->saveDMF(dmfVersion);
|
2022-01-09 08:52:41 +00:00
|
|
|
} else {
|
|
|
|
w=e->saveFur();
|
|
|
|
}
|
2022-01-08 07:04:43 +00:00
|
|
|
if (w==NULL) {
|
|
|
|
lastError=e->getLastError();
|
|
|
|
return 3;
|
|
|
|
}
|
2022-01-20 10:04:03 +00:00
|
|
|
FILE* outFile=ps_fopen(path.c_str(),"wb");
|
2022-01-14 05:34:22 +00:00
|
|
|
if (outFile==NULL) {
|
|
|
|
lastError=strerror(errno);
|
|
|
|
w->finish();
|
|
|
|
return 1;
|
|
|
|
}
|
2021-12-15 19:15:44 +00:00
|
|
|
#ifdef FURNACE_ZLIB_COMPRESS
|
|
|
|
unsigned char zbuf[131072];
|
|
|
|
int ret;
|
|
|
|
z_stream zl;
|
|
|
|
memset(&zl,0,sizeof(z_stream));
|
|
|
|
ret=deflateInit(&zl,Z_DEFAULT_COMPRESSION);
|
|
|
|
if (ret!=Z_OK) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("zlib error!");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError="compression error";
|
2021-12-15 19:15:44 +00:00
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
zl.avail_in=w->size();
|
|
|
|
zl.next_in=w->getFinalBuf();
|
|
|
|
while (zl.avail_in>0) {
|
|
|
|
zl.avail_out=131072;
|
|
|
|
zl.next_out=zbuf;
|
|
|
|
if ((ret=deflate(&zl,Z_NO_FLUSH))==Z_STREAM_ERROR) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("zlib stream error!");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError="zlib stream error";
|
2021-12-15 19:15:44 +00:00
|
|
|
deflateEnd(&zl);
|
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
size_t amount=131072-zl.avail_out;
|
|
|
|
if (amount>0) {
|
|
|
|
if (fwrite(zbuf,1,amount,outFile)!=amount) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("did not write entirely: %s!",strerror(errno));
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=strerror(errno);
|
2021-12-15 19:15:44 +00:00
|
|
|
deflateEnd(&zl);
|
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zl.avail_out=131072;
|
|
|
|
zl.next_out=zbuf;
|
|
|
|
if ((ret=deflate(&zl,Z_FINISH))==Z_STREAM_ERROR) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("zlib finish stream error!");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError="zlib finish stream error";
|
2021-12-15 19:15:44 +00:00
|
|
|
deflateEnd(&zl);
|
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (131072-zl.avail_out>0) {
|
|
|
|
if (fwrite(zbuf,1,131072-zl.avail_out,outFile)!=(131072-zl.avail_out)) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("did not write entirely: %s!",strerror(errno));
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=strerror(errno);
|
2021-12-15 19:15:44 +00:00
|
|
|
deflateEnd(&zl);
|
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
deflateEnd(&zl);
|
|
|
|
#else
|
|
|
|
if (fwrite(w->getFinalBuf(),1,w->size(),outFile)!=w->size()) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("did not write entirely: %s!",strerror(errno));
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=strerror(errno);
|
2021-12-15 19:15:44 +00:00
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
fclose(outFile);
|
|
|
|
w->finish();
|
2021-12-30 23:25:55 +00:00
|
|
|
curFileName=path;
|
|
|
|
modified=false;
|
2022-04-04 18:25:38 +00:00
|
|
|
updateWindowTitle();
|
2022-01-29 06:22:32 +00:00
|
|
|
if (!e->getWarnings().empty()) {
|
|
|
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
|
|
|
}
|
2021-12-15 19:15:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-12-15 05:37:27 +00:00
|
|
|
int FurnaceGUI::load(String path) {
|
|
|
|
if (!path.empty()) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logI("loading module...");
|
2022-01-20 10:04:03 +00:00
|
|
|
FILE* f=ps_fopen(path.c_str(),"rb");
|
2021-12-15 05:37:27 +00:00
|
|
|
if (f==NULL) {
|
|
|
|
perror("error");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=strerror(errno);
|
2021-12-15 05:37:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (fseek(f,0,SEEK_END)<0) {
|
|
|
|
perror("size error");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=fmt::sprintf("on seek: %s",strerror(errno));
|
2021-12-15 05:37:27 +00:00
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
ssize_t len=ftell(f);
|
2022-01-18 02:08:14 +00:00
|
|
|
if (len==(SIZE_MAX>>1)) {
|
2021-12-15 05:37:27 +00:00
|
|
|
perror("could not get file length");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=fmt::sprintf("on pre tell: %s",strerror(errno));
|
2021-12-15 05:37:27 +00:00
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (len<1) {
|
|
|
|
if (len==0) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("that file is empty!");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError="file is empty";
|
2021-12-15 05:37:27 +00:00
|
|
|
} else {
|
|
|
|
perror("tell error");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=fmt::sprintf("on tell: %s",strerror(errno));
|
2021-12-15 05:37:27 +00:00
|
|
|
}
|
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (fseek(f,0,SEEK_SET)<0) {
|
|
|
|
perror("size error");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=fmt::sprintf("on get size: %s",strerror(errno));
|
2021-12-15 05:37:27 +00:00
|
|
|
fclose(f);
|
|
|
|
return 1;
|
|
|
|
}
|
2022-04-15 06:30:21 +00:00
|
|
|
unsigned char* file=new unsigned char[len];
|
2021-12-15 05:37:27 +00:00
|
|
|
if (fread(file,1,(size_t)len,f)!=(size_t)len) {
|
|
|
|
perror("read error");
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=fmt::sprintf("on read: %s",strerror(errno));
|
2021-12-15 05:37:27 +00:00
|
|
|
fclose(f);
|
2021-12-16 07:21:43 +00:00
|
|
|
delete[] file;
|
2021-12-15 05:37:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
fclose(f);
|
2021-12-16 07:21:43 +00:00
|
|
|
if (!e->load(file,(size_t)len)) {
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError=e->getLastError();
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("could not open file!");
|
2021-12-15 05:37:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 23:25:55 +00:00
|
|
|
curFileName=path;
|
|
|
|
modified=false;
|
2022-01-20 07:11:03 +00:00
|
|
|
curNibble=false;
|
|
|
|
orderNibble=false;
|
|
|
|
orderCursor=-1;
|
2022-03-21 05:41:18 +00:00
|
|
|
samplePos=0;
|
|
|
|
updateSampleTex=true;
|
2022-01-20 07:11:03 +00:00
|
|
|
selStart=SelectionPoint();
|
|
|
|
selEnd=SelectionPoint();
|
|
|
|
cursor=SelectionPoint();
|
2021-12-21 04:20:30 +00:00
|
|
|
lastError="everything OK";
|
2021-12-26 23:05:18 +00:00
|
|
|
undoHist.clear();
|
|
|
|
redoHist.clear();
|
2021-12-15 22:32:08 +00:00
|
|
|
updateWindowTitle();
|
2022-01-29 06:22:32 +00:00
|
|
|
if (!e->getWarnings().empty()) {
|
|
|
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
|
|
|
}
|
2021-12-15 05:37:27 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-01-18 04:34:29 +00:00
|
|
|
void FurnaceGUI::exportAudio(String path, DivAudioExportModes mode) {
|
|
|
|
e->saveAudio(path.c_str(),exportLoops+1,mode);
|
|
|
|
displayExporting=true;
|
|
|
|
}
|
|
|
|
|
2021-12-30 23:52:36 +00:00
|
|
|
void FurnaceGUI::showWarning(String what, FurnaceGUIWarnings type) {
|
|
|
|
warnString=what;
|
|
|
|
warnAction=type;
|
|
|
|
warnQuit=true;
|
|
|
|
}
|
|
|
|
|
2021-12-21 04:20:30 +00:00
|
|
|
void FurnaceGUI::showError(String what) {
|
|
|
|
errorString=what;
|
2022-01-09 21:36:47 +00:00
|
|
|
displayError=true;
|
2021-12-21 04:20:30 +00:00
|
|
|
}
|
|
|
|
|
2022-01-21 07:54:52 +00:00
|
|
|
#define MACRO_DRAG(t) \
|
|
|
|
if (macroDragBitMode) { \
|
|
|
|
if (macroDragLastX!=x || macroDragLastY!=y) { \
|
|
|
|
macroDragLastX=x; \
|
|
|
|
macroDragLastY=y; \
|
|
|
|
if (macroDragInitialValueSet) { \
|
|
|
|
if (macroDragInitialValue) { \
|
|
|
|
t[x]=(((t[x]+macroDragBitOff)&((1<<macroDragMax)-1))&(~(1<<y)))-macroDragBitOff; \
|
|
|
|
} else { \
|
|
|
|
t[x]=(((t[x]+macroDragBitOff)&((1<<macroDragMax)-1))|(1<<y))-macroDragBitOff; \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
macroDragInitialValue=(((t[x]+macroDragBitOff)&((1<<macroDragMax)-1))&(1<<y)); \
|
|
|
|
macroDragInitialValueSet=true; \
|
|
|
|
t[x]=(((t[x]+macroDragBitOff)&((1<<macroDragMax)-1))^(1<<y))-macroDragBitOff; \
|
|
|
|
} \
|
|
|
|
t[x]&=(1<<macroDragMax)-1; \
|
|
|
|
} \
|
|
|
|
} else { \
|
2022-04-13 04:03:20 +00:00
|
|
|
if (macroDragLineMode) { \
|
|
|
|
if (!macroDragInitialValueSet) { \
|
|
|
|
macroDragLineInitial=ImVec2(x,y); \
|
|
|
|
macroDragInitialValueSet=true; \
|
|
|
|
} \
|
|
|
|
if ((int)round(x-macroDragLineInitial.x)==0) { \
|
|
|
|
t[x]=macroDragLineInitial.y; \
|
|
|
|
} else { \
|
|
|
|
if ((int)round(x-macroDragLineInitial.x)<0) { \
|
|
|
|
for (int i=0; i<=(int)round(macroDragLineInitial.x-x); i++) { \
|
|
|
|
int index=(int)round(x+i); \
|
|
|
|
if (index<0) continue; \
|
|
|
|
t[index]=y+(macroDragLineInitial.y-y)*((float)i/(float)(macroDragLineInitial.x-x)); \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
for (int i=0; i<=(int)round(x-macroDragLineInitial.x); i++) { \
|
|
|
|
int index=(int)round(i+macroDragLineInitial.x); \
|
|
|
|
if (index<0) continue; \
|
|
|
|
t[index]=macroDragLineInitial.y+(y-macroDragLineInitial.y)*((float)i/(x-macroDragLineInitial.x)); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} else { \
|
|
|
|
t[x]=y; \
|
|
|
|
} \
|
2022-01-21 07:54:52 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 03:58:43 +00:00
|
|
|
void FurnaceGUI::processDrags(int dragX, int dragY) {
|
|
|
|
if (macroDragActive) {
|
|
|
|
if (macroDragLen>0) {
|
2022-02-15 22:22:09 +00:00
|
|
|
int x=((dragX-macroDragStart.x)*macroDragLen/MAX(1,macroDragAreaSize.x));
|
2021-12-24 03:58:43 +00:00
|
|
|
if (x<0) x=0;
|
|
|
|
if (x>=macroDragLen) x=macroDragLen-1;
|
2022-01-21 22:00:28 +00:00
|
|
|
x+=macroDragScroll;
|
2022-01-21 06:56:30 +00:00
|
|
|
int y;
|
|
|
|
if (macroDragBitMode) {
|
2022-02-15 22:22:09 +00:00
|
|
|
y=(int)(macroDragMax-((dragY-macroDragStart.y)*(double(macroDragMax-macroDragMin)/(double)MAX(1,macroDragAreaSize.y))));
|
2022-01-21 06:56:30 +00:00
|
|
|
} else {
|
2022-02-15 22:22:09 +00:00
|
|
|
y=round(macroDragMax-((dragY-macroDragStart.y)*(double(macroDragMax-macroDragMin)/(double)MAX(1,macroDragAreaSize.y))));
|
2022-01-21 06:56:30 +00:00
|
|
|
}
|
2021-12-24 03:58:43 +00:00
|
|
|
if (y>macroDragMax) y=macroDragMax;
|
|
|
|
if (y<macroDragMin) y=macroDragMin;
|
2022-01-21 07:54:52 +00:00
|
|
|
if (macroDragChar) {
|
|
|
|
MACRO_DRAG(macroDragCTarget);
|
2022-01-21 06:56:30 +00:00
|
|
|
} else {
|
2022-01-21 07:54:52 +00:00
|
|
|
MACRO_DRAG(macroDragTarget);
|
2022-01-21 06:56:30 +00:00
|
|
|
}
|
2021-12-24 03:58:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (macroLoopDragActive) {
|
|
|
|
if (macroLoopDragLen>0) {
|
2022-02-15 22:22:09 +00:00
|
|
|
int x=(dragX-macroLoopDragStart.x)*macroLoopDragLen/MAX(1,macroLoopDragAreaSize.x);
|
2021-12-24 03:58:43 +00:00
|
|
|
if (x<0) x=0;
|
|
|
|
if (x>=macroLoopDragLen) x=-1;
|
2022-01-26 22:22:29 +00:00
|
|
|
x+=macroDragScroll;
|
2021-12-24 03:58:43 +00:00
|
|
|
*macroLoopDragTarget=x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (waveDragActive) {
|
|
|
|
if (waveDragLen>0) {
|
2022-02-15 22:22:09 +00:00
|
|
|
int x=(dragX-waveDragStart.x)*waveDragLen/MAX(1,waveDragAreaSize.x);
|
2021-12-24 03:58:43 +00:00
|
|
|
if (x<0) x=0;
|
|
|
|
if (x>=waveDragLen) x=waveDragLen-1;
|
2022-02-15 22:22:09 +00:00
|
|
|
int y=round(waveDragMax-((dragY-waveDragStart.y)*(double(waveDragMax-waveDragMin)/(double)MAX(1,waveDragAreaSize.y))));
|
2021-12-24 03:58:43 +00:00
|
|
|
if (y>waveDragMax) y=waveDragMax;
|
|
|
|
if (y<waveDragMin) y=waveDragMin;
|
|
|
|
waveDragTarget[x]=y;
|
2022-01-18 05:25:10 +00:00
|
|
|
e->notifyWaveChange(curWave);
|
2022-03-21 21:17:51 +00:00
|
|
|
MARK_MODIFIED;
|
2021-12-24 03:58:43 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-20 23:25:48 +00:00
|
|
|
if (sampleDragActive) {
|
2022-03-21 05:41:18 +00:00
|
|
|
int x=samplePos+round(double(dragX-sampleDragStart.x)*sampleZoom);
|
|
|
|
int x1=samplePos+round(double(dragX-sampleDragStart.x+1)*sampleZoom);
|
2022-03-20 23:25:48 +00:00
|
|
|
if (x<0) x=0;
|
2022-03-21 05:41:18 +00:00
|
|
|
if (sampleDragMode) {
|
|
|
|
if (x>=(int)sampleDragLen) x=sampleDragLen-1;
|
|
|
|
} else {
|
|
|
|
if (x>(int)sampleDragLen) x=sampleDragLen;
|
|
|
|
}
|
2022-03-20 23:25:48 +00:00
|
|
|
if (x1<0) x1=0;
|
|
|
|
if (x1>=(int)sampleDragLen) x1=sampleDragLen-1;
|
|
|
|
double y=0.5-double(dragY-sampleDragStart.y)/sampleDragAreaSize.y;
|
|
|
|
if (sampleDragMode) { // draw
|
|
|
|
if (sampleDrag16) {
|
|
|
|
int val=y*65536;
|
|
|
|
if (val<-32768) val=-32768;
|
|
|
|
if (val>32767) val=32767;
|
|
|
|
for (int i=x; i<=x1; i++) ((short*)sampleDragTarget)[i]=val;
|
|
|
|
} else {
|
|
|
|
int val=y*256;
|
|
|
|
if (val<-128) val=-128;
|
|
|
|
if (val>127) val=127;
|
|
|
|
for (int i=x; i<=x1; i++) ((signed char*)sampleDragTarget)[i]=val;
|
|
|
|
}
|
|
|
|
updateSampleTex=true;
|
|
|
|
} else { // select
|
|
|
|
if (sampleSelStart<0) {
|
|
|
|
sampleSelStart=x;
|
|
|
|
}
|
|
|
|
sampleSelEnd=x;
|
|
|
|
}
|
|
|
|
}
|
2021-12-24 03:58:43 +00:00
|
|
|
}
|
|
|
|
|
2022-01-08 23:18:23 +00:00
|
|
|
#define sysAddOption(x) \
|
2022-01-28 08:17:35 +00:00
|
|
|
if (ImGui::MenuItem(getSystemName(x))) { \
|
2022-01-08 23:18:23 +00:00
|
|
|
if (!e->addSystem(x)) { \
|
2022-01-16 06:17:30 +00:00
|
|
|
showError("cannot add system! ("+e->getLastError()+")"); \
|
2022-01-08 23:18:23 +00:00
|
|
|
} \
|
|
|
|
updateWindowTitle(); \
|
|
|
|
}
|
|
|
|
|
2022-01-09 21:36:47 +00:00
|
|
|
#define sysChangeOption(x,y) \
|
2022-01-28 08:17:35 +00:00
|
|
|
if (ImGui::MenuItem(getSystemName(y),NULL,e->song.system[x]==y)) { \
|
2022-01-09 21:36:47 +00:00
|
|
|
e->changeSystem(x,y); \
|
2021-12-18 03:14:41 +00:00
|
|
|
updateWindowTitle(); \
|
|
|
|
}
|
|
|
|
|
2022-01-19 10:10:06 +00:00
|
|
|
#define checkExtension(x) \
|
2022-02-09 04:13:54 +00:00
|
|
|
String lowerCase=fileName; \
|
|
|
|
for (char& i: lowerCase) { \
|
|
|
|
if (i>='A' && i<='Z') i+='a'-'A'; \
|
|
|
|
} \
|
|
|
|
if (lowerCase.size()<4 || lowerCase.rfind(x)!=lowerCase.size()-4) { \
|
2022-01-19 10:10:06 +00:00
|
|
|
fileName+=x; \
|
|
|
|
}
|
|
|
|
|
2022-03-14 04:10:43 +00:00
|
|
|
#define checkExtensionDual(x,y,fallback) \
|
|
|
|
String lowerCase=fileName; \
|
|
|
|
for (char& i: lowerCase) { \
|
|
|
|
if (i>='A' && i<='Z') i+='a'-'A'; \
|
|
|
|
} \
|
|
|
|
if (lowerCase.size()<4 || (lowerCase.rfind(x)!=lowerCase.size()-4 && lowerCase.rfind(y)!=lowerCase.size()-4)) { \
|
|
|
|
fileName+=fallback; \
|
|
|
|
}
|
|
|
|
|
2022-03-09 23:03:15 +00:00
|
|
|
void FurnaceGUI::editOptions(bool topMenu) {
|
|
|
|
char id[4096];
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("cut",BIND_FOR(GUI_ACTION_PAT_CUT))) doCopy(true);
|
|
|
|
if (ImGui::MenuItem("copy",BIND_FOR(GUI_ACTION_PAT_COPY))) doCopy(false);
|
|
|
|
if (ImGui::MenuItem("paste",BIND_FOR(GUI_ACTION_PAT_PASTE))) doPaste();
|
|
|
|
if (ImGui::BeginMenu("paste special...")) {
|
|
|
|
if (ImGui::MenuItem("paste mix",BIND_FOR(GUI_ACTION_PAT_PASTE_MIX))) doPaste(GUI_PASTE_MODE_MIX_FG);
|
|
|
|
if (ImGui::MenuItem("paste mix (background)",BIND_FOR(GUI_ACTION_PAT_PASTE_MIX_BG))) doPaste(GUI_PASTE_MODE_MIX_BG);
|
|
|
|
if (ImGui::MenuItem("paste flood",BIND_FOR(GUI_ACTION_PAT_PASTE_FLOOD))) doPaste(GUI_PASTE_MODE_FLOOD);
|
|
|
|
if (ImGui::MenuItem("paste overflow",BIND_FOR(GUI_ACTION_PAT_PASTE_OVERFLOW))) doPaste(GUI_PASTE_MODE_OVERFLOW);
|
2022-03-09 23:03:15 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("delete",BIND_FOR(GUI_ACTION_PAT_DELETE))) doDelete();
|
2022-03-09 23:03:15 +00:00
|
|
|
if (topMenu) {
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("select all",BIND_FOR(GUI_ACTION_PAT_SELECT_ALL))) doSelectAll();
|
2022-03-09 23:03:15 +00:00
|
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
|
2022-04-01 10:20:00 +00:00
|
|
|
ImGui::Text("operation mask");
|
2022-03-12 08:04:34 +00:00
|
|
|
ImGui::SameLine();
|
2022-03-12 07:13:15 +00:00
|
|
|
|
|
|
|
ImGui::PushFont(patFont);
|
|
|
|
if (ImGui::BeginTable("opMaskTable",5,ImGuiTableFlags_Borders|ImGuiTableFlags_SizingFixedFit|ImGuiTableFlags_NoHostExtendX)) {
|
|
|
|
ImGui::TableNextRow();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_ACTIVE]);
|
|
|
|
if (ImGui::Selectable(opMaskNote?"C-4##opMaskNote":"---##opMaskNote",opMaskNote,ImGuiSelectableFlags_DontClosePopups)) {
|
|
|
|
opMaskNote=!opMaskNote;
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_INS]);
|
|
|
|
if (ImGui::Selectable(opMaskIns?"01##opMaskIns":"--##opMaskIns",opMaskIns,ImGuiSelectableFlags_DontClosePopups)) {
|
|
|
|
opMaskIns=!opMaskIns;
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_VOLUME_MAX]);
|
|
|
|
if (ImGui::Selectable(opMaskVol?"7F##opMaskVol":"--##opMaskVol",opMaskVol,ImGuiSelectableFlags_DontClosePopups)) {
|
|
|
|
opMaskVol=!opMaskVol;
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PATTERN_EFFECT_PITCH]);
|
|
|
|
if (ImGui::Selectable(opMaskEffect?"04##opMaskEffect":"--##opMaskEffect",opMaskEffect,ImGuiSelectableFlags_DontClosePopups)) {
|
|
|
|
opMaskEffect=!opMaskEffect;
|
|
|
|
}
|
|
|
|
ImGui::TableNextColumn();
|
|
|
|
if (ImGui::Selectable(opMaskEffectVal?"72##opMaskEffectVal":"--##opMaskEffectVal",opMaskEffectVal,ImGuiSelectableFlags_DontClosePopups)) {
|
|
|
|
opMaskEffectVal=!opMaskEffectVal;
|
|
|
|
}
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
ImGui::EndTable();
|
|
|
|
}
|
|
|
|
ImGui::PopFont();
|
|
|
|
|
2022-04-01 10:20:00 +00:00
|
|
|
ImGui::Text("input latch");
|
2022-03-09 23:03:15 +00:00
|
|
|
if (ImGui::MenuItem("set latch",BIND_FOR(GUI_ACTION_PAT_LATCH))) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
ImGui::Separator();
|
|
|
|
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("note up",BIND_FOR(GUI_ACTION_PAT_NOTE_UP))) doTranspose(1);
|
|
|
|
if (ImGui::MenuItem("note down",BIND_FOR(GUI_ACTION_PAT_NOTE_DOWN))) doTranspose(-1);
|
|
|
|
if (ImGui::MenuItem("octave up",BIND_FOR(GUI_ACTION_PAT_OCTAVE_UP))) doTranspose(12);
|
|
|
|
if (ImGui::MenuItem("octave down",BIND_FOR(GUI_ACTION_PAT_OCTAVE_DOWN))) doTranspose(-12);
|
2022-03-09 23:03:15 +00:00
|
|
|
if (ImGui::InputInt("##TransposeAmount",&transposeAmount,1,1)) {
|
|
|
|
if (transposeAmount<-96) transposeAmount=-96;
|
|
|
|
if (transposeAmount>96) transposeAmount=96;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Transpose")) {
|
|
|
|
doTranspose(transposeAmount);
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("interpolate",BIND_FOR(GUI_ACTION_PAT_INTERPOLATE))) doInterpolate();
|
|
|
|
if (ImGui::BeginMenu("change instrument...")) {
|
2022-03-09 23:03:15 +00:00
|
|
|
if (e->song.ins.empty()) {
|
|
|
|
ImGui::Text("no instruments available");
|
|
|
|
}
|
|
|
|
for (size_t i=0; i<e->song.ins.size(); i++) {
|
|
|
|
snprintf(id,4095,"%.2X: %s",(int)i,e->song.ins[i]->name.c_str());
|
2022-03-11 06:31:21 +00:00
|
|
|
if (ImGui::MenuItem(id)) {
|
|
|
|
doChangeIns(i);
|
2022-03-09 23:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("gradient/fade...")) {
|
2022-03-12 08:04:34 +00:00
|
|
|
if (ImGui::InputInt("Start",&fadeMin,1,1)) {
|
|
|
|
if (fadeMin<0) fadeMin=0;
|
|
|
|
if (fadeMode) {
|
|
|
|
if (fadeMin>15) fadeMin=15;
|
|
|
|
} else {
|
|
|
|
if (fadeMin>255) fadeMin=255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ImGui::InputInt("End",&fadeMax,1,1)) {
|
|
|
|
if (fadeMax<0) fadeMax=0;
|
|
|
|
if (fadeMode) {
|
|
|
|
if (fadeMax>15) fadeMax=15;
|
|
|
|
} else {
|
|
|
|
if (fadeMax>255) fadeMax=255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ImGui::Checkbox("Nibble mode",&fadeMode)) {
|
|
|
|
if (fadeMode) {
|
|
|
|
if (fadeMin>15) fadeMin=15;
|
|
|
|
if (fadeMax>15) fadeMax=15;
|
|
|
|
} else {
|
|
|
|
if (fadeMin>255) fadeMin=255;
|
|
|
|
if (fadeMax>255) fadeMax=255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ImGui::Button("Go ahead")) {
|
|
|
|
doFade(fadeMin,fadeMax,fadeMode);
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("scale...")) {
|
2022-03-12 07:13:15 +00:00
|
|
|
if (ImGui::InputFloat("##ScaleMax",&scaleMax,1,1,"%.1f%%")) {
|
2022-03-09 23:03:15 +00:00
|
|
|
if (scaleMax<0.0f) scaleMax=0.0f;
|
2022-03-12 07:13:15 +00:00
|
|
|
if (scaleMax>25600.0f) scaleMax=25600.0f;
|
2022-03-09 23:03:15 +00:00
|
|
|
}
|
|
|
|
if (ImGui::Button("Scale")) {
|
2022-03-12 07:13:15 +00:00
|
|
|
doScale(scaleMax);
|
2022-03-09 23:03:15 +00:00
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("randomize...")) {
|
2022-03-12 07:13:15 +00:00
|
|
|
if (ImGui::InputInt("Minimum",&randomizeMin,1,1)) {
|
|
|
|
if (randomizeMin<0) randomizeMin=0;
|
2022-03-12 08:40:56 +00:00
|
|
|
if (randomMode) {
|
|
|
|
if (randomizeMin>15) randomizeMin=15;
|
|
|
|
} else {
|
|
|
|
if (randomizeMin>255) randomizeMin=255;
|
|
|
|
}
|
2022-03-12 07:13:15 +00:00
|
|
|
if (randomizeMin>randomizeMax) randomizeMin=randomizeMax;
|
|
|
|
}
|
|
|
|
if (ImGui::InputInt("Maximum",&randomizeMax,1,1)) {
|
|
|
|
if (randomizeMax<0) randomizeMax=0;
|
|
|
|
if (randomizeMax<randomizeMin) randomizeMax=randomizeMin;
|
2022-03-12 08:40:56 +00:00
|
|
|
if (randomMode) {
|
|
|
|
if (randomizeMax>15) randomizeMax=15;
|
|
|
|
} else {
|
|
|
|
if (randomizeMax>255) randomizeMax=255;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ImGui::Checkbox("Nibble mode",&randomMode)) {
|
|
|
|
if (randomMode) {
|
|
|
|
if (randomizeMin>15) randomizeMin=15;
|
|
|
|
if (randomizeMax>15) randomizeMax=15;
|
|
|
|
} else {
|
|
|
|
if (randomizeMin>255) randomizeMin=255;
|
|
|
|
if (randomizeMax>255) randomizeMax=255;
|
|
|
|
}
|
2022-03-12 07:13:15 +00:00
|
|
|
}
|
2022-03-12 08:04:34 +00:00
|
|
|
// TODO: add an option to set effect to specific value?
|
2022-03-09 23:03:15 +00:00
|
|
|
if (ImGui::Button("Randomize")) {
|
2022-03-12 08:40:56 +00:00
|
|
|
doRandomize(randomizeMin,randomizeMax,randomMode);
|
2022-03-09 23:03:15 +00:00
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("invert values",BIND_FOR(GUI_ACTION_PAT_INVERT_VALUES))) doInvertValues();
|
2022-03-09 23:03:15 +00:00
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("flip selection",BIND_FOR(GUI_ACTION_PAT_FLIP_SELECTION))) doFlip();
|
|
|
|
if (ImGui::MenuItem("collapse",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_ROWS))) doCollapse(2);
|
|
|
|
if (ImGui::MenuItem("expand",BIND_FOR(GUI_ACTION_PAT_EXPAND_ROWS))) doExpand(2);
|
2022-03-09 23:03:15 +00:00
|
|
|
|
|
|
|
if (topMenu) {
|
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
ImGui::MenuItem("collapse pattern",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_PAT));
|
|
|
|
ImGui::MenuItem("expand pattern",BIND_FOR(GUI_ACTION_PAT_EXPAND_PAT));
|
2022-03-09 23:03:15 +00:00
|
|
|
|
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
ImGui::MenuItem("collapse song",BIND_FOR(GUI_ACTION_PAT_COLLAPSE_SONG));
|
|
|
|
ImGui::MenuItem("expand song",BIND_FOR(GUI_ACTION_PAT_EXPAND_SONG));
|
2022-03-09 23:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-16 03:22:47 +00:00
|
|
|
int _processEvent(void* instance, SDL_Event* event) {
|
|
|
|
return ((FurnaceGUI*)instance)->processEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
int FurnaceGUI::processEvent(SDL_Event* ev) {
|
|
|
|
if (ev->type==SDL_KEYDOWN) {
|
2022-04-16 05:10:52 +00:00
|
|
|
if (!ev->key.repeat && !wantCaptureKeyboard && (ev->key.keysym.mod&(~(KMOD_NUM|KMOD_CAPS|KMOD_SCROLL)))==0) {
|
2022-04-16 18:13:19 +00:00
|
|
|
if (settings.notePreviewBehavior==0) return 1;
|
2022-04-16 04:47:39 +00:00
|
|
|
switch (curWindow) {
|
|
|
|
case GUI_WINDOW_SAMPLE_EDIT:
|
|
|
|
case GUI_WINDOW_SAMPLE_LIST:
|
|
|
|
try {
|
|
|
|
int key=noteKeys.at(ev->key.keysym.scancode);
|
|
|
|
int num=12*curOctave+key;
|
|
|
|
if (key!=100 && key!=101 && key!=102) {
|
|
|
|
e->previewSample(curSample,num);
|
|
|
|
samplePreviewOn=true;
|
|
|
|
samplePreviewKey=ev->key.keysym.scancode;
|
|
|
|
samplePreviewNote=num;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WINDOW_WAVE_LIST:
|
|
|
|
case GUI_WINDOW_WAVE_EDIT:
|
|
|
|
try {
|
|
|
|
int key=noteKeys.at(ev->key.keysym.scancode);
|
|
|
|
int num=12*curOctave+key;
|
|
|
|
if (key!=100 && key!=101 && key!=102) {
|
|
|
|
e->previewWave(curWave,num);
|
|
|
|
wavePreviewOn=true;
|
|
|
|
wavePreviewKey=ev->key.keysym.scancode;
|
|
|
|
wavePreviewNote=num;
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WINDOW_ORDERS: // ignore here
|
|
|
|
break;
|
2022-04-16 18:13:19 +00:00
|
|
|
case GUI_WINDOW_PATTERN:
|
|
|
|
if (settings.notePreviewBehavior==1) {
|
|
|
|
if (cursor.xFine!=0) break;
|
|
|
|
} else if (settings.notePreviewBehavior==2) {
|
|
|
|
if (edit && cursor.xFine!=0) break;
|
|
|
|
}
|
|
|
|
// fall-through
|
2022-04-16 04:47:39 +00:00
|
|
|
default:
|
|
|
|
try {
|
|
|
|
int key=noteKeys.at(ev->key.keysym.scancode);
|
|
|
|
int num=12*curOctave+key;
|
2022-04-16 03:22:47 +00:00
|
|
|
|
2022-04-16 04:47:39 +00:00
|
|
|
if (num<-60) num=-60; // C-(-5)
|
|
|
|
if (num>119) num=119; // B-9
|
2022-04-16 03:22:47 +00:00
|
|
|
|
2022-04-16 04:47:39 +00:00
|
|
|
if (key!=100 && key!=101 && key!=102) {
|
|
|
|
previewNote(cursor.xCoarse,num);
|
|
|
|
}
|
|
|
|
} catch (std::out_of_range& e) {
|
|
|
|
}
|
|
|
|
break;
|
2022-04-16 03:22:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (ev->type==SDL_KEYUP) {
|
|
|
|
stopPreviewNote(ev->key.keysym.scancode,true);
|
|
|
|
if (wavePreviewOn) {
|
|
|
|
if (ev->key.keysym.scancode==wavePreviewKey) {
|
|
|
|
wavePreviewOn=false;
|
|
|
|
e->stopWavePreview();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (samplePreviewOn) {
|
|
|
|
if (ev->key.keysym.scancode==samplePreviewKey) {
|
|
|
|
samplePreviewOn=false;
|
|
|
|
e->stopSamplePreview();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-12-14 09:45:44 +00:00
|
|
|
bool FurnaceGUI::loop() {
|
2022-04-16 03:22:47 +00:00
|
|
|
SDL_SetEventFilter(_processEvent,this);
|
|
|
|
|
2021-12-14 09:45:44 +00:00
|
|
|
while (!quit) {
|
|
|
|
SDL_Event ev;
|
|
|
|
while (SDL_PollEvent(&ev)) {
|
|
|
|
ImGui_ImplSDL2_ProcessEvent(&ev);
|
|
|
|
switch (ev.type) {
|
2022-02-08 07:04:23 +00:00
|
|
|
case SDL_MOUSEMOTION: {
|
|
|
|
int motionX=ev.motion.x;
|
|
|
|
int motionY=ev.motion.y;
|
|
|
|
int motionXrel=ev.motion.xrel;
|
|
|
|
int motionYrel=ev.motion.yrel;
|
|
|
|
#ifdef __APPLE__
|
|
|
|
motionX*=dpiScale;
|
|
|
|
motionY*=dpiScale;
|
|
|
|
motionXrel*=dpiScale;
|
|
|
|
motionYrel*=dpiScale;
|
|
|
|
#endif
|
2021-12-23 16:29:11 +00:00
|
|
|
if (selecting) {
|
|
|
|
// detect whether we have to scroll
|
2022-03-17 21:17:33 +00:00
|
|
|
if (motionY<patWindowPos.y+2.0f*dpiScale) {
|
2021-12-24 03:14:59 +00:00
|
|
|
addScroll(-1);
|
|
|
|
}
|
2022-03-17 21:17:33 +00:00
|
|
|
if (motionY>patWindowPos.y+patWindowSize.y-2.0f*dpiScale) {
|
2021-12-24 03:14:59 +00:00
|
|
|
addScroll(1);
|
|
|
|
}
|
2021-12-23 16:29:11 +00:00
|
|
|
}
|
2022-03-20 23:25:48 +00:00
|
|
|
if (macroDragActive || macroLoopDragActive || waveDragActive || sampleDragActive) {
|
2022-03-22 02:48:36 +00:00
|
|
|
int distance=fabs((double)motionXrel);
|
2022-01-30 23:10:41 +00:00
|
|
|
if (distance<1) distance=1;
|
2022-02-08 07:04:23 +00:00
|
|
|
float start=motionX-motionXrel;
|
|
|
|
float end=motionX;
|
|
|
|
float startY=motionY-motionYrel;
|
|
|
|
float endY=motionY;
|
2022-01-30 23:10:41 +00:00
|
|
|
for (int i=0; i<=distance; i++) {
|
|
|
|
float fraction=(float)i/(float)distance;
|
|
|
|
float x=start+(end-start)*fraction;
|
|
|
|
float y=startY+(endY-startY)*fraction;
|
|
|
|
processDrags(x,y);
|
|
|
|
}
|
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
break;
|
2022-02-08 07:04:23 +00:00
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
case SDL_MOUSEBUTTONUP:
|
2022-03-21 21:17:51 +00:00
|
|
|
if (macroDragActive || macroLoopDragActive || waveDragActive || (sampleDragActive && sampleDragMode)) {
|
|
|
|
MARK_MODIFIED;
|
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
macroDragActive=false;
|
2022-01-21 06:56:30 +00:00
|
|
|
macroDragBitMode=false;
|
|
|
|
macroDragInitialValue=false;
|
|
|
|
macroDragInitialValueSet=false;
|
|
|
|
macroDragLastX=-1;
|
|
|
|
macroDragLastY=-1;
|
2021-12-14 09:45:44 +00:00
|
|
|
macroLoopDragActive=false;
|
2021-12-18 22:54:26 +00:00
|
|
|
waveDragActive=false;
|
2022-03-20 23:25:48 +00:00
|
|
|
if (sampleDragActive) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logD("stopping sample drag");
|
2022-03-20 23:25:48 +00:00
|
|
|
if (sampleDragMode) {
|
|
|
|
e->renderSamplesP();
|
|
|
|
} else {
|
|
|
|
if (sampleSelStart>sampleSelEnd) {
|
|
|
|
sampleSelStart^=sampleSelEnd;
|
|
|
|
sampleSelEnd^=sampleSelStart;
|
|
|
|
sampleSelStart^=sampleSelEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sampleDragActive=false;
|
2021-12-24 03:20:54 +00:00
|
|
|
if (selecting) {
|
2022-01-22 08:12:02 +00:00
|
|
|
cursor=selEnd;
|
2021-12-24 03:20:54 +00:00
|
|
|
finishSelection();
|
2022-02-15 07:59:20 +00:00
|
|
|
demandScrollX=true;
|
2021-12-24 03:20:54 +00:00
|
|
|
if (cursor.xCoarse==selStart.xCoarse && cursor.xFine==selStart.xFine && cursor.y==selStart.y &&
|
|
|
|
cursor.xCoarse==selEnd.xCoarse && cursor.xFine==selEnd.xFine && cursor.y==selEnd.y) {
|
|
|
|
updateScroll(cursor.y);
|
|
|
|
}
|
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
break;
|
2021-12-19 04:03:50 +00:00
|
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
|
|
aboutOpen=false;
|
2022-02-12 06:57:55 +00:00
|
|
|
if (bindSetActive) {
|
|
|
|
bindSetActive=false;
|
|
|
|
bindSetPending=false;
|
|
|
|
actionKeys[bindSetTarget]=bindSetPrevValue;
|
|
|
|
bindSetTarget=0;
|
|
|
|
bindSetPrevValue=0;
|
|
|
|
}
|
2021-12-19 04:03:50 +00:00
|
|
|
break;
|
2022-04-02 05:11:44 +00:00
|
|
|
case SDL_MOUSEWHEEL:
|
|
|
|
wheelX+=ev.wheel.x;
|
|
|
|
wheelY+=ev.wheel.y;
|
|
|
|
break;
|
2021-12-14 09:45:44 +00:00
|
|
|
case SDL_WINDOWEVENT:
|
|
|
|
switch (ev.window.event) {
|
|
|
|
case SDL_WINDOWEVENT_RESIZED:
|
2022-02-08 07:04:23 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
scrW=ev.window.data1;
|
|
|
|
scrH=ev.window.data2;
|
|
|
|
#else
|
2021-12-14 09:45:44 +00:00
|
|
|
scrW=ev.window.data1/dpiScale;
|
|
|
|
scrH=ev.window.data2/dpiScale;
|
2022-02-08 07:04:23 +00:00
|
|
|
#endif
|
2021-12-14 09:45:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2021-12-14 22:45:37 +00:00
|
|
|
case SDL_KEYDOWN:
|
|
|
|
if (!ImGui::GetIO().WantCaptureKeyboard) {
|
|
|
|
keyDown(ev);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SDL_KEYUP:
|
2022-04-16 03:22:47 +00:00
|
|
|
// for now
|
2021-12-14 22:45:37 +00:00
|
|
|
break;
|
2022-02-01 08:09:53 +00:00
|
|
|
case SDL_DROPFILE:
|
|
|
|
if (ev.drop.file!=NULL) {
|
|
|
|
if (modified) {
|
|
|
|
nextFile=ev.drop.file;
|
2022-04-13 07:09:59 +00:00
|
|
|
showWarning("Unsaved changes! Save changes before opening file?",GUI_WARN_OPEN_DROP);
|
2022-02-01 08:09:53 +00:00
|
|
|
} else {
|
|
|
|
if (load(ev.drop.file)>0) {
|
|
|
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SDL_free(ev.drop.file);
|
|
|
|
}
|
|
|
|
break;
|
2021-12-14 09:45:44 +00:00
|
|
|
case SDL_QUIT:
|
2021-12-30 23:52:36 +00:00
|
|
|
if (modified) {
|
2022-04-13 07:09:59 +00:00
|
|
|
showWarning("Unsaved changes! Save changes before quitting?",GUI_WARN_QUIT);
|
2021-12-30 23:52:36 +00:00
|
|
|
} else {
|
|
|
|
quit=true;
|
|
|
|
return true;
|
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
break;
|
2021-12-13 07:03:36 +00:00
|
|
|
}
|
2021-12-12 09:21:09 +00:00
|
|
|
}
|
2022-04-16 04:47:39 +00:00
|
|
|
|
|
|
|
wantCaptureKeyboard=ImGui::GetIO().WantCaptureKeyboard;
|
2021-12-14 09:45:44 +00:00
|
|
|
|
2022-03-28 23:19:47 +00:00
|
|
|
while (true) {
|
|
|
|
midiLock.lock();
|
|
|
|
if (midiQueue.empty()) {
|
|
|
|
midiLock.unlock();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TAMidiMessage msg=midiQueue.front();
|
|
|
|
midiLock.unlock();
|
|
|
|
|
|
|
|
// parse message here
|
2022-03-31 23:39:01 +00:00
|
|
|
if (learning!=-1) {
|
|
|
|
if (learning>=0 && learning<(int)midiMap.binds.size()) {
|
|
|
|
midiMap.binds[learning].type=msg.type>>4;
|
|
|
|
midiMap.binds[learning].channel=msg.type&15;
|
|
|
|
midiMap.binds[learning].data1=msg.data[0];
|
2022-04-01 06:50:01 +00:00
|
|
|
switch (msg.type&0xf0) {
|
2022-03-31 23:39:01 +00:00
|
|
|
case TA_MIDI_NOTE_OFF:
|
|
|
|
case TA_MIDI_NOTE_ON:
|
|
|
|
case TA_MIDI_AFTERTOUCH:
|
|
|
|
case TA_MIDI_PITCH_BEND:
|
|
|
|
case TA_MIDI_CONTROL:
|
|
|
|
midiMap.binds[learning].data2=msg.data[1];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
midiMap.binds[learning].data2=128;
|
|
|
|
break;
|
2022-03-30 20:44:27 +00:00
|
|
|
}
|
2022-03-31 23:39:01 +00:00
|
|
|
}
|
|
|
|
learning=-1;
|
|
|
|
} else {
|
|
|
|
int action=midiMap.at(msg);
|
|
|
|
if (action!=0) {
|
|
|
|
doAction(action);
|
|
|
|
} else switch (msg.type&0xf0) {
|
|
|
|
case TA_MIDI_NOTE_ON:
|
2022-04-01 06:50:01 +00:00
|
|
|
if (midiMap.valueInputStyle==0 || midiMap.valueInputStyle>3 || cursor.xFine==0) {
|
|
|
|
if (midiMap.noteInput && edit && msg.data[1]!=0) {
|
|
|
|
noteInput(
|
|
|
|
msg.data[0]-12,
|
|
|
|
0,
|
|
|
|
midiMap.volInput?((int)(pow((double)msg.data[1]/127.0,midiMap.volExp)*127.0)):-1
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (edit && msg.data[1]!=0) {
|
|
|
|
switch (midiMap.valueInputStyle) {
|
|
|
|
case 1: {
|
|
|
|
int val=msg.data[0]%24;
|
|
|
|
if (val<16) {
|
|
|
|
valueInput(val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
valueInput(msg.data[0]&15);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
int val=altValues[msg.data[0]%24];
|
|
|
|
if (val>=0) {
|
|
|
|
valueInput(val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-03-31 23:39:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TA_MIDI_PROGRAM:
|
|
|
|
if (midiMap.programChange) {
|
|
|
|
curIns=msg.data[0];
|
|
|
|
if (curIns>=(int)e->song.ins.size()) curIns=e->song.ins.size()-1;
|
|
|
|
}
|
|
|
|
break;
|
2022-04-01 06:50:01 +00:00
|
|
|
case TA_MIDI_CONTROL:
|
|
|
|
bool gchanged=false;
|
|
|
|
if (msg.data[0]==midiMap.valueInputControlMSB) {
|
|
|
|
midiMap.valueInputCurMSB=msg.data[1];
|
|
|
|
gchanged=true;
|
|
|
|
}
|
|
|
|
if (msg.data[0]==midiMap.valueInputControlLSB) {
|
|
|
|
midiMap.valueInputCurLSB=msg.data[1];
|
|
|
|
gchanged=true;
|
|
|
|
}
|
|
|
|
if (msg.data[0]==midiMap.valueInputControlSingle) {
|
|
|
|
midiMap.valueInputCurSingle=msg.data[1];
|
|
|
|
gchanged=true;
|
|
|
|
}
|
|
|
|
if (gchanged && cursor.xFine>0) {
|
|
|
|
switch (midiMap.valueInputStyle) {
|
|
|
|
case 4: // dual CC
|
|
|
|
valueInput(((midiMap.valueInputCurMSB>>3)<<4)|(midiMap.valueInputCurLSB>>3),true);
|
|
|
|
break;
|
|
|
|
case 5: // 14-bit
|
|
|
|
valueInput((midiMap.valueInputCurMSB<<1)|(midiMap.valueInputCurLSB>>6),true);
|
|
|
|
break;
|
|
|
|
case 6: // single CC
|
|
|
|
valueInput((midiMap.valueInputCurSingle*255)/127,true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i<18; i++) {
|
|
|
|
bool changed=false;
|
|
|
|
if (midiMap.valueInputSpecificStyle[i]!=0) {
|
|
|
|
if (msg.data[0]==midiMap.valueInputSpecificMSB[i]) {
|
|
|
|
changed=true;
|
|
|
|
midiMap.valueInputCurMSBS[i]=msg.data[1];
|
|
|
|
}
|
|
|
|
if (msg.data[0]==midiMap.valueInputSpecificLSB[i]) {
|
|
|
|
changed=true;
|
|
|
|
midiMap.valueInputCurLSBS[i]=msg.data[1];
|
|
|
|
}
|
|
|
|
if (msg.data[0]==midiMap.valueInputSpecificSingle[i]) {
|
|
|
|
changed=true;
|
|
|
|
midiMap.valueInputCurSingleS[i]=msg.data[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) switch (midiMap.valueInputStyle) {
|
|
|
|
case 1: // dual CC
|
|
|
|
valueInput(((midiMap.valueInputCurMSBS[i]>>3)<<4)|(midiMap.valueInputCurLSBS[i]>>3),true,i+2);
|
|
|
|
break;
|
|
|
|
case 2: // 14-bit
|
|
|
|
valueInput((midiMap.valueInputCurMSBS[i]<<1)|(midiMap.valueInputCurLSBS[i]>>6),true,i+2);
|
|
|
|
break;
|
|
|
|
case 3: // single CC
|
|
|
|
valueInput((midiMap.valueInputCurSingleS[i]*255)/127,true,i+2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2022-03-31 23:39:01 +00:00
|
|
|
}
|
2022-03-30 20:44:27 +00:00
|
|
|
}
|
2022-03-28 23:19:47 +00:00
|
|
|
|
|
|
|
midiLock.lock();
|
|
|
|
midiQueue.pop();
|
|
|
|
midiLock.unlock();
|
|
|
|
}
|
|
|
|
|
2021-12-14 09:45:44 +00:00
|
|
|
ImGui_ImplSDLRenderer_NewFrame();
|
|
|
|
ImGui_ImplSDL2_NewFrame(sdlWin);
|
|
|
|
ImGui::NewFrame();
|
|
|
|
|
2021-12-14 22:45:37 +00:00
|
|
|
curWindow=GUI_WINDOW_NOTHING;
|
|
|
|
|
2021-12-14 09:45:44 +00:00
|
|
|
ImGui::BeginMainMenuBar();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("file")) {
|
|
|
|
if (ImGui::MenuItem("new...")) {
|
2021-12-30 23:52:36 +00:00
|
|
|
if (modified) {
|
2022-04-13 07:09:59 +00:00
|
|
|
showWarning("Unsaved changes! Save changes before creating a new song?",GUI_WARN_NEW);
|
2021-12-30 23:52:36 +00:00
|
|
|
} else {
|
2022-03-01 22:19:52 +00:00
|
|
|
displayNew=true;
|
2021-12-30 23:52:36 +00:00
|
|
|
}
|
2021-12-24 23:23:01 +00:00
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("open...",BIND_FOR(GUI_ACTION_OPEN))) {
|
2021-12-30 23:52:36 +00:00
|
|
|
if (modified) {
|
2022-04-13 07:09:59 +00:00
|
|
|
showWarning("Unsaved changes! Save changes before opening another file?",GUI_WARN_OPEN);
|
2021-12-30 23:52:36 +00:00
|
|
|
} else {
|
|
|
|
openFileDialog(GUI_FILE_OPEN);
|
|
|
|
}
|
2021-12-15 05:37:27 +00:00
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("save",BIND_FOR(GUI_ACTION_SAVE))) {
|
2022-03-21 19:47:10 +00:00
|
|
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
2021-12-30 23:25:55 +00:00
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
|
|
|
} else {
|
2022-02-20 08:18:20 +00:00
|
|
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
2021-12-30 23:25:55 +00:00
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("save as...",BIND_FOR(GUI_ACTION_SAVE_AS))) {
|
2021-12-17 08:33:12 +00:00
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
2021-12-15 19:15:44 +00:00
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("save as .dmf (1.0/legacy)...",BIND_FOR(GUI_ACTION_SAVE_AS))) {
|
2022-02-20 08:18:20 +00:00
|
|
|
openFileDialog(GUI_FILE_SAVE_DMF_LEGACY);
|
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("export audio...")) {
|
2022-01-18 04:34:29 +00:00
|
|
|
if (ImGui::MenuItem("one file")) {
|
|
|
|
openFileDialog(GUI_FILE_EXPORT_AUDIO_ONE);
|
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("multiple files (one per system)")) {
|
|
|
|
openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_SYS);
|
|
|
|
}
|
|
|
|
if (ImGui::MenuItem("multiple files (one per channel)")) {
|
|
|
|
openFileDialog(GUI_FILE_EXPORT_AUDIO_PER_CHANNEL);
|
|
|
|
}
|
|
|
|
if (ImGui::InputInt("Loops",&exportLoops,1,2)) {
|
|
|
|
if (exportLoops<0) exportLoops=0;
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("export VGM...")) {
|
2022-01-26 05:26:15 +00:00
|
|
|
ImGui::Text("settings:");
|
2022-04-02 02:40:32 +00:00
|
|
|
if (ImGui::BeginCombo("format version",fmt::sprintf("%d.%.2x",vgmExportVersion>>8,vgmExportVersion&0xff).c_str())) {
|
|
|
|
for (int i=0; i<6; i++) {
|
|
|
|
if (ImGui::Selectable(fmt::sprintf("%d.%.2x",vgmVersions[i]>>8,vgmVersions[i]&0xff).c_str(),vgmExportVersion==vgmVersions[i])) {
|
|
|
|
vgmExportVersion=vgmVersions[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
2022-01-26 05:26:15 +00:00
|
|
|
ImGui::Checkbox("loop",&vgmExportLoop);
|
2022-04-02 02:40:32 +00:00
|
|
|
ImGui::Text("systems to export:");
|
2022-01-26 05:26:15 +00:00
|
|
|
bool hasOneAtLeast=false;
|
|
|
|
for (int i=0; i<e->song.systemLen; i++) {
|
2022-04-02 02:40:32 +00:00
|
|
|
int minVersion=e->minVGMVersion(e->song.system[i]);
|
|
|
|
ImGui::BeginDisabled(minVersion>vgmExportVersion || minVersion==0);
|
2022-01-28 08:17:35 +00:00
|
|
|
ImGui::Checkbox(fmt::sprintf("%d. %s##_SYSV%d",i+1,getSystemName(e->song.system[i]),i).c_str(),&willExport[i]);
|
2022-01-26 05:26:15 +00:00
|
|
|
ImGui::EndDisabled();
|
2022-04-02 02:40:32 +00:00
|
|
|
if (minVersion>vgmExportVersion) {
|
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
|
|
|
ImGui::SetTooltip("this system is only available in VGM %d.%.2x and higher!",minVersion>>8,minVersion&0xff);
|
|
|
|
}
|
|
|
|
} else if (minVersion==0) {
|
2022-01-26 05:26:15 +00:00
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)) {
|
|
|
|
ImGui::SetTooltip("this system is not supported by the VGM format!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (willExport[i]) hasOneAtLeast=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::Text("select the systems you wish to export,");
|
2022-04-02 02:40:32 +00:00
|
|
|
ImGui::Text("but only up to %d of each type.",(vgmExportVersion>=0x151)?2:1);
|
2022-01-26 05:26:15 +00:00
|
|
|
if (hasOneAtLeast) {
|
|
|
|
if (ImGui::MenuItem("click to export")) {
|
|
|
|
openFileDialog(GUI_FILE_EXPORT_VGM);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ImGui::Text("nothing to export");
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
2022-01-24 02:50:45 +00:00
|
|
|
}
|
2022-01-18 04:34:29 +00:00
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("add system...")) {
|
2022-03-21 22:34:43 +00:00
|
|
|
for (int j=0; availableSystems[j]; j++) {
|
|
|
|
sysAddOption((DivSystem)availableSystems[j]);
|
|
|
|
}
|
2022-01-08 23:18:23 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("configure system...")) {
|
2022-01-28 23:12:56 +00:00
|
|
|
for (int i=0; i<e->song.systemLen; i++) {
|
|
|
|
if (ImGui::TreeNode(fmt::sprintf("%d. %s##_SYSP%d",i+1,getSystemName(e->song.system[i]),i).c_str())) {
|
2022-03-21 22:34:43 +00:00
|
|
|
drawSysConf(i);
|
2022-01-28 23:12:56 +00:00
|
|
|
ImGui::TreePop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("change system...")) {
|
2022-01-09 21:36:47 +00:00
|
|
|
for (int i=0; i<e->song.systemLen; i++) {
|
2022-01-28 08:17:35 +00:00
|
|
|
if (ImGui::BeginMenu(fmt::sprintf("%d. %s##_SYSC%d",i+1,getSystemName(e->song.system[i]),i).c_str())) {
|
2022-03-21 22:34:43 +00:00
|
|
|
for (int j=0; availableSystems[j]; j++) {
|
|
|
|
sysChangeOption(i,(DivSystem)availableSystems[j]);
|
|
|
|
}
|
2022-01-09 21:36:47 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("remove system...")) {
|
2022-01-09 21:36:47 +00:00
|
|
|
for (int i=0; i<e->song.systemLen; i++) {
|
2022-01-28 08:17:35 +00:00
|
|
|
if (ImGui::MenuItem(fmt::sprintf("%d. %s##_SYSR%d",i+1,getSystemName(e->song.system[i]),i).c_str())) {
|
2022-01-09 21:36:47 +00:00
|
|
|
if (!e->removeSystem(i)) {
|
2022-01-16 06:17:30 +00:00
|
|
|
showError("cannot remove system! ("+e->getLastError()+")");
|
2022-01-09 21:36:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-18 03:14:41 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2021-12-16 07:21:43 +00:00
|
|
|
ImGui::Separator();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("restore backup",BIND_FOR(GUI_ACTION_OPEN_BACKUP))) {
|
2022-03-21 19:32:33 +00:00
|
|
|
doAction(GUI_ACTION_OPEN_BACKUP);
|
|
|
|
}
|
|
|
|
ImGui::Separator();
|
2021-12-14 09:45:44 +00:00
|
|
|
if (ImGui::MenuItem("exit")) {
|
2021-12-30 23:52:36 +00:00
|
|
|
if (modified) {
|
2022-04-13 07:09:59 +00:00
|
|
|
showWarning("Unsaved changes! Save before quitting?",GUI_WARN_QUIT);
|
2021-12-30 23:52:36 +00:00
|
|
|
} else {
|
|
|
|
quit=true;
|
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
}
|
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("edit")) {
|
|
|
|
if (ImGui::MenuItem("undo",BIND_FOR(GUI_ACTION_UNDO))) doUndo();
|
|
|
|
if (ImGui::MenuItem("redo",BIND_FOR(GUI_ACTION_REDO))) doRedo();
|
2021-12-16 07:21:43 +00:00
|
|
|
ImGui::Separator();
|
2022-03-09 23:03:15 +00:00
|
|
|
editOptions(true);
|
2022-02-17 08:33:43 +00:00
|
|
|
/*ImGui::Separator();
|
|
|
|
ImGui::MenuItem("clear...");*/
|
2021-12-16 07:21:43 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("settings")) {
|
2022-04-02 20:07:47 +00:00
|
|
|
if (ImGui::MenuItem("lock layout",NULL,lockLayout)) {
|
|
|
|
lockLayout=!lockLayout;
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("visualizer",NULL,fancyPattern)) {
|
2022-03-16 18:31:42 +00:00
|
|
|
fancyPattern=!fancyPattern;
|
2022-03-22 06:34:53 +00:00
|
|
|
e->enableCommandStream(fancyPattern);
|
|
|
|
e->getCommandStream(cmdStream);
|
|
|
|
cmdStream.clear();
|
2022-03-16 18:31:42 +00:00
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("reset layout")) {
|
2022-03-02 04:46:04 +00:00
|
|
|
showWarning("Are you sure you want to reset the workspace layout?",GUI_WARN_RESET_LAYOUT);
|
2022-02-22 07:01:59 +00:00
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::MenuItem("settings...",BIND_FOR(GUI_ACTION_WINDOW_SETTINGS))) {
|
2022-01-16 22:25:43 +00:00
|
|
|
syncSettings();
|
|
|
|
settingsOpen=true;
|
|
|
|
}
|
2021-12-20 03:51:02 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("window")) {
|
2022-02-17 08:33:43 +00:00
|
|
|
if (ImGui::MenuItem("song information",BIND_FOR(GUI_ACTION_WINDOW_SONG_INFO),songInfoOpen)) songInfoOpen=!songInfoOpen;
|
|
|
|
if (ImGui::MenuItem("instruments",BIND_FOR(GUI_ACTION_WINDOW_INS_LIST),insListOpen)) insListOpen=!insListOpen;
|
|
|
|
if (ImGui::MenuItem("wavetables",BIND_FOR(GUI_ACTION_WINDOW_WAVE_LIST),waveListOpen)) waveListOpen=!waveListOpen;
|
|
|
|
if (ImGui::MenuItem("samples",BIND_FOR(GUI_ACTION_WINDOW_SAMPLE_LIST),sampleListOpen)) sampleListOpen=!sampleListOpen;
|
|
|
|
if (ImGui::MenuItem("orders",BIND_FOR(GUI_ACTION_WINDOW_ORDERS),ordersOpen)) ordersOpen=!ordersOpen;
|
|
|
|
if (ImGui::MenuItem("pattern",BIND_FOR(GUI_ACTION_WINDOW_PATTERN),patternOpen)) patternOpen=!patternOpen;
|
|
|
|
if (ImGui::MenuItem("mixer",BIND_FOR(GUI_ACTION_WINDOW_MIXER),mixerOpen)) mixerOpen=!mixerOpen;
|
|
|
|
if (ImGui::MenuItem("channels",BIND_FOR(GUI_ACTION_WINDOW_CHANNELS),channelsOpen)) channelsOpen=!channelsOpen;
|
|
|
|
if (ImGui::MenuItem("compatibility flags",BIND_FOR(GUI_ACTION_WINDOW_COMPAT_FLAGS),compatFlagsOpen)) compatFlagsOpen=!compatFlagsOpen;
|
|
|
|
if (ImGui::MenuItem("song comments",BIND_FOR(GUI_ACTION_WINDOW_NOTES),notesOpen)) notesOpen=!notesOpen;
|
2022-02-05 08:10:19 +00:00
|
|
|
ImGui::Separator();
|
2022-02-17 08:33:43 +00:00
|
|
|
if (ImGui::MenuItem("instrument editor",BIND_FOR(GUI_ACTION_WINDOW_INS_EDIT),insEditOpen)) insEditOpen=!insEditOpen;
|
|
|
|
if (ImGui::MenuItem("wavetable editor",BIND_FOR(GUI_ACTION_WINDOW_WAVE_EDIT),waveEditOpen)) waveEditOpen=!waveEditOpen;
|
|
|
|
if (ImGui::MenuItem("sample editor",BIND_FOR(GUI_ACTION_WINDOW_SAMPLE_EDIT),sampleEditOpen)) sampleEditOpen=!sampleEditOpen;
|
2022-02-05 08:10:19 +00:00
|
|
|
ImGui::Separator();
|
2022-02-17 08:33:43 +00:00
|
|
|
if (ImGui::MenuItem("play/edit controls",BIND_FOR(GUI_ACTION_WINDOW_EDIT_CONTROLS),editControlsOpen)) editControlsOpen=!editControlsOpen;
|
|
|
|
if (ImGui::MenuItem("piano/input pad",BIND_FOR(GUI_ACTION_WINDOW_PIANO),pianoOpen)) pianoOpen=!pianoOpen;
|
|
|
|
if (ImGui::MenuItem("oscilloscope",BIND_FOR(GUI_ACTION_WINDOW_OSCILLOSCOPE),oscOpen)) oscOpen=!oscOpen;
|
|
|
|
if (ImGui::MenuItem("volume meter",BIND_FOR(GUI_ACTION_WINDOW_VOL_METER),volMeterOpen)) volMeterOpen=!volMeterOpen;
|
2022-02-22 03:31:27 +00:00
|
|
|
if (ImGui::MenuItem("register view",BIND_FOR(GUI_ACTION_WINDOW_REGISTER_VIEW),regViewOpen)) regViewOpen=!regViewOpen;
|
2022-04-11 03:12:02 +00:00
|
|
|
if (ImGui::MenuItem("log viewer",BIND_FOR(GUI_ACTION_WINDOW_LOG),logOpen)) logOpen=!logOpen;
|
2022-02-17 08:33:43 +00:00
|
|
|
if (ImGui::MenuItem("statistics",BIND_FOR(GUI_ACTION_WINDOW_STATS),statsOpen)) statsOpen=!statsOpen;
|
2022-02-05 08:10:19 +00:00
|
|
|
|
2021-12-14 09:45:44 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2022-04-01 10:20:00 +00:00
|
|
|
if (ImGui::BeginMenu("help")) {
|
|
|
|
if (ImGui::MenuItem("debug menu",BIND_FOR(GUI_ACTION_WINDOW_DEBUG))) debugOpen=!debugOpen;
|
|
|
|
if (ImGui::MenuItem("panic",BIND_FOR(GUI_ACTION_PANIC))) e->syncReset();
|
|
|
|
if (ImGui::MenuItem("about...",BIND_FOR(GUI_ACTION_WINDOW_ABOUT))) {
|
2021-12-19 04:03:50 +00:00
|
|
|
aboutOpen=true;
|
|
|
|
aboutScroll=0;
|
|
|
|
}
|
2021-12-16 07:21:43 +00:00
|
|
|
ImGui::EndMenu();
|
|
|
|
}
|
2021-12-30 23:25:55 +00:00
|
|
|
ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_PLAYBACK_STAT]);
|
2021-12-21 07:30:09 +00:00
|
|
|
if (e->isPlaying()) {
|
|
|
|
int totalTicks=e->getTotalTicks();
|
2022-01-12 07:45:26 +00:00
|
|
|
int totalSeconds=e->getTotalSeconds();
|
2022-04-01 10:20:00 +00:00
|
|
|
ImGui::Text("| Speed %d:%d @ %gHz (%g BPM) | Order %d/%d | Row %d/%d | %d:%.2d:%.2d.%.2d",e->getSpeed1(),e->getSpeed2(),e->getCurHz(),calcBPM(e->getSpeed1(),e->getSpeed2(),e->getCurHz()),e->getOrder(),e->song.ordersLen,e->getRow(),e->song.patLen,totalSeconds/3600,(totalSeconds/60)%60,totalSeconds%60,totalTicks/10000);
|
2021-12-30 23:25:55 +00:00
|
|
|
} else {
|
2022-02-15 06:46:03 +00:00
|
|
|
bool hasInfo=false;
|
|
|
|
String info;
|
|
|
|
if (cursor.xCoarse>=0 && cursor.xCoarse<e->getTotalChannelCount()) {
|
2022-04-14 07:58:29 +00:00
|
|
|
DivPattern* p=e->song.pat[cursor.xCoarse].getPattern(e->song.orders.ord[cursor.xCoarse][curOrder],false);
|
2022-02-15 06:46:03 +00:00
|
|
|
if (cursor.xFine>=0) switch (cursor.xFine) {
|
|
|
|
case 0: // note
|
|
|
|
if (p->data[cursor.y][0]>0) {
|
|
|
|
if (p->data[cursor.y][0]==100) {
|
|
|
|
info=fmt::sprintf("Note off (cut)");
|
|
|
|
} else if (p->data[cursor.y][0]==101) {
|
|
|
|
info=fmt::sprintf("Note off (release)");
|
|
|
|
} else if (p->data[cursor.y][0]==102) {
|
|
|
|
info=fmt::sprintf("Macro release only");
|
|
|
|
} else {
|
|
|
|
info=fmt::sprintf("Note on: %s",noteName(p->data[cursor.y][0],p->data[cursor.y][1]));
|
|
|
|
}
|
|
|
|
hasInfo=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: // instrument
|
|
|
|
if (p->data[cursor.y][2]>-1) {
|
|
|
|
if (p->data[cursor.y][2]>=(int)e->song.ins.size()) {
|
|
|
|
info=fmt::sprintf("Ins %d: <invalid>",p->data[cursor.y][2]);
|
|
|
|
} else {
|
|
|
|
DivInstrument* ins=e->getIns(p->data[cursor.y][2]);
|
|
|
|
info=fmt::sprintf("Ins %d: %s",p->data[cursor.y][2],ins->name);
|
|
|
|
}
|
|
|
|
hasInfo=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: // volume
|
|
|
|
if (p->data[cursor.y][3]>-1) {
|
|
|
|
int maxVol=e->getMaxVolumeChan(cursor.xCoarse);
|
|
|
|
if (maxVol<1 || p->data[cursor.y][3]>maxVol) {
|
|
|
|
info=fmt::sprintf("Set volume: %d (%.2X, INVALID!)",p->data[cursor.y][3],p->data[cursor.y][3]);
|
|
|
|
} else {
|
|
|
|
info=fmt::sprintf("Set volume: %d (%.2X, %d%%)",p->data[cursor.y][3],p->data[cursor.y][3],(p->data[cursor.y][3]*100)/maxVol);
|
|
|
|
}
|
|
|
|
hasInfo=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: // effect
|
|
|
|
int actualCursor=((cursor.xFine+1)&(~1));
|
|
|
|
if (p->data[cursor.y][actualCursor]>-1) {
|
|
|
|
info=e->getEffectDesc(p->data[cursor.y][actualCursor],cursor.xCoarse);
|
|
|
|
hasInfo=true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasInfo && (settings.statusDisplay==0 || settings.statusDisplay==2)) {
|
|
|
|
ImGui::Text("| %s",info.c_str());
|
|
|
|
} else if (settings.statusDisplay==1 || settings.statusDisplay==2) {
|
|
|
|
if (curFileName!="") ImGui::Text("| %s",curFileName.c_str());
|
|
|
|
}
|
2021-12-30 23:25:55 +00:00
|
|
|
}
|
|
|
|
ImGui::PopStyleColor();
|
|
|
|
if (modified) {
|
|
|
|
ImGui::Text("| modified");
|
2021-12-21 07:30:09 +00:00
|
|
|
}
|
2021-12-14 09:45:44 +00:00
|
|
|
ImGui::EndMainMenuBar();
|
|
|
|
|
2022-04-02 20:07:47 +00:00
|
|
|
ImGui::DockSpaceOverViewport(NULL,lockLayout?(ImGuiDockNodeFlags_NoResize|ImGuiDockNodeFlags_NoCloseButton|ImGuiDockNodeFlags_NoDocking|ImGuiDockNodeFlags_NoDockingSplitMe|ImGuiDockNodeFlags_NoDockingSplitOther):0);
|
2021-12-14 09:45:44 +00:00
|
|
|
|
2022-03-05 07:13:15 +00:00
|
|
|
drawPattern();
|
2021-12-15 22:32:08 +00:00
|
|
|
drawEditControls();
|
2021-12-14 09:45:44 +00:00
|
|
|
drawSongInfo();
|
|
|
|
drawOrders();
|
2021-12-16 08:09:18 +00:00
|
|
|
drawSampleList();
|
|
|
|
drawSampleEdit();
|
2022-03-05 07:28:03 +00:00
|
|
|
drawWaveList();
|
|
|
|
drawWaveEdit();
|
|
|
|
drawInsList();
|
|
|
|
drawInsEdit();
|
2022-01-13 06:03:57 +00:00
|
|
|
drawMixer();
|
2022-04-09 07:42:58 +00:00
|
|
|
|
|
|
|
readOsc();
|
|
|
|
|
2022-01-27 22:49:00 +00:00
|
|
|
drawOsc();
|
2022-01-29 23:56:08 +00:00
|
|
|
drawVolMeter();
|
2021-12-20 03:51:02 +00:00
|
|
|
drawSettings();
|
2022-01-27 05:29:16 +00:00
|
|
|
drawDebug();
|
2022-02-03 05:34:48 +00:00
|
|
|
drawStats();
|
|
|
|
drawCompatFlags();
|
|
|
|
drawPiano();
|
|
|
|
drawNotes();
|
2022-02-05 06:48:35 +00:00
|
|
|
drawChannels();
|
2022-02-22 03:31:27 +00:00
|
|
|
drawRegView();
|
2022-04-11 03:12:02 +00:00
|
|
|
drawLog();
|
2021-12-12 09:21:09 +00:00
|
|
|
|
2022-03-21 05:52:38 +00:00
|
|
|
if (inspectorOpen) ImGui::ShowMetricsWindow(&inspectorOpen);
|
2022-03-18 04:28:01 +00:00
|
|
|
|
2022-03-11 03:10:52 +00:00
|
|
|
if (firstFrame) {
|
|
|
|
firstFrame=false;
|
|
|
|
if (patternOpen) nextWindow=GUI_WINDOW_PATTERN;
|
2022-03-22 20:37:36 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
SDL_RaiseWindow(sdlWin);
|
|
|
|
#endif
|
2022-03-11 03:10:52 +00:00
|
|
|
}
|
|
|
|
|
2022-03-13 23:32:35 +00:00
|
|
|
if (fileDialog->render(ImVec2(600.0f*dpiScale,400.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale))) {
|
2022-04-13 07:09:59 +00:00
|
|
|
bool openOpen=false;
|
2022-02-01 07:52:36 +00:00
|
|
|
//ImGui::GetIO().ConfigFlags&=~ImGuiConfigFlags_NavEnableKeyboard;
|
2022-03-02 05:02:52 +00:00
|
|
|
switch (curFileDialog) {
|
|
|
|
case GUI_FILE_OPEN:
|
|
|
|
case GUI_FILE_SAVE:
|
|
|
|
case GUI_FILE_SAVE_DMF_LEGACY:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirSong=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_INS_OPEN:
|
|
|
|
case GUI_FILE_INS_SAVE:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirIns=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_WAVE_OPEN:
|
|
|
|
case GUI_FILE_WAVE_SAVE:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirWave=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_SAMPLE_OPEN:
|
|
|
|
case GUI_FILE_SAMPLE_SAVE:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirSample=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_ONE:
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_PER_SYS:
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_PER_CHANNEL:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirAudioExport=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_VGM:
|
|
|
|
case GUI_FILE_EXPORT_ROM:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirVGMExport=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_LOAD_MAIN_FONT:
|
|
|
|
case GUI_FILE_LOAD_PAT_FONT:
|
2022-03-13 23:32:35 +00:00
|
|
|
workingDirFont=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
2022-03-02 05:02:52 +00:00
|
|
|
break;
|
2022-04-06 18:53:39 +00:00
|
|
|
case GUI_FILE_IMPORT_COLORS:
|
|
|
|
case GUI_FILE_EXPORT_COLORS:
|
|
|
|
workingDirColors=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
|
|
|
break;
|
|
|
|
case GUI_FILE_IMPORT_KEYBINDS:
|
|
|
|
case GUI_FILE_EXPORT_KEYBINDS:
|
|
|
|
workingDirKeybinds=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
|
|
|
break;
|
|
|
|
case GUI_FILE_IMPORT_LAYOUT:
|
|
|
|
case GUI_FILE_EXPORT_LAYOUT:
|
|
|
|
workingDirLayout=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
|
|
|
break;
|
2022-03-02 05:02:52 +00:00
|
|
|
}
|
2022-03-13 23:32:35 +00:00
|
|
|
if (fileDialog->accepted()) {
|
|
|
|
fileName=fileDialog->getFileName();
|
2021-12-15 05:37:27 +00:00
|
|
|
if (fileName!="") {
|
2021-12-17 08:33:12 +00:00
|
|
|
if (curFileDialog==GUI_FILE_SAVE) {
|
2022-03-14 04:10:43 +00:00
|
|
|
// we can't tell whether the user chose .dmf or .fur in the system file picker
|
|
|
|
const char* fallbackExt=(settings.sysFileDialog || ImGuiFileDialog::Instance()->GetCurrentFilter()=="Furnace song")?".fur":".dmf";
|
|
|
|
checkExtensionDual(".fur",".dmf",fallbackExt);
|
2021-12-15 05:37:27 +00:00
|
|
|
}
|
2022-02-25 07:40:30 +00:00
|
|
|
if (curFileDialog==GUI_FILE_SAVE_DMF_LEGACY) {
|
|
|
|
checkExtension(".dmf");
|
|
|
|
}
|
2022-01-19 10:10:06 +00:00
|
|
|
if (curFileDialog==GUI_FILE_SAMPLE_SAVE ||
|
|
|
|
curFileDialog==GUI_FILE_EXPORT_AUDIO_ONE ||
|
|
|
|
curFileDialog==GUI_FILE_EXPORT_AUDIO_PER_SYS ||
|
|
|
|
curFileDialog==GUI_FILE_EXPORT_AUDIO_PER_CHANNEL) {
|
|
|
|
checkExtension(".wav");
|
2021-12-17 08:33:12 +00:00
|
|
|
}
|
2022-01-21 23:17:05 +00:00
|
|
|
if (curFileDialog==GUI_FILE_INS_SAVE) {
|
|
|
|
checkExtension(".fui");
|
|
|
|
}
|
|
|
|
if (curFileDialog==GUI_FILE_WAVE_SAVE) {
|
|
|
|
checkExtension(".fuw");
|
|
|
|
}
|
2022-01-24 06:10:38 +00:00
|
|
|
if (curFileDialog==GUI_FILE_EXPORT_VGM) {
|
|
|
|
checkExtension(".vgm");
|
|
|
|
}
|
2022-04-06 19:45:58 +00:00
|
|
|
if (curFileDialog==GUI_FILE_EXPORT_COLORS) {
|
|
|
|
checkExtension(".cfgc");
|
|
|
|
}
|
|
|
|
if (curFileDialog==GUI_FILE_EXPORT_KEYBINDS) {
|
|
|
|
checkExtension(".cfgk");
|
|
|
|
}
|
|
|
|
if (curFileDialog==GUI_FILE_EXPORT_LAYOUT) {
|
|
|
|
checkExtension(".ini");
|
|
|
|
}
|
2021-12-15 05:37:27 +00:00
|
|
|
String copyOfName=fileName;
|
2021-12-17 08:33:12 +00:00
|
|
|
switch (curFileDialog) {
|
|
|
|
case GUI_FILE_OPEN:
|
2021-12-21 04:20:30 +00:00
|
|
|
if (load(copyOfName)>0) {
|
|
|
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
|
|
|
}
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
2022-03-14 04:10:43 +00:00
|
|
|
case GUI_FILE_SAVE: {
|
2022-04-11 03:12:02 +00:00
|
|
|
logD("saving: %s",copyOfName.c_str());
|
2022-03-14 04:10:43 +00:00
|
|
|
String lowerCase=fileName;
|
|
|
|
for (char& i: lowerCase) {
|
|
|
|
if (i>='A' && i<='Z') i+='a'-'A';
|
|
|
|
}
|
2022-04-13 07:09:59 +00:00
|
|
|
bool saveWasSuccessful=true;
|
2022-03-14 04:10:43 +00:00
|
|
|
if ((lowerCase.size()<4 || lowerCase.rfind(".dmf")!=lowerCase.size()-4)) {
|
2022-02-20 08:18:20 +00:00
|
|
|
if (save(copyOfName,0)>0) {
|
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
2022-04-13 07:09:59 +00:00
|
|
|
saveWasSuccessful=false;
|
2022-02-20 08:18:20 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-04-08 01:13:11 +00:00
|
|
|
if (save(copyOfName,26)>0) {
|
2022-02-20 08:18:20 +00:00
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
2022-04-13 07:09:59 +00:00
|
|
|
saveWasSuccessful=false;
|
2022-02-20 08:18:20 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-13 07:09:59 +00:00
|
|
|
if (saveWasSuccessful && postWarnAction!=GUI_WARN_GENERIC) {
|
|
|
|
switch (postWarnAction) {
|
|
|
|
case GUI_WARN_QUIT:
|
|
|
|
quit=true;
|
|
|
|
break;
|
|
|
|
case GUI_WARN_NEW:
|
|
|
|
displayNew=true;
|
|
|
|
break;
|
|
|
|
case GUI_WARN_OPEN:
|
|
|
|
openOpen=true;
|
|
|
|
break;
|
|
|
|
case GUI_WARN_OPEN_DROP:
|
|
|
|
if (load(nextFile)>0) {
|
|
|
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
|
|
|
}
|
|
|
|
nextFile="";
|
|
|
|
break;
|
|
|
|
case GUI_WARN_OPEN_BACKUP:
|
|
|
|
if (load(backupPath)>0) {
|
|
|
|
showError("No backup available! (or unable to open it)");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
postWarnAction=GUI_WARN_GENERIC;
|
|
|
|
} else if (postWarnAction==GUI_WARN_OPEN_DROP) {
|
|
|
|
nextFile="";
|
|
|
|
}
|
2022-02-20 08:18:20 +00:00
|
|
|
break;
|
2022-03-14 04:10:43 +00:00
|
|
|
}
|
2022-02-20 08:18:20 +00:00
|
|
|
case GUI_FILE_SAVE_DMF_LEGACY:
|
2022-04-11 03:12:02 +00:00
|
|
|
logD("saving: %s",copyOfName.c_str());
|
2022-02-20 08:18:20 +00:00
|
|
|
if (save(copyOfName,24)>0) {
|
2021-12-21 04:20:30 +00:00
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
}
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
2022-01-19 08:28:29 +00:00
|
|
|
case GUI_FILE_INS_SAVE:
|
|
|
|
if (curIns>=0 && curIns<(int)e->song.ins.size()) {
|
|
|
|
e->song.ins[curIns]->save(copyOfName.c_str());
|
|
|
|
}
|
|
|
|
break;
|
2022-01-19 10:10:06 +00:00
|
|
|
case GUI_FILE_WAVE_SAVE:
|
|
|
|
if (curWave>=0 && curWave<(int)e->song.wave.size()) {
|
|
|
|
e->song.wave[curWave]->save(copyOfName.c_str());
|
|
|
|
}
|
|
|
|
break;
|
2021-12-17 08:33:12 +00:00
|
|
|
case GUI_FILE_SAMPLE_OPEN:
|
2022-03-23 21:39:08 +00:00
|
|
|
if (e->addSampleFromFile(copyOfName.c_str())==-1) {
|
|
|
|
showError(e->getLastError());
|
|
|
|
} else {
|
|
|
|
MARK_MODIFIED;
|
|
|
|
}
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
|
|
|
case GUI_FILE_SAMPLE_SAVE:
|
2021-12-18 06:03:59 +00:00
|
|
|
if (curSample>=0 && curSample<(int)e->song.sample.size()) {
|
|
|
|
e->song.sample[curSample]->save(copyOfName.c_str());
|
|
|
|
}
|
2021-12-17 08:33:12 +00:00
|
|
|
break;
|
2022-01-18 04:34:29 +00:00
|
|
|
case GUI_FILE_EXPORT_AUDIO_ONE:
|
|
|
|
exportAudio(copyOfName,DIV_EXPORT_MODE_ONE);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_PER_SYS:
|
|
|
|
exportAudio(copyOfName,DIV_EXPORT_MODE_MANY_SYS);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_AUDIO_PER_CHANNEL:
|
|
|
|
exportAudio(copyOfName,DIV_EXPORT_MODE_MANY_CHAN);
|
|
|
|
break;
|
2022-04-03 06:56:49 +00:00
|
|
|
case GUI_FILE_INS_OPEN: {
|
|
|
|
std::vector<DivInstrument*> instruments=e->instrumentFromFile(copyOfName.c_str());
|
|
|
|
if (!instruments.empty()) {
|
2022-01-29 09:25:28 +00:00
|
|
|
if (!e->getWarnings().empty()) {
|
|
|
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
|
|
|
}
|
2022-04-03 06:56:49 +00:00
|
|
|
for (DivInstrument* i: instruments) {
|
|
|
|
e->addInstrumentPtr(i);
|
|
|
|
}
|
2022-01-29 09:25:28 +00:00
|
|
|
} else {
|
|
|
|
showError("cannot load instrument! ("+e->getLastError()+")");
|
2022-01-29 06:22:32 +00:00
|
|
|
}
|
2022-01-21 22:59:48 +00:00
|
|
|
break;
|
2022-04-03 06:56:49 +00:00
|
|
|
}
|
2022-01-19 08:15:20 +00:00
|
|
|
case GUI_FILE_WAVE_OPEN:
|
2022-01-21 22:59:48 +00:00
|
|
|
e->addWaveFromFile(copyOfName.c_str());
|
2022-03-21 21:17:51 +00:00
|
|
|
MARK_MODIFIED;
|
2022-01-21 22:59:48 +00:00
|
|
|
break;
|
2022-01-24 06:10:38 +00:00
|
|
|
case GUI_FILE_EXPORT_VGM: {
|
2022-04-02 02:40:32 +00:00
|
|
|
SafeWriter* w=e->saveVGM(willExport,vgmExportLoop,vgmExportVersion);
|
2022-01-24 06:10:38 +00:00
|
|
|
if (w!=NULL) {
|
2022-04-06 07:46:09 +00:00
|
|
|
FILE* f=ps_fopen(copyOfName.c_str(),"wb");
|
2022-01-24 06:10:38 +00:00
|
|
|
if (f!=NULL) {
|
|
|
|
fwrite(w->getFinalBuf(),1,w->size(),f);
|
|
|
|
fclose(f);
|
|
|
|
} else {
|
|
|
|
showError("could not open file!");
|
|
|
|
}
|
|
|
|
w->finish();
|
|
|
|
delete w;
|
2022-01-30 22:18:10 +00:00
|
|
|
if (!e->getWarnings().empty()) {
|
|
|
|
showWarning(e->getWarnings(),GUI_WARN_GENERIC);
|
|
|
|
}
|
2022-01-24 06:10:38 +00:00
|
|
|
} else {
|
2022-04-02 02:40:32 +00:00
|
|
|
showError(fmt::sprintf("could not write VGM! (%s)",e->getLastError()));
|
2022-01-24 06:10:38 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2022-01-18 04:34:29 +00:00
|
|
|
case GUI_FILE_EXPORT_ROM:
|
|
|
|
showError("Coming soon!");
|
|
|
|
break;
|
2022-02-14 23:18:30 +00:00
|
|
|
case GUI_FILE_LOAD_MAIN_FONT:
|
|
|
|
settings.mainFontPath=copyOfName;
|
|
|
|
break;
|
|
|
|
case GUI_FILE_LOAD_PAT_FONT:
|
|
|
|
settings.patFontPath=copyOfName;
|
|
|
|
break;
|
2022-04-06 18:53:39 +00:00
|
|
|
case GUI_FILE_IMPORT_COLORS:
|
|
|
|
importColors(copyOfName);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_IMPORT_KEYBINDS:
|
|
|
|
importKeybinds(copyOfName);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_IMPORT_LAYOUT:
|
|
|
|
importLayout(copyOfName);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_COLORS:
|
|
|
|
exportColors(copyOfName);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_KEYBINDS:
|
|
|
|
exportKeybinds(copyOfName);
|
|
|
|
break;
|
|
|
|
case GUI_FILE_EXPORT_LAYOUT:
|
|
|
|
exportLayout(copyOfName);
|
|
|
|
break;
|
2021-12-15 05:37:27 +00:00
|
|
|
}
|
2021-12-17 08:33:12 +00:00
|
|
|
curFileDialog=GUI_FILE_OPEN;
|
2021-12-15 05:37:27 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-13 23:32:35 +00:00
|
|
|
fileDialog->close();
|
2022-04-13 07:09:59 +00:00
|
|
|
postWarnAction=GUI_WARN_GENERIC;
|
|
|
|
|
|
|
|
if (openOpen) {
|
|
|
|
openFileDialog(GUI_FILE_OPEN);
|
|
|
|
}
|
2021-12-15 05:37:27 +00:00
|
|
|
}
|
|
|
|
|
2021-12-30 23:52:36 +00:00
|
|
|
if (warnQuit) {
|
|
|
|
warnQuit=false;
|
|
|
|
ImGui::OpenPopup("Warning");
|
|
|
|
}
|
|
|
|
|
2022-01-09 21:36:47 +00:00
|
|
|
if (displayError) {
|
|
|
|
displayError=false;
|
|
|
|
ImGui::OpenPopup("Error");
|
|
|
|
}
|
|
|
|
|
2022-01-18 04:34:29 +00:00
|
|
|
if (displayExporting) {
|
|
|
|
displayExporting=false;
|
|
|
|
ImGui::OpenPopup("Rendering...");
|
|
|
|
}
|
|
|
|
|
2022-03-01 22:19:52 +00:00
|
|
|
if (displayNew) {
|
|
|
|
displayNew=false;
|
|
|
|
ImGui::OpenPopup("New Song");
|
|
|
|
}
|
|
|
|
|
2022-02-12 07:14:25 +00:00
|
|
|
if (nextWindow==GUI_WINDOW_ABOUT) {
|
|
|
|
aboutOpen=true;
|
|
|
|
nextWindow=GUI_WINDOW_NOTHING;
|
|
|
|
}
|
2021-12-19 04:03:50 +00:00
|
|
|
if (aboutOpen) drawAbout();
|
|
|
|
|
2022-01-18 04:34:29 +00:00
|
|
|
if (ImGui::BeginPopupModal("Rendering...",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
2022-04-11 03:12:02 +00:00
|
|
|
ImGui::Text("Please wait...");
|
2022-01-18 04:34:29 +00:00
|
|
|
if (ImGui::Button("Abort")) {
|
|
|
|
if (e->haltAudioFile()) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!e->isExporting()) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
2022-03-01 22:19:52 +00:00
|
|
|
ImGui::SetNextWindowSizeConstraints(ImVec2(400.0f*dpiScale,200.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
|
2022-03-02 07:22:51 +00:00
|
|
|
if (ImGui::BeginPopupModal("New Song",NULL,ImGuiWindowFlags_NoMove)) {
|
2022-03-01 22:19:52 +00:00
|
|
|
ImGui::SetWindowPos(ImVec2(((scrW*dpiScale)-ImGui::GetWindowSize().x)*0.5,((scrH*dpiScale)-ImGui::GetWindowSize().y)*0.5));
|
|
|
|
drawNewSong();
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
2021-12-21 04:20:30 +00:00
|
|
|
if (ImGui::BeginPopupModal("Error",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
|
|
ImGui::Text("%s",errorString.c_str());
|
|
|
|
if (ImGui::Button("OK")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
2021-12-30 23:52:36 +00:00
|
|
|
if (ImGui::BeginPopupModal("Warning",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
|
|
|
ImGui::Text("%s",warnString.c_str());
|
2022-04-13 07:09:59 +00:00
|
|
|
switch (warnAction) {
|
|
|
|
case GUI_WARN_QUIT:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
|
|
|
postWarnAction=GUI_WARN_QUIT;
|
|
|
|
} else {
|
|
|
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
} else {
|
|
|
|
quit=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-01 10:20:00 +00:00
|
|
|
quit=true;
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_NEW:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
|
|
|
postWarnAction=GUI_WARN_NEW;
|
|
|
|
} else {
|
|
|
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
} else {
|
|
|
|
displayNew=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-01 10:20:00 +00:00
|
|
|
displayNew=true;
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_OPEN:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
|
|
|
postWarnAction=GUI_WARN_OPEN;
|
|
|
|
} else {
|
|
|
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
} else {
|
|
|
|
openFileDialog(GUI_FILE_OPEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-01 10:20:00 +00:00
|
|
|
openFileDialog(GUI_FILE_OPEN);
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_OPEN_BACKUP:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
|
|
|
postWarnAction=GUI_WARN_OPEN_BACKUP;
|
|
|
|
} else {
|
|
|
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
} else {
|
|
|
|
if (load(backupPath)>0) {
|
|
|
|
showError("No backup available! (or unable to open it)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (load(backupPath)>0) {
|
|
|
|
showError("No backup available! (or unable to open it)");
|
|
|
|
}
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_OPEN_DROP:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
if (curFileName=="" || curFileName==backupPath || e->song.version>=0xff00) {
|
|
|
|
openFileDialog(GUI_FILE_SAVE);
|
|
|
|
postWarnAction=GUI_WARN_OPEN_DROP;
|
|
|
|
} else {
|
|
|
|
if (save(curFileName,e->song.isDMF?e->song.version:0)>0) {
|
|
|
|
showError(fmt::sprintf("Error while saving file! (%s)",lastError));
|
|
|
|
nextFile="";
|
|
|
|
} else {
|
|
|
|
if (load(nextFile)>0) {
|
|
|
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
|
|
|
}
|
|
|
|
nextFile="";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-01 10:20:00 +00:00
|
|
|
if (load(nextFile)>0) {
|
|
|
|
showError(fmt::sprintf("Error while loading file! (%s)",lastError));
|
|
|
|
}
|
|
|
|
nextFile="";
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
nextFile="";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_RESET_LAYOUT:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-01 10:20:00 +00:00
|
|
|
ImGui::LoadIniSettingsFromMemory(defaultLayout);
|
|
|
|
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_RESET_KEYBINDS:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-06 18:53:39 +00:00
|
|
|
resetKeybinds();
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_RESET_COLORS:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
2022-04-06 18:53:39 +00:00
|
|
|
resetColors();
|
2022-04-11 07:53:21 +00:00
|
|
|
applyUISettings(false);
|
2022-04-13 07:09:59 +00:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_CLOSE_SETTINGS:
|
|
|
|
if (ImGui::Button("Yes")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
settingsOpen=false;
|
|
|
|
willCommit=true;
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("No")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
settingsOpen=false;
|
|
|
|
syncSettings();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
if (ImGui::Button("Cancel")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GUI_WARN_GENERIC:
|
|
|
|
if (ImGui::Button("OK")) {
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
}
|
|
|
|
break;
|
2021-12-30 23:52:36 +00:00
|
|
|
}
|
|
|
|
ImGui::EndPopup();
|
|
|
|
}
|
|
|
|
|
2022-03-21 19:11:28 +00:00
|
|
|
// backup trigger
|
|
|
|
if (modified) {
|
|
|
|
if (backupTimer>0) {
|
|
|
|
backupTimer-=ImGui::GetIO().DeltaTime;
|
|
|
|
if (backupTimer<=0) {
|
|
|
|
backupTask=std::async(std::launch::async,[this]() -> bool {
|
|
|
|
if (backupPath==curFileName) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logD("backup file open. not saving backup.");
|
2022-03-21 19:11:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
2022-04-11 03:12:02 +00:00
|
|
|
logD("saving backup...");
|
2022-03-21 19:11:28 +00:00
|
|
|
SafeWriter* w=e->saveFur(true);
|
|
|
|
|
|
|
|
if (w!=NULL) {
|
|
|
|
FILE* outFile=ps_fopen(backupPath.c_str(),"wb");
|
|
|
|
if (outFile!=NULL) {
|
|
|
|
if (fwrite(w->getFinalBuf(),1,w->size(),outFile)!=w->size()) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logW("did not write backup entirely: %s!",strerror(errno));
|
2022-03-21 19:11:28 +00:00
|
|
|
w->finish();
|
|
|
|
}
|
2022-03-22 02:47:27 +00:00
|
|
|
fclose(outFile);
|
2022-03-21 19:11:28 +00:00
|
|
|
} else {
|
2022-04-11 03:12:02 +00:00
|
|
|
logW("could not save backup: %s!",strerror(errno));
|
2022-03-21 19:11:28 +00:00
|
|
|
w->finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
backupTimer=30.0;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-13 22:09:46 +00:00
|
|
|
SDL_SetRenderDrawColor(sdlRend,uiColors[GUI_COLOR_BACKGROUND].x*255,
|
|
|
|
uiColors[GUI_COLOR_BACKGROUND].y*255,
|
|
|
|
uiColors[GUI_COLOR_BACKGROUND].z*255,
|
|
|
|
uiColors[GUI_COLOR_BACKGROUND].w*255);
|
2021-12-11 08:11:40 +00:00
|
|
|
SDL_RenderClear(sdlRend);
|
|
|
|
ImGui::Render();
|
|
|
|
ImGui_ImplSDLRenderer_RenderDrawData(ImGui::GetDrawData());
|
|
|
|
SDL_RenderPresent(sdlRend);
|
2021-12-20 03:51:02 +00:00
|
|
|
|
2022-01-20 07:28:55 +00:00
|
|
|
if (--soloTimeout<0) soloTimeout=0;
|
|
|
|
|
2022-04-02 05:11:44 +00:00
|
|
|
wheelX=0;
|
|
|
|
wheelY=0;
|
|
|
|
|
2021-12-20 03:51:02 +00:00
|
|
|
if (willCommit) {
|
|
|
|
commitSettings();
|
|
|
|
willCommit=false;
|
|
|
|
}
|
2022-03-02 05:09:28 +00:00
|
|
|
|
|
|
|
if (SDL_GetWindowFlags(sdlWin)&SDL_WINDOW_MINIMIZED) {
|
|
|
|
SDL_Delay(100);
|
|
|
|
}
|
2021-12-11 08:11:40 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-31 03:34:42 +00:00
|
|
|
bool FurnaceGUI::init() {
|
2022-02-08 07:04:23 +00:00
|
|
|
#ifndef __APPLE__
|
2021-12-31 03:34:42 +00:00
|
|
|
float dpiScaleF;
|
2022-02-08 07:04:23 +00:00
|
|
|
#endif
|
2021-12-31 03:34:42 +00:00
|
|
|
|
2022-03-02 05:02:52 +00:00
|
|
|
String homeDir=getHomeDir();
|
|
|
|
workingDir=e->getConfString("lastDir",homeDir);
|
|
|
|
workingDirSong=e->getConfString("lastDirSong",workingDir);
|
|
|
|
workingDirIns=e->getConfString("lastDirIns",workingDir);
|
|
|
|
workingDirWave=e->getConfString("lastDirWave",workingDir);
|
|
|
|
workingDirSample=e->getConfString("lastDirSample",workingDir);
|
|
|
|
workingDirAudioExport=e->getConfString("lastDirAudioExport",workingDir);
|
|
|
|
workingDirVGMExport=e->getConfString("lastDirVGMExport",workingDir);
|
|
|
|
workingDirFont=e->getConfString("lastDirFont",workingDir);
|
2022-04-06 18:53:39 +00:00
|
|
|
workingDirColors=e->getConfString("lastDirColors",workingDir);
|
|
|
|
workingDirKeybinds=e->getConfString("lastDirKeybinds",workingDir);
|
|
|
|
workingDirLayout=e->getConfString("lastDirLayout",workingDir);
|
2022-01-29 06:54:30 +00:00
|
|
|
|
|
|
|
editControlsOpen=e->getConfBool("editControlsOpen",true);
|
|
|
|
ordersOpen=e->getConfBool("ordersOpen",true);
|
|
|
|
insListOpen=e->getConfBool("insListOpen",true);
|
|
|
|
songInfoOpen=e->getConfBool("songInfoOpen",true);
|
|
|
|
patternOpen=e->getConfBool("patternOpen",true);
|
|
|
|
insEditOpen=e->getConfBool("insEditOpen",false);
|
|
|
|
waveListOpen=e->getConfBool("waveListOpen",true);
|
|
|
|
waveEditOpen=e->getConfBool("waveEditOpen",false);
|
|
|
|
sampleListOpen=e->getConfBool("sampleListOpen",true);
|
|
|
|
sampleEditOpen=e->getConfBool("sampleEditOpen",false);
|
|
|
|
settingsOpen=e->getConfBool("settingsOpen",false);
|
|
|
|
mixerOpen=e->getConfBool("mixerOpen",false);
|
|
|
|
oscOpen=e->getConfBool("oscOpen",true);
|
2022-01-29 23:56:08 +00:00
|
|
|
volMeterOpen=e->getConfBool("volMeterOpen",true);
|
2022-02-03 05:34:48 +00:00
|
|
|
statsOpen=e->getConfBool("statsOpen",false);
|
|
|
|
compatFlagsOpen=e->getConfBool("compatFlagsOpen",false);
|
|
|
|
pianoOpen=e->getConfBool("pianoOpen",false);
|
|
|
|
notesOpen=e->getConfBool("notesOpen",false);
|
2022-02-05 06:48:35 +00:00
|
|
|
channelsOpen=e->getConfBool("channelsOpen",false);
|
2022-02-22 03:31:27 +00:00
|
|
|
regViewOpen=e->getConfBool("regViewOpen",false);
|
2022-04-11 03:12:02 +00:00
|
|
|
logOpen=e->getConfBool("logOpen",false);
|
2022-01-29 06:54:30 +00:00
|
|
|
|
2022-03-16 06:27:34 +00:00
|
|
|
tempoView=e->getConfBool("tempoView",true);
|
2022-03-30 05:28:49 +00:00
|
|
|
waveHex=e->getConfBool("waveHex",false);
|
2022-04-02 20:07:47 +00:00
|
|
|
lockLayout=e->getConfBool("lockLayout",false);
|
2022-03-16 06:27:34 +00:00
|
|
|
|
2022-01-16 22:25:43 +00:00
|
|
|
syncSettings();
|
2021-12-31 03:34:42 +00:00
|
|
|
|
2022-02-15 22:42:56 +00:00
|
|
|
if (settings.dpiScale>=0.5f) {
|
|
|
|
dpiScale=settings.dpiScale;
|
|
|
|
}
|
|
|
|
|
2022-01-20 06:46:03 +00:00
|
|
|
#if !(defined(__APPLE__) || defined(_WIN32))
|
2022-01-07 08:29:56 +00:00
|
|
|
unsigned char* furIcon=getFurnaceIcon();
|
|
|
|
SDL_Surface* icon=SDL_CreateRGBSurfaceFrom(furIcon,256,256,32,256*4,0xff,0xff00,0xff0000,0xff000000);
|
|
|
|
#endif
|
|
|
|
|
2022-01-29 22:27:51 +00:00
|
|
|
scrW=e->getConfInt("lastWindowWidth",1280);
|
|
|
|
scrH=e->getConfInt("lastWindowHeight",800);
|
|
|
|
|
2022-02-08 07:04:23 +00:00
|
|
|
#ifndef __APPLE__
|
2022-01-29 22:23:45 +00:00
|
|
|
SDL_Rect displaySize;
|
2022-02-08 07:04:23 +00:00
|
|
|
#endif
|
2022-01-29 22:23:45 +00:00
|
|
|
|
2022-02-08 21:15:53 +00:00
|
|
|
SDL_SetHint("SDL_HINT_VIDEO_ALLOW_SCREENSAVER","1");
|
|
|
|
|
|
|
|
SDL_Init(SDL_INIT_VIDEO);
|
|
|
|
|
2022-04-01 10:20:00 +00:00
|
|
|
sdlWin=SDL_CreateWindow("Furnace",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,scrW*dpiScale,scrH*dpiScale,SDL_WINDOW_RESIZABLE|SDL_WINDOW_ALLOW_HIGHDPI);
|
2021-12-11 08:11:40 +00:00
|
|
|
if (sdlWin==NULL) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("could not open window! %s",SDL_GetError());
|
2021-12-11 08:11:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-01-07 08:29:56 +00:00
|
|
|
|
2022-02-08 07:04:23 +00:00
|
|
|
#ifndef __APPLE__
|
2022-02-15 22:42:56 +00:00
|
|
|
if (settings.dpiScale<0.5f) {
|
|
|
|
SDL_GetDisplayDPI(SDL_GetWindowDisplayIndex(sdlWin),&dpiScaleF,NULL,NULL);
|
|
|
|
dpiScale=round(dpiScaleF/96.0f);
|
|
|
|
if (dpiScale<1) dpiScale=1;
|
|
|
|
if (dpiScale!=1) SDL_SetWindowSize(sdlWin,scrW*dpiScale,scrH*dpiScale);
|
|
|
|
|
|
|
|
if (SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(sdlWin),&displaySize)==0) {
|
|
|
|
if (scrW>displaySize.w/dpiScale) scrW=(displaySize.w/dpiScale)-32;
|
|
|
|
if (scrH>displaySize.h/dpiScale) scrH=(displaySize.h/dpiScale)-32;
|
|
|
|
SDL_SetWindowSize(sdlWin,scrW*dpiScale,scrH*dpiScale);
|
|
|
|
}
|
2022-01-29 22:23:45 +00:00
|
|
|
}
|
2022-02-08 07:04:23 +00:00
|
|
|
#endif
|
2022-01-29 22:23:45 +00:00
|
|
|
|
2022-01-20 06:46:03 +00:00
|
|
|
#if !(defined(__APPLE__) || defined(_WIN32))
|
2022-01-07 08:29:56 +00:00
|
|
|
if (icon!=NULL) {
|
|
|
|
SDL_SetWindowIcon(sdlWin,icon);
|
|
|
|
SDL_FreeSurface(icon);
|
|
|
|
free(furIcon);
|
|
|
|
} else {
|
2022-04-11 03:12:02 +00:00
|
|
|
logW("could not create icon!");
|
2022-01-07 08:29:56 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-12-11 08:11:40 +00:00
|
|
|
sdlRend=SDL_CreateRenderer(sdlWin,-1,SDL_RENDERER_ACCELERATED|SDL_RENDERER_PRESENTVSYNC|SDL_RENDERER_TARGETTEXTURE);
|
|
|
|
|
|
|
|
if (sdlRend==NULL) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("could not init renderer! %s",SDL_GetError());
|
2021-12-11 08:11:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-08 07:04:23 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
dpiScale=getMacDPIScale();
|
|
|
|
#endif
|
|
|
|
|
2021-12-11 08:11:40 +00:00
|
|
|
IMGUI_CHECKVERSION();
|
|
|
|
ImGui::CreateContext();
|
|
|
|
|
2022-02-08 03:09:20 +00:00
|
|
|
ImGui_ImplSDL2_InitForSDLRenderer(sdlWin,sdlRend);
|
2021-12-11 08:11:40 +00:00
|
|
|
ImGui_ImplSDLRenderer_Init(sdlRend);
|
|
|
|
|
2022-01-22 06:50:52 +00:00
|
|
|
applyUISettings();
|
2021-12-11 08:11:40 +00:00
|
|
|
|
2022-02-18 02:40:31 +00:00
|
|
|
if (!ImGui::GetIO().Fonts->Build()) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("error while building font atlas!");
|
2022-02-18 02:40:31 +00:00
|
|
|
showError("error while loading fonts! please check your settings.");
|
|
|
|
ImGui::GetIO().Fonts->Clear();
|
|
|
|
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
|
|
|
|
patFont=mainFont;
|
|
|
|
ImGui_ImplSDLRenderer_DestroyFontsTexture();
|
|
|
|
if (!ImGui::GetIO().Fonts->Build()) {
|
2022-04-11 03:12:02 +00:00
|
|
|
logE("error again while building font atlas!");
|
2022-02-18 02:40:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-19 21:01:24 +00:00
|
|
|
strncpy(finalLayoutPath,(e->getConfigPath()+String(LAYOUT_INI)).c_str(),4095);
|
2022-03-21 19:11:28 +00:00
|
|
|
backupPath=e->getConfigPath()+String(BACKUP_FUR);
|
2021-12-19 21:01:24 +00:00
|
|
|
prepareLayout();
|
2021-12-19 08:16:24 +00:00
|
|
|
|
2021-12-14 01:55:40 +00:00
|
|
|
ImGui::GetIO().ConfigFlags|=ImGuiConfigFlags_DockingEnable;
|
2021-12-19 21:01:24 +00:00
|
|
|
ImGui::GetIO().IniFilename=finalLayoutPath;
|
2022-02-20 03:04:55 +00:00
|
|
|
ImGui::LoadIniSettingsFromDisk(finalLayoutPath);
|
2021-12-14 01:55:40 +00:00
|
|
|
|
2021-12-15 22:32:08 +00:00
|
|
|
updateWindowTitle();
|
2021-12-26 23:05:18 +00:00
|
|
|
|
2022-01-08 06:57:37 +00:00
|
|
|
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
2021-12-26 23:05:18 +00:00
|
|
|
oldPat[i]=new DivPattern;
|
|
|
|
}
|
2022-02-08 07:11:21 +00:00
|
|
|
|
2022-03-11 03:10:52 +00:00
|
|
|
firstFrame=true;
|
|
|
|
|
2022-03-28 23:19:47 +00:00
|
|
|
// TODO: MIDI mapping time!
|
|
|
|
e->setMidiCallback([this](const TAMidiMessage& msg) -> int {
|
|
|
|
midiLock.lock();
|
|
|
|
midiQueue.push(msg);
|
|
|
|
midiLock.unlock();
|
2022-03-31 06:51:57 +00:00
|
|
|
e->setMidiBaseChan(cursor.xCoarse);
|
2022-04-01 06:50:01 +00:00
|
|
|
if (midiMap.valueInputStyle!=0 && cursor.xFine!=0 && edit) return -2;
|
|
|
|
if (!midiMap.noteInput) return -2;
|
2022-03-31 23:39:01 +00:00
|
|
|
if (learning!=-1) return -2;
|
2022-03-29 22:38:30 +00:00
|
|
|
if (midiMap.at(msg)) return -2;
|
2022-03-28 23:19:47 +00:00
|
|
|
return curIns;
|
2022-03-28 20:24:09 +00:00
|
|
|
});
|
|
|
|
|
2021-12-11 08:11:40 +00:00
|
|
|
return true;
|
2021-12-19 21:01:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FurnaceGUI::finish() {
|
|
|
|
ImGui::SaveIniSettingsToDisk(finalLayoutPath);
|
|
|
|
ImGui_ImplSDLRenderer_Shutdown();
|
|
|
|
ImGui_ImplSDL2_Shutdown();
|
|
|
|
ImGui::DestroyContext();
|
|
|
|
SDL_DestroyRenderer(sdlRend);
|
|
|
|
SDL_DestroyWindow(sdlWin);
|
2021-12-26 23:05:18 +00:00
|
|
|
|
2021-12-31 03:34:42 +00:00
|
|
|
e->setConf("lastDir",workingDir);
|
2022-03-02 05:02:52 +00:00
|
|
|
e->setConf("lastDirSong",workingDirSong);
|
|
|
|
e->setConf("lastDirIns",workingDirIns);
|
|
|
|
e->setConf("lastDirWave",workingDirWave);
|
|
|
|
e->setConf("lastDirSample",workingDirSample);
|
|
|
|
e->setConf("lastDirAudioExport",workingDirAudioExport);
|
|
|
|
e->setConf("lastDirVGMExport",workingDirVGMExport);
|
|
|
|
e->setConf("lastDirFont",workingDirFont);
|
2022-04-06 18:53:39 +00:00
|
|
|
e->setConf("lastDirColors",workingDirColors);
|
|
|
|
e->setConf("lastDirKeybinds",workingDirKeybinds);
|
|
|
|
e->setConf("lastDirLayout",workingDirLayout);
|
2021-12-31 03:34:42 +00:00
|
|
|
|
2022-01-29 06:54:30 +00:00
|
|
|
// commit last open windows
|
|
|
|
e->setConf("editControlsOpen",editControlsOpen);
|
|
|
|
e->setConf("ordersOpen",ordersOpen);
|
|
|
|
e->setConf("insListOpen",insListOpen);
|
|
|
|
e->setConf("songInfoOpen",songInfoOpen);
|
|
|
|
e->setConf("patternOpen",patternOpen);
|
|
|
|
e->setConf("insEditOpen",insEditOpen);
|
|
|
|
e->setConf("waveListOpen",waveListOpen);
|
|
|
|
e->setConf("waveEditOpen",waveEditOpen);
|
|
|
|
e->setConf("sampleListOpen",sampleListOpen);
|
|
|
|
e->setConf("sampleEditOpen",sampleEditOpen);
|
|
|
|
e->setConf("settingsOpen",settingsOpen);
|
|
|
|
e->setConf("mixerOpen",mixerOpen);
|
|
|
|
e->setConf("oscOpen",oscOpen);
|
2022-01-29 23:56:08 +00:00
|
|
|
e->setConf("volMeterOpen",volMeterOpen);
|
2022-02-03 05:34:48 +00:00
|
|
|
e->setConf("statsOpen",statsOpen);
|
|
|
|
e->setConf("compatFlagsOpen",compatFlagsOpen);
|
|
|
|
e->setConf("pianoOpen",pianoOpen);
|
|
|
|
e->setConf("notesOpen",notesOpen);
|
2022-02-05 06:48:35 +00:00
|
|
|
e->setConf("channelsOpen",channelsOpen);
|
2022-02-22 03:31:27 +00:00
|
|
|
e->setConf("regViewOpen",regViewOpen);
|
2022-04-11 03:12:02 +00:00
|
|
|
e->setConf("logOpen",logOpen);
|
2022-01-29 06:54:30 +00:00
|
|
|
|
2022-01-29 22:27:51 +00:00
|
|
|
// commit last window size
|
|
|
|
e->setConf("lastWindowWidth",scrW);
|
|
|
|
e->setConf("lastWindowHeight",scrH);
|
|
|
|
|
2022-03-16 06:27:34 +00:00
|
|
|
e->setConf("tempoView",tempoView);
|
2022-03-30 05:28:49 +00:00
|
|
|
e->setConf("waveHex",waveHex);
|
2022-04-02 20:07:47 +00:00
|
|
|
e->setConf("lockLayout",lockLayout);
|
2022-03-16 06:27:34 +00:00
|
|
|
|
2022-01-08 06:57:37 +00:00
|
|
|
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
2021-12-26 23:05:18 +00:00
|
|
|
delete oldPat[i];
|
|
|
|
}
|
2022-03-21 19:11:28 +00:00
|
|
|
|
|
|
|
if (backupTask.valid()) {
|
|
|
|
backupTask.get();
|
|
|
|
}
|
|
|
|
|
2021-12-19 21:01:24 +00:00
|
|
|
return true;
|
2021-12-11 08:11:40 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 07:10:09 +00:00
|
|
|
FurnaceGUI::FurnaceGUI():
|
2021-12-11 08:11:40 +00:00
|
|
|
e(NULL),
|
2022-04-04 18:25:38 +00:00
|
|
|
sdlWin(NULL),
|
|
|
|
sdlRend(NULL),
|
2022-03-17 08:43:02 +00:00
|
|
|
sampleTex(NULL),
|
|
|
|
sampleTexW(0),
|
|
|
|
sampleTexH(0),
|
|
|
|
updateSampleTex(true),
|
2021-12-11 08:11:40 +00:00
|
|
|
quit(false),
|
2021-12-30 23:52:36 +00:00
|
|
|
warnQuit(false),
|
2021-12-20 03:51:02 +00:00
|
|
|
willCommit(false),
|
2021-12-28 23:23:57 +00:00
|
|
|
edit(false),
|
2021-12-30 23:25:55 +00:00
|
|
|
modified(false),
|
2022-01-09 21:36:47 +00:00
|
|
|
displayError(false),
|
2022-01-18 04:34:29 +00:00
|
|
|
displayExporting(false),
|
2022-01-26 05:26:15 +00:00
|
|
|
vgmExportLoop(true),
|
2022-04-16 04:47:39 +00:00
|
|
|
wantCaptureKeyboard(false),
|
2022-03-01 22:19:52 +00:00
|
|
|
displayNew(false),
|
2022-04-02 02:40:32 +00:00
|
|
|
vgmExportVersion(0x171),
|
2021-12-17 08:33:12 +00:00
|
|
|
curFileDialog(GUI_FILE_OPEN),
|
2021-12-30 23:52:36 +00:00
|
|
|
warnAction(GUI_WARN_OPEN),
|
2022-04-13 07:09:59 +00:00
|
|
|
postWarnAction(GUI_WARN_GENERIC),
|
2022-03-13 23:32:35 +00:00
|
|
|
fileDialog(NULL),
|
2021-12-11 08:11:40 +00:00
|
|
|
scrW(1280),
|
|
|
|
scrH(800),
|
2021-12-11 21:44:02 +00:00
|
|
|
dpiScale(1),
|
2021-12-19 04:03:50 +00:00
|
|
|
aboutScroll(0),
|
|
|
|
aboutSin(0),
|
|
|
|
aboutHue(0.0f),
|
2022-03-21 19:32:33 +00:00
|
|
|
backupTimer(15.0),
|
2022-03-31 23:39:01 +00:00
|
|
|
learning(-1),
|
2022-03-22 04:36:17 +00:00
|
|
|
mainFont(NULL),
|
|
|
|
iconFont(NULL),
|
|
|
|
patFont(NULL),
|
|
|
|
bigFont(NULL),
|
|
|
|
fontRange(NULL),
|
2021-12-11 21:44:02 +00:00
|
|
|
curIns(0),
|
2021-12-16 08:09:18 +00:00
|
|
|
curWave(0),
|
|
|
|
curSample(0),
|
2021-12-12 09:21:09 +00:00
|
|
|
curOctave(3),
|
2022-04-14 07:58:29 +00:00
|
|
|
curOrder(0),
|
2021-12-13 22:09:46 +00:00
|
|
|
oldRow(0),
|
2021-12-21 04:20:30 +00:00
|
|
|
oldOrder(0),
|
|
|
|
oldOrder1(0),
|
2021-12-14 22:45:37 +00:00
|
|
|
editStep(1),
|
2022-01-18 04:34:29 +00:00
|
|
|
exportLoops(0),
|
2022-01-20 07:28:55 +00:00
|
|
|
soloChan(-1),
|
|
|
|
soloTimeout(0),
|
2022-01-19 23:19:52 +00:00
|
|
|
orderEditMode(0),
|
2022-01-20 07:11:03 +00:00
|
|
|
orderCursor(-1),
|
2022-01-27 05:29:16 +00:00
|
|
|
loopOrder(-1),
|
|
|
|
loopRow(-1),
|
|
|
|
loopEnd(-1),
|
2022-01-29 23:56:08 +00:00
|
|
|
isClipping(0),
|
2022-02-21 08:05:00 +00:00
|
|
|
extraChannelButtons(0),
|
|
|
|
patNameTarget(-1),
|
2022-03-02 07:22:51 +00:00
|
|
|
newSongCategory(0),
|
2022-04-02 05:11:44 +00:00
|
|
|
wheelX(0),
|
|
|
|
wheelY(0),
|
2021-12-15 22:32:08 +00:00
|
|
|
editControlsOpen(true),
|
2021-12-14 09:45:44 +00:00
|
|
|
ordersOpen(true),
|
|
|
|
insListOpen(true),
|
|
|
|
songInfoOpen(true),
|
|
|
|
patternOpen(true),
|
|
|
|
insEditOpen(false),
|
2021-12-16 08:09:18 +00:00
|
|
|
waveListOpen(true),
|
|
|
|
waveEditOpen(false),
|
|
|
|
sampleListOpen(true),
|
|
|
|
sampleEditOpen(false),
|
2021-12-19 04:03:50 +00:00
|
|
|
aboutOpen(false),
|
2021-12-20 03:51:02 +00:00
|
|
|
settingsOpen(false),
|
2022-01-13 06:03:57 +00:00
|
|
|
mixerOpen(false),
|
2022-01-27 05:29:16 +00:00
|
|
|
debugOpen(false),
|
2022-03-21 05:52:38 +00:00
|
|
|
inspectorOpen(false),
|
2022-01-27 22:49:00 +00:00
|
|
|
oscOpen(true),
|
2022-01-29 23:56:08 +00:00
|
|
|
volMeterOpen(true),
|
2022-02-03 05:34:48 +00:00
|
|
|
statsOpen(false),
|
|
|
|
compatFlagsOpen(false),
|
|
|
|
pianoOpen(false),
|
|
|
|
notesOpen(false),
|
2022-02-05 06:48:35 +00:00
|
|
|
channelsOpen(false),
|
2022-02-22 03:31:27 +00:00
|
|
|
regViewOpen(false),
|
2022-04-11 03:12:02 +00:00
|
|
|
logOpen(false),
|
2022-04-02 20:07:47 +00:00
|
|
|
/*
|
|
|
|
editControlsDocked(false),
|
|
|
|
ordersDocked(false),
|
|
|
|
insListDocked(false),
|
|
|
|
songInfoDocked(false),
|
|
|
|
patternDocked(false),
|
|
|
|
insEditDocked(false),
|
|
|
|
waveListDocked(false),
|
|
|
|
waveEditDocked(false),
|
|
|
|
sampleListDocked(false),
|
|
|
|
sampleEditDocked(false),
|
|
|
|
aboutDocked(false),
|
|
|
|
settingsDocked(false),
|
|
|
|
mixerDocked(false),
|
|
|
|
debugDocked(false),
|
|
|
|
inspectorDocked(false),
|
|
|
|
oscDocked(false),
|
|
|
|
volMeterDocked(false),
|
|
|
|
statsDocked(false),
|
|
|
|
compatFlagsDocked(false),
|
|
|
|
pianoDocked(false),
|
|
|
|
notesDocked(false),
|
|
|
|
channelsDocked(false),
|
|
|
|
regViewDocked(false),
|
|
|
|
*/
|
2021-12-14 22:45:37 +00:00
|
|
|
selecting(false),
|
|
|
|
curNibble(false),
|
2022-01-20 07:11:03 +00:00
|
|
|
orderNibble(false),
|
2021-12-21 22:42:27 +00:00
|
|
|
followOrders(true),
|
|
|
|
followPattern(true),
|
2021-12-22 21:22:47 +00:00
|
|
|
changeAllOrders(false),
|
2022-02-11 23:20:39 +00:00
|
|
|
collapseWindow(false),
|
2022-02-15 07:59:20 +00:00
|
|
|
demandScrollX(false),
|
2022-02-15 18:38:59 +00:00
|
|
|
fancyPattern(false),
|
2022-02-21 08:05:00 +00:00
|
|
|
wantPatName(false),
|
2022-03-11 03:10:52 +00:00
|
|
|
firstFrame(true),
|
2022-03-16 06:27:34 +00:00
|
|
|
tempoView(true),
|
2022-04-02 20:07:47 +00:00
|
|
|
waveHex(false),
|
|
|
|
lockLayout(false),
|
2021-12-14 22:45:37 +00:00
|
|
|
curWindow(GUI_WINDOW_NOTHING),
|
2022-02-11 23:20:39 +00:00
|
|
|
nextWindow(GUI_WINDOW_NOTHING),
|
2022-03-01 22:19:52 +00:00
|
|
|
nextDesc(NULL),
|
2022-03-12 07:13:15 +00:00
|
|
|
opMaskNote(true),
|
|
|
|
opMaskIns(true),
|
|
|
|
opMaskVol(true),
|
|
|
|
opMaskEffect(true),
|
|
|
|
opMaskEffectVal(true),
|
|
|
|
latchNote(-1),
|
2022-03-13 09:51:05 +00:00
|
|
|
latchIns(-2),
|
2022-03-12 07:13:15 +00:00
|
|
|
latchVol(-1),
|
|
|
|
latchEffect(-1),
|
|
|
|
latchEffectVal(-1),
|
2022-01-20 05:07:53 +00:00
|
|
|
wavePreviewOn(false),
|
|
|
|
wavePreviewKey((SDL_Scancode)0),
|
|
|
|
wavePreviewNote(0),
|
2022-01-20 21:51:31 +00:00
|
|
|
samplePreviewOn(false),
|
|
|
|
samplePreviewKey((SDL_Scancode)0),
|
|
|
|
samplePreviewNote(0),
|
2022-04-15 07:51:38 +00:00
|
|
|
arpMacroScroll(-12),
|
|
|
|
pitchMacroScroll(-80),
|
2021-12-12 09:21:09 +00:00
|
|
|
macroDragStart(0,0),
|
|
|
|
macroDragAreaSize(0,0),
|
2022-01-21 07:54:52 +00:00
|
|
|
macroDragCTarget(NULL),
|
2021-12-12 09:21:09 +00:00
|
|
|
macroDragTarget(NULL),
|
|
|
|
macroDragLen(0),
|
|
|
|
macroDragMin(0),
|
|
|
|
macroDragMax(0),
|
2022-01-21 06:56:30 +00:00
|
|
|
macroDragLastX(-1),
|
|
|
|
macroDragLastY(-1),
|
|
|
|
macroDragBitOff(0),
|
2022-01-21 22:00:28 +00:00
|
|
|
macroDragScroll(0),
|
2022-01-21 06:56:30 +00:00
|
|
|
macroDragBitMode(false),
|
|
|
|
macroDragInitialValueSet(false),
|
|
|
|
macroDragInitialValue(false),
|
2022-01-21 07:54:52 +00:00
|
|
|
macroDragChar(false),
|
2022-04-13 04:03:20 +00:00
|
|
|
macroDragLineMode(false),
|
|
|
|
macroDragLineInitial(0,0),
|
2021-12-13 22:09:46 +00:00
|
|
|
macroDragActive(false),
|
2022-02-12 06:57:55 +00:00
|
|
|
macroLoopDragStart(0,0),
|
|
|
|
macroLoopDragAreaSize(0,0),
|
|
|
|
macroLoopDragTarget(NULL),
|
|
|
|
macroLoopDragLen(0),
|
|
|
|
macroLoopDragActive(false),
|
|
|
|
waveDragStart(0,0),
|
|
|
|
waveDragAreaSize(0,0),
|
|
|
|
waveDragTarget(NULL),
|
|
|
|
waveDragLen(0),
|
|
|
|
waveDragMin(0),
|
|
|
|
waveDragMax(0),
|
|
|
|
waveDragActive(false),
|
|
|
|
bindSetTarget(0),
|
|
|
|
bindSetPrevValue(0),
|
|
|
|
bindSetActive(false),
|
|
|
|
bindSetPending(false),
|
2021-12-24 03:14:59 +00:00
|
|
|
nextScroll(-1.0f),
|
2021-12-26 23:05:18 +00:00
|
|
|
nextAddScroll(0.0f),
|
2022-03-09 20:43:30 +00:00
|
|
|
transposeAmount(0),
|
|
|
|
randomizeMin(0),
|
|
|
|
randomizeMax(255),
|
2022-03-12 08:04:34 +00:00
|
|
|
fadeMin(0),
|
|
|
|
fadeMax(255),
|
2022-03-09 20:43:30 +00:00
|
|
|
scaleMax(100.0f),
|
2022-03-12 08:04:34 +00:00
|
|
|
fadeMode(false),
|
2022-03-12 08:40:56 +00:00
|
|
|
randomMode(false),
|
2022-04-13 23:16:55 +00:00
|
|
|
haveHitBounds(false),
|
2022-04-14 08:05:58 +00:00
|
|
|
pendingStepUpdate(false),
|
2022-03-17 23:08:59 +00:00
|
|
|
oldOrdersLen(0),
|
|
|
|
sampleZoom(1.0),
|
2022-03-21 05:41:18 +00:00
|
|
|
prevSampleZoom(1.0),
|
2022-03-19 08:42:44 +00:00
|
|
|
samplePos(0),
|
|
|
|
resizeSize(1024),
|
2022-03-22 22:01:06 +00:00
|
|
|
silenceSize(1024),
|
2022-03-19 08:42:44 +00:00
|
|
|
resampleTarget(32000),
|
|
|
|
resampleStrat(5),
|
|
|
|
amplifyVol(100.0),
|
|
|
|
sampleSelStart(-1),
|
|
|
|
sampleSelEnd(-1),
|
|
|
|
sampleDragActive(false),
|
2022-03-19 21:14:11 +00:00
|
|
|
sampleDragMode(false),
|
|
|
|
sampleDrag16(false),
|
2022-03-21 05:41:18 +00:00
|
|
|
sampleZoomAuto(true),
|
2022-03-19 21:14:11 +00:00
|
|
|
sampleDragTarget(NULL),
|
|
|
|
sampleDragStart(0,0),
|
2022-03-21 08:45:20 +00:00
|
|
|
sampleDragAreaSize(0,0),
|
|
|
|
sampleDragLen(0),
|
|
|
|
sampleFilterL(1.0f),
|
|
|
|
sampleFilterB(0.0f),
|
|
|
|
sampleFilterH(0.0f),
|
|
|
|
sampleFilterRes(0.25f),
|
|
|
|
sampleFilterCutStart(16000.0f),
|
|
|
|
sampleFilterCutEnd(100.0f),
|
2022-03-22 06:57:06 +00:00
|
|
|
sampleFilterPower(1),
|
|
|
|
sampleClipboard(NULL),
|
2022-03-22 09:54:01 +00:00
|
|
|
sampleClipboardLen(0),
|
|
|
|
openSampleResizeOpt(false),
|
|
|
|
openSampleResampleOpt(false),
|
|
|
|
openSampleAmplifyOpt(false),
|
2022-03-22 22:01:06 +00:00
|
|
|
openSampleSilenceOpt(false),
|
2022-04-09 07:42:58 +00:00
|
|
|
openSampleFilterOpt(false),
|
2022-04-09 10:02:24 +00:00
|
|
|
oscTotal(0),
|
|
|
|
oscZoom(0.5f),
|
2022-04-11 04:01:55 +00:00
|
|
|
oscZoomSlider(false),
|
2022-04-13 08:24:49 +00:00
|
|
|
followLog(true),
|
|
|
|
pianoOctaves(7),
|
|
|
|
pianoOptions(false),
|
|
|
|
pianoOffset(6) {
|
2021-12-14 22:45:37 +00:00
|
|
|
// value keys
|
|
|
|
valueKeys[SDLK_0]=0;
|
|
|
|
valueKeys[SDLK_1]=1;
|
|
|
|
valueKeys[SDLK_2]=2;
|
|
|
|
valueKeys[SDLK_3]=3;
|
|
|
|
valueKeys[SDLK_4]=4;
|
|
|
|
valueKeys[SDLK_5]=5;
|
|
|
|
valueKeys[SDLK_6]=6;
|
|
|
|
valueKeys[SDLK_7]=7;
|
|
|
|
valueKeys[SDLK_8]=8;
|
|
|
|
valueKeys[SDLK_9]=9;
|
|
|
|
valueKeys[SDLK_a]=10;
|
|
|
|
valueKeys[SDLK_b]=11;
|
|
|
|
valueKeys[SDLK_c]=12;
|
|
|
|
valueKeys[SDLK_d]=13;
|
|
|
|
valueKeys[SDLK_e]=14;
|
|
|
|
valueKeys[SDLK_f]=15;
|
2022-02-15 22:47:07 +00:00
|
|
|
valueKeys[SDLK_KP_0]=0;
|
|
|
|
valueKeys[SDLK_KP_1]=1;
|
|
|
|
valueKeys[SDLK_KP_2]=2;
|
|
|
|
valueKeys[SDLK_KP_3]=3;
|
|
|
|
valueKeys[SDLK_KP_4]=4;
|
|
|
|
valueKeys[SDLK_KP_5]=5;
|
|
|
|
valueKeys[SDLK_KP_6]=6;
|
|
|
|
valueKeys[SDLK_KP_7]=7;
|
|
|
|
valueKeys[SDLK_KP_8]=8;
|
|
|
|
valueKeys[SDLK_KP_9]=9;
|
2022-03-01 22:19:52 +00:00
|
|
|
|
2022-03-21 22:34:43 +00:00
|
|
|
initSystemPresets();
|
2022-01-26 05:26:15 +00:00
|
|
|
|
|
|
|
memset(willExport,1,32*sizeof(bool));
|
2022-01-29 23:56:08 +00:00
|
|
|
|
|
|
|
peak[0]=0;
|
|
|
|
peak[1]=0;
|
2022-02-10 22:44:27 +00:00
|
|
|
|
|
|
|
memset(actionKeys,0,GUI_ACTION_MAX*sizeof(int));
|
2022-02-15 18:38:59 +00:00
|
|
|
|
|
|
|
memset(patChanX,0,sizeof(float)*(DIV_MAX_CHANS+1));
|
|
|
|
memset(patChanSlideY,0,sizeof(float)*(DIV_MAX_CHANS+1));
|
2022-02-22 05:13:32 +00:00
|
|
|
memset(lastIns,-1,sizeof(int)*DIV_MAX_CHANS);
|
2022-04-09 07:42:58 +00:00
|
|
|
memset(oscValues,0,sizeof(float)*512);
|
2022-03-28 20:24:09 +00:00
|
|
|
}
|