mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 04:55:13 +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 "song.h"
|
||||
#include <cstddef>
|
||||
#define _USE_MATH_DEFINES
|
||||
#include "engine.h"
|
||||
#include "instrument.h"
|
||||
|
@ -533,13 +534,25 @@ void DivEngine::renderSamples() {
|
|||
qsoundMemLen=memPos+256;
|
||||
}
|
||||
|
||||
void DivEngine::createNew() {
|
||||
DivSystem sys=song.system[0];
|
||||
void DivEngine::createNew(int* description) {
|
||||
quitDispatch();
|
||||
isBusy.lock();
|
||||
song.unload();
|
||||
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();
|
||||
renderSamples();
|
||||
isBusy.unlock();
|
||||
|
|
|
@ -262,7 +262,7 @@ class DivEngine {
|
|||
DivWavetable* getWave(int index);
|
||||
DivSample* getSample(int index);
|
||||
// start fresh
|
||||
void createNew();
|
||||
void createNew(int* description);
|
||||
// load a file.
|
||||
bool load(unsigned char* f, size_t length);
|
||||
// save as .dmf.
|
||||
|
|
126
src/gui/gui.cpp
126
src/gui/gui.cpp
|
@ -1898,6 +1898,73 @@ void FurnaceGUI::drawDebug() {
|
|||
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() {
|
||||
if (nextWindow==GUI_WINDOW_STATS) {
|
||||
statsOpen=true;
|
||||
|
@ -4391,22 +4458,11 @@ bool FurnaceGUI::loop() {
|
|||
|
||||
ImGui::BeginMainMenuBar();
|
||||
if (ImGui::BeginMenu("file")) {
|
||||
if (ImGui::MenuItem("new")) {
|
||||
if (ImGui::MenuItem("new...")) {
|
||||
if (modified) {
|
||||
showWarning("Unsaved changes! Are you sure?",GUI_WARN_NEW);
|
||||
} else {
|
||||
e->createNew();
|
||||
undoHist.clear();
|
||||
redoHist.clear();
|
||||
curFileName="";
|
||||
modified=false;
|
||||
curNibble=false;
|
||||
orderNibble=false;
|
||||
orderCursor=-1;
|
||||
selStart=SelectionPoint();
|
||||
selEnd=SelectionPoint();
|
||||
cursor=SelectionPoint();
|
||||
updateWindowTitle();
|
||||
displayNew=true;
|
||||
}
|
||||
}
|
||||
if (ImGui::MenuItem("open...",BIND_FOR(GUI_ACTION_OPEN))) {
|
||||
|
@ -5107,6 +5163,11 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::OpenPopup("Rendering...");
|
||||
}
|
||||
|
||||
if (displayNew) {
|
||||
displayNew=false;
|
||||
ImGui::OpenPopup("New Song");
|
||||
}
|
||||
|
||||
if (nextWindow==GUI_WINDOW_ABOUT) {
|
||||
aboutOpen=true;
|
||||
nextWindow=GUI_WINDOW_NOTHING;
|
||||
|
@ -5126,6 +5187,13 @@ bool FurnaceGUI::loop() {
|
|||
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)) {
|
||||
ImGui::Text("%s",errorString.c_str());
|
||||
if (ImGui::Button("OK")) {
|
||||
|
@ -5143,18 +5211,7 @@ bool FurnaceGUI::loop() {
|
|||
quit=true;
|
||||
break;
|
||||
case GUI_WARN_NEW:
|
||||
e->createNew();
|
||||
undoHist.clear();
|
||||
redoHist.clear();
|
||||
curFileName="";
|
||||
modified=false;
|
||||
curNibble=false;
|
||||
orderNibble=false;
|
||||
orderCursor=-1;
|
||||
selStart=SelectionPoint();
|
||||
selEnd=SelectionPoint();
|
||||
cursor=SelectionPoint();
|
||||
updateWindowTitle();
|
||||
displayNew=true;
|
||||
break;
|
||||
case GUI_WARN_OPEN:
|
||||
openFileDialog(GUI_FILE_OPEN);
|
||||
|
@ -5743,6 +5800,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
displayError(false),
|
||||
displayExporting(false),
|
||||
vgmExportLoop(true),
|
||||
displayNew(false),
|
||||
curFileDialog(GUI_FILE_OPEN),
|
||||
warnAction(GUI_WARN_OPEN),
|
||||
scrW(1280),
|
||||
|
@ -5804,6 +5862,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
wantPatName(false),
|
||||
curWindow(GUI_WINDOW_NOTHING),
|
||||
nextWindow(GUI_WINDOW_NOTHING),
|
||||
nextDesc(NULL),
|
||||
wavePreviewOn(false),
|
||||
wavePreviewKey((SDL_Scancode)0),
|
||||
wavePreviewNote(0),
|
||||
|
@ -5923,6 +5982,23 @@ FurnaceGUI::FurnaceGUI():
|
|||
valueKeys[SDLK_KP_7]=7;
|
||||
valueKeys[SDLK_KP_8]=8;
|
||||
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));
|
||||
|
||||
|
|
|
@ -402,6 +402,22 @@ struct Particle {
|
|||
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 {
|
||||
DivEngine* e;
|
||||
|
||||
|
@ -413,6 +429,7 @@ class FurnaceGUI {
|
|||
String mmlStringW;
|
||||
|
||||
bool quit, warnQuit, willCommit, edit, modified, displayError, displayExporting, vgmExportLoop;
|
||||
bool displayNew;
|
||||
bool willExport[32];
|
||||
|
||||
FurnaceGUIFileDialogs curFileDialog;
|
||||
|
@ -533,6 +550,7 @@ class FurnaceGUI {
|
|||
float peak[2];
|
||||
float patChanX[DIV_MAX_CHANS+1];
|
||||
float patChanSlideY[DIV_MAX_CHANS+1];
|
||||
int* nextDesc;
|
||||
|
||||
// bit 31: ctrl
|
||||
// bit 30: reserved for SDL scancode mask
|
||||
|
@ -563,6 +581,8 @@ class FurnaceGUI {
|
|||
std::vector<DivCommand> cmdStream;
|
||||
std::vector<Particle> particles;
|
||||
|
||||
std::vector<FurnaceGUISysCategory> sysCategories;
|
||||
|
||||
bool wavePreviewOn;
|
||||
SDL_Scancode wavePreviewKey;
|
||||
int wavePreviewNote;
|
||||
|
@ -657,6 +677,7 @@ class FurnaceGUI {
|
|||
void drawAbout();
|
||||
void drawSettings();
|
||||
void drawDebug();
|
||||
void drawNewSong();
|
||||
|
||||
void parseKeybinds();
|
||||
void promptKey(int which);
|
||||
|
|
Loading…
Reference in a new issue