-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep entity property type names to be used by smart editors #4293
Comments
I would suggest to keep this simple and just extend the smart editor matcher for the color editor to cover the cases you want. We can of course extend the matchers to look at the property definitions, too. But remember that not all FGDs are well maintained, so we would prefer to keep everything working without having any property definitions. That's also the reason for the current design.
I think this enum can be mostly replaced by using The target related properties are indeed outliers. But this is a larger topic. Currently, the names of these properties ( This whole process is pretty involved, and could arguably do with an overhaul. But to get back to your issue: If you want to make targetname etc. configurable via the FGD, you have to keep these caches working. One part of this puzzle is
No, I wouldn't do this. Rather, I would prefer it if we have an independent and concrete model of the property definitions that TB supports (via classnames or an enum or anything that can be checked by the compiler), and map whatever we read from FGD files to this model. The reason is that TB supports various kinds of entity definition files (FGD, DEF, ENT), and in the future we might want to add more. If we leak info that is specific to a specific file format directly into the editor, we will have to support any special cases that come along with these string types names forever. That sounds like a maintenance nightmare to me.
I would not do this either, the game config files are already too complex, and we should rather try to use the entity definitions for this. To summarize: You can fix your specific problem by extending the smart editor matcher to include any property that contains the word "color" or "colour". That sounds like a simple solution. But I would also be open to a solution that leverages info from the FGD files in addition to "just" the property names to improve the matcher. But this would require some refactoring of TB's entity property definitions to represent the property type we read from the FGD file. I'd be open to this and would like to help to design this, if you want to go this route. |
Oh, I didn't see the issue for FGD property types, that pretty much covers the issues I'm facing with the colour editor, so maybe it'd be better to close this out in favour of that one? I'm willing to help out the implementation once a good design can be worked out. I get where you're coming from in regards to the extra maintenance added by leaking the definition through to the rest of the app. I didn't really consider that aspect. Changing the smart editor matcher would get 80% of the way there, but I'd really also like to be able to tell the difference between a There's also the slightly more complicated cases of
So if we wanted first-class support for these, we'd need to either hard-code this behaviour into the app, or alternatively add some optional syntax to TB FGDs for this to be configured (it should be noted that Source2 FGDs have some additional syntax that might be useful in this space). Either way doesn't sound very nice in my opinion, is there a better approach? (I realise that file browser smart editors are not in scope for now, but if changes are being made in this area then it would be nice to try and cover this potential future functionality as well) |
I have some code that's already implemented this change to some degree, but I think it deserves some discussion beforehand in case there's better possibilities.
Currently TB has "smart editors" for:
FlagsProperty
definition type)ChoiceProperty
definition type)What I would like (for now) is for the "color" smart editor to be a bit more flexible than just matching by name - for example, HL has a standard key called
rendercolor
on almost all brush entities. Instead of just including more hard-coded names in the smart editor, it would be great if the behaviour could instead be driven by the data types available in the entity definition format, if it's available.FGDs also have multiple colour types:
color1
andcolor255
to indicate RGB colours that should have components of either float (1 0 0.5) or byte (255 0 127). It would be great if the colour smart editor would have access to see if one of these two types are used and automatically select the correct colour formatting to use instead of relying on the user to know which option to select.Additionally I think the current
PropertyDefinitionType
enum is serving a dual purpose that isn't currently used and could be replaced by a change like this. The enum values are currently:If we ignore the first two types (and arguably,
ChoiceProperty
), they all seem to make sense - they represent the underlying data type that the value stores. ButTargetSourceProperty
andTargetDestinationProperty
are outliers, in my opinion. Those two values are represented as strings internally so it makes sense they areStringProperties
, much like thecolor
properties are also represented as strings and don't have their own specialColorProperty
entry in the enum.My first thought was to simply add a
ColorProperty
type to this enum and update the code to match. However, this wouldn't allow thecolor1
andcolor255
types to make it to the smart editor, so you would need multiple colour properties, such asColor1Property
,Color255Property
, and thenColorProperty
as a fallback type for entity definitions that don't specify the exact storage method. This starts to get quite shaky as you add more property types (FGD by itself has quite a few at this point, though you wouldn't need smart editors for the majority of them).I think a better option would be to add a new field to the
PropertyDefinition
calledtypeName
(or similar) which retains the original value of the property's type from the FGD/DEF file. ThetypeName
can then be used by smart editors and potentially other editor features as a "hint" which informs us more specifically what the value's purpose is.This would not only be useful for removing hard-coding of property names from the code (e.g.
"color", "*_color", "*_color2", "*_colour"
), but would also allow for easier future extension of new types and smart editors (e.g. a file browser for sprite/model/sound paths is very useful for HL editing and HL FGDs usesprite
,studio
, andsound
property types for this purpose).I also think a change like this would open up the possibilities of moving the smart editor configuration into the game config, rather than hard-coding it into the editor - much like how the "tags" functionality already works. This would make configuration of "generic" game types much more flexible, as it could be changed by the user without needing to recompile the code.
For example, perhaps one day HL could be configured like:
The text was updated successfully, but these errors were encountered: