public void initialise(ASPTextureEdit textureEdit, int count)
        {
            _windowID = _nextID;
            ++_nextID;

            _textureEdit = textureEdit;
            _windowPosition = new Rect(700, 200 -((count) * 100), 400, 400);
            _locked = false;
            _remakePreview = true;

            _imageModifiers = _textureEdit.cloneImageModifiers();
            _baseTexture = _textureEdit.cloneBaseTexture();
            _baseTexture.gui().initialise(this);
            _imageModifiers.guiInit(this);

            _boundingBox = _textureEdit.cloneBoundingBox();
            _bbXselector = new ValueSelector<int, IntField>(_boundingBox.x, 0, 999999, 1, "Bottom Left X", Color.white);
            _bbYselector = new ValueSelector<int, IntField>(_boundingBox.y, 0, 999999, 1, "Bottom Left Y", Color.white);
            _bbWselector = new ValueSelector<int, IntField>(_boundingBox.w, 0, 999999, 1, "Width", Color.white);
            _bbHselector = new ValueSelector<int, IntField>(_boundingBox.h, 0, 999999, 1, "Height", Color.white);

            _selectedModifier = -2;

            Global.LastButtonPress = 0f;
            Global.AutoRepeatGap = 0.4f;
        }
 public void setImageModifiers(ImageModifiers imageModifiers)
 {
     _imageModifiers = imageModifiers.clone();
 }
        private void loadConfig(ConfigNode node)
        {
            if (Global.Debug3) Utils.Log("loadConfig start");

            _ok = false;
            _transformNames = null;
            _transforms = null;
            kspTextureInfo = null;
            if (_gui != null) Destroy(_gui);
            _gui = null;
            _boundingBox = null;
            _transformsOption = TransformOption.USE_ALL;
            if (_baseTexture != null) _baseTexture.cleanUp();
            _baseTexture = null;
            if (_imageModifiers != null) _imageModifiers.cleanUp();
            _imageModifiers = null;

            if (node.HasNode("ASP_BOUNDINGBOX"))
            {
                if (_boundingBox == null) _boundingBox = new BoundingBox();
                ConfigNode n = node.GetNode("ASP_BOUNDINGBOX");
                _boundingBox.load(n);
            }

            if (node.HasValue("transformsOption")) _transformsOption = (TransformOption)ConfigNode.ParseEnum(typeof(TransformOption), node.GetValue("transformsOption"));

            if (node.HasNode("ASP_BASETEXTURE"))
            {
                ConfigNode n = node.GetNode("ASP_BASETEXTURE");
                _baseTexture = IM.BaseTexture.CreateBaseTexture(n);
                _baseTexture.load(n);
            }

            if (node.HasNode("ASP_IMAGEMODIFIERS"))
            {
                _imageModifiers = new ImageModifiers();
                ConfigNode n = node.GetNode("ASP_IMAGEMODIFIERS");
                _imageModifiers.load(n);
            }

            if (label != string.Empty) Events["editTextureEvent"].guiName = label;
        }
        public override void OnStart(StartState state)
        {
            if (Global.Debug2) Utils.Log("state {0}", state.ToString());
            base.OnStart(state);

            // side step serialization issues and use the saved config
            _startState = state;
            if (state == StartState.Editor)
            {
                if (originalConfig == null)
                {
                    if (Global.Debug1) Utils.Log("originalConfig is null");
                }
                else loadConfig(originalConfig);
            }

            if (label != string.Empty) Events["editTextureEvent"].guiName = label;

            _ok = false;
            try
            {
                if (Global.Debug1) Utils.Log("part {0}", this.part.name);

                fillTransformNamesList();
                fillTransformsList();

                if (_transforms == null || _transforms[0] == null)
                {
                    Utils.LogError("No useable transforms, disabling plugin");
                    return;
                }

                findTextures();

                if (_imageModifiers == null) _imageModifiers = new ImageModifiers();
                if (_boundingBox == null) _boundingBox = new BoundingBox();
                if (_baseTexture == null) _baseTexture = new IM.AutoBaseTexture();

                _baseTexture.set(kspTextureInfo);

                if (!_baseTexture.valid)
                {
                    Utils.LogError("invalid base texture trying auto");
                    _baseTexture = new IM.AutoBaseTexture();
                    _baseTexture.set(kspTextureInfo);
                }

                if (_baseTexture.valid)
                {
                    if (_imageModifiers.modifiers.Count > 0) writeTexture();
                    _ok = true;
                }
            }
            catch
            {
                Utils.LogError("Something went wrong in OnStart disabling plugin");
            }
        }