Esempio n. 1
0
        public void ActionBarWithSingleAction()
        {
            new MockGlobal();

            var frameProviderMock = new Mock <IFrameProvider>();

            Global.FrameProvider = frameProviderMock.Object;

            var framesMock = new Mock <IFrames>();

            var uiParent = (IFrame)Global.FrameProvider.CreateFrame(FrameType.Frame, "UIParent");

            framesMock.Setup(frames => frames.UIParent).Returns(uiParent);
            Global.Frames = framesMock.Object;

            frameProviderMock.Setup(fp => fp.CreateFrame(FrameType.Button, It.IsAny <string>(), Global.Frames.UIParent))
            .Returns(new Mock <IButton>().Object);


            var actionButtonMocks = new List <Mock <IActionButtonProxy> >();

            var actionBar = new ActionBar((parent) =>
            {
                var actionButtonMock = new Mock <IActionButtonProxy>();
                actionButtonMocks.Add(actionButtonMock);
                return(actionButtonMock.Object);
            });

            var             id1    = "id1";
            var             icon1  = "icon1";
            Action <string> click1 = (id) => { };
            Action <string, IGameTooltip> tooltip1    = (id, TT) => { };
            Func <string, ICooldownInfo>  getCooldown = (id) => new CooldownInfo();

            actionBar.AddButton(id1, icon1, click1, tooltip1, getCooldown);

            Assert.AreEqual(1, actionButtonMocks.Count);
            var mock1 = actionButtonMocks[0];

            mock1.VerifySet(b => b.Id = id1);
            mock1.Verify(b => b.SetIcon(icon1), Times.Once());
            mock1.Verify(b => b.SetOnClick(click1), Times.Once());
            mock1.Verify(b => b.SetTooltipFunc(tooltip1), Times.Once());
        }
Esempio n. 2
0
        private void TempShowActionBar()
        {
            var    duration = 5;
            double?castTime = null;
            var    bar      = new ActionBar((frame) => new ActionButtonProxy(frame, this.wrapper));

            bar.AddButton("test", "Interface/ICONS/INV_Misc_Bag_11", s =>
            {
                castTime = Global.Api.GetTime();
                Core.print("test");
            },
                          (s, tooltip) => { tooltip.AddLine("Test"); },
                          (s) => new CooldownInfo()
            {
                Active    = castTime != null && Global.Api.GetTime() < castTime + duration,
                Duration  = duration,
                StartTime = castTime
            });
            bar.Show();
        }
Esempio n. 3
0
 /// <summary>
 /// Logic that handles selecting two groups of event stubs, and then executing a given action when
 /// both groups are selected and the Finish button is pressed.
 /// </summary>
 private void InitDualGroupSelection(Action<HashSet<EventStub>, HashSet<EventStub>> onSelectionEnd)
 {
     HashSet<EventStub> firstSet = new HashSet<EventStub>();
     HashSet<EventStub> secondSet = new HashSet<EventStub>();
     //all onClick actions
     Action<EventStub> highlightGreen = (EventStub evnt) => SetEventColor(evnt, Color.green);
     Action<EventStub> highlightMagenta = (EventStub evnt) => SetEventColor(evnt, Color.magenta);
     Action<EventStub> addToFirst = (EventStub e) => firstSet.Add(e);
     Action<EventStub> addToSecond = (EventStub e) => secondSet.Add(e);
     onEventLeftClick.Add(addToFirst);
     onEventLeftClick.Add(highlightGreen);
     ActionBar bar = new ActionBar(true);
     bar.AddButton("Cancel", () =>
     {
         onEventLeftClick.Remove(addToFirst);
         onEventLeftClick.Remove(addToSecond);
         onEventLeftClick.Remove(highlightGreen);
         onEventLeftClick.Remove(highlightMagenta);
         ResetEventColors(firstSet.Union(secondSet));
         parent.PopActionBar();
     });
     bar.AddButton("Next", () => 
         {
             onEventLeftClick.Remove(addToFirst);
             onEventLeftClick.Remove(highlightGreen);
             onEventLeftClick.Add(highlightMagenta);
             onEventLeftClick.Add(addToSecond);
             bar.RemoveButton("Next");
             bar.AddButton("Finish", () =>
             {
                 onEventLeftClick.Remove(addToSecond);
                 parent.PopActionBar();
                 onEventLeftClick.Remove(highlightMagenta);
                 ResetEventColors(firstSet.Union(secondSet));
                 onSelectionEnd.Invoke(firstSet, secondSet);
             });
         });
     parent.AddActionBar(bar);
 }
Esempio n. 4
0
 /// <summary>
 /// The default bar for selecting a new crowd.
 /// </summary>
 private ActionBar SelectCrowdBar()
 {
     ActionBar result = new ActionBar(true);
     result.AddToggle("Crowd Static", (bool b) => crowdStatic = b);
     result.AddButton("Cancel", Reset);
     return result;
 }
Esempio n. 5
0
    /// <summary>
    /// The default bar, shown when the GUI is first opened,and when event selection is finished.
    /// </summary>
    private ActionBar DefaultBar()
    {
        ActionBar result = new ActionBar(true);
        result.AddButton(new GUIContent("Select Crowd", "Select a crowd by spatial parameters"), StartCrowdSelection);
        result.AddButton(new GUIContent("Options", "Change options for FillIn and ordering of new Events"), 
            () => actionBars.Add(optionsBar));
        result.AddButton(new GUIContent("Clear", "Clear all Events and SmartObjects from the window"), 
            () => { mainWindow.Clear(); mainArea = mainWindow = mainWindow.Copy(); });
        result.AddButton(new GUIContent("Play", "Play the scene. Changes can not be made anymore once playback starts"),
            () => { highlighter.UnhighlightAll(); mainWindow.Play();  });
        result.AddButton("Load/Save", StartLoadSave);
        result.AddButton("Reset", () =>
        {
            StoryArcSerializer.Instance.Delete(StoryArcSerializer.TEMP_FILE_NAME, false);
            ImporterExporter.TrySaveToTemp();
            //clear all events there, otherwise it tries using destroyed smart objects 
            AuthoredEventManager.Instance.ClearAllEvents();
            //must clear all receivers from the behavior manager, else if a tree is running everything crashes
            BehaviorManager.Instance.ClearReceivers();
            //must deregister all current objects here, otherwise they stay in manager as null objects..
            foreach (SmartObject obj in new List<SmartObject>(ObjectManager.Instance.GetObjects()))
            {
                 ObjectManager.Instance.DeregisterSmartObject(obj);
            }
            Application.LoadLevel(Application.loadedLevel);
        });

        
        return result;
    }