public static IDisposable AddTalkButton(string icon, Action <Button> onCreated, TalkSceneActionKind targetMenu)
        {
            if (icon == null)
            {
                throw new ArgumentNullException(nameof(icon));
            }
            if (onCreated == null)
            {
                throw new ArgumentNullException(nameof(onCreated));
            }
            if (targetMenu == TalkSceneActionKind.Listen)
            {
                throw new NotSupportedException("TalkSceneActionKind.Listen does not support adding custom buttons");
            }
            if (!Enum.IsDefined(typeof(TalkSceneActionKind), targetMenu))
            {
                throw new InvalidEnumArgumentException(nameof(targetMenu), (int)targetMenu, typeof(TalkSceneActionKind));
            }

            var entry = new TalkButtonEntry(icon, onCreated, targetMenu);

            _buttons.Add(entry);

            return(Disposable.Create(() =>
            {
                _buttons.Remove(entry);
                entry.Dispose();
            }));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Register a new conversation button in talk scenes in roaming mode.
 /// (the white buttons you get when you click on the buttons on the right when talking to someone, for example "Confess", "Excercise together")
 /// Dispose the return value to remove the button (It will not be created anymore and have to be re-added. If inside a talk scene the button will be removed immediately).
 /// </summary>
 /// <param name="text">Text of the new button.</param>
 /// <param name="onCreated">Action to run after the icon is created.
 /// Use to subscribe to the onClick event and/or attach extra code to the button, e.g. by using <see cref="ObservableTriggerExtensions.UpdateAsObservable(Component)"/> and similar methods.</param>
 /// <param name="targetMenu">Which submenu to put your button under (from the 3 buttons on right, only top and bottom buttons can be used here).</param>
 public static IDisposable AddTalkButton(string text, Action <Button> onCreated, TalkSceneActionKind targetMenu)
 {
     if (StudioAPI.InsideStudio)
     {
         return(Disposable.Empty);
     }
     return(TalkSceneCustomButtons.AddTalkButton(text, onCreated, targetMenu));
 }
 public TalkButtonEntry(string text, Action <Button> onCreated, TalkSceneActionKind targetMenu)
 {
     TargetMenu = targetMenu;
     Text       = text;
     OnCreated  = onCreated;
 }
Ejemplo n.º 4
0
 public static IDisposable AddTalkButton(string text, Action <Button> onCreated, TalkSceneActionKind targetMenu)
 {
     throw new NotImplementedException("Not implemented yet");
     //if (StudioAPI.InsideStudio) return Disposable.Empty;
     //return TalkSceneCustomButtons.AddTalkButton(text, onCreated, targetMenu);
 }