GUI: finish order buttons
This commit is contained in:
parent
e093e00225
commit
bbb0a14946
|
@ -1752,6 +1752,103 @@ void DivEngine::delSample(int index) {
|
||||||
isBusy.unlock();
|
isBusy.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::addOrder(bool duplicate, bool where) {
|
||||||
|
unsigned char order[32];
|
||||||
|
if (song.ordersLen>=0x7e) return;
|
||||||
|
isBusy.lock();
|
||||||
|
if (duplicate) {
|
||||||
|
for (int i=0; i<32; i++) {
|
||||||
|
order[i]=song.orders.ord[i][curOrder];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bool used[256];
|
||||||
|
for (int i=0; i<chans; i++) {
|
||||||
|
memset(used,0,sizeof(bool)*256);
|
||||||
|
for (int j=0; j<song.ordersLen; j++) {
|
||||||
|
used[song.orders.ord[i][j]]=true;
|
||||||
|
}
|
||||||
|
order[i]=0x7e;
|
||||||
|
for (int j=0; j<256; j++) {
|
||||||
|
if (!used[j]) {
|
||||||
|
order[i]=j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (where) { // at the end
|
||||||
|
for (int i=0; i<32; i++) {
|
||||||
|
song.orders.ord[i][song.ordersLen]=order[i];
|
||||||
|
}
|
||||||
|
song.ordersLen++;
|
||||||
|
} else { // after current order
|
||||||
|
for (int i=0; i<32; i++) {
|
||||||
|
for (int j=song.ordersLen; j>curOrder; j--) {
|
||||||
|
song.orders.ord[i][j]=song.orders.ord[i][j-1];
|
||||||
|
}
|
||||||
|
song.orders.ord[i][curOrder+1]=order[i];
|
||||||
|
}
|
||||||
|
song.ordersLen++;
|
||||||
|
curOrder++;
|
||||||
|
if (playing) {
|
||||||
|
playSub(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isBusy.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::deleteOrder() {
|
||||||
|
if (song.ordersLen<=1) return;
|
||||||
|
isBusy.lock();
|
||||||
|
for (int i=0; i<32; i++) {
|
||||||
|
for (int j=curOrder; j<song.ordersLen; j++) {
|
||||||
|
song.orders.ord[i][j]=song.orders.ord[i][j+1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
song.ordersLen--;
|
||||||
|
if (curOrder>=song.ordersLen) curOrder=song.ordersLen-1;
|
||||||
|
if (playing) {
|
||||||
|
playSub(false);
|
||||||
|
}
|
||||||
|
isBusy.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::moveOrderUp() {
|
||||||
|
isBusy.lock();
|
||||||
|
if (curOrder<1) {
|
||||||
|
isBusy.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i=0; i<32; i++) {
|
||||||
|
song.orders.ord[i][curOrder]^=song.orders.ord[i][curOrder-1];
|
||||||
|
song.orders.ord[i][curOrder-1]^=song.orders.ord[i][curOrder];
|
||||||
|
song.orders.ord[i][curOrder]^=song.orders.ord[i][curOrder-1];
|
||||||
|
}
|
||||||
|
curOrder--;
|
||||||
|
if (playing) {
|
||||||
|
playSub(false);
|
||||||
|
}
|
||||||
|
isBusy.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DivEngine::moveOrderDown() {
|
||||||
|
isBusy.lock();
|
||||||
|
if (curOrder>=song.ordersLen-1) {
|
||||||
|
isBusy.unlock();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i=0; i<32; i++) {
|
||||||
|
song.orders.ord[i][curOrder]^=song.orders.ord[i][curOrder+1];
|
||||||
|
song.orders.ord[i][curOrder+1]^=song.orders.ord[i][curOrder];
|
||||||
|
song.orders.ord[i][curOrder]^=song.orders.ord[i][curOrder+1];
|
||||||
|
}
|
||||||
|
curOrder++;
|
||||||
|
if (playing) {
|
||||||
|
playSub(false);
|
||||||
|
}
|
||||||
|
isBusy.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
void DivEngine::setOrder(unsigned char order) {
|
void DivEngine::setOrder(unsigned char order) {
|
||||||
isBusy.lock();
|
isBusy.lock();
|
||||||
curOrder=order;
|
curOrder=order;
|
||||||
|
|
|
@ -269,6 +269,18 @@ class DivEngine {
|
||||||
// delete sample
|
// delete sample
|
||||||
void delSample(int index);
|
void delSample(int index);
|
||||||
|
|
||||||
|
// add order
|
||||||
|
void addOrder(bool duplicate, bool where);
|
||||||
|
|
||||||
|
// delete order
|
||||||
|
void deleteOrder();
|
||||||
|
|
||||||
|
// move order up
|
||||||
|
void moveOrderUp();
|
||||||
|
|
||||||
|
// move order down
|
||||||
|
void moveOrderDown();
|
||||||
|
|
||||||
// go to order
|
// go to order
|
||||||
void setOrder(unsigned char order);
|
void setOrder(unsigned char order);
|
||||||
|
|
||||||
|
|
|
@ -435,24 +435,31 @@ void FurnaceGUI::drawOrders() {
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
if (ImGui::Button(ICON_FA_PLUS)) {
|
if (ImGui::Button(ICON_FA_PLUS)) {
|
||||||
// add order row (new)
|
// add order row (new)
|
||||||
|
e->addOrder(false,false);
|
||||||
}
|
}
|
||||||
if (ImGui::Button(ICON_FA_MINUS)) {
|
if (ImGui::Button(ICON_FA_MINUS)) {
|
||||||
// remove this order row
|
// remove this order row
|
||||||
|
e->deleteOrder();
|
||||||
}
|
}
|
||||||
if (ImGui::Button(ICON_FA_FILES_O)) {
|
if (ImGui::Button(ICON_FA_FILES_O)) {
|
||||||
// duplicate order row
|
// duplicate order row
|
||||||
|
e->addOrder(true,false);
|
||||||
}
|
}
|
||||||
if (ImGui::Button(ICON_FA_ANGLE_UP)) {
|
if (ImGui::Button(ICON_FA_ANGLE_UP)) {
|
||||||
// move order row up
|
// move order row up
|
||||||
|
e->moveOrderUp();
|
||||||
}
|
}
|
||||||
if (ImGui::Button(ICON_FA_ANGLE_DOWN)) {
|
if (ImGui::Button(ICON_FA_ANGLE_DOWN)) {
|
||||||
// move order row down
|
// move order row down
|
||||||
|
e->moveOrderDown();
|
||||||
}
|
}
|
||||||
if (ImGui::Button(ICON_FA_ANGLE_DOUBLE_DOWN)) {
|
if (ImGui::Button(ICON_FA_ANGLE_DOUBLE_DOWN)) {
|
||||||
// duplicate order row at end
|
// duplicate order row at end
|
||||||
|
e->addOrder(true,true);
|
||||||
}
|
}
|
||||||
if (ImGui::Button(changeAllOrders?"1##ChangeAll":"A##ChangeAll")) {
|
if (ImGui::Button(changeAllOrders?ICON_FA_LINK"##ChangeAll":ICON_FA_CHAIN_BROKEN"##ChangeAll")) {
|
||||||
// whether to change one or all orders in a row
|
// whether to change one or all orders in a row
|
||||||
|
changeAllOrders=!changeAllOrders;
|
||||||
}
|
}
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue