Beispiel #1
0
 public ButtonWrapper(Rect defaultPosition, string imageFilename, string noImageText,
     string tooltip, Action onClickHandler, string configNodeName = "Icon")
 {
     button = ToolbarButton.Create(imageFilename, noImageText, tooltip, onClickHandler);
     if (button == null)
     {
         this.Log("Failed to create the toolbar button, using my Icon instead.");
         icon = new Icon<ButtonWrapper>(defaultPosition, imageFilename, noImageText, tooltip,
             onClickHandler, configNodeName);
     }
 }
Beispiel #2
0
 public ButtonWrapper(Rect defaultPosition, string imageFilename, string noImageText,
                      string tooltip, Action onClickHandler, string configNodeName = "Icon")
 {
     button = ToolbarButton.Create(imageFilename, noImageText, tooltip, onClickHandler);
     if (button == null)
     {
         this.Log("Failed to create the toolbar button, using my Icon instead.");
         icon = new Icon <ButtonWrapper>(defaultPosition, imageFilename, noImageText, tooltip,
                                         onClickHandler, configNodeName);
     }
 }
        public static ToolbarButton Create(string imageFilename, string noImageText,
            string tooltip, Action onClickHandler)
        {
            try
            {
                if (!typeInfoIsLoaded && !LoadTypeInfo())
                {
                    // The error was already logged in LoadTypeInfo
                    return null;
                }

                var b = ToolbarWrapper.AddButton("Tac", noImageText);
                if (b == null)
                {
                    LogWarningS("Failed to create the Toolbar Button");
                    return null;
                }

                ToolbarButton button = new ToolbarButton(b);
                button.ToolTip = tooltip;
                button.AddOnClickHandler(e => onClickHandler());

                if (GameDatabase.Instance.ExistsTexture(imageFilename))
                {
                    button.TexturePath = imageFilename;
                }
                else
                {
                    button.Text = noImageText;
                }

                button.Log("Create successful.");
                return button;
            }
            catch (Exception ex)
            {
                LogWarningS("Exception while creating the Toolbar button: " + ex.Message);
                return null;
            }
        }
Beispiel #4
0
        public static ToolbarButton Create(string imageFilename, string noImageText,
            string tooltip, Action onClickHandler)
        {
            try
            {
                if (!typeInfoIsLoaded && !LoadTypeInfo())
                {
                    // The error was already logged in LoadTypeInfo
                    return null;
                }

                var b = ToolbarWrapper.AddButton("Tac", noImageText);
                if (b == null)
                {
                    LogWarningS("Failed to create the Toolbar Button");
                    return null;
                }

                ToolbarButton button = new ToolbarButton(b);
                button.ToolTip = tooltip;
                button.AddOnClickHandler(e => onClickHandler());

                if (GameDatabase.Instance.ExistsTexture(imageFilename))
                {
                    button.TexturePath = imageFilename;
                }
                else
                {
                    button.Text = noImageText;
                }

                button.Log("Create successful.");
                return button;
            }
            catch (Exception ex)
            {
                LogWarningS("Exception while creating the Toolbar button: " + ex.Message);
                return null;
            }
        }