예제 #1
0
        public bool RegisterToggle(string modName, string buttonText, string hoverText, Action <string, int> callback,
                                   SpriteData state0Sprites,
                                   SpriteData state1Sprites)
        {
            Log.Message(string.Format("CorralRegistration.RegisterToggle()"));

            bool success = false;

            try
            {
                foreach (ModRegistrationInfo mri in RegisteredMods)
                {
                    if (mri.ModName == modName && mri.ButtonText == buttonText)
                    {
                        // already registered
                        Log.Warning(string.Format("CorralRegistration.RegisterToggle() - '{0}-{1}' already registered", modName, buttonText));

                        return(false);
                    }
                }

                // register it
                ToggleModRegistrationInfo newMRI = new ToggleModRegistrationInfo
                {
                    ModName           = modName,
                    ButtonText        = buttonText,
                    HoverText         = hoverText,
                    ToggleCallback    = callback,
                    SpriteInfo        = state0Sprites,
                    SpriteInfo_state2 = state1Sprites
                };

                // create new button...
                if (ModCorral.mcPanel != null)
                {
                    newMRI.ToggleButton = ModCorral.mcPanel.ScrollPanel.AddAToggleButton(newMRI);

                    ModCorral.UpdateNewCount();
                }

                RegisteredMods.Add(newMRI);
                success = true;

                Log.Message(string.Format("CorralRegistration.RegisterToggle() added mod: '{0}-{1}'", newMRI.ModName, newMRI.ButtonText));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("CorralRegistration.RegisterToggle() Exception: {0}", ex.Message));
            }

            return(success);
        }
예제 #2
0
        public bool Register(string modName, string buttonText, string hoverText, Action <string> callback,
                             string normalFgSpritename, Texture2D normalFgTexture,
                             string normalBgSpritename, Texture2D normalBgTexture,
                             string hoveredFgSpritename, Texture2D hoveredFgTexture,
                             string hoveredBgSpritename, Texture2D hoveredBgTexture,
                             string pressedFgSpritename, Texture2D pressedFgTexture,
                             string pressedBgSpritename, Texture2D pressedBgTexture
                             )
        {
            Log.Message(string.Format("CorralRegistration.Register()"));

            bool success = false;

            try
            {
                foreach (ModRegistrationInfo mri in RegisteredMods)
                {
                    if (mri.ModName == modName && mri.ButtonText == buttonText)
                    {
                        // already registered
                        Log.Warning(string.Format("CorralRegistration.Register() - '{0}-{1}' already registered", modName, buttonText));

                        return(false);
                    }
                }

                // register it
                ModRegistrationInfo newMRI = new ModRegistrationInfo
                {
                    ModName       = modName,
                    ButtonText    = buttonText,
                    HoverText     = hoverText,
                    ClickCallback = callback,
                    SpriteInfo    = new SpriteData()
                    {
                        NormalFgSpritename  = normalFgSpritename,
                        NormalFgTexture     = normalFgTexture,
                        NormalBgSpritename  = normalBgSpritename,
                        NormalBgTexture     = normalBgTexture,
                        HoveredFgSpritename = hoveredFgSpritename,
                        HoveredFgTexture    = hoveredFgTexture,
                        HoveredBgSpritename = hoveredBgSpritename,
                        HoveredBgTexture    = hoveredBgTexture,
                        PressedFgSpritename = pressedFgSpritename,
                        PressedFgTexture    = pressedFgTexture,
                        PressedBgSpritename = pressedBgSpritename,
                        PressedBgTexture    = pressedBgTexture
                    }
                };

                // create new button...
                if (ModCorral.mcPanel != null)
                {
                    newMRI.ModButton = ModCorral.mcPanel.ScrollPanel.AddAButton(newMRI);
                    ModCorral.UpdateNewCount();
                }

                RegisteredMods.Add(newMRI);
                success = true;

                Log.Message(string.Format("CorralRegistration.Register() added mod: '{0}-{1}'", newMRI.ModName, newMRI.ButtonText));
            }
            catch (Exception ex)
            {
                Log.Error(string.Format("CorralRegistration.Register() Exception: {0}", ex.Message));
            }

            return(success);
        }