From 87d5b6efe557ee73b613c030cca2374dd23bc1be Mon Sep 17 00:00:00 2001 From: Garux Date: Wed, 2 Aug 2017 09:17:58 +0300 Subject: [PATCH] menus... * view->show: +Entity Names = Targetnames (option to draw targetnames, not classnames; def = no) --- include/ientity.h | 2 ++ plugins/entity/entity.cpp | 8 ++++++++ plugins/entity/entity.h | 1 + plugins/entity/namedentity.h | 6 +++++- radiant/mainframe.cpp | 1 + radiant/xywindow.cpp | 13 +++++++++++++ 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/ientity.h b/include/ientity.h index c315b3ab..5c09d2c4 100644 --- a/include/ientity.h +++ b/include/ientity.h @@ -126,6 +126,8 @@ virtual void setLightRadii( bool lightRadii ) = 0; virtual bool getLightRadii() = 0; virtual void setShowNames( bool showNames ) = 0; virtual bool getShowNames() = 0; +virtual void setShowTargetNames( bool showNames ) = 0; +virtual bool getShowTargetNames() = 0; virtual void setShowAngles( bool showAngles ) = 0; virtual bool getShowAngles() = 0; diff --git a/plugins/entity/entity.cpp b/plugins/entity/entity.cpp index c862459e..0dd32115 100644 --- a/plugins/entity/entity.cpp +++ b/plugins/entity/entity.cpp @@ -111,6 +111,7 @@ EntityCreator::KeyValueChangedFunc KeyValue::m_entityKeyValueChanged = 0; Counter* EntityKeyValues::m_counter = 0; bool g_showNames = true; +bool g_showTargetNames = false; bool g_showAngles = true; bool g_newLightDraw = true; bool g_lightRadii = true; @@ -264,6 +265,12 @@ void setShowNames( bool showNames ){ bool getShowNames(){ return g_showNames; } +void setShowTargetNames( bool showNames ){ + g_showTargetNames = showNames; +} +bool getShowTargetNames(){ + return g_showTargetNames; +} void setShowAngles( bool showAngles ){ g_showAngles = showAngles; } @@ -368,6 +375,7 @@ void Entity_Construct( EGameType gameType ){ } GlobalPreferenceSystem().registerPreference( "SI_ShowNames", BoolImportStringCaller( g_showNames ), BoolExportStringCaller( g_showNames ) ); + GlobalPreferenceSystem().registerPreference( "SI_ShowTargetNames", BoolImportStringCaller( g_showTargetNames ), BoolExportStringCaller( g_showTargetNames ) ); GlobalPreferenceSystem().registerPreference( "SI_ShowAngles", BoolImportStringCaller( g_showAngles ), BoolExportStringCaller( g_showAngles ) ); GlobalPreferenceSystem().registerPreference( "NewLightStyle", BoolImportStringCaller( g_newLightDraw ), BoolExportStringCaller( g_newLightDraw ) ); GlobalPreferenceSystem().registerPreference( "LightRadiuses", BoolImportStringCaller( g_lightRadii ), BoolExportStringCaller( g_lightRadii ) ); diff --git a/plugins/entity/entity.h b/plugins/entity/entity.h index ae294ab7..ba5f991f 100644 --- a/plugins/entity/entity.h +++ b/plugins/entity/entity.h @@ -39,6 +39,7 @@ void Entity_Construct( EGameType gameType = eGameTypeQuake3 ); void Entity_Destroy(); extern bool g_showNames; +extern bool g_showTargetNames; extern bool g_showAngles; extern bool g_newLightDraw; extern bool g_lightRadii; diff --git a/plugins/entity/namedentity.h b/plugins/entity/namedentity.h index 29170d9e..e29aa524 100644 --- a/plugins/entity/namedentity.h +++ b/plugins/entity/namedentity.h @@ -26,6 +26,7 @@ #include "eclasslib.h" #include "generic/callback.h" #include "nameable.h" +#include "entity.h" //g_showTargetNames #include @@ -62,6 +63,9 @@ const char* name() const { } return m_name.c_str(); } +const char* classname() const { + return m_entity.getEntityClass().name(); +} void attach( const NameCallback& callback ){ m_changed.insert( callback ); } @@ -92,7 +96,7 @@ RenderableNamedEntity( const NamedEntity& named, const Vector3& position ) } void render( RenderStateFlags state ) const { glRasterPos3fv( vector3_to_array( m_position ) ); - GlobalOpenGL().drawString( m_named.name() ); + GlobalOpenGL().drawString( g_showTargetNames ? m_named.name() : m_named.classname() ); } }; diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index b93e1e26..04e7b000 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -1994,6 +1994,7 @@ GtkMenuItem* create_view_menu( MainFrame::EViewStyle style ){ } create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity _Angles", "ShowAngles" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Entity _Names", "ShowNames" ); + create_check_menu_item_with_mnemonic( menu_in_menu, "Entity Names = Targetnames", "ShowTargetNames" ); create_check_menu_item_with_mnemonic( menu_in_menu, "Show Light Radiuses", "ShowLightRadiuses" ); menu_separator( menu_in_menu ); diff --git a/radiant/xywindow.cpp b/radiant/xywindow.cpp index f82ab0d2..ee957abe 100644 --- a/radiant/xywindow.cpp +++ b/radiant/xywindow.cpp @@ -2840,6 +2840,18 @@ void ShowNamesToggle(){ XY_UpdateAllWindows(); } +void ShowTargetNamesExport( const BoolImportCallback& importer ){ + importer( GlobalEntityCreator().getShowTargetNames() ); +} +typedef FreeCaller1 ShowTargetNamesExportCaller; +ShowTargetNamesExportCaller g_show_targetnames_caller; +ToggleItem g_show_targetnames( g_show_targetnames_caller ); +void ShowTargetNamesToggle(){ + GlobalEntityCreator().setShowTargetNames( !GlobalEntityCreator().getShowTargetNames() ); + g_show_targetnames.update(); + XY_UpdateAllWindows(); +} + void ShowAnglesExport( const BoolImportCallback& importer ){ importer( GlobalEntityCreator().getShowAngles() ); } @@ -2951,6 +2963,7 @@ void XYShow_registerCommands(){ GlobalToggles_insert( "ShowAngles", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_angles ) ); GlobalToggles_insert( "ShowNames", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_names ) ); + GlobalToggles_insert( "ShowTargetNames", FreeCaller(), ToggleItem::AddCallbackCaller( g_show_targetnames ) ); 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 ) ); -- 2.39.2