From: Thomas Debesse Date: Mon, 20 Jun 2022 02:38:12 +0000 (+0200) Subject: Merge commit '39f598c5f44010cc32f1b445b12cb088a72bbc50' into master-merge X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0ae4329330f964c0e5af3742e365d71bb7d607fd;p=xonotic%2Fnetradiant.git Merge commit '39f598c5f44010cc32f1b445b12cb088a72bbc50' into master-merge --- 0ae4329330f964c0e5af3742e365d71bb7d607fd diff --cc radiant/csg.cpp index 2a59d2fe,24ca4035..c459804a --- a/radiant/csg.cpp +++ b/radiant/csg.cpp @@@ -46,9 -33,9 +33,9 @@@ void Face_makeBrush( Face& face, const Brush& brush, brush_vector_t& out, float offset ){ if ( face.contributes() ) { out.push_back( new Brush( brush ) ); - //face.getPlane().offset( -offset ); - //face.planeChanged(); - Face* newFace = out.back()->addFace( face ); + std::shared_ptr newFace = out.back()->addFace( face ); + face.getPlane().offset( -offset ); + face.planeChanged(); if ( newFace != 0 ) { newFace->flipWinding(); newFace->getPlane().offset( offset ); @@@ -70,16 -57,29 +57,29 @@@ void Face_extrude( Face& face, const Br } } - void Brush_makeHollow( const Brush &brush, brush_vector_t &out, float offset ){ - Brush_forEachFace( brush, [&]( Face &face ) { + + class FaceMakeBrush + { + const Brush& brush; + brush_vector_t& out; + float offset; + bool room; + public: + FaceMakeBrush( const Brush& brush, brush_vector_t& out, float offset, bool room ) + : brush( brush ), out( out ), offset( offset ), room( room ){ + } + void operator()( Face& face ) const { + if( room ){ + Face_extrude( face, brush, out, offset ); + } + else{ Face_makeBrush( face, brush, out, offset ); - } ); - } +} + } + }; - void Brush_makeRoom( const Brush &brush, brush_vector_t &out, float offset ){ - Brush_forEachFace( brush, [&]( Face &face ) { - Face_makeRoom( face, brush, out, offset ); - } ); + void Brush_makeHollow( const Brush& brush, brush_vector_t& out, float offset, bool room ){ + Brush_forEachFace( brush, FaceMakeBrush( brush, out, offset, room ) ); } class BrushHollowSelectedWalker : public scene::Graph::Walker diff --cc radiant/mainframe.cpp index ea0ccd5b,50101b3f..1bea47d1 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@@ -3080,24 -2992,32 +3080,33 @@@ void MainFrame::Create() window.show(); - if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) { + if ( CurrentStyle() == eRegular || CurrentStyle() == eRegularLeft ) + { { + ui::Widget hsplit = ui::HPaned(ui::New); + m_vSplit = hsplit; + vbox.pack_start( hsplit, TRUE, TRUE, 0 ); + hsplit.show(); + { - ui::Widget vsplit = ui::VPaned(ui::New); + ui::Widget vsplit = ui::VPaned(ui::New); + vsplit.show(); - m_vSplit = vsplit; + m_vSplit = vsplit; - vbox.pack_start( vsplit, TRUE, TRUE, 0 ); - vsplit.show(); + ui::Widget vsplit2 = ui::VPaned(ui::New); + vsplit2.show(); + m_vSplit = vsplit2; + if ( CurrentStyle() == eRegular ){ + gtk_paned_add1( GTK_PANED( hsplit ), vsplit ); + gtk_paned_add2( GTK_PANED( hsplit ), vsplit2 ); + } + else{ + gtk_paned_add2( GTK_PANED( hsplit ), vsplit ); + gtk_paned_add1( GTK_PANED( hsplit ), vsplit2 ); + } - // console - ui::Widget console_window = Console_constructWindow( window ); - gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE ); - + // console + ui::Widget console_window = Console_constructWindow( window ); + gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE ); + - { - ui::Widget hsplit = ui::HPaned(ui::New); - hsplit.show(); - m_hSplit = hsplit; - gtk_paned_add1( GTK_PANED( vsplit ), hsplit ); - // xy m_pXYWnd = new XYWnd(); m_pXYWnd->SetViewType( XY ); diff --cc radiant/texwindow.cpp index 18311b40,45c684b2..6640b97e --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@@ -327,42 -325,80 +328,80 @@@ bool m_searchedTags bool m_tags; // The uniform size (in pixels) that textures are resized to when m_resizeTextures is true. int m_uniformTextureSize; + int m_uniformTextureMinSize; // Return the display width of a texture in the texture browser - int getTextureWidth( qtexture_t* tex ){ - int width; + /*void getTextureWH( qtexture_t* tex, int *width, int *height ){ if ( !g_TextureBrowser_fixedSize ) { // Don't use uniform size - width = (int)( tex->width * ( (float)m_textureScale / 100 ) ); + *width = (int)( tex->width * ( (float)m_textureScale / 100 ) ); + *height = (int)( tex->height * ( (float)m_textureScale / 100 ) ); + } - else if - ( tex->width >= tex->height ) { + else if ( tex->width >= tex->height ) { // Texture is square, or wider than it is tall - width = m_uniformTextureSize; + if ( tex->width >= m_uniformTextureSize ){ + *width = m_uniformTextureSize; + *height = (int)( m_uniformTextureSize * ( (float)tex->height / tex->width ) ); + } + else if ( tex->width <= m_uniformTextureMinSize ){ + *width = m_uniformTextureMinSize; + *height = (int)( m_uniformTextureMinSize * ( (float)tex->height / tex->width ) ); - } - else { + } + else { - // Otherwise, preserve the texture's aspect ratio - width = (int)( m_uniformTextureSize * ( (float)tex->width / tex->height ) ); + *width = tex->width; + *height = tex->height; - } ++ } + } + else { + // Texture taller than it is wide + if ( tex->height >= m_uniformTextureSize ){ + *height = m_uniformTextureSize; + *width = (int)( m_uniformTextureSize * ( (float)tex->width / tex->height ) ); + } + else if ( tex->height <= m_uniformTextureMinSize ){ + *height = m_uniformTextureMinSize; + *width = (int)( m_uniformTextureMinSize * ( (float)tex->width / tex->height ) ); + } + else { + *width = tex->width; + *height = tex->height; + } } - return width; } - // Return the display height of a texture in the texture browser - int getTextureHeight( qtexture_t* tex ){ - int height; - if ( !g_TextureBrowser_fixedSize ) { + */ + void getTextureWH( qtexture_t* tex, int *width, int *height ){ // Don't use uniform size - height = (int)( tex->height * ( (float)m_textureScale / 100 ) ); - } - else if ( tex->height >= tex->width ) { - // Texture is square, or taller than it is wide - height = m_uniformTextureSize; + *width = (int)( tex->width * ( (float)m_textureScale / 100 ) ); + *height = (int)( tex->height * ( (float)m_textureScale / 100 ) ); + + if ( g_TextureBrowser_fixedSize ){ + int W = *width; + int H = *height; + if ( W >= H ) { + // Texture is square, or wider than it is tall + if ( W >= m_uniformTextureSize ){ + *width = m_uniformTextureSize; + *height = m_uniformTextureSize * H / W; - } ++ } + else if ( W <= m_uniformTextureMinSize ){ + *width = m_uniformTextureMinSize; + *height = m_uniformTextureMinSize * H / W; + } - } - else { + } + else { - // Otherwise, preserve the texture's aspect ratio - height = (int)( m_uniformTextureSize * ( (float)tex->height / tex->width ) ); + // Texture taller than it is wide + if ( H >= m_uniformTextureSize ){ + *height = m_uniformTextureSize; + *width = m_uniformTextureSize * W / H; - } ++ } + else if ( H <= m_uniformTextureMinSize ){ + *height = m_uniformTextureMinSize; + *width = m_uniformTextureMinSize * W / H; + } + } } - return height; } TextureBrowser() : @@@ -865,22 -887,10 +907,22 @@@ void visit( const char* minor, const _Q void TextureBrowser_ShowDirectory( TextureBrowser& textureBrowser, const char* directory ){ if ( TextureBrowser_showWads() ) { + g_TextureBrowser_currentDirectory = directory; + TextureBrowser_heightChanged( textureBrowser ); + Archive* archive = GlobalFileSystem().getArchive( directory ); - ASSERT_NOTNULL( archive ); + if ( archive != nullptr ) + { - LoadShaderVisitor visitor; - archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "textures/" ); + LoadShaderVisitor visitor; + archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "textures/" ); + + // Doom3-like dds/ prefix (used by DarkPlaces). + archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "dds/textures/" ); + } + else if ( extension_equal_i( path_get_extension( directory ), "wad" ) ) + { + globalErrorStream() << "Failed to load " << directory << "\n"; + } } else { @@@ -2414,48 -2318,11 +2463,48 @@@ void TextureBrowser_destroyGLWidget() void TextureBrowser_destroyWindow(){ GlobalShaderSystem().setActiveShadersChangedNotify( Callback() ); - g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_sizeHandler ); - g_signal_handler_disconnect( G_OBJECT( g_TextureBrowser.m_gl_widget ), g_TextureBrowser.m_exposeHandler ); + TextureBrowser_destroyGLWidget(); +} + +#ifdef WORKAROUND_MACOS_GTK2_GLWIDGET +/* workaround for gtkglext on gtk 2 issue: OpenGL texture viewport being drawn over the other pages */ +/* this is very ugly: force the resizing of the viewport to a single bottom line by forcing the + * resizing of the gl widget by expanding some empty boxes, so the widget area size is reduced + * while covered by another page, so the texture viewport is still rendered over the other page + * but does not annoy the user that much because it's just a line on the bottom that may even + * be printed over existing bottom frame or very close to it. */ +void TextureBrowser_showGLWidget(){ + TextureBrowser &textureBrowser = GlobalTextureBrowser(); + if ( isWindowConstructed && isGLWidgetConstructed ) + { + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_vfiller, FALSE, FALSE, 0, ui::Packing::START ); + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hframe, TRUE, TRUE, 0, ui::Packing::START ); + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hfiller, FALSE, FALSE, 0, ui::Packing::START ); + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_gl_widget, TRUE, TRUE, 0, ui::Packing::START ); + + textureBrowser.m_gl_widget.show(); - } ++} +} + +void TextureBrowser_hideGLWidget(){ + TextureBrowser &textureBrowser = GlobalTextureBrowser(); + if ( isWindowConstructed && isGLWidgetConstructed ) + { + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_vfiller, TRUE, TRUE, 0, ui::Packing::START); + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hframe, FALSE, FALSE, 0, ui::Packing::END ); + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_hfiller, TRUE, TRUE, 0, ui::Packing::START); + textureBrowser.m_vframe.set_child_packing( textureBrowser.m_gl_widget, FALSE, FALSE, 0, ui::Packing::END ); + + // The hack needs the GL widget to not be hidden to work, + // so resizing it triggers the redraw of it with the new size. + // GlobalTextureBrowser().m_gl_widget.hide(); - g_TextureBrowser.m_gl_widget.unref(); + // Trigger the redraw. + TextureBrowser_redraw( &GlobalTextureBrowser() ); + ui::process(); + } } +#endif // WORKAROUND_MACOS_GTK2_GLWIDGET const Vector3& TextureBrowser_getBackgroundColour( TextureBrowser& textureBrowser ){ return textureBrowser.color_textureback; @@@ -2804,6 -2664,17 +2853,17 @@@ struct UniformTextureSize } }; + struct UniformTextureMinSize { + static void Export(const TextureBrowser &self, const Callback &returnz) { - returnz(g_TextureBrowser.m_uniformTextureMinSize); ++ returnz(GlobalTextureBrowser().m_uniformTextureMinSize); + } + + static void Import(TextureBrowser &self, int value) { + if (value > 16) + TextureBrowser_setUniformSize(self, value); + } + }; + void TextureBrowser_constructPreferences( PreferencesPage& page ){ page.appendCheckBox( "", "Texture scrollbar", @@@ -2817,15 -2688,11 +2877,11 @@@ make_property(GlobalTextureBrowser()) ); } - page.appendSpinner( - "Texture Thumbnail Size", - GlobalTextureBrowser().m_uniformTextureSize, - GlobalTextureBrowser().m_uniformTextureSize, - 16, 8192 - ); + page.appendSpinner( "Thumbnails Max Size", GlobalTextureBrowser().m_uniformTextureSize, GlobalTextureBrowser().m_uniformTextureSize, 16, 8192 ); + page.appendSpinner( "Thumbnails Min Size", GlobalTextureBrowser().m_uniformTextureMinSize, GlobalTextureBrowser().m_uniformTextureMinSize, 16, 8192 ); page.appendEntry( "Mousewheel Increment", GlobalTextureBrowser().m_mouseWheelScrollIncrement ); { - const char* startup_shaders[] = { "None", TextureBrowser_getComonShadersName() }; + const char* startup_shaders[] = { "None", TextureBrowser_getCommonShadersName() }; page.appendCombo( "Load Shaders at Startup", reinterpret_cast( GlobalTextureBrowser().m_startupShaders ), STRING_ARRAY_RANGE( startup_shaders ) ); } } @@@ -2856,20 -2722,21 +2913,21 @@@ void TextureBrowser_Construct() GlobalCommands_insert( "CopyTag", makeCallbackF(TextureBrowser_copyTag) ); GlobalCommands_insert( "PasteTag", makeCallbackF(TextureBrowser_pasteTag) ); GlobalCommands_insert( "RefreshShaders", makeCallbackF(VFS_Refresh) ); - GlobalToggles_insert( "ShowInUse", makeCallbackF(TextureBrowser_ToggleHideUnused), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hideunused_item ), Accelerator( 'U' ) ); + GlobalToggles_insert( "ShowInUse", makeCallbackF(TextureBrowser_ToggleHideUnused), ToggleItem::AddCallbackCaller( textureBrowser.m_hideunused_item ), Accelerator( 'U' ) ); GlobalCommands_insert( "ShowAllTextures", makeCallbackF(TextureBrowser_showAll), Accelerator( 'A', (GdkModifierType)GDK_CONTROL_MASK ) ); GlobalCommands_insert( "ToggleTextures", makeCallbackF(TextureBrowser_toggleShow), Accelerator( 'T' ) ); - GlobalToggles_insert( "ToggleShowShaders", makeCallbackF(TextureBrowser_ToggleShowShaders), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaders_item ) ); - GlobalToggles_insert( "ToggleShowShaderlistOnly", makeCallbackF(TextureBrowser_ToggleShowShaderListOnly), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_showshaderlistonly_item ) ); - GlobalToggles_insert( "FixedSize", makeCallbackF(TextureBrowser_FixedSize), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_fixedsize_item ) ); - GlobalToggles_insert( "FilterMissing", makeCallbackF(TextureBrowser_FilterMissing), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_filternotex_item ) ); - GlobalToggles_insert( "FilterFallback", makeCallbackF(TextureBrowser_FilterFallback), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_hidenotex_item ) ); - GlobalToggles_insert( "EnableAlpha", makeCallbackF(TextureBrowser_EnableAlpha), ToggleItem::AddCallbackCaller( g_TextureBrowser.m_enablealpha_item ) ); - - GlobalPreferenceSystem().registerPreference( "TextureScale", make_property_string(g_TextureBrowser) ); - GlobalPreferenceSystem().registerPreference( "UniformTextureSize", make_property_string(g_TextureBrowser) ); - GlobalPreferenceSystem().registerPreference( "UniformTextureMinSize", make_property_string(g_TextureBrowser) ); - GlobalPreferenceSystem().registerPreference( "TextureScrollbar", make_property_string(GlobalTextureBrowser())); - GlobalPreferenceSystem().registerPreference( "ShowShaders", make_property_string( GlobalTextureBrowser().m_showShaders ) ); + GlobalToggles_insert( "ToggleShowShaders", makeCallbackF(TextureBrowser_ToggleShowShaders), ToggleItem::AddCallbackCaller( textureBrowser.m_showshaders_item ) ); + GlobalToggles_insert( "ToggleShowShaderlistOnly", makeCallbackF(TextureBrowser_ToggleShowShaderListOnly), ToggleItem::AddCallbackCaller( textureBrowser.m_showshaderlistonly_item ) ); + GlobalToggles_insert( "FixedSize", makeCallbackF(TextureBrowser_FixedSize), ToggleItem::AddCallbackCaller( textureBrowser.m_fixedsize_item ) ); + GlobalToggles_insert( "FilterMissing", makeCallbackF(TextureBrowser_FilterMissing), ToggleItem::AddCallbackCaller( textureBrowser.m_filternotex_item ) ); + GlobalToggles_insert( "FilterFallback", makeCallbackF(TextureBrowser_FilterFallback), ToggleItem::AddCallbackCaller( textureBrowser.m_hidenotex_item ) ); + GlobalToggles_insert( "EnableAlpha", makeCallbackF(TextureBrowser_EnableAlpha), ToggleItem::AddCallbackCaller( textureBrowser.m_enablealpha_item ) ); + + GlobalPreferenceSystem().registerPreference( "TextureScale", make_property_string(textureBrowser) ); + GlobalPreferenceSystem().registerPreference( "UniformTextureSize", make_property_string(textureBrowser) ); ++ GlobalPreferenceSystem().registerPreference( "UniformTextureMinSize", make_property_string(textureBrowser) ); + GlobalPreferenceSystem().registerPreference( "TextureScrollbar", make_property_string(textureBrowser)); + GlobalPreferenceSystem().registerPreference( "ShowShaders", make_property_string( textureBrowser.m_showShaders ) ); GlobalPreferenceSystem().registerPreference( "ShowShaderlistOnly", make_property_string( g_TextureBrowser_shaderlistOnly ) ); GlobalPreferenceSystem().registerPreference( "FixedSize", make_property_string( g_TextureBrowser_fixedSize ) ); GlobalPreferenceSystem().registerPreference( "FilterMissing", make_property_string( g_TextureBrowser_filterMissing ) ); diff --cc radiant/xywindow.h index bf7eb853,3842e8f6..bb9e92dd --- a/radiant/xywindow.h +++ b/radiant/xywindow.h @@@ -124,8 -124,10 +124,12 @@@ void Zoom_End() bool m_zoom_started; guint m_zoom_focusOut; + void ZoomIn(); + void ZoomOut(); + void ZoomInWithMouse( int pointx, int pointy ); + +void Redraw(); + void SetActive( bool b ){ m_bActive = b; };