protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressCloseLibrary pressCloseLibrary)
     {
         AddListener(pressCloseLibrary.CloseLibrary);
     }
 }
Exemplo n.º 2
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressEndTurn pressEndTurn)
     {
         AddListener(pressEndTurn.PressRandomMove);
     }
 }
Exemplo n.º 3
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressDamage passTurn)
     {
         AddListener(passTurn.PressDamageMove);
     }
 }
Exemplo n.º 4
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressReveal pressReveal)
     {
         AddListener(pressReveal.Reveal);
     }
 }
Exemplo n.º 5
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressWin win)
     {
         AddListener(win.PressWin);
     }
 }
Exemplo n.º 6
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IFinishBattle finish)
     {
         AddListener(finish.FinishBattle);
     }
 }
Exemplo n.º 7
0
        public Button(string name, IButtonHandler handler)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }

            _handler           = handler;
            Name               = name;
            Width              = 50;
            Height             = 20;
            Location           = new Vector2(100, 100);
            Enabled            = true;
            Visible            = true;
            Text               = "My Button";
            Color              = Color.LightGray;
            OutlineColor       = Color.Gray;
            MouseOverColor     = Color.Gray;
            TextColor          = Color.Black;
            MouseOverTextColor = Color.Khaki;

            DrawWindowChrome = true;
            _font            = Engine.Content.Load <SpriteFont>("default");
        }
Exemplo n.º 8
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressPassTurn pressRandom)
     {
         AddListener(pressRandom.PassTurn);
     }
 }
Exemplo n.º 9
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressDraw pressDraw)
     {
         AddListener(pressDraw.Draw);
     }
 }
Exemplo n.º 10
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressLose lose)
     {
         AddListener(lose.PressLose);
     }
 }
Exemplo n.º 11
0
        public static void MapText(IButtonHandler handler, IText button)
        {
            handler.PlatformView?.UpdateText(button);

            // Any text update requires that we update any attributed string formatting
            MapFormatting(handler, button);
        }
Exemplo n.º 12
0
 public static void MapLineBreakMode(IButtonHandler handler, IButton button)
 {
     if (button is ILineBreakMode lineBreakMode)
     {
         handler.PlatformView?.UpdateLineBreakMode(lineBreakMode);
     }
 }
Exemplo n.º 13
0
 protected override void OnSetHandler(IButtonHandler handler)
 {
     if (handler is IPressRestart restart)
     {
         AddListener(restart.PressRestart);
     }
 }
Exemplo n.º 14
0
 public static Task MapImageSourceAsync(IButtonHandler handler, IImage image)
 {
     if (image.Source == null)
     {
         return(Task.CompletedTask);
     }
     return(handler.ImageSourceLoader.UpdateImageSourceAsync());
 }
Exemplo n.º 15
0
    //private void RegisterButtonHandlerList()
    //{
    //    foreach (var btn in buttonList)
    //    {
    //        handler.RegistButtonHandler(btn.handler);
    //    }
    //}

    public IButtonHandler[] GetStaticButtonArray()
    {
        IButtonHandler[] btnArr = new IButtonHandler[buttonList.Count];
        for (int i = 0; i < btnArr.Length; i++)
        {
            btnArr[i] = buttonList[i].handler;
        }
        return(btnArr);
    }
Exemplo n.º 16
0
 private bool executeKeyDown(string key)
 {
     foreach (IOutputHandler handler in outputHandlers)
     {
         IButtonHandler buttonHandler = handler as IButtonHandler;
         if (buttonHandler != null)
         {
             if (buttonHandler.setButtonDown(key))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 17
0
        public void SetButtonHandler(int x, int y, IButtonHandler handler)
        {
            if (x >= 0 && x < 8 && y >= 0 && y < 8)
            {
                int index = GridCoordsToIndex(x, y);

                while (_handlers.Count <= index)
                {
                    _handlers.Add(null);
                }

                _handlers[index] = handler;

                UnityEditor.EditorUtility.SetDirty(this);
            }
        }
Exemplo n.º 18
0
    public void RegistButtonHandler(IButtonHandler btn)
    {
        LifeCheck();
        int id = btn.ID;

        if (HasButtonHandler(id))
        {
            RemoveButtonHandler(id);

            buttonHandlerList.Add(id, btn);
            btn.Initialize(this);
            log += string.Format("RegistButton(id:{1},btn{2})\n移除重覆ButtonHandler\n{0}\n\n", Utilty.CallStack(), id, btn);
        }
        else
        {
            buttonHandlerList.Add(id, btn);
            btn.Initialize(this);
            log += string.Format("RegistButton(id:{1},btn{2})\n{0}\n\n", Utilty.CallStack(), id, btn);
        }
        if (onButtonRegisted != null)
        {
            onButtonRegisted(this, new RegistButtonArgs(btn));
        }
    }
Exemplo n.º 19
0
        public bool GetLedState(GlowingButton button)
        {
            if (button.position == DeleteStoredDataButtonHandler.currentDeletePosition)
            {
                return(true);
            }

            IButtonHandler buttonHandler = GridController.gridConfig.GetButtonHandler(button.x, button.y);

            float   time   = (float)(UnityEditor.EditorApplication.timeSinceStartup - startTime) * frequency;
            Vector2 offset = DeleteStoredDataButtonHandler.currentDeletePosition - button.position;

            time -= offset.magnitude * 0.05f;

            if (buttonHandler != null &&
                buttonHandler is IDeleteStoredData &&
                (buttonHandler as IDeleteStoredData).HasStoredData)
            {
                IDeleteStoredData deleter = buttonHandler as IDeleteStoredData;
                return(time > 0 && (time < dutyCycleNormal || Mathf.Repeat((float)UnityEditor.EditorApplication.timeSinceStartup * frequency, 1) < dutyCycleOn));
            }

            return(time > 0 && time < dutyCycleNormal);
        }
Exemplo n.º 20
0
 public static void MapStrokeColor(IButtonHandler handler, IButtonStroke buttonStroke)
 {
     handler.PlatformView?.UpdateStrokeColor(buttonStroke);
 }
Exemplo n.º 21
0
 public static void MapLineBreakMode(IButtonHandler handler, Button button)
 {
     handler.PlatformView?.UpdateLineBreakMode(button);
 }
Exemplo n.º 22
0
 public static void MapFormatting(IButtonHandler handler, IText button)
 {
     // Update all of the attributed text formatting properties
     handler.PlatformView?.UpdateCharacterSpacing(button);
 }
Exemplo n.º 23
0
        public static void MapFont(IButtonHandler handler, ITextStyle button)
        {
            var fontManager = handler.GetRequiredService <IFontManager>();

            handler.PlatformView?.UpdateFont(button, fontManager);
        }
Exemplo n.º 24
0
 public static void MapPadding(IButtonHandler handler, IButton button)
 {
     handler.PlatformView?.UpdatePadding(button, DefaultPadding);
 }
Exemplo n.º 25
0
 public static void MapCharacterSpacing(IButtonHandler handler, ITextStyle button)
 {
     handler.PlatformView?.UpdateCharacterSpacing(button);
 }
Exemplo n.º 26
0
 public static void MapTextColor(IButtonHandler handler, ITextStyle button)
 {
     handler.PlatformView?.UpdateTextColor(button);
 }
Exemplo n.º 27
0
 public static void MapCornerRadius(IButtonHandler handler, IButtonStroke buttonStroke)
 {
     handler.PlatformView?.UpdateCornerRadius(buttonStroke);
 }
Exemplo n.º 28
0
 public static void MapStrokeThickness(IButtonHandler handler, IButtonStroke buttonStroke)
 {
     handler.PlatformView?.UpdateStrokeThickness(buttonStroke);
 }
Exemplo n.º 29
0
 /// <summary> Override this function to implement the funcionality. </summary>
 /// <param name="handler"></param>
 protected abstract void OnSetHandler(IButtonHandler handler);
Exemplo n.º 30
0
 public static void MapImageSource(IButtonHandler handler, IImage image) =>
 MapImageSourceAsync(handler, image).FireAndForget(handler);
Exemplo n.º 31
0
 void Setup()
 {
     SetButtons();
     _board = BoardFactory.GetFactory().GetDefaultBoard();
     _moveModule = MoveModule.GetBuilder().BoardIs(_board).Build();
     _buttonHandler = ButtonHandler.GetBuilder().BoardIs(_board).ButtonsAre(_buttons).Build();
     _buttonHandler.Update(null, null, null);
 }