mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-23 21:15:11 +00:00
GUI: set path when opening file as cmdline arg
This commit is contained in:
parent
26cd33bae6
commit
ed15f01697
3 changed files with 30 additions and 0 deletions
|
@ -356,6 +356,31 @@ void FurnaceGUI::addScroll(int amount) {
|
||||||
nextAddScroll=lineHeight*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() {
|
void FurnaceGUI::updateWindowTitle() {
|
||||||
String type=getSystemName(e->song.system[0]);
|
String type=getSystemName(e->song.system[0]);
|
||||||
if (e->song.systemLen>1) type="multi-system";
|
if (e->song.systemLen>1) type="multi-system";
|
||||||
|
|
|
@ -396,6 +396,7 @@ class FurnaceGUI {
|
||||||
void bindEngine(DivEngine* eng);
|
void bindEngine(DivEngine* eng);
|
||||||
void updateScroll(int amount);
|
void updateScroll(int amount);
|
||||||
void addScroll(int amount);
|
void addScroll(int amount);
|
||||||
|
void setFileName(String name);
|
||||||
bool loop();
|
bool loop();
|
||||||
bool finish();
|
bool finish();
|
||||||
bool init();
|
bool init();
|
||||||
|
|
|
@ -383,6 +383,10 @@ int main(int argc, char** argv) {
|
||||||
g.bindEngine(&e);
|
g.bindEngine(&e);
|
||||||
if (!g.init()) return 1;
|
if (!g.init()) return 1;
|
||||||
|
|
||||||
|
if (!fileName.empty()) {
|
||||||
|
g.setFileName(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
g.loop();
|
g.loop();
|
||||||
logI("closing GUI.\n");
|
logI("closing GUI.\n");
|
||||||
g.finish();
|
g.finish();
|
||||||
|
|
Loading…
Reference in a new issue