* Entity Inspector->smartedit: enable array, target, targetname, skin attribute types

* Entity Inspector->smartedit: enable texture attribute type, add full shader path autocompletion
	* fix lags, caused by texture entries autocompletion
This commit is contained in:
Garux 2018-03-01 04:01:18 +03:00
parent 286f784ecf
commit 565f7fc6db
3 changed files with 80 additions and 35 deletions

View File

@ -52,11 +52,12 @@
/// array an array of strings - value is a semi-colon-delimited string
/// integer an integer value
/// boolean an integer - shows as a checkbox - true = non-zero
/// integer2 two integer values
/// integer3 three integer values
/// real3 three floating-point values
/// integer2 two integer values //not supported
/// integer3 three integer values //not supported
/// real floating-point value
/// angle specialisation of real - Yaw angle
/// direction specialisation of real - Yaw angle, -1 = down, -2 = up
/// real3 three floating-point values
/// angles specialisation of real3 - Pitch Yaw Roll
/// color specialisation of real3 - RGB floating-point colour
/// target a string that uniquely identifies an entity or group of entities
@ -233,16 +234,16 @@ std::size_t write( const char* data, std::size_t length ){
};
bool attributeSupported( const char* name ){
return string_equal( name, "real" )
return string_equal( name, "string" )
|| string_equal( name, "array" )
|| string_equal( name, "integer" )
|| string_equal( name, "boolean" )
|| string_equal( name, "string" )
|| string_equal( name, "array" )
|| string_equal( name, "flag" )
|| string_equal( name, "real3" )
|| string_equal( name, "integer2" )
|| string_equal( name, "integer3" )
|| string_equal( name, "direction" )
|| string_equal( name, "real" )
|| string_equal( name, "angle" )
|| string_equal( name, "direction" )
|| string_equal( name, "real3" )
|| string_equal( name, "angles" )
|| string_equal( name, "color" )
|| string_equal( name, "target" )
@ -251,7 +252,7 @@ bool attributeSupported( const char* name ){
|| string_equal( name, "texture" )
|| string_equal( name, "model" )
|| string_equal( name, "skin" )
|| string_equal( name, "integer2" );
|| string_equal( name, "flag" );
}
typedef std::map<CopiedString, ListAttributeType> ListAttributeTypes;

View File

@ -224,6 +224,17 @@ ShaderAttribute( const char* key ) : StringAttribute( key ){
}
};
class TextureAttribute : public StringAttribute
{
public:
TextureAttribute( const char* key ) : StringAttribute( key ){
if( string_empty( GlobalRadiant().getGameDescriptionKeyValue( "show_wads" ) ) )
GlobalAllShadersEntryCompletion::instance().connect( StringAttribute::getEntry() ); // with textures/
else
GlobalTextureEntryCompletion::instance().connect( StringAttribute::getEntry() ); // w/o
}
};
class ColorAttribute : public EntityAttribute
{
@ -1079,18 +1090,23 @@ Creators m_creators;
public:
EntityAttributeFactory(){
m_creators.insert( Creators::value_type( "string", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "color", &StatelessAttributeCreator<ColorAttribute>::create ) );
m_creators.insert( Creators::value_type( "array", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "integer", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "real", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "shader", &StatelessAttributeCreator<ShaderAttribute>::create ) );
m_creators.insert( Creators::value_type( "boolean", &StatelessAttributeCreator<BooleanAttribute>::create ) );
m_creators.insert( Creators::value_type( "real", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "angle", &StatelessAttributeCreator<AngleAttribute>::create ) );
m_creators.insert( Creators::value_type( "direction", &StatelessAttributeCreator<DirectionAttribute>::create ) );
m_creators.insert( Creators::value_type( "angles", &StatelessAttributeCreator<AnglesAttribute>::create ) );
m_creators.insert( Creators::value_type( "model", &StatelessAttributeCreator<ModelAttribute>::create ) );
m_creators.insert( Creators::value_type( "sound", &StatelessAttributeCreator<SoundAttribute>::create ) );
m_creators.insert( Creators::value_type( "vector3", &StatelessAttributeCreator<Vector3Attribute>::create ) );
m_creators.insert( Creators::value_type( "real3", &StatelessAttributeCreator<Vector3Attribute>::create ) );
m_creators.insert( Creators::value_type( "angles", &StatelessAttributeCreator<AnglesAttribute>::create ) );
m_creators.insert( Creators::value_type( "color", &StatelessAttributeCreator<ColorAttribute>::create ) );
m_creators.insert( Creators::value_type( "target", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "targetname", &StatelessAttributeCreator<StringAttribute>::create ) );
m_creators.insert( Creators::value_type( "sound", &StatelessAttributeCreator<SoundAttribute>::create ) );
m_creators.insert( Creators::value_type( "shader", &StatelessAttributeCreator<ShaderAttribute>::create ) );
m_creators.insert( Creators::value_type( "texture", &StatelessAttributeCreator<TextureAttribute>::create ) );
m_creators.insert( Creators::value_type( "model", &StatelessAttributeCreator<ModelAttribute>::create ) );
m_creators.insert( Creators::value_type( "skin", &StatelessAttributeCreator<StringAttribute>::create ) );
}
EntityAttribute* create( const char* type, const char* name ){
Creators::iterator i = m_creators.find( type );

View File

@ -37,9 +37,14 @@ template<typename StringList>
class EntryCompletion
{
GtkListStore* m_store;
IdleDraw m_idleUpdate;
bool m_invalid;
public:
EntryCompletion() : m_store( 0 ), m_idleUpdate( UpdateCaller( *this ) ){
EntryCompletion() : m_store( 0 ), m_invalid( true ){
}
static gboolean focus_in( GtkEntry* entry, GdkEventFocus *event, EntryCompletion* self ){
self->update();
return FALSE;
}
void connect( GtkEntry* entry ){
@ -48,13 +53,14 @@ void connect( GtkEntry* entry ){
fill();
StringList().connect( IdleDraw::QueueDrawCaller( m_idleUpdate ) );
StringList().connect( InvalidateCaller( *this ) );
}
GtkEntryCompletion* completion = gtk_entry_completion_new();
gtk_entry_set_completion( entry, completion );
gtk_entry_completion_set_model( completion, GTK_TREE_MODEL( m_store ) );
gtk_entry_completion_set_text_column( completion, 0 );
g_signal_connect( G_OBJECT( entry ), "focus_in_event", G_CALLBACK( focus_in ), this );
}
void append( const char* string ){
@ -66,6 +72,7 @@ typedef MemberCaller1<EntryCompletion, const char*, &EntryCompletion::append> Ap
void fill(){
StringList().forEach( AppendCaller( *this ) );
m_invalid = false;
}
void clear(){
@ -73,19 +80,26 @@ void clear(){
}
void update(){
if( m_invalid ){
clear();
fill();
}
}
typedef MemberCaller<EntryCompletion, &EntryCompletion::update> UpdateCaller;
void invalidate(){
m_invalid = true;
}
typedef MemberCaller<EntryCompletion, &EntryCompletion::invalidate> InvalidateCaller;
};
/* loaded ( shaders + textures ) */
class TextureNameList
{
public:
void forEach( const ShaderNameCallback& callback ) const {
for ( QERApp_ActiveShaders_IteratorBegin(); !QERApp_ActiveShaders_IteratorAtEnd(); QERApp_ActiveShaders_IteratorIncrement() )
{
IShader *shader = QERApp_ActiveShaders_IteratorCurrent();
const IShader *shader = QERApp_ActiveShaders_IteratorCurrent();
if ( shader_equal_prefix( shader->getName(), "textures/" ) ) {
callback( shader->getName() + 9 );
@ -99,7 +113,21 @@ void connect( const SignalHandler& update ) const {
typedef Static< EntryCompletion<TextureNameList> > GlobalTextureEntryCompletion;
/* shaders + loaded textures */
class AllShadersNameList
{
public:
void forEach( const ShaderNameCallback& callback ) const {
GlobalShaderSystem().foreachShaderName( callback );
}
void connect( const SignalHandler& update ) const {
TextureBrowser_addActiveShadersChangedCallback( update );
}
};
typedef Static< EntryCompletion<AllShadersNameList> > GlobalAllShadersEntryCompletion;
/* shaders + may also include plain textures, loaded before first use */
class ShaderList
{
public: