]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge pull request #47 from mrwonko/MapLoading
authorTimothee "TTimo" Besset <ttimo@ttimo.net>
Sun, 6 May 2012 18:21:44 +0000 (11:21 -0700)
committerTimothee "TTimo" Besset <ttimo@ttimo.net>
Sun, 6 May 2012 18:21:44 +0000 (11:21 -0700)
Ability to open .map files with Radiant

radiant/main.cpp
radiant/mainframe.cpp
radiant/mainframe.h

index 2fa5221419e921720380c648aa507a1ccda815a2..ede1426f540ba8372647f16cc38d5ef67fe75d6c 100644 (file)
@@ -894,7 +894,11 @@ int main( int argc, char* argv[] ) {
 
        g_pParentWnd = new MainFrame();
 
-       if ( g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0 ) {
+       // If the first parameter is a .map, load that.
+       if( g_argc > 1 && IsMap( g_argv[1] ) ){
+               Map_LoadFile( g_argv[1] );
+       }
+       else if ( g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0 ) {
                Map_LoadFile( g_PrefsDlg.m_strLastMap.GetBuffer() );
        }
        else {
index cb62e79a4ae97df6b99f784d069ae8222a7c4682..27307a72d523363ee6d78efed0988f8e2172e50d 100644 (file)
@@ -3621,9 +3621,14 @@ void MainFrame::ShowMenuItemKeyBindings( GtkWidget* window ){
        }
 }
 
+// Checks whether a given filename ends in .map
+const bool IsMap(const char* filename){
+       return strlen(filename) >= 4 && strcmp(filename + strlen(filename) - 4, ".map") == 0;
+}
+
 void MainFrame::CreateQEChildren(){
-       // load the project file
-       if ( g_argc > 1 ) {
+       // load the project file, if it is a project file. (Or at least no .map)
+       if ( g_argc > 1 && !IsMap( g_argv[1] ) ) {
                Sys_Printf( "loading project file from the command line: %s\n", g_argv[1] );
                if ( !QE_LoadProject( g_argv[1] ) ) {
                        Error( "Unable to load project file %s\n", g_argv[1] );
index e72adc4c210ec1865a42e6981773272cd49fbd54..3caf58407c31b74f4d00e15e1dcf7cc403b383bc 100644 (file)
@@ -908,4 +908,7 @@ int gdk_offset_y;
 // some C API to the mainframe functions
 void WINAPI QERApp_Sleep();
 
+// Checks whether a given filename ends in .map
+const bool IsMap(const char* filename);
+
 #endif // _MAINFRAME_H_