From: Thomas Debesse Date: Mon, 11 Feb 2019 14:44:28 +0000 (+0100) Subject: Merge commit 'f8b2b1f25e7e195c0c11e3d2e2ddf308562de77f' into garux-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ee4b663ef7227a42b5eb051698265bed514ab3c0;p=xonotic%2Fnetradiant.git Merge commit 'f8b2b1f25e7e195c0c11e3d2e2ddf308562de77f' into garux-merge --- ee4b663ef7227a42b5eb051698265bed514ab3c0 diff --cc radiant/main.cpp index f19bec37,f19eb4db..e338baeb --- a/radiant/main.cpp +++ b/radiant/main.cpp @@@ -550,35 -559,11 +550,36 @@@ int main( int argc, char* argv[] ) } FreeLibrary( lib ); } + _setmaxstdio(2048); #endif - gtk_disable_setlocale(); - gtk_init( &argc, &argv ); + const char* mapname = NULL; + char const *error = NULL; + if ( !ui::init( &argc, &argv, "", &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]; + } + else { + mapname = g_build_filename( g_get_current_dir(), argv[1], NULL ); + } + } + else { + g_print( "bad file name, will not load: %s\n", argv[1] ); + } + } + } + else if (argc > 2) { + g_print ( "%s\n", "too many arguments" ); + return -1; + } // redirect Gtk warnings to the console g_log_set_handler( "Gdk", (GLogLevelFlags)( G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | diff --cc radiant/patchmanip.cpp index 7ae19fb4,9ea7c5d8..15faff88 --- a/radiant/patchmanip.cpp +++ b/radiant/patchmanip.cpp @@@ -145,8 -112,20 +145,9 @@@ void Patch_makeCaps( Patch& patch, scen } } + typedef std::vector InstanceVector; -class PatchStoreInstance -{ -InstanceVector& m_instances; -public: -PatchStoreInstance( InstanceVector& instances ) : m_instances( instances ){ -} -void operator()( PatchInstance& patch ) const { - m_instances.push_back( &patch ); -} -}; - enum ECapDialog { PATCHCAP_BEVEL = 0, PATCHCAP_ENDCAP, @@@ -195,6 -172,30 +196,32 @@@ void Scene_PatchDoCap_Selected( scene:: } } + void Patch_deform( Patch& patch, scene::Instance& instance, const int deform ){ + patch.undoSave(); + + for (PatchControlIter i = patch.begin(); i != patch.end(); ++i) + { + PatchControl& control = *i; + int randomNumber = int( deform * (float(std::rand()) / float(RAND_MAX))); + control.m_vertex[2] += randomNumber; + } + + patch.controlPointsChanged(); + } + + void Scene_PatchDeform( scene::Graph& graph, const int deform ) + { + InstanceVector instances; - Scene_forEachVisibleSelectedPatchInstance( PatchStoreInstance( instances ) ); ++ Scene_forEachVisibleSelectedPatchInstance([&](PatchInstance &patch) { ++ instances.push_back(&patch); ++ }); + for ( InstanceVector::const_iterator i = instances.begin(); i != instances.end(); ++i ) + { + Patch_deform( *Node_getPatch( ( *i )->path().top() ), *( *i ), deform ); + } + + } + Patch* Scene_GetUltimateSelectedVisiblePatch(){ if ( GlobalSelectionSystem().countSelected() != 0 ) { scene::Node& node = GlobalSelectionSystem().ultimateSelected().path().top(); @@@ -523,26 -610,17 +550,34 @@@ void Patch_NaturalTexture() Scene_PatchNaturalTexture_Selected( GlobalSceneGraph() ); } +void Patch_CapTexture(){ + UndoableCommand command( "patchCapTexture" ); + + Scene_PatchCapTexture_Selected( GlobalSceneGraph() ); +} + +void Patch_ResetTexture(){ + float fx, fy; + if ( DoTextureLayout( &fx, &fy ) == eIDOK ) { + UndoableCommand command( "patchTileTexture" ); + Scene_PatchTileTexture_Selected( GlobalSceneGraph(), fx, fy ); + } +} + +void Patch_FitTexture(){ + UndoableCommand command( "patchFitTexture" ); + + Scene_PatchTileTexture_Selected( GlobalSceneGraph(), 1, 1 ); +} + + void DoPatchDeformDlg(); + + void Patch_Deform(){ + UndoableCommand undo( "patchDeform" ); + + DoPatchDeformDlg(); + } + - - - #include "ifilter.h" @@@ -614,55 -692,56 +649,56 @@@ void PatchPreferences_construct() #include "generic/callback.h" void Patch_registerCommands(){ - GlobalCommands_insert( "InvertCurveTextureX", FreeCaller(), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "InvertCurveTextureY", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "IncPatchColumn", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "IncPatchRow", FreeCaller(), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "DecPatchColumn", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "DecPatchRow", FreeCaller(), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "NaturalizePatch", FreeCaller(), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PatchCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchDenseCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchVeryDenseCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchSquareCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchXactCylinder", FreeCaller() ); - GlobalCommands_insert( "PatchXactSphere", FreeCaller() ); - GlobalCommands_insert( "PatchXactCone", FreeCaller() ); - GlobalCommands_insert( "PatchEndCap", FreeCaller() ); - GlobalCommands_insert( "PatchBevel", FreeCaller() ); - GlobalCommands_insert( "PatchSquareBevel", FreeCaller() ); - GlobalCommands_insert( "PatchSquareEndcap", FreeCaller() ); - GlobalCommands_insert( "PatchCone", FreeCaller() ); - GlobalCommands_insert( "PatchSphere", FreeCaller() ); - GlobalCommands_insert( "SimplePatchMesh", FreeCaller(), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "PatchInsertInsertColumn", FreeCaller() ); - GlobalCommands_insert( "PatchInsertAddColumn", FreeCaller() ); - GlobalCommands_insert( "PatchInsertInsertRow", FreeCaller() ); - GlobalCommands_insert( "PatchInsertAddRow", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteFirstColumn", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastColumn", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteFirstRow", FreeCaller() ); - GlobalCommands_insert( "PatchDeleteLastRow", FreeCaller() ); - GlobalCommands_insert( "InvertCurve", FreeCaller(), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "RedisperseRows", FreeCaller(), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "RedisperseCols", FreeCaller(), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "SmoothRows", FreeCaller(), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "SmoothCols", FreeCaller(), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "MatrixTranspose", FreeCaller(), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); - GlobalCommands_insert( "CapCurrentCurve", FreeCaller(), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "CycleCapTexturePatch", FreeCaller(), Accelerator( 'N', (GdkModifierType)GDK_SHIFT_MASK ) ); - GlobalCommands_insert( "MakeOverlayPatch", FreeCaller(), Accelerator( 'Y' ) ); - GlobalCommands_insert( "ClearPatchOverlays", FreeCaller(), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) ); - GlobalCommands_insert( "PatchDeform", FreeCaller() ); -} - -void Patch_constructToolbar( GtkToolbar* toolbar ){ - toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "curve_cap.bmp", "CapCurrentCurve" ); -} - -void Patch_constructMenu( GtkMenu* menu ){ + GlobalCommands_insert( "InvertCurveTextureX", makeCallbackF(Patch_FlipTextureX), Accelerator( 'I', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "InvertCurveTextureY", makeCallbackF(Patch_FlipTextureY), Accelerator( 'I', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "IncPatchColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "IncPatchRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "DecPatchColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "DecPatchRow", makeCallbackF(Patch_DeleteLastRow), Accelerator( GDK_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "NaturalizePatch", makeCallbackF(Patch_NaturalTexture), Accelerator( 'N', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchCylinder", makeCallbackF(Patch_Cylinder) ); + GlobalCommands_insert( "PatchDenseCylinder", makeCallbackF(Patch_DenseCylinder) ); + GlobalCommands_insert( "PatchVeryDenseCylinder", makeCallbackF(Patch_VeryDenseCylinder) ); + GlobalCommands_insert( "PatchSquareCylinder", makeCallbackF(Patch_SquareCylinder) ); + GlobalCommands_insert( "PatchXactCylinder", makeCallbackF(Patch_XactCylinder) ); + GlobalCommands_insert( "PatchXactSphere", makeCallbackF(Patch_XactSphere) ); + GlobalCommands_insert( "PatchXactCone", makeCallbackF(Patch_XactCone) ); + GlobalCommands_insert( "PatchEndCap", makeCallbackF(Patch_Endcap) ); + GlobalCommands_insert( "PatchBevel", makeCallbackF(Patch_Bevel) ); + GlobalCommands_insert( "PatchSquareBevel", makeCallbackF(Patch_SquareBevel) ); + GlobalCommands_insert( "PatchSquareEndcap", makeCallbackF(Patch_SquareEndcap) ); + GlobalCommands_insert( "PatchCone", makeCallbackF(Patch_Cone) ); + GlobalCommands_insert( "PatchSphere", makeCallbackF(Patch_Sphere) ); + GlobalCommands_insert( "SimplePatchMesh", makeCallbackF(Patch_Plane), Accelerator( 'P', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "PatchInsertInsertColumn", makeCallbackF(Patch_InsertInsertColumn), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchInsertAddColumn", makeCallbackF(Patch_InsertAddColumn) ); + GlobalCommands_insert( "PatchInsertInsertRow", makeCallbackF(Patch_InsertInsertRow), Accelerator( GDK_KEY_KP_Add, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchInsertAddRow", makeCallbackF(Patch_InsertAddRow) ); + GlobalCommands_insert( "PatchDeleteFirstColumn", makeCallbackF(Patch_DeleteFirstColumn) ); + GlobalCommands_insert( "PatchDeleteLastColumn", makeCallbackF(Patch_DeleteLastColumn), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "PatchDeleteFirstRow", makeCallbackF(Patch_DeleteFirstRow), Accelerator( GDK_KEY_KP_Subtract, (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "PatchDeleteLastRow", makeCallbackF(Patch_DeleteLastRow) ); + GlobalCommands_insert( "InvertCurve", makeCallbackF(Patch_Invert), Accelerator( 'I', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "RedisperseRows", makeCallbackF(Patch_RedisperseRows), Accelerator( 'E', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "RedisperseCols", makeCallbackF(Patch_RedisperseCols), Accelerator( 'E', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "SmoothRows", makeCallbackF(Patch_SmoothRows), Accelerator( 'W', (GdkModifierType)GDK_CONTROL_MASK ) ); + GlobalCommands_insert( "SmoothCols", makeCallbackF(Patch_SmoothCols), Accelerator( 'W', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "MatrixTranspose", makeCallbackF(Patch_Transpose), Accelerator( 'M', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "CapCurrentCurve", makeCallbackF(Patch_Cap), Accelerator( 'C', (GdkModifierType)GDK_SHIFT_MASK ) ); + GlobalCommands_insert( "CycleCapTexturePatch", makeCallbackF(Patch_CycleProjection), Accelerator( 'N', (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) ); + GlobalCommands_insert( "MakeOverlayPatch", makeCallbackF(Patch_OverlayOn), Accelerator( 'Y' ) ); + GlobalCommands_insert( "ClearPatchOverlays", makeCallbackF(Patch_OverlayOff), Accelerator( 'L', (GdkModifierType)GDK_CONTROL_MASK ) ); ++ GlobalCommands_insert( "PatchDeform", makeCallbackF(Patch_Deform) ); +} + +void Patch_constructToolbar( ui::Toolbar toolbar ){ + toolbar_append_button( toolbar, "Put caps on the current patch (SHIFT + C)", "cap_curve.png", "CapCurrentCurve" ); +} + +void Patch_constructMenu( ui::Menu menu ){ create_menu_item_with_mnemonic( menu, "Cylinder", "PatchCylinder" ); { - GtkMenu* menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" ); + auto menu_in_menu = create_sub_menu_with_mnemonic( menu, "More Cylinders" ); if ( g_Layout_enableDetachableMenus.m_value ) { menu_tearoff( menu_in_menu ); } @@@ -873,6 -972,66 +911,66 @@@ void DoNewPatchDlg( EPatchPrefab prefab } + void DoPatchDeformDlg(){ + ModalDialog dialog; + GtkWidget* deformW; + - GtkWindow* window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog ); ++ ui::Window window = create_dialog_window( MainFrame_getWindow(), "Patch deform", G_CALLBACK( dialog_delete_callback ), &dialog ); + + GtkAccelGroup* accel = gtk_accel_group_new(); + gtk_window_add_accel_group( window, accel ); + + { + GtkHBox* hbox = create_dialog_hbox( 4, 4 ); + gtk_container_add( GTK_CONTAINER( window ), GTK_WIDGET( hbox ) ); + { + GtkTable* table = create_dialog_table( 2, 2, 4, 4 ); + gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( table ), TRUE, TRUE, 0 ); + { + GtkLabel* label = GTK_LABEL( gtk_label_new( "Max deform:" ) ); + gtk_widget_show( GTK_WIDGET( label ) ); + gtk_table_attach( table, GTK_WIDGET( label ), 0, 1, 0, 1, + (GtkAttachOptions) ( GTK_FILL ), + (GtkAttachOptions) ( 0 ), 0, 0 ); + gtk_misc_set_alignment( GTK_MISC( label ), 0, 0.5 ); + } + { + GtkWidget* entry = gtk_entry_new(); + gtk_entry_set_text( GTK_ENTRY( entry ), "16" ); + gtk_widget_show( entry ); + gtk_table_attach( table, entry, 1, 2, 0, 1, + (GtkAttachOptions) ( GTK_EXPAND | GTK_FILL ), + (GtkAttachOptions) ( 0 ), 0, 0 ); + + deformW = entry; + } + } + { - GtkVBox* vbox = create_dialog_vbox( 4 ); ++ auto vbox = create_dialog_vbox( 4 ); + gtk_box_pack_start( GTK_BOX( hbox ), GTK_WIDGET( vbox ), TRUE, TRUE, 0 ); + { - GtkButton* button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - widget_make_default( GTK_WIDGET( button ) ); - gtk_widget_grab_focus( GTK_WIDGET( button ) ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); ++ auto button = create_dialog_button( "OK", G_CALLBACK( dialog_button_ok ), &dialog ); ++ vbox.pack_start( button, FALSE, FALSE, 0 ); ++ widget_make_default( button ); ++ gtk_widget_grab_focus( button ); ++ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Return, (GdkModifierType)0, (GtkAccelFlags)0 ); + } + { - GtkButton* button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog ); - gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( button ), FALSE, FALSE, 0 ); - gtk_widget_add_accelerator( GTK_WIDGET( button ), "clicked", accel, GDK_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); ++ auto button = create_dialog_button( "Cancel", G_CALLBACK( dialog_button_cancel ), &dialog ); ++ vbox.pack_start( button, FALSE, FALSE, 0 ); ++ gtk_widget_add_accelerator( button , "clicked", accel, GDK_KEY_Escape, (GdkModifierType)0, (GtkAccelFlags)0 ); + } + } + } + + if ( modal_dialog_show( window, dialog ) == eIDOK ) { + int deform = static_cast( atoi( gtk_entry_get_text( GTK_ENTRY( deformW ) ) ) ); + Scene_PatchDeform( GlobalSceneGraph(), deform ); + } + + gtk_widget_destroy( GTK_WIDGET( window ) ); + } + EMessageBoxReturn DoCapDlg( ECapDialog* type ){