View Issue Details

IDProjectCategoryView StatusLast Update
0002682NoesisGUIC# SDKpublic2023-09-08 20:02
Reporterstonstad Assigned Tosfernandez  
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.2.1 
Target Version3.2.2Fixed in Version3.2.2 
Summary0002682: Repeatable Crash On Keyboard Input
DescriptionWhen I press the down key I get an immediate crash.

=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at Noesis.View:Noesis_View_KeyDown <0x000fe>
      at Noesis.View:KeyDown <0x000da>
      at NoesisView:ProcessEvent <0x0189a>
      at NoesisView:OnGUI <0x0030a>
      at System.Object:runtime_invoke_void__this__ <0x00187>
=================================================================

I see this in the log file and it may be related. I'm working to remove this error.

[NOESIS/W] Virtualization disabled: available viewport size is Infinite
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object,UnityEngine.Object)
UnityEngine.Debug:LogWarning (object,UnityEngine.Object)
NoesisUnity:UnityLog (int,string) (at D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/NoesisUnity.cs:355)
Noesis.View:Update (double) (at D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/API/Core/View.cs:368)
NoesisView:UpdateInternal () (at D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/NoesisView.cs:1455)
NoesisView:LateUpdate () (at D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/NoesisView.cs:1356)

(Filename: D:/Source/StellarConquest/StellarConquest.Utilities/Noesis/3.2.1/Runtime/NoesisUnity.cs Line: 355)


TagsNo tags attached.
PlatformAny

Activities

stonstad

stonstad

2023-09-08 18:12

reporter  

EmotesControl.xaml (2,138 bytes)   
<UserControl
    x:Class="StellarConquest.Presentation.Unity.UI.EmotesControl"
    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:local="clr-namespace:StellarConquest.Presentation.Unity.UI">
    <Grid x:Name="_LayoutRoot" HorizontalAlignment="Center" VerticalAlignment="Center">
        <local:BorderControlTitle x:Name="_BorderControl" TitleText="Emotes" BlurLayer="{DynamicResource BaseLayerBlurSource}">
            <Grid x:Name="_Grid" Margin="25, 15, 25, 25">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="0, 0, 0, 15" Visibility="Collapsed">
                    <ToggleButton x:Name="_SortButton" Style="{StaticResource DefaultUI.ToggleBlue}" Margin="0, 0, 33, 0">
                        <ContentControl ContentTemplate="{StaticResource sort_svg}" Width="30" Height="30"/>
                    </ToggleButton>
                </StackPanel>

                <StackPanel x:Name="_RecentEmotesStackPanel" Grid.Row="1" Orientation="Vertical" Margin="0, 0, 0, 3" Visibility="Collapsed">
                    <ListBox x:Name="_RecentEmotesListBox" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"/>
                    <local:DecorLineControl VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0, -2, 0, -2"/>
                </StackPanel>

                <ListBox x:Name="_EmotesListBox" Grid.Row="2" ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderBrush="Transparent" Background="Transparent" Height="300"/>
            </Grid>
        </local:BorderControlTitle>
    </Grid>
</UserControl>
EmotesControl.xaml (2,138 bytes)   
EmotesControl.cs (6,065 bytes)   
using Noesis;
using System.Collections.Generic;
using System.Linq;
using GUI = Noesis.GUI;
using NoesisEventArgs = Noesis.EventArgs;
using StellarConquest.Model.Extensions;

namespace StellarConquest.Presentation.Unity.UI
{
    public partial class EmotesControl : OverlayControl
    {
        public static readonly IReadOnlyList<string> Emotes = new List<string>()
        {
            "angry hurt", "angry point", "anticipate", "apex", "argue", "ashamed", "backhand", "beckon", "blame", "bow", "boxing", "brush off", "cheer", "chicken", "come at me", "conduct", "cough", "cough arm", "crazy", "cry", "cry slow", "dab left", "dab right", "dang", "despair", "drum", "embrace", "encourage", "exasperation", "exhaustion", "explain", "face palm", "faint", "frustration", "giggle", "glory spin", "grateful", "groin", "gunslinger", "hat tip", "headache", "hook line", "horns", "i can't hear you", "idea", "ignore", "impatient", "impatient foot", "jig", "karate kick", "kick ground", "knuckles", "lasso", "laugh", "laugh belly", "maca", "mime", "moonwalk", "mr universe", "nailed it", "nervous", "no more", "no way", "no", "nod", "nod left", "nod right", "over here", "pain", "please", "point behind", "point down", "point forward", "point left", "point right", "raise the roof", "rally", "regret", "relief", "ride bull", "ride bull circle", "robot", "sad", "salutations", "salute", "sarcastic clap", "scared", "shake behind", "shoot me now", "shut up", "slit throat", "stair walk", "stop", "that way", "the finger", "the wave", "think", "tired", "tired stretch", "touchdown", "up yours", "victory", "waiting", "warm up", "wave", "wave gentle", "wave long", "what", "winning", "yes"
        };

        private FrameworkElement _Root;
        private ToggleButton _SortButton;
        private StackPanel _RecentEmotesStackPanel;
        private ListBox _RecentEmotesListBox;
        private ListBox _EmotesListBox;

        private List<string> _Emotes = new List<string>(Emotes);
        private List<string> _RecentEmotes = new List<string>();

        public string SelectedEmote { get; private set; }

        public EmotesControl()
        {
            Name = nameof(EmotesControl);
            Initialized += OnInitialized;
            InitializeComponent();
        }

        protected override void InitializeComponent()
        {
            base.InitializeComponent();
            GUI.LoadComponent(this, "Assets/User Interface/Screens/Game/Overlay/Emotes/EmotesControl.xaml");

            _Root = Content as FrameworkElement;
            _SortButton = _Root.FindName(nameof(_SortButton)) as ToggleButton;
            _RecentEmotesStackPanel = _Root.FindName("_RecentEmotesStackPanel") as StackPanel;
            _RecentEmotesListBox = _Root.FindName("_RecentEmotesListBox") as ListBox;
            _EmotesListBox = _Root.FindName("_EmotesListBox") as ListBox;
        }

        protected override void OnInitialized(object sender, NoesisEventArgs args)
        {
            base.OnInitialized(sender, args);

            _SortButton.Checked += (sender, e) =>
            {
                _Emotes = _Emotes.OrderBy(a => a).ToList();
                Update();
            };

            _SortButton.Unchecked += (sender, e) =>
            {
                _Emotes = _Emotes.OrderByDescending(a => a).ToList();
                Update();
            };

            UIUtility.SetToolTip(_SortButton, "Sort Emotes", null, "sort_svg", "Sorts emotes by name or last used date");
        }

        public void Update(List<string> emotes = null)
        {
            if (emotes != null)
                _Emotes = emotes.OrderByDescending(a => a).ToList();

            SelectedEmote = null;

            if (_RecentEmotes.Count == 0)
                _RecentEmotesStackPanel.Visibility = Visibility.Collapsed;
            else
            {
                _RecentEmotesListBox.Items.Clear();
                foreach (string emote in _RecentEmotes)
                {
                    ListBoxItem item = CreateRow(emote);
                    _RecentEmotesListBox.Items.Add(item);
                }
                _RecentEmotesStackPanel.Visibility = Visibility.Visible;
            }

            _EmotesListBox.Items.Clear();
            foreach (string emote in _Emotes)
            {
                ListBoxItem item = CreateRow(emote);
                _EmotesListBox.Items.Add(item);
            }

            _EmotesListBox.ScrollIntoView(_EmotesListBox.Items[0]);
            _EmotesListBox.UpdateLayout();
        }

        private ListBoxItem CreateRow(string emote)
        {
            string svgIcon = "emoteminimal_svg";

            string emoteLabel = emote.ToTitleCase();
            StackPanel stackPanel = UIUtility.CreateActionLabel(_Root, emoteLabel, svgIcon, emoteLabel);

            ((FrameworkElement)stackPanel.Children[1]).Margin = new Thickness(0, 0, 5, 0);
            ((FrameworkElement)stackPanel.Children[1]).HorizontalAlignment = HorizontalAlignment.Stretch;

            ListBoxItem item = new ListBoxItem();
            item.Content = stackPanel;
            item.Margin = new Thickness(0, 0, 3, 0);

            item.PreviewKeyDown += (sender, e) =>
            {
                SelectedEmote = emote;
                _RecentEmotes.Insert(0, SelectedEmote);
                if (_RecentEmotes.Count > 3)
                    _RecentEmotes.RemoveAt(3);
                Hide();
            };

            item.MouseDown += (sender, e) =>
            {
                SelectedEmote = emote;
            };

            item.MouseDoubleClick += (sender, e) =>
            {
                SelectedEmote = emote;
                _RecentEmotes.Insert(0, SelectedEmote);
                if (_RecentEmotes.Count > 3)
                    _RecentEmotes.RemoveAt(3);
                Hide();
            };

            item.Content = stackPanel;

            return item;
        }
    }
}
EmotesControl.cs (6,065 bytes)   
stonstad

stonstad

2023-09-08 18:15

reporter   ~0008711

For clarification purposes, this is a patched version of 3.2.1 that I'm using.
stonstad

stonstad

2023-09-08 18:21

reporter   ~0008712

Phew! OK, this is an easy fix. I had some bad logic. It likely shouldn't crash, but it works. Here's the change:

Original:

           item.PreviewKeyDown += (sender, e) =>
            {
                    SelectedEmote = emote;
                    _RecentEmotes.Insert(0, SelectedEmote);
                    if (_RecentEmotes.Count > 3)
                        _RecentEmotes.RemoveAt(3);
                    Hide();
            };

New:

           item.PreviewKeyDown += (sender, e) =>
            {
                if (e.Key == Key.Enter)
                {
                    SelectedEmote = emote;
                    _RecentEmotes.Insert(0, SelectedEmote);
                    if (_RecentEmotes.Count > 3)
                        _RecentEmotes.RemoveAt(3);
                    Hide();
                }
            };
sfernandez

sfernandez

2023-09-08 20:02

manager   ~0008713

Fixed in changeset 12716

Issue History

Date Modified Username Field Change
2023-09-08 18:12 stonstad New Issue
2023-09-08 18:12 stonstad File Added: Crash_2023-09-08_154015070.zip
2023-09-08 18:12 stonstad File Added: EmotesControl.xaml
2023-09-08 18:12 stonstad File Added: EmotesControl.cs
2023-09-08 18:15 stonstad Note Added: 0008711
2023-09-08 18:21 stonstad Note Added: 0008712
2023-09-08 20:00 sfernandez Assigned To => sfernandez
2023-09-08 20:00 sfernandez Status new => assigned
2023-09-08 20:00 sfernandez Target Version => 3.2.2
2023-09-08 20:02 sfernandez Status assigned => resolved
2023-09-08 20:02 sfernandez Resolution open => fixed
2023-09-08 20:02 sfernandez Fixed in Version => 3.2.2
2023-09-08 20:02 sfernandez Note Added: 0008713