mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 04:55:13 +00:00
GUI: options to import/export user presets
This commit is contained in:
parent
e7b0130e5c
commit
0ad7863d78
4 changed files with 114 additions and 11 deletions
|
@ -1961,11 +1961,30 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
|||
);
|
||||
break;
|
||||
case GUI_FILE_IMPORT_LAYOUT:
|
||||
if (!dirExists(workingDirKeybinds)) workingDirKeybinds=getHomeDir();
|
||||
if (!dirExists(workingDirLayout)) workingDirLayout=getHomeDir();
|
||||
hasOpened=fileDialog->openLoad(
|
||||
"Select Layout File",
|
||||
{".ini files", "*.ini"},
|
||||
workingDirKeybinds,
|
||||
workingDirLayout,
|
||||
dpiScale
|
||||
);
|
||||
break;
|
||||
case GUI_FILE_IMPORT_USER_PRESETS:
|
||||
case GUI_FILE_IMPORT_USER_PRESETS_REPLACE:
|
||||
if (!dirExists(workingDirConfig)) workingDirConfig=getHomeDir();
|
||||
hasOpened=fileDialog->openLoad(
|
||||
"Select User Presets File",
|
||||
{"configuration files", "*.cfgu"},
|
||||
workingDirConfig,
|
||||
dpiScale
|
||||
);
|
||||
break;
|
||||
case GUI_FILE_IMPORT_CONFIG:
|
||||
if (!dirExists(workingDirConfig)) workingDirConfig=getHomeDir();
|
||||
hasOpened=fileDialog->openLoad(
|
||||
"Select Settings File",
|
||||
{"configuration files", "*.cfg"},
|
||||
workingDirConfig,
|
||||
dpiScale
|
||||
);
|
||||
break;
|
||||
|
@ -1988,11 +2007,29 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
|
|||
);
|
||||
break;
|
||||
case GUI_FILE_EXPORT_LAYOUT:
|
||||
if (!dirExists(workingDirKeybinds)) workingDirKeybinds=getHomeDir();
|
||||
if (!dirExists(workingDirLayout)) workingDirLayout=getHomeDir();
|
||||
hasOpened=fileDialog->openSave(
|
||||
"Export Layout",
|
||||
{".ini files", "*.ini"},
|
||||
workingDirKeybinds,
|
||||
workingDirLayout,
|
||||
dpiScale
|
||||
);
|
||||
break;
|
||||
case GUI_FILE_EXPORT_USER_PRESETS:
|
||||
if (!dirExists(workingDirConfig)) workingDirConfig=getHomeDir();
|
||||
hasOpened=fileDialog->openSave(
|
||||
"Export User Presets",
|
||||
{"configuration files", "*.cfgu"},
|
||||
workingDirConfig,
|
||||
dpiScale
|
||||
);
|
||||
break;
|
||||
case GUI_FILE_EXPORT_CONFIG:
|
||||
if (!dirExists(workingDirConfig)) workingDirConfig=getHomeDir();
|
||||
hasOpened=fileDialog->openSave(
|
||||
"Export Settings",
|
||||
{"configuration files", "*.cfg"},
|
||||
workingDirConfig,
|
||||
dpiScale
|
||||
);
|
||||
break;
|
||||
|
@ -4852,6 +4889,13 @@ bool FurnaceGUI::loop() {
|
|||
case GUI_FILE_EXPORT_LAYOUT:
|
||||
workingDirLayout=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
||||
break;
|
||||
case GUI_FILE_IMPORT_USER_PRESETS:
|
||||
case GUI_FILE_IMPORT_USER_PRESETS_REPLACE:
|
||||
case GUI_FILE_EXPORT_USER_PRESETS:
|
||||
case GUI_FILE_IMPORT_CONFIG:
|
||||
case GUI_FILE_EXPORT_CONFIG:
|
||||
workingDirConfig=fileDialog->getPath()+DIR_SEPARATOR_STR;
|
||||
break;
|
||||
case GUI_FILE_YRW801_ROM_OPEN:
|
||||
case GUI_FILE_TG100_ROM_OPEN:
|
||||
case GUI_FILE_MU5_ROM_OPEN:
|
||||
|
@ -4937,6 +4981,12 @@ bool FurnaceGUI::loop() {
|
|||
if (curFileDialog==GUI_FILE_EXPORT_LAYOUT) {
|
||||
checkExtension(".ini");
|
||||
}
|
||||
if (curFileDialog==GUI_FILE_EXPORT_USER_PRESETS) {
|
||||
checkExtension(".cfgu");
|
||||
}
|
||||
if (curFileDialog==GUI_FILE_EXPORT_CONFIG) {
|
||||
checkExtension(".cfg");
|
||||
}
|
||||
String copyOfName=fileName;
|
||||
switch (curFileDialog) {
|
||||
case GUI_FILE_OPEN:
|
||||
|
@ -5361,6 +5411,19 @@ bool FurnaceGUI::loop() {
|
|||
case GUI_FILE_IMPORT_LAYOUT:
|
||||
importLayout(copyOfName);
|
||||
break;
|
||||
case GUI_FILE_IMPORT_USER_PRESETS:
|
||||
if (!loadUserPresets(false,copyOfName,true)) {
|
||||
showError("could not import user presets!");
|
||||
}
|
||||
break;
|
||||
case GUI_FILE_IMPORT_USER_PRESETS_REPLACE:
|
||||
if (!loadUserPresets(false,copyOfName,false)) {
|
||||
showError(fmt::sprintf("could not import user presets! (%s)",strerror(errno)));
|
||||
}
|
||||
break;
|
||||
case GUI_FILE_IMPORT_CONFIG:
|
||||
importConfig(copyOfName);
|
||||
break;
|
||||
case GUI_FILE_EXPORT_COLORS:
|
||||
exportColors(copyOfName);
|
||||
break;
|
||||
|
@ -5370,6 +5433,14 @@ bool FurnaceGUI::loop() {
|
|||
case GUI_FILE_EXPORT_LAYOUT:
|
||||
exportLayout(copyOfName);
|
||||
break;
|
||||
case GUI_FILE_EXPORT_USER_PRESETS:
|
||||
if (!saveUserPresets(false,copyOfName)) {
|
||||
showError(fmt::sprintf("could not import user presets! (%s)",strerror(errno)));
|
||||
}
|
||||
break;
|
||||
case GUI_FILE_EXPORT_CONFIG:
|
||||
exportConfig(copyOfName);
|
||||
break;
|
||||
case GUI_FILE_YRW801_ROM_OPEN:
|
||||
settings.yrw801Path=copyOfName;
|
||||
break;
|
||||
|
@ -6614,6 +6685,7 @@ bool FurnaceGUI::init() {
|
|||
workingDirColors=e->getConfString("lastDirColors",workingDir);
|
||||
workingDirKeybinds=e->getConfString("lastDirKeybinds",workingDir);
|
||||
workingDirLayout=e->getConfString("lastDirLayout",workingDir);
|
||||
workingDirConfig=e->getConfString("lastDirConfig",workingDir);
|
||||
workingDirTest=e->getConfString("lastDirTest",workingDir);
|
||||
|
||||
editControlsOpen=e->getConfBool("editControlsOpen",true);
|
||||
|
@ -7173,6 +7245,7 @@ void FurnaceGUI::commitState() {
|
|||
e->setConf("lastDirColors",workingDirColors);
|
||||
e->setConf("lastDirKeybinds",workingDirKeybinds);
|
||||
e->setConf("lastDirLayout",workingDirLayout);
|
||||
e->setConf("lastDirConfig",workingDirConfig);
|
||||
e->setConf("lastDirTest",workingDirTest);
|
||||
|
||||
// commit last open windows
|
||||
|
|
|
@ -575,9 +575,14 @@ enum FurnaceGUIFileDialogs {
|
|||
GUI_FILE_IMPORT_COLORS,
|
||||
GUI_FILE_IMPORT_KEYBINDS,
|
||||
GUI_FILE_IMPORT_LAYOUT,
|
||||
GUI_FILE_IMPORT_USER_PRESETS,
|
||||
GUI_FILE_IMPORT_USER_PRESETS_REPLACE,
|
||||
GUI_FILE_IMPORT_CONFIG,
|
||||
GUI_FILE_EXPORT_COLORS,
|
||||
GUI_FILE_EXPORT_KEYBINDS,
|
||||
GUI_FILE_EXPORT_LAYOUT,
|
||||
GUI_FILE_EXPORT_USER_PRESETS,
|
||||
GUI_FILE_EXPORT_CONFIG,
|
||||
GUI_FILE_YRW801_ROM_OPEN,
|
||||
GUI_FILE_TG100_ROM_OPEN,
|
||||
GUI_FILE_MU5_ROM_OPEN,
|
||||
|
@ -1526,6 +1531,7 @@ class FurnaceGUI {
|
|||
String workingDirSong, workingDirIns, workingDirWave, workingDirSample, workingDirAudioExport;
|
||||
String workingDirVGMExport, workingDirZSMExport, workingDirROMExport, workingDirFont, workingDirColors, workingDirKeybinds;
|
||||
String workingDirLayout, workingDirROM, workingDirTest;
|
||||
String workingDirConfig;
|
||||
String mmlString[32];
|
||||
String mmlStringW, grooveString, grooveListString, mmlStringModTable;
|
||||
String mmlStringSNES[DIV_MAX_CHIPS];
|
||||
|
@ -2697,6 +2703,8 @@ class FurnaceGUI {
|
|||
bool exportKeybinds(String path);
|
||||
bool importLayout(String path);
|
||||
bool exportLayout(String path);
|
||||
bool importConfig(String path);
|
||||
bool exportConfig(String path);
|
||||
|
||||
float computeGradPos(int type, int chan);
|
||||
|
||||
|
@ -2796,8 +2804,8 @@ class FurnaceGUI {
|
|||
void initRandomDemoSong();
|
||||
bool loadRandomDemoSong();
|
||||
|
||||
bool loadUserPresets(bool redundancy=true);
|
||||
bool saveUserPresets(bool redundancy=true);
|
||||
bool loadUserPresets(bool redundancy=true, String path="", bool append=false);
|
||||
bool saveUserPresets(bool redundancy=true, String path="");
|
||||
|
||||
void encodeMMLStr(String& target, int* macro, int macroLen, int macroLoop, int macroRel, bool hex=false, bool bit30=false);
|
||||
void decodeMMLStr(String& source, int* macro, unsigned char& macroLen, unsigned char& macroLoop, int macroMin, int macroMax, unsigned char& macroRel, bool bit30=false);
|
||||
|
|
|
@ -5189,6 +5189,14 @@ bool FurnaceGUI::exportLayout(String path) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FurnaceGUI::importConfig(String path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FurnaceGUI::exportConfig(String path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void FurnaceGUI::resetColors() {
|
||||
for (int i=0; i<GUI_COLOR_MAX; i++) {
|
||||
uiColors[i]=ImGui::ColorConvertU32ToFloat4(guiColors[i].defaultColor);
|
||||
|
|
|
@ -48,8 +48,8 @@ std::vector<FurnaceGUISysDef>* digDeep(std::vector<FurnaceGUISysDef>& entries, i
|
|||
return &result;
|
||||
}
|
||||
|
||||
bool FurnaceGUI::loadUserPresets(bool redundancy) {
|
||||
String path=e->getConfigPath()+PRESETS_FILE;
|
||||
bool FurnaceGUI::loadUserPresets(bool redundancy, String path, bool append) {
|
||||
if (path.empty()) path=e->getConfigPath()+PRESETS_FILE;
|
||||
String line;
|
||||
logD("opening user presets: %s",path);
|
||||
|
||||
|
@ -142,7 +142,7 @@ bool FurnaceGUI::loadUserPresets(bool redundancy) {
|
|||
return false;
|
||||
}
|
||||
|
||||
userCategory->systems.clear();
|
||||
if (!append) userCategory->systems.clear();
|
||||
|
||||
char nextLine[4096];
|
||||
while (!feof(f)) {
|
||||
|
@ -210,8 +210,8 @@ void writeSubEntries(FILE* f, std::vector<FurnaceGUISysDef>& entries, int depth)
|
|||
}
|
||||
}
|
||||
|
||||
bool FurnaceGUI::saveUserPresets(bool redundancy) {
|
||||
String path=e->getConfigPath()+PRESETS_FILE;
|
||||
bool FurnaceGUI::saveUserPresets(bool redundancy, String path) {
|
||||
if (path.empty()) path=e->getConfigPath()+PRESETS_FILE;
|
||||
FurnaceGUISysCategory* userCategory=NULL;
|
||||
|
||||
for (FurnaceGUISysCategory& i: sysCategories) {
|
||||
|
@ -509,6 +509,20 @@ void FurnaceGUI::drawUserPresets() {
|
|||
if (ImGui::Button("Save and Close")) {
|
||||
userPresetsOpen=false;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Dummy(ImVec2(8.0f*dpiScale,1.0f));
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Import")) {
|
||||
openFileDialog(GUI_FILE_IMPORT_USER_PRESETS);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Import (replace)")) {
|
||||
openFileDialog(GUI_FILE_IMPORT_USER_PRESETS_REPLACE);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Export")) {
|
||||
openFileDialog(GUI_FILE_EXPORT_USER_PRESETS);
|
||||
}
|
||||
}
|
||||
if (!userPresetsOpen) {
|
||||
saveUserPresets(true);
|
||||
|
|
Loading…
Reference in a new issue