diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index f1cdca248..271dc208e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -356,6 +356,31 @@ void FurnaceGUI::addScroll(int amount) { nextAddScroll=lineHeight*amount; } +void FurnaceGUI::setFileName(String name) { +#ifdef _WIN32 + wchar_t ret[4096]; + WString ws=utf8To16(name.c_str()); + int index=0; + for (wchar_t& i: ws) { + ret[index++]=i; + if (index>=4095) break; + } + ret[index]=0; + if (GetFullPathNameW(ws.c_str(),4095,ret,NULL)==0) { + curFileName=name; + } else { + curFileName=utf16To8(ret); + } +#else + char ret[4096]; + if (realpath(name.c_str(),ret)==NULL) { + curFileName=name; + } else { + curFileName=ret; + } +#endif +} + void FurnaceGUI::updateWindowTitle() { String type=getSystemName(e->song.system[0]); if (e->song.systemLen>1) type="multi-system"; diff --git a/src/gui/gui.h b/src/gui/gui.h index a03568e00..cac707abe 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -396,6 +396,7 @@ class FurnaceGUI { void bindEngine(DivEngine* eng); void updateScroll(int amount); void addScroll(int amount); + void setFileName(String name); bool loop(); bool finish(); bool init(); diff --git a/src/main.cpp b/src/main.cpp index 0f59e955f..730a091c4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -383,6 +383,10 @@ int main(int argc, char** argv) { g.bindEngine(&e); if (!g.init()) return 1; + if (!fileName.empty()) { + g.setFileName(fileName); + } + g.loop(); logI("closing GUI.\n"); g.finish();