#include "gtkutil/messagebox.h"
#include "gtkmisc.h"
+#define NETRADIANT_CUSTOM_FULLY_MERGED 0
+#if NETRADIANT_CUSTOM_FULLY_MERGED
+// For deleting old shortcuts.ini file
+#include "preferences.h"
+#include "unistd.h"
+#endif // NETRADIANT_CUSTOM_FULLY_MERGED
+
typedef std::pair<Accelerator, int> ShortcutValue; // accelerator, isRegistered
typedef std::map<CopiedString, ShortcutValue> Shortcuts;
const char* const COMMANDS_VERSION = "1.0-gtk-accelnames";
-void SaveCommandMap( const char* path ){
+void DeleteOldCommandMap(){
+#if NETRADIANT_CUSTOM_FULLY_MERGED
+// To enable when NetRadiant and NetRadiant-custom are fully merged together.
+ StringOutputStream path( 256 );
+ path << SettingsPath_get() << g_pGameDescription->mGameFile.c_str() << '/';
+ path << "shortcuts.ini";
+ unlink( path.c_str() );
+#endif
+}
+
+void SaveCommandMap(){
StringOutputStream strINI( 256 );
- strINI << path << "shortcuts.ini";
+ strINI << SettingsPath_get() << "shortcuts.ini";
TextFileOutputStream file( strINI.c_str() );
if ( !file.failed() ) {
} visitor( file );
GlobalShortcuts_foreach( visitor );
}
+
+ DeleteOldCommandMap();
}
const char* stringrange_find( const char* first, const char* last, char c ){
}
};
-void LoadCommandMap( const char* path ){
+void LoadCommandMap(){
StringOutputStream strINI( 256 );
- strINI << path << "shortcuts.ini";
+ strINI << SettingsPath_get() << "shortcuts.ini";
FILE* f = fopen( strINI.c_str(), "r" );
if ( f != 0 ) {
}
void user_shortcuts_init(){
- StringOutputStream path( 256 );
- path << SettingsPath_get() << g_pGameDescription->mGameFile.c_str() << '/';
- LoadCommandMap( path.c_str() );
- SaveCommandMap( path.c_str() );
+ LoadCommandMap();
+ SaveCommandMap();
}
void user_shortcuts_save(){
- StringOutputStream path( 256 );
- path << SettingsPath_get() << g_pGameDescription->mGameFile.c_str() << '/';
- SaveCommandMap( path.c_str() );
+ SaveCommandMap();
}
/* HACK: If ui::main is not called yet,