Esempio n. 1
0
        protected override void HandleEvent(ActionBarButtonStateChangedEventArgs args)
        {
            //TODO: Check actionbar index and handle multiple rows.
            if (ActionBarRow.ContainsKey(args.Index))
            {
                IUIActionBarButton barButton = ActionBarRow[args.Index];

                if (args.ActionType == ActionBarIndexType.Empty)
                {
                    barButton.SetElementActive(false);
                }
                else
                {
                    barButton.SetElementActive(true);

                    //TODO: Refactor for spell/item
                    if (args.ActionType == ActionBarIndexType.Spell)
                    {
                        //TODO: Abstract the icon content loading
                        //TODO: Don't assume we have the content icon. Throw/log better exception
                        SpellDefinitionDataModel definition = SpellDataCollection.GetSpellDefinition(args.ActionId);
                        ContentIconInstanceModel icon       = ContentIconCollection[definition.SpellIconId];

                        ProjectVersionStage.AssertAlpha();
                        //TODO: Load async
                        Texture2D iconTexture = Resources.Load <Texture2D>(Path.Combine("Icon", Path.GetFileNameWithoutExtension(icon.IconPathName)));
                        barButton.ActionBarImageIcon.SetSpriteTexture(iconTexture);
                    }
                    else
                    {
                        throw new InvalidOperationException($"TODO: Implement empty/item action bar support");
                    }
                }
            }
        }