GeorgeR
Topic Author
Posts: 39
Joined: 15 Mar 2018, 01:06

Static members not supported?

05 Apr 2018, 15:02

I'm binding to a static enum value but apparently I can't. Is there another way of doing this?
                                <StackPanel Grid.Row="3"
                                            Orientation="Horizontal"
                                            FlowDirection="RightToLeft">
                                    <Button x:Name="CancelButton" Content="Cancel" Visibility="{Binding ButtonSet, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HasFlagToVisibilityConverter}, ConverterParameter={x:Static controls:ButtonSet.Cancel}}"/>
                                    <Button x:Name="NoButton" Content="No" Visibility="{Binding ButtonSet, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HasFlagToVisibilityConverter}, ConverterParameter={x:Static controls:ButtonSet.No}}"/>
                                    <Button x:Name="YesButon" Content="Yes" Visibility="{Binding ButtonSet, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HasFlagToVisibilityConverter}, ConverterParameter={x:Static controls:ButtonSet.Yes}}"/>
                                    <Button x:Name="OkButton" Content="Ok" Visibility="{Binding ButtonSet, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource HasFlagToVisibilityConverter}, ConverterParameter={x:Static controls:ButtonSet.Ok}}"/>
                                </StackPanel>
 
User avatar
hcpizzi
Site Admin
Posts: 316
Joined: 09 Feb 2012, 12:40

Re: Static members not supported?

16 Apr 2018, 21:23

Hi George,

I'm looking into this at the moment. I'm assuming ButtonSet is an UENUM, is that correct?

The problem lies in the names used to register the Unreal type wrappers with the Noesis reflection system. At the moment, the Unreal path is used. This has the form /Script/<ModuleName>.<TypeName> for native C++ types, and <Root>/<Path>/<Package>.<ObjectName> for Blueprint based enums, structs and classes, where <Root> will most likely be /Game, but potentially can be /Engine, /<PluginName> (apparently plugins are the way to add DLC at the moment, so it's important) and maybe others i have missed.

Those names contain characters that are not supported (the slashes), and even without those they wouldn't be convenient to use.

I'm looking to replace those with XAML friendly names, and I've come up with several options, and I'd like to hear which one would you prefer, or if you have any other ideas.

The first option would be to stick all the types in a flat namespace named after the project. This is simple, but on the blueprint side more than one object can have the same name, as long as they're on different folders.

Hence option two. Use the project name as the root package, then use the path as nested namespaces. So, say, if you have a blueprint class in /Game/UI/Blueprints/MyClass.MyClass, then you'd refer to it in XAML by declaring a mapping for the namespace, like xmlns:bp="clr-namespace:<ProjectName>.UI.Blueprints" and then bp:MyClass.

Native classes could either use a similar approach, using the module name as part of the namespace, with or without the <ProjectName> at the beginning, or they could still be left as flat with just the project name. Flat has the problem that Unreal still lets you have a BlueprintClass that has the same name as a native class, so collisions are again a possibility, but you may end up having to declare more namespace mappings (although probably you'll only have one runtime module with code in the game).

I'd like to hear your feedback. Right now I'm definitely leaning towards using the asset path as part of the namespace for blueprint types, but I'm undecided about using module names for native types, since those are more obscure and really no one should really have to know about modules other than their own game's, so I'm more on the single namespace named after the project camp. Maybe we could use <ProjectName> for native classes, and <ProjectName>BP for blueprint?

Anyway, I'm ready to implement these changes, the only thing I need is the naming convention, so if you have any preference, please let us know.

Thanks in advance
 
GeorgeR
Topic Author
Posts: 39
Joined: 15 Mar 2018, 01:06

Re: Static members not supported?

17 Apr 2018, 06:06

Yeah ButtonSet is a UENUM. I'd do the same for both Blueprints and Native, except Native wouldn't have folder paths, so it would be
<ProjectName>.EnumClassName
or (for BPs in folders) <ProjectName>.FolderA.FolderB.EnumClassNameBlueprint

So yeah it would be (for the blueprint):
xmlns:bp="clr-namespace:<ProjectName>.FolderA.FolderB"
bp:EnumClassNameBlueprint
 
User avatar
hcpizzi
Site Admin
Posts: 316
Joined: 09 Feb 2012, 12:40

Re: Static members not supported?

23 Apr 2018, 15:05

Hi,

I just committed the changes to GitHub. I tried to be as conservative as possible to avoid breaking things. What I do is an initial scan of the assets to create a map from the names used to register the unreal types to the real unreal names of the UClass/UStruct/UEnum. When a class that's not registered is needed, that map is used to find the type to register, and if it isn't found another scan is performed just to play it safe that it won't miss anything. I think that second scan should never be triggered in a cooked game, but I decided to put it there just in case.

As always, please let us know if you find any problems with the code.

Who is online

Users browsing this forum: No registered users and 105 guests