antsonthetree
Topic Author
Posts: 44
Joined: 09 Jan 2018, 15:56

UE4 C++ Custom Converter Question

26 Jan 2018, 16:31

I am trying to write a ValueConverter in C++ for the UE4 plugin, but it does not seem to be working. It compiles, and the project runs without crashing, but my value is not being converted. The converter is designed to simply return the negative of a float value. I use this with ActualWidth to help me slide panels in from off screen. Below is my code. There isn't a lot of info on the net about writing converters in C++ so I'm probably doing something wrong. Any help would be appreciated.

File: InvertNumberConverter.h
#pragma once

#ifndef __BUTTONS_ELEMENTEXTENSIONS_H__
#define __BUTTONS_ELEMENTEXTENSIONS_H__

#include <NsCore/Noesis.h>
#include <NsCore/ReflectionDeclare.h>
#include <NsGui/DependencyObject.h>
#include <NsGui/BaseValueConverter.h>

namespace NoesisGUIExtensions
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	class InvertNumberConverter final : public Noesis::BaseValueConverter
	{
	public:
		/// From IValueConverter
		//@{
		bool TryConvert(Noesis::BaseComponent* value, const Noesis::Type* targetType,
			Noesis::BaseComponent* parameter, Noesis::Ptr<Noesis::BaseComponent>& result) override;
		//@}

	private:
		NS_DECLARE_REFLECTION(InvertNumberConverter, BaseValueConverter)
	};

}

#endif
File: InvertNumberConverter.cpp
#include "InvertNumberConverter.h"

#include <NsCore/ReflectionImplement.h>
#include <NsCore/TypeId.h>
#include <NsGui/FrameworkElement.h>
#include <NsGui/UIElementData.h>
#include <NsGui/PropertyMetadata.h>
#include <NsGui/Selector.h>
#include <NsGui/PasswordBox.h>
#include <NsGui/TextBox.h>

#include <NsCore/Boxing.h>
#include <NsCore/StringUtils.h>

using namespace NoesisGUIExtensions;
using namespace Noesis;

////////////////////////////////////////////////////////////////////////////////////////////////////
bool InvertNumberConverter::TryConvert(BaseComponent* value, const Type* targetType,
	BaseComponent* parameter, Ptr<BaseComponent>& result)
{
	NS_UNUSED(targetType, parameter);

	//if (Boxing::CanUnbox<int>(value))
	//{
	//	char str[16];
	//	int v = Boxing::Unbox<int>(value);
	//	String::FormatBuffer(str, sizeof(str), "%.2f K", (float)v / 1000.0f);
	//	result = Boxing::Box(str);
	//	return true;
	//}
	if (Boxing::CanUnbox<float>(value))
	{
		float v = Boxing::Unbox<float>(value);
		result = -v;
		return true;
	}

	return false;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
NS_IMPLEMENT_REFLECTION(NoesisGUIExtensions::InvertNumberConverter)
{
	NsMeta<TypeId>("NoesisGUIExtensions.InvertNumberConverter");
}
File: MainMenu.xaml
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions"
  d:DesignWidth="1280" d:DesignHeight="720"
  d:DataContext="{d:DesignData /SampleData/MainMenuSampleData/MainMenuSampleData.xaml}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MenuResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Storyboard x:Key="OnMenuLoaded">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="MainPanel">
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="HostButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="JoinButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="OptionsButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="QuitButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HostButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="JoinButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="OptionsButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="QuitButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="HostButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.7" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.8" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="JoinButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.8" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.9" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="OptionsButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.9" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:1" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="QuitButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:1" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:1.1" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostPanel">
                    <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostButton">
                    <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="MainPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="MainPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="HostPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="HostPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="JoinPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="JoinPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="OptionsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="OptionsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="CheatsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="CheatsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="UnselectAll">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="QuitButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnHostSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnJoinSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnOptionsSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnQuitSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="QuitButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnMainHide">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="MainPanel">
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </ResourceDictionary>
    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource OnMenuLoaded}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="HostButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnHostSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="JoinButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnJoinSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="OptionsButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnOptionsSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="QuitButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnQuitSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="HostFFAButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="HostTDMButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="JoinGameButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="QuitButton">
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid TextElement.FontFamily="Fonts/#Saira" TextElement.FontWeight="SemiBold" TextElement.Foreground="{StaticResource Brush.PrimaryShade75}" noesis:Text.StrokeThickness="1.5">
        <noesis:Text.Stroke>
            <SolidColorBrush Color="{StaticResource Color.PrimaryShade0}" Opacity="0.25"/>
        </noesis:Text.Stroke>
        <Grid x:Name="RefGroup" d:IsLocked="True">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Decorator x:Name="REFx6" Grid.Row="0" Grid.RowSpan="6"/>
            <Decorator x:Name="REFx12" Grid.Row="0" Grid.RowSpan="12"/>
        </Grid>
        <Grid Width="{Binding ActualHeight, ElementName=REFx12}" Height="{Binding ActualHeight, ElementName=REFx6}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="4*"/>
                    <ColumnDefinition Width="7*"/>
                </Grid.ColumnDefinitions>
                <Viewbox Grid.Column="0" Stretch="Uniform" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <ContentControl x:Name="MainPanel" Height="180" Width="180" Style="{StaticResource Style.MenuPanel}">
                        <Grid Margin="0.5,24" KeyboardNavigation.TabNavigation="Cycle">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Button x:Name="HostButton" Grid.Row="0" Content="HOST" Style="{StaticResource Style.MenuButton}"/>
                            <Button x:Name="JoinButton" Grid.Row="1" Content="JOIN" Style="{StaticResource Style.MenuButton}"/>
                            <Button x:Name="OptionsButton" Grid.Row="2" Content="OPTIONS" Style="{StaticResource Style.MenuButton}"/>
                            <Button x:Name="QuitButton" Grid.Row="3" Content="QUIT" Style="{StaticResource Style.MenuButton}" Command="{Binding Quit}"/>
                        </Grid>
                    </ContentControl>
                </Viewbox>
                <Grid Grid.Column="1" x:Name="SelectedPanel">
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top">
                        <ContentControl x:Name="HostPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Height="150" Width="210" Margin="8,0,0,35">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <ComboBox Tag="MAP" ItemsSource="{Binding MapList}" SelectedValue="{Binding SelectedMap}" SelectedIndex="0"/>
                                <ComboBox Tag="BOTS" ItemsSource="{Binding BotCountList}" SelectedValue="{Binding NumBots}" SelectedIndex="1"/>
                                <CheckBox Content="RECORD DEMO" IsChecked="{Binding IsRecordingDemo}"/>
                                <Button x:Name="HostFFAButton" Content="FREE FOR ALL" Command="{Binding HostFFA}" Margin="0,12,0,2"/>
                                <Button x:Name="HostTDMButton" Content="TEAM DEATHMATCH" Command="{Binding HostTDM}"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" d:IsHidden="True">
                        <ContentControl x:Name="JoinPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Height="185" Width="180" Margin="8,0,0,0">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <Button Content="SEARCH SERVER" Command="{Binding SearchServer}" Margin="0,0,0,2"/>
                                <CheckBox Content="DEDICATED" IsChecked="{Binding DedicatedServer}"/>
                                <CheckBox Content="LAN" IsChecked="{Binding LANMatch}"/>
                                <ListBox ItemsSource="{Binding ServerNames}" SelectedIndex="{Binding SelectedServerIndex}" Height="64" Margin="0,2,0,0"/>
                                <Button x:Name="JoinGameButton" Content="JOIN" Command="{Binding JoinGame}" Margin="0,12,0,0"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" d:IsHidden="True">
                        <ContentControl x:Name="OptionsPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Width="220" Height="180" Margin="8,0,0,5">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <ComboBox Tag="RESOLUTION" ItemsSource="{Binding Resolutions}" SelectedIndex="{Binding SelectedResolutionIndex}"/>
                                <ComboBox Tag="QUALITY" ItemsSource="{Binding QualityPresets}" SelectedIndex="{Binding SelectedQualityIndex}"/>
                                <CheckBox Content="FULLSCREEN" IsChecked="{Binding FullScreen}"/>
                                <CheckBox Content="INVERT Y AXIS" IsChecked="{Binding InvertYAxis}"/>
                                <Slider Tag="GAMMA" Minimum="-50" Maximum="50" Value="{Binding Gamma}" SmallChange="1" LargeChange="10"/>
                                <Slider Tag="SENSITIVITY" Minimum="0" Maximum="50" Value="{Binding Sensitivity}" SmallChange="1" LargeChange="10"/>
                                <Button Content="APPLY" Command="{Binding ApplyOptions}" Margin="0,12,0,0"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" d:IsHidden="True">
                        <ContentControl x:Name="CheatsPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Width="200" Height="110" Margin="8,0,0,75">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <CheckBox Content="INFINITE AMMO" IsChecked="{Binding InfiniteAmmo}"/>
                                <CheckBox Content="INFINITE CLIP" IsChecked="{Binding InfiniteClip}"/>
                                <CheckBox Content="FREEZE MATCH TIMER" IsChecked="{Binding FreezeMatchTimer}"/>
                                <CheckBox Content="HEALTH REGENERATION" IsChecked="{Binding HealthRegeneration}"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
Thanks
Jake
 
User avatar
hcpizzi
Site Admin
Posts: 321
Joined: 09 Feb 2012, 12:40

Re: UE4 C++ Custom Converter Question

26 Jan 2018, 17:50

Hi Jake,

I don't see the converter referenced in the xaml. You can take a look at the Scoreboard sample that uses a ThousandConverter class. I've modified the xaml here, but haven't had the time to test it. Hopefully I got it right:
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions"
  d:DesignWidth="1280" d:DesignHeight="720"
  d:DataContext="{d:DesignData /SampleData/MainMenuSampleData/MainMenuSampleData.xaml}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MenuResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <noesis:InvertNumberConverter x:Key="InvertNumberConverter"/>
            <Storyboard x:Key="OnMenuLoaded">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="MainPanel">
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="HostButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="JoinButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="OptionsButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="QuitButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="-10"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HostButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.7" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="JoinButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="OptionsButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:0.9" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="QuitButton">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="0:0:1.1" Value="1">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="HostButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.7" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.8" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="JoinButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.8" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.9" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="OptionsButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:0.9" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:1" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="QuitButton">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:1" Value="False"/>
                    <DiscreteBooleanKeyFrame KeyTime="0:0:1.1" Value="True"/>
                </BooleanAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostPanel">
                    <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostButton">
                    <DiscreteObjectKeyFrame KeyTime="0:0:1.1" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="MainPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="MainPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="HostPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="HostPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="JoinPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="JoinPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="OptionsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="OptionsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="CheatsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="CheatsPanel">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="UnselectAll">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="QuitButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnHostSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="HostButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnJoinSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="JoinButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnOptionsSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsPanel">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Show"/>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="OptionsButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnQuitSelected">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="QuitButton">
                    <DiscreteObjectKeyFrame KeyTime="0" Value="Selected"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="OnMainHide">
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Tag)" Storyboard.TargetName="MainPanel">
                    <DiscreteObjectKeyFrame KeyTime="0:0:0.2" Value="{x:Null}"/>
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
        </ResourceDictionary>
    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource OnMenuLoaded}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="HostButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnHostSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="JoinButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnJoinSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="OptionsButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnOptionsSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="UIElement.GotFocus" SourceName="QuitButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnQuitSelected}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="HostFFAButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="HostTDMButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="JoinGameButton">
            <BeginStoryboard Storyboard="{StaticResource UnselectAll}"/>
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="QuitButton">
            <BeginStoryboard Storyboard="{StaticResource OnMainHide}"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid TextElement.FontFamily="Fonts/#Saira" TextElement.FontWeight="SemiBold" TextElement.Foreground="{StaticResource Brush.PrimaryShade75}" noesis:Text.StrokeThickness="1.5">
        <noesis:Text.Stroke>
            <SolidColorBrush Color="{StaticResource Color.PrimaryShade0}" Opacity="0.25"/>
        </noesis:Text.Stroke>
        <Grid x:Name="RefGroup" d:IsLocked="True">
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Decorator x:Name="REFx6" Grid.Row="0" Grid.RowSpan="6"/>
            <Decorator x:Name="REFx12" Grid.Row="0" Grid.RowSpan="12"/>
        </Grid>
        <Grid Width="{Binding ActualHeight, ElementName=REFx12, Converter={StaticResource InvertNumberConverter}}" Height="{Binding ActualHeight, ElementName=REFx6}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="4*"/>
                    <ColumnDefinition Width="7*"/>
                </Grid.ColumnDefinitions>
                <Viewbox Grid.Column="0" Stretch="Uniform" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <ContentControl x:Name="MainPanel" Height="180" Width="180" Style="{StaticResource Style.MenuPanel}">
                        <Grid Margin="0.5,24" KeyboardNavigation.TabNavigation="Cycle">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Button x:Name="HostButton" Grid.Row="0" Content="HOST" Style="{StaticResource Style.MenuButton}"/>
                            <Button x:Name="JoinButton" Grid.Row="1" Content="JOIN" Style="{StaticResource Style.MenuButton}"/>
                            <Button x:Name="OptionsButton" Grid.Row="2" Content="OPTIONS" Style="{StaticResource Style.MenuButton}"/>
                            <Button x:Name="QuitButton" Grid.Row="3" Content="QUIT" Style="{StaticResource Style.MenuButton}" Command="{Binding Quit}"/>
                        </Grid>
                    </ContentControl>
                </Viewbox>
                <Grid Grid.Column="1" x:Name="SelectedPanel">
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top">
                        <ContentControl x:Name="HostPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Height="150" Width="210" Margin="8,0,0,35">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <ComboBox Tag="MAP" ItemsSource="{Binding MapList}" SelectedValue="{Binding SelectedMap}" SelectedIndex="0"/>
                                <ComboBox Tag="BOTS" ItemsSource="{Binding BotCountList}" SelectedValue="{Binding NumBots}" SelectedIndex="1"/>
                                <CheckBox Content="RECORD DEMO" IsChecked="{Binding IsRecordingDemo}"/>
                                <Button x:Name="HostFFAButton" Content="FREE FOR ALL" Command="{Binding HostFFA}" Margin="0,12,0,2"/>
                                <Button x:Name="HostTDMButton" Content="TEAM DEATHMATCH" Command="{Binding HostTDM}"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" d:IsHidden="True">
                        <ContentControl x:Name="JoinPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Height="185" Width="180" Margin="8,0,0,0">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <Button Content="SEARCH SERVER" Command="{Binding SearchServer}" Margin="0,0,0,2"/>
                                <CheckBox Content="DEDICATED" IsChecked="{Binding DedicatedServer}"/>
                                <CheckBox Content="LAN" IsChecked="{Binding LANMatch}"/>
                                <ListBox ItemsSource="{Binding ServerNames}" SelectedIndex="{Binding SelectedServerIndex}" Height="64" Margin="0,2,0,0"/>
                                <Button x:Name="JoinGameButton" Content="JOIN" Command="{Binding JoinGame}" Margin="0,12,0,0"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" d:IsHidden="True">
                        <ContentControl x:Name="OptionsPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Width="220" Height="180" Margin="8,0,0,5">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <ComboBox Tag="RESOLUTION" ItemsSource="{Binding Resolutions}" SelectedIndex="{Binding SelectedResolutionIndex}"/>
                                <ComboBox Tag="QUALITY" ItemsSource="{Binding QualityPresets}" SelectedIndex="{Binding SelectedQualityIndex}"/>
                                <CheckBox Content="FULLSCREEN" IsChecked="{Binding FullScreen}"/>
                                <CheckBox Content="INVERT Y AXIS" IsChecked="{Binding InvertYAxis}"/>
                                <Slider Tag="GAMMA" Minimum="-50" Maximum="50" Value="{Binding Gamma}" SmallChange="1" LargeChange="10"/>
                                <Slider Tag="SENSITIVITY" Minimum="0" Maximum="50" Value="{Binding Sensitivity}" SmallChange="1" LargeChange="10"/>
                                <Button Content="APPLY" Command="{Binding ApplyOptions}" Margin="0,12,0,0"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                    <Viewbox HorizontalAlignment="Left" VerticalAlignment="Top" d:IsHidden="True">
                        <ContentControl x:Name="CheatsPanel" Style="{StaticResource Style.MenuPanel}" BorderBrush="{StaticResource Brush.PanelBorder.Dark}" Width="200" Height="110" Margin="8,0,0,75">
                            <StackPanel Margin="10" KeyboardNavigation.TabNavigation="Cycle">
                                <CheckBox Content="INFINITE AMMO" IsChecked="{Binding InfiniteAmmo}"/>
                                <CheckBox Content="INFINITE CLIP" IsChecked="{Binding InfiniteClip}"/>
                                <CheckBox Content="FREEZE MATCH TIMER" IsChecked="{Binding FreezeMatchTimer}"/>
                                <CheckBox Content="HEALTH REGENERATION" IsChecked="{Binding HealthRegeneration}"/>
                            </StackPanel>
                        </ContentControl>
                    </Viewbox>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
 
antsonthetree
Topic Author
Posts: 44
Joined: 09 Jan 2018, 15:56

Re: UE4 C++ Custom Converter Question

26 Jan 2018, 18:54

My bad - I posted the wrong xaml file. The converter is used in GameMenu.xaml below.
See lines 43 and 53. I based my C++ implementation on the Thousands converter code, but somethings not working right.
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions" mc:Ignorable="d"
  d:DesignWidth="1280" d:DesignHeight="720"
  d:DataContext="{d:DesignData /SampleData/GameMenuSampleData/GameMenuSampleData.xaml}">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="MenuResources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <noesis:InvertNumberConverter x:Key="InvertNumberConverter" />
            <Storyboard x:Key="OnMenuLoaded">
                <DoubleAnimation Storyboard.TargetName="MenuHeader" Storyboard.TargetProperty="Opacity"
                    From="0" To="1" Duration="0:0:0.5" />
                <DoubleAnimation Storyboard.TargetName="MenuFooter" Storyboard.TargetProperty="Opacity"
                    From="0" To="1" Duration="0:0:0.5" />
                <DoubleAnimation Storyboard.TargetName="MainMenuFlag" Storyboard.TargetProperty="Opacity"
                    From="0" To="1" Duration="0:0:0.5" />
                <DoubleAnimation Storyboard.TargetName="MainMenuFlag" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)"
                   From="{Binding ActualHeight, ElementName=MainMenuFlag, Converter={StaticResource InvertNumberConverter}}" To="0" Duration="0:0:0.5">
                    <DoubleAnimation.EasingFunction>
                        <ElasticEase EasingMode="EaseOut" Oscillations="1" Springiness="4"  />
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
            </Storyboard>
            <Storyboard x:Key="OnMenuClosed">
                <DoubleAnimation Storyboard.TargetName="MainMenuFlag" Storyboard.TargetProperty="Opacity"
                    From="0" To="1" Duration="0:0:0.5" />
                <DoubleAnimation Storyboard.TargetName="MainMenuFlag" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.Y)"
                   From="{Binding ActualHeight, ElementName=MainMenuFlag, Converter={StaticResource InvertNumberConverter}}" To="0" Duration="0:0:0.5">
                    <DoubleAnimation.EasingFunction>
                        <ElasticEase EasingMode="EaseOut" Oscillations="1" Springiness="4"  />
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
            </Storyboard>
            <Storyboard x:Key="OnPlayClicked">
                <DoubleAnimation Storyboard.TargetName="LeftPanel" Storyboard.TargetProperty="Opacity"
                   From="0" To="1" Duration="0:0:0.5" />
                <DoubleAnimation Storyboard.TargetName="LeftPanel" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)"
                   From="{Binding ActualWidth, ElementName=LeftPanel, Converter={StaticResource InvertNumberConverter}}"  To="0" Duration="0:0:0.5">
                    <DoubleAnimation.EasingFunction>
                        <SineEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
            </Storyboard>
            <Storyboard x:Key="OnOptionsClicked">
                <DoubleAnimation Storyboard.TargetName="LeftPanel" Storyboard.TargetProperty="Opacity"
                    To="0" Duration="0:0:0.5" />
                <DoubleAnimation Storyboard.TargetName="LeftPanel" Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)"
                    From="0"  To="{Binding ActualWidth, ElementName=LeftPanel, Converter={StaticResource InvertNumberConverter}}" Duration="0:0:0.5">
                    <DoubleAnimation.EasingFunction>
                        <SineEase EasingMode="EaseOut"/>
                    </DoubleAnimation.EasingFunction>
                </DoubleAnimation>
            </Storyboard>
            <Storyboard x:Key="OnContentClicked">
                <DoubleAnimation Storyboard.TargetName="MainMenuFlag" Storyboard.TargetProperty="Opacity"
                    From="1" To="0" Duration="0:0:0.5" />
            </Storyboard>
        </ResourceDictionary>
    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard Storyboard="{StaticResource OnMenuLoaded}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="QuitButton">
            <BeginStoryboard Storyboard="{StaticResource OnMenuClosed}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="PlayButton">
            <BeginStoryboard Storyboard="{StaticResource OnPlayClicked}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="OptionsButton">
            <BeginStoryboard Storyboard="{StaticResource OnOptionsClicked}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="ContentButton">
            <BeginStoryboard Storyboard="{StaticResource OnContentClicked}"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid TextElement.Foreground="AliceBlue">
        <Grid x:Name="MenuHeader" Height="50" Background="#B2000000" VerticalAlignment="Top" >
            <Label Margin="20,0" Content="MENU TITLE BAR" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="#FFFBF8F8" FontSize="24"/>
        </Grid>
        <Grid x:Name="MenuContent" Margin="0,52">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
                <ColumnDefinition Width="1*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Border x:Name="LeftPanel" Background="#B2000000" Margin="0,0" Padding="20"  Grid.Column="0" Grid.ColumnSpan="3" 
                    RenderTransformOrigin="0,0" >
                <Border.RenderTransform>
                    <TranslateTransform X="{Binding ActualWidth, ElementName=LeftPanel, Converter={StaticResource InvertNumberConverter}}" />
                </Border.RenderTransform>
                <StackPanel Background="#B2000000" KeyboardNavigation.TabNavigation="Cycle">
                    <Button Content="VIDEO" Style="{StaticResource Style.MenuButton}"/>
                    <Button Content="AUDIO" Style="{StaticResource Style.MenuButton}"/>
                    <Button Content="CONTROLS" Style="{StaticResource Style.MenuButton}"/>
                    <Button Content="MOUSE" Style="{StaticResource Style.MenuButton}"/>
                    <Button Content="QUIT" Style="{StaticResource Style.MenuButton}" Command="{Binding Quit}"/>
                </StackPanel>
            </Border>
            <Border Background="#B2000000" Margin="2,0" Grid.Column="3" Grid.ColumnSpan="9" >
            </Border>
            <Border x:Name="MainMenuFlag" Grid.Column="9" Grid.ColumnSpan="2" VerticalAlignment="Top" Margin="0,0,0,0"  Background="#B2000000"
                    RenderTransformOrigin="0.5,0.5">
                <Border.RenderTransform>
                    <TranslateTransform Y="0" />
                </Border.RenderTransform>
                <StackPanel Margin="30" KeyboardNavigation.TabNavigation="Cycle">
                    <Button x:Name="PlayButton" Content="PLAY GAME" Style="{StaticResource Style.MenuButton}"/>
                    <Button x:Name="OptionsButton" Content="OPTIONS" Style="{StaticResource Style.MenuButton}"/>
                    <Button x:Name="ContentButton" Content="CONTENT" Style="{StaticResource Style.MenuButton}"/>
                    <Button x:Name="QuitButton" Content="QUIT" Style="{StaticResource Style.MenuButton}"/>
                </StackPanel>
            </Border>
        </Grid>
        <Grid x:Name="MenuFooter" Height="50" Background="#B2000000" VerticalAlignment="Bottom">
            <Label Margin="20,0" Content="SOME TEXT GOES HERE" VerticalAlignment="Center" HorizontalAlignment="Left" Foreground="#FFFBF8F8" FontSize="14"/>
            <Label Margin="20,0" Content="SOME NOTICE GOES HERE" VerticalAlignment="Center" HorizontalAlignment="Right" Foreground="#FFFBF8F8" FontSize="14"/>
        </Grid>
    </Grid>
</UserControl>
 
antsonthetree
Topic Author
Posts: 44
Joined: 09 Jan 2018, 15:56

Re: UE4 C++ Custom Converter Question

26 Jan 2018, 21:20

UPDATE: I have this working now. Stupid mistake. I missed adding the call to:
NsRegisterComponent<Scoreboard::InvertNumberConverter>();
in the FDefaultGameModuleImpl::StartupModule() function.

FYI - This is not something that is commonly implemented manually, particularly when knocking together a test app for a plugin.
Mostly we'd just use the default macro that is added by the studio:
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MyGame, "MyGame" );

I would definitely add something about this to your UE4 doc when you get around to it! :)

Thanks!
Jake
 
User avatar
hcpizzi
Site Admin
Posts: 321
Joined: 09 Feb 2012, 12:40

Re: UE4 C++ Custom Converter Question

27 Jan 2018, 13:34

I will :)

I forgot to ask you to look in the output log. If a component is not registered you should get a warning message there. This is the output of the Scoreboard sample if I remove the converter registration:
LogNoesis: Warning: /Game/MainWindow.MainWindow(11): Unknown type 'Scoreboard.ThousandConverter'.
LogNoesis: Warning: /Game/MainWindow.MainWindow(95): StaticResource 'ThousandConverter' not found.
LogNoesis: Warning: /Game/MainWindow.MainWindow(96): StaticResource 'ThousandConverter' not found.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 6 guests