implement sort orders
This commit is contained in:
parent
9e8d344a89
commit
3d6f9b4723
|
@ -58,6 +58,39 @@ void DivSubSong::rearrangePatterns() {
|
|||
}
|
||||
|
||||
void DivSubSong::sortOrders() {
|
||||
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
||||
DivPattern* patPointer[DIV_MAX_PATTERNS];
|
||||
unsigned char orderMap[DIV_MAX_PATTERNS];
|
||||
bool seen[DIV_MAX_PATTERNS];
|
||||
int orderMapLen=0;
|
||||
|
||||
memcpy(patPointer,pat[i].data,DIV_MAX_PATTERNS*sizeof(void*));
|
||||
memset(orderMap,0,DIV_MAX_PATTERNS);
|
||||
memset(seen,0,DIV_MAX_PATTERNS*sizeof(bool));
|
||||
|
||||
// 1. sort orders
|
||||
for (int j=0; j<ordersLen; j++) {
|
||||
if (!seen[orders.ord[i][j]]) {
|
||||
orderMap[orders.ord[i][j]]=orderMapLen++;
|
||||
seen[orders.ord[i][j]]=true;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. populate the rest
|
||||
for (int j=0; j<DIV_MAX_PATTERNS; j++) {
|
||||
if (!seen[j]) orderMap[j]=orderMapLen++;
|
||||
}
|
||||
|
||||
// 3. swap pattern pointers
|
||||
for (int j=0; j<DIV_MAX_PATTERNS; j++) {
|
||||
pat[i].data[orderMap[j]]=patPointer[j];
|
||||
}
|
||||
|
||||
// 4. swap orders
|
||||
for (int j=0; j<ordersLen; j++) {
|
||||
orders.ord[i][j]=orderMap[orders.ord[i][j]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DivSubSong::makePatUnique() {
|
||||
|
|
|
@ -589,6 +589,10 @@ void FurnaceGUI::drawMobileControls() {
|
|||
if (ImGui::Button("Presets")) {
|
||||
userPresetsOpen=!userPresetsOpen;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("PatManager")) {
|
||||
patManagerOpen=!patManagerOpen;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
|
|
|
@ -4714,6 +4714,7 @@ bool FurnaceGUI::loop() {
|
|||
MEASURE(regView,drawRegView());
|
||||
MEASURE(memory,drawMemory());
|
||||
MEASURE(userPresets,drawUserPresets());
|
||||
MEASURE(patManager,drawPatManager());
|
||||
} else {
|
||||
globalWinFlags=0;
|
||||
ImGui::DockSpaceOverViewport(NULL,lockLayout?(ImGuiDockNodeFlags_NoWindowMenuButton|ImGuiDockNodeFlags_NoMove|ImGuiDockNodeFlags_NoResize|ImGuiDockNodeFlags_NoCloseButton|ImGuiDockNodeFlags_NoDocking|ImGuiDockNodeFlags_NoDockingSplitMe|ImGuiDockNodeFlags_NoDockingSplitOther):0);
|
||||
|
|
|
@ -33,10 +33,6 @@ void FurnaceGUI::drawPatManager() {
|
|||
unsigned char isUsed[DIV_MAX_PATTERNS];
|
||||
bool isNull[DIV_MAX_PATTERNS];
|
||||
if (ImGui::Begin("Pattern Manager",&patManagerOpen,globalWinFlags)) {
|
||||
ImGui::Text("Global Tasks:");
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
if (ImGui::Button("De-duplicate patterns")) {
|
||||
e->lockEngine([this]() {
|
||||
e->curSubSong->optimizePatterns();
|
||||
|
|
Loading…
Reference in a new issue