From dd7f4f1689e8ede7580bdfa8e08d0b78d08f5253 Mon Sep 17 00:00:00 2001 From: Garux Date: Wed, 2 Aug 2017 09:18:45 +0300 Subject: [PATCH] Radiant: binds... * ctrl + shift + m1 (in texbro): open shader in external editor misc... * fix: do not unmaximize external shader editor on win * fix: blank cursor in radiant after calling external shader editor on win * fix shader editors stuff for non uindowses * 'Shader Editor Command' preference is available on win (is used, if set; otherwise try default os action for file) * fix: 'Shader Editor Command' preference allows selecting executable via dialog * GDK_HAND2 cursor in clipper tool mode * fix: clipper points have numeric labels * '2d zoom in to mouse pointer' option works for alt + m2 zoom * '3d zoom in to mouse pointer' option (def = yes) --- radiant/camwindow.cpp | 29 +++++++- radiant/camwindow.h | 5 +- radiant/entityinspector.cpp | 1 + radiant/gtkdlgs.cpp | 131 +++++++++++++++++------------------- radiant/gtkdlgs.h | 7 +- radiant/preferences.cpp | 19 +----- radiant/shaders.cpp | 4 +- radiant/shaders.h | 2 +- radiant/texwindow.cpp | 36 ++++++---- radiant/xywindow.cpp | 50 +++++++++++--- radiant/xywindow.h | 6 +- tools/quake3/q3map2/main.c | 1 + 12 files changed, 168 insertions(+), 123 deletions(-) diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index fdad03e1..ca7e26a0 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -888,7 +888,32 @@ gboolean selection_motion_freemove( GtkWidget *widget, GdkEventMotion *event, Wi gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* camwnd ){ if ( event->direction == GDK_SCROLL_UP ) { Camera_Freemove_updateAxes( camwnd->getCamera() ); - Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( camwnd->getCamera().forward, static_cast( g_camwindow_globals_private.m_nMoveSpeed ) ) ) ); + if( camwnd->m_bFreeMove || !g_camwindow_globals.m_bZoomInToPointer ){ + Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( camwnd->getCamera().forward, static_cast( g_camwindow_globals_private.m_nMoveSpeed ) ) ) ); + } + else{ + //Matrix4 maa = matrix4_multiplied_by_matrix4( camwnd->getCamera().projection, camwnd->getCamera().modelview ); + Matrix4 maa = camwnd->getCamera().m_view->GetViewMatrix(); + matrix4_affine_invert( maa ); + + float x = static_cast( event->x ); + float y = static_cast( event->y ); + Vector3 normalized; + + normalized[0] = 2.0f * ( x ) / static_cast( camwnd->getCamera().width ) - 1.0f; + normalized[1] = 2.0f * ( y )/ static_cast( camwnd->getCamera().height ) - 1.0f; + normalized[1] *= -1.f; + normalized[2] = 0.f; + + normalized *= 16.0f; + //globalOutputStream() << normalized << " normalized "; + matrix4_transform_point( maa, normalized ); + //globalOutputStream() << normalized << "\n"; + Vector3 norm = vector3_normalised( normalized - Camera_getOrigin( *camwnd ) ); + //globalOutputStream() << normalized - Camera_getOrigin( *camwnd ) << " normalized - Camera_getOrigin( *camwnd )\n"; + //globalOutputStream() << norm << " norm\n"; + Camera_setOrigin( *camwnd, vector3_added( Camera_getOrigin( *camwnd ), vector3_scaled( norm, static_cast( g_camwindow_globals_private.m_nMoveSpeed ) ) ) ); + } } else if ( event->direction == GDK_SCROLL_DOWN ) { Camera_Freemove_updateAxes( camwnd->getCamera() ); @@ -1891,6 +1916,7 @@ void Camera_constructPreferences( PreferencesPage& page ){ page.appendCheckBox( "", "Link strafe speed to movement speed", g_camwindow_globals_private.m_bCamLinkSpeed ); page.appendSlider( "Rotation Speed", g_camwindow_globals_private.m_nAngleSpeed, TRUE, 0, 0, 3, 1, 180, 1, 10 ); page.appendCheckBox( "", "Invert mouse vertical axis", g_camwindow_globals_private.m_bCamInverseMouse ); + page.appendCheckBox( "", "Zoom In to Mouse pointer", g_camwindow_globals.m_bZoomInToPointer ); page.appendCheckBox( "", "Discrete movement", FreeCaller1(), @@ -2026,6 +2052,7 @@ void CamWnd_Construct(){ GlobalPreferenceSystem().registerPreference( "SI_Colors12", Vector3ImportStringCaller( g_camwindow_globals.color_selbrushes3d ), Vector3ExportStringCaller( g_camwindow_globals.color_selbrushes3d ) ); GlobalPreferenceSystem().registerPreference( "CameraRenderMode", makeIntStringImportCallback( RenderModeImportCaller() ), makeIntStringExportCallback( RenderModeExportCaller() ) ); GlobalPreferenceSystem().registerPreference( "StrafeMode", IntImportStringCaller( g_camwindow_globals_private.m_nStrafeMode ), IntExportStringCaller( g_camwindow_globals_private.m_nStrafeMode ) ); + GlobalPreferenceSystem().registerPreference( "3DZoomInToPointer", BoolImportStringCaller( g_camwindow_globals.m_bZoomInToPointer ), BoolExportStringCaller( g_camwindow_globals.m_bZoomInToPointer ) ); CamWnd_constructStatic(); diff --git a/radiant/camwindow.h b/radiant/camwindow.h index c40c8fb0..ce8db6e2 100644 --- a/radiant/camwindow.h +++ b/radiant/camwindow.h @@ -68,10 +68,13 @@ struct camwindow_globals_t int m_nCubicScale; + bool m_bZoomInToPointer; + camwindow_globals_t() : color_cameraback( 0.25f, 0.25f, 0.25f ), color_selbrushes3d( 1.0f, 0.f, 0.f ), - m_nCubicScale( 14 ){ + m_nCubicScale( 14 ), + m_bZoomInToPointer( true ){ } }; diff --git a/radiant/entityinspector.cpp b/radiant/entityinspector.cpp index e187d803..f1096bf0 100644 --- a/radiant/entityinspector.cpp +++ b/radiant/entityinspector.cpp @@ -1338,6 +1338,7 @@ static gint EntityInspector_hideWindowKB( GtkWidget* widget, GdkEventKey* event, gtk_widget_hide( GTK_WIDGET( GroupDialog_getWindow() ) ); return TRUE; } + /* this doesn't work, if tab is bound (func is not called then) */ if ( event->keyval == GDK_Tab ) { gtk_window_set_focus( GTK_WINDOW( gtk_widget_get_toplevel( GTK_WIDGET( widget ) ) ), GTK_WIDGET( g_entityKeyEntry ) ); return TRUE; diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index 32ee3f3e..d0738e8d 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -874,9 +874,9 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length ) gtk_widget_show( text_editor ); gtk_window_present( GTK_WINDOW( text_editor ) ); -#ifdef WIN32 +//#ifdef WIN32 process_gui(); -#endif +//#endif // only move the cursor if it's not exceeding the size.. // NOTE: this is erroneous, cursorpos is the offset in bytes, not in characters @@ -890,9 +890,9 @@ static void DoGtkTextEditor( const char* filename, guint cursorpos, int length ) gtk_text_view_scroll_to_iter( GTK_TEXT_VIEW( text_widget ), &text_iter, 0, TRUE, 0, 0); } -#ifdef WIN32 +//#ifdef WIN32 gtk_widget_queue_draw( text_widget ); -#endif +//#endif text_buffer_ = text_buffer; free( buf ); @@ -1088,77 +1088,72 @@ EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* #include #endif -#ifdef WIN32 -// use the file associations to open files instead of builtin Gtk editor -bool g_TextEditor_useWin32Editor = false; -#else -// custom shader editor -bool g_TextEditor_useCustomEditor = false; CopiedString g_TextEditor_editorCommand( "" ); -#endif -void DoTextEditor( const char* filename, int cursorpos, int length ){ -#ifdef WIN32 - if ( g_TextEditor_useWin32Editor ) { - StringOutputStream path( 256 ); - StringOutputStream modpath( 256 ); - const char* gamename = GlobalRadiant().getGameName(); - const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" ); - const char* enginePath = GlobalRadiant().getEnginePath(); - path << enginePath << basegame << '/' << filename; - modpath << enginePath << gamename << '/' << filename; - if ( file_exists( modpath.c_str() ) ){ - globalOutputStream() << "opening file '" << modpath.c_str() << "' (line " << cursorpos << " info ignored)\n"; - ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", modpath.c_str(), 0, 0, SW_SHOW ); +void DoTextEditor( const char* filename, int cursorpos, int length, bool external_editor ){ + //StringOutputStream paths[4]( 256 ); + StringOutputStream paths[4] = { StringOutputStream(256) }; + StringOutputStream* goodpath = 0; + + const char* gamename = GlobalRadiant().getGameName(); + const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" ); + const char* enginePath = GlobalRadiant().getEnginePath(); + const char* homeEnginePath = g_qeglobals.m_userEnginePath.c_str(); + + paths[0] << homeEnginePath << gamename << '/' << filename; + paths[1] << enginePath << gamename << '/' << filename; + paths[2] << homeEnginePath << basegame << '/' << filename; + paths[3] << enginePath << basegame << '/' << filename; + + for ( std::size_t i = 0; i < 4; ++i ){ + if ( file_exists( paths[i].c_str() ) ){ + goodpath = &paths[i]; + break; } - else if ( file_exists( path.c_str() ) ){ - globalOutputStream() << "opening file '" << path.c_str() << "' (line " << cursorpos << " info ignored)\n"; - ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), "open", path.c_str(), 0, 0, SW_SHOW ); - } - else{ - globalOutputStream() << "Failed to open '" << filename << "'\nOne sits in .pk3 most likely!\n"; - } - return; } - else{ - StringOutputStream path( 256 ); - StringOutputStream modpath( 256 ); - const char* gamename = GlobalRadiant().getGameName(); - const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" ); - const char* enginePath = GlobalRadiant().getEnginePath(); - path << enginePath << basegame << '/' << filename; - modpath << enginePath << gamename << '/' << filename; - if ( file_exists( modpath.c_str() ) ){ - globalOutputStream() << "opening file '" << modpath.c_str() << "' (line " << cursorpos << " info ignored)\n"; - DoGtkTextEditor( modpath.c_str(), cursorpos, length ); - } - else if ( file_exists( path.c_str() ) ){ - globalOutputStream() << "opening file '" << path.c_str() << "' (line " << cursorpos << " info ignored)\n"; - DoGtkTextEditor( path.c_str(), cursorpos, length ); + + if( goodpath ){ + globalOutputStream() << "opening file '" << goodpath->c_str() << "' (line " << cursorpos << " info ignored)\n"; + if( external_editor ){ + if( g_TextEditor_editorCommand.empty() ){ +#ifdef WIN32 + ShellExecute( (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ), 0, goodpath->c_str(), 0, 0, SW_SHOWNORMAL ); +// SHELLEXECUTEINFO ShExecInfo; +// ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); +// ShExecInfo.fMask = 0; +// ShExecInfo.hwnd = (HWND)GDK_WINDOW_HWND( GTK_WIDGET( MainFrame_getWindow() )->window ); +// ShExecInfo.lpVerb = NULL; +// ShExecInfo.lpFile = goodpath->c_str(); +// ShExecInfo.lpParameters = NULL; +// ShExecInfo.lpDirectory = NULL; +// ShExecInfo.nShow = SW_SHOWNORMAL; +// ShExecInfo.hInstApp = NULL; +// ShellExecuteEx(&ShExecInfo); +#else + globalOutputStream() << "Failed to open '" << goodpath->c_str() << "'\nSet Shader Editor Command in preferences\n"; +#endif + } + else{ + StringOutputStream strEditCommand( 256 ); + strEditCommand << g_TextEditor_editorCommand.c_str() << " \"" << goodpath->c_str() << "\""; + + globalOutputStream() << "Launching: " << strEditCommand.c_str() << "\n"; + // note: linux does not return false if the command failed so it will assume success + if ( Q_Exec( 0, const_cast( strEditCommand.c_str() ), 0, true, false ) == false ) { + globalOutputStream() << "Failed to execute " << strEditCommand.c_str() << "\n"; + } + else + { + // the command (appeared) to run successfully, no need to do anything more + return; + } + } } else{ - globalOutputStream() << "Failed to open '" << filename << "'\nOne sits in .pk3 most likely!\n"; + DoGtkTextEditor( goodpath->c_str(), cursorpos, length ); } - return; } -#else - // check if a custom editor is set - if ( g_TextEditor_useCustomEditor && !g_TextEditor_editorCommand.empty() ) { - StringOutputStream strEditCommand( 256 ); - strEditCommand << g_TextEditor_editorCommand.c_str() << " \"" << filename << "\""; - - globalOutputStream() << "Launching: " << strEditCommand.c_str() << "\n"; - // note: linux does not return false if the command failed so it will assume success - if ( Q_Exec( 0, const_cast( strEditCommand.c_str() ), 0, true, false ) == false ) { - globalOutputStream() << "Failed to execute " << strEditCommand.c_str() << ", using default\n"; - } - else - { - // the command (appeared) to run successfully, no need to do anything more - return; - } + else{ + globalOutputStream() << "Failed to open '" << filename << "'\nOne sits in .pk3 most likely!\n"; } - - DoGtkTextEditor( filename, cursorpos, length ); -#endif } diff --git a/radiant/gtkdlgs.h b/radiant/gtkdlgs.h index a0ad7401..dfebe8f8 100644 --- a/radiant/gtkdlgs.h +++ b/radiant/gtkdlgs.h @@ -38,7 +38,7 @@ EMessageBoxReturn DoLightIntensityDlg( int *intensity ); EMessageBoxReturn DoShaderTagDlg( CopiedString *tag, char* title ); EMessageBoxReturn DoShaderInfoDlg( const char* name, const char* filename, char* title ); EMessageBoxReturn DoTextureLayout( float *fx, float *fy ); -void DoTextEditor( const char* filename, int cursorpos, int length ); +void DoTextEditor( const char* filename, int cursorpos, int length, bool external_editor ); void DoProjectSettings(); @@ -47,13 +47,8 @@ void DoSides( int type, int axis ); void DoAbout(); -#ifdef WIN32 -extern bool g_TextEditor_useWin32Editor; -#else #include "string/stringfwd.h" -extern bool g_TextEditor_useCustomEditor; extern CopiedString g_TextEditor_editorCommand; -#endif #endif diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index b3d176ba..52ea8877 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -70,15 +70,7 @@ void Global_constructPreferences( PreferencesPage& page ){ } void Interface_constructPreferences( PreferencesPage& page ){ -#ifdef WIN32 - page.appendCheckBox( "", "External Shader Editor", g_TextEditor_useWin32Editor ); -#else - { - GtkWidget* use_custom = page.appendCheckBox( "Text Editor", "Custom", g_TextEditor_useCustomEditor ); - GtkWidget* custom_editor = page.appendPathEntry( "Text Editor Command", g_TextEditor_editorCommand, true ); - Widget_connectToggleDependency( custom_editor, use_custom ); - } -#endif + page.appendPathEntry( "Shader Editor Command", g_TextEditor_editorCommand, false ); } void Mouse_constructPreferences( PreferencesPage& page ){ @@ -87,7 +79,7 @@ void Mouse_constructPreferences( PreferencesPage& page ){ // page.appendRadio( "Mouse Type", g_glwindow_globals.m_nMouseType, STRING_ARRAY_RANGE( buttons ) ); // } // page.appendCheckBox( "Right Button", "Activates Context Menu", g_xywindow_globals.m_bRightClick ); - page.appendCheckBox( "", "Improved mousewheel zoom", g_xywindow_globals.m_bImprovedWheelZoom ); + page.appendCheckBox( "", "Zoom to mouse pointer", g_xywindow_globals.m_bZoomInToPointer ); } void Mouse_constructPage( PreferenceGroup& group ){ PreferencesPage page( group.createPage( "Mouse", "Mouse Preferences" ) ); @@ -702,7 +694,7 @@ PreferencesPage createPage( const char* treeName, const char* frameName ){ GtkWindow* PrefsDlg::BuildDialog(){ PreferencesDialog_addInterfacePreferences( FreeCaller1() ); - Mouse_registerPreferencesPage(); + //Mouse_registerPreferencesPage(); GtkWindow* dialog = create_floating_window( "NetRadiant Preferences", m_parent ); @@ -972,12 +964,7 @@ typedef FreeCaller1 GameMode void RegisterPreferences( PreferenceSystem& preferences ){ -#ifdef WIN32 - preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useWin32Editor ), BoolExportStringCaller( g_TextEditor_useWin32Editor ) ); -#else - preferences.registerPreference( "UseCustomShaderEditor", BoolImportStringCaller( g_TextEditor_useCustomEditor ), BoolExportStringCaller( g_TextEditor_useCustomEditor ) ); preferences.registerPreference( "CustomShaderEditorCommand", CopiedStringImportStringCaller( g_TextEditor_editorCommand ), CopiedStringExportStringCaller( g_TextEditor_editorCommand ) ); -#endif preferences.registerPreference( "GameName", GameNameImportStringCaller(), GameNameExportStringCaller() ); preferences.registerPreference( "GameMode", GameModeImportStringCaller(), GameModeExportStringCaller() ); diff --git a/radiant/shaders.cpp b/radiant/shaders.cpp index f02474e0..6612c335 100644 --- a/radiant/shaders.cpp +++ b/radiant/shaders.cpp @@ -27,7 +27,7 @@ #include "gtkdlgs.h" -void ViewShader( const char *pFile, const char *pName ){ +void ViewShader( const char *pFile, const char *pName, bool external_editor ){ char* pBuff = 0; //int nSize = vfsLoadFile( pFile, reinterpret_cast( &pBuff ) ); @@ -123,5 +123,5 @@ void ViewShader( const char *pFile, const char *pName ){ // now close the file vfsFreeFile( pBuff ); - DoTextEditor( pFile, static_cast( nOffset ), length ); + DoTextEditor( pFile, static_cast( nOffset ), length, external_editor ); } diff --git a/radiant/shaders.h b/radiant/shaders.h index 6cf0ec85..7758853a 100644 --- a/radiant/shaders.h +++ b/radiant/shaders.h @@ -22,6 +22,6 @@ #if !defined( INCLUDED_SHADERS_H ) #define INCLUDED_SHADERS_H -void ViewShader( const char* file, const char* shader ); +void ViewShader( const char* file, const char* shader, bool external_editor ); #endif diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 366019ca..926937ea 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -973,19 +973,10 @@ IShader* Texture_At( TextureBrowser& textureBrowser, int mx, int my ){ By mouse click ============== */ -void SelectTexture( TextureBrowser& textureBrowser, int mx, int my, bool bShift ){ - IShader* shader = Texture_At( textureBrowser, mx, my ); - if ( shader != 0 ) { - if ( bShift ) { - if ( shader->IsDefault() ) { - globalOutputStream() << "ERROR: " << shader->getName() << " is not a shader, it's a texture.\n"; - } - else{ - ViewShader( shader->getShaderFileName(), shader->getName() ); - } - } - else - { +void SelectTexture( TextureBrowser& textureBrowser, int mx, int my, guint32 flags ){ + if ( ( flags & GDK_SHIFT_MASK ) == 0 ) { + IShader* shader = Texture_At( textureBrowser, mx, my ); + if ( shader != 0 ) { TextureBrowser_SetSelectedShader( textureBrowser, shader->getName() ); TextureBrowser_textureSelected( shader->getName() ); @@ -1034,7 +1025,21 @@ void TextureBrowser_Tracking_MouseDown( TextureBrowser& textureBrowser ){ } void TextureBrowser_Selection_MouseDown( TextureBrowser& textureBrowser, guint32 flags, int pointx, int pointy ){ - SelectTexture( textureBrowser, pointx, textureBrowser.height - 1 - pointy, ( flags & GDK_SHIFT_MASK ) != 0 ); + SelectTexture( textureBrowser, pointx, textureBrowser.height - 1 - pointy, flags ); +} + +void TextureBrowser_Selection_MouseUp( TextureBrowser& textureBrowser, guint32 flags, int pointx, int pointy ){ + if ( ( flags & GDK_SHIFT_MASK ) != 0 ) { + IShader* shader = Texture_At( textureBrowser, pointx, textureBrowser.height - 1 - pointy ); + if ( shader != 0 ) { + if ( shader->IsDefault() ) { + globalOutputStream() << "ERROR: " << shader->getName() << " is not a shader, it's a texture.\n"; + } + else{ + ViewShader( shader->getShaderFileName(), shader->getName(), ( flags & GDK_CONTROL_MASK ) != 0 ); + } + } + } } /* @@ -1434,6 +1439,9 @@ gboolean TextureBrowser_button_release( GtkWidget* widget, GdkEventButton* event TextureBrowser_Tracking_MouseUp( *textureBrowser ); } } + if ( event->button == 1 ) { + TextureBrowser_Selection_MouseUp( *textureBrowser, event->state, static_cast( event->x ), static_cast( event->y ) ); + } } return FALSE; } diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index ee957abe..8b2da7cb 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -136,7 +136,9 @@ void ClipPoint::Draw( const char *label, float scale ){ // draw label glRasterPos3f( m_ptClip[0] + offset, m_ptClip[1] + offset, m_ptClip[2] + offset ); - glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label ); + //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, label ); //fails with GCC + //glCallLists( GLsizei( strlen( label ) ), GL_UNSIGNED_BYTE, reinterpret_cast( label ) ); //worx + GlobalOpenGL().drawString( label ); } float fDiff( float f1, float f2 ){ @@ -537,7 +539,7 @@ void XYWnd::ZoomOut(){ void XYWnd::ZoomInWithMouse( int pointx, int pointy ){ float old_scale = Scale(); ZoomIn(); - if ( g_xywindow_globals.m_bImprovedWheelZoom ) { + if ( g_xywindow_globals.m_bZoomInToPointer ) { float scale_diff = 1.0 / old_scale - 1.0 / Scale(); int nDim1 = ( m_viewType == YZ ) ? 1 : 0; int nDim2 = ( m_viewType == XY ) ? 1 : 2; @@ -982,14 +984,30 @@ void XYWnd::Clipper_OnMouseMoved( int x, int y ){ } } +//#include "gtkutil/image.h" + +/* is called on every mouse move fraction; ain't good! */ void XYWnd::Clipper_Crosshair_OnMouseMoved( int x, int y ){ Vector3 mousePosition; XY_ToPoint( x, y, mousePosition ); - if ( ClipMode() && GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ) { - GdkCursor *cursor; - cursor = gdk_cursor_new( GDK_CROSSHAIR ); - gdk_window_set_cursor( m_gl_widget->window, cursor ); - gdk_cursor_unref( cursor ); + if ( ClipMode() ) { + if( GlobalClipPoints_Find( mousePosition, (VIEWTYPE)m_viewType, m_fScale ) != 0 ){ + GdkCursor *cursor; + cursor = gdk_cursor_new( GDK_CROSSHAIR ); + //cursor = gdk_cursor_new( GDK_FLEUR ); + gdk_window_set_cursor( m_gl_widget->window, cursor ); + gdk_cursor_unref( cursor ); + } + else{ + GdkCursor *cursor; + cursor = gdk_cursor_new( GDK_HAND2 ); +// GdkPixbuf* pixbuf = pixbuf_new_from_file_with_mask( "bitmaps/icon.png" ); +// cursor = gdk_cursor_new_from_pixbuf( gdk_display_get_default(), pixbuf, 0, 0 ); +// g_object_unref( pixbuf ); + gdk_window_set_cursor( m_gl_widget->window, cursor ); + gdk_cursor_unref( cursor ); + + } } else { @@ -1285,6 +1303,8 @@ unsigned int Zoom_buttons(){ } int g_dragZoom = 0; +int g_zoom2x = 0; +int g_zoom2y = 0; void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){ if ( y != 0 ) { @@ -1297,7 +1317,12 @@ void XYWnd_zoomDelta( int x, int y, unsigned int state, void* data ){ } else { - reinterpret_cast( data )->ZoomIn(); + if ( g_xywindow_globals.m_bZoomInToPointer ) { + reinterpret_cast( data )->ZoomInWithMouse( g_zoom2x, g_zoom2y ); + } + else{ + reinterpret_cast( data )->ZoomIn(); + } g_dragZoom += 8; } } @@ -1309,12 +1334,14 @@ gboolean XYWnd_Zoom_focusOut( GtkWidget* widget, GdkEventFocus* event, XYWnd* xy return FALSE; } -void XYWnd::Zoom_Begin(){ +void XYWnd::Zoom_Begin( int x, int y ){ if ( m_zoom_started ) { Zoom_End(); } m_zoom_started = true; g_dragZoom = 0; + g_zoom2x = x; + g_zoom2y = y; g_xywnd_freezePointer.freeze_pointer( m_parent != 0 ? m_parent : MainFrame_getWindow(), m_gl_widget, XYWnd_zoomDelta, this ); m_zoom_focusOut = g_signal_connect( G_OBJECT( m_gl_widget ), "focus_out_event", G_CALLBACK( XYWnd_Zoom_focusOut ), this ); } @@ -1361,7 +1388,7 @@ void XYWnd::XY_MouseDown( int x, int y, unsigned int buttons ){ EntityCreate_MouseDown( x, y ); } else if ( buttons == Zoom_buttons() ) { - Zoom_Begin(); + Zoom_Begin( x, y ); } else if ( ClipMode() && ( buttons == Clipper_buttons() || buttons == Clipper_quick_buttons() ) ) { Clipper_OnLButtonDown( x, y ); @@ -2983,6 +3010,7 @@ void Orthographic_constructPreferences( PreferencesPage& page ){ //page.appendCheckBox( "", "Display size info", g_xywindow_globals_private.m_bSizePaint ); page.appendCheckBox( "", "Chase mouse during drags", g_xywindow_globals_private.m_bChaseMouse ); // page.appendCheckBox( "", "Update views on camera move", g_xywindow_globals_private.m_bCamXYUpdate ); + page.appendCheckBox( "", "Zoom In to Mouse pointer", g_xywindow_globals.m_bZoomInToPointer ); } void Orthographic_constructPage( PreferenceGroup& group ){ PreferencesPage page( group.createPage( "Orthographic", "Orthographic View Preferences" ) ); @@ -3040,7 +3068,7 @@ void XYWindow_Construct(){ GlobalPreferenceSystem().registerPreference( "ClipCaulk", BoolImportStringCaller( g_clip_useCaulk ), BoolExportStringCaller( g_clip_useCaulk ) ); // GlobalPreferenceSystem().registerPreference( "NewRightClick", BoolImportStringCaller( g_xywindow_globals.m_bRightClick ), BoolExportStringCaller( g_xywindow_globals.m_bRightClick ) ); - GlobalPreferenceSystem().registerPreference( "ImprovedWheelZoom", BoolImportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ), BoolExportStringCaller( g_xywindow_globals.m_bImprovedWheelZoom ) ); + GlobalPreferenceSystem().registerPreference( "2DZoomInToPointer", BoolImportStringCaller( g_xywindow_globals.m_bZoomInToPointer ), BoolExportStringCaller( g_xywindow_globals.m_bZoomInToPointer ) ); GlobalPreferenceSystem().registerPreference( "ChaseMouse", BoolImportStringCaller( g_xywindow_globals_private.m_bChaseMouse ), BoolExportStringCaller( g_xywindow_globals_private.m_bChaseMouse ) ); GlobalPreferenceSystem().registerPreference( "SizePainting", BoolImportStringCaller( g_xywindow_globals_private.m_bSizePaint ), BoolExportStringCaller( g_xywindow_globals_private.m_bSizePaint ) ); GlobalPreferenceSystem().registerPreference( "ShowCrosshair", BoolImportStringCaller( g_bCrossHairs ), BoolExportStringCaller( g_bCrossHairs ) ); diff --git a/radiant/xywindow.h b/radiant/xywindow.h index 822045a5..a3fbd301 100644 --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@ -121,7 +121,7 @@ void Move_End(); bool m_move_started; guint m_move_focusOut; -void Zoom_Begin(); +void Zoom_Begin( int x, int y ); void Zoom_End(); bool m_zoom_started; guint m_zoom_focusOut; @@ -269,7 +269,7 @@ struct xywindow_globals_t // bool m_bRightClick; bool m_bNoStipple; - bool m_bImprovedWheelZoom; + bool m_bZoomInToPointer; xywindow_globals_t() : color_gridback( 0.77f, 0.77f, 0.77f ), @@ -287,7 +287,7 @@ struct xywindow_globals_t AxisColorZ( 0.f, 0.f, 1.f ), // m_bRightClick( true ), m_bNoStipple( true ), - m_bImprovedWheelZoom( true ){ + m_bZoomInToPointer( true ){ } }; diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 1b8275df..ff95bbdf 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -1596,6 +1596,7 @@ int ShiftBSPMain( int argc, char **argv ){ { //find point on plane for ( j=0; j<3; j++ ){ + //point[j] = bspPlanes[ i ].dist * bspPlanes[ i ].normal[j]; if ( fabs( bspPlanes[ i ].normal[j] ) > 0.5 ){ point[j] = bspPlanes[ i ].dist / bspPlanes[ i ].normal[j]; point[(j+1)%3] = point[(j+2)%3] = 0; -- 2.39.2