Exemplo n.º 1
0
        public void swapSelectTexture(TerrainTextureButton but)
        {
            if (mSelectedButton != but)
            {
                TerrainTextureDef newDef  = null;
                TerrainTextureDef origDef = mSelectedDef;
                bool activeSel            = isActiveSetSelected();
                if (activeSel)
                {
                    newDef = SimTerrainType.getFromTypeName(but.typename);
                }
                else
                {
                    addSelectTexture(but);
                    newDef = mSelectedDef;
                }

                //replace across the board
                if (mSelectSwap)
                {
                    TerrainGlobals.getTexturing().swapActiveTextures(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                    SimTerrainType.swapActiveSetDef(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                }
                else if (mSelectReplace)
                {
                    if (SimTerrainType.getActiveSetIndex(newDef) == 0)
                    {
                        MessageBox.Show("You can not replace with the base texture");
                    }
                    else
                    {
                        TerrainGlobals.getTexturing().replaceActiveTexture(SimTerrainType.getActiveSetIndex(origDef), SimTerrainType.getActiveSetIndex(newDef));
                        SimTerrainType.removeActiveSetDef(origDef);
                    }
                }

                if (!activeSel)
                {
                    //now select our new texture
                    addSelectTexture(but);
                }
            }
            mSelectSwap     = false;
            mSelectReplace  = false;
            alertLabel.Text = "";

            TerrainGlobals.getTexturing().freeAllCaches();
            selectActiveSet();
            redrawPreviewList(0);
            SelectButton(but);

            //TerrainGlobals.getTexturing().reloadActiveTextures(true);
        }
Exemplo n.º 2
0
        public void apply()
        {
            string fName     = Path.GetFileNameWithoutExtension(mData.Texture);
            string dir       = Path.GetDirectoryName(mData.Texture);
            string themeName = dir.Substring(dir.LastIndexOf("\\") + 1);

            TerrainTextureDef SelectedDef = SimTerrainType.getFromTypeName(themeName + "_" + fName);

            TerrainGlobals.getTexturing().addActiveTexture(SimTerrainType.getWorkingTexName(SelectedDef));
            SimTerrainType.addActiveSetDef(SelectedDef);
            TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex = SimTerrainType.getActiveSetIndex(SelectedDef);


            TerrainGlobals.getEditor().applyTextureToMask();
        }
Exemplo n.º 3
0
        public void removeSelectedTexture()
        {
            if (mSelectedButton is TerrainTextureSplatButton)
            {
                if (TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex == 0)
                {
                    return;
                }

                if (SimTerrainType.mActiveWorkingSet.Count - 1 <= 0)
                {
                    return;
                }

                TerrainGlobals.getTexturing().removeActiveTexture(SimTerrainType.getActiveSetIndex(mSelectedDef));

                SimTerrainType.removeActiveSetDef(mSelectedDef);

                flowLayoutPanel1.Controls.Remove(mSelectedButton);
                SelectedDef = SimTerrainType.getDefsOfActiveSet()[0];
            }
            else
            {
                //   if (TerrainGlobals.getTerrainFrontEnd().SelectedTextureIndex == 0)
                //      return;

                int index = TerrainGlobals.getTexturing().getActiveDecalIndex(((TerrainTextureDecalButton)mSelectedButton).mFullFilename);
                TerrainGlobals.getTexturing().removeActiveDecal(index);


                flowLayoutPanel1.Controls.Remove(mSelectedButton);
                SelectedDef = SimTerrainType.getDefsOfActiveSet()[0];
            }
            redrawPreviewList(0);
            mSelectedButton = (TerrainTextureButton)flowLayoutPanel1.Controls[firstSplatIndex()];
        }