add option to save unused patterns

closes #106

also prepare for the pattern manager window
This commit is contained in:
tildearrow 2022-08-16 03:42:17 -05:00
parent edddff8431
commit d1c5a4725b
8 changed files with 85 additions and 10 deletions

View File

@ -531,6 +531,7 @@ src/gui/midiMap.cpp
src/gui/newSong.cpp
src/gui/orders.cpp
src/gui/osc.cpp
src/gui/patManager.cpp
src/gui/pattern.cpp
src/gui/piano.cpp
src/gui/presets.cpp

View File

@ -3515,15 +3515,27 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
// high short is channel
// low short is pattern number
std::vector<PatToWrite> patsToWrite;
bool alreadyAdded[256];
for (int i=0; i<chans; i++) {
for (size_t j=0; j<song.subsong.size(); j++) {
DivSubSong* subs=song.subsong[j];
memset(alreadyAdded,0,256*sizeof(bool));
for (int k=0; k<subs->ordersLen; k++) {
if (alreadyAdded[subs->orders.ord[i][k]]) continue;
patsToWrite.push_back(PatToWrite(j,i,subs->orders.ord[i][k]));
alreadyAdded[subs->orders.ord[i][k]]=true;
if (getConfInt("saveUnusedPatterns",0)==1) {
for (int i=0; i<chans; i++) {
for (size_t j=0; j<song.subsong.size(); j++) {
DivSubSong* subs=song.subsong[j];
for (int k=0; k<256; k++) {
if (subs->pat[i].data[k]==NULL) continue;
patsToWrite.push_back(PatToWrite(j,i,k));
}
}
}
} else {
bool alreadyAdded[256];
for (int i=0; i<chans; i++) {
for (size_t j=0; j<song.subsong.size(); j++) {
DivSubSong* subs=song.subsong[j];
memset(alreadyAdded,0,256*sizeof(bool));
for (int k=0; k<subs->ordersLen; k++) {
if (alreadyAdded[subs->orders.ord[i][k]]) continue;
patsToWrite.push_back(PatToWrite(j,i,subs->orders.ord[i][k]));
alreadyAdded[subs->orders.ord[i][k]]=true;
}
}
}
}

View File

@ -238,6 +238,9 @@ void FurnaceGUI::doAction(int what) {
case GUI_ACTION_WINDOW_CHANNELS:
nextWindow=GUI_WINDOW_CHANNELS;
break;
case GUI_ACTION_WINDOW_PAT_MANAGER:
nextWindow=GUI_WINDOW_PAT_MANAGER;
break;
case GUI_ACTION_WINDOW_REGISTER_VIEW:
nextWindow=GUI_WINDOW_REGISTER_VIEW;
break;
@ -322,6 +325,9 @@ void FurnaceGUI::doAction(int what) {
case GUI_WINDOW_CHANNELS:
channelsOpen=false;
break;
case GUI_WINDOW_PAT_MANAGER:
patManagerOpen=false;
break;
case GUI_WINDOW_REGISTER_VIEW:
regViewOpen=false;
break;

View File

@ -3107,6 +3107,7 @@ bool FurnaceGUI::loop() {
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("pattern manager",BIND_FOR(GUI_ACTION_WINDOW_PAT_MANAGER),patManagerOpen)) patManagerOpen=!patManagerOpen;
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;
ImGui::Separator();
@ -3241,6 +3242,7 @@ bool FurnaceGUI::loop() {
drawPiano();
drawNotes();
drawChannels();
drawPatManager();
drawRegView();
drawLog();
drawEffectList();
@ -4361,6 +4363,7 @@ bool FurnaceGUI::init() {
pianoOpen=e->getConfBool("pianoOpen",false);
notesOpen=e->getConfBool("notesOpen",false);
channelsOpen=e->getConfBool("channelsOpen",false);
patManagerOpen=e->getConfBool("patManagerOpen",false);
regViewOpen=e->getConfBool("regViewOpen",false);
logOpen=e->getConfBool("logOpen",false);
effectListOpen=e->getConfBool("effectListOpen",false);
@ -4603,6 +4606,7 @@ bool FurnaceGUI::finish() {
e->setConf("pianoOpen",pianoOpen);
e->setConf("notesOpen",notesOpen);
e->setConf("channelsOpen",channelsOpen);
e->setConf("patManagerOpen",patManagerOpen);
e->setConf("regViewOpen",regViewOpen);
e->setConf("logOpen",logOpen);
e->setConf("effectListOpen",effectListOpen);
@ -4782,6 +4786,7 @@ FurnaceGUI::FurnaceGUI():
subSongsOpen(true),
findOpen(false),
spoilerOpen(false),
patManagerOpen(false),
selecting(false),
selectingFull(false),
dragging(false),

View File

@ -242,6 +242,7 @@ enum FurnaceGUIWindows {
GUI_WINDOW_PIANO,
GUI_WINDOW_NOTES,
GUI_WINDOW_CHANNELS,
GUI_WINDOW_PAT_MANAGER,
GUI_WINDOW_REGISTER_VIEW,
GUI_WINDOW_LOG,
GUI_WINDOW_EFFECT_LIST,
@ -361,6 +362,7 @@ enum FurnaceGUIActions {
GUI_ACTION_WINDOW_PIANO,
GUI_ACTION_WINDOW_NOTES,
GUI_ACTION_WINDOW_CHANNELS,
GUI_ACTION_WINDOW_PAT_MANAGER,
GUI_ACTION_WINDOW_REGISTER_VIEW,
GUI_ACTION_WINDOW_LOG,
GUI_ACTION_WINDOW_EFFECT_LIST,
@ -1117,6 +1119,7 @@ class FurnaceGUI {
int unsignedDetune;
int noThreadedInput;
int clampSamples;
int saveUnusedPatterns;
unsigned int maxUndoSteps;
String mainFontPath;
String patFontPath;
@ -1228,6 +1231,7 @@ class FurnaceGUI {
unsignedDetune(0),
noThreadedInput(0),
clampSamples(0),
saveUnusedPatterns(0),
maxUndoSteps(100),
mainFontPath(""),
patFontPath(""),
@ -1257,7 +1261,7 @@ class FurnaceGUI {
bool waveListOpen, waveEditOpen, sampleListOpen, sampleEditOpen, aboutOpen, settingsOpen;
bool mixerOpen, debugOpen, inspectorOpen, oscOpen, volMeterOpen, statsOpen, compatFlagsOpen;
bool pianoOpen, notesOpen, channelsOpen, regViewOpen, logOpen, effectListOpen, chanOscOpen;
bool subSongsOpen, findOpen, spoilerOpen;
bool subSongsOpen, findOpen, spoilerOpen, patManagerOpen;
SelectionPoint selStart, selEnd, cursor, cursorDrag, dragStart, dragEnd;
bool selecting, selectingFull, dragging, curNibble, orderNibble, followOrders, followPattern, changeAllOrders, mobileUI;
@ -1566,6 +1570,7 @@ class FurnaceGUI {
void drawPiano();
void drawNotes();
void drawChannels();
void drawPatManager();
void drawRegView();
void drawAbout();
void drawSettings();

View File

@ -487,6 +487,7 @@ const FurnaceGUIActionDef guiActions[GUI_ACTION_MAX]={
D("WINDOW_PIANO", "Piano", 0),
D("WINDOW_NOTES", "Song Comments", 0),
D("WINDOW_CHANNELS", "Channels", 0),
D("WINDOW_PAT_MANAGER", "Pattern Manager", 0),
D("WINDOW_REGISTER_VIEW", "Register View", 0),
D("WINDOW_LOG", "Log Viewer", 0),
D("EFFECT_LIST", "Effect List", 0),

37
src/gui/patManager.cpp Normal file
View File

@ -0,0 +1,37 @@
/**
* 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.
*/
#include "gui.h"
#include "misc/cpp/imgui_stdlib.h"
#include "IconsFontAwesome4.h"
#include <imgui.h>
void FurnaceGUI::drawPatManager() {
if (nextWindow==GUI_WINDOW_PAT_MANAGER) {
patManagerOpen=true;
ImGui::SetNextWindowFocus();
nextWindow=GUI_WINDOW_NOTHING;
}
if (!patManagerOpen) return;
if (ImGui::Begin("Pattern Manager",&patManagerOpen,globalWinFlags)) {
ImGui::Text("Hello World!");
}
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_ChildWindows)) curWindow=GUI_WINDOW_PAT_MANAGER;
ImGui::End();
}

View File

@ -514,6 +514,11 @@ void FurnaceGUI::drawSettings() {
settings.blankIns=blankInsB;
}
bool saveUnusedPatternsB=settings.saveUnusedPatterns;
if (ImGui::Checkbox("Save unused patterns",&saveUnusedPatternsB)) {
settings.saveUnusedPatterns=saveUnusedPatternsB;
}
ImGui::Text("Note preview behavior:");
if (ImGui::RadioButton("Never##npb0",settings.notePreviewBehavior==0)) {
settings.notePreviewBehavior=0;
@ -2133,6 +2138,7 @@ void FurnaceGUI::syncSettings() {
settings.macroRelLabel=e->getConfString("macroRelLabel","REL");
settings.emptyLabel=e->getConfString("emptyLabel","...");
settings.emptyLabel2=e->getConfString("emptyLabel2","..");
settings.saveUnusedPatterns=e->getConfInt("saveUnusedPatterns",0);
clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.patFontSize,2,96);
@ -2221,6 +2227,7 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.unsignedDetune,0,1);
clampSetting(settings.noThreadedInput,0,1);
clampSetting(settings.clampSamples,0,1);
clampSetting(settings.saveUnusedPatterns,0,1);
settings.initialSys=e->decodeSysDesc(e->getConfString("initialSys",""));
if (settings.initialSys.size()<4) {
@ -2365,6 +2372,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("macroRelLabel",settings.macroRelLabel);
e->setConf("emptyLabel",settings.emptyLabel);
e->setConf("emptyLabel2",settings.emptyLabel2);
e->setConf("saveUnusedPatterns",settings.saveUnusedPatterns);
// colors
for (int i=0; i<GUI_COLOR_MAX; i++) {