mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-30 08:23:01 +00:00
TODO: revamp new song system picker
This commit is contained in:
parent
7f3460bfcd
commit
fa5e2bc439
4 changed files with 139 additions and 29 deletions
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "dataErrors.h"
|
#include "dataErrors.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
|
#include <cstddef>
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "instrument.h"
|
#include "instrument.h"
|
||||||
|
@ -533,13 +534,25 @@ void DivEngine::renderSamples() {
|
||||||
qsoundMemLen=memPos+256;
|
qsoundMemLen=memPos+256;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivEngine::createNew() {
|
void DivEngine::createNew(int* description) {
|
||||||
DivSystem sys=song.system[0];
|
|
||||||
quitDispatch();
|
quitDispatch();
|
||||||
isBusy.lock();
|
isBusy.lock();
|
||||||
song.unload();
|
song.unload();
|
||||||
song=DivSong();
|
song=DivSong();
|
||||||
song.system[0]=sys;
|
if (description!=NULL) {
|
||||||
|
if (description[0]!=0) {
|
||||||
|
int index=0;
|
||||||
|
for (int i=0; description[i]; i+=4) {
|
||||||
|
song.system[index]=(DivSystem)description[i];
|
||||||
|
song.systemVol[index]=description[i+1];
|
||||||
|
song.systemPan[index]=description[i+2];
|
||||||
|
song.systemFlags[index]=description[i+3];
|
||||||
|
index++;
|
||||||
|
if (index>=32) break;
|
||||||
|
}
|
||||||
|
song.systemLen=index;
|
||||||
|
}
|
||||||
|
}
|
||||||
recalcChans();
|
recalcChans();
|
||||||
renderSamples();
|
renderSamples();
|
||||||
isBusy.unlock();
|
isBusy.unlock();
|
||||||
|
|
|
@ -262,7 +262,7 @@ class DivEngine {
|
||||||
DivWavetable* getWave(int index);
|
DivWavetable* getWave(int index);
|
||||||
DivSample* getSample(int index);
|
DivSample* getSample(int index);
|
||||||
// start fresh
|
// start fresh
|
||||||
void createNew();
|
void createNew(int* description);
|
||||||
// load a file.
|
// load a file.
|
||||||
bool load(unsigned char* f, size_t length);
|
bool load(unsigned char* f, size_t length);
|
||||||
// save as .dmf.
|
// save as .dmf.
|
||||||
|
|
126
src/gui/gui.cpp
126
src/gui/gui.cpp
|
@ -1898,6 +1898,73 @@ void FurnaceGUI::drawDebug() {
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define NEWSONG_CATEGORY(x) \
|
||||||
|
if (ImGui::Selectable(x,false,ImGuiSelectableFlags_DontClosePopups)) { \
|
||||||
|
printf("selected a category\n"); \
|
||||||
|
}
|
||||||
|
|
||||||
|
void FurnaceGUI::drawNewSong() {
|
||||||
|
bool accepted=false;
|
||||||
|
|
||||||
|
ImGui::PushFont(bigFont);
|
||||||
|
ImGui::SetCursorPosX((ImGui::GetContentRegionAvail().x-ImGui::CalcTextSize("Choose a System!").x)*0.5);
|
||||||
|
ImGui::Text("Choose a System!");
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
if (ImGui::BeginTable("sysPicker",2,ImGuiTableFlags_Borders)) {
|
||||||
|
ImGui::TableSetupColumn("c0",ImGuiTableColumnFlags_WidthFixed,0.0f);
|
||||||
|
ImGui::TableSetupColumn("c1",ImGuiTableColumnFlags_WidthStretch,0.0f);
|
||||||
|
|
||||||
|
ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Categories");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Systems");
|
||||||
|
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
|
// CATEGORIES
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
NEWSONG_CATEGORY("All chips");
|
||||||
|
NEWSONG_CATEGORY("FM");
|
||||||
|
NEWSONG_CATEGORY("Square");
|
||||||
|
NEWSONG_CATEGORY("Sample");
|
||||||
|
NEWSONG_CATEGORY("Wavetable");
|
||||||
|
NEWSONG_CATEGORY("Other/Special");
|
||||||
|
NEWSONG_CATEGORY("Game consoles");
|
||||||
|
NEWSONG_CATEGORY("Computers");
|
||||||
|
NEWSONG_CATEGORY("Arcade systems");
|
||||||
|
NEWSONG_CATEGORY("DefleMask-compatible");
|
||||||
|
|
||||||
|
// SYSTEMS
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
if (ImGui::BeginTable("Systems",1,ImGuiTableFlags_BordersInnerV|ImGuiTableFlags_ScrollY)) {
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Selectable("System system",false,ImGuiSelectableFlags_DontClosePopups);
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::Button("Go ahead") || accepted) {
|
||||||
|
e->createNew(nextDesc);
|
||||||
|
undoHist.clear();
|
||||||
|
redoHist.clear();
|
||||||
|
curFileName="";
|
||||||
|
modified=false;
|
||||||
|
curNibble=false;
|
||||||
|
orderNibble=false;
|
||||||
|
orderCursor=-1;
|
||||||
|
selStart=SelectionPoint();
|
||||||
|
selEnd=SelectionPoint();
|
||||||
|
cursor=SelectionPoint();
|
||||||
|
updateWindowTitle();
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FurnaceGUI::drawStats() {
|
void FurnaceGUI::drawStats() {
|
||||||
if (nextWindow==GUI_WINDOW_STATS) {
|
if (nextWindow==GUI_WINDOW_STATS) {
|
||||||
statsOpen=true;
|
statsOpen=true;
|
||||||
|
@ -4391,22 +4458,11 @@ bool FurnaceGUI::loop() {
|
||||||
|
|
||||||
ImGui::BeginMainMenuBar();
|
ImGui::BeginMainMenuBar();
|
||||||
if (ImGui::BeginMenu("file")) {
|
if (ImGui::BeginMenu("file")) {
|
||||||
if (ImGui::MenuItem("new")) {
|
if (ImGui::MenuItem("new...")) {
|
||||||
if (modified) {
|
if (modified) {
|
||||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_NEW);
|
showWarning("Unsaved changes! Are you sure?",GUI_WARN_NEW);
|
||||||
} else {
|
} else {
|
||||||
e->createNew();
|
displayNew=true;
|
||||||
undoHist.clear();
|
|
||||||
redoHist.clear();
|
|
||||||
curFileName="";
|
|
||||||
modified=false;
|
|
||||||
curNibble=false;
|
|
||||||
orderNibble=false;
|
|
||||||
orderCursor=-1;
|
|
||||||
selStart=SelectionPoint();
|
|
||||||
selEnd=SelectionPoint();
|
|
||||||
cursor=SelectionPoint();
|
|
||||||
updateWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ImGui::MenuItem("open...",BIND_FOR(GUI_ACTION_OPEN))) {
|
if (ImGui::MenuItem("open...",BIND_FOR(GUI_ACTION_OPEN))) {
|
||||||
|
@ -5107,6 +5163,11 @@ bool FurnaceGUI::loop() {
|
||||||
ImGui::OpenPopup("Rendering...");
|
ImGui::OpenPopup("Rendering...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (displayNew) {
|
||||||
|
displayNew=false;
|
||||||
|
ImGui::OpenPopup("New Song");
|
||||||
|
}
|
||||||
|
|
||||||
if (nextWindow==GUI_WINDOW_ABOUT) {
|
if (nextWindow==GUI_WINDOW_ABOUT) {
|
||||||
aboutOpen=true;
|
aboutOpen=true;
|
||||||
nextWindow=GUI_WINDOW_NOTHING;
|
nextWindow=GUI_WINDOW_NOTHING;
|
||||||
|
@ -5126,6 +5187,13 @@ bool FurnaceGUI::loop() {
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSizeConstraints(ImVec2(400.0f*dpiScale,200.0f*dpiScale),ImVec2(scrW*dpiScale,scrH*dpiScale));
|
||||||
|
if (ImGui::BeginPopupModal("New Song",NULL)) {
|
||||||
|
ImGui::SetWindowPos(ImVec2(((scrW*dpiScale)-ImGui::GetWindowSize().x)*0.5,((scrH*dpiScale)-ImGui::GetWindowSize().y)*0.5));
|
||||||
|
drawNewSong();
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::BeginPopupModal("Error",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
if (ImGui::BeginPopupModal("Error",NULL,ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
ImGui::Text("%s",errorString.c_str());
|
ImGui::Text("%s",errorString.c_str());
|
||||||
if (ImGui::Button("OK")) {
|
if (ImGui::Button("OK")) {
|
||||||
|
@ -5143,18 +5211,7 @@ bool FurnaceGUI::loop() {
|
||||||
quit=true;
|
quit=true;
|
||||||
break;
|
break;
|
||||||
case GUI_WARN_NEW:
|
case GUI_WARN_NEW:
|
||||||
e->createNew();
|
displayNew=true;
|
||||||
undoHist.clear();
|
|
||||||
redoHist.clear();
|
|
||||||
curFileName="";
|
|
||||||
modified=false;
|
|
||||||
curNibble=false;
|
|
||||||
orderNibble=false;
|
|
||||||
orderCursor=-1;
|
|
||||||
selStart=SelectionPoint();
|
|
||||||
selEnd=SelectionPoint();
|
|
||||||
cursor=SelectionPoint();
|
|
||||||
updateWindowTitle();
|
|
||||||
break;
|
break;
|
||||||
case GUI_WARN_OPEN:
|
case GUI_WARN_OPEN:
|
||||||
openFileDialog(GUI_FILE_OPEN);
|
openFileDialog(GUI_FILE_OPEN);
|
||||||
|
@ -5743,6 +5800,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
displayError(false),
|
displayError(false),
|
||||||
displayExporting(false),
|
displayExporting(false),
|
||||||
vgmExportLoop(true),
|
vgmExportLoop(true),
|
||||||
|
displayNew(false),
|
||||||
curFileDialog(GUI_FILE_OPEN),
|
curFileDialog(GUI_FILE_OPEN),
|
||||||
warnAction(GUI_WARN_OPEN),
|
warnAction(GUI_WARN_OPEN),
|
||||||
scrW(1280),
|
scrW(1280),
|
||||||
|
@ -5804,6 +5862,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
wantPatName(false),
|
wantPatName(false),
|
||||||
curWindow(GUI_WINDOW_NOTHING),
|
curWindow(GUI_WINDOW_NOTHING),
|
||||||
nextWindow(GUI_WINDOW_NOTHING),
|
nextWindow(GUI_WINDOW_NOTHING),
|
||||||
|
nextDesc(NULL),
|
||||||
wavePreviewOn(false),
|
wavePreviewOn(false),
|
||||||
wavePreviewKey((SDL_Scancode)0),
|
wavePreviewKey((SDL_Scancode)0),
|
||||||
wavePreviewNote(0),
|
wavePreviewNote(0),
|
||||||
|
@ -5924,6 +5983,23 @@ FurnaceGUI::FurnaceGUI():
|
||||||
valueKeys[SDLK_KP_8]=8;
|
valueKeys[SDLK_KP_8]=8;
|
||||||
valueKeys[SDLK_KP_9]=9;
|
valueKeys[SDLK_KP_9]=9;
|
||||||
|
|
||||||
|
/*
|
||||||
|
const char* sysCategories[]={
|
||||||
|
"All chips",
|
||||||
|
"FM",
|
||||||
|
"Square",
|
||||||
|
"Sample",
|
||||||
|
"Wavetable",
|
||||||
|
"Other/Special",
|
||||||
|
"Game consoles",
|
||||||
|
"Computers",
|
||||||
|
"Arcade systems",
|
||||||
|
"DefleMask-compatible"
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
sysCategories.push_back(FurnaceGUISysCategory("All chips"));
|
||||||
|
|
||||||
memset(willExport,1,32*sizeof(bool));
|
memset(willExport,1,32*sizeof(bool));
|
||||||
|
|
||||||
peak[0]=0;
|
peak[0]=0;
|
||||||
|
|
|
@ -402,6 +402,22 @@ struct Particle {
|
||||||
lifeSpeed(lS) {}
|
lifeSpeed(lS) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FurnaceGUISysDef {
|
||||||
|
const char* name;
|
||||||
|
const int* definition;
|
||||||
|
FurnaceGUISysDef(const char* n, const int* def):
|
||||||
|
name(n), definition(def) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FurnaceGUISysCategory {
|
||||||
|
const char* name;
|
||||||
|
std::vector<FurnaceGUISysDef> systems;
|
||||||
|
FurnaceGUISysCategory(const char* n):
|
||||||
|
name(n) {}
|
||||||
|
FurnaceGUISysCategory():
|
||||||
|
name(NULL) {}
|
||||||
|
};
|
||||||
|
|
||||||
class FurnaceGUI {
|
class FurnaceGUI {
|
||||||
DivEngine* e;
|
DivEngine* e;
|
||||||
|
|
||||||
|
@ -413,6 +429,7 @@ class FurnaceGUI {
|
||||||
String mmlStringW;
|
String mmlStringW;
|
||||||
|
|
||||||
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop;
|
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop;
|
||||||
|
bool displayNew;
|
||||||
bool willExport[32];
|
bool willExport[32];
|
||||||
|
|
||||||
FurnaceGUIFileDialogs curFileDialog;
|
FurnaceGUIFileDialogs curFileDialog;
|
||||||
|
@ -533,6 +550,7 @@ class FurnaceGUI {
|
||||||
float peak[2];
|
float peak[2];
|
||||||
float patChanX[DIV_MAX_CHANS+1];
|
float patChanX[DIV_MAX_CHANS+1];
|
||||||
float patChanSlideY[DIV_MAX_CHANS+1];
|
float patChanSlideY[DIV_MAX_CHANS+1];
|
||||||
|
int* nextDesc;
|
||||||
|
|
||||||
// bit 31: ctrl
|
// bit 31: ctrl
|
||||||
// bit 30: reserved for SDL scancode mask
|
// bit 30: reserved for SDL scancode mask
|
||||||
|
@ -563,6 +581,8 @@ class FurnaceGUI {
|
||||||
std::vector<DivCommand> cmdStream;
|
std::vector<DivCommand> cmdStream;
|
||||||
std::vector<Particle> particles;
|
std::vector<Particle> particles;
|
||||||
|
|
||||||
|
std::vector<FurnaceGUISysCategory> sysCategories;
|
||||||
|
|
||||||
bool wavePreviewOn;
|
bool wavePreviewOn;
|
||||||
SDL_Scancode wavePreviewKey;
|
SDL_Scancode wavePreviewKey;
|
||||||
int wavePreviewNote;
|
int wavePreviewNote;
|
||||||
|
@ -657,6 +677,7 @@ class FurnaceGUI {
|
||||||
void drawAbout();
|
void drawAbout();
|
||||||
void drawSettings();
|
void drawSettings();
|
||||||
void drawDebug();
|
void drawDebug();
|
||||||
|
void drawNewSong();
|
||||||
|
|
||||||
void parseKeybinds();
|
void parseKeybinds();
|
||||||
void promptKey(int which);
|
void promptKey(int which);
|
||||||
|
|
Loading…
Reference in a new issue