From bd28ec81f7442adc5019b2790eeba85afb76f603 Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 27 Oct 2017 18:18:11 +0300 Subject: [PATCH] * View->Show->Entity Connections option --- include/ientity.h | 2 ++ plugins/entity/entity.cpp | 8 ++++++++ plugins/entity/entity.h | 1 + plugins/entity/targetable.cpp | 2 +- plugins/entity/targetable.h | 17 ++++++++++------- radiant/mainframe.cpp | 1 + radiant/xywindow.cpp | 13 +++++++++++++ 7 files changed, 36 insertions(+), 8 deletions(-) diff --git a/include/ientity.h b/include/ientity.h index 7420dea2..9a9f7e25 100644 --- a/include/ientity.h +++ b/include/ientity.h @@ -128,6 +128,8 @@ virtual void setShowNames( bool showNames ) = 0; virtual bool getShowNames() = 0; virtual void setShowBboxes( bool showBboxes ) = 0; virtual bool getShowBboxes() = 0; +virtual void setShowConnections( bool showConnections ) = 0; +virtual bool getShowConnections() = 0; virtual void setShowNamesDist( int dist ) = 0; virtual int getShowNamesDist() = 0; virtual void setShowNamesRatio( int ratio ) = 0; diff --git a/plugins/entity/entity.cpp b/plugins/entity/entity.cpp index bf318de1..23e22f56 100644 --- a/plugins/entity/entity.cpp +++ b/plugins/entity/entity.cpp @@ -114,6 +114,7 @@ Counter* EntityKeyValues::m_counter = 0; bool g_showNames = true; bool g_showBboxes = false; +bool g_showConnections = true; int g_showNamesDist = 512; int g_showNamesRatio = 64; bool g_showTargetNames = false; @@ -278,6 +279,12 @@ void setShowBboxes( bool showBboxes ){ bool getShowBboxes(){ return g_showBboxes; } +void setShowConnections( bool showConnections ){ + g_showConnections = showConnections; +} +bool getShowConnections(){ + return g_showConnections; +} void setShowNamesDist( int dist ){ g_showNamesDist = dist; } @@ -409,6 +416,7 @@ void Entity_Construct( EGameType gameType ){ GlobalPreferenceSystem().registerPreference( "SI_ShowNames", BoolImportStringCaller( g_showNames ), BoolExportStringCaller( g_showNames ) ); GlobalPreferenceSystem().registerPreference( "SI_ShowBboxes", BoolImportStringCaller( g_showBboxes ), BoolExportStringCaller( g_showBboxes ) ); + GlobalPreferenceSystem().registerPreference( "SI_ShowConnections", BoolImportStringCaller( g_showConnections ), BoolExportStringCaller( g_showConnections ) ); GlobalPreferenceSystem().registerPreference( "SI_ShowNamesDist", IntImportStringCaller( g_showNamesDist ), IntExportStringCaller( g_showNamesDist ) ); GlobalPreferenceSystem().registerPreference( "SI_ShowNamesRatio", IntImportStringCaller( g_showNamesRatio ), IntExportStringCaller( g_showNamesRatio ) ); GlobalPreferenceSystem().registerPreference( "SI_ShowTargetNames", BoolImportStringCaller( g_showTargetNames ), BoolExportStringCaller( g_showTargetNames ) ); diff --git a/plugins/entity/entity.h b/plugins/entity/entity.h index 3a748494..c9ae285e 100644 --- a/plugins/entity/entity.h +++ b/plugins/entity/entity.h @@ -41,6 +41,7 @@ void Entity_Destroy(); extern bool g_showNames; extern bool g_showBboxes; +extern bool g_showConnections; extern int g_showNamesDist; extern int g_showNamesRatio; extern bool g_showTargetNames; diff --git a/plugins/entity/targetable.cpp b/plugins/entity/targetable.cpp index e041ee99..fe29b55a 100644 --- a/plugins/entity/targetable.cpp +++ b/plugins/entity/targetable.cpp @@ -34,4 +34,4 @@ targetables_t* getTargetables( const char* targetname ){ return &g_targetnames[targetname]; } -Shader* RenderableTargetingEntity::m_state; +//Shader* RenderableTargetingEntity::m_state; diff --git a/plugins/entity/targetable.h b/plugins/entity/targetable.h index 9a775526..bea09bdf 100644 --- a/plugins/entity/targetable.h +++ b/plugins/entity/targetable.h @@ -289,7 +289,7 @@ const TargetingEntities& get() const { }; - +#if 0 class RenderableTargetingEntity { TargetingEntity& m_targets; @@ -314,13 +314,13 @@ void render( Renderer& renderer, const VolumeTest& volume, const Vector3& world_ } } }; - +#endif class RenderableTargetingEntities { const TargetingEntities& m_targets; mutable RenderablePointVector m_target_lines; public: -static Shader* m_state; +//static Shader* m_state; RenderableTargetingEntities( const TargetingEntities& targets ) : m_targets( targets ), m_target_lines( GL_LINES ){ @@ -416,6 +416,7 @@ const TargetingEntities& getTargeting() const { } }; +#include "entity.h" class RenderableConnectionLines : public Renderable { @@ -432,10 +433,12 @@ void detach( TargetableInstance& instance ){ } void renderSolid( Renderer& renderer, const VolumeTest& volume ) const { - for ( TargetableInstances::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i ) - { - if ( ( *i )->path().top().get().visible() ) { - ( *i )->render( renderer, volume ); + if( g_showConnections ){ + for ( TargetableInstances::const_iterator i = m_instances.begin(); i != m_instances.end(); ++i ) + { + if ( ( *i )->path().top().get().visible() ) { + ( *i )->render( renderer, volume ); + } } } } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index e611a6fe..cc257205 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -2082,6 +2082,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity _Names", "ShowNames" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Light Radiuses", "ShowLightRadiuses" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity Boxes", "ShowBboxes" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity Connections", "ShowConnections" ); menu_separator( menu_in_menu ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index 5fd12131..055bd75d 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -3184,6 +3184,18 @@ void ShowBboxesToggle(){ UpdateAllWindows(); } +void ShowConnectionsExport( const BoolImportCallback& importer ){ + importer( GlobalEntityCreator().getShowConnections() ); +} +typedef FreeCaller1 ShowConnectionsExportCaller; +ShowConnectionsExportCaller g_show_connections_caller; +ToggleItem g_show_connections( g_show_connections_caller ); +void ShowConnectionsToggle(){ + GlobalEntityCreator().setShowConnections( !GlobalEntityCreator().getShowConnections() ); + g_show_connections.update(); + UpdateAllWindows(); +} + void ShowAnglesExport( const BoolImportCallback& importer ){ importer( GlobalEntityCreator().getShowAngles() ); } @@ -3324,6 +3336,7 @@ void XYShow_registerCommands(){ GlobalToggles_insert( "ShowAngles", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_angles ) ); GlobalToggles_insert( "ShowNames", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_names ) ); GlobalToggles_insert( "ShowBboxes", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_bboxes ) ); + GlobalToggles_insert( "ShowConnections", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_connections ) ); GlobalToggles_insert( "ShowBlocks", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_blocks ) ); GlobalToggles_insert( "ShowCoordinates", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_coordinates ) ); GlobalToggles_insert( "ShowWindowOutline", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_outline ) );