Exemple #1
0
        public void SetClickHandler(IClickHandler newHandler)
        {
            if (newHandler == ClickHandler)
            {
                return;
            }

            ClickHandler?.Disable(game);
            ClickHandler = newHandler;
            newHandler?.Enable(game);
        }
        /// <summary>
        /// Builds a menu based on the parameters given
        /// </summary>
        /// <typeparam name="T">The type of data the menu should hold</typeparam>
        /// <param name="parentControl">The parent control this menu resides in</param>
        /// <param name="appearance">The appearance of the menu<para>Leave null for default values</para></param>
        /// <param name="menuDrawer">The menu drawer to use when the menu needs to be drawn</param>
        /// <param name="tabDrawer">The tab drawer to use when a tab needs to be drawn</param>
        /// <param name="clickHandler">The click handler to use with the menu</param>
        /// <param name="locationDrawer">The location drawer the tab uses to finalize location dependent tab visuals</param>
        /// <param name="eventFunction">The function to execute when the tab changes</param>
        /// <returns>A Menu that conforms to the given parameters</returns>
        public static IMenu <T> Build <T>(Control parentControl, MenuAppearance appearance = null, IMenuDrawer menuDrawer = null, ITabDrawer tabDrawer = null, IClickHandler clickHandler = null, ITabLocationDrawer locationDrawer = null, EventHandler <TabChangedEventArgs <T> > eventFunction = null)
        {
            var menu = new Menu <T> {
                appearance       = appearance ?? MenuAppearance.GetDefaultAppearance(),
                allowRightClick  = false,
                parentControl    = parentControl,
                currentTabIndex  = -1,
                currentMouseMode = MouseModes.mouseClick,
                menuDrawer       = menuDrawer ?? new VerticalMenuDrawer(),
                tabDrawer        = tabDrawer ?? new VerticalTabDrawer(),
                clickHandler     = clickHandler ?? new VerticalClickHandler(),
            };

            parentControl.Paint      += menu.OnDraw;
            parentControl.MouseClick += menu.OnClick;

            if (locationDrawer != null)
            {
                menu.tabDrawer.tabLocationDrawer = locationDrawer;
            }

            if (eventFunction != null)
            {
                menu.tabChanged += eventFunction;
            }

            return(menu);
        }
Exemple #3
0
 public ConsoleMouseDriver(IClickHandler clickHandler)
 {
     this.clickHandler = clickHandler;
     inputHandle       = GetStdHandle(InputHandle);
 }
        public void InitializeSystems()
        {
            Singleton<DrawSystem>.Instance.Initialize();
            Singleton<MoveSystem>.Instance.Initialize();
            Singleton<LightSystem>.Instance.Initialize();
            Singleton<MapSystem>.Instance.Initialize();
            Singleton<ConstructionSystem>.Instance.Initialize();
            Singleton<InventorySystem>.Instance.Initialize();
            Singleton<MenuSystem>.Instance.Initialize();

            _curHandler = Singleton<MapSystem>.Instance;
        }