]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit '461d008daa6328113ea4ccda37e5604d3df14ba3' into garux-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 22 Feb 2021 23:49:09 +0000 (00:49 +0100)
committerThomas Debesse <dev@illwieckz.net>
Mon, 22 Feb 2021 23:49:09 +0000 (00:49 +0100)
16 files changed:
1  2 
libs/gtkutil/accelerator.cpp
libs/picomodel/pm_mdc.c
libs/stringio.h
plugins/md3model/md5.cpp
radiant/camwindow.cpp
radiant/eclass_doom3.cpp
radiant/entity.cpp
radiant/entity.h
radiant/entityinspector.cpp
radiant/mainframe.cpp
radiant/preferences.cpp
radiant/preferences.h
radiant/texwindow.cpp
radiant/xywindow.cpp
tools/quake3/common/scriplib.c
tools/quake3/q3map2/portals.c

Simple merge
index 235dcecf9467c0ca90d1508e0fef403e1adf285e,aac525b8bb5c83f29c6329d9f098503a4425ca91..5139da0245b7eb9db165f9f723c6f4ec44119f6a
  #include "picointernal.h"
  
  /* mdc model format */
 -#define MDC_MAGIC           "IDPC"
 -#define MDC_VERSION         2
 +const char *MDC_MAGIC = "IDPC";
 +const int MDC_VERSION = 2;
  
  /* mdc vertex scale */
 -#define MDC_SCALE           ( 1.0f / 64.0f )
 -#define MDC_MAX_OFS         127.0f
 -#define MDC_DIST_SCALE      0.05f
 +const float MDC_SCALE           = ( 1.0f / 64.0f );
 +const float MDC_MAX_OFS         = 127.0f;
 +const float MDC_DIST_SCALE      = 0.05f;
  
  /* mdc decoding normal table */
- double mdcNormals[ 256 ][ 3 ] =
const double mdcNormals[ 256 ][ 3 ] =
  {
        { 1.000000, 0.000000, 0.000000 },
        { 0.980785, 0.195090, 0.000000 },
diff --cc libs/stringio.h
index 227927291ebbe8b8ebf37e1f6cc93631da26dbf1,83572e2fbcc0d70f735512eff2f464407e69f467..544b433674a73ca292a37168150e08c886fde2af
@@@ -220,7 -219,8 +220,7 @@@ inline bool string_parse_size( const ch
  }
  
  
- #define RETURN_FALSE_IF_FAIL(expression) do { if (!(expression)) return false; } while (0)
 -//#define RETURN_FALSE_IF_FAIL( expression ) if ( !expression ) {return false; }else
+ #define RETURN_FALSE_IF_FAIL( expression ) do{ if ( !expression ) {return false; } }while( 0 )
  
  inline void Tokeniser_unexpectedError( Tokeniser& tokeniser, const char* token, const char* expected ){
        globalErrorStream() << Unsigned( tokeniser.getLine() ) << ":" << Unsigned( tokeniser.getColumn() ) << ": parse error at '" << ( token != 0 ? token : "#EOF" ) << "': expected '" << expected << "'\n";
index e1c5de56d23f0ea0e4ec149a6c62115d9a0992b8,6da4b7205ba2e7c70217b8942a4952d2c0b6fe87..8fea68d7844ba904a28318b9a4dfa3ac7547f44d
@@@ -29,7 -29,8 +29,7 @@@
  
  #include "model.h"
  
- #define MD5_RETURN_FALSE_IF_FAIL(expression) do { if (!(expression)) { globalErrorStream() << "md5 parse failed: " #expression "\n"; return false; } } while (0)
 -//#define MD5_RETURN_FALSE_IF_FAIL( expression ) if ( !( expression ) ) { globalErrorStream() << "md5 parse failed: " # expression "\n"; return false; } else
+ #define MD5_RETURN_FALSE_IF_FAIL( expression ) do{ if ( !( expression ) ) { globalErrorStream() << "md5 parse failed: " # expression "\n"; return false; } }while( 0 )
  
  bool MD5_parseToken( Tokeniser& tokeniser, const char* string ){
        const char* token = tokeniser.getToken();
index 283e36c515da9156e36951bb48e26baf0f7f6081,1c782e43ad455c5374961a8465cd032d04294955..2e412badcfe5b71184d5c68c0abfa1e2042065c8
@@@ -837,8 -843,9 +837,9 @@@ void camwnd_update_xor_rectangle( CamWn
  }
  
  
 -gboolean selection_button_press( GtkWidget* widget, GdkEventButton* event, WindowObserver* observer ){
 +gboolean selection_button_press( ui::Widget widget, GdkEventButton* event, WindowObserver* observer ){
        if ( event->type == GDK_BUTTON_PRESS ) {
+               gtk_widget_grab_focus( widget );
                observer->onMouseDown( WindowVector_forDouble( event->x, event->y ), button_for_button( event->button ), modifiers_for_state( event->state ) );
        }
        return FALSE;
@@@ -880,7 -886,12 +881,12 @@@ gboolean selection_motion_freemove( ui:
        return FALSE;
  }
  
 -gboolean wheelmove_scroll( GtkWidget* widget, GdkEventScroll* event, CamWnd* camwnd ){
 +gboolean wheelmove_scroll( ui::Widget widget, GdkEventScroll* event, CamWnd* camwnd ){
+       //gtk_window_set_focus( camwnd->m_parent, camwnd->m_gl_widget );
+       gtk_widget_grab_focus( camwnd->m_gl_widget );
+       if( !gtk_window_is_active( camwnd->m_parent ) )
+               gtk_window_present( camwnd->m_parent );
        if ( event->direction == GDK_SCROLL_UP ) {
                Camera_Freemove_updateAxes( camwnd->getCamera() );
                if( camwnd->m_bFreeMove || !g_camwindow_globals.m_bZoomInToPointer ){
index 4c7525ea4fdb9219bd60c0b958946954c5b2db5a,a358dccea4fcbdfc2b06065f6ca6bc864ba22c91..b6a5344037ef8b6038e51bc8ce2dcf2f30947f7c
@@@ -84,7 -84,8 +84,7 @@@ inline void printParseError( const char
        globalErrorStream() << message;
  }
  
- #define PARSE_RETURN_FALSE_IF_FAIL(expression) do { if (!( expression)) { printParseError(FILE_LINE "\nparse failed: " #expression "\n"); return false; } } while (0)
 -//#define PARSE_RETURN_FALSE_IF_FAIL( expression ) if ( !( expression ) ) { printParseError( FILE_LINE "\nparse failed: " # expression "\n" ); return false; } else
+ #define PARSE_RETURN_FALSE_IF_FAIL( expression ) do{ if ( !( expression ) ) { printParseError( FILE_LINE "\nparse failed: " # expression "\n" ); return false; } }while( 0 )
  
  bool EntityClassDoom3_parseToken( Tokeniser& tokeniser ){
        const char* token = tokeniser.getToken();
Simple merge
index fca38f92cd4c598852325ceccc19a725b4f9912f,9096287a63eb3179e95d5fa1a0cf780e39db9335..d655774cde72d9207c9a34ecfd01fcf0e5cbf8a9
@@@ -32,9 -30,12 +32,10 @@@ void Scene_EntitySetKeyValue_Selected( 
  void Scene_EntitySetClassname_Selected( const char* classname );
  
  
 -typedef struct _GtkWidget GtkWidget;
 -const char* misc_model_dialog( GtkWidget* parent );
 +const char* misc_model_dialog( ui::Widget parent );
+ void Entity_setColour();
  
 -typedef struct _GtkMenu GtkMenu;
 -void Entity_constructMenu( GtkMenu* menu );
 +void Entity_constructMenu( ui::Menu menu );
  
  void Entity_Construct();
  void Entity_Destroy();
index 349d5d09b5fd34d47f3bf14f3a807121bbd6cd24,4905cf0141c7b46deb37fbe620cb21d3d47cb35c..564d7173e3cfb328a9dbf4554fa5849567e9d1e0
@@@ -209,6 -222,52 +209,52 @@@ ShaderAttribute( const char* key ) : St
  };
  
  
 -GtkWidget* getWidget() const {
 -      return GTK_WIDGET( m_entry.m_entry.m_frame );
+ class ColorAttribute : public EntityAttribute
+ {
+ CopiedString m_key;
+ BrowsedPathEntry m_entry;
+ NonModalEntry m_nonModal;
+ public:
+ ColorAttribute( const char* key ) :
+       m_key( key ),
+       m_entry( BrowseCaller( *this ) ),
+       m_nonModal( ApplyCaller( *this ), UpdateCaller( *this ) ){
+       m_nonModal.connect( m_entry.m_entry.m_entry );
+ }
+ void release(){
+       delete this;
+ }
 -typedef MemberCaller<ColorAttribute, &ColorAttribute::apply> ApplyCaller;
++ui::Widget getWidget() const {
++      return ui::Widget( m_entry.m_entry.m_frame );
+ }
+ void apply(){
+       StringOutputStream value( 64 );
+       value << gtk_entry_get_text( GTK_ENTRY( m_entry.m_entry.m_entry ) );
+       Scene_EntitySetKeyValue_Selected_Undoable( m_key.c_str(), value.c_str() );
+ }
 -typedef MemberCaller<ColorAttribute, &ColorAttribute::update> UpdateCaller;
++typedef MemberCaller<ColorAttribute, void(), &ColorAttribute::apply> ApplyCaller;
+ void update(){
+       StringOutputStream value( 64 );
+       value << SelectedEntity_getValueForKey( m_key.c_str() );
+       gtk_entry_set_text( GTK_ENTRY( m_entry.m_entry.m_entry ), value.c_str() );
+ }
 -typedef MemberCaller1<ColorAttribute, const BrowsedPathEntry::SetPathCallback&, &ColorAttribute::browse> BrowseCaller;
++typedef MemberCaller<ColorAttribute, void(), &ColorAttribute::update> UpdateCaller;
+ void browse( const BrowsedPathEntry::SetPathCallback& setPath ){
+       //const char *filename = misc_model_dialog( gtk_widget_get_toplevel( GTK_WIDGET( m_entry.m_entry.m_frame ) ) );
+       /* hijack BrowsedPathEntry to call colour chooser */
+       Entity_setColour();
+ //    if ( filename != 0 ) {
+ //            setPath( filename );
+ //            apply();
+ //    }
+       update();
+ }
++typedef MemberCaller<ColorAttribute, void(const BrowsedPathEntry::SetPathCallback&), &ColorAttribute::browse> BrowseCaller;
+ };
  class ModelAttribute : public EntityAttribute
  {
  CopiedString m_key;
@@@ -832,7 -892,35 +878,37 @@@ void SetComment( EntityClass* eclass )
  
        g_current_comment = eclass;
  
 +      g_entityClassComment.text(eclass->comments());
++
+       GtkTextBuffer* buffer = gtk_text_view_get_buffer( g_entityClassComment );
+       //gtk_text_buffer_set_text( buffer, eclass->comments(), -1 );
+       const char* comment = eclass->comments(), *c;
+       int offset = 0, pattern_start = -1, spaces = 0;
+       gtk_text_buffer_set_text( buffer, comment, -1 );
+       // Catch patterns like "\nstuff :" used to describe keys and spawnflags, and make them bold for readability.
+       for( c = comment; *c; ++c, ++offset ) {
+               if( *c == '\n' ) {
+                       pattern_start = offset;
+                       spaces = 0;
+               }
+               else if( pattern_start >= 0 && ( *c < 'a' || *c > 'z' ) && ( *c < 'A' || *c > 'Z' ) && ( *c < '0' || *c > '9' ) && ( *c != '_' ) ) {
+                       if( *c == ':' && spaces <= 1 ) {
+                               GtkTextIter iter_start, iter_end;
+                               gtk_text_buffer_get_iter_at_offset( buffer, &iter_start, pattern_start );
+                               gtk_text_buffer_get_iter_at_offset( buffer, &iter_end, offset );
+                               gtk_text_buffer_apply_tag_by_name( buffer, "bold", &iter_start, &iter_end );
+                       }
+                       if( *c == ' ' )
+                               ++spaces;
+                       else
+                               pattern_start = -1;
+               }
+       }
  }
  
  void SurfaceFlags_setEntityClass( EntityClass* eclass ){
@@@ -1391,13 -1482,17 +1467,17 @@@ ui::Widget EntityInspector_constructWin
                                gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW( scr ), GTK_SHADOW_IN );
  
                                {
 -                                      GtkTextView* text = GTK_TEXT_VIEW( gtk_text_view_new() );
 -                                      gtk_widget_set_size_request( GTK_WIDGET( text ), 0, -1 ); // allow shrinking
 +                                      auto text = ui::TextView(ui::New);
 +                                      text.dimensions(0, -1); // allow shrinking
                                        gtk_text_view_set_wrap_mode( text, GTK_WRAP_WORD );
                                        gtk_text_view_set_editable( text, FALSE );
 -                                      gtk_widget_show( GTK_WIDGET( text ) );
 -                                      gtk_container_add( GTK_CONTAINER( scr ), GTK_WIDGET( text ) );
 +                                      text.show();
 +                                      scr.add(text);
                                        g_entityClassComment = text;
+                                       {
+                                               GtkTextBuffer *buffer = gtk_text_view_get_buffer( text );
+                                               gtk_text_buffer_create_tag( buffer, "bold", "weight", PANGO_WEIGHT_BOLD, NULL );
+                                       }
                                }
                        }
                }
index 133b4a75bfd5666ef2ab8203738185acd5a36412,1c956db0b9cf341a3f8b610f7af4b4a01095439f..4e4efa67fb9ac9cee605ad1d2ef517eaeaef29b9
@@@ -594,18 -432,34 +594,34 @@@ void Paths_registerPreferencesPage()
  class PathsDialog : public Dialog
  {
  public:
 -GtkWindow* BuildDialog(){
 -      GtkFrame* frame = create_dialog_frame( "Path settings", GTK_SHADOW_ETCHED_IN );
 +ui::Window BuildDialog(){
 +      auto frame = create_dialog_frame( "Path settings", ui::Shadow::ETCHED_IN );
  
 -      GtkVBox* vbox2 = create_dialog_vbox( 0, 4 );
 -      gtk_container_add( GTK_CONTAINER( frame ), GTK_WIDGET( vbox2 ) );
 +      auto vbox2 = create_dialog_vbox( 0, 4 );
 +      frame.add(vbox2);
  
+       const char* engine;
+ #if defined( WIN32 )
+       engine = g_pGameDescription->getRequiredKeyValue( "engine_win32" );
+ #elif defined( __linux__ ) || defined ( __FreeBSD__ )
+       engine = g_pGameDescription->getRequiredKeyValue( "engine_linux" );
+ #elif defined( __APPLE__ )
+       engine = g_pGameDescription->getRequiredKeyValue( "engine_macos" );
+ #else
+ #error "unsupported platform"
+ #endif
+       StringOutputStream text( 256 );
+       text << "Select directory, where game executable sits (typically \"" << engine << "\")\n";
+       GtkLabel* label = GTK_LABEL( gtk_label_new( text.c_str() ) );
+       gtk_widget_show( GTK_WIDGET( label ) );
+       gtk_container_add( GTK_CONTAINER( vbox2 ), GTK_WIDGET( label ) );
        {
 -              PreferencesPage preferencesPage( *this, GTK_WIDGET( vbox2 ) );
 +              PreferencesPage preferencesPage( *this, vbox2 );
                Paths_constructPreferences( preferencesPage );
        }
  
-       return ui::Window(create_simple_modal_dialog_window( "Engine Path Not Found", m_modal, frame ));
 -      return create_simple_modal_dialog_window( "Engine Path Configuration", m_modal, GTK_WIDGET( frame ) );
++      return ui::Window(create_simple_modal_dialog_window( "Engine Path Configuration", m_modal, frame ));
  }
  };
  
Simple merge
Simple merge
index a76c0d99e912783deb95ad95e949b4a96d09d771,efc5f4327e8c2dca4b6cf2b19e651c8a19a0c072..00969834e90e47146e3a65723589043bb39c1885
@@@ -1475,8 -1376,9 +1476,9 @@@ void BuildStoreAvailableTags(   ui::Lis
        }
  }
  
 -gboolean TextureBrowser_button_press( GtkWidget* widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
 +gboolean TextureBrowser_button_press( ui::Widget widget, GdkEventButton* event, TextureBrowser* textureBrowser ){
        if ( event->type == GDK_BUTTON_PRESS ) {
+               gtk_widget_grab_focus( widget );
                if ( event->button == 3 ) {
                        if ( GlobalTextureBrowser().m_tags ) {
                                textureBrowser->m_rmbSelected = true;
@@@ -1553,7 -1452,11 +1555,11 @@@ gboolean TextureBrowser_motion( ui::Wid
        return FALSE;
  }
  
 -gboolean TextureBrowser_scroll( GtkWidget* widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){
 +gboolean TextureBrowser_scroll( ui::Widget widget, GdkEventScroll* event, TextureBrowser* textureBrowser ){
+       gtk_widget_grab_focus( widget );
+       if( !gtk_window_is_active( textureBrowser->m_parent ) )
+               gtk_window_present( textureBrowser->m_parent );
        if ( event->direction == GDK_SCROLL_UP ) {
                TextureBrowser_MouseWheel( *textureBrowser, true );
        }
index 6da0a4b25fefd0907a712493a7da1f2906553915,9a1be033098b674ac0b98e939d380e732b14e308..3e81deefa49f0c974b8107a358e1b223de017a57
@@@ -749,8 -744,10 +749,10 @@@ void xy_update_xor_rectangle( XYWnd& se
        }
  }
  
 -gboolean xywnd_button_press( GtkWidget* widget, GdkEventButton* event, XYWnd* xywnd ){
 +gboolean xywnd_button_press( ui::Widget widget, GdkEventButton* event, XYWnd* xywnd ){
        if ( event->type == GDK_BUTTON_PRESS ) {
+               gtk_widget_grab_focus( xywnd->GetWidget() );
                if( !xywnd->Active() ){
                        g_pParentWnd->SetActiveXY( xywnd );
                }
@@@ -789,7 -786,12 +791,12 @@@ void xywnd_motion( gdouble x, gdouble y
        reinterpret_cast<XYWnd*>( data )->XY_MouseMoved( static_cast<int>( x ), static_cast<int>( y ), buttons_for_state( state ) );
  }
  
 -gboolean xywnd_wheel_scroll( GtkWidget* widget, GdkEventScroll* event, XYWnd* xywnd ){
 +gboolean xywnd_wheel_scroll( ui::Widget widget, GdkEventScroll* event, XYWnd* xywnd ){
+       gtk_widget_grab_focus( xywnd->GetWidget() );
 -      GtkWindow* window = xywnd->m_parent != 0 ? xywnd->m_parent : MainFrame_getWindow();
++      ui::Window window = xywnd->m_parent ? xywnd->m_parent : MainFrame_getWindow();
+       if( !gtk_window_is_active( window ) )
+               gtk_window_present( window );
        if( !xywnd->Active() ){
                g_pParentWnd->SetActiveXY( xywnd );
        }
Simple merge
Simple merge