Merge branch 'master' of https://github.com/tildearrow/furnace into command-palette
This commit is contained in:
commit
81fd5a23b8
269 changed files with 5121 additions and 1816 deletions
184
src/gui/gui.cpp
184
src/gui/gui.cpp
|
|
@ -497,6 +497,13 @@ bool FurnaceGUI::InvCheckbox(const char* label, bool* value) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void FurnaceGUI::sameLineMaybe(float width) {
|
||||
if (width<0.0f) width=ImGui::GetFrameHeight();
|
||||
|
||||
ImGui::SameLine();
|
||||
if (ImGui::GetContentRegionAvail().x<width) ImGui::NewLine();
|
||||
}
|
||||
|
||||
const char* FurnaceGUI::getSystemName(DivSystem which) {
|
||||
/*
|
||||
if (settings.chipNames) {
|
||||
|
|
@ -3466,6 +3473,11 @@ bool FurnaceGUI::loop() {
|
|||
break;
|
||||
}
|
||||
break;
|
||||
#if SDL_VERSION_ATLEAST(2,0,4)
|
||||
case SDL_RENDER_DEVICE_RESET:
|
||||
killGraphics=true;
|
||||
break;
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2,0,17)
|
||||
case SDL_DISPLAYEVENT: {
|
||||
switch (ev.display.event) {
|
||||
|
|
@ -3778,6 +3790,80 @@ bool FurnaceGUI::loop() {
|
|||
});
|
||||
}
|
||||
|
||||
// recover from dead graphics
|
||||
if (rend->isDead() || killGraphics) {
|
||||
killGraphics=false;
|
||||
|
||||
logW("graphics are dead! restarting...");
|
||||
|
||||
if (sampleTex!=NULL) {
|
||||
rend->destroyTexture(sampleTex);
|
||||
sampleTex=NULL;
|
||||
}
|
||||
|
||||
if (chanOscGradTex!=NULL) {
|
||||
rend->destroyTexture(chanOscGradTex);
|
||||
chanOscGradTex=NULL;
|
||||
}
|
||||
|
||||
for (auto& i: images) {
|
||||
if (i.second->tex!=NULL) {
|
||||
rend->destroyTexture(i.second->tex);
|
||||
i.second->tex=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
commitState();
|
||||
rend->quitGUI();
|
||||
rend->quit();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
|
||||
int initAttempts=0;
|
||||
|
||||
SDL_Delay(500);
|
||||
|
||||
logD("starting render backend...");
|
||||
while (++initAttempts<=5) {
|
||||
if (rend->init(sdlWin)) {
|
||||
break;
|
||||
}
|
||||
SDL_Delay(1000);
|
||||
logV("trying again...");
|
||||
}
|
||||
|
||||
if (initAttempts>5) {
|
||||
reportError("can't keep going without graphics! Furnace will quit now.");
|
||||
quit=true;
|
||||
break;
|
||||
}
|
||||
|
||||
rend->clear(ImVec4(0.0,0.0,0.0,1.0));
|
||||
rend->present();
|
||||
|
||||
logD("preparing user interface...");
|
||||
rend->initGUI(sdlWin);
|
||||
|
||||
logD("building font...");
|
||||
if (!ImGui::GetIO().Fonts->Build()) {
|
||||
logE("error while building font atlas!");
|
||||
showError("error while loading fonts! please check your settings.");
|
||||
ImGui::GetIO().Fonts->Clear();
|
||||
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
|
||||
patFont=mainFont;
|
||||
bigFont=mainFont;
|
||||
if (rend) rend->destroyFontsTexture();
|
||||
if (!ImGui::GetIO().Fonts->Build()) {
|
||||
logE("error again while building font atlas!");
|
||||
}
|
||||
}
|
||||
|
||||
firstFrame=true;
|
||||
mustClear=2;
|
||||
initialScreenWipe=1.0f;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
bool fontsFailed=false;
|
||||
|
||||
layoutTimeBegin=SDL_GetPerformanceCounter();
|
||||
|
|
@ -5085,7 +5171,24 @@ bool FurnaceGUI::loop() {
|
|||
newSongQuery="";
|
||||
newSongFirstFrame=true;
|
||||
displayNew=false;
|
||||
ImGui::OpenPopup("New Song");
|
||||
if (settings.newSongBehavior==1) {
|
||||
e->createNewFromDefaults();
|
||||
undoHist.clear();
|
||||
redoHist.clear();
|
||||
curFileName="";
|
||||
modified=false;
|
||||
curNibble=false;
|
||||
orderNibble=false;
|
||||
orderCursor=-1;
|
||||
samplePos=0;
|
||||
updateSampleTex=true;
|
||||
selStart=SelectionPoint();
|
||||
selEnd=SelectionPoint();
|
||||
cursor=SelectionPoint();
|
||||
updateWindowTitle();
|
||||
} else {
|
||||
ImGui::OpenPopup("New Song");
|
||||
}
|
||||
}
|
||||
|
||||
if (displayPalette) {
|
||||
|
|
@ -5175,7 +5278,7 @@ bool FurnaceGUI::loop() {
|
|||
quit=true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
@ -5199,7 +5302,7 @@ bool FurnaceGUI::loop() {
|
|||
displayNew=true;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
@ -5223,7 +5326,7 @@ bool FurnaceGUI::loop() {
|
|||
openFileDialog(GUI_FILE_OPEN);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
@ -5247,7 +5350,7 @@ bool FurnaceGUI::loop() {
|
|||
openFileDialog(GUI_FILE_OPEN_BACKUP);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
@ -5278,7 +5381,7 @@ bool FurnaceGUI::loop() {
|
|||
nextFile="";
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
nextFile="";
|
||||
}
|
||||
|
|
@ -5332,7 +5435,7 @@ bool FurnaceGUI::loop() {
|
|||
syncSettings();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
@ -5419,7 +5522,7 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Wait! What am I doing? Cancel!")) {
|
||||
if (ImGui::Button("Wait! What am I doing? Cancel!") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
break;
|
||||
|
|
@ -5570,7 +5673,7 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::EndDisabled();
|
||||
ImGui::SameLine();
|
||||
}
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
for (std::pair<DivInstrument*,bool>& i: pendingIns) {
|
||||
i.second=false;
|
||||
}
|
||||
|
|
@ -5642,7 +5745,7 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Cancel")) {
|
||||
if (ImGui::Button("Cancel") || ImGui::IsKeyPressed(ImGuiKey_Escape)) {
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
|
@ -5683,6 +5786,17 @@ bool FurnaceGUI::loop() {
|
|||
introPos=12.0;
|
||||
}
|
||||
|
||||
#ifdef DIV_UNSTABLE
|
||||
{
|
||||
ImDrawList* dl=ImGui::GetForegroundDrawList();
|
||||
ImVec2 markPos=ImVec2(canvasW-ImGui::CalcTextSize(DIV_VERSION).x-6.0*dpiScale,4.0*dpiScale);
|
||||
ImVec4 markColor=uiColors[GUI_COLOR_TEXT];
|
||||
markColor.w=0.67f;
|
||||
|
||||
dl->AddText(markPos,ImGui::ColorConvertFloat4ToU32(markColor),DIV_VERSION);
|
||||
}
|
||||
#endif
|
||||
|
||||
layoutTimeEnd=SDL_GetPerformanceCounter();
|
||||
|
||||
// backup trigger
|
||||
|
|
@ -5761,13 +5875,12 @@ bool FurnaceGUI::loop() {
|
|||
if (outFile!=NULL) {
|
||||
if (fwrite(w->getFinalBuf(),1,w->size(),outFile)!=w->size()) {
|
||||
logW("did not write backup entirely: %s!",strerror(errno));
|
||||
w->finish();
|
||||
}
|
||||
fclose(outFile);
|
||||
} else {
|
||||
logW("could not save backup: %s!",strerror(errno));
|
||||
w->finish();
|
||||
}
|
||||
w->finish();
|
||||
|
||||
// delete previous backup if there are too many
|
||||
delFirstBackup(backupBaseName);
|
||||
|
|
@ -5891,6 +6004,7 @@ bool FurnaceGUI::loop() {
|
|||
ImGui::GetIO().Fonts->Clear();
|
||||
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
|
||||
patFont=mainFont;
|
||||
bigFont=mainFont;
|
||||
if (rend) rend->destroyFontsTexture();
|
||||
if (!ImGui::GetIO().Fonts->Build()) {
|
||||
logE("error again while building font atlas!");
|
||||
|
|
@ -6185,18 +6299,18 @@ bool FurnaceGUI::init() {
|
|||
logV("window size: %dx%d",scrW,scrH);
|
||||
|
||||
if (!initRender()) {
|
||||
if (settings.renderBackend!="SDL" && !settings.renderBackend.empty()) {
|
||||
settings.renderBackend="";
|
||||
e->setConf("renderBackend","");
|
||||
if (settings.renderBackend!="SDL") {
|
||||
settings.renderBackend="SDL";
|
||||
e->setConf("renderBackend","SDL");
|
||||
e->saveConf();
|
||||
lastError=fmt::sprintf("\r\nthe render backend has been set to a safe value. please restart Furnace.");
|
||||
lastError=fmt::sprintf("could not init renderer!\r\nthe render backend has been set to a safe value. please restart Furnace.");
|
||||
} else {
|
||||
lastError=fmt::sprintf("could not init renderer! %s",SDL_GetError());
|
||||
if (!settings.renderDriver.empty()) {
|
||||
settings.renderDriver="";
|
||||
e->setConf("renderDriver","");
|
||||
e->saveConf();
|
||||
lastError=fmt::sprintf("\r\nthe render driver has been set to a safe value. please restart Furnace.");
|
||||
lastError+=fmt::sprintf("\r\nthe render driver has been set to a safe value. please restart Furnace.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -6253,6 +6367,19 @@ bool FurnaceGUI::init() {
|
|||
}
|
||||
#endif
|
||||
|
||||
int numDriversA=SDL_GetNumAudioDrivers();
|
||||
if (numDriversA<0) {
|
||||
logW("could not list audio drivers! %s",SDL_GetError());
|
||||
} else {
|
||||
for (int i=0; i<numDriversA; i++) {
|
||||
const char* r=SDL_GetAudioDriver(i);
|
||||
if (r==NULL) continue;
|
||||
if (strcmp(r,"disk")==0) continue;
|
||||
if (strcmp(r,"dummy")==0) continue;
|
||||
availAudioDrivers.push_back(String(r));
|
||||
}
|
||||
}
|
||||
|
||||
int numDrivers=SDL_GetNumRenderDrivers();
|
||||
if (numDrivers<0) {
|
||||
logW("could not list render drivers! %s",SDL_GetError());
|
||||
|
|
@ -6271,18 +6398,18 @@ bool FurnaceGUI::init() {
|
|||
|
||||
logD("starting render backend...");
|
||||
if (!rend->init(sdlWin)) {
|
||||
if (settings.renderBackend!="SDL" && !settings.renderBackend.empty()) {
|
||||
settings.renderBackend="";
|
||||
//e->setConf("renderBackend","");
|
||||
//e->saveConf();
|
||||
//lastError=fmt::sprintf("\r\nthe render backend has been set to a safe value. please restart Furnace.");
|
||||
if (settings.renderBackend!="SDL") {
|
||||
settings.renderBackend="SDL";
|
||||
e->setConf("renderBackend","SDL");
|
||||
e->saveConf();
|
||||
lastError=fmt::sprintf("could not init renderer!\r\nthe render backend has been set to a safe value. please restart Furnace.");
|
||||
} else {
|
||||
lastError=fmt::sprintf("could not init renderer! %s",SDL_GetError());
|
||||
if (!settings.renderDriver.empty()) {
|
||||
settings.renderDriver="";
|
||||
e->setConf("renderDriver","");
|
||||
e->saveConf();
|
||||
lastError=fmt::sprintf("\r\nthe render driver has been set to a safe value. please restart Furnace.");
|
||||
lastError+=fmt::sprintf("\r\nthe render driver has been set to a safe value. please restart Furnace.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
@ -6319,6 +6446,8 @@ bool FurnaceGUI::init() {
|
|||
rend->present();
|
||||
|
||||
logD("preparing user interface...");
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
rend->initGUI(sdlWin);
|
||||
|
||||
applyUISettings();
|
||||
|
|
@ -6330,6 +6459,7 @@ bool FurnaceGUI::init() {
|
|||
ImGui::GetIO().Fonts->Clear();
|
||||
mainFont=ImGui::GetIO().Fonts->AddFontDefault();
|
||||
patFont=mainFont;
|
||||
bigFont=mainFont;
|
||||
if (rend) rend->destroyFontsTexture();
|
||||
if (!ImGui::GetIO().Fonts->Build()) {
|
||||
logE("error again while building font atlas!");
|
||||
|
|
@ -6556,8 +6686,8 @@ bool FurnaceGUI::finish() {
|
|||
commitState();
|
||||
rend->quitGUI();
|
||||
ImGui_ImplSDL2_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
quitRender();
|
||||
ImGui::DestroyContext();
|
||||
SDL_DestroyWindow(sdlWin);
|
||||
|
||||
if (vibrator) {
|
||||
|
|
@ -6575,6 +6705,10 @@ bool FurnaceGUI::finish() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void FurnaceGUI::requestQuit() {
|
||||
quit=true;
|
||||
}
|
||||
|
||||
FurnaceGUI::FurnaceGUI():
|
||||
e(NULL),
|
||||
renderBackend(GUI_BACKEND_SDL),
|
||||
|
|
@ -6601,6 +6735,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
portrait(false),
|
||||
injectBackUp(false),
|
||||
mobileMenuOpen(false),
|
||||
warnColorPushed(false),
|
||||
wantCaptureKeyboard(false),
|
||||
oldWantCaptureKeyboard(false),
|
||||
displayMacroMenu(false),
|
||||
|
|
@ -6617,6 +6752,7 @@ FurnaceGUI::FurnaceGUI():
|
|||
modTableHex(false),
|
||||
displayEditString(false),
|
||||
mobileEdit(false),
|
||||
killGraphics(false),
|
||||
vgmExportVersion(0x171),
|
||||
vgmExportTrailingTicks(-1),
|
||||
drawHalt(10),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue