#include "main.h"
#include "globaldefs.h"
-#include "version.h"
-
#include "debugging/debugging.h"
#include "iundo.h"
ScopedLock lock( m_lock );
if (GDEF_DEBUG) {
m_buffer << "Break into the debugger?\n";
- bool handled = ui::alert(ui::root, m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error) == ui::alert_response::NO;
+ bool handled = ui::alert(ui::root, m_buffer.c_str(), RADIANT_NAME " - Runtime Error", ui::alert_type::YESNO, ui::alert_icon::Error) == ui::alert_response::NO;
m_buffer.clear();
return handled;
} else {
m_buffer << "Please report this error to the developers\n";
- ui::alert(ui::root, m_buffer.c_str(), "Radiant - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error);
+ ui::alert(ui::root, m_buffer.c_str(), RADIANT_NAME " - Runtime Error", ui::alert_type::OK, ui::alert_icon::Error);
m_buffer.clear();
}
}
Q_mkdir( g_strSettingsPath.c_str() );
+ g_strAppFilePath = environment_get_app_filepath();
g_strAppPath = environment_get_app_path();
+ g_strLibPath = environment_get_lib_path();
+ g_strDataPath = environment_get_data_path();
// radiant is installed in the parent dir of "tools/"
// NOTE: this is not very easy for debugging
// (for now I had to create symlinks)
{
StringOutputStream path( 256 );
- path << g_strAppPath.c_str() << "bitmaps/";
+ path << g_strDataPath.c_str() << "bitmaps/";
BitmapsPath_set( path.c_str() );
}
// we will set this right after the game selection is done
- g_strGameToolsPath = g_strAppPath;
+ g_strGameToolsPath = g_strDataPath;
}
bool check_version_file( const char* filename, const char* version ){
if ( remove( g_pidFile.c_str() ) == -1 ) {
StringOutputStream msg( 256 );
msg << "WARNING: Could not delete " << g_pidFile.c_str();
- ui::alert( ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::alert( ui::root, msg.c_str(), RADIANT_NAME, ui::alert_type::OK, ui::alert_icon::Error );
}
// in debug, never prompt to clean registry, turn console logging auto after a failed start
if (!GDEF_DEBUG) {
StringOutputStream msg(256);
- msg << "Radiant failed to start properly the last time it was run.\n"
+ msg << RADIANT_NAME " failed to start properly the last time it was run.\n"
"The failure may be related to current global preferences.\n"
"Do you want to reset global preferences to defaults?";
- if (ui::alert(ui::root, msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question) == ui::alert_response::YES) {
+ if (ui::alert(ui::root, msg.c_str(), RADIANT_NAME " - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question) == ui::alert_response::YES) {
g_GamesDialog.Reset();
}
msg.clear();
msg << "Logging console output to " << SettingsPath_get()
- << "radiant.log\nRefer to the log if Radiant fails to start again.";
+ << "radiant.log\nRefer to the log if " RADIANT_NAME " fails to start again.";
- ui::alert(ui::root, msg.c_str(), "Radiant - Console Log", ui::alert_type::OK);
+ ui::alert(ui::root, msg.c_str(), RADIANT_NAME " - Console Log", ui::alert_type::OK);
}
// set without saving, the class is not in a coherent state yet
// just do the value change and call to start logging, CGamesDialog will pickup when relevant
g_GamesDialog.m_bForceLogConsole = true;
- Sys_LogFile( true );
+ Sys_EnableLogFile( true );
}
// create a primary .pid for global init run
if ( remove( g_pidFile.c_str() ) == -1 ) {
StringOutputStream msg( 256 );
msg << "WARNING: Could not delete " << g_pidFile.c_str();
- ui::alert( ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::alert( ui::root, msg.c_str(), RADIANT_NAME, ui::alert_type::OK, ui::alert_icon::Error );
}
}
if ( remove( g_pidGameFile.c_str() ) == -1 ) {
StringOutputStream msg;
msg << "WARNING: Could not delete " << g_pidGameFile.c_str();
- ui::alert( ui::root, msg.c_str(), "Radiant", ui::alert_type::OK, ui::alert_icon::Error );
+ ui::alert( ui::root, msg.c_str(), RADIANT_NAME, ui::alert_type::OK, ui::alert_icon::Error );
}
// in debug, never prompt to clean registry, turn console logging auto after a failed start
if (!GDEF_DEBUG) {
StringOutputStream msg;
- msg << "Radiant failed to start properly the last time it was run.\n"
+ msg << RADIANT_NAME " failed to start properly the last time it was run.\n"
"The failure may be caused by current preferences.\n"
"Do you want to reset all preferences to defaults?";
- if (ui::alert(ui::root, msg.c_str(), "Radiant - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question) == ui::alert_response::YES) {
+ if (ui::alert(ui::root, msg.c_str(), RADIANT_NAME " - Startup Failure", ui::alert_type::YESNO, ui::alert_icon::Question) == ui::alert_response::YES) {
Preferences_Reset();
}
msg.clear();
msg << "Logging console output to " << SettingsPath_get()
- << "radiant.log\nRefer to the log if Radiant fails to start again.";
+ << "radiant.log\nRefer to the log if " RADIANT_NAME " fails to start again.";
- ui::alert(ui::root, msg.c_str(), "Radiant - Console Log", ui::alert_type::OK);
+ ui::alert(ui::root, msg.c_str(), RADIANT_NAME " - Console Log", ui::alert_type::OK);
}
// force console logging on! (will go in prefs too)
g_GamesDialog.m_bForceLogConsole = true;
- Sys_LogFile( true );
+ Sys_EnableLogFile( true );
}
else
{
SaveCommandMap( path.c_str() );
}
+void add_local_rc_files(){
+#define GARUX_DISABLE_GTKTHEME
+#ifndef GARUX_DISABLE_GTKTHEME
+/* FIXME: HACK: not GTK3 compatible
+ https://developer.gnome.org/gtk2/stable/gtk2-Resource-Files.html#gtk-rc-add-default-file
+ https://developer.gnome.org/gtk3/stable/gtk3-Resource-Files.html#gtk-rc-add-default-file
+ > gtk_rc_add_default_file has been deprecated since version 3.0 and should not be used in newly-written code.
+ > Use GtkStyleContext with a custom GtkStyleProvider instead
+*/
+
+ {
+ StringOutputStream path( 512 );
+ path << AppPath_get() << ".gtkrc-2.0.radiant";
+ gtk_rc_add_default_file( path.c_str() );
+ }
+#ifdef WIN32
+ {
+ StringOutputStream path( 512 );
+ path << AppPath_get() << ".gtkrc-2.0.win";
+ gtk_rc_add_default_file( path.c_str() );
+ }
+#endif
+#endif // GARUX_DISABLE_GTKTHEME
+}
+
+/* HACK: If ui::main is not called yet,
+gtk_main_quit will not quit, so tell main
+to not call ui::main. This happens when a
+map is loaded from command line and require
+a restart because of wrong format.
+Delete this when the code to not have to
+restart to load another format is merged. */
+bool g_dontStart = false;
+
int main( int argc, char* argv[] ){
+#if GTK_TARGET == 3
+ // HACK: force legacy GL backend as we don't support GL3 yet
+ setenv("GDK_GL", "LEGACY", 0);
+#if GDEF_OS_LINUX || GDEF_OS_BSD
+ setenv("GDK_BACKEND", "x11", 0);
+#endif
+#endif // GTK_TARGET == 3
crt_init();
streams_init();
if ( lib != 0 ) {
void ( WINAPI *qDwmEnableComposition )( bool bEnable ) = ( void (WINAPI *) ( bool bEnable ) )GetProcAddress( lib, "DwmEnableComposition" );
if ( qDwmEnableComposition ) {
- qDwmEnableComposition( FALSE );
+ bool Aero = false;
+ for ( int i = 1; i < argc; ++i ){
+ if ( !stricmp( argv[i], "-aero" ) ){
+ Aero = true;
+ qDwmEnableComposition( TRUE );
+ break;
+ }
+ }
+ // disable Aero
+ if ( !Aero ){
+ qDwmEnableComposition( FALSE );
+ }
}
FreeLibrary( lib );
}
+ _setmaxstdio(2048);
#endif
const char* mapname = NULL;
+
+#if GDEF_OS_WINDOWS
+ StringOutputStream mapname_buffer( 256 );
+#endif
+
char const *error = NULL;
+
if ( !ui::init( &argc, &argv, "<filename.map>", &error) ) {
g_print( "%s\n", error );
return -1;
// Gtk already removed parsed `--options`
if (argc == 2) {
if ( strlen( argv[1] ) > 1 ) {
- if ( g_str_has_suffix( argv[1], ".map" ) ) {
- if ( g_path_is_absolute( argv[1] ) ) {
mapname = argv[1];
+
+ if ( g_str_has_suffix( mapname, ".map" ) ) {
+ if ( !g_path_is_absolute( mapname ) ) {
+ mapname = g_build_filename( g_get_current_dir(), mapname, NULL );
}
- else {
- mapname = g_build_filename( g_get_current_dir(), argv[1], NULL );
- }
+
+#if GDEF_OS_WINDOWS
+ mapname_buffer << PathCleaned( mapname );
+ mapname = mapname_buffer.c_str();
+#endif
}
else {
- g_print( "bad file name, will not load: %s\n", argv[1] );
+ g_print( "bad file name, will not load: %s\n", mapname );
+ mapname = NULL;
}
}
}
paths_init();
+ add_local_rc_files();
+
show_splash();
create_global_pid();
// we may have the console turned on and want to keep it that way
// so we use a latching system
if ( g_GamesDialog.m_bForceLogConsole ) {
- Sys_LogFile( true );
+ Sys_EnableLogFile( true );
g_Console_enableLogging = true;
g_GamesDialog.m_bForceLogConsole = false;
}
hide_splash();
- if ( mapname != NULL ) {
+ if( openCmdMap && *openCmdMap ){
+ Map_LoadFile( openCmdMap );
+ }
+ else if ( mapname != NULL ) {
Map_LoadFile( mapname );
}
else if ( g_bLoadLastMap && !g_strLastMap.empty() ) {
remove_local_pid();
+ /* HACK: If ui::main is not called yet,
+ gtk_main_quit will not quit, so tell main
+ to not call ui::main. This happens when a
+ map is loaded from command line and require
+ a restart because of wrong format.
+ Delete this when the code to not have to
+ restart to load another format is merged. */
+ if ( !g_dontStart )
+ {
ui::main();
+ }
// avoid saving prefs when the app is minimized
if ( g_pParentWnd->IsSleeping() ) {
Radiant_Shutdown();
// close the log file if any
- Sys_LogFile( false );
+ Sys_EnableLogFile( false );
return EXIT_SUCCESS;
}