]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/map.cpp
Merge commit 'f472e6f0e8066e62cf3e159287bb07de97d2e59d' into master-merge
[xonotic/netradiant.git] / radiant / map.cpp
index a192231e30e63b02a911a9dd8af3d19425087cb7..86fd37d42c721f5664248da01bf62b4b55b3adae 100644 (file)
@@ -966,6 +966,8 @@ void Map_LoadFile( const char *filename ){
        MRU_AddFile( filename );
        g_strLastMapFolder = g_path_get_dirname( filename );
 
+       bool switch_format = false;
+
        {
                ScopeTimer timer( "map load" );
 
@@ -992,6 +994,7 @@ void Map_LoadFile( const char *filename ){
                                if ( !format->wrongFormat ) {
                                        break;
                                }
+                               switch_format = !switch_format;
                        }
                }
 
@@ -1012,6 +1015,8 @@ void Map_LoadFile( const char *filename ){
        Map_StartPosition();
 
        g_currentMap = &g_map;
+
+       Brush_switchFormat( switch_format );
 }
 
 class Excluder
@@ -1316,7 +1321,17 @@ void ConstructRegionStartpoint( scene::Node* startpoint, const Vector3& region_m
 
    ===========================================================
  */
-bool region_active;
+bool region_active = false;
+
+ConstReferenceCaller<bool, void(const Callback<void(bool)> &), PropertyImpl<bool>::Export> g_region_caller( region_active );
+
+ToggleItem g_region_item( g_region_caller );
+
+/*void Map_ToggleRegion(){
+       region_active = !region_active;
+       g_region_item.update();
+}*/
+
 Vector3 region_mins( g_MinWorldCoord, g_MinWorldCoord, g_MinWorldCoord );
 Vector3 region_maxs( g_MaxWorldCoord, g_MaxWorldCoord, g_MaxWorldCoord );
 
@@ -1443,6 +1458,7 @@ void Scene_Exclude_Region( bool exclude ){
  */
 void Map_RegionOff(){
        region_active = false;
+       g_region_item.update();
 
        region_maxs[0] = g_MaxWorldCoord - 64;
        region_mins[0] = g_MinWorldCoord + 64;
@@ -1456,6 +1472,7 @@ void Map_RegionOff(){
 
 void Map_ApplyRegion( void ){
        region_active = true;
+       g_region_item.update();
 
        Scene_Exclude_Region( false );
 }
@@ -1472,6 +1489,7 @@ void Map_RegionSelectedBrushes( void ){
        if ( GlobalSelectionSystem().countSelected() != 0
                 && GlobalSelectionSystem().Mode() == SelectionSystem::ePrimitive ) {
                region_active = true;
+               g_region_item.update();
                Select_GetBounds( region_mins, region_maxs );
 
                Scene_Exclude_Selected( false );
@@ -1578,54 +1596,55 @@ tryDecompile:
        const char *type = GlobalRadiant().getGameDescriptionKeyValue( "q3map2_type" );
        int n = string_length( path_get_extension( filename ) );
        if ( n && ( extension_equal( path_get_extension( filename ), "bsp" ) || extension_equal( path_get_extension( filename ), "map" ) ) ) {
-               StringBuffer output;
-               output.push_string( AppPath_get() );
-               output.push_string( "q3map2." );
-               output.push_string( RADIANT_EXECUTABLE );
-               output.push_string( " -v -game " );
-               output.push_string( ( type && *type ) ? type : "quake3" );
-               output.push_string( " -fs_basepath \"" );
-               output.push_string( EnginePath_get() );
-               output.push_string( "\" -fs_homepath \"" );
-               output.push_string( g_qeglobals.m_userEnginePath.c_str() );
-               output.push_string( "\"" );
+               std::string output;
+               output += AppPath_get();
+               output += "q3map2";
+               output += GDEF_OS_EXE_EXT;
+
+               output += " -v -game ";
+               output += ( type && *type ) ? type : "quake3";
+               output += " -fs_basepath \"";
+               output += EnginePath_get();
+               output += "\" -fs_homepath \"";
+               output += g_qeglobals.m_userEnginePath.c_str();
+               output += "\"";
 
                // extra pakpaths
                for ( int i = 0; i < g_pakPathCount; i++ ) {
                        if ( g_strcmp0( g_strPakPath[i].c_str(), "") ) {
-                               output.push_string( " -fs_pakpath \"" );
-                               output.push_string( g_strPakPath[i].c_str() );
-                               output.push_string( "\"" );
+                               output += " -fs_pakpath \"";
+                               output += g_strPakPath[i].c_str();
+                               output += "\"";
                        }
                }
 
                // extra switches
                if ( g_disableEnginePath ) {
-                       output.push_string( " -fs_nobasepath " );
+                       output += " -fs_nobasepath ";
                }
 
                if ( g_disableHomePath ) {
-                       output.push_string( " -fs_nohomepath " );
+                       output += " -fs_nohomepath ";
                }
 
-               output.push_string( " -fs_game " );
-               output.push_string( gamename_get() );
-               output.push_string( " -convert -format " );
-               output.push_string( Brush::m_type == eBrushTypeQuake3BP ? "map_bp" : "map" );
+               output += " -fs_game ";
+               output += gamename_get();
+               output += " -convert -format ";
+               output += Brush::m_type == eBrushTypeQuake3BP ? "map_bp" : "map";
                if ( extension_equal( path_get_extension( filename ), "map" ) ) {
-                       output.push_string( " -readmap " );
+                       output += " -readmap ";
                }
-               output.push_string( " \"" );
-               output.push_string( filename );
-               output.push_string( "\"" );
+               output += " \"";
+               output += filename;
+               output += "\"";
 
                // run
                Q_Exec( NULL, output.c_str(), NULL, false, true );
 
                // rebuild filename as "filenamewithoutext_converted.map"
-               output.clear();
-               output.push_range( filename, filename + string_length( filename ) - ( n + 1 ) );
-               output.push_string( "_converted.map" );
+               output = "";
+               output.append( filename, string_length( filename ) - ( n + 1 ) );
+               output += "_converted.map";
                filename = output.c_str();
 
                // open
@@ -1943,6 +1962,7 @@ void SaveMap(){
        }
        else if ( Map_Modified( g_map ) ) {
                Map_Save();
+               MRU_AddFile( g_map.m_name.c_str() );    //add on saving, but not opening via cmd line: spoils the list
        }
 }
 
@@ -2262,7 +2282,8 @@ void Map_Construct(){
        GlobalCommands_insert( "RegionOff", makeCallbackF(RegionOff) );
        GlobalCommands_insert( "RegionSetXY", makeCallbackF(RegionXY) );
        GlobalCommands_insert( "RegionSetBrush", makeCallbackF(RegionBrush) );
-       GlobalCommands_insert( "RegionSetSelection", makeCallbackF(RegionSelected), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       //GlobalCommands_insert( "RegionSetSelection", makeCallbackF(RegionSelected), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+       GlobalToggles_insert( "RegionSetSelection", makeCallbackF(RegionSelected), ToggleItem::AddCallbackCaller( g_region_item ), Accelerator( 'R', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
 
        GlobalPreferenceSystem().registerPreference( "LastMap", make_property_string( g_strLastMap ) );
        GlobalPreferenceSystem().registerPreference( "LoadLastMap", make_property_string( g_bLoadLastMap ) );