mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-22 20:45:11 +00:00
GUI: code split, part 4
gui.cpp now 5600 lines
This commit is contained in:
parent
dde2849a16
commit
f735617ee3
5 changed files with 1309 additions and 1227 deletions
|
@ -328,6 +328,8 @@ src/gui/guiConst.cpp
|
||||||
src/gui/insEdit.cpp
|
src/gui/insEdit.cpp
|
||||||
src/gui/orders.cpp
|
src/gui/orders.cpp
|
||||||
src/gui/pattern.cpp
|
src/gui/pattern.cpp
|
||||||
|
src/gui/settings.cpp
|
||||||
|
src/gui/util.cpp
|
||||||
src/gui/gui.cpp
|
src/gui/gui.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
1229
src/gui/gui.cpp
1229
src/gui/gui.cpp
File diff suppressed because it is too large
Load diff
1168
src/gui/settings.cpp
Normal file
1168
src/gui/settings.cpp
Normal file
File diff suppressed because it is too large
Load diff
104
src/gui/util.cpp
Normal file
104
src/gui/util.cpp
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <shlwapi.h>
|
||||||
|
#include "../utfutils.h"
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
String getHomeDir() {
|
||||||
|
String ret;
|
||||||
|
char tempDir[4096];
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
char* up=getenv("USERPROFILE");
|
||||||
|
if (up!=NULL) {
|
||||||
|
ret=up;
|
||||||
|
ret+='\\';
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
char* home=getenv("HOME");
|
||||||
|
if (home!=NULL) {
|
||||||
|
ret=home;
|
||||||
|
ret+='/';
|
||||||
|
} else {
|
||||||
|
int uid=getuid();
|
||||||
|
struct passwd* entry=getpwuid(uid);
|
||||||
|
if (entry!=NULL) {
|
||||||
|
if (entry->pw_dir!=NULL) {
|
||||||
|
ret=entry->pw_dir;
|
||||||
|
ret+='/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (ret=="") { // fallback
|
||||||
|
#ifdef _WIN32
|
||||||
|
GetCurrentDirectory(4095,tempDir);
|
||||||
|
ret=tempDir;
|
||||||
|
ret+='\\';
|
||||||
|
#else
|
||||||
|
char* unused=getcwd(tempDir,4095);
|
||||||
|
char* unused1=unused; // dang it compiler
|
||||||
|
unused=unused1;
|
||||||
|
ret=tempDir;
|
||||||
|
ret+='/';
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
String getKeyName(int key, bool emptyNone) {
|
||||||
|
if (key==0) {
|
||||||
|
if (emptyNone) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return "<nothing>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String ret;
|
||||||
|
if (key&FURKMOD_CTRL) ret+="Ctrl-";
|
||||||
|
if (key&FURKMOD_META) ret+=META_MODIFIER_NAME;
|
||||||
|
if (key&FURKMOD_ALT) ret+="Alt-";
|
||||||
|
if (key&FURKMOD_SHIFT) ret+="Shift-";
|
||||||
|
if ((key&FURK_MASK)==0xffffff) {
|
||||||
|
ret+="...";
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
const char* name=SDL_GetKeyName(key&FURK_MASK);
|
||||||
|
if (name==NULL) {
|
||||||
|
ret+="Unknown";
|
||||||
|
} else if (name[0]==0) {
|
||||||
|
ret+="Unknown";
|
||||||
|
} else {
|
||||||
|
ret+=name;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
33
src/gui/util.h
Normal file
33
src/gui/util.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../ta-utils.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define META_MODIFIER_NAME "Win-"
|
||||||
|
#else
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#define META_MODIFIER_NAME "Cmd-"
|
||||||
|
#else
|
||||||
|
#define META_MODIFIER_NAME "Meta-"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
String getHomeDir();
|
||||||
|
String getKeyName(int key, bool emptyNone=false);
|
Loading…
Reference in a new issue