mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: add option to add more systems
This commit is contained in:
parent
e961cf79ca
commit
c43cc0ae80
3 changed files with 53 additions and 4 deletions
|
@ -485,7 +485,12 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
if (ds.version>0x0a) {
|
||||
String hz=reader.readString(3);
|
||||
if (ds.customTempo) {
|
||||
ds.hz=std::stoi(hz);
|
||||
try {
|
||||
ds.hz=std::stoi(hz);
|
||||
} catch (std::exception& e) {
|
||||
logW("invalid custom Hz!\n");
|
||||
ds.hz=60;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
|
@ -1516,6 +1521,28 @@ void DivEngine::changeSystem(int index, DivSystem which) {
|
|||
isBusy.unlock();
|
||||
}
|
||||
|
||||
bool DivEngine::addSystem(DivSystem which) {
|
||||
if (song.systemLen>32) {
|
||||
lastError="cannot add more than 32 systems";
|
||||
return false;
|
||||
}
|
||||
if (chans+getChannelCount(which)>DIV_MAX_CHANS) {
|
||||
lastError="max number of total channels is 128";
|
||||
return false;
|
||||
}
|
||||
quitDispatch();
|
||||
isBusy.lock();
|
||||
song.system[song.systemLen++]=which;
|
||||
recalcChans();
|
||||
isBusy.unlock();
|
||||
initDispatch();
|
||||
isBusy.lock();
|
||||
renderSamples();
|
||||
reset();
|
||||
isBusy.unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
String DivEngine::getLastError() {
|
||||
return lastError;
|
||||
}
|
||||
|
|
|
@ -402,10 +402,10 @@ class DivEngine {
|
|||
void changeSystem(int index, DivSystem which);
|
||||
|
||||
// add system
|
||||
void addSystem(DivSystem which);
|
||||
bool addSystem(DivSystem which);
|
||||
|
||||
// remove system
|
||||
void removeSystem(int index);
|
||||
bool removeSystem(int index);
|
||||
|
||||
// get last error
|
||||
String getLastError();
|
||||
|
|
|
@ -2555,6 +2555,14 @@ void FurnaceGUI::processDrags(int dragX, int dragY) {
|
|||
}
|
||||
}
|
||||
|
||||
#define sysAddOption(x) \
|
||||
if (ImGui::MenuItem(e->getSystemName(x))) { \
|
||||
if (!e->addSystem(x)) { \
|
||||
showError("cannot add system! ("+e->getLastError()+")"); \
|
||||
} \
|
||||
updateWindowTitle(); \
|
||||
}
|
||||
|
||||
#define sysChangeOption(x) \
|
||||
if (ImGui::MenuItem(e->getSystemName(x),NULL,e->song.system[0]==x)) { \
|
||||
e->changeSystem(0,x); \
|
||||
|
@ -2664,7 +2672,21 @@ bool FurnaceGUI::loop() {
|
|||
openFileDialog(GUI_FILE_SAVE);
|
||||
}
|
||||
ImGui::Separator();
|
||||
if (ImGui::BeginMenu("change platform...")) {
|
||||
if (ImGui::BeginMenu("add platform...")) {
|
||||
sysAddOption(DIV_SYSTEM_GENESIS);
|
||||
sysAddOption(DIV_SYSTEM_GENESIS_EXT);
|
||||
sysAddOption(DIV_SYSTEM_SMS);
|
||||
sysAddOption(DIV_SYSTEM_GB);
|
||||
sysAddOption(DIV_SYSTEM_PCE);
|
||||
sysAddOption(DIV_SYSTEM_NES);
|
||||
sysAddOption(DIV_SYSTEM_C64_8580);
|
||||
sysAddOption(DIV_SYSTEM_C64_6581);
|
||||
sysAddOption(DIV_SYSTEM_ARCADE);
|
||||
sysAddOption(DIV_SYSTEM_YM2610);
|
||||
sysAddOption(DIV_SYSTEM_YM2610_EXT);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("change first platform...")) {
|
||||
sysChangeOption(DIV_SYSTEM_GENESIS);
|
||||
sysChangeOption(DIV_SYSTEM_GENESIS_EXT);
|
||||
sysChangeOption(DIV_SYSTEM_SMS);
|
||||
|
|
Loading…
Reference in a new issue